제출 #1349817

#제출 시각아이디문제언어결과실행 시간메모리
1349817blameazu마술쇼 (APIO24_show)C++20
5 / 100
2 ms1092 KiB
#include <bits/stdc++.h>
using namespace std;

#include "Alice.h"

vector<pair<int,int> > Alice() {
    int seed = 87;
    const int N = 5000;
    const int m = 30;

    long long x = setN(N);

    if(x <= 5000) {
        vector<pair<int, int> > re;
        for(int i = 1; i <= N; i++) if(i != (int)x) {
            re.push_back({(int)x, i});
        }
        return re;
    }
    
    vector<int> order(N);
    iota(order.begin(), order.end(), 1);
    for(int i = 0; i < N; i++) {
        swap(order[i], order[(i*seed+seed*67)%N]);
        seed += 67;
    }

    vector<pair<int, int> > re;
    vector<int> adj(N);
    adj[order.back()] = 1;

    int now = 0;
    int F = 0;
    for(int i = 0; i < m; i++, now += (N/m)) if(x>>i&1) {
        for(int j = now; j < min(N, now + (N/m)-1); j++) if(order[j] != order.back()) {
            adj[order[j]] = 1;
            F = order[j];
            re.push_back({order[j], order.back()});
        }
    }

    for(int i = 1; i <= N; i++) if(!adj[i])
        re.push_back({i, F});
    
    for(int i = 0; i < re.size(); i++) {
        swap(re[i], re[(i*seed+seed*67)%((int)re.size())]);
        seed += 67;
    }

    // for(int i = 0; i < re.size(); i++) cout << re[i].first << ' ' << re[i].second << '\n';

    return re;
}
#include <bits/stdc++.h>
using namespace std;

#include "Bob.h"

long long Bob(vector<pair<int,int> > edges){
    int seed = 87;
	const int N = 5000;
    const int m = 30;

    {
        vector<int> deg(N+1);
        for(auto &[a, b] : edges) deg[a]++, deg[b]++;
        int ok = 0;
        for(int i = 1; i <= N; i++) if(deg[i] > 1) ok++;
        if(ok == 1) {
            for(int i = 1; i <= N; i++) if(deg[i] > 1) {
                return (long long)i;
            }
        }
    }

    vector<int> order(N);
    iota(order.begin(), order.end(), 1);
    for(int i = 0; i < N; i++) {
        swap(order[i], order[(i*seed+seed*67)%N]);
        seed += 67;
    }

    vector<int> OK(N);
    // int OKK = 0;
    for(auto &[a, b] : edges) {
        if(a == order.back()) swap(a, b);
        if(b == order.back()) {
            OK[a] = 1;
            // OKK++;
        }
    }
    // cout << OKK << '\n';

    long long ans = 0;

    for(int i = 0, now = 0; i < m; i++, now+=(N/m)) {
        int ok = 0;
        for(int j = now; j < min(N, now+(N/m)-1); j++) if(order[j] != order.back())
            ok |= OK[order[j]];
        if(ok) ans |= (1LL<<i);
    }
    return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...