# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
959043 | IUA_Hasin | Paint By Numbers (IOI16_paint) | C++17 | 1 ms | 500 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 <bits/stdc++.h>
#define endl "\n"
#define yeap cout<<"YES"<<endl
#define nope cout<<"NO"<<endl
#define ll long long
using namespace std;
#include "paint.h"
#include <cstdlib>
std::string solve_puzzle(std::string s, std::vector<int> c) {
ll d = c.size();
ll arr[d];
ll brr[d];
vector<ll> v;
for(int i=0; i<d; i++){
if(i==0){
arr[i] = c[i];
} else {
arr[i] = arr[i-1]+c[i]+1;
}
}
for(int i=d-1; i>=0; i--){
if(i==d-1){
brr[i] = c[i];
} else {
brr[i] = brr[i+1]+c[i]+1;
}
}
ll dd = s.length();
ll cnt = 0;
ll a = arr[0];
ll b = brr[0];
for(int i=1; i<=dd; i++){
// cout<<a<<" "<<b<<endl;
if(i<=a){
if(dd-b>=i){
v.push_back(i);
}
} else {
a = arr[cnt+1];
b = brr[cnt+1];
cnt++;
if(cnt>=d){
b = 0;
a = arr[d-1];
}
if(dd-b>=i){
v.push_back(i);
}
}
}
ll aaa = v.size();
// for(int i=0; i<d; i++){
// cout << arr[i] << " ";
// }
// cout<<endl;
// for(int i=0; i<d; i++){
// cout << brr[i] << " ";
// }
// cout<<endl;
// for(int i=0; i<v.size(); i++){
// cout << v[i] << " ";
// }
// cout<<endl;
// ll dd = s.length();
string ss;
if(aaa==d-1){
if(aaa==0){
for(int i=0; i<s.length(); i++){
ss.push_back('X');
}
return ss;
} else {
ll cnt = 1;
ll a = v[0]-1;
for(int i=0; i<dd; i++){
if(cnt>aaa){
ss.push_back('X');
}else if(i==a){
ss.push_back('_');
a = v[cnt]-1;
cnt++;
} else {
ss.push_back('X');
}
}
return ss;
}
}else if(v.size()==0){
for(int i=0; i<dd; i++){
ss.push_back('X');
}
return ss;
} else {
ll cnt = 1;
ll a = v[0]-1;
for(int i=0; i<dd; i++){
if(cnt==aaa){
ss.push_back('?');
}else if(i==a){
ss.push_back('?');
a = v[cnt]-1;
cnt++;
} else {
ss.push_back('X');
}
}
return ss;
}
}
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... |