제출 #923183

#제출 시각아이디문제언어결과실행 시간메모리
923183gawr_guraBroken Device (JOI17_broken_device)C++17
0 / 100
30 ms2688 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) { int z = X % 4; if (wrong[i] + wrong[i + 1] + wrong[i + 2] == 0) { X /= 4; // cout << "? " << i << '\n'; if (z == 1) { a[i + 2] = a[i + 1] = 1; } else { a[i] = 1; a[i + 1] = z & 1; a[i + 2] = z / 2; } } else if (wrong[i] + wrong[i + 1] + wrong[i + 2] == 1) { if (wrong[i]) { if (z == 1) { 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 / 2; X /= 4; } else { a[i + 2] = 1; X /= 2; } } else { if (z == 0) { 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 + 2]) * 2 + A[i + 1]; } } 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...