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 "Alice.h"
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
using namespace std;
const int MAX=5010;
struct DSU{
int f[MAX];
void init(int n){
for(int i=1;i<=n;i++)f[i]=i;
}
int get(int v){
return (f[v]==v?v:get(f[v]));
}
void unite(int a,int b){
a=get(a),b=get(b);
f[a]=b;
}
}D;
bool bit(ll i,int j){
return (i>>j)&1;
}
int hsb(ll i){
for(int j=60;j>=0;j--){
if(i>>j&1)return j;
}
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
vector<pair<int,int>> Alice(){
vector<pair<int,int>> res;
ll x=setN(5000);
int n=5000;
D.init(n);
vector<pair<int,int>> e;
for(int i=1;i<=n;i++){
for(int j=i+1;j<=n;j++){
if(bit(x,(i+j)%60)){
e.pb({i,j});
}
}
}
shuffle(all(e),rng);
for(auto [x,y]:e){
if(D.get(x)!=D.get(y)){
D.unite(x,y);
res.pb({x,y});
}
}
return res;
}
#include "Bob.h"
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
using namespace std;
const int MAX=5010;
int hsb1(ll i){
for(int j=60;j>=0;j--){
if(i>>j&1)return j;
}
}
long long Bob(vector<pair<int,int>> V){
ll ans=0;
for(auto [x,y]:V){
int a=(x+y)%60;
ans|=(1ll<<a);
}
return ans;
}
Compilation message (stderr)
Alice.cpp: In function 'int hsb(long long int)':
Alice.cpp:37:1: warning: control reaches end of non-void function [-Wreturn-type]
37 | }
| ^
Bob.cpp: In function 'int hsb1(long long int)':
Bob.cpp:16:1: warning: control reaches end of non-void function [-Wreturn-type]
16 | }
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |