Submission #1029906

#TimeUsernameProblemLanguageResultExecution timeMemory
1029906borisAngelovBroken Device (JOI17_broken_device)C++17
85 / 100
37 ms3020 KiB
#include "Annalib.h" #include <bits/stdc++.h> using namespace std; void Anna(int N, long long X, int K, int P[]) { int n = N; long long x = X; int k = K; bool isBlocked[n + 1] = {}; for (int i = 0; i < n; ++i) { isBlocked[i] = false; } for (int i = 0; i < k; ++i) { isBlocked[P[i]] = true; } for (int i = 0; i < n / 2; ++i) { int digit = x % 3; int pos1 = 2 * i; int pos2 = 2 * i + 1; bool flag = false; if (digit == 0 && isBlocked[pos1] == false) { Set(pos1, 1); Set(pos2, 0); flag = true; } if (digit == 1 && isBlocked[pos2] == false) { Set(pos1, 0); Set(pos2, 1); flag = true; } if (digit == 2 && isBlocked[pos1] == false && isBlocked[pos2] == false) { Set(pos1, 1); Set(pos2, 1); flag = true; } if (flag == false) { Set(pos1, 0); Set(pos2, 0); } else { x /= 3; } } }
#include "Brunolib.h" #include <bits/stdc++.h> using namespace std; long long Bruno(int N, int A[]) { int n = N; int a[n + 1] = {}; for (int i = 0; i < n; ++i) { a[i] = A[i]; } long long ans = 0; long long curr = 1; for (int i = 0; i < n / 2; ++i) { int pos1 = 2 * i; int pos2 = 2 * i + 1; if (a[pos1] + a[pos2] == 0) continue; if (a[pos1] == 0 && a[pos2] == 1) { ans += curr; } if (a[pos1] == 1 && a[pos2] == 1) { ans += 2 * curr; } curr *= 3; } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...