#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
const int dydis = 1000;
vector<int> gr[dydis];
int enter[dydis];
int leave[dydis];
vector<int> ret (dydis);
int dbInd = 0;
void dfs(int v, int came){
enter[v] = dbInd++;
for(auto x : gr[v]){
if(x == came) continue;
dfs(x, v);
}
leave[v] = dbInd;
ret[v] = enter[v] * dydis + leave[v] - 1;
//cout << "enter " << v << " - " << enter[v] << ", o leave " << leave[v]-1 << endl;
}
void dfs1(int v, int came, int as){
ret[v] = as;
for(auto x : gr[v]){
if(x == came) continue;
dfs1(x, v, as+1);
}
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
int mxsz = 0;
for(int i = 0; i < n; i++){
gr[i].clear();
gr[i].clear();
}
dbInd = 0;
ret.resize(n);
for(int i = 0; i < n-1; i++){
gr[u[i]].push_back(v[i]);
gr[v[i]].push_back(u[i]);
}
for(int i = 0; i < n; i++) mxsz = max(mxsz, (int)gr[i].size());
if(mxsz <= 2){
int st = 0;
for(int i = 0; i < n; i++) if(gr[i].size() == 1) st = i;
dfs1(st, -1, 0);
}else{
dfs(0, -1);
}
return ret;
}
/*
int find_next_station(int s, int t, vector<int> c) {
int enterS = s / 1000;
int leaveS = s % 1000;
int enterT = t / 1000;
int leaveT = t % 1000;
// cout << "kitas einant is " << s << " i " << t << " yra:\n";
if(enterS <= enterT && leaveT <= leaveS){
// cout << enterS << " yra " << enterT << " tevas\n";
for(auto x : c){
int e = x / 1000;
int l = x % 1000;
if(e <= enterT && leaveT <= l && !(e <= enterS && leaveS <= l)){
// cout << "ret " << x << endl << endl;
return x;
}
}
}else{ // eisiu aukstyn
for(auto x : c){
int e = x / 1000;
int l = x % 1000;
if(e <= enterS && leaveS <= l){
// cout << "ret " << x << endl << endl;
return x;
}
}
}
return c[0];
}
*/
int find_next_station(int s, int t, vector<int> c) {
if(s < t) return s+1;
return s-1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
687 ms |
520 KB |
Output is correct |
2 |
Correct |
760 ms |
636 KB |
Output is correct |
3 |
Correct |
1162 ms |
520 KB |
Output is correct |
4 |
Correct |
919 ms |
716 KB |
Output is correct |
5 |
Correct |
982 ms |
400 KB |
Output is correct |
6 |
Correct |
483 ms |
496 KB |
Output is correct |
7 |
Correct |
659 ms |
496 KB |
Output is correct |
8 |
Correct |
4 ms |
468 KB |
Output is correct |
9 |
Correct |
3 ms |
420 KB |
Output is correct |
10 |
Correct |
2 ms |
416 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
372 KB |
Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=1511 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
650 ms |
516 KB |
Output is correct |
2 |
Correct |
638 ms |
516 KB |
Output is correct |
3 |
Correct |
1361 ms |
584 KB |
Output is correct |
4 |
Correct |
931 ms |
500 KB |
Output is correct |
5 |
Correct |
730 ms |
656 KB |
Output is correct |
6 |
Correct |
459 ms |
516 KB |
Output is correct |
7 |
Correct |
549 ms |
516 KB |
Output is correct |
8 |
Correct |
2 ms |
528 KB |
Output is correct |
9 |
Correct |
7 ms |
548 KB |
Output is correct |
10 |
Correct |
2 ms |
468 KB |
Output is correct |
11 |
Incorrect |
619 ms |
520 KB |
Wrong query response. |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1484 ms |
628 KB |
Output is correct |
2 |
Correct |
1101 ms |
400 KB |
Output is correct |
3 |
Correct |
607 ms |
400 KB |
Output is correct |
4 |
Correct |
2 ms |
596 KB |
Output is correct |
5 |
Correct |
4 ms |
420 KB |
Output is correct |
6 |
Correct |
2 ms |
528 KB |
Output is correct |
7 |
Incorrect |
756 ms |
400 KB |
Wrong query response. |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
730 ms |
528 KB |
Output is correct |
2 |
Correct |
519 ms |
648 KB |
Output is correct |
3 |
Correct |
1089 ms |
520 KB |
Output is correct |
4 |
Correct |
890 ms |
640 KB |
Output is correct |
5 |
Correct |
742 ms |
528 KB |
Output is correct |
6 |
Correct |
593 ms |
516 KB |
Output is correct |
7 |
Correct |
618 ms |
520 KB |
Output is correct |
8 |
Correct |
3 ms |
596 KB |
Output is correct |
9 |
Correct |
5 ms |
468 KB |
Output is correct |
10 |
Correct |
2 ms |
472 KB |
Output is correct |
11 |
Incorrect |
573 ms |
520 KB |
Wrong query response. |
12 |
Halted |
0 ms |
0 KB |
- |