Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: speedbuffalo99

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

Language: cpp

Time: 0.004 second

Submitted On: 2026-10-15 16:26:54

#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
using namespace std;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int h;
    string s;
    cin >> s;
    cin >> h;
    
    int row = 2*h + 1;
    int step = 2 * h - 1;
    int col = (int)s.size() * step + 2 * h - step + 1;
    
    
    vector<string> a(row, string(col, '.'));
    for (int k=0;k<s.size();k++) {
    	int start = k*step;
    	
    	for (int i=0;i<=2*h;i++) {
    		int left, right = 0;
    		left = abs(h-i);
    		right = 2*h - abs(h-i);
    		
     	a[i][start + left] = s[k];
        a[i][start + right] = s[k];
		}
	}
	for (int i=0;i<row;i++) {
		cout << a[i] << '\n';
	}
    return 0;
}