#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void dfs(ll node, vector<vector<ll>> & adj, vector<bool> & vis, vector<int> & labels, ll it){
vis[node] = 1;
labels[node] = it;
for(auto x : adj[node]){
if(vis[x]) continue;
it++;
dfs(x, adj, vis, labels, it);
}
}
vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
cout << "\n";
vector<int> labels(n);
vector<vector<ll>> adj(n);
for(int i = 0; i < (ll)u.size(); i++){
adj[ u[i] ].push_back( v[i] );
adj[ v[i] ].push_back( u[i] );
}
for(int i = 0; i < n; i++){
if(adj[i].size() == 1){
ll it = 0;
vector<bool> vis(n);
dfs( i, adj, vis, labels, it);
break;
}
}
return labels;
}
int find_next_station(int s, int t, std::vector<int> c){
sort(c.begin(), c.end());
if(t > s && s != 0){
return c[1];
}
return c[0];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
579 ms |
636 KB |
Output is correct |
2 |
Correct |
446 ms |
544 KB |
Output is correct |
3 |
Correct |
802 ms |
504 KB |
Output is correct |
4 |
Correct |
666 ms |
500 KB |
Output is correct |
5 |
Correct |
609 ms |
416 KB |
Output is correct |
6 |
Correct |
469 ms |
616 KB |
Output is correct |
7 |
Correct |
513 ms |
632 KB |
Output is correct |
8 |
Correct |
3 ms |
492 KB |
Output is correct |
9 |
Correct |
5 ms |
492 KB |
Output is correct |
10 |
Correct |
2 ms |
492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
296 KB |
Invalid labels (duplicates values). scenario=0, label=9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
594 ms |
544 KB |
Output is correct |
2 |
Correct |
479 ms |
616 KB |
Output is correct |
3 |
Correct |
1008 ms |
488 KB |
Output is correct |
4 |
Correct |
631 ms |
520 KB |
Output is correct |
5 |
Correct |
596 ms |
416 KB |
Output is correct |
6 |
Correct |
510 ms |
624 KB |
Output is correct |
7 |
Correct |
445 ms |
620 KB |
Output is correct |
8 |
Correct |
2 ms |
456 KB |
Output is correct |
9 |
Correct |
4 ms |
492 KB |
Output is correct |
10 |
Correct |
2 ms |
492 KB |
Output is correct |
11 |
Incorrect |
554 ms |
500 KB |
Wrong query response. |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1000 ms |
504 KB |
Output is correct |
2 |
Correct |
628 ms |
504 KB |
Output is correct |
3 |
Correct |
479 ms |
420 KB |
Output is correct |
4 |
Correct |
2 ms |
504 KB |
Output is correct |
5 |
Correct |
3 ms |
500 KB |
Output is correct |
6 |
Correct |
0 ms |
500 KB |
Output is correct |
7 |
Incorrect |
607 ms |
504 KB |
Wrong query response. |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
461 ms |
548 KB |
Output is correct |
2 |
Correct |
469 ms |
540 KB |
Output is correct |
3 |
Correct |
895 ms |
500 KB |
Output is correct |
4 |
Correct |
681 ms |
416 KB |
Output is correct |
5 |
Correct |
579 ms |
508 KB |
Output is correct |
6 |
Correct |
479 ms |
644 KB |
Output is correct |
7 |
Correct |
464 ms |
608 KB |
Output is correct |
8 |
Correct |
3 ms |
500 KB |
Output is correct |
9 |
Correct |
4 ms |
492 KB |
Output is correct |
10 |
Correct |
0 ms |
500 KB |
Output is correct |
11 |
Incorrect |
4 ms |
288 KB |
Invalid labels (duplicates values). scenario=0, label=9 |
12 |
Halted |
0 ms |
0 KB |
- |