Submission #593116

#TimeUsernameProblemLanguageResultExecution timeMemory
593116Koosha_mvPaint By Numbers (IOI16_paint)C++14
59 / 100
1 ms340 KiB
#include "paint.h" #include <bits/stdc++.h> using namespace std; #define dbgv(v) cout<<#v<<" = "; f(i,0,v.size()) cout<<v[i]<<" "; cout<<endl #define dbga(a,x,y) cout<<#a<<" = "; f(i,x,y) cout<<a[i]<<" "; cout<<endl #define erorp(x) cout<<#x<<"={"<<x.F<<" , "<<x.S<<"}"<<endl #define eror(x) cout<<#x<<'='<<(x)<<endl #define f_(i,a,b) for(int i=a;i>=b;i--) #define f(i,a,b) for(int i=a;i<b;i++) #define nb(x) __builtin_popcount(x) #define all(v) v.begin(),v.end() #define bit(n,k) (((n)>>(k))&1) #define Add(x,y) x=(x+y)%mod #define maxm(a,b) a=max(a,b) #define minm(a,b) a=min(a,b) #define lst(x) x[x.size()-1] #define sz(x) int(x.size()) #define mp make_pair #define ll long long #define pb push_back #define S second #define F first const int N=2e5+99,K=111; int n,k,a[N],ps[N],ans[N]; bool dp[N][K],pd[N][K]; string s; string solve_puzzle(string _s,vector<int> c) { n=_s.size(),k=c.size(); s=' '+_s+' '; dp[0][0]=pd[n+1][0]=pd[n+2][0]=1; f(i,1,n+1) ps[i]=ps[i-1]+(s[i]=='_'); f_(i,n,1){ f(j,0,k+1){ if(s[i]!='X') pd[i][j]=pd[i+1][j]; if(j>0 && n-i+1>=c[k-j] && ps[i-1]==ps[i+c[k-j]-1] && s[i+c[k-j]+1]!='X'){ pd[i][j]|=pd[i+c[k-j]+1][j-1]; } //cout<<i<<" "<<j<<" -> "<<pd[i][j]<<endl; } } f(i,1,n+1){ f(j,0,k+1){ if(s[i]!='X') dp[i][j]=dp[i-1][j]; if(j>0 && i>=c[j-1] && ps[i]==ps[i-c[j-1]] && s[i-c[j-1]]!='X'){ if(!(i==c[j-1] && j>1) && !(i>c[j-1] && dp[i-c[j-1]-1][j-1]==0)){ dp[i][j]=1; if(s[i+1]!='X' && pd[i+2][k-j]){ a[i-c[j-1]+1]++; a[i+1]--; } } } ////cout<<i<<" "<<j<<" -> "<<dp[i][j]<<endl; } } string res; f(i,1,n+1){ a[i]+=a[i-1]; if(a[i]>0) ans[i]=1; } f(i,1,n+1){ if(s[i]=='X') continue ; f(j,0,k+1){ if(dp[i-1][j] && pd[i+1][k-j]){ ans[i]|=2; } } } f(i,1,n+1){ if(ans[i]==1){ res+='X'; } if(ans[i]==2){ res+='_'; } if(ans[i]==3){ res+='?'; } } //dbga(ans,1,n+1); return res; }
#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...