Submission #961223

#TimeUsernameProblemLanguageResultExecution timeMemory
961223MinaRagy06Paint By Numbers (IOI16_paint)C++17
10 / 100
213 ms436 KiB
#include <bits/stdc++.h> #include "paint.h" #ifdef MINA #include "grader.cpp" #endif using namespace std; #define ll long long const int N = 200'005, K = 105; string solve_puzzle(string s, vector<int> c) { int n = s.size(), k = c.size(); bool gud[n][2]{}; for (int msk = 0; msk < (1 << n); msk++) { string t; for (int i = 0; i < n; i++) { if ((msk >> i) & 1) { t.push_back('_'); } else { t.push_back('X'); } } t.push_back('_'); int cur = 0, cnt = 0; bool ok = 1; for (int i = 0; i < n; i++) { ok &= s[i] == '.' || s[i] == t[i]; } if (!ok) continue; for (auto i : t) { if (i == 'X') { cnt++; } else { if (cnt) { if (cur == k) { ok = 0; break; } ok &= c[cur] == cnt; cnt = 0; cur++; } } } ok &= cur == k; if (ok) { for (int i = 0; i < n; i++) { if (t[i] == 'X') { gud[i][1] = 1; } else { gud[i][0] = 1; } } } } string ans; ans.resize(n); for (int i = 0; i < n; i++) { if (gud[i][0] && gud[i][1]) { ans[i] = '?'; } else if (gud[i][0]) { ans[i] = '_'; } else { ans[i] = 'X'; } } return ans; }
#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...