Submission
Status:
-----PP---
Subtask/Task Score:
20/100
Score: 20
User: anusitt
Problemset: ห่วงโซ่ (Chain)
Language: cpp
Time: 0.035 second
Submitted On: 2026-07-03 21:42:19
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
string S;
int h;
if (!(cin >> S >> h)) return 0;
int L = S.length();
int total_rows = 2 * h + 1;
int total_cols = 2 * h * L + 1;
for (int r = 0; r < total_rows; ++r) {
int diff_r = abs(r - h);
for (int c = 0; c < total_cols; ++c) {
int approx_i = c / (2 * h);
char current_char = '.';
for (int i = approx_i - 1; i <= approx_i + 1; ++i) {
if (i >= 0 && i < L) {
int center_c = h + (i * 2 * h);
if (diff_r + abs(c - center_c) == h) {
current_char = S[i];
break;
}
}
}
cout << current_char;
}
cout << "\n";
}
return 0;
}