# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
977348 |
2024-05-07T19:02:22 Z |
aykhn |
Stations (IOI20_stations) |
C++17 |
|
565 ms |
1532 KB |
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
const int MXN = 1e3 + 5;
int in[MXN], out[MXN], tim = -1;
vector<int> adj[MXN];
vector<int> labels;
void dfs(int a, int p, int w)
{
in[a] = ++tim;
for (int v : adj[a])
{
if (v == p) continue;
dfs(v, a, w ^ 1);
}
out[a] = ++tim;
if (w) labels[a] = in[a];
else labels[a] = out[a];
}
vector<int> label(int n, int k, vector<int> u, vector<int> v)
{
tim = -1;
for (int i = 0; i < n; i++)
{
in[i] = out[i] = 0;
adj[i].clear();
}
for (int i = 0; i < n - 1; i++) adj[u[i]].push_back(v[i]), adj[v[i]].push_back(u[i]);
labels.assign(n, 0);
dfs(0, 0, 0);
return labels;
}
int find_next_station(int s, int t, vector<int> c)
{
sort(c.begin(), c.end());
for (int x : c) if (x == t) return t;
if (s == 0)
{
reverse(c.begin(), c.end());
for (int x : c) if (x <= t) return x;
}
int sz = c.size();
if (sz == 1) return c[0];
else if (s < c[0])
{
if (!(s + 1 <= t && t <= c[sz - 2])) return c[sz - 1];
c.pop_back();
for (int x : c) if (t <= x) return x;
}
else
{
if (!(c[1] <= t && t <= s - 1)) return c[0];
c.erase(c.begin());
reverse(c.begin(), c.end());
for (int x : c) if (x <= t) return x;
}
}
Compilation message
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:63:1: warning: control reaches end of non-void function [-Wreturn-type]
63 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
596 KB |
Invalid labels (values out of range). scenario=2, k=1000, vertex=0, label=1995 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
540 KB |
Invalid labels (values out of range). scenario=0, k=1000, vertex=0, label=1991 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
390 ms |
1204 KB |
Output is correct |
2 |
Correct |
282 ms |
944 KB |
Output is correct |
3 |
Correct |
537 ms |
940 KB |
Output is correct |
4 |
Correct |
391 ms |
684 KB |
Output is correct |
5 |
Correct |
344 ms |
684 KB |
Output is correct |
6 |
Correct |
290 ms |
944 KB |
Output is correct |
7 |
Correct |
268 ms |
684 KB |
Output is correct |
8 |
Correct |
2 ms |
936 KB |
Output is correct |
9 |
Correct |
3 ms |
768 KB |
Output is correct |
10 |
Correct |
1 ms |
1020 KB |
Output is correct |
11 |
Correct |
352 ms |
684 KB |
Output is correct |
12 |
Correct |
274 ms |
1052 KB |
Output is correct |
13 |
Correct |
276 ms |
1296 KB |
Output is correct |
14 |
Correct |
271 ms |
684 KB |
Output is correct |
15 |
Correct |
39 ms |
716 KB |
Output is correct |
16 |
Correct |
34 ms |
928 KB |
Output is correct |
17 |
Correct |
68 ms |
884 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
565 ms |
684 KB |
Output is correct |
2 |
Correct |
436 ms |
684 KB |
Output is correct |
3 |
Correct |
352 ms |
684 KB |
Output is correct |
4 |
Correct |
2 ms |
768 KB |
Output is correct |
5 |
Correct |
3 ms |
1024 KB |
Output is correct |
6 |
Correct |
0 ms |
768 KB |
Output is correct |
7 |
Correct |
358 ms |
940 KB |
Output is correct |
8 |
Correct |
531 ms |
684 KB |
Output is correct |
9 |
Correct |
419 ms |
684 KB |
Output is correct |
10 |
Correct |
376 ms |
684 KB |
Output is correct |
11 |
Correct |
3 ms |
768 KB |
Output is correct |
12 |
Correct |
4 ms |
768 KB |
Output is correct |
13 |
Correct |
2 ms |
808 KB |
Output is correct |
14 |
Correct |
2 ms |
768 KB |
Output is correct |
15 |
Correct |
1 ms |
932 KB |
Output is correct |
16 |
Correct |
317 ms |
684 KB |
Output is correct |
17 |
Correct |
386 ms |
684 KB |
Output is correct |
18 |
Correct |
307 ms |
684 KB |
Output is correct |
19 |
Correct |
341 ms |
684 KB |
Output is correct |
20 |
Correct |
308 ms |
684 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
350 ms |
948 KB |
Partially correct |
2 |
Partially correct |
303 ms |
940 KB |
Partially correct |
3 |
Correct |
536 ms |
684 KB |
Output is correct |
4 |
Correct |
423 ms |
684 KB |
Output is correct |
5 |
Correct |
357 ms |
684 KB |
Output is correct |
6 |
Partially correct |
284 ms |
948 KB |
Partially correct |
7 |
Partially correct |
265 ms |
852 KB |
Partially correct |
8 |
Correct |
1 ms |
764 KB |
Output is correct |
9 |
Correct |
2 ms |
768 KB |
Output is correct |
10 |
Correct |
1 ms |
764 KB |
Output is correct |
11 |
Partially correct |
284 ms |
884 KB |
Partially correct |
12 |
Partially correct |
345 ms |
844 KB |
Partially correct |
13 |
Correct |
524 ms |
684 KB |
Output is correct |
14 |
Correct |
455 ms |
684 KB |
Output is correct |
15 |
Correct |
391 ms |
684 KB |
Output is correct |
16 |
Partially correct |
309 ms |
684 KB |
Partially correct |
17 |
Correct |
392 ms |
680 KB |
Output is correct |
18 |
Partially correct |
311 ms |
1036 KB |
Partially correct |
19 |
Partially correct |
325 ms |
1300 KB |
Partially correct |
20 |
Partially correct |
303 ms |
688 KB |
Partially correct |
21 |
Correct |
38 ms |
768 KB |
Output is correct |
22 |
Partially correct |
41 ms |
1156 KB |
Partially correct |
23 |
Partially correct |
56 ms |
940 KB |
Partially correct |
24 |
Correct |
4 ms |
768 KB |
Output is correct |
25 |
Correct |
3 ms |
768 KB |
Output is correct |
26 |
Correct |
3 ms |
768 KB |
Output is correct |
27 |
Correct |
2 ms |
768 KB |
Output is correct |
28 |
Correct |
0 ms |
772 KB |
Output is correct |
29 |
Correct |
341 ms |
684 KB |
Output is correct |
30 |
Correct |
321 ms |
684 KB |
Output is correct |
31 |
Correct |
331 ms |
1188 KB |
Output is correct |
32 |
Correct |
328 ms |
688 KB |
Output is correct |
33 |
Correct |
354 ms |
684 KB |
Output is correct |
34 |
Partially correct |
204 ms |
936 KB |
Partially correct |
35 |
Partially correct |
296 ms |
1060 KB |
Partially correct |
36 |
Partially correct |
310 ms |
1044 KB |
Partially correct |
37 |
Partially correct |
311 ms |
1160 KB |
Partially correct |
38 |
Partially correct |
301 ms |
1528 KB |
Partially correct |
39 |
Partially correct |
309 ms |
1288 KB |
Partially correct |
40 |
Partially correct |
331 ms |
1532 KB |
Partially correct |
41 |
Partially correct |
283 ms |
1260 KB |
Partially correct |
42 |
Partially correct |
38 ms |
944 KB |
Partially correct |
43 |
Partially correct |
65 ms |
968 KB |
Partially correct |
44 |
Partially correct |
110 ms |
968 KB |
Partially correct |
45 |
Partially correct |
89 ms |
900 KB |
Partially correct |
46 |
Partially correct |
193 ms |
868 KB |
Partially correct |
47 |
Partially correct |
202 ms |
904 KB |
Partially correct |
48 |
Partially correct |
33 ms |
1260 KB |
Partially correct |
49 |
Partially correct |
34 ms |
1392 KB |
Partially correct |