Submission #1029804

#TimeUsernameProblemLanguageResultExecution timeMemory
1029804borisAngelovBroken Device (JOI17_broken_device)C++17
41 / 100
25 ms3276 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; } long long bit = 0; for (int i = 0; i < n; ++i) { if (bit == 60) { Set(i, 0); continue; } if (i < n - 1 && (x & (1LL << bit)) == 0 && isBlocked[i + 1] == false) { Set(i, 0); Set(i + 1, 1); ++i; ++bit; continue; } if (i < n - 1 && isBlocked[i] == false && isBlocked[i + 1] == false) { if ((x & (1LL << bit)) != 0) { Set(i, 1); } else { Set(i, 0); } Set(i + 1, 1); ++i; ++bit; } else { Set(i, 0); } } }
#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]; } /*for (int i = 0; i < n; ++i) { cout << a[i] << " "; } cout << endl;*/ long long ans = 0; long long bit = 0; for (int i = 0; i < n; ++i) { if (a[i] == 1) { int cnt = 1, from = i; while (i + 1 < n && a[i + 1] == 1) { ++cnt; ++i; } if (cnt % 2 == 1) { ++from; ++bit; } for (int j = from; j <= i; j += 2) { ans += (1LL << bit); ++bit; } //cout << from << " " << i << " :: " << ans << endl; } } //cout << ans << endl; return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...