Submission #250225

# Submission time Handle Problem Language Result Execution time Memory
250225 2020-07-17T08:52:28 Z srvlt Simurgh (IOI17_simurgh) C++14
51 / 100
211 ms 6648 KB
#include "simurgh.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define ld long double
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
template <typename T> using ord_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int n0 = 243, m0 = 29000;
int N, M, used[n0], ch[m0], par[n0], sp[m0], same[m0];
int in[n0], out[n0], T, common;
vector <int> g[n0], V, U, query;

void dfs(int v) {
	used[v] = 1;
	in[v] = ++T;
	for (int i : g[v]) {
		int to = V[i] ^ U[i] ^ v;
		if (used[to]) continue;
		par[to] = i;
		query.pb(i);
		sp[i] =  1;
		dfs(to);
	}
	out[v] = T;
}

bool upper(int v, int u) {
	return in[v] <= in[u] && out[u] <= out[v];
}

void add(int x) {
	query.pb(x);
}

void del(int x) {
	for (int i = 0; i < SZ(query); i++) {
		if (query[i] == x) {
			query.erase(query.begin() + i);
			break;
		}
	}
}

std::vector<int> find_roads(int n, std::vector<int> u, std::vector<int> v) {
	memset(& ch, -1, sizeof(ch));
	N = n, M = u.size(), V = v, U = u;
	for (int i = 0; i < M; i++)
		g[v[i]].pb(i), g[u[i]].pb(i);
	dfs(0);
	vector <int> path;
	common = count_common_roads(query);
	for (int i = 0; i < M; i++) {
		if (sp[i]) continue;
		int a = v[i], b = u[i];
		if (upper(b, a)) swap(a, b);
		assert(upper(a, b));
		path.clear();
		while (b != a) {
			path.pb(par[b]);
			b = v[par[b]] ^ u[par[b]] ^ b;
		}
		add(i);
		for (int j : path) {
			if (ch[i] != -1 && ch[j] != -1) continue;
			del(j);
			int x = count_common_roads(query);
			if (x == common) {
				if (ch[j] != -1) ch[i] = ch[j];
				same[j] = 1;
			}	else {
				if (x == common - 1) {
					ch[i] = 0;
					ch[j] = 1;
				}
				if (x == common + 1) {
					ch[i] = 1;
					ch[j] = 0;
				}
			}
			add(j);
		}
		if (ch[i] == -1) ch[i] = 0;
		del(i);
		for (int j : path) {
			if (same[j]) ch[j] = ch[i];
			same[j] = 0;
		}
	}
	vector <int> res;
	for (int i = 0; i < M; i++) {
		if (ch[i] == -1) ch[i] = 1;
		if (ch[i] == 1) res.pb(i);
	}
	return res;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 512 KB correct
2 Correct 1 ms 512 KB correct
3 Correct 0 ms 512 KB correct
4 Correct 1 ms 384 KB correct
5 Correct 0 ms 512 KB correct
6 Correct 0 ms 512 KB correct
7 Correct 1 ms 512 KB correct
8 Correct 0 ms 512 KB correct
9 Correct 1 ms 384 KB correct
10 Correct 1 ms 512 KB correct
11 Correct 0 ms 512 KB correct
12 Correct 0 ms 384 KB correct
13 Correct 0 ms 384 KB correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 512 KB correct
2 Correct 1 ms 512 KB correct
3 Correct 0 ms 512 KB correct
4 Correct 1 ms 384 KB correct
5 Correct 0 ms 512 KB correct
6 Correct 0 ms 512 KB correct
7 Correct 1 ms 512 KB correct
8 Correct 0 ms 512 KB correct
9 Correct 1 ms 384 KB correct
10 Correct 1 ms 512 KB correct
11 Correct 0 ms 512 KB correct
12 Correct 0 ms 384 KB correct
13 Correct 0 ms 384 KB correct
14 Correct 3 ms 512 KB correct
15 Correct 3 ms 512 KB correct
16 Correct 3 ms 512 KB correct
17 Correct 3 ms 512 KB correct
18 Correct 1 ms 512 KB correct
19 Correct 2 ms 512 KB correct
20 Correct 2 ms 484 KB correct
21 Correct 2 ms 512 KB correct
22 Correct 2 ms 512 KB correct
23 Correct 2 ms 512 KB correct
24 Correct 2 ms 512 KB correct
25 Correct 1 ms 512 KB correct
26 Correct 2 ms 512 KB correct
27 Correct 2 ms 512 KB correct
28 Correct 1 ms 512 KB correct
29 Correct 1 ms 512 KB correct
30 Correct 2 ms 512 KB correct
31 Correct 2 ms 512 KB correct
32 Correct 2 ms 512 KB correct
33 Correct 3 ms 512 KB correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 512 KB correct
2 Correct 1 ms 512 KB correct
3 Correct 0 ms 512 KB correct
4 Correct 1 ms 384 KB correct
5 Correct 0 ms 512 KB correct
6 Correct 0 ms 512 KB correct
7 Correct 1 ms 512 KB correct
8 Correct 0 ms 512 KB correct
9 Correct 1 ms 384 KB correct
10 Correct 1 ms 512 KB correct
11 Correct 0 ms 512 KB correct
12 Correct 0 ms 384 KB correct
13 Correct 0 ms 384 KB correct
14 Correct 3 ms 512 KB correct
15 Correct 3 ms 512 KB correct
16 Correct 3 ms 512 KB correct
17 Correct 3 ms 512 KB correct
18 Correct 1 ms 512 KB correct
19 Correct 2 ms 512 KB correct
20 Correct 2 ms 484 KB correct
21 Correct 2 ms 512 KB correct
22 Correct 2 ms 512 KB correct
23 Correct 2 ms 512 KB correct
24 Correct 2 ms 512 KB correct
25 Correct 1 ms 512 KB correct
26 Correct 2 ms 512 KB correct
27 Correct 2 ms 512 KB correct
28 Correct 1 ms 512 KB correct
29 Correct 1 ms 512 KB correct
30 Correct 2 ms 512 KB correct
31 Correct 2 ms 512 KB correct
32 Correct 2 ms 512 KB correct
33 Correct 3 ms 512 KB correct
34 Correct 194 ms 1704 KB correct
35 Correct 188 ms 1688 KB correct
36 Correct 129 ms 1528 KB correct
37 Correct 8 ms 512 KB correct
38 Correct 192 ms 1664 KB correct
39 Correct 166 ms 1592 KB correct
40 Correct 131 ms 1400 KB correct
41 Correct 199 ms 1664 KB correct
42 Correct 211 ms 1664 KB correct
43 Correct 99 ms 1276 KB correct
44 Correct 77 ms 1024 KB correct
45 Correct 92 ms 1156 KB correct
46 Correct 70 ms 896 KB correct
47 Correct 29 ms 640 KB correct
48 Correct 3 ms 512 KB correct
49 Correct 7 ms 512 KB correct
50 Correct 28 ms 640 KB correct
51 Correct 93 ms 1136 KB correct
52 Correct 78 ms 1080 KB correct
53 Correct 68 ms 912 KB correct
54 Correct 96 ms 1152 KB correct
55 Correct 99 ms 1140 KB correct
56 Correct 95 ms 1136 KB correct
57 Correct 97 ms 1144 KB correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 512 KB correct
2 Correct 1 ms 512 KB correct
3 Runtime error 40 ms 6648 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 512 KB correct
2 Correct 1 ms 512 KB correct
3 Correct 0 ms 512 KB correct
4 Correct 1 ms 384 KB correct
5 Correct 0 ms 512 KB correct
6 Correct 0 ms 512 KB correct
7 Correct 1 ms 512 KB correct
8 Correct 0 ms 512 KB correct
9 Correct 1 ms 384 KB correct
10 Correct 1 ms 512 KB correct
11 Correct 0 ms 512 KB correct
12 Correct 0 ms 384 KB correct
13 Correct 0 ms 384 KB correct
14 Correct 3 ms 512 KB correct
15 Correct 3 ms 512 KB correct
16 Correct 3 ms 512 KB correct
17 Correct 3 ms 512 KB correct
18 Correct 1 ms 512 KB correct
19 Correct 2 ms 512 KB correct
20 Correct 2 ms 484 KB correct
21 Correct 2 ms 512 KB correct
22 Correct 2 ms 512 KB correct
23 Correct 2 ms 512 KB correct
24 Correct 2 ms 512 KB correct
25 Correct 1 ms 512 KB correct
26 Correct 2 ms 512 KB correct
27 Correct 2 ms 512 KB correct
28 Correct 1 ms 512 KB correct
29 Correct 1 ms 512 KB correct
30 Correct 2 ms 512 KB correct
31 Correct 2 ms 512 KB correct
32 Correct 2 ms 512 KB correct
33 Correct 3 ms 512 KB correct
34 Correct 194 ms 1704 KB correct
35 Correct 188 ms 1688 KB correct
36 Correct 129 ms 1528 KB correct
37 Correct 8 ms 512 KB correct
38 Correct 192 ms 1664 KB correct
39 Correct 166 ms 1592 KB correct
40 Correct 131 ms 1400 KB correct
41 Correct 199 ms 1664 KB correct
42 Correct 211 ms 1664 KB correct
43 Correct 99 ms 1276 KB correct
44 Correct 77 ms 1024 KB correct
45 Correct 92 ms 1156 KB correct
46 Correct 70 ms 896 KB correct
47 Correct 29 ms 640 KB correct
48 Correct 3 ms 512 KB correct
49 Correct 7 ms 512 KB correct
50 Correct 28 ms 640 KB correct
51 Correct 93 ms 1136 KB correct
52 Correct 78 ms 1080 KB correct
53 Correct 68 ms 912 KB correct
54 Correct 96 ms 1152 KB correct
55 Correct 99 ms 1140 KB correct
56 Correct 95 ms 1136 KB correct
57 Correct 97 ms 1144 KB correct
58 Correct 1 ms 512 KB correct
59 Correct 1 ms 512 KB correct
60 Runtime error 40 ms 6648 KB Execution killed with signal 11 (could be triggered by violating memory limits)
61 Halted 0 ms 0 KB -