Submission #211557

# Submission time Handle Problem Language Result Execution time Memory
211557 2020-03-20T17:16:00 Z admin Senior Postmen (BOI14_postmen) C++14
55 / 100
500 ms 57584 KB
#include <bits/stdc++.h>
using namespace std;
 
vector<pair<int, int>> graph[500001];
bool visited[500001], used[500001];
int nxt[500001];
 
void dfs(int node) {
	if (visited[node]) {
		while (visited[node]) {
			visited[node] = false;
			cout << node << ' ';
			node = nxt[node];
		}
		cout << '\n';
	}
	while (graph[node].size()) {
		int c, idx;
		tie(c, idx) = graph[node].back();
		graph[node].pop_back();
		if (!used[idx]) {
			used[idx] = true;
			visited[node] = true;
			nxt[node] = c;
			dfs(c);
		}
	}
}
 
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		graph[a].push_back({b, i});
		graph[b].push_back({a, i});
	}
	
	dfs(1);
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 12 ms 12032 KB Output is correct
2 Correct 12 ms 12032 KB Output is correct
3 Correct 12 ms 12032 KB Output is correct
4 Correct 14 ms 12416 KB Output is correct
5 Correct 12 ms 12160 KB Output is correct
6 Correct 15 ms 12416 KB Output is correct
7 Correct 18 ms 13312 KB Output is correct
8 Correct 13 ms 12352 KB Output is correct
9 Correct 52 ms 19284 KB Output is correct
10 Correct 15 ms 12288 KB Output is correct
11 Correct 14 ms 12264 KB Output is correct
12 Correct 53 ms 19576 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 12032 KB Output is correct
2 Correct 11 ms 12176 KB Output is correct
3 Correct 11 ms 12032 KB Output is correct
4 Correct 16 ms 12288 KB Output is correct
5 Correct 16 ms 12160 KB Output is correct
6 Correct 15 ms 12416 KB Output is correct
7 Correct 17 ms 13336 KB Output is correct
8 Correct 15 ms 12288 KB Output is correct
9 Correct 51 ms 19288 KB Output is correct
10 Correct 13 ms 12288 KB Output is correct
11 Correct 13 ms 12288 KB Output is correct
12 Correct 50 ms 19576 KB Output is correct
13 Correct 91 ms 21088 KB Output is correct
14 Correct 79 ms 18536 KB Output is correct
15 Correct 73 ms 20380 KB Output is correct
16 Correct 87 ms 21112 KB Output is correct
17 Correct 96 ms 16280 KB Output is correct
18 Correct 90 ms 19576 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 12032 KB Output is correct
2 Correct 14 ms 12160 KB Output is correct
3 Correct 11 ms 12032 KB Output is correct
4 Correct 14 ms 12416 KB Output is correct
5 Correct 11 ms 12160 KB Output is correct
6 Correct 12 ms 12416 KB Output is correct
7 Correct 17 ms 13312 KB Output is correct
8 Correct 15 ms 12264 KB Output is correct
9 Correct 48 ms 19244 KB Output is correct
10 Correct 14 ms 12264 KB Output is correct
11 Correct 13 ms 12288 KB Output is correct
12 Correct 50 ms 19576 KB Output is correct
13 Correct 105 ms 21088 KB Output is correct
14 Correct 87 ms 18524 KB Output is correct
15 Correct 77 ms 20308 KB Output is correct
16 Correct 129 ms 21088 KB Output is correct
17 Correct 103 ms 16356 KB Output is correct
18 Correct 85 ms 19620 KB Output is correct
19 Correct 488 ms 57568 KB Output is correct
20 Correct 463 ms 44000 KB Output is correct
21 Correct 461 ms 53616 KB Output is correct
22 Correct 499 ms 57584 KB Output is correct
23 Correct 204 ms 46688 KB Output is correct
24 Execution timed out 583 ms 33588 KB Time limit exceeded
25 Halted 0 ms 0 KB -