Submission #799791

#TimeUsernameProblemLanguageResultExecution timeMemory
799791NeroZeinPaint By Numbers (IOI16_paint)C++17
32 / 100
1 ms308 KiB
#include "paint.h" #include <cstdlib> #include "bits/stdc++.h" using namespace std; std::string solve_puzzle(std::string s, std::vector<int> c) { int n = (int) s.size(); int k = (int) c.size(); int sum = accumulate(c.begin(), c.end(), 0); vector<int> ps(k); ps[0] = c[0]; for (int i = 1; i < k; ++i) { ps[i] = c[i] + ps[i - 1]; } int p = 0; int cur = 0; string sml(n, '?'); vector<int> belong(n); for (int i = 0; i < n; ++i) { if (cur == c[p]) { if (p < k - 1) { sml[i] = '_'; } cur = 0; p++; } else if (p < k) { cur++; sml[i] = 'X'; belong[i] = p; } } int space = n - k + 1 - sum; if (space == 0) { return sml; } string ans(n, '?'); for (int i = space; i < n; ++i) { if (belong[i] == belong[i - space] && sml[i] == 'X' && sml[i - space] == 'X') { 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...