답안 #73362

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
73362 2018-08-28T07:53:08 Z Navick Simurgh (IOI17_simurgh) C++17
51 / 100
277 ms 3708 KB
#include "simurgh.h"
#include <bits/stdc++.h>

#define F first
#define S second
#define pii pair<int, int>
#define pb push_back

using namespace std;

typedef long long ll;
typedef long double ld;

const int maxN = 510, maxE = maxN * maxN / 2;

int cmp[maxN], from[maxE], to[maxE], r, n;
bool mark[maxN];
int good[maxE];
bool flag[maxN];

vector <int> adj[maxN], ans, tree;
vector <int> edge[maxN];

void DFS(int v, int id)
{
	mark[v] = true;
	cmp[v] = id;

	for (auto i : adj[v])
	{
		int u = from[i] + to[i] - v;
		if(u == r || mark[u]) continue ;
		tree.pb(i);
		DFS(u, id);
	}
}

void solve(int v)
{
	memset(mark, 0, sizeof mark);
	r = v; 
	int sz = 0;
	tree.clear();
	
	for (int i=0; i<n; i++)
	{
		if(i == v || mark[i]) continue ;
		DFS(i, sz);
		sz ++;
	}
	
	memset(flag, 0, sizeof flag);

	for (auto i : adj[v])
	{
		int u = from[i] + to[i] - v;
		if(good[i] == 1 && !flag[cmp[u]]) edge[cmp[u]].pb(i), flag[cmp[u]] = true;
		else if(good[i] == 0) edge[cmp[u]].pb(i);
	}


	//cout << " FIRST " << v << " --> " << sz << endl;
	//for (auto x : tree) cout << x << ' '; cout << endl;

	for (int i=0; i<sz; i++)
		tree.pb(edge[i][0]);
	
	int last_ans = -1;
	for (int i=0; i<sz; i++)
	{
		int td = edge[i].size(), mx = -1;
		vector <int> tmp;

		if(last_ans != -1) tmp.pb(last_ans), mx = last_ans;
		else
		{
			int r = count_common_roads(tree);
			tmp.pb(r);
			mx = r;
			last_ans = r;
		}

		for (int j=1; j<td; j++)
		{
			tree[n - sz - 1 + i] = edge[i][j];
			int r = count_common_roads(tree);
			tmp.pb(r);
			mx = max(mx, r);
			last_ans = r;
		}
		for (int j=0; j<td; j++) {
			if(tmp[j] == mx) ans.pb(edge[i][j]), good[edge[i][j]] = 1;
			else good[edge[i][j]] = 2;
		}
	}

	//cout << ans.size() << endl;

	for (int i=0; i<sz; i++) edge[i].clear();

}

std::vector<int> find_roads(int _n, std::vector<int> u, std::vector<int> v) {
	int m = u.size(); n = _n;
	for (int i=0; i<m; i++)
	{
		from[i] = u[i];
		to[i] = v[i];
		adj[u[i]].pb(i);
		adj[v[i]].pb(i);
	}

	for (int i=0; i<n; i++) solve(i);

	sort(ans.begin(), ans.end());
	ans.resize(unique(ans.begin(), ans.end()) - ans.begin());
	
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB correct
2 Correct 2 ms 484 KB correct
3 Correct 2 ms 484 KB correct
4 Correct 2 ms 484 KB correct
5 Correct 2 ms 636 KB correct
6 Correct 3 ms 636 KB correct
7 Correct 4 ms 636 KB correct
8 Correct 2 ms 636 KB correct
9 Correct 2 ms 636 KB correct
10 Correct 3 ms 636 KB correct
11 Correct 3 ms 636 KB correct
12 Correct 2 ms 636 KB correct
13 Correct 2 ms 636 KB correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB correct
2 Correct 2 ms 484 KB correct
3 Correct 2 ms 484 KB correct
4 Correct 2 ms 484 KB correct
5 Correct 2 ms 636 KB correct
6 Correct 3 ms 636 KB correct
7 Correct 4 ms 636 KB correct
8 Correct 2 ms 636 KB correct
9 Correct 2 ms 636 KB correct
10 Correct 3 ms 636 KB correct
11 Correct 3 ms 636 KB correct
12 Correct 2 ms 636 KB correct
13 Correct 2 ms 636 KB correct
14 Correct 5 ms 636 KB correct
15 Correct 4 ms 636 KB correct
16 Correct 4 ms 636 KB correct
17 Correct 4 ms 636 KB correct
18 Correct 5 ms 636 KB correct
19 Correct 5 ms 636 KB correct
20 Correct 5 ms 636 KB correct
21 Correct 5 ms 636 KB correct
22 Correct 3 ms 636 KB correct
23 Correct 3 ms 636 KB correct
24 Correct 4 ms 636 KB correct
25 Correct 3 ms 636 KB correct
26 Correct 3 ms 708 KB correct
27 Correct 4 ms 708 KB correct
28 Correct 3 ms 708 KB correct
29 Correct 3 ms 708 KB correct
30 Correct 3 ms 708 KB correct
31 Correct 3 ms 708 KB correct
32 Correct 4 ms 708 KB correct
33 Correct 3 ms 708 KB correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB correct
2 Correct 2 ms 484 KB correct
3 Correct 2 ms 484 KB correct
4 Correct 2 ms 484 KB correct
5 Correct 2 ms 636 KB correct
6 Correct 3 ms 636 KB correct
7 Correct 4 ms 636 KB correct
8 Correct 2 ms 636 KB correct
9 Correct 2 ms 636 KB correct
10 Correct 3 ms 636 KB correct
11 Correct 3 ms 636 KB correct
12 Correct 2 ms 636 KB correct
13 Correct 2 ms 636 KB correct
14 Correct 5 ms 636 KB correct
15 Correct 4 ms 636 KB correct
16 Correct 4 ms 636 KB correct
17 Correct 4 ms 636 KB correct
18 Correct 5 ms 636 KB correct
19 Correct 5 ms 636 KB correct
20 Correct 5 ms 636 KB correct
21 Correct 5 ms 636 KB correct
22 Correct 3 ms 636 KB correct
23 Correct 3 ms 636 KB correct
24 Correct 4 ms 636 KB correct
25 Correct 3 ms 636 KB correct
26 Correct 3 ms 708 KB correct
27 Correct 4 ms 708 KB correct
28 Correct 3 ms 708 KB correct
29 Correct 3 ms 708 KB correct
30 Correct 3 ms 708 KB correct
31 Correct 3 ms 708 KB correct
32 Correct 4 ms 708 KB correct
33 Correct 3 ms 708 KB correct
34 Correct 167 ms 1708 KB correct
35 Correct 181 ms 1708 KB correct
36 Correct 170 ms 1708 KB correct
37 Correct 11 ms 1708 KB correct
38 Correct 193 ms 1708 KB correct
39 Correct 149 ms 1708 KB correct
40 Correct 119 ms 1708 KB correct
41 Correct 277 ms 1708 KB correct
42 Correct 177 ms 1708 KB correct
43 Correct 88 ms 1708 KB correct
44 Correct 88 ms 1708 KB correct
45 Correct 95 ms 1708 KB correct
46 Correct 73 ms 1708 KB correct
47 Correct 30 ms 1708 KB correct
48 Correct 6 ms 1708 KB correct
49 Correct 11 ms 1708 KB correct
50 Correct 37 ms 1708 KB correct
51 Correct 83 ms 1708 KB correct
52 Correct 69 ms 1708 KB correct
53 Correct 67 ms 1708 KB correct
54 Correct 115 ms 1708 KB correct
55 Correct 137 ms 1708 KB correct
56 Correct 83 ms 1708 KB correct
57 Correct 91 ms 1708 KB correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1708 KB correct
2 Correct 2 ms 1708 KB correct
3 Incorrect 130 ms 3708 KB WA in grader: NO
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB correct
2 Correct 2 ms 484 KB correct
3 Correct 2 ms 484 KB correct
4 Correct 2 ms 484 KB correct
5 Correct 2 ms 636 KB correct
6 Correct 3 ms 636 KB correct
7 Correct 4 ms 636 KB correct
8 Correct 2 ms 636 KB correct
9 Correct 2 ms 636 KB correct
10 Correct 3 ms 636 KB correct
11 Correct 3 ms 636 KB correct
12 Correct 2 ms 636 KB correct
13 Correct 2 ms 636 KB correct
14 Correct 5 ms 636 KB correct
15 Correct 4 ms 636 KB correct
16 Correct 4 ms 636 KB correct
17 Correct 4 ms 636 KB correct
18 Correct 5 ms 636 KB correct
19 Correct 5 ms 636 KB correct
20 Correct 5 ms 636 KB correct
21 Correct 5 ms 636 KB correct
22 Correct 3 ms 636 KB correct
23 Correct 3 ms 636 KB correct
24 Correct 4 ms 636 KB correct
25 Correct 3 ms 636 KB correct
26 Correct 3 ms 708 KB correct
27 Correct 4 ms 708 KB correct
28 Correct 3 ms 708 KB correct
29 Correct 3 ms 708 KB correct
30 Correct 3 ms 708 KB correct
31 Correct 3 ms 708 KB correct
32 Correct 4 ms 708 KB correct
33 Correct 3 ms 708 KB correct
34 Correct 167 ms 1708 KB correct
35 Correct 181 ms 1708 KB correct
36 Correct 170 ms 1708 KB correct
37 Correct 11 ms 1708 KB correct
38 Correct 193 ms 1708 KB correct
39 Correct 149 ms 1708 KB correct
40 Correct 119 ms 1708 KB correct
41 Correct 277 ms 1708 KB correct
42 Correct 177 ms 1708 KB correct
43 Correct 88 ms 1708 KB correct
44 Correct 88 ms 1708 KB correct
45 Correct 95 ms 1708 KB correct
46 Correct 73 ms 1708 KB correct
47 Correct 30 ms 1708 KB correct
48 Correct 6 ms 1708 KB correct
49 Correct 11 ms 1708 KB correct
50 Correct 37 ms 1708 KB correct
51 Correct 83 ms 1708 KB correct
52 Correct 69 ms 1708 KB correct
53 Correct 67 ms 1708 KB correct
54 Correct 115 ms 1708 KB correct
55 Correct 137 ms 1708 KB correct
56 Correct 83 ms 1708 KB correct
57 Correct 91 ms 1708 KB correct
58 Correct 2 ms 1708 KB correct
59 Correct 2 ms 1708 KB correct
60 Incorrect 130 ms 3708 KB WA in grader: NO
61 Halted 0 ms 0 KB -