# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
617224 | A_D | Paint By Numbers (IOI16_paint) | C++14 | 0 ms | 212 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;
const int N=2e5+100;
int pre[N];
int suf[N];
string solve_puzzle(string s,vector<int> c){
string ans=s;
int n=s.size();
int k=c.size();
int sum=1;
pre[0]=0;
for(int i=1;i<n;i++){
if(pre[i-1]==k){
pre[i]=k;
continue;
}
if(sum==c[pre[i-1]]){
pre[i]=pre[i-1]+1;
i++;
if(i==n)break;
pre[i]=pre[i-1];
sum=1;
}
else{
pre[i]=pre[i-1];
sum++;
}
}
sum=1;
suf[n-1]=k-1;
for(int i=n-2;i>=0;i--){
if(suf[i+1]==-1){
suf[i]=-1;
continue;
}
if(sum==c[suf[i+1]]){
suf[i]=suf[i+1]-1;
i--;
if(i==-1)break;
suf[i]=suf[i+1];
sum=1;
}
else{
suf[i]=suf[i+1];
sum++;
}
}
if(suf[0]==-1){
ans[0]='?';
}
else{
ans[0]='X';
}
if(pre[n-1]==k){
ans[n-1]='?';
}
else{
ans[n-1]='X';
}
for(int i=1;i<n-1;i++){
if(pre[i]==suf[i]){
ans[i]='X';
if((pre[i]!=pre[i-1])&&(suf[i]!=suf[i+1])){
}
}
else{
if((pre[i]==suf[i]+1)&&(pre[i]!=pre[i-1])&&(suf[i]!=suf[i+1])){
ans[i]='_';
}
else ans[i]='?';
}
}
for(int i=0;i<n;i++)cout<<pre[i]<<" ";cout<<"\n";
for(int i=0;i<n;i++)cout<<suf[i]<<" ";cout<<"\n";
return ans;
}
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... |