# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
361391 | NachoLibre | Paint By Numbers (IOI16_paint) | C++17 | 1 ms | 364 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;
#ifndef wambule
#include "paint.h"
#else
#endif
string solve_puzzle(string s, vector<int> c) {
for(int i = 1; i <= 200000; ++i) {
for(int j = 1; j <= 100; ++j) {
swap(i, j);
int x = i;
i = j;
j = x;
}
}
return s;
int n = s.size();
int m = c.size();
s = " " + s + " ";
{
vector<int> t = c;
c.clear();
c.push_back(0);
for(int i = 0; i < t.size(); ++i)
c.push_back(t[i]);
c.push_back(0);
}
bool cu[2][m + 2][n + 2];
int qt[n + 2] = {0};
qt[n + 1] = 0;
for(int i = 1; i <= n; ++i) {
qt[i] = qt[i - 1] + (s[i] == '_');
}
cu[0][0][0] = 1;
for(int i = 1; i <= m; ++i) cu[0][i][0] = 0;
for(int i = 1; i <= n; ++i) cu[0][0][i] = (cu[0][0][i - 1] && (s[i] != 'X'));
for(int i = 1; i <= m; ++i) {
for(int j = 1; j <= n; ++j) {
cu[0][i][j] = 0;
if(s[j] == '_') {
cu[0][i][j] = cu[0][i][j - 1];
} else if(s[j] == 'X') {
if(c[i] <= j && qt[j] == qt[j - c[i]] && s[j - c[i]] != 'X') {
if(c[i] < j) cu[0][i][j] |= cu[0][i - 1][j - c[i] - 1];
else cu[0][i][j] |= (i == 1);
}
} else {
cu[0][i][j] = cu[0][i][j - 1];
if(c[i] <= j && qt[j] == qt[j - c[i]] && s[j - c[i]] != 'X') {
if(c[i] < j) cu[0][i][j] |= cu[0][i - 1][j - c[i] - 1];
else cu[0][i][j] |= (i == 1);
}
}
}
}
// // // // // // // //
for(int i = n; i >= 1; --i)
qt[i] = qt[i + 1] + (s[i] == '_');
cu[1][m + 1][n + 1] = 1;
for(int i = 1; i <= m; ++i) cu[1][i][n + 1] = 0;
for(int i = n; i >= 1; --i) cu[1][m + 1][i] = (cu[1][m + 1][i + 1] && (s[i] != 'X'));
for(int i = m; i >= 1; --i) {
for(int j = n; j >= 1; --j) {
cu[1][i][j] = 0;
if(s[j] == '_') {
cu[1][i][j] = cu[1][i][j + 1];
} else if(s[j] == 'X') {
if(c[i] <= n - j + 1 && qt[j] == qt[j + c[i]] && s[j + c[i]] != 'X') {
if(c[i] < n - j + 1) cu[1][i][j] |= cu[1][i + 1][j + c[i] + 1];
else cu[1][i][j] |= (i == m);
}
} else {
cu[1][i][j] = cu[1][i][j + 1];
if(c[i] <= n - j + 1 && qt[j] == qt[j + c[i]] && s[j + c[i]] != 'X') {
if(c[i] < n - j + 1) cu[1][i][j] |= cu[1][i + 1][j + c[i] + 1];
else cu[1][i][j] |= (i == m);
}
}
}
}
// // // // // // // //
int fl[2][m + 2][n + 2];
#ifdef wambule
for(int i = 0; i <= m; ++i) {
for(int j = 1; j <= n; ++j) {
cout << cu[0][i][j] << " ";
}
cout << endl;
}
cout << endl;
for(int i = m + 1; i >= 1; --i) {
for(int j = 1; j <= n; ++j) {
cout << cu[1][i][j] << " ";
}
cout << endl;
}
#endif
return s;
}
#ifdef wambule
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
// string s = solve_puzzle(".X.....X..", {1, 1});
return 0;
}
#endif
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... |