#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
const bool debug = 0;
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
vector<int> ret(n);
for (int i=0; i<n; i++) ret[i] = i+1;
return ret;
}
int find_next_station(int s, int t, vector<int> c) {
bitset<15> a, b;
int tmp = s, s1 = 0, s2 = 0;
while (tmp > 0) a[s1] = tmp%2, tmp = (tmp>>1), s1++;
tmp = t;
while (tmp > 0) b[s2] = tmp%2, tmp = (tmp>>1), s2++;
if (debug) {
cout << "bit s ";
for (int i=0; i<s1; i++) cout << a[i];
cout << endl << "bit t ";
for (int i=0; i<s2; i++) cout << b[i];
cout << endl;
}
bitset<15> go;
int s3 = 0;
for (int i=1; i<=min(s1, s2); i++) {
if (a[s1-i] != b[s2-i]) break;
go[i-1] = a[s1-i];
s3 = i;
}
if (debug) {
cout << "bit lca ";
for (int i=0; i<s3; i++) cout << go[i];
cout << endl;
}
int lca = 0;
for (int i=0; i<s3; i++) lca += go[i] * (1<<(s3-1-i));
if (debug) cout << "s " << s << " t " << t << " lca " << lca << endl;
if (lca < s) return s/2;
return (s<<1) + b[s2-1-s1];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
562 ms |
496 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
451 ms |
400 KB |
Output is correct |
2 |
Correct |
553 ms |
404 KB |
Output is correct |
3 |
Correct |
839 ms |
404 KB |
Output is correct |
4 |
Correct |
476 ms |
400 KB |
Output is correct |
5 |
Correct |
509 ms |
616 KB |
Output is correct |
6 |
Correct |
360 ms |
400 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
607 ms |
400 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
883 ms |
400 KB |
Output is correct |
2 |
Incorrect |
605 ms |
480 KB |
Wrong query response. |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
496 ms |
488 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |