Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: nate213121
Problemset: ห่วงโซ่ (Chain)
Language: cpp
Time: 0.047 second
Submitted On: 2026-09-18 20:59:04
#include <bits/stdc++.h>
using namespace std;
int main()
{
string in;
cin >> in;
int n;
cin >> n;
int currTopCol = n;
vector<vector<char>> v((n * 2 + 1), vector<char>(in.size() * (n * 2 + 1) - (in.size() - 1) * 2, '.'));
for(auto& currChar:in)
{
int col = currTopCol;
for(int row = 0; row <= n; row++)
{
v[row][col] = currChar;
col--;
}
col = currTopCol;
col += n;
for(int row = n; row < v.size(); row++)
{
v[row][col] = currChar;
col--;
}
col = currTopCol;
for(int row = 0; row <= n; row++)
{
v[row][col] = currChar;
col++;
}
col = currTopCol;
col -= n;
for(int row = n; row < v.size(); row++)
{
v[row][col] = currChar;
col++;
}
currTopCol += (n * 2 - 1);
}
for(int i = 0; i < v.size(); i++)
{
for(int j = 0; j < v[i].size(); j++)
{
cout << v[i][j];
}
cout << endl;
}
}