제출 #617761

#제출 시각아이디문제언어결과실행 시간메모리
617761A_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 okx(int u) { int sum=0,lst=0; for(int h=0;h<n;h++){ 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])goto d; } else{ if(i==u)goto d; if(cnt+sum>=cc[lst]){ sum++; if(sum==cc[lst]){ sum=0; lst++; i++; if(lst==k)return 1; } } } } d: ; } } 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:86:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   86 |     for(int i=0;i<s.size();i++){
      |                 ~^~~~~~~~~
paint.cpp: In function 'int okx(int)':
paint.cpp:77:1: warning: control reaches end of non-void function [-Wreturn-type]
   77 | }
      | ^
#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...