Submission #617844

#TimeUsernameProblemLanguageResultExecution timeMemory
617844HazemPaint By Numbers (IOI16_paint)C++14
0 / 100
0 ms212 KiB
#include <bits/stdc++.h> using namespace std; int pr[200]; int a[200]; int n,k; int get(int l,int r){ if(l>r) return 0; int ret = 0; for(int i=l;i<=r;i++) ret += a[i]; return max(0,ret+r-l); } bool white(int idx){ int l = max(0,idx); int r = n-idx-1; for(int j=1;j<=k;j++) if(get(1,j)<=l&&get(j+1,k)<=r) return 1; return 0; } bool black(int idx){ for(int i=1;i<=k;i++) for(int j=max(0,idx-a[i]+1);j<=idx;j++){ int l = max(0,j-1); int r = max(0,n-(j+a[i]-1)-2); if(get(1,i-1)<=l&&get(i+1,k)<=r) return 1; } return 0; } std::string solve_puzzle(std::string s, std::vector<int> c) { n = s.size(); k = c.size(); for(int i=1;i<=k;i++) pr[i] = pr[i-1] + c[i-1],a[i] = c[i-1]; string ans(n,'?'); for(int i=0;i<n;i++){ if(black(i)&&!white(i)){ ans[i] = 'X'; continue; } if(white(i)&&!black(i)){ ans[i] = '_'; continue; } } 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...