Submission #26814

#TimeUsernameProblemLanguageResultExecution timeMemory
26814wangyenjenBroken Device (JOI17_broken_device)C++14
8 / 100
114 ms4640 KiB
/// 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 = i; j < N - (59 - i); j++) { if(st[j]) A[i][j] = 0; else A[i][j] = 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] = 1; } 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 = i; j < N - (59 - i); j++) X ^= ((long long)A[j]<<i); } return X; }
#Verdict Execution timeMemoryGrader output
Fetching results...