Submission #753349

# Submission time Handle Problem Language Result Execution time Memory
753349 2023-06-05T05:50:57 Z Dan4Life Meetings (JOI19_meetings) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "meetings.h"
using namespace std;
 
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) begin(a),end(a)
const int mxN = (int)2e3+10;
int n, used[mxN];
set<int> S[mxN];
map<array<int,3>,int> M;
 
int query(int a, int b, int c){
	if(a>b) swap(a,b);
	if(b>c) swap(b,c);
	if(a>b) swap(a,b);
    if(M.count({a,b,c})) return M[{a,b,c}]
	return Query(a,b,c);
}
 
void mergeSort(vector<int> &v, int a, int b){
	if(sz(v)<=1) return;
	int mid = sz(v)/2;
	vector<int> 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 recur(int a, set<int> SS){
	if(SS.empty()) return;
	auto itr = SS.begin();
	int r = rand()%sz(SS);
	while(r--) itr++;
	int b = *itr; used[a]=used[b]=1;
	vector<int> path; path.clear();
  set<int> S[n+1];
  for(int i = 0; i < n; i++) S[i].clear();
	for(auto i : SS){ if(!used[i]){
			int x = query(a,b,i);
			if(x==i) path.pb(i),used[i]=1;
			else S[x].insert(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,S[u]);
  recur(a,S[a]); recur(b,S[b]);
}
 
void Solve(int N) {
	n = N; vector<int> v;
	for(int i = 1; i < n; i++) S[0].insert(i);
	recur(0,S[0]);
}

Compilation message

meetings.cpp: In function 'int query(int, int, int)':
meetings.cpp:17:43: error: expected ';' before 'return'
   17 |     if(M.count({a,b,c})) return M[{a,b,c}]
      |                                           ^
      |                                           ;
   18 |  return Query(a,b,c);
      |  ~~~~~~