Submission #131286

#TimeUsernameProblemLanguageResultExecution timeMemory
131286DanerZeinPaint By Numbers (IOI16_paint)C++14
32 / 100
2 ms504 KiB
#include "paint.h" #include <bits/stdc++.h> using namespace std; std::string solve_puzzle(std::string s, std::vector<int> c) { string rp=""; vector<int>id; for(int i=0;i<c.size();i++){ for(int j=0;j<c[i];j++){ rp+='X'; } id.push_back(rp.size()); if(rp.size()==s.size()){ break; } rp+='_'; } int t; if(rp[rp.size()-1]=='_'){ t=1; t+=(s.size()-rp.size()); for(int i=1;i<t;i++){ rp+='_'; } } else{ return rp; } // cout<<"t: "<<t<<endl; /*for(int i=0;i<id.size();i++){ cout<<id[i]<<" "; } cout<<endl;*/ string ans; ans.resize(rp.size()); //int id=0; //cout<<rp<<" "<<t<<endl; int j=0; for(int i=0;i<rp.size();i++){ if(rp[i]=='X'){ if(id[j]-1>=i+t){ if(rp[i+t]=='X'){ ans[i+t]='X'; //ans[i]='?'; } } if(i==id[j]-1){ j++; } } } for(int i=0;i<ans.size();i++){ if(ans[i]!='X'){ ans[i]='?'; } if(s[i]=='_'){ ans[i]='_'; } } // cout<<ans[7]<<endl; return ans; } /* const int S_MAX_LEN = 200 * 1000; char buf[S_MAX_LEN + 1]; int main() { assert(1 == scanf("%s", buf)); std::string s = buf; int c_len; assert(1 == scanf("%d", &c_len)); std::vector<int> c(c_len); for (int i = 0; i < c_len; i++) { assert(1 == scanf("%d", &c[i])); } std::string ans = solve_puzzle(s, c); printf("%s\n", ans.data()); return 0; }*/

Compilation message (stderr)

paint.cpp: In function 'std::__cxx11::string solve_puzzle(std::__cxx11::string, std::vector<int>)':
paint.cpp:8:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<c.size();i++){
                 ~^~~~~~~~~
paint.cpp:40:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<rp.size();i++){
                 ~^~~~~~~~~~
paint.cpp:53:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<ans.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...