| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 126770 | Sorting | Paint By Numbers (IOI16_paint) | C++14 | 2 ms | 376 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>
using namespace std;
const int N = 2e5 + 7;
const int K = 1e2 + 7;
pair<bool, bool> dp[N][K];
string s, ans;
vector<int> c;
int a[N], n;
bool solve(int i1, int i2){
if(i1 == n){
if(i2 == c.size()){
return 1;
}
return 0;
}
if(dp[i1][i2].second){
return dp[i1][i2].first;
}
dp[i1][i2].second = true;
dp[i1][i2].first = false;
if(s[i1] == '.' || s[i1] == '_'){
bool b = solve(i1 + 1, i2);
if(b){
if(ans[i1] == '_'){
ans[i1] = '_';
}
else{
if(ans[i1] != '_'){
ans[i1] = '?';
}
}
dp[i1][i2].first = true;
}
}
if(a[i1] >= c[i2]){
bool b = solve(i1 + c[i2], i2 + 1);
if(b){
if(ans[i1] == 'X'){
ans[i1] = 'X';
}
else{
if(ans[i1] != 'X'){
ans[i1] = '?';
}
}
dp[i1][i2].first = true;
}
}
return dp[i1][i2].first;
}
string solve_puzzle(string _s, vector<int> _c){
n = s.size();
s = _s;
for(int i = 0; i < (int)_c.size(); i++){
c.push_back(_c[i]);
}
if(s[n - 1] == 'X' || s[n - 1] == '.'){
a[n - 1] = 1;
}
else{
a[n - 1] = 0;
}
for(int i = n - 2; i >= 0; i--){
if(s[i] == 'X' || s[i] == '.'){
a[i] = a[i + 1] + 1;
}
else{
a[i] = 0;
}
}
ans = s;
solve(0, 0);
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... | ||||
