Submission #24871

#TimeUsernameProblemLanguageResultExecution timeMemory
24871khsoo01Broken Device (JOI17_broken_device)C++11
51 / 100
62 ms2836 KiB
#include "Annalib.h" typedef long long ll; int br[155], cur; int idx[9] = {7, 5, 4, 3, 6, 2, 1, 0}; int val[9] = {1, 3, 2, 0, 0, 1, 0, 0}; int mod[9] = {4, 4, 4, 4, 2, 2, 2, 1}; void Write (int X) { for(int i=2;i>=0;i--) { Set(cur+i, X%2); X /= 2; } cur += 3; } void Anna( int N, long long X, int K, int P[] ) { for(int i=0;i<N;i++) br[i] = 0; for(int i=0;i<K;i++) br[P[i]] = 1; cur = 0; for(int i=0;i<N;i+=3) { int tmp = 7 - (4*br[i] + 2*br[i+1] + br[i+2]); for(int j=0;j<8;j++) { if((tmp&idx[j])==idx[j] && X%mod[j]==val[j]) { Write(idx[j]); X /= 1ll*mod[j]; break; } } } }
#include "Brunolib.h" int idx[9] = {7, 5, 4, 3, 6, 2, 1, 0}; int val[9] = {1, 3, 2, 0, 0, 1, 0, 0}; int mod[9] = {4, 4, 4, 4, 2, 2, 2, 1}; long long Bruno( int N, int A[] ){ long long ans = 0; for(int i=N-3;i>=0;i-=3) { int cur = 4*A[i]+2*A[i+1]+A[i+2]; for(int j=0;j<8;j++) { if(cur == idx[j]) { ans *= 1ll*mod[j]; ans += 1ll*val[j]; } } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...