#include "meetings.h"
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
#define ll long long
#define ull unsigned ll
#define pb push_back
#define pii pair<int,int>
#define pl pair<ll,ll>
#define F first
#define S second
#define pq priority_queue
#define all(x) x.begin(), x.end()
#define deb(x) cout << #x << " = " << x << '\n';
#define deb2(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << '\n';
constexpr int M = 2007;
constexpr bool debug = 0;
int n;
vector<int> adj[M];
map<ll,int> ans;
queue<int> emp;
ll detup(vector<int> ok){
    return ok[0]+ok[1]*M+ok[2]*M*M;
}
int Quer(vector<int> ok){
    sort(all(ok));
    int sus = ans[detup(ok)];
    if(sus == 0){
        sus = Query(ok[0], ok[1], ok[2])+1;
        ans[detup(ok)] = sus;
    }
    return sus-1;
}
void DFS(int s, int p, queue<int> sub){
    queue<int> osub, csub;
    //if(sub.empty()) break;
    while(!sub.empty()){
      int coc = sub.front();
      sub.pop();
        while(!sub.empty()){
            int x = sub.front();
            sub.pop();
            int y = Quer({s, coc, x});
            if(y == x){
                csub.push(coc);
                coc = x;
            }
            else if(y == s){
                osub.push(x);
            }
            else{
                csub.push(x);
            }    
        }
        Bridge(s,coc);
        DFS(coc, s, csub);
        csub = emp;
        sub = osub;
        osub = emp;
    }
}
void Solve(int N){
    n = N;
    queue<int> tot;
    for(int i = 1; i < N; i++) tot.push(i);
    DFS(0,0, tot);
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |