Submission #97561

#TimeUsernameProblemLanguageResultExecution timeMemory
97561shoemakerjoBroken Device (JOI17_broken_device)C++14
100 / 100
64 ms3328 KiB
#include "Annalib.h" #include <bits/stdc++.h> #define ll long long using namespace std; bool marked[200]; void Anna( int N, ll X, int K, int P[] ){ for (int i = 0; i < N; i++) marked[i] = false; for (int i = 0; i < K; i++) { marked[P[i]] = true; } int a, b, c; for (int i = 0; i < N; i += 3) { a = i; b = i+1; c = i+2; int ct = 0; if (marked[a]) ct++; if (marked[b]) ct++; if (marked[c]) ct++; if (ct >= 2) { Set(a, 0); Set(b, 0); Set(c, 0); continue; } if (ct == 0) { //set all to 1 for a 1 bit if (X % 4 == 0) { Set(a, 0); Set(b, 1); Set(c, 1); } if (X % 4 == 2) { Set(a, 0); Set(b, 1); Set(c, 0); } if (X % 4 == 1) { Set(a, 1); Set(b, 0); Set(c, 1); } if (X % 4 == 3) { Set(a, 1); Set(b, 1); Set(c, 1); } X /= 4; } if (ct == 1) { if (X % 2 == 0) { if (marked[a]) { if (X % 4 == 0) { Set(a, 0); Set(b, 1); Set(c, 1); } else { Set(a, 0); Set(b, 1); Set(c, 0); } X/=4; } else { Set(a, 1); Set(b, 0); Set(c, 0); X /= 2; } } else { if (marked[c]) { Set(a, 1); Set(b, 1); Set(c, 0); } else { Set(a, 0); Set(b, 0); Set(c, 1); } X /= 2; } } } }
#include "Brunolib.h" #include <bits/stdc++.h> using namespace std; #define ll long long ll Bruno( int N, int A[] ){ ll res = 0; for (int i = N-1; i > 0; i -= 3) { int a = i-2; int b = i-1; int c = i; if (A[a] == 0 && A[b] == 0 && A[c] == 0) continue; int cv = (A[c] == 1) + 2*(A[b] == 1) + 4*(A[a] == 1); // cout << "cv : " << cv << endl; if (cv == 1) { res = res * 2 + 1; } if (cv == 2) { res = res * 4 + 2; } if (cv == 3) { res = res * 4 + 0; } if (cv == 4) { res = res * 2 + 0; } if (cv == 5) { res = res * 4 + 1; } if (cv == 6) { res = res * 2 + 1; } if (cv == 7) { res = res * 4 + 3; } } // cout << "RES: " << res << endl; return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...