답안 #799089

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
799089 2023-07-31T09:33:55 Z LittleCube Simurgh (IOI17_simurgh) C++17
51 / 100
88 ms 3636 KB
#include "simurgh.h"
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define F first
#define S second
using namespace std;

int vis[505], cc[505], base[505], out[505], no[505 * 505];
vector<pii> E[505];
vector<int> tree, ans;

void dfs(int u, int c)
{
	vis[u] = 1;
	cc[u] = c;
	for (auto [v, i] : E[u])
		if (!vis[v])
		{
			tree.emplace_back(i);
			dfs(v, c);
		}
}

vector<int> find_roads(int n, vector<int> u, vector<int> v)
{
	int m = u.size();
	for (int i = 0; i < m; i++)
	{
		E[u[i]].emplace_back(pii(v[i], i));
		E[v[i]].emplace_back(pii(u[i], i));
	}
	for (int i = 0; i < n; i++)
	{
		tree.clear();
		for (int j = 0; j < n; j++)
			vis[j] = 0, base[j] = -1, out[j] = -1;
		vis[i] = 1;
		for (auto j = 0; j < n; j++)
			if (!vis[j])
				dfs(j, j);
		// check
		vector<tuple<int, int, int>> queries;
		for (auto [j, id] : E[i])
			out[cc[j]] = id;
		
		for (auto [j, id] : E[i])
		{
			if(no[id])
				continue;
			vector<int> query = tree;
			for (int k = 0; k < n; k++)
				if (k != cc[j] && out[k] >= 0)
					query.emplace_back(out[k]);
			query.emplace_back(id);
			int res = count_common_roads(query);
			base[cc[j]] = max(base[cc[j]], res);
			queries.emplace_back(make_tuple(j, id, res));
		}
		for (auto [j, id, res] : queries)
			if (res == base[cc[j]])
				ans.emplace_back(id);
			else
				no[id] = 1;
	}	
	sort(ans.begin(), ans.end());
	ans.resize(unique(ans.begin(), ans.end()) - ans.begin());
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB correct
2 Correct 1 ms 212 KB correct
3 Correct 0 ms 212 KB correct
4 Correct 0 ms 212 KB correct
5 Correct 0 ms 212 KB correct
6 Correct 0 ms 212 KB correct
7 Correct 0 ms 212 KB correct
8 Correct 0 ms 212 KB correct
9 Correct 0 ms 212 KB correct
10 Correct 0 ms 212 KB correct
11 Correct 0 ms 212 KB correct
12 Correct 0 ms 212 KB correct
13 Correct 0 ms 212 KB correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB correct
2 Correct 1 ms 212 KB correct
3 Correct 0 ms 212 KB correct
4 Correct 0 ms 212 KB correct
5 Correct 0 ms 212 KB correct
6 Correct 0 ms 212 KB correct
7 Correct 0 ms 212 KB correct
8 Correct 0 ms 212 KB correct
9 Correct 0 ms 212 KB correct
10 Correct 0 ms 212 KB correct
11 Correct 0 ms 212 KB correct
12 Correct 0 ms 212 KB correct
13 Correct 0 ms 212 KB correct
14 Correct 2 ms 340 KB correct
15 Correct 1 ms 340 KB correct
16 Correct 1 ms 340 KB correct
17 Correct 1 ms 340 KB correct
18 Correct 1 ms 340 KB correct
19 Correct 1 ms 340 KB correct
20 Correct 1 ms 340 KB correct
21 Correct 1 ms 340 KB correct
22 Correct 1 ms 340 KB correct
23 Correct 1 ms 340 KB correct
24 Correct 1 ms 340 KB correct
25 Correct 1 ms 212 KB correct
26 Correct 1 ms 340 KB correct
27 Correct 1 ms 340 KB correct
28 Correct 1 ms 340 KB correct
29 Correct 1 ms 340 KB correct
30 Correct 1 ms 340 KB correct
31 Correct 1 ms 340 KB correct
32 Correct 1 ms 340 KB correct
33 Correct 1 ms 340 KB correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB correct
2 Correct 1 ms 212 KB correct
3 Correct 0 ms 212 KB correct
4 Correct 0 ms 212 KB correct
5 Correct 0 ms 212 KB correct
6 Correct 0 ms 212 KB correct
7 Correct 0 ms 212 KB correct
8 Correct 0 ms 212 KB correct
9 Correct 0 ms 212 KB correct
10 Correct 0 ms 212 KB correct
11 Correct 0 ms 212 KB correct
12 Correct 0 ms 212 KB correct
13 Correct 0 ms 212 KB correct
14 Correct 2 ms 340 KB correct
15 Correct 1 ms 340 KB correct
16 Correct 1 ms 340 KB correct
17 Correct 1 ms 340 KB correct
18 Correct 1 ms 340 KB correct
19 Correct 1 ms 340 KB correct
20 Correct 1 ms 340 KB correct
21 Correct 1 ms 340 KB correct
22 Correct 1 ms 340 KB correct
23 Correct 1 ms 340 KB correct
24 Correct 1 ms 340 KB correct
25 Correct 1 ms 212 KB correct
26 Correct 1 ms 340 KB correct
27 Correct 1 ms 340 KB correct
28 Correct 1 ms 340 KB correct
29 Correct 1 ms 340 KB correct
30 Correct 1 ms 340 KB correct
31 Correct 1 ms 340 KB correct
32 Correct 1 ms 340 KB correct
33 Correct 1 ms 340 KB correct
34 Correct 88 ms 1464 KB correct
35 Correct 81 ms 1620 KB correct
36 Correct 57 ms 1400 KB correct
37 Correct 6 ms 332 KB correct
38 Correct 84 ms 1668 KB correct
39 Correct 72 ms 1552 KB correct
40 Correct 59 ms 1352 KB correct
41 Correct 85 ms 1664 KB correct
42 Correct 84 ms 1608 KB correct
43 Correct 46 ms 1108 KB correct
44 Correct 37 ms 920 KB correct
45 Correct 43 ms 980 KB correct
46 Correct 35 ms 852 KB correct
47 Correct 16 ms 724 KB correct
48 Correct 3 ms 340 KB correct
49 Correct 6 ms 340 KB correct
50 Correct 20 ms 616 KB correct
51 Correct 53 ms 992 KB correct
52 Correct 37 ms 840 KB correct
53 Correct 33 ms 852 KB correct
54 Correct 46 ms 1108 KB correct
55 Correct 43 ms 980 KB correct
56 Correct 43 ms 980 KB correct
57 Correct 43 ms 1004 KB correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB correct
2 Correct 0 ms 212 KB correct
3 Incorrect 65 ms 3636 KB WA in grader: NO
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB correct
2 Correct 1 ms 212 KB correct
3 Correct 0 ms 212 KB correct
4 Correct 0 ms 212 KB correct
5 Correct 0 ms 212 KB correct
6 Correct 0 ms 212 KB correct
7 Correct 0 ms 212 KB correct
8 Correct 0 ms 212 KB correct
9 Correct 0 ms 212 KB correct
10 Correct 0 ms 212 KB correct
11 Correct 0 ms 212 KB correct
12 Correct 0 ms 212 KB correct
13 Correct 0 ms 212 KB correct
14 Correct 2 ms 340 KB correct
15 Correct 1 ms 340 KB correct
16 Correct 1 ms 340 KB correct
17 Correct 1 ms 340 KB correct
18 Correct 1 ms 340 KB correct
19 Correct 1 ms 340 KB correct
20 Correct 1 ms 340 KB correct
21 Correct 1 ms 340 KB correct
22 Correct 1 ms 340 KB correct
23 Correct 1 ms 340 KB correct
24 Correct 1 ms 340 KB correct
25 Correct 1 ms 212 KB correct
26 Correct 1 ms 340 KB correct
27 Correct 1 ms 340 KB correct
28 Correct 1 ms 340 KB correct
29 Correct 1 ms 340 KB correct
30 Correct 1 ms 340 KB correct
31 Correct 1 ms 340 KB correct
32 Correct 1 ms 340 KB correct
33 Correct 1 ms 340 KB correct
34 Correct 88 ms 1464 KB correct
35 Correct 81 ms 1620 KB correct
36 Correct 57 ms 1400 KB correct
37 Correct 6 ms 332 KB correct
38 Correct 84 ms 1668 KB correct
39 Correct 72 ms 1552 KB correct
40 Correct 59 ms 1352 KB correct
41 Correct 85 ms 1664 KB correct
42 Correct 84 ms 1608 KB correct
43 Correct 46 ms 1108 KB correct
44 Correct 37 ms 920 KB correct
45 Correct 43 ms 980 KB correct
46 Correct 35 ms 852 KB correct
47 Correct 16 ms 724 KB correct
48 Correct 3 ms 340 KB correct
49 Correct 6 ms 340 KB correct
50 Correct 20 ms 616 KB correct
51 Correct 53 ms 992 KB correct
52 Correct 37 ms 840 KB correct
53 Correct 33 ms 852 KB correct
54 Correct 46 ms 1108 KB correct
55 Correct 43 ms 980 KB correct
56 Correct 43 ms 980 KB correct
57 Correct 43 ms 1004 KB correct
58 Correct 0 ms 212 KB correct
59 Correct 0 ms 212 KB correct
60 Incorrect 65 ms 3636 KB WA in grader: NO
61 Halted 0 ms 0 KB -