# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
930272 | Aiperiii | Paint By Numbers (IOI16_paint) | C++14 | 133 ms | 600 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>
#include "paint.h"
//#define int long long
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
using namespace std;
string solve_puzzle(string s,vector<int> c) {
int n=s.size();
string res="";
vector <int> cnt1(n),cnt2(n);
for(int i=0;i<(1<<n);i++){
string x=s;
for(int j=0;j<n;j++){
if((i&(1<<j))!=0)x[j]='X';
else x[j]='_';
}
int cnt=0,ind=0;
bool ok=1;
for(int j=0;j<n;j++){
if(x[j]=='X')cnt++;
else if(cnt!=0){
if(ind<c.size() && c[ind]==cnt)ind++;
else ok=0;
cnt=0;
}
}
if(cnt!=0){
if(ind<c.size() && c[ind]==cnt)ind++;
else ok=0;
}
if(ok && ind==c.size()){
for(int j=0;j<n;j++){
if(x[j]=='X')cnt1[j]++;
else cnt2[j]++;
}
}
}
for(int i=0;i<n;i++){
if(cnt1[i] && cnt2[i])res+='?';
else if(cnt1[i])res+='X';
else res+='_';
}
return res;
}
/*signed main(){
ios_base::sync_with_stdio();
cin.tie(0);cout.tie(0);
string s;
cin>>s;
int n;
cin>>n;
vector <int> c(n);
for(int i=0;i<n;i++){
cin>>c[i];
}
cout<<solve_puzzle(s,c);
}
*/
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... |