Submission #123819

# Submission time Handle Problem Language Result Execution time Memory
123819 2019-07-02T07:25:09 Z 김세빈(#3028) Meetings (JOI19_meetings) C++14
29 / 100
2000 ms 900 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);
				}
				return;
			}
		}
	}
	
	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);
		dfs2(0, 0, i);
	}
	
	for(i=0; i<n; i++){
		for(int &t: T[i]){
			if(i < t) Bridge(i, t);
		}
	}
}

Compilation message

meetings.cpp: In function 'void Solve(int)':
meetings.cpp:62:9: warning: unused variable 'j' [-Wunused-variable]
  int i, j, v;
         ^
# 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 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
# 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 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 504 KB Output is correct
26 Correct 3 ms 376 KB Output is correct
# 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 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 504 KB Output is correct
26 Correct 3 ms 376 KB Output is correct
27 Correct 10 ms 376 KB Output is correct
28 Correct 9 ms 376 KB Output is correct
29 Correct 10 ms 376 KB Output is correct
30 Correct 10 ms 504 KB Output is correct
31 Correct 7 ms 376 KB Output is correct
32 Correct 9 ms 380 KB Output is correct
33 Correct 11 ms 376 KB Output is correct
34 Correct 14 ms 440 KB Output is correct
35 Correct 13 ms 376 KB Output is correct
36 Correct 11 ms 380 KB Output is correct
37 Correct 45 ms 504 KB Output is correct
38 Correct 68 ms 504 KB Output is correct
39 Correct 194 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 951 ms 692 KB Output is correct
2 Correct 1160 ms 900 KB Output is correct
3 Correct 1092 ms 896 KB Output is correct
4 Correct 1254 ms 808 KB Output is correct
5 Correct 754 ms 812 KB Output is correct
6 Correct 538 ms 768 KB Output is correct
7 Correct 626 ms 724 KB Output is correct
8 Correct 745 ms 756 KB Output is correct
9 Correct 739 ms 868 KB Output is correct
10 Correct 687 ms 888 KB Output is correct
11 Correct 841 ms 888 KB Output is correct
12 Execution timed out 3050 ms 892 KB Time limit exceeded
13 Halted 0 ms 0 KB -