제출 #732945

#제출 시각아이디문제언어결과실행 시간메모리
732945benjaminkleynPaint By Numbers (IOI16_paint)C++17
10 / 100
2082 ms284 KiB
#include <bits/stdc++.h> #include "paint.h" using namespace std; int n, k; int W[101], B[101]; bool white[101], black[101]; string cur; void solve(int r, int i, string &s, vector<int> &c, int suff_sum) { if (i == k) { for (int j = 1; j <= n; j++) if (cur[j] == 'X') black[j] = true; else if (cur[j] == '_') white[j] = true; return; } for (int j = r + 2; j + suff_sum - 1 <= n; j++) if (W[j + c[i] - 1] - W[j - 1] == 0 && (B[j - 1] - B[r] == 0 || (r == -1 && B[j-1] == 0))) { for (int m = j; m <= j + c[i] - 1; m++) cur[m] = 'X'; solve(j + c[i] - 1, i + 1, s, c, suff_sum - c[i]); for (int m = j; m <= j + c[i] - 1; m++) cur[m] = '_'; } } string solve_puzzle(string s, vector<int> c) { n = s.size(), k = c.size(); s = "#" + s; W[0] = B[0] = 0; for (int i = 1; i <= n; i++) { W[i] = W[i-1] + (s[i] == '_'); B[i] = B[i-1] + (s[i] == 'X'); } memset(white, false, sizeof(white)); memset(black, false, sizeof(black)); cur = "#" + string(n, '_'); int sum = 0; for (int i = 0; i < k; i++) sum += c[i]; solve(-1, 0, s, c, sum); string res = ""; for (int i = 1; i <= n; i++) { if (white[i] && black[i]) res += "?"; else if (white[i]) res += "_"; else if (black[i]) res += "X"; else res += "F"; } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...