제출 #1037897

#제출 시각아이디문제언어결과실행 시간메모리
1037897shenfe1마술쇼 (APIO24_show)C++17
100 / 100
433 ms132584 KiB
#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:f[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;
}

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;

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;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...