# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1113127 | ttamx | Broken Device (JOI17_broken_device) | C++17 | 56 ms | 2784 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.
#include "Annalib.h"
#include<bits/stdc++.h>
using namespace std;
void Anna(int n,long long x,int k,int p[]){
using ull = uint64_t;
mt19937_64 rng(0);
vector<ull> basis(64),way(64);
vector<int> id(64,-1);
auto add=[&](ull x,int i){
ull w=0;
for(int b=63;b>=0;b--){
if(x>>b&1){
if(id[b]==-1){
basis[b]=x;
way[b]=w|(1ULL<<b);
id[b]=i;
return;
}
x^=basis[b];
w^=way[b];
}
}
};
vector<bool> ok(n,true);
for(int i=0;i<k;i++){
ok[p[i]]=false;
}
for(int i=0;i<n;i++){
ull val=rng();
if(ok[i]){
add(val,i);
}
}
vector<int> ans(n);
ull w=0;
for(int i=63;i>=0;i--){
if(x>>i&1){
x^=basis[i];
w^=way[i];
}
}
for(int i=63;i>=0;i--){
if(w>>i&1){
ans[id[i]]=1;
}
}
for(int i=0;i<n;i++){
Set(i,ans[i]);
}
}
#include "Brunolib.h"
#include<bits/stdc++.h>
using namespace std;
long long Bruno(int n,int a[]){
mt19937_64 rng(0);
uint64_t ans=0;
for(int i=0;i<n;i++){
uint64_t val=rng();
if(a[i]){
ans^=val;
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |