Submission #473777

#TimeUsernameProblemLanguageResultExecution timeMemory
473777Ahmed_SolymanCrtanje (COCI20_crtanje)C++14
50 / 50
171 ms16224 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll n; ll valid(ll i){ if(i>=0 && i<n)return 1; return 0; } char con(char c){ if(c=='+')return '/'; else if(c=='-')return 92; else return '_'; } int main() { cin>>n; string s;cin>>s; vector<vector<char>>ans(500,vector<char>(500,'.')); for(ll start=0;start<n;start++){ ll prev=-1; vector<vector<char>>temp(500,vector<char>(500,'.')); bool b=1; char c; for(ll i=0;i<n;i++){ if(prev==-1){ temp[start][i]=con(s[i]); prev=start; c=s[i]; } else{ ll x=0; if(s[i]=='-' && c!='+')x++; else if(s[i]!='-' && c=='+')x--; ll j=prev+x; if(!valid(j)){ b=0; break; } else{ temp[j][i]=con(s[i]); prev=j; c=s[i]; } } } if(b){ ans=temp; break; } } map<pair<ll,ll>,bool>un_valid; for(ll i=0;i<500;i++){ bool b=0; for(ll j=0;j<500;j++){ b|=(ans[i][j]!='.'); } if(!b){ for(ll j=0;j<500;j++){ un_valid[{i,j}]=1; } } } for(ll i=0;i<500;i++){ bool b=0; for(ll j=0;j<500;j++){ b|=(ans[j][i]!='.'); } if(!b){ for(ll j=0;j<500;j++){ un_valid[{j,i}]=1; } } } for(ll i=0;i<n;i++){ bool b=0; for(ll j=0;j<n;j++){ if(un_valid[{i,j}]){ continue; } b=1; cout<<ans[i][j]; } if(b)cout<<endl; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...