Submission #427233

#TimeUsernameProblemLanguageResultExecution timeMemory
427233vincentpikachu20Paint By Numbers (IOI16_paint)C++17
59 / 100
1 ms204 KiB
#include "paint.h" #include <bits/stdc++.h> #define int long long using namespace std; string solve_puzzle(string s, vector<signed> c) { int n = s.size(), k = c.size(); string ans = s; vector<int> l(k),r(k); //put all to the lefts int p = 0; for(int i = 0; i < k; i ++){ bool okay; do{ okay = true; int mine = 0; for(int j = p; j < p + c[i]; j ++){ if(s[j] == '_'){ okay = false; mine = j; break; } } if(okay){ l[i] = p; p += c[i] + 1; } else p = mine + 1; }while(!okay); } //put all to the rights p = n; for(int i = k-1; i >= 0; i --){ bool okay; do{ okay = true; int mine = 0; for(int j = p-1; j >= p-c[i]; j --){ if(s[j] == '_'){ okay = false; mine = j; break; } } if(okay){ r[i] = p - c[i]; p -= c[i] + 1; } else p = mine; }while(!okay); } //apply x's for(int i = 0; i < k; i ++){ for(int j = l[i]; j < r[i] + c[i]; j ++) ans[j] = (ans[j] == '.' ? '?' : ans[j]); for(int j = r[i]; j < l[i] + c[i]; j ++) ans[j] = 'X'; } for(char &v : ans) if(v == '.') v = '_'; 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...