Submission #295113

#TimeUsernameProblemLanguageResultExecution timeMemory
295113BTheroBroken Device (JOI17_broken_device)C++17
41 / 100
64 ms3328 KiB
// chrono::system_clock::now().time_since_epoch().count() #include "Annalib.h" #include<bits/stdc++.h> #define pb push_back #define eb emplace_back #define mp make_pair #define fi first #define se second #define all(x) (x).begin(), (x).end() #define debug(x) cerr << #x << " = " << x << endl; using namespace std; typedef long long ll; typedef pair<int, int> pii; namespace { int n, k, bad_pos[45]; int is_bad[205]; ll msg; int bit(ll x, int p) { if (p > 60) return 0; return (x >> p) & 1; } void set(int p, int x) { if (p < n) { Set(p, x); } } void solve() { fill(is_bad, is_bad + n, 0); for (int i = 0; i < k; ++i) { is_bad[bad_pos[i]] = 1; } int p = 0; for (int i = 0; i < n; i += 2) { if (is_bad[i] && is_bad[i + 1]) { Set(i, 0); Set(i + 1, 0); continue; } if (bit(msg, p) == 0 && !is_bad[i + 1]) { Set(i, 0); Set(i + 1, 1); p++; continue; } if (bit(msg, p) == 1 && !is_bad[i]) { Set(i, 1); Set(i + 1, 0); p++; continue; } Set(i, 0); Set(i + 1, 0); } } }; void Anna( int N, long long X, int K, int P[] ){ n = N; msg = X; k = K; for (int i = 0; i < k; ++i) { bad_pos[i] = P[i]; } solve(); }
// chrono::system_clock::now().time_since_epoch().count() #include "Brunolib.h" #include<bits/stdc++.h> #define pb push_back #define eb emplace_back #define mp make_pair #define fi first #define se second #define all(x) (x).begin(), (x).end() #define debug(x) cerr << #x << " = " << x << endl; using namespace std; typedef long long ll; typedef pair<int, int> pii; namespace { int n, arr[205]; ll solve() { ll ret = 0; int p = 0; for (int i = 0; i < n; i += 2) { if (arr[i] == 0 && arr[i + 1] == 0) { continue; } if (arr[i] == 1 && arr[i + 1] == 0) { ret += (1ll << p); } p++; } return ret; } }; long long Bruno( int N, int A[] ){ n = N; for (int i = 0; i < n; ++i) { arr[i] = A[i]; } return solve(); }

Compilation message (stderr)

Anna.cpp:28:8: warning: 'void {anonymous}::set(int, int)' defined but not used [-Wunused-function]
   28 |   void set(int p, int x) {
      |        ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...