Submission #350170

# Submission time Handle Problem Language Result Execution time Memory
350170 2021-01-19T03:47:16 Z tengiz05 Stations (IOI20_stations) C++17
100 / 100
1154 ms 1400 KB
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> edges[1005];
int a[1005];
vector<bool> used;
int timer=0;
void dfs(int u, int d){
	if(d==0)a[u] = timer,timer++;
	used[u] = true;
	for(auto v:edges[u]){
		if(used[v])continue;
		dfs(v,d^1);
	}if(d==1)a[u] = timer,timer++;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
	for(int i=0;i<n;i++)edges[i].clear();
	for(int i=0;i<n-1;i++){
		edges[u[i]].push_back(v[i]);
		edges[v[i]].push_back(u[i]);
	}
	timer=0;
	used.assign(n,0);
	dfs(0,0);
	vector<int> ans(n);
	for(int i=0;i<n;i++)ans[i] = a[i];
	return ans;
}
/*
 
1
5 10
0 1
1 2
2 3
3 4
3
1 3 121
1 4 121
0 1 122
 
*/
 
int find_next_station(int s, int t, vector<int> c) {
//	cout << s << ": " << t << '\n';
	if(c[c.size()-1] < s){
		int ans = c[0];
		for(auto x : c){
			if(min(s, x) <= t && t <= max(s, x))ans = x;
		}return ans;
	}else {
		for(auto x : c)if(min(s, x) <= t && t <= max(s, x))return x;
		return c[c.size()-1];
	}
}
# Verdict Execution time Memory Grader output
1 Correct 512 ms 1116 KB Output is correct
2 Correct 514 ms 992 KB Output is correct
3 Correct 1154 ms 948 KB Output is correct
4 Correct 842 ms 948 KB Output is correct
5 Correct 765 ms 736 KB Output is correct
6 Correct 619 ms 992 KB Output is correct
7 Correct 403 ms 868 KB Output is correct
8 Correct 3 ms 948 KB Output is correct
9 Correct 4 ms 736 KB Output is correct
10 Correct 2 ms 736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 499 ms 888 KB Output is correct
2 Correct 669 ms 892 KB Output is correct
3 Correct 986 ms 864 KB Output is correct
4 Correct 681 ms 1120 KB Output is correct
5 Correct 575 ms 1076 KB Output is correct
6 Correct 444 ms 864 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 602 ms 1108 KB Output is correct
2 Correct 437 ms 1400 KB Output is correct
3 Correct 998 ms 948 KB Output is correct
4 Correct 643 ms 736 KB Output is correct
5 Correct 624 ms 864 KB Output is correct
6 Correct 513 ms 1108 KB Output is correct
7 Correct 469 ms 864 KB Output is correct
8 Correct 2 ms 948 KB Output is correct
9 Correct 5 ms 736 KB Output is correct
10 Correct 2 ms 956 KB Output is correct
11 Correct 622 ms 1108 KB Output is correct
12 Correct 470 ms 1120 KB Output is correct
13 Correct 494 ms 864 KB Output is correct
14 Correct 532 ms 864 KB Output is correct
15 Correct 55 ms 988 KB Output is correct
16 Correct 69 ms 736 KB Output is correct
17 Correct 120 ms 884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 873 ms 864 KB Output is correct
2 Correct 777 ms 948 KB Output is correct
3 Correct 717 ms 1108 KB Output is correct
4 Correct 3 ms 956 KB Output is correct
5 Correct 5 ms 864 KB Output is correct
6 Correct 2 ms 776 KB Output is correct
7 Correct 660 ms 992 KB Output is correct
8 Correct 1103 ms 948 KB Output is correct
9 Correct 653 ms 948 KB Output is correct
10 Correct 601 ms 864 KB Output is correct
11 Correct 7 ms 736 KB Output is correct
12 Correct 7 ms 956 KB Output is correct
13 Correct 6 ms 736 KB Output is correct
14 Correct 4 ms 736 KB Output is correct
15 Correct 2 ms 736 KB Output is correct
16 Correct 600 ms 864 KB Output is correct
17 Correct 528 ms 864 KB Output is correct
18 Correct 474 ms 1084 KB Output is correct
19 Correct 505 ms 864 KB Output is correct
20 Correct 502 ms 948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 588 ms 1116 KB Output is correct
2 Correct 518 ms 1236 KB Output is correct
3 Correct 1063 ms 840 KB Output is correct
4 Correct 896 ms 864 KB Output is correct
5 Correct 815 ms 948 KB Output is correct
6 Correct 514 ms 992 KB Output is correct
7 Correct 501 ms 864 KB Output is correct
8 Correct 3 ms 864 KB Output is correct
9 Correct 4 ms 736 KB Output is correct
10 Correct 2 ms 948 KB Output is correct
11 Correct 597 ms 736 KB Output is correct
12 Correct 564 ms 1156 KB Output is correct
13 Correct 1011 ms 948 KB Output is correct
14 Correct 723 ms 864 KB Output is correct
15 Correct 671 ms 1108 KB Output is correct
16 Correct 571 ms 1108 KB Output is correct
17 Correct 644 ms 736 KB Output is correct
18 Correct 481 ms 992 KB Output is correct
19 Correct 456 ms 1232 KB Output is correct
20 Correct 477 ms 736 KB Output is correct
21 Correct 71 ms 948 KB Output is correct
22 Correct 72 ms 864 KB Output is correct
23 Correct 142 ms 884 KB Output is correct
24 Correct 7 ms 956 KB Output is correct
25 Correct 4 ms 948 KB Output is correct
26 Correct 5 ms 864 KB Output is correct
27 Correct 3 ms 956 KB Output is correct
28 Correct 2 ms 956 KB Output is correct
29 Correct 491 ms 736 KB Output is correct
30 Correct 595 ms 948 KB Output is correct
31 Correct 600 ms 1116 KB Output is correct
32 Correct 601 ms 864 KB Output is correct
33 Correct 661 ms 736 KB Output is correct
34 Correct 303 ms 992 KB Output is correct
35 Correct 489 ms 992 KB Output is correct
36 Correct 462 ms 1232 KB Output is correct
37 Correct 536 ms 992 KB Output is correct
38 Correct 616 ms 992 KB Output is correct
39 Correct 614 ms 1112 KB Output is correct
40 Correct 479 ms 1008 KB Output is correct
41 Correct 398 ms 736 KB Output is correct
42 Correct 57 ms 896 KB Output is correct
43 Correct 110 ms 736 KB Output is correct
44 Correct 126 ms 868 KB Output is correct
45 Correct 164 ms 872 KB Output is correct
46 Correct 330 ms 1160 KB Output is correct
47 Correct 296 ms 864 KB Output is correct
48 Correct 63 ms 1100 KB Output is correct
49 Correct 61 ms 864 KB Output is correct