#include "Alice.h"
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define vll vector<ll>
#define pll pair<ll, ll>
typedef long long ll;
// 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().
vector<pair<int,int>> Alice(){
    ll n=5000;
    ll tar=setN(n);
    vector<pair<int, int>> re;
        ll f=tar/n+1;
        ll s=tar%n+1;
        cout<<"f: "<<f<<'\n';
        cout<<"s: "<<s<<'\n';
        if(f==s){
            for(ll i=1;i<=n;i++){
                if(i==tar) continue;
                re.pb({i, tar});
            }
            return re;
        }
        ll pt=1;
        for(ll rep=0;rep<n/2-1;rep++){
            while(pt==f || pt==s) pt++;
            re.pb({pt, f});
            pt++;
        }
        for(ll rep=0;rep<n/2-1;rep++){
            while(pt==f || pt==s) pt++;
            re.pb({pt, s});
            pt++;
        }
        re.pb({f, s});
    return re;
}
#include "Bob.h"
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define vll vector<ll>
#define pll pair<ll, ll>
typedef long long ll;
// 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().
namespace{
    const ll inf=1e9;
}
long long Bob(std::vector<std::pair<int,int>> V){
	// add your code here
    ll n=5000;
    vll cnt(n+1);
    for(auto &[x, y]:V){
        cnt[x]++;
        cnt[y]++;
    }
    vll con;
    for(ll i=1;i<=n;i++){
        if(cnt[i]>1){
            con.pb(i);
        }
    }
    if(con.size()==1){
        ll tep=con[0];
        tep--;
        return tep*n+tep;
    }
    int mn1=inf, mn2=inf;
    for(auto &[x, y]:V){
        if((x==con[0] && y==con[1]) || (x==con[1] && y==con[0])){
            continue;
        }
        if(x==con[0]){
            mn1=min(mn1, y);
        }
        else if(y==con[0]){
            mn1=min(mn1, x);
        }
        else if(x==con[1]){
            mn2=min(mn2, y);
        }
        else{
            assert(y==con[1]);
            mn2=min(mn2, x);
        }
    }
    if(mn1>mn2){
        swap(con[0], con[1]);
    }
    con[0]--;
    con[1]--;
    return con[0]*n+con[1];
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |