Submission #1021766

#TimeUsernameProblemLanguageResultExecution timeMemory
1021766vjudge1Paint By Numbers (IOI16_paint)C++17
7 / 100
0 ms348 KiB
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 100; int n, k; int pref[maxn]; int sum(int l, int r){ if(l > r) return 0; return pref[r] - pref[l-1]; } string solve_puzzle(std::string s, std::vector<int> c){ n = s.size(); s = "#" + s; k = c.size(); reverse(c.begin(), c.end()); c.push_back(0); reverse(c.begin(), c.end()); for(int i = 1; i <= k; i++){ pref[i] += pref[i-1] + c[i]; } string res; vector<int> ans = {'.', 'Y', 'X', '?'}; for(int i = 1; i <= n; i++){ int x = 0; for(int j = 1; j <= k; j++){ int l = sum(1, j - 1) + j; int r = n - sum(j + 1, k) - k + j; if(l <= i && i <= r && r - l + 1 >= c[j]) x |= 2; } for(int j = 0; j <= k; j++){ int l = sum(1, j) + max(j, 1); int r = 1 + n - sum(j + 1, k) - max(1, k - j); if(l <= i && i <= r) x |= 1; } res.push_back(ans[x]); } 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...