제출 #123115

#제출 시각아이디문제언어결과실행 시간메모리
123115baqargamPaint By Numbers (IOI16_paint)C++14
7 / 100
2 ms376 KiB
#include<bits/stdc++.h> #include "paint.h" using namespace std; int n,k,res[200005],ones[200005],z[200005],val; bool pre[200005][105],su[200005][105]; string s,ret; vector<int>c; int v(int id){ if(s[id]=='X') return 1; if(s[id]=='_') return 0; if(s[id]=='.') return -1; } string solve_puzzle(string ss, vector<int> c) { s=ss; n=s.size(); k=c.size(); for(int i=1;i<=n;i++){ if(s[i-1]=='_') z[i]=1; z[i]+=z[i-1]; } for(int i=1;i<=n;i++){ val=v(i-1); if(val==1) break; pre[i][0]=1; } for(int i=n;i>0;i--){ val=v(i-1); if(val==1) break; su[i][0]=1; } pre[0][0]=1; su[n+1][0]=1; for(int i=1;i<=n;i++){//prefix val=v(i-1); //cout<<i<<" "<<val<<endl; if(val!=0)//1 & -1 { for(int j=1;j<=k;j++){//cout<<c[j-1]<<" "; if(i-c[j-1]+1>=1) if((pre[i-c[j-1]-1][j-1] || (i==c[j-1] && j==1)) && (z[i]-z[i-c[j-1]]==0))pre[i][j]=1; } } if(val<=0)//0 & -1 { for(int j=1;j<=k;j++){ if(pre[i-1][j])pre[i][j]=1; } } } reverse(c.begin(),c.end()); for(int i=n;i>0;i--){//sufix val=v(i-1); //cout<<i<<" "<<val<<endl; if(val!=0)//1 & -1 { for(int j=1;j<=k;j++){//cout<<c[j-1]<<" "; if(i+c[j-1]-1<=n) if((su[i+c[j-1]+1][j-1] || (i+c[j-1]-1==n && j==1)) && !(z[i+c[j-1]-1]-z[i-1]))su[i][j]=1; } } if(val<=0)//0 & -1 { for(int j=1;j<=k;j++){ if(su[i+1][j])su[i][j]=1; } } } for(int i=1;i<=n;i++){ if(s[i-1]=='X') continue; for(int j=0;j<=k;j++){ //cout<<i<<" "<<j<<" "<<pre[i][j]<<endl; if(pre[i-1][j]&&su[i+1][k-j]) {res[i]=1;} } } reverse(c.begin(),c.end()); // cout<<su[1+c[0]+1][0]<<endl; for(int i=1;i<=k;i++){ for(int j=1;j+c[i-1]-1<=n;j++){ if((z[j+c[i-1]-1]-z[j-1])==0 && (pre[j-2][i-1] || j==1) && (su[j+c[i-1]+1][k-i] || (j+c[i-1]-1)==n)) {ones[j]++;ones[j+c[i-1]]--;} } } for(int i=1;i<=n;i++){ ones[i]+=ones[i-1]; if(ones[i]>0) res[i]+=2; } for(int i=1;i<=n;i++){ if(res[i]==1) ret+='_'; if(res[i]==2) ret+='X'; if(res[i]==3) ret+='?'; } return ret; }

컴파일 시 표준 에러 (stderr) 메시지

paint.cpp: In function 'int v(int)':
paint.cpp:15:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
#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...