Submission #1186508

#TimeUsernameProblemLanguageResultExecution timeMemory
1186508MighilonMagic Show (APIO24_show)C++20
0 / 100
4 ms616 KiB
#include <bits/stdc++.h>
using namespace std;
 
#ifdef DEBUG
#include "../Library/debug.h"
#else
#include "Alice.h"
#define dbg(x...)
#endif

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl; 
 
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) for (int i = 0; i < (a); ++i)
#define FORd(i, a, b) for (int i = (b) - 1; i >= (a); --i)
#define F0Rd(i, a) for (int i = (a) - 1; i >= 0; --i)
#define trav(a, x) for (auto& a : x)
#define f first 
#define s second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
 
const char nl = '\n';
const int INF = 1e9;
const ll MOD = 998244353;
const int mxN = 3e5+5;

struct DSU {
    vector<int> par, sz;
    int c;
    DSU(int n) : par(n), c(n) {
        sz.resize(n, 1); 
        for (int i = 0; i < n; ++i) par[i] = i;
    }
    int find(int i) {
        return par[i] == i ? i : (par[i] = find(par[i]));
    }
    bool same(int i, int j) {
        return find(i) == find(j);
    }
    int get_size(int i) {
        return sz[find(i)];
    }
    int count() {
        return c;
    }
    int merge(int i, int j) {
        if ((i = find(i)) == (j = find(j))) return -1;
        else --c;
        if (sz[i] > sz[j]) swap(i, j);
        par[i] = j;
        sz[j] += sz[i];
        return j;
    }
};

vpi Alice(){
    DSU dsu(5000);
    int n=5000;
    ll x=setN(n);
    vpi e;
    F0R(i,60){
        if((x>>i)&1){
            F0R(j,82){
                e.pb({j*60+i+1,(j+1)*60+i+2});
            }
        }
    }
    trav(i,e){
        if(!~dsu.merge(i.f-1,i.s-1)){
            assert(0==1);
        }
    }
    F0R(i,n-1){
        if(dsu.same(n-1,i)==false){
            dsu.merge(n-1,i);
            e.push_back({n,i+1});
        }
    }
    sort(all(e));
    assert(sz(e)==n-1);
    trav(i,e){
        i.f=(i.f+4337)%5000;
        if(!i.f) i.f=5000;
        i.s=(i.s+4337)%5000;
        if(!i.s) i.s=5000;
    }
    return e;
}
#include <bits/stdc++.h>
using namespace std;
 
#ifdef DEBUG
#include "../Library/debug.h"
#else
#include "Bob.h"
#define dbg(x...)
#endif

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl; 
 
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) for (int i = 0; i < (a); ++i)
#define FORd(i, a, b) for (int i = (b) - 1; i >= (a); --i)
#define F0Rd(i, a) for (int i = (a) - 1; i >= 0; --i)
#define trav(a, x) for (auto& a : x)
#define f first 
#define s second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
 
const char nl = '\n';
const int INF = 1e9;
const ll MOD = 998244353;
const int mxN = 3e5+5;

ll Bob(vpi e){
    trav(i,e){
        i.f=(i.f-4337+5000)%5000;
        if(i.f==0) i.f=5000;
        i.s=(i.s-4337+5000)%5000;
        if(i.s==0) i.s=5000;
    }
    set<pi> st;
    st.insert(all(e));
    ll res=0;
    F0R(i,60){
        F0R(j,82){
            if(st.find({j*60+i+1,(j+1)*60+i+2})!=st.end()){
                res+=(1LL<<i);
                break;
            }
        }
    }
    return res;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...