#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
#define what_is(a) cout << #a << " is " << a << "\n"
#define checker(a) cout <"checker reached " << a << "\n"
vector<vector<int>> adj(1000,vector<int>());
vector<int> lbl;
int m;
void dfs(int u,int p,int d){
lbl[u] = d;
for(int i=0;i<(int)adj[u].size();i++)
if(adj[u][i]!=p)
dfs(adj[u][i],u,d*m+i+1);
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
lbl = vector<int>(n);
for(int i=0;i<n;i++)
adj[i] = vector<int>();
for(int i=0;i<n-1;i++){
adj[u[i]].push_back(v[i]);
adj[v[i]].push_back(u[i]);
}
m=0;
for(int i=0;i<n;i++)
m = max(m,(int)adj[i].size());
dfs(0,0,0);
return lbl;
}
int find_next_station(int s, int t, std::vector<int> c) {
int a =s,b=t;
while(a>0){
a= (a-1)/m;
if(a==b)break;
}
if(a==b)return (s-1)/m;
a=s,b=t;
int p=b;
while(b>0){
p=b;
b = (b-1)/m;
if(a==b)break;
}
if(a==b)return p;
return (s-1)/m;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
432 KB |
Invalid labels (values out of range). scenario=2, k=1000, vertex=2, label=1380596652 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
368 KB |
Invalid labels (values out of range). scenario=0, k=1000, vertex=127, label=1457 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
400 KB |
Invalid labels (values out of range). scenario=1, k=1000000, vertex=1, label=-1671179380 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
656 KB |
Execution killed with signal 8 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
416 KB |
Invalid labels (values out of range). scenario=1, k=1000000000, vertex=1, label=-1369328816 |
2 |
Halted |
0 ms |
0 KB |
- |