Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: UNJE0o
Problemset: ห่วงโซ่ (Chain)
Language: cpp
Time: 0.032 second
Submitted On: 2026-10-12 08:51:08
#include <bits/stdc++.h>
#define en '\n'
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);
string s;
getline(cin,s);
int n,h,w;cin >> n;
h = n+1;
w = (2*n + 1) * s.size() - (2*(s.size() - 1));
// cout << h << " " << w << en;
char bx[h][w];
for(int i = 0;i < h;i++){
for(int j = 0;j < w;j++) bx[i][j] = '.';
}
int pos = 0;
for(int i = n;i < w;i+= (2*n) - 1) {
bx[0][i] = s[pos];
for(int j = 1;j < h;j++){
bx[j][i-j] = s[pos];
bx[j][i+j] = s[pos];
}
pos+=1;
}
// for(int i = 1;i < h;i++){
// for(int j = 0;j < w;j++){
// if(bx[i-1][j+1] != '.'){
// bx[i][j] = bx[i-1][j+1];
// }
// if(bx[i-1][j-1] != '.'){
// bx[i][j] = bx[i-1][j-1];
// }
// }
// }
for(int i = 0;i < h;i++){
for(int j = 0;j < w;j++){
cout << bx[i][j];
} cout << en;
}
for(int i = h-2;i >= 0;i--){
for(int j = 0;j < w;j++){
cout << bx[i][j];
} cout << en;
}
}