제출 #96295

#제출 시각아이디문제언어결과실행 시간메모리
96295figter001Paint By Numbers (IOI16_paint)C++14
100 / 100
639 ms104676 KiB
#include "paint.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 2e5+50; const int maxk = 110; int n; vector<int> c; string s; int dp[maxn][maxk],sum[maxn]; bool can[maxn][2]; int calc(int idx,int at){ if(idx >= n)return (at == (int)c.size()); int &res = dp[idx][at]; if(res != -1)return res; res = 0; if(s[idx] == 'X'){ if(at == c.size())return res; int to = idx + c[at] - 1; if(to >= n)return res; int cur = sum[to]; if(idx)cur -= sum[idx-1]; if(cur)return res = 0; if(s[to + 1] == 'X')return res = 0; res = calc(to+2,at+1); if(res){ can[to+1][1] = 1; for(int i=idx;i<=to;i++)can[i][0] = 1; } } else if(s[idx] == '_'){ res = calc(idx+1,at); }else{ res = calc(idx+1,at); if(res)can[idx][1] = 1; if(at != c.size()){ int to = idx + c[at] - 1; if(to < n){ int cur = sum[to]; if(idx)cur -= sum[idx-1]; if(!cur){ if(s[to + 1] != 'X'){ res |= calc(to+2,at+1); if(calc(to+2,at+1)){ can[to+1][1] = 1; for(int i=idx;i<=to;i++)can[i][0] = 1; } } } } } } return res; } string solve_puzzle(string S, vector<int> C){ memset(dp,-1,sizeof(dp)); n = S.size(); c = C; s = S; for(int i=0;i<n;i++){ sum[i] = s[i] == '_'; if(i)sum[i]+=sum[i-1]; } calc(0,0); string ans; for(int i=0;i<n;i++){ if(s[i] == '.'){ if(can[i][0] && can[i][1])ans += '?'; else if(can[i][1])ans += '_'; else ans += 'X'; }else ans += s[i]; } return ans; }

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

paint.cpp: In function 'int calc(int, int)':
paint.cpp:22:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(at == c.size())return res;
      ~~~^~~~~~~~~~~
paint.cpp:40:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(at != c.size()){
      ~~~^~~~~~~~~~~
#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...