# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
348075 |
2021-01-14T07:33:10 Z |
blue |
Stations (IOI20_stations) |
C++17 |
|
5 ms |
620 KB |
#include "stations.h"
#include <iostream>
#include <vector>
using namespace std;
vector<int> edge[1000];
vector<int> visit(1000, 0);
vector<int> L;
int dfs(int u, int a, bool flag) //vertex, minimum label, left/right? return largest unused label
{
visit[u] = 1;
if(flag == 0)
{
L[u] = a;
a++;
}
for(int v: edge[u])
{
if(visit[v]) continue;
a = dfs(v, a, !flag);
}
if(flag == 1)
{
L[u] = a;
a++;
}
return a;
}
/*
0
/ | \
1 2 3
/ \ \
4 5 6
*/
vector<int> label(int n, int k, vector<int> u, vector<int> v)
{
for(int j = 0; j < n-1; j++)
{
edge[u[j]].push_back(v[j]);
edge[v[j]].push_back(u[j]);
}
L = vector<int>(n, -1);
dfs(0, 0, 0);
return L;
}
int find_next_station(int s, int t, vector<int> c)
{
if(s < c[0]) // s is left label
{
if(t < s) return c.back();
for(int i = 0; i < c.size(); i++) if(t <= c[i]) return c[i];
}
else // s is right label
{
if(t > s) return c[0];
for(int i = c.size()-1; i >= 0; i--) if(t >= c[i]) return c[i];
}
}
Compilation message
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:63:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
63 | for(int i = 0; i < c.size(); i++) if(t <= c[i]) return c[i];
| ~~^~~~~~~~~~
stations.cpp:70:1: warning: control reaches end of non-void function [-Wreturn-type]
70 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
620 KB |
Execution killed with signal 6 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
520 KB |
Invalid labels (values out of range). scenario=1, k=1000, vertex=1, label=-1 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
620 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Invalid labels (values out of range). scenario=1, k=1000000000, vertex=1, label=-1 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
492 KB |
Invalid labels (values out of range). scenario=1, k=1000000000, vertex=1, label=-1 |
2 |
Halted |
0 ms |
0 KB |
- |