Submission #72702

#TimeUsernameProblemLanguageResultExecution timeMemory
72702ikura355Broken Device (JOI17_broken_device)C++14
100 / 100
77 ms3984 KiB
#include "Annalib.h" #include<bits/stdc++.h> using namespace std; const int maxn = 150 + 5; int bad[maxn], res[maxn]; void Anna(int N, long long X, int K, int P[]) { for(int i=0;i<N;i++) bad[i] = 0; for(int i=0;i<K;i++) bad[P[i]] = 1; for(int i=0;i<N;i++) res[i] = 0; for(int i=0;i<N;i+=3) { if(bad[i] + bad[i+1] + bad[i+2] == 0) { int val = X%4; if(val==0) res[i] = res[i+2] = 1; if(val==1) res[i+1] = 1; if(val==2) res[i] = res[i+1] = res[i+2] = 1; if(val==3) res[i+1] = 1, res[i+2] = 1; X /= 4; } else if(bad[i] + bad[i+1] + bad[i+2] == 1) { int val = X%2; if(val==0) { if(bad[i] || bad[i+1]) res[i+2] = 1; if(bad[i+2]) res[i] = res[i+1] = 1; } if(val==1) { if(bad[i+1] || bad[i+2]) { res[i] = 1; } if(bad[i]) { if(X%4 == 1) res[i+1] = 1; if(X%4 == 3) res[i+1] = 1, res[i+2] = 1; X /= 2; } } X /= 2; } } for(int i=0;i<N;i++) Set(i,res[i]); }
#include "Brunolib.h" #include<bits/stdc++.h> using namespace std; long long Bruno(int N, int A[]) { long long ans = 0; for(int i=N-3;i>=0;i-=3) { int x = A[i], y = A[i+1], z = A[i+2]; int val = x*4 + y*2 + z; if(val==1 || val==6) ans = ans*2; if(val==4) ans = ans*2 + 1; if(val==2) ans = ans*4 + 1; if(val==3) ans = ans*4 + 3; if(val==5) ans = ans*4; if(val==7) ans = ans*4 + 2; } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...