Submission #617224

#TimeUsernameProblemLanguageResultExecution timeMemory
617224A_DPaint By Numbers (IOI16_paint)C++14
0 / 100
0 ms212 KiB
#include "paint.h" #include <bits/stdc++.h> using namespace std; const int N=2e5+100; int pre[N]; int suf[N]; string solve_puzzle(string s,vector<int> c){ string ans=s; int n=s.size(); int k=c.size(); int sum=1; pre[0]=0; for(int i=1;i<n;i++){ if(pre[i-1]==k){ pre[i]=k; continue; } if(sum==c[pre[i-1]]){ pre[i]=pre[i-1]+1; i++; if(i==n)break; pre[i]=pre[i-1]; sum=1; } else{ pre[i]=pre[i-1]; sum++; } } sum=1; suf[n-1]=k-1; for(int i=n-2;i>=0;i--){ if(suf[i+1]==-1){ suf[i]=-1; continue; } if(sum==c[suf[i+1]]){ suf[i]=suf[i+1]-1; i--; if(i==-1)break; suf[i]=suf[i+1]; sum=1; } else{ suf[i]=suf[i+1]; sum++; } } if(suf[0]==-1){ ans[0]='?'; } else{ ans[0]='X'; } if(pre[n-1]==k){ ans[n-1]='?'; } else{ ans[n-1]='X'; } for(int i=1;i<n-1;i++){ if(pre[i]==suf[i]){ ans[i]='X'; if((pre[i]!=pre[i-1])&&(suf[i]!=suf[i+1])){ } } else{ if((pre[i]==suf[i]+1)&&(pre[i]!=pre[i-1])&&(suf[i]!=suf[i+1])){ ans[i]='_'; } else ans[i]='?'; } } for(int i=0;i<n;i++)cout<<pre[i]<<" ";cout<<"\n"; for(int i=0;i<n;i++)cout<<suf[i]<<" ";cout<<"\n"; return ans; }

Compilation message (stderr)

paint.cpp: In function 'std::string solve_puzzle(std::string, std::vector<int>)':
paint.cpp:83:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   83 |     for(int i=0;i<n;i++)cout<<pre[i]<<" ";cout<<"\n";
      |     ^~~
paint.cpp:83:43: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   83 |     for(int i=0;i<n;i++)cout<<pre[i]<<" ";cout<<"\n";
      |                                           ^~~~
paint.cpp:84:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   84 |     for(int i=0;i<n;i++)cout<<suf[i]<<" ";cout<<"\n";
      |     ^~~
paint.cpp:84:43: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   84 |     for(int i=0;i<n;i++)cout<<suf[i]<<" ";cout<<"\n";
      |                                           ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...