Submission #26510

#TimeUsernameProblemLanguageResultExecution timeMemory
26510youaremysky99Broken Device (JOI17_broken_device)C++14
0 / 100
0 ms4636 KiB
#include "Annalib.h" #include <iostream> #include <cstdio> #include <cstring> using namespace std; #define For(i,a,b) for (int i = (a), _b = (b) ; i <= _b; i++) bool onbit(const long long state, const int pos) { return (state >> pos) & 1; } const int L = 60; bool broken[500]; void Anna( int N, long long X, int K, int P[] ){ memset(broken,0,sizeof(broken)); for (int i = 0 ; i < K; i++) broken[P[i]] = true; int cur = 0; for (int pos = 0; pos < L; pos += 2) { bool found = false; while (!found) { while (broken[cur]) { Set(cur,0); ++cur; } if (onbit(X, pos) && broken[cur + 1]) { Set(cur,0); ++cur; continue; } if (onbit(X, pos + 1) && broken[cur + 2]) { Set(cur,0); ++cur; continue; } found = true; Set(cur,1); ++cur; Set(cur,onbit(X, pos)); ++cur; Set(cur,onbit(X, pos + 1)); ++cur; } } while (cur < N) { Set(cur,0);++cur; } }
#include "Annalib.h" #include <iostream> #include <cstdio> using namespace std; #define For(i,a,b) for (int i = (a), _b = (b) ; i <= _b; i++) long long Bruno( int N, int A[] ){ int cur = 0; int pos = 0; long long res = 0; for (; pos < 60 ; pos +=2 ) { while (!A[cur]) ++cur; if (A[cur + 1]) res |= (1LL << (pos)); if (A[cur + 2]) res |= (1LL << (pos + 1)); cur = cur + 3; } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...