제출 #617766

#제출 시각아이디문제언어결과실행 시간메모리
617766A_DPaint By Numbers (IOI16_paint)C++14
0 / 100
1 ms340 KiB
#include "paint.h" #include <bits/stdc++.h> using namespace std; const int N=2e5+100; int n,k; string ss; vector<int> cc; int ok_(int u) { int lst=0,sum=0; for(int i=0;i<n;i++){ int cnt=0; for(int j=i;j<n;j++){ if(ss[j]=='.'||j==u){ cnt++; } else{ break; } } if(sum+cnt<=cc[lst]){ sum++; if(sum==cc[lst]){ lst++; if(lst==k)return 1; i++; sum=0; } } } return 0; } int okxx(int u,int h) { int sum=0,lst=0; for(int i=0;i<n;i++){ int cnt=0; for(int j=i;j<n;j++){ if(ss[j]=='.'||j==u){ cnt++; } else{ break; } } if(sum==cc[lst]){ sum=0; lst++; if(lst==k)return 1; } if(lst==h){ if(i+min(cnt-1,cc[lst]-1)>=u){ sum++; } if(i==u&&sum+cnt-1<cc[lst])return 0; } else{ if(i==u)return 0; if(cnt+sum>=cc[lst]){ sum++; if(sum==cc[lst]){ sum=0; lst++; i++; if(lst==k)return 1; } } } } } int okx(int u) { for(int h=0;h<n;h++){ if(okxx(u,h))return 1; } } string solve_puzzle(string s,vector<int> c){ string ans=s; ss=s; n=s.size(); k=c.size(); for(int i=0;i<s.size();i++){ if(s[i]!='.')continue; int ok=okx(i); ok+=2*ok_(i); if(ok==1)ans[i]='X'; if(ok==2)ans[i]='_'; if(ok==3)ans[i]='?'; } return ans; }

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

paint.cpp: In function 'std::string solve_puzzle(std::string, std::vector<int>)':
paint.cpp:89:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   89 |     for(int i=0;i<s.size();i++){
      |                 ~^~~~~~~~~
paint.cpp: In function 'int okxx(int, int)':
paint.cpp:74:1: warning: control reaches end of non-void function [-Wreturn-type]
   74 | }
      | ^
paint.cpp: In function 'int okx(int)':
paint.cpp:80:1: warning: control reaches end of non-void function [-Wreturn-type]
   80 | }
      | ^
#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...