Submission #1011807

#TimeUsernameProblemLanguageResultExecution timeMemory
101180712345678Magic Show (APIO24_show)C++17
100 / 100
2 ms1084 KiB
#include <bits/stdc++.h>
#include "Alice.h"

using namespace std;

std::vector<std::pair<int,int>> Alice(){
    int N=5000;
    long long x=setN(N);
    vector<pair<int, int>> edg;
    for (int i=1; i<N; i++) edg.push_back({x%i+1, i+1});
    return edg;
}
#include <bits/stdc++.h>
#include "Bob.h"

using namespace std;

#define ll __int128_t

tuple<ll, ll, ll> euclid(ll a, ll b)
{
    ll u=1, v=0, tmp;
    while (b)
    {
        tmp=a/b;
        a-=tmp*b;
        u-=tmp*v;
        swap(a, b);
        swap(u, v);
    }
    return make_tuple(a, u, v);
}

long long Bob(std::vector<std::pair<int,int>> V){
    ll a=0, l=0;
    for (auto [u, v]:V)
    {
        if (l>=1e18) break;
        if (u>v) swap(u, v);
        u--; v--;
        if (a==0)
        {
            a=u, l=v;
            continue;
        }
        auto [d, x, y]=euclid(l, v);
        a=a+(x*(u-a)/d)%(v/d)*l;
        l=l*v/d;
        a=((a%l)+l)%l;
    }
    return a;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...