Submission #361608

#TimeUsernameProblemLanguageResultExecution timeMemory
361608saarang123Paint By Numbers (IOI16_paint)C++17
10 / 100
159 ms492 KiB
#include <bits/stdc++.h> using namespace std; string solve_puzzle(string s, vector<int> c) { int n = s.size(), k = c.size(); vector<bool> white(n, true), black(n, true); for(int mask = 0; mask < (1 << n); mask++) { vector<bool> puzzle(n); for(int i = 0; i < n; i++) puzzle[i] = (mask >> i & 1); int ptr = 0; bool flag = 1; for(int i = 0, j = 0; i < n && j < n && ptr < k; i = j) { while(j < n && puzzle[i] == puzzle[j]) j++; if(puzzle[i] == 1) { int cnt = j - i; if(cnt == c[ptr]) ptr++; else { flag = 0; break; } } } if(ptr != k) continue; if(!flag) continue; for(int i = 0; i < n; i++) { white[i] = white[i] && (puzzle[i] == 0); black[i] = black[i] && (puzzle[i]); } } string ans = ""; for(int i = 0; i < n; i++) { if(black[i]) ans += "X"; else if(white[i]) ans += "_"; else ans += "?"; } 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...