Submission #123048

#TimeUsernameProblemLanguageResultExecution timeMemory
123048tjd229Broken Device (JOI17_broken_device)C++14
0 / 100
25 ms3312 KiB
#include "Annalib.h" void Anna(int N, long long X, int K, int P[]) { int mem[150]; for (int i = 0; i < N; ++i) mem[i] = -1; for (int i = 0; i < K; ++i) mem[P[i]] = 0; for (int pos = 0; X && pos + 1 < N; ++pos) { if (mem[pos] == 0 && mem[pos + 1] == 0) continue; else if (mem[pos] == 0 && mem[pos + 1]==-1) {//01 if (X & 1) { mem[pos + 1] = 1; X >>= 1; } } else if (mem[pos] == -1 && mem[pos + 1] == -1) {//00->1X mem[pos] = 1; mem[++pos] = X & 1; X >>= 1; } else if (mem[pos] == 1 && mem[pos + 1] == -1) {//10->1X mem[pos] = 1; mem[++pos] = X & 1; X >>= 1; } } for (int i = 0; i < N; ++i) Set(i, mem[i] < 0 ? 0 : mem[i]); //for (int i = 0; i < 10; ++i) printf("%d ",mem[i]); }
#include "Brunolib.h" long long Bruno( int N, int A[] ){ long long X = 0; int recon[60] = { 0 }; int pos = 0; for (int i = 0; i + 1 < N; ++i) { int b2 = A[i] + A[i] + A[i + 1]; if (b2&1) recon[pos++] = 1; else if (b2 & 2) recon[pos++] = 0; if (b2 & 2)++i; }pos=60; while (pos--) { X <<= 1; X += recon[pos]; } return X; }
#Verdict Execution timeMemoryGrader output
Fetching results...