Submission #792344

#TimeUsernameProblemLanguageResultExecution timeMemory
7923441075508020060209tcCrtanje (COCI20_crtanje)C++14
50 / 50
1 ms340 KiB
#pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx,popcnt,sse4,abm") #include<bits/stdc++.h> //#pragma GCC target("popcnt") using namespace std; #define int long long int n; string s; int ar[200005]; int ps[200005]; int chmn; int chmx; string ans[500]; signed main() { cin>>n>>s; for(int i=1;i<=300;i++){ ans[i]="*"; for(int j=1;j<=n;j++){ ans[i]+="."; } } s="*"+s; chmn=0; chmx=0; for(int i=1;i<=n;i++){ if(s[i]=='='){ ps[i]=ps[i-1]; } if(s[i]=='+'){ ps[i]=ps[i-1]+1; } if(s[i]=='-'){ ps[i]=ps[i-1]-1; } if(i==n){continue;} chmn=min(chmn,ps[i]); chmx=max(chmx,ps[i]); } int nwx=chmx+1; if(s[1]=='='){ans[nwx][1]='_';} if(s[1]=='+'){ans[nwx][1]='/';} if(s[1]=='-'){ans[nwx][1]='a'-5;} for(int i=2;i<=n;i++){ if(s[i]=='='){ if(s[i-1]=='='||s[i-1]=='-'){ ans[nwx][i]='_'; }else{ ans[--nwx][i]='_'; } } if(s[i]=='+'){ if(s[i-1]=='+'){ ans[--nwx][i]='/'; }else{ ans[nwx][i]='/'; } } if(s[i]=='-'){ if(s[i-1]=='-'||s[i-1]=='='){ ans[++nwx][i]='a'-5; }else{ ans[nwx][i]='a'-5; } } } for(int i=1;i<=chmx-chmn+1;i++){ int ok=0; for(int j=1;j<=n;j++){ if(ans[i][j]!='.'){ok=1;} } if(!ok){continue;} for(int j=1;j<=n;j++){ cout<<ans[i][j]; }cout<<endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...