#include <bits/stdc++.h>
using namespace std;
#include "stations.h"
#define fin(i,s,n) for(auto i = s; i < n; ++i)
#define fine(i,s,n) for(auto i = s; i <= n; ++i)
#define x first
#define y second
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using ii = pair<int,int>;
using vi = vector<int>;
using vii = vector<ii>;
template<class T> ostream& operator<<(ostream& os, vector<T> v) {
if(v.empty()) return os << "[]";
os << '[' << v[0];
fin(i,1,int(v.size())) os << ',' << v[i];
return os << ']';
}
const int maxn = 1005;
vi l;
int lid = 0;
vi g[maxn];
void dfs(int u) {
if(l[u]!=-1) return;
l[u] = lid++;
for(int v : g[u]) dfs(v);
}
vi label(int n, int k, vi u, vi v) {
l = vi(n,-1),lid = 0;
fin(i,0,n) g[i].clear();
fin(i,0,n-1) g[u[i]].pb(v[i]),g[v[i]].pb(u[i]);
fin(i,0,n) if(g[i].size()==1) { dfs(i); break; }
return l;
}
int dir(int a, int b){
if(a==b) return 0;
return b>a?1:-1;
}
int find_next_station(int s, int t, std::vector<int> c) {
for(int v : c) if(dir(s,v)==dir(s,t)) return v;
return c[0];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
684 ms |
528 KB |
Output is correct |
2 |
Correct |
475 ms |
528 KB |
Output is correct |
3 |
Correct |
1003 ms |
400 KB |
Output is correct |
4 |
Correct |
765 ms |
528 KB |
Output is correct |
5 |
Correct |
778 ms |
400 KB |
Output is correct |
6 |
Correct |
460 ms |
528 KB |
Output is correct |
7 |
Correct |
512 ms |
528 KB |
Output is correct |
8 |
Correct |
3 ms |
468 KB |
Output is correct |
9 |
Correct |
6 ms |
448 KB |
Output is correct |
10 |
Correct |
2 ms |
476 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
557 ms |
508 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
572 ms |
528 KB |
Output is correct |
2 |
Correct |
581 ms |
600 KB |
Output is correct |
3 |
Correct |
1333 ms |
488 KB |
Output is correct |
4 |
Correct |
981 ms |
508 KB |
Output is correct |
5 |
Correct |
672 ms |
504 KB |
Output is correct |
6 |
Correct |
569 ms |
520 KB |
Output is correct |
7 |
Correct |
502 ms |
528 KB |
Output is correct |
8 |
Correct |
3 ms |
468 KB |
Output is correct |
9 |
Correct |
6 ms |
476 KB |
Output is correct |
10 |
Correct |
2 ms |
468 KB |
Output is correct |
11 |
Incorrect |
701 ms |
508 KB |
Wrong query response. |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
974 ms |
400 KB |
Output is correct |
2 |
Correct |
760 ms |
508 KB |
Output is correct |
3 |
Correct |
689 ms |
512 KB |
Output is correct |
4 |
Correct |
2 ms |
468 KB |
Output is correct |
5 |
Correct |
5 ms |
468 KB |
Output is correct |
6 |
Correct |
2 ms |
468 KB |
Output is correct |
7 |
Incorrect |
700 ms |
400 KB |
Wrong query response. |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
771 ms |
512 KB |
Output is correct |
2 |
Correct |
695 ms |
508 KB |
Output is correct |
3 |
Correct |
1251 ms |
568 KB |
Output is correct |
4 |
Correct |
958 ms |
400 KB |
Output is correct |
5 |
Correct |
761 ms |
512 KB |
Output is correct |
6 |
Correct |
651 ms |
528 KB |
Output is correct |
7 |
Correct |
578 ms |
508 KB |
Output is correct |
8 |
Correct |
2 ms |
468 KB |
Output is correct |
9 |
Correct |
4 ms |
468 KB |
Output is correct |
10 |
Correct |
2 ms |
468 KB |
Output is correct |
11 |
Incorrect |
620 ms |
492 KB |
Wrong query response. |
12 |
Halted |
0 ms |
0 KB |
- |