# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
348074 |
2021-01-14T07:32:40 Z |
blue |
Stations (IOI20_stations) |
C++17 |
|
1 ms |
416 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;
cout << "dfs " << u << ' ' << a << ' ' << flag << '\n';
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:64:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
64 | for(int i = 0; i < c.size(); i++) if(t <= c[i]) return c[i];
| ~~^~~~~~~~~~
stations.cpp:71:1: warning: control reaches end of non-void function [-Wreturn-type]
71 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
416 KB |
Execution killed with signal 13 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
364 KB |
Execution killed with signal 13 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
384 KB |
Execution killed with signal 13 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
364 KB |
Execution killed with signal 13 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
364 KB |
Execution killed with signal 13 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |