#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1005;
int deg[N];
vector <int> g[N];
vector <int> label(int n,int k,vector <int> u,vector <int> v){
for(int i = 0; i < n; i++){
deg[i] = 0;
g[i].clear();
}
for(int i = 0; i < n-1; i++){
deg[u[i]]++;
deg[v[i]]++;
g[u[i]].push_back(v[i]);
g[v[i]].push_back(u[i]);
}
bool prvi = 1;
for(int i = 0; i < n; i++) if(deg[i] > 2) prvi = 0;
if(prvi){
int cnt = 0;
vector <int> l(n,0);
queue <pair<int,int>> q;
for(int i = 0; i < n; i++){
if(deg[i] == 1){
q.push({i,-1});
break;
}
}
while(!q.empty()){
int u = q.front().first,par = q.front().second;
l[u] = cnt++;
q.pop();
for(auto v : g[u]){
if(v == par) continue;
q.push({v,u});
}
}
return l;
}
assert(1 == 0);
}
int find_next_station(int s,int t,vector <int> c){
if(s < t){
return s+1;
}
else{
return s-1;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
522 ms |
504 KB |
Output is correct |
2 |
Correct |
530 ms |
508 KB |
Output is correct |
3 |
Correct |
976 ms |
400 KB |
Output is correct |
4 |
Correct |
726 ms |
508 KB |
Output is correct |
5 |
Correct |
690 ms |
400 KB |
Output is correct |
6 |
Correct |
548 ms |
508 KB |
Output is correct |
7 |
Correct |
493 ms |
528 KB |
Output is correct |
8 |
Correct |
3 ms |
468 KB |
Output is correct |
9 |
Correct |
5 ms |
468 KB |
Output is correct |
10 |
Correct |
2 ms |
468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
576 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
637 ms |
508 KB |
Output is correct |
2 |
Correct |
578 ms |
528 KB |
Output is correct |
3 |
Correct |
1095 ms |
400 KB |
Output is correct |
4 |
Correct |
818 ms |
400 KB |
Output is correct |
5 |
Correct |
724 ms |
404 KB |
Output is correct |
6 |
Correct |
551 ms |
528 KB |
Output is correct |
7 |
Correct |
504 ms |
512 KB |
Output is correct |
8 |
Correct |
4 ms |
468 KB |
Output is correct |
9 |
Correct |
4 ms |
476 KB |
Output is correct |
10 |
Correct |
3 ms |
468 KB |
Output is correct |
11 |
Runtime error |
1 ms |
456 KB |
Execution killed with signal 6 |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
975 ms |
400 KB |
Output is correct |
2 |
Correct |
629 ms |
404 KB |
Output is correct |
3 |
Correct |
731 ms |
516 KB |
Output is correct |
4 |
Correct |
3 ms |
468 KB |
Output is correct |
5 |
Correct |
4 ms |
448 KB |
Output is correct |
6 |
Correct |
2 ms |
468 KB |
Output is correct |
7 |
Runtime error |
1 ms |
428 KB |
Execution killed with signal 6 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
623 ms |
516 KB |
Output is correct |
2 |
Correct |
523 ms |
492 KB |
Output is correct |
3 |
Correct |
1115 ms |
400 KB |
Output is correct |
4 |
Correct |
765 ms |
420 KB |
Output is correct |
5 |
Correct |
763 ms |
404 KB |
Output is correct |
6 |
Correct |
572 ms |
520 KB |
Output is correct |
7 |
Correct |
557 ms |
528 KB |
Output is correct |
8 |
Correct |
4 ms |
468 KB |
Output is correct |
9 |
Correct |
6 ms |
468 KB |
Output is correct |
10 |
Correct |
2 ms |
468 KB |
Output is correct |
11 |
Runtime error |
2 ms |
600 KB |
Execution killed with signal 6 |
12 |
Halted |
0 ms |
0 KB |
- |