Submission #1016835

# Submission time Handle Problem Language Result Execution time Memory
1016835 2024-07-08T13:08:00 Z NValchanov Magic Show (APIO24_show) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "Alice.h"
 
using namespace std;
 
vector<pair<int,int>> Alice()
{
    int N=5000;
    long long x = setN(N);
    vector < pair < int, int > > edges;
  
    for (int i = 1; i < N; i++) 
      edges.push_back({x % i + 1, i + 1});
  
    return edges;
}
#include <bits/stdc++.h>
#include "Bob.h"

#define endl '\n'

using namespace std;

typedef __int128_t ll;

/// EXTENDED GCD :(

pair < ll, pair < ll, ll > > extgcd(ll a, ll b)
{
    ll x = 1;
    ll y = 0;
    
    while(b)
    {
        ll tmp = a / b;
        a -= (tmp * b);
        x -= (tmp * y);
        swap(a, b);
        swap(x, y);
    }

    return {a, {x, y}};
}

ll Bob(vector < pair < int, int > > edges)
{

    /// CRT

    ll l = 0;
    ll ans = 0;

    for(pair < int, int > e : edges)
    {
        if(l >= 1e18)
            break;

        ll u = e.first;
        ll v = e.second;

        if(u > v)
            swap(u, v);

        u--;
        v--;

        if(ans == 0)
        {
            ans = u;
            l = v;
            continue;
        }

        pair < ll, pair < ll , ll > > g = extgcd(l, v);

        ll d = g.first;
        ll x = g.second.first;
        ll y = g.second.second;

        ans = ans + (x * (u - ans) / d) % (v / d) * l;
        l = l * v / d;
        ans = (ans % l + l) % l;
    }

    return ans;
}

Compilation message

Bob.cpp:29:4: error: ambiguating new declaration of 'll Bob(std::vector<std::pair<int, int> >)'
   29 | ll Bob(vector < pair < int, int > > edges)
      |    ^~~
In file included from Bob.cpp:2:
Bob.h:3:11: note: old declaration 'long long int Bob(std::vector<std::pair<int, int> >)'
    3 | long long Bob(std::vector<std::pair<int,int>> V);
      |           ^~~
Bob.cpp: In function 'll Bob(std::vector<std::pair<int, int> >)':
Bob.cpp:62:12: warning: unused variable 'y' [-Wunused-variable]
   62 |         ll y = g.second.second;
      |            ^