# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
308278 |
2020-09-30T18:00:27 Z |
Peti |
Stations (IOI20_stations) |
C++14 |
|
860 ms |
1008 KB |
#include "stations.h"
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
vector<vector<int>> g;
vector<bool> volt;
int ido = 0;
void Bejar(vector<int> &labels, int akt, int t)
{
volt[akt] = true;
if(t%2 == 0)
labels[akt] = ido / 2;
ido++;
for(int x : g[akt])
if(!volt[x])
Bejar(labels, x, t+1);
if(t%2 == 1)
labels[akt] = ido / 2;
ido++;
return;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
ido = 0;
volt.assign(n, false);
g.assign(n, vector<int>());
for(int i = 0; i < n-1; i++)
{
g[u[i]].push_back(v[i]);
g[v[i]].push_back(u[i]);
}
std::vector<int> labels(n);
Bejar(labels, 0, 0);
return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
sort(c.begin(), c.end());
for(int i = 0; i < (int)c.size(); i++)
c[i] *= 2;
if(s < c[0])
{
if(t < s || t > (*c.rbegin()))
return (*c.rbegin())/2;
for(int x : c)
if(x >= t)
return x/2;
}
else
{
if(t > s || t <= c[0])
return c[0]/2;
reverse(c.begin(), c.end());
for(int x : c)
if(x <= t)
return x/2;
}
return -1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
520 ms |
768 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
457 ms |
952 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
526 ms |
1008 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
860 ms |
644 KB |
Output is correct |
2 |
Incorrect |
684 ms |
644 KB |
Wrong query response. |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
508 ms |
1008 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |