Submission

Status:

-----PP---

Subtask/Task Score:

20/100

Score: 20

User: anusitt

Problemset: ห่วงโซ่ (Chain)

Language: cpp

Time: 0.345 second

Submitted On: 2026-07-03 21:39:54

/*
TASK: chain
LANG: C++
AUTHOR: YourName YourLastName
CENTER: SUT
*/
#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) {
       
        for (int c = 0; c < total_cols; ++c) {
            char current_char = '.'; 
            
            for (int i = 0; i < L; ++i) {
                int center_c = h + (i * 2 * h); 
                
                if (abs(r - h) + abs(c - center_c) == h) {
                    current_char = S[i];
                    break; 
                }
            }
            cout << current_char;
        }
        cout << "\n";
    }

    return 0;
}