Submission

Status:

PPPPxxxxxx

Subtask/Task Score:

40/100

Score: 40

User: UNJE0o

Problemset: กราฟสัญญาณดิจิทัล

Language: cpp

Time: 0.003 second

Submitted On: 2026-10-13 13:01:24

// #include<iostream>
// #include<string>
#include<bits/stdc++.h>
using namespace std;
#define en '\n'

int main(){
    string sig; cin >> sig;
    int n,len = sig.size(),s;
    cin >> n;

    s = len*n;

    char bx[n][s];

    for(int i = 0;i < n;i++){
        for(int j = 0;j < s;j++) {
            bx[i][j] = '_';
        }
    }

    int y,pos = 0;
    for(int i = 0;i < len;i++){

        pos += n;

        if(sig[i] == '1') y = 0;

        else if(sig[i] == '0') y = n-1;
        
        for(int j = pos-n; j < pos  && j < s;j++){
            bx[y][j] = 'x';
        }
        pos -= 1;

        
        

    }

    if(bx[0][0] == '_'){
        for(int i = 0;i < n;i++){
            bx[i][0] = 'x';
        }
    }

    for(int j = 1;j < pos+1;j++){
        if((bx[0][j] == 'x' && bx[0][j-1] == '_') ||
           (bx[0][j] == 'x' && bx[0][j+1] == '_' && j+1 < pos+1)){
            for(int i = 0;i < n;i++) bx[i][j] = 'x';
        }
    }

    for(int i = 0;i < n;i++){
        for(int j = 0;j < pos+1;j++){
            cout << bx[i][j];
        } cout << en;
    }
}