# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
131286 | DanerZein | Paint By Numbers (IOI16_paint) | C++14 | 2 ms | 504 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |