Submission #319829

# Submission time Handle Problem Language Result Execution time Memory
319829 2020-11-06T14:01:27 Z model_code Stations (IOI20_stations) Java 11
100 / 100
2012 ms 44644 KB
import java.util.ArrayList;
 
public class stations {
  private static final int MAXN = 1000;
  
  private int cnt;
  private ArrayList<Integer>[] adj;
  private int[] labels;
  
  private void dfs(int v, int p, int d) {
  	if(d == 0) labels[v] = cnt++;
  	for (Integer i : adj[v]) if (i != p) dfs(i, v, d ^ 1);
  	if(d == 1) labels[v] = cnt++;
  }
 
  int[] label(int n, int k, int[] u, int[] v) {
    cnt = 0;
    adj = new ArrayList[n];
    for (int i = 0; i < n; i++) {
      adj[i] = new ArrayList<Integer>();
    }
  	for (int i = 0; i < n - 1; i++) {
  		adj[u[i]].add(v[i]);
  		adj[v[i]].add(u[i]);
  	}
  	labels = new int[n];
  	dfs(0, -1, 0);
  	return labels;
  }
 
  int find_next_station(int s, int t, int[] c) {
  	if (s < c[0]) {
  		if (t < s || t >= c[c.length - 1]) return c[c.length - 1];
  		for (int i : c) if (i >= t) return i;
    	return c[c.length - 1];
  	}
  	if (t > s || t <= c[0]) return c[0];
  	int ans = c[0];
  	for (int i : c) if (i <= t) ans = i;
  	return ans;
  }
}

Compilation message

Note: stations.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
# Verdict Execution time Memory Grader output
1 Correct 1367 ms 41188 KB Output is correct
2 Correct 1204 ms 39692 KB Output is correct
3 Correct 1892 ms 42864 KB Output is correct
4 Correct 1501 ms 39568 KB Output is correct
5 Correct 1359 ms 38700 KB Output is correct
6 Correct 1388 ms 43228 KB Output is correct
7 Correct 1257 ms 39064 KB Output is correct
8 Correct 207 ms 22904 KB Output is correct
9 Correct 207 ms 23376 KB Output is correct
10 Correct 184 ms 22940 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1400 ms 43440 KB Output is correct
2 Correct 1298 ms 39060 KB Output is correct
3 Correct 1837 ms 41048 KB Output is correct
4 Correct 1509 ms 41196 KB Output is correct
5 Correct 1329 ms 39512 KB Output is correct
6 Correct 1375 ms 38752 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1468 ms 41536 KB Output is correct
2 Correct 1346 ms 41252 KB Output is correct
3 Correct 1775 ms 42740 KB Output is correct
4 Correct 1292 ms 39840 KB Output is correct
5 Correct 1274 ms 38608 KB Output is correct
6 Correct 1272 ms 41480 KB Output is correct
7 Correct 1205 ms 37560 KB Output is correct
8 Correct 198 ms 23388 KB Output is correct
9 Correct 207 ms 23364 KB Output is correct
10 Correct 161 ms 22736 KB Output is correct
11 Correct 1512 ms 39848 KB Output is correct
12 Correct 1275 ms 42572 KB Output is correct
13 Correct 1407 ms 42284 KB Output is correct
14 Correct 1319 ms 37868 KB Output is correct
15 Correct 407 ms 27888 KB Output is correct
16 Correct 440 ms 28360 KB Output is correct
17 Correct 760 ms 38692 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1583 ms 43352 KB Output is correct
2 Correct 1595 ms 40240 KB Output is correct
3 Correct 1399 ms 39380 KB Output is correct
4 Correct 175 ms 23020 KB Output is correct
5 Correct 198 ms 23168 KB Output is correct
6 Correct 175 ms 23000 KB Output is correct
7 Correct 1357 ms 39264 KB Output is correct
8 Correct 1692 ms 44520 KB Output is correct
9 Correct 1449 ms 39596 KB Output is correct
10 Correct 1444 ms 39312 KB Output is correct
11 Correct 221 ms 23224 KB Output is correct
12 Correct 213 ms 22888 KB Output is correct
13 Correct 193 ms 22940 KB Output is correct
14 Correct 193 ms 22844 KB Output is correct
15 Correct 170 ms 22900 KB Output is correct
16 Correct 1281 ms 39024 KB Output is correct
17 Correct 1144 ms 39884 KB Output is correct
18 Correct 1306 ms 36704 KB Output is correct
19 Correct 1218 ms 36956 KB Output is correct
20 Correct 1280 ms 38680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1615 ms 38352 KB Output is correct
2 Correct 1249 ms 40836 KB Output is correct
3 Correct 1795 ms 40312 KB Output is correct
4 Correct 1505 ms 38136 KB Output is correct
5 Correct 1472 ms 39604 KB Output is correct
6 Correct 1255 ms 41476 KB Output is correct
7 Correct 1354 ms 37228 KB Output is correct
8 Correct 183 ms 23168 KB Output is correct
9 Correct 198 ms 23548 KB Output is correct
10 Correct 180 ms 23044 KB Output is correct
11 Correct 1351 ms 43420 KB Output is correct
12 Correct 1347 ms 40308 KB Output is correct
13 Correct 2012 ms 44644 KB Output is correct
14 Correct 1367 ms 41220 KB Output is correct
15 Correct 1248 ms 39296 KB Output is correct
16 Correct 1382 ms 38500 KB Output is correct
17 Correct 1474 ms 37604 KB Output is correct
18 Correct 1438 ms 43464 KB Output is correct
19 Correct 1414 ms 43496 KB Output is correct
20 Correct 1250 ms 39888 KB Output is correct
21 Correct 374 ms 26872 KB Output is correct
22 Correct 481 ms 28356 KB Output is correct
23 Correct 772 ms 34848 KB Output is correct
24 Correct 209 ms 23096 KB Output is correct
25 Correct 216 ms 23364 KB Output is correct
26 Correct 198 ms 23424 KB Output is correct
27 Correct 202 ms 23052 KB Output is correct
28 Correct 186 ms 22540 KB Output is correct
29 Correct 1267 ms 38160 KB Output is correct
30 Correct 1360 ms 37124 KB Output is correct
31 Correct 1259 ms 39264 KB Output is correct
32 Correct 1377 ms 38420 KB Output is correct
33 Correct 1498 ms 39256 KB Output is correct
34 Correct 1078 ms 41020 KB Output is correct
35 Correct 1301 ms 41224 KB Output is correct
36 Correct 1432 ms 43304 KB Output is correct
37 Correct 1226 ms 41420 KB Output is correct
38 Correct 1299 ms 41980 KB Output is correct
39 Correct 1198 ms 40456 KB Output is correct
40 Correct 1478 ms 42528 KB Output is correct
41 Correct 1377 ms 41480 KB Output is correct
42 Correct 403 ms 29512 KB Output is correct
43 Correct 722 ms 37532 KB Output is correct
44 Correct 836 ms 37312 KB Output is correct
45 Correct 895 ms 39932 KB Output is correct
46 Correct 1091 ms 37932 KB Output is correct
47 Correct 1040 ms 41580 KB Output is correct
48 Correct 443 ms 29712 KB Output is correct
49 Correct 495 ms 31048 KB Output is correct