Submission #753365

# Submission time Handle Problem Language Result Execution time Memory
753365 2023-06-05T06:05:32 Z Dan4Life Meetings (JOI19_meetings) C++17
0 / 100
93 ms 600 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((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 bridge(int, int)':
meetings.cpp:27:43: warning: left operand of comma operator has no effect [-Wunused-value]
   27 | void bridge(int a, int b){ return Bridge((a,b),max(a,b)); }
      |                                           ^
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 93 ms 600 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -