Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: spammer_destroyer
Problemset: กราฟสัญญาณดิจิทัล
Language: cpp
Time: 0.002 second
Submitted On: 2025-10-22 18:27:43
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
using namespace std;
void show(vector<vector<char>> arr, int n, int len) {
int i,j;
for(i=0;i<n;i++) {
for(j=0;j<(n-1)*len+1;j++) {
cout << arr[i][j];
}
cout << "\n";
}
}
int main()
{
bool change=false;
string str,str1;
int i,j,l,k,n,left,num;
cin >> str >> n;
int len=str.length();
for(l=0;l<len;l++) {
if(str[l]>=65){change=true;}
}
//alphabet to binary
if(change==true) {
str1="";
string bi="12345678";
for(l=0;l<len;l++) {
num=(int)str[l];
for(k=7;k>=0;k--) {
bi[k]=(char)(num%2+'0');
num/=2;
}
str1+=bi;
}
str=str1;
}
len=str.length();
/////////////////////
vector<vector<char>> arr(n,vector<char>((n-1)*len+1,'_'));
int x,y,a,b;
char last='1';
j=0;
for(l=0;l<len;l++) {
//switch rank system
if(str[l]!=last) {
for(i=0;i<n;i++) {
arr[i][j]='x';
}
}
//find current rank
if(str[l]=='1'){i=0;}
else if(str[l]=='0'){i=n-1;}
//move to next position
for(a=0;a<n;a++) {
arr[i][j]='x';
j++;
}
j-=1;
last=str[l];
}
show(arr,n,len);
return 0;
}