Submission #1099158

#TimeUsernameProblemLanguageResultExecution timeMemory
1099158thangdz2k7Broken Device (JOI17_broken_device)C++17
100 / 100
252 ms2964 KiB
#include <bits/stdc++.h> #define fi first #define se second #include "Annalib.h" using namespace std; mt19937 rng(145); const int m = 150, T = 60; bitset <T> a[m]; long long rnd(long long l, long long r){ return l + rng() % (r - l + 1); } #define Bit(x, i) (x >> i & 1) void Anna(int N, long long X, int K, int P[]){ for (int i = 0; i < m; ++ i){ for (int j = 0; j < T; ++ j) a[i][j] = rnd(0, 1); } vector <long long> b(m, 0); vector <bool> broken(m, 0); for (int i = 0; i < K; ++ i) broken[P[i]] = 1; for (int i = 0; i < m; ++ i){ for (int j = 0; j < T; ++ j) if (a[i][j]) b[i] += (1ll << j); } bitset <m> base; vector <pair <long long, bitset <m>>> basis(T, {0, base}); for (int i = 0; i < m; ++ i) if (!broken[i]){ long long x = b[i]; bitset <m> cur; cur.set(i); for (int j = 0; j < T; ++ j) if (Bit(x, j)){ if (!basis[j].fi) { basis[j] = {x, cur}; break; } x ^= basis[j].fi; cur ^= basis[j].se; } } bitset <m> ans; long long x = X; for (int j = 0; j < T; ++ j) if (Bit(x, j)){ x ^= basis[j].fi; ans ^= basis[j].se; } for (int i = 0; i < m; ++ i) Set(i, ans[i]); }
#include <bits/stdc++.h> #include "Brunolib.h" using namespace std; mt19937 rng(145); const int m = 150, T = 60; bitset <T> a[m]; long long rnd(long long l, long long r){ return l + rng() % (r - l + 1); } long long Bruno(int N, int A[]){ long long xr = 0; for (int i = 0; i < m; ++ i){ long long b = 0; for (int j = 0; j < T; ++ j){ int a = rnd(0, 1); if (a) b += (1ll << j); } if (A[i]) xr ^= b; } return xr; }
#Verdict Execution timeMemoryGrader output
Fetching results...