Submission #414910

#TimeUsernameProblemLanguageResultExecution timeMemory
414910Ahmadsm2005Paint By Numbers (IOI16_paint)C++14
100 / 100
976 ms36424 KiB
#include "paint.h" //#include "grader.cpp" #include <bits/stdc++.h> using namespace std; bool CAN2[200003]; int8_t DP[200001][101]; int ACC[200003],L[200003],R[200003]; vector<int>F; string t; bool REC(int idx,int CUR){ if(idx>=t.size()&&CUR+1==F.size()) return 1; else if(idx>=t.size()) return 0; if(DP[idx][CUR]+1) return DP[idx][CUR]; DP[idx][CUR]=0; if((F[CUR]+idx)<=t.size()){ if(ACC[idx+F[CUR]]-ACC[idx]) goto a; if((idx+F[CUR]>=t.size())||(t[idx+F[CUR]]!='X')) if(REC(idx+F[CUR]+1,CUR+1)){ L[idx]++,R[idx+F[CUR]-1]++; CAN2[idx+F[CUR]]=1; DP[idx][CUR]=1; } } a:; if(t[idx]!='X'){ if(REC(idx+1,CUR)){ CAN2[idx]=1; DP[idx][CUR]=1; } } return DP[idx][CUR]; } string solve_puzzle(string s,vector<int>c){ F=c; F.push_back(INT_MAX); t=s; ACC[0]=0; for(int i=1;i<=s.size();i++) ACC[i]+=ACC[i-1]+(s[i-1]=='_'?1:0); string ANS; for(int i=0;i<=200000;i++) for(int l=0;l<=100;l++) DP[i][l]=-1; REC(0,0); int ZZ=0; for(int i=0;i<s.size();i++){ ZZ+=L[i]; if(s[i]=='.'){ if(ZZ&&CAN2[i]) ANS+='?'; else if(ZZ) ANS+='X'; else ANS+='_'; } else ANS+=s[i]; ZZ-=R[i]; } return ANS; }

Compilation message (stderr)

paint.cpp: In function 'bool REC(int, int)':
paint.cpp:11:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 | if(idx>=t.size()&&CUR+1==F.size())
      |    ~~~^~~~~~~~~~
paint.cpp:11:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 | if(idx>=t.size()&&CUR+1==F.size())
      |                   ~~~~~^~~~~~~~~~
paint.cpp:13:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 | else if(idx>=t.size())
      |         ~~~^~~~~~~~~~
paint.cpp:18:16: warning: comparison of integer expressions of different signedness: '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 | if((F[CUR]+idx)<=t.size()){
      |    ~~~~~~~~~~~~^~~~~~~~~~
paint.cpp:21:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 | if((idx+F[CUR]>=t.size())||(t[idx+F[CUR]]!='X'))
      |     ~~~~~~~~~~^~~~~~~~~~
paint.cpp: In function 'std::string solve_puzzle(std::string, std::vector<int>)':
paint.cpp:42:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 | for(int i=1;i<=s.size();i++)
      |             ~^~~~~~~~~~
paint.cpp:50:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 | for(int i=0;i<s.size();i++){
      |             ~^~~~~~~~~
#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...