#include "stations.h"
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define INF 10000000
#define MOD 1000000007
#define MID ((l+r)/2)
#define HASHMOD 2305843009213693951
#define ll long long
#define ull unsigned long long
#define F first
#define S second
typedef pair<ll, ll> ii;
typedef pair<ii, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef map<int, int> mii;
#define EPS 1e-6
#define FOR(i,n) for(int i=0;i<((int)(n));i++)
#define FORi(i,a,b) for(int i=((int)(a));i<((int)(b));i++)
#define FOA(v, a) for(auto v : a)
vi label(int n, int k, std::vector<int> u, std::vector<int> v) {
vi labels(n);
vector<vi> adj(n, vi());
FOR(i,n-1){
adj[u[i]].push_back(v[i]);
adj[v[i]].push_back(u[i]);
}
// find hub
int h=0;
vector<bool> vis(n, false);
FOR(i,n) if(adj[i].size()>2){
h=i;
labels[i] = 1000000;
vis[i] = true;
break;
}
int off=0;
FOA(s,adj[h]){
int cnt=0;
bool ff = true;
while(ff){
vis[s] = true;
labels[s] = off+cnt++;
ff = false;
FOA(v, adj[s]) if(!vis[v]) s = v, ff=true;
}
off+=1000;
}
//FOA(v,labels) cout<<v<<" "; cout<<endl;
return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
//cout<<s<<" "<<t<<endl;
if(s==1000000) return t/1000 * 1000;
else if(s/1000!=t/1000 || s>t) return *min_element(c.begin(), c.end());
else return s+1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
328 KB |
Invalid labels (duplicates values). scenario=1, label=0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
288 KB |
Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=1000000 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
288 KB |
Invalid labels (duplicates values). scenario=1, label=0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1081 ms |
400 KB |
Output is correct |
2 |
Incorrect |
1 ms |
288 KB |
Invalid labels (duplicates values). scenario=0, label=0 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
412 KB |
Invalid labels (duplicates values). scenario=0, label=0 |
2 |
Halted |
0 ms |
0 KB |
- |