# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
977337 |
2024-05-07T18:39:08 Z |
aykhn |
Stations (IOI20_stations) |
C++17 |
|
557 ms |
684 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 & 1) 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();
}
labels.assign(n, 0);
dfs(0, 0, 0);
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) 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[0] + 2 <= 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:57:1: warning: control reaches end of non-void function [-Wreturn-type]
57 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
496 KB |
Invalid labels (duplicates values). scenario=0, label=0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
504 KB |
Invalid labels (duplicates values). scenario=0, label=0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
492 KB |
Invalid labels (duplicates values). scenario=1, label=0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
557 ms |
684 KB |
Output is correct |
2 |
Incorrect |
0 ms |
344 KB |
Invalid labels (duplicates values). scenario=0, label=0 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
496 KB |
Invalid labels (duplicates values). scenario=0, label=0 |
2 |
Halted |
0 ms |
0 KB |
- |