#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)
vector<vi> adj;
vi labels;
int cnt=0;
vi sub;
int d = 0;
void dfs(int s, int p=-1){
d++;
labels[s] = cnt;
//cout<<"enter "<<s<<" "<<cnt<<endl;
for(auto v : adj[s]) if(v!=p) cnt++, dfs(v, s), sub[s]+=sub[v];
cnt++;
labels[s]=labels[s]*1000 + cnt;
//cout<<"leave "<<s<<" "<<cnt<<endl;
d--;
}
vi label(int n, int k, std::vector<int> u, std::vector<int> v) {
cnt = 0;
adj.assign(n, vi());
sub.assign(n, 1);
labels.assign(n, 0);
FOR(i,n-1){
adj[u[i]].push_back(v[i]);
adj[v[i]].push_back(u[i]);
}
dfs(0);
//FOR(i,n) cout<<labels[i]<<" "<<sub[i]<<endl;
//FOR(i,n) labels[i] = (labels[i]<<10) + sub[i];
//FOA(v, labels) cout<<v<<" "; cout<<endl;
return labels;
}
int get_s(int x){ return x % (1000); }
int find_next_station(int s, int t, std::vector<int> c) {
//cout<<s<<" "<<t<<endl;
int lt = t/1000;
int sin = s/1000;
FOA(x, c){
if((x/1000)<sin) continue;
int xin = x/1000;
int xout = x%1000;
if(xin<=lt && lt<=xout) return x;
}
return *min_element(c.begin(), c.end());
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
456 KB |
Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=7014 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
412 KB |
Invalid labels (values out of range). scenario=0, k=1000, vertex=0, label=1991 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
420 KB |
Invalid labels (values out of range). scenario=1, k=1000000, vertex=12, label=1750970 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1144 ms |
472 KB |
Output is correct |
2 |
Correct |
804 ms |
400 KB |
Output is correct |
3 |
Correct |
618 ms |
404 KB |
Output is correct |
4 |
Correct |
3 ms |
472 KB |
Output is correct |
5 |
Correct |
5 ms |
472 KB |
Output is correct |
6 |
Correct |
2 ms |
472 KB |
Output is correct |
7 |
Correct |
637 ms |
400 KB |
Output is correct |
8 |
Correct |
1073 ms |
400 KB |
Output is correct |
9 |
Correct |
765 ms |
492 KB |
Output is correct |
10 |
Correct |
622 ms |
476 KB |
Output is correct |
11 |
Correct |
7 ms |
472 KB |
Output is correct |
12 |
Correct |
6 ms |
480 KB |
Output is correct |
13 |
Correct |
6 ms |
480 KB |
Output is correct |
14 |
Correct |
4 ms |
472 KB |
Output is correct |
15 |
Correct |
2 ms |
480 KB |
Output is correct |
16 |
Correct |
712 ms |
492 KB |
Output is correct |
17 |
Correct |
714 ms |
400 KB |
Output is correct |
18 |
Correct |
516 ms |
400 KB |
Output is correct |
19 |
Correct |
582 ms |
492 KB |
Output is correct |
20 |
Correct |
535 ms |
472 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
656 ms |
656 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |