#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
int pos = 0;
vector <int> bfs (int n, int nodo, vector <int> grafo[1000005]){
vector <int> aux(n);
bool visto[1000005];
queue <int> q;
pos = 0;
for (int i = 0; i < 1000005; i++) visto[i] = false;
q.push(nodo);
while (!q.empty()){
int act = q.front();
q.pop();
if (visto[act] == true) continue;
visto[act] = true;
for (auto i : grafo[act]) q.push(i);
aux[act] = pos;
pos++;
}
return aux;
}
vector <int> label(int n, int k, vector <int> u, vector <int> v) {
vector <int> grafo[1000005];
for (int i = 0; i < u.size(); i++) {
int a = u[i], b = v[i];
grafo[a].pb(b);
grafo[b].pb(a);
}
for (int i = 0; i < n; i++){
if (grafo[i].size() == 1){
vector <int> labels = bfs(n, i, grafo);
//for (auto j : labels) cout << j << " ";
return labels;
}
}
return u;
}
int find_next_station(int s, int t, vector <int> c) {
if (c.size() == 1) return c[0];
if (t > s) return max(c[0], c[1]);
else return min(c[0], c[1]);
}
/*
int main(){
label(5, 10, {0, 3, 4, 2}, {1, 4, 0, 1});
}
*/
Compilation message
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:42:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
42 | for (int i = 0; i < u.size(); i++) {
| ~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
389 ms |
25260 KB |
Output is correct |
2 |
Correct |
353 ms |
25304 KB |
Output is correct |
3 |
Correct |
671 ms |
25004 KB |
Output is correct |
4 |
Correct |
509 ms |
25176 KB |
Output is correct |
5 |
Correct |
422 ms |
25004 KB |
Output is correct |
6 |
Correct |
310 ms |
25260 KB |
Output is correct |
7 |
Correct |
320 ms |
25260 KB |
Output is correct |
8 |
Correct |
37 ms |
25112 KB |
Output is correct |
9 |
Correct |
40 ms |
25112 KB |
Output is correct |
10 |
Correct |
22 ms |
25004 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
336 ms |
25520 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
373 ms |
25288 KB |
Output is correct |
2 |
Correct |
335 ms |
25260 KB |
Output is correct |
3 |
Correct |
686 ms |
25208 KB |
Output is correct |
4 |
Correct |
492 ms |
25000 KB |
Output is correct |
5 |
Correct |
423 ms |
25264 KB |
Output is correct |
6 |
Correct |
359 ms |
25260 KB |
Output is correct |
7 |
Correct |
305 ms |
25260 KB |
Output is correct |
8 |
Correct |
35 ms |
25112 KB |
Output is correct |
9 |
Correct |
33 ms |
25004 KB |
Output is correct |
10 |
Correct |
26 ms |
25328 KB |
Output is correct |
11 |
Incorrect |
434 ms |
25004 KB |
Wrong query response. |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
701 ms |
25004 KB |
Output is correct |
2 |
Correct |
501 ms |
25008 KB |
Output is correct |
3 |
Correct |
478 ms |
25004 KB |
Output is correct |
4 |
Correct |
35 ms |
25004 KB |
Output is correct |
5 |
Correct |
32 ms |
25008 KB |
Output is correct |
6 |
Correct |
21 ms |
25136 KB |
Output is correct |
7 |
Incorrect |
466 ms |
25004 KB |
Wrong query response. |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
412 ms |
25260 KB |
Output is correct |
2 |
Correct |
333 ms |
25260 KB |
Output is correct |
3 |
Correct |
603 ms |
25152 KB |
Output is correct |
4 |
Correct |
522 ms |
25228 KB |
Output is correct |
5 |
Correct |
487 ms |
25080 KB |
Output is correct |
6 |
Correct |
341 ms |
25260 KB |
Output is correct |
7 |
Correct |
309 ms |
25048 KB |
Output is correct |
8 |
Correct |
33 ms |
25136 KB |
Output is correct |
9 |
Correct |
36 ms |
25136 KB |
Output is correct |
10 |
Correct |
18 ms |
25136 KB |
Output is correct |
11 |
Incorrect |
330 ms |
25260 KB |
Wrong query response. |
12 |
Halted |
0 ms |
0 KB |
- |