Submission #123097

#TimeUsernameProblemLanguageResultExecution timeMemory
123097tjd229Broken Device (JOI17_broken_device)C++11
100 / 100
45 ms3064 KiB
#include "Annalib.h" void Anna(int N, long long X, int K, int P[]) { int mem[150]; int b[70] = { 0 }; for (int i = 0; i < N; ++i) mem[i] = 1; for (int i = 0; i < K; ++i) mem[P[i]] = 0; for (int i = 0; X; ++i,X>>=1) b[i] = X & 1; int pos = 0; for (int i = 0; i < N; i += 3) { int s = mem[i] + mem[i + 1] + mem[i + 2]; int mask = (mem[i] << 2) + mem[i + 1] + mem[i + 1] + mem[i + 2]; int w = 0; if (pos >= 60) { mem[i] = mem[i + 1] = mem[i + 2] = 0; continue; } if (mask == 7 && b[pos] + b[pos + 1]==2) { w = 7; pos += 2; } else if ((mask & 2) == 2 && b[pos] + b[pos + 1] == 0) { w = 2; pos += 2; } else if ((mask & 5)==5 && b[pos]==1&& b[pos + 1] == 0) { w = 5; pos += 2; } else if ((mask & 3)==3 && b[pos] == 0 && b[pos + 1] == 1) { w = 3; pos += 2; } else if ((mask & 6)==6 && b[pos]) { w = 6; ++pos; } else if ((mask & 1) &&b[pos]) { w = 1; ++pos; } else if ((mask & 4) == 4 && b[pos] == 0 ) { w = 4; ++pos; } mem[i] = (w & 4) >> 2; mem[i + 1] = (w&2) >> 1; mem[i + 2] = w & 1; } for (int i = 0; i < N; ++i) Set(i, mem[i]); }
#include "Brunolib.h" long long Bruno( int N, int A[] ){ long long X = 0; int recon[70] = { 0 }; int pos = 0; for (int i = 0; i < N; i += 3) { int mask = (A[i] << 2) + A[i + 1] + A[i + 1] + A[i + 2]; if (mask == 1 || mask == 6) recon[pos++] = 1; else if (mask == 2) pos += 2; else if (mask == 3) recon[++pos] = 1, ++pos; else if (mask == 4) ++pos; else if (mask == 5) recon[pos++] = 1, ++pos; else if (mask == 7) recon[pos] = recon[pos + 1] = 1, pos += 2; } //printf("%d\n",pos); pos = 60; while (pos--) { X <<= 1; X += recon[pos]; } return X; }

Compilation message (stderr)

Anna.cpp: In function 'void Anna(int, long long int, int, int*)':
Anna.cpp:12:7: warning: unused variable 's' [-Wunused-variable]
   int s = mem[i] + mem[i + 1] + mem[i + 2];
       ^
#Verdict Execution timeMemoryGrader output
Fetching results...