Submission #1001126

#TimeUsernameProblemLanguageResultExecution timeMemory
1001126TobBroken Device (JOI17_broken_device)C++14
100 / 100
27 ms2916 KiB
#include <bits/stdc++.h> #include "Annalib.h" #define F first #define S second #define all(x) x.begin(), x.end() #define pb push_back #define FIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0) using namespace std; typedef long long ll; typedef pair <ll, ll> pii; void Anna(int n, ll x, int k, int p[]) { int bio[150] = {0}, a[150] = {0}; for (int i = 0; i < k; i++) bio[p[i]] = 1; for (ll i = 0, j = 0; i < n; i += 3) { int sum = bio[i]+bio[i+1]+bio[i+2]; if (sum > 1) continue; int o = ((x >> j) & 1), o2 = ((x >> (j+1)) & 1); if (o) { if (sum == 0) a[i+1] = a[i+2] = 1, a[i] = o2, j += 2; else a[i] = bio[i+2], a[i+1] = bio[i+2], a[i+2] = bio[i+2]^1, j++; } else { if (bio[i+1] || sum == 0) a[i] = 1, a[i+2] = o2, j += 2; else a[i+1] = 1, j++; } } for (int i = 0; i < n; i++) Set(i, a[i]); }
#include <bits/stdc++.h> #include "Brunolib.h" #define F first #define S second #define all(x) x.begin(), x.end() #define pb push_back #define FIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0) using namespace std; typedef long long ll; typedef pair <ll, ll> pii; int va[] = {0, 1, 0, 1, 0, 2, 1, 3}; int zn[] = {0, 1, 1, 2, 2, 2, 1, 2}; ll Bruno(int n, int a[]) { ll x = 0; for (int i = n-3; i >= 0; i -= 3) { int o = 4*a[i]+2*a[i+1]+a[i+2]; if (o == 0) continue; if (zn[o] == 1) x = 2*x+va[o]; else x = 4*x+va[o]; } return x; }
#Verdict Execution timeMemoryGrader output
Fetching results...