Submission #923174

#TimeUsernameProblemLanguageResultExecution timeMemory
923174gawr_guraBroken Device (JOI17_broken_device)C++17
51 / 100
28 ms2656 KiB
#include <bits/stdc++.h> #include "Annalib.h" using namespace std; void Anna(int N, long long X, int K, int P[]) { vector<int> a(N); vector<int> wrong(N); for (int i = 0; i < K; i++) wrong[P[i]] = 1; for (int i = 0; i < N; i += 3) { if (wrong[i] + wrong[i + 1] + wrong[i + 2] == 0) { int z = X % 4; X /= 4; if (z == 0b10) { a[i + 1] = a[i + 2] = 1; } else { a[i] = 1; a[i + 2] = z & 1; a[i + 1] = z / 2; } } else if (wrong[i] + wrong[i + 1] + wrong[i + 2] == 1) { int z = X % 4; if (wrong[i]) { if (z == 0b10) { a[i + 1] = a[i + 2] = 1; X /= 4; } else { a[i + 1 + (z & 1)] = 1; X /= 2; } } else if (wrong[i + 1]) { if (z / 2 == 0) { a[i] = 1; a[i + 2] = z & 1; X /= 4; } else if (z & 1) { a[i + 2] = 1; X /= 2; } } else { if (z == 0b00) { a[i] = 1; X /= 4; } else { a[i + 1] = 1; a[i] = z & 1; X /= 2; } } } } for (int i = 0; i < N; i++) Set(i, a[i]); }
#include <bits/stdc++.h> #include "Brunolib.h" using namespace std; long long Bruno(int N, int A[]) { int64_t X = 0; for (int i = N - 3; i >= 0; i -= 3) { if (A[i] + A[i + 1] + A[i + 2] == 0) continue; if (A[i] == 1) { if (A[i + 1] == 1 && A[i + 2] == 0) { X = X * 2 + 1; } else { X = (X * 2 + A[i + 1]) * 2 + A[i + 2]; } } else { if (A[i + 1] + A[i + 2] == 1) { X = X * 2 + A[i + 2]; } else { X = (X * 2 + 1) * 2; } } } return X; }
#Verdict Execution timeMemoryGrader output
Fetching results...