Submission #753371

# Submission time Handle Problem Language Result Execution time Memory
753371 2023-06-05T06:10:11 Z Dan4Life Meetings (JOI19_meetings) C++17
0 / 100
91 ms 616 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, vis[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)]; vis[a]=vis[b]=1;
	vi path, v[n+1]; path.clear();
	for(auto i : w){ if(!vis[i]){
		int x = Query(a,b,i);
		if(x==i) path.pb(i),vis[i]=1;
		else v[x].pb(i);
	} } path.pb(a), mergeSort(path,a,b),  path.pb(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]);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 336 KB Output is correct
2 Incorrect 0 ms 336 KB Wrong Answer [1]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 336 KB Output is correct
2 Incorrect 0 ms 336 KB Wrong Answer [1]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 336 KB Output is correct
2 Incorrect 0 ms 336 KB Wrong Answer [1]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 91 ms 616 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -