제출 #617210

#제출 시각아이디문제언어결과실행 시간메모리
617210A_DPaint By Numbers (IOI16_paint)C++14
0 / 100
1 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++; pre[i]=pre[i-1]; sum=0; } 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--; suf[i]=suf[i-1]; sum=0; } else{ suf[i]=suf[i+1]; sum++; } } if(suf[1]==k){ ans[0]='?'; } else{ ans[0]='X'; } if(pre[n-2]==k){ ans[n-1]='?'; } else{ ans[n-1]='X'; } for(int i=1;i<n;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; }
#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...