Submission #753367

# Submission time Handle Problem Language Result Execution time Memory
753367 2023-06-05T06:06:01 Z Dan4Life Meetings (JOI19_meetings) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
//#include "meetings.h"
using namespace std;
using vi = vector<int>;
#define pb push_back
#define sz(a) (int)a.size()
const int mxN = (int)2e3+10;
int n, used[mxN];
vi v[mxN];
 
void mergeSort(vi &v, int a, int b){
	if(sz(v)<=1) return;
	int mid = sz(v)/2;
	vi w,x; w.clear(), x.clear();
	for(int i = 0; i < mid; i++) w.pb(v[i]);
	for(int i = mid; i < sz(v); i++) x.pb(v[i]);
	mergeSort(w,a,b), mergeSort(x,a,b); v.clear();
	int i = 0, j = 0;
	while(i<sz(w) and j<sz(x)){
		if(Query(a,w[i],x[j])==w[i]) v.pb(w[i++]);
		else v.pb(x[j++]);
	}
	while(i<sz(w)) v.pb(w[i++]);
	while(j<sz(x)) v.pb(x[j++]);
}
 
void bridge(int a, int b){ return Bridge(min(a,b),max(a,b)); }
 
void recur(int a, vi &w){
	if(w.empty()) return;
	int b = w[rand()%sz(w)]; used[a]=used[b]=1;
	vi path, v[n+1]; path.clear();
	for(auto i : w){ if(!used[i]){
		int x = Query(a,b,i);
		if(x==i) path.pb(i),used[i]=1;
		else v[x].pb(i);
	} }
	mergeSort(path,a,b);
	if(path.empty()) bridge(a,b);
	else bridge(a,path[0]),bridge(path.back(),b);
	for(int i = 0; i < sz(path)-1; i++) bridge(path[i],path[i+1]);
	for(auto u : path) recur(u,v[u]);
 	recur(a,v[a]); recur(b,v[b]);
}
 
void Solve(int N) {
	n = N; int x = rand()%N;
	for(int i = 0; i < n; i++) if(x!=i) v[x].pb(i);
	random_shuffle(begin(v[x]),end(v[x])); recur(x,v[x]);
}

Compilation message

meetings.cpp: In function 'void mergeSort(vi&, int, int)':
meetings.cpp:20:6: error: 'Query' was not declared in this scope
   20 |   if(Query(a,w[i],x[j])==w[i]) v.pb(w[i++]);
      |      ^~~~~
meetings.cpp: In function 'void bridge(int, int)':
meetings.cpp:27:35: error: 'Bridge' was not declared in this scope; did you mean 'bridge'?
   27 | void bridge(int a, int b){ return Bridge(min(a,b),max(a,b)); }
      |                                   ^~~~~~
      |                                   bridge
meetings.cpp: In function 'void recur(int, vi&)':
meetings.cpp:34:11: error: 'Query' was not declared in this scope
   34 |   int x = Query(a,b,i);
      |           ^~~~~