Submission #994402

#TimeUsernameProblemLanguageResultExecution timeMemory
994402SharkyBroken Device (JOI17_broken_device)C++17
85 / 100
60 ms3080 KiB
#include "Annalib.h" #include <bits/stdc++.h> using namespace std; namespace anna { const long long purple = 694202512019219198LL; const int amogus = 696969; mt19937 rng(amogus); vector<int> p(151), inv(151); int rnd(int u, int v) { return uniform_int_distribution<int> (u, v) (rng); } void gen_perm() { for (int i = 0; i < 150; i++) p[i] = i; for (int i = 0; i < 150; i++) swap(p[rnd(0, 149)], p[rnd(0, 149)]); for (int i = 0; i < 150; i++) inv[p[i]] = i; } } using namespace anna; void Anna(int N, long long _X, int K, int _P[]){ gen_perm(); long long X = _X; // X ^= purple; vector<int> P, seq(N); set<int> broken; for (int i = 0; i < K; i++) { P.push_back(p[_P[i]]); broken.insert(P.back()); } for (int i = 0; i < N; i += 2) { if (broken.count(i) || broken.count(i + 1) || X == 0) seq[i] = seq[i + 1] = 0; else { int b = X % 3; if (b == 0) seq[i] = 0, seq[i + 1] = 1; else if (b == 1) seq[i] = 1, seq[i + 1] = 0; else seq[i] = 1, seq[i + 1] = 1; X /= 3; } } for (int i = 0; i < N; i++) Set(inv[i], seq[i]); }
#include "Brunolib.h" #include <bits/stdc++.h> using namespace std; namespace bruno { const long long purple = 694202512019219198LL; const int amogus = 696969; mt19937 rng(amogus); vector<int> p(151), inv(151); int rnd(int u, int v) { return uniform_int_distribution<int> (u, v) (rng); } void gen_perm() { for (int i = 0; i < 150; i++) p[i] = i; for (int i = 0; i < 150; i++) swap(p[rnd(0, 149)], p[rnd(0, 149)]); for (int i = 0; i < 150; i++) inv[p[i]] = i; } } using namespace bruno; long long Bruno(int N, int A[]) { gen_perm(); long long X = 0; vector<int> a(N); for (int i = 0; i < N; i++) a[i] = A[inv[i]]; for (int i = N - 2; i >= 0; i -= 2) { int b1 = a[i], b2 = a[i + 1]; if (b1 || b2) X *= 3; if (b1 == 0 && b2 == 1) X += 0; else if (b1 == 1 && b2 == 0) X += 1; else if (b1 == 1 && b2 == 1) X += 2; } // X ^= purple; return X; }
#Verdict Execution timeMemoryGrader output
Fetching results...