Submission #1011804

# Submission time Handle Problem Language Result Execution time Memory
1011804 2024-07-01T08:53:13 Z 12345678 Magic Show (APIO24_show) C++17
0 / 100
1 ms 832 KB
#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);
        ll nl=l*v/d;
        a=((a+((x*(u-a)/d)%nl)*l)*nl+nl)%nl;
        l=nl;
    }
    return a;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 820 KB Correct.
2 Incorrect 1 ms 832 KB Incorrect answer.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 820 KB Correct.
2 Incorrect 1 ms 832 KB Incorrect answer.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 820 KB Correct.
2 Incorrect 1 ms 832 KB Incorrect answer.
3 Halted 0 ms 0 KB -