#include <vector>
#include "Alice.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
// you may define some global variables, but it does not work if you try to transfer any information from function Alice() to function Bob() through these variables.
// you had better not use the same global variables in function Alice() and in function Bob().
std::vector<std::pair<int,int>> Alice(){
long long x = setN(5000);
vector<pair<int, int>>vp;
if (x==25000000)
{
for (int i=1 ; i<5000 ; i++)
vp.push_back({i, i+1});
return vp;
}
ll a = x/5000;
ll b = x%5000;
a++;
b++;
ll cnt = 0;
ll val = 1;
while (cnt*2<4998)
{
while (val==a or val==b) val++;
cnt++;
vp.push_back({val++, a});
}
cnt = 0;
while (cnt*2<4998)
{
while (val==a or val==b) val++;
cnt++;
vp.push_back({val++, b});
}
if (a!=b)
vp.push_back({a, b});
else
vp.push_back({a, val++});
return vp;
}
#include <vector>
#include "Bob.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
// you may define some global variables, but it does not work if you try to transfer any information from function Alice() to function Bob() through these variables.
// you had better not use the same global variables in function Alice() and in function Bob().
long long Bob(std::vector<std::pair<int,int>> V){
map<ll,ll>frq;
set<ll>s;
for (auto it:V)
{
frq[it.first]++;
frq[it.second]++;
if (frq[it.first]>1)
s.insert(it.first);
if (frq[it.second]>1)
s.insert(it.second);
}
if (s.size()>2)
{
return 25000000;
}
ll a=-1, b=-1;
if (s.size()==1)
a = b = *s.begin();
else
{
ll mx1 = -1, mx2 = -1;
a = *s.begin();
b = *(--s.end());
for (auto it:V)
{
ll x = it.first, y = it.second;
if (x>y) swap(x, y);
if (x==a and y==b) continue;
if (x==a) mx1 = max(mx1, y);
if (x==b) mx2 = max(mx2, y);
if (y==a) mx1 = max(mx1, x);
if (y==b) mx2 = max(mx2, x);
}
if (mx2<mx1) swap(a,b);
}
return (a-1)*5000+b-1;
}//g++ Alice.cpp grader.cpp Bob.cpp -o a.exe