Submission #123815

# Submission time Handle Problem Language Result Execution time Memory
123815 2019-07-02T07:22:40 Z 김세빈(#3028) Meetings (JOI19_meetings) C++14
0 / 100
298 ms 262148 KB
#include <bits/stdc++.h>

#include "meetings.h"

using namespace std;

vector <int> T[2020];
int S[2020];
bool chk[2020];

int dfs1(int p, int r)
{
	S[p] = 1;
	
	for(int &t: T[p]){
		if(t != r){
			S[p] += dfs1(t, p);
		}
	}
	
	return S[p];
}

void dfs2(int p, int r, int x)
{
	int v;
	
	for(int t: T[p]){
		if(t != r){
			v = Query(t, p, x);
			if(v == p) continue;
			else if(v == t){
				dfs2(t, p, x);
				return;
			}
			else{
				chk[v] = chk[x] = 1;
				for(int &u: T[p]){
					if(u == t) u = v;
				}
				for(int &u: T[t]){
					if(u == p) u = v;
				}
				T[v].push_back(p);
				T[v].push_back(t);
				if(v != x){
					T[v].push_back(x);
					T[x].push_back(v);
				}
			}
		}
	}
	
	chk[x] = 1;
	T[p].push_back(x);
	T[x].push_back(p);
}

void Solve(int n)
{
	int i, j, v;
	
	v = Query(0, 1, 2);
	chk[v] = 1;
	
	for(i=0; i<3; i++){
		chk[i] = 1;
		if(i != v){
			T[i].push_back(v);
			T[v].push_back(i);
		}
	}
	
	for(i=3; i<n; i++){
		if(chk[i]) continue;
		dfs1(0, 0);
		
		for(j=1; j<=n; j++){
			sort(T[j].begin(), T[j].end(), [&](int &a, int &b){
				return S[a] > S[b];
			});
		}
		
		dfs2(0, 0, i);
	}
	
	for(i=0; i<n; i++){
		for(int &t: T[i]){
			if(i < t) Bridge(i, t);
		}
	}
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 2 ms 380 KB Wrong Answer [5]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 2 ms 380 KB Wrong Answer [5]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 2 ms 380 KB Wrong Answer [5]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 298 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -