이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "meetings.h"
using namespace std ;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()) ;
int rand(int l , int r)
{
	return uniform_int_distribution<int>(l , r)(rng) ;
}
const int MAX = 2004 ;
int n ;
vector< pair<int , int> >ans ;
vector<int>subtree[MAX] ;
int curroot ;
bool cmp(int &a , int &b)
{
	return (Query(curroot , a , b) == a) ;
}
void solve(int root , vector<int>v)
{
	if(!v.size())
		return ;
	curroot = root ;
	shuffle(v.begin() , v.end() , rng) ;
	subtree[root].clear() ;
	for(auto &node : v)
		subtree[node].clear() ;
	int x = v.back() ;
	v.pop_back() ;
	vector<int>path = {x} ;
	for(auto &node : v)
	{
		int lca = Query(root , x , node) ;
		if(lca != node)
			subtree[lca].push_back(node) ;
		if(lca != root)
			path.push_back(lca) ;
	}
	sort(path.begin() , path.end()) ;
	path.erase(unique(path.begin() , path.end()) , path.end()) ;
	sort(path.begin() , path.end() , cmp) ;
	ans.emplace_back(root , path[0]) ;
	for(int i = 0 ; i+1 < path.size() ; ++i)
		ans.emplace_back(path[i] , path[i+1]) ;
	solve(root , subtree[root]) ;
	for(auto &node : path)
		solve(node , subtree[node]) ;
}
void Solve(int N) 
{
	n = N ;
	int root = rand(0 , n-1) ;
	vector<int>v ;
	for(int i = 0 ; i < n ; ++i)
	{
		if(i != root)
			v.push_back(i) ;
	}
	solve(root , v) ;
	for(auto &p : ans)
		Bridge(min(p.first , p.second) , max(p.first , p.second)) ;
}
컴파일 시 표준 에러 (stderr) 메시지
meetings.cpp: In function 'void solve(int, std::vector<int>)':
meetings.cpp:52:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |  for(int i = 0 ; i+1 < path.size() ; ++i)
      |                  ~~~~^~~~~~~~~~~~~| # | 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... |