# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
26820 | wangyenjen | Broken Device (JOI17_broken_device) | C++14 | 128 ms | 4640 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/// Author: Wang, Yen-Jen
#include "Annalib.h"
#include <bits/stdc++.h>
using namespace std;
static bool st[150];
static bool val[150];
static bool vis[150];
static bitset<151> A[60];
void Anna(int N , long long X , int K , int P[]) {
memset(st , 0 , sizeof(st));
for(int i = 0; i < K; i++) st[P[i]] = 1;
for(int i = 0; i < 60; i++) {
A[i].reset();
for(int j = 0; j < 50; j++) {
int x = (i * 2 + j) % N;
if(st[x]) A[i][x] = 0;
else A[i][x] = 1;
}
A[i][N] = ((X>>i)&1);
}
memset(val , 0 , sizeof(val));
memset(vis , 0 , sizeof(vis));
int cnt = 0;
for(int i = 0; i < N; i++) {
int p = -1;
for(int j = cnt; j < 60; j++) {
if(A[j][i]) {
p = j;
break;
}
}
if(p == -1) continue;
if(p != cnt) swap(A[p] , A[cnt]);
for(int j = cnt + 1; j < 60; j++) {
if(A[j][i]) A[j] ^= A[cnt];
}
vis[i] = 1;
if(++cnt == 60) break;
}
for(int i = 0; i < N; i++) {
if(!st[i]) {
if(!vis[i]) {
vis[i] = 1;
val[i] = 0;
}
else vis[i] = 0;
}
else vis[i] = 1;
}
for(int i = 59; i >= 0; i--) {
int p = -1;
for(int j = 0; j < N; j++) {
if(A[i][j]) {
if(vis[j]) {
A[i][N] = (A[i][N] ^ val[j]);
A[i][j] = 0;
}
else p = j;
}
}
if(p != -1) {
vis[p] = 1;
val[p] = A[i][N];
}
}
for(int i = 0; i < N; i++) assert(vis[i]);
for(int i = 0; i < N; i++) Set(i , val[i]);
}
/// Author: Wang, Yen-Jen
#include "Brunolib.h"
#include <bits/stdc++.h>
using namespace std;
long long Bruno(int N , int A[]) {
long long X = 0;
for(int i = 0; i < 60; i++) {
for(int j = 0; j < 50; j++) {
int t = (i * 2 + j) % N;
X ^= ((long long)A[t]<<i);
}
}
return X;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |