이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "Alice.h"
#define endl '\n'
using namespace std;
typedef long long ll;
vector < pair < int, int > > Alice()
{
int x = setN(5000);
vector < pair < int, int > > edges;
for(int i = 1; i < 5000; 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 long long ll;
/// EXTENDED GCD :(
pair < ll, pair < ll, ll > > extgcd(ll a, ll b)
{
if(b == 0)
return {a, {1, 0}};
pair < ll, pair < ll, ll > > g = extgcd(b, a % b);
ll d = g.first;
ll x = g.second.first;
ll y = g.second.second;
ll x1 = y;
ll y1 = x - y * (a / b);
return {d, {x1, y1}};
}
ll Bob(vector < pair < int, int > > edges)
{
/// CRT
ll l = 0;
ll ans = 0;
for(pair < int, int > e : edges)
{
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;
if(l >= 1e18)
break;
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
Bob.cpp: In function 'll Bob(std::vector<std::pair<int, int> >)':
Bob.cpp:59:12: warning: unused variable 'y' [-Wunused-variable]
59 | ll y = g.second.second;
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |