# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1035292 |
2024-07-26T08:54:18 Z |
Gray |
Stations (IOI20_stations) |
C++17 |
|
608 ms |
772 KB |
#include "stations.h"
#include <iostream>
#include <vector>
#define ll int
#define ff first
#define ss second
#define ln "\n"
#define pll pair<ll, ll>
using namespace std;
vector<vector<ll>> A;
void dfs(ll u, ll p, vector<ll> &labels){
ll add=0;
for (auto v:A[u]){
if (v==p) continue;
labels[v]=(labels[u]<<1ll)+add;
add++;
dfs(v, u, labels);
}
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
A.clear();
A.resize(n);
for (ll i=0; i<n-1; i++){
A[u[i]].push_back(v[i]);
A[v[i]].push_back(u[i]);
}
vector<int> labels(n);
labels[0]=1;
dfs(0, 0, labels);
// for (ll i=0; i<n; i++){
// cout << labels[i] << ln;
// }
return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
ll cnts=0, cntt=0;
for (ll i=0; i<=10; i++){
if ((1ull<<i)&s){
cnts=i;
}
if ((1ull<<i)&t){
cntt=i;
}
}
// cout << s << "->" << t << ":" << cnts << "&" <<cntt << ln;
if (cnts>cntt){
return c[0];
}else if (cntt>cnts){
if ((t^(s<<(cntt-cnts)))>>(cntt-cnts)==0){
// cout << "Hap\n";
if ((t&(1ll<<(cntt-cnts-1)))){
return c[c.size()-1];
}else{
if (c.size()==3)return c[c.size()-2];
else if (s==1){
return c[0];
}
else return c[c.size()-1];
}
}else{
return c[0];
}
}else{
return c[0];
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
600 KB |
Invalid labels (duplicates values). scenario=2, label=0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
287 ms |
688 KB |
Output is correct |
2 |
Correct |
353 ms |
684 KB |
Output is correct |
3 |
Correct |
608 ms |
684 KB |
Output is correct |
4 |
Correct |
449 ms |
684 KB |
Output is correct |
5 |
Correct |
411 ms |
684 KB |
Output is correct |
6 |
Correct |
286 ms |
684 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
600 KB |
Invalid labels (duplicates values). scenario=1, label=0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
582 ms |
684 KB |
Output is correct |
2 |
Correct |
421 ms |
684 KB |
Output is correct |
3 |
Correct |
363 ms |
684 KB |
Output is correct |
4 |
Correct |
1 ms |
768 KB |
Output is correct |
5 |
Correct |
2 ms |
764 KB |
Output is correct |
6 |
Correct |
0 ms |
768 KB |
Output is correct |
7 |
Correct |
341 ms |
772 KB |
Output is correct |
8 |
Correct |
478 ms |
768 KB |
Output is correct |
9 |
Correct |
391 ms |
684 KB |
Output is correct |
10 |
Correct |
354 ms |
684 KB |
Output is correct |
11 |
Incorrect |
0 ms |
344 KB |
Invalid labels (duplicates values). scenario=2, label=4 |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
600 KB |
Invalid labels (duplicates values). scenario=1, label=0 |
2 |
Halted |
0 ms |
0 KB |
- |