# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
977355 |
2024-05-07T19:14:16 Z |
aykhn |
Stations (IOI20_stations) |
C++17 |
|
611 ms |
1696 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);
// vector<array<int, 2>> v1;
// for (int i = 0; i < labels.size(); i++) v1.push_back({labels[i], i});
// sort(v1.begin(), v1.end());
// for (int i = 0; i < v1.size(); i++) labels[v1[i][1]] = i;
return labels;
}
int find_next_station(int s, int t, vector<int> c)
{
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 <= 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)) 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:66:1: warning: control reaches end of non-void function [-Wreturn-type]
66 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
608 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 |
596 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 |
344 ms |
948 KB |
Output is correct |
2 |
Correct |
308 ms |
944 KB |
Output is correct |
3 |
Correct |
611 ms |
920 KB |
Output is correct |
4 |
Correct |
440 ms |
684 KB |
Output is correct |
5 |
Correct |
381 ms |
692 KB |
Output is correct |
6 |
Correct |
261 ms |
968 KB |
Output is correct |
7 |
Correct |
295 ms |
688 KB |
Output is correct |
8 |
Correct |
1 ms |
768 KB |
Output is correct |
9 |
Correct |
1 ms |
768 KB |
Output is correct |
10 |
Correct |
0 ms |
768 KB |
Output is correct |
11 |
Correct |
407 ms |
684 KB |
Output is correct |
12 |
Correct |
315 ms |
1200 KB |
Output is correct |
13 |
Correct |
289 ms |
1696 KB |
Output is correct |
14 |
Correct |
279 ms |
684 KB |
Output is correct |
15 |
Correct |
29 ms |
1016 KB |
Output is correct |
16 |
Correct |
33 ms |
884 KB |
Output is correct |
17 |
Correct |
65 ms |
1132 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
539 ms |
684 KB |
Output is correct |
2 |
Correct |
413 ms |
684 KB |
Output is correct |
3 |
Correct |
381 ms |
684 KB |
Output is correct |
4 |
Correct |
1 ms |
768 KB |
Output is correct |
5 |
Correct |
3 ms |
768 KB |
Output is correct |
6 |
Correct |
1 ms |
776 KB |
Output is correct |
7 |
Correct |
408 ms |
684 KB |
Output is correct |
8 |
Correct |
567 ms |
684 KB |
Output is correct |
9 |
Correct |
438 ms |
684 KB |
Output is correct |
10 |
Correct |
356 ms |
684 KB |
Output is correct |
11 |
Correct |
2 ms |
768 KB |
Output is correct |
12 |
Correct |
2 ms |
768 KB |
Output is correct |
13 |
Correct |
3 ms |
768 KB |
Output is correct |
14 |
Correct |
2 ms |
776 KB |
Output is correct |
15 |
Correct |
2 ms |
768 KB |
Output is correct |
16 |
Correct |
349 ms |
684 KB |
Output is correct |
17 |
Correct |
348 ms |
684 KB |
Output is correct |
18 |
Correct |
302 ms |
684 KB |
Output is correct |
19 |
Correct |
328 ms |
684 KB |
Output is correct |
20 |
Correct |
336 ms |
684 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
363 ms |
948 KB |
Partially correct |
2 |
Partially correct |
295 ms |
940 KB |
Partially correct |
3 |
Correct |
588 ms |
684 KB |
Output is correct |
4 |
Correct |
460 ms |
688 KB |
Output is correct |
5 |
Correct |
380 ms |
684 KB |
Output is correct |
6 |
Partially correct |
333 ms |
948 KB |
Partially correct |
7 |
Partially correct |
286 ms |
936 KB |
Partially correct |
8 |
Correct |
2 ms |
768 KB |
Output is correct |
9 |
Correct |
2 ms |
768 KB |
Output is correct |
10 |
Correct |
0 ms |
768 KB |
Output is correct |
11 |
Partially correct |
297 ms |
880 KB |
Partially correct |
12 |
Partially correct |
378 ms |
1276 KB |
Partially correct |
13 |
Correct |
577 ms |
684 KB |
Output is correct |
14 |
Correct |
445 ms |
684 KB |
Output is correct |
15 |
Correct |
408 ms |
688 KB |
Output is correct |
16 |
Partially correct |
273 ms |
684 KB |
Partially correct |
17 |
Correct |
378 ms |
684 KB |
Output is correct |
18 |
Partially correct |
293 ms |
1184 KB |
Partially correct |
19 |
Partially correct |
301 ms |
1048 KB |
Partially correct |
20 |
Partially correct |
269 ms |
936 KB |
Partially correct |
21 |
Correct |
33 ms |
768 KB |
Output is correct |
22 |
Partially correct |
39 ms |
1096 KB |
Partially correct |
23 |
Partially correct |
65 ms |
1132 KB |
Partially correct |
24 |
Correct |
3 ms |
764 KB |
Output is correct |
25 |
Correct |
4 ms |
768 KB |
Output is correct |
26 |
Correct |
3 ms |
768 KB |
Output is correct |
27 |
Correct |
2 ms |
1020 KB |
Output is correct |
28 |
Correct |
2 ms |
764 KB |
Output is correct |
29 |
Correct |
331 ms |
684 KB |
Output is correct |
30 |
Correct |
315 ms |
936 KB |
Output is correct |
31 |
Correct |
340 ms |
684 KB |
Output is correct |
32 |
Correct |
307 ms |
684 KB |
Output is correct |
33 |
Correct |
359 ms |
684 KB |
Output is correct |
34 |
Partially correct |
210 ms |
932 KB |
Partially correct |
35 |
Partially correct |
258 ms |
1064 KB |
Partially correct |
36 |
Partially correct |
295 ms |
1056 KB |
Partially correct |
37 |
Partially correct |
339 ms |
1032 KB |
Partially correct |
38 |
Partially correct |
310 ms |
1028 KB |
Partially correct |
39 |
Partially correct |
285 ms |
1188 KB |
Partially correct |
40 |
Partially correct |
267 ms |
1284 KB |
Partially correct |
41 |
Partially correct |
288 ms |
1016 KB |
Partially correct |
42 |
Partially correct |
33 ms |
1204 KB |
Partially correct |
43 |
Partially correct |
66 ms |
884 KB |
Partially correct |
44 |
Partially correct |
74 ms |
968 KB |
Partially correct |
45 |
Partially correct |
112 ms |
1184 KB |
Partially correct |
46 |
Partially correct |
177 ms |
872 KB |
Partially correct |
47 |
Partially correct |
192 ms |
1156 KB |
Partially correct |
48 |
Partially correct |
34 ms |
1328 KB |
Partially correct |
49 |
Partially correct |
31 ms |
1228 KB |
Partially correct |