QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#777653 | #2810. Speedrun | ursus# | 0 | 0ms | 0kb | C++20 | 1.8kb | 2024-11-24 06:02:56 | 2024-11-24 06:02:57 |
speedrun
#include <bits/stdc++.h>
using namespace std;
using vec = vector<int>;
using vvec = vector<vec>;
using bvec = vector<bool>;
using pii = pair<int,int>;
#define VECT(T) vector<T>
#define PRINT(vector) for(auto ele : vector) cout << ele << " "; cout << "\n";
#define RANGE(vector) vector.begin(), vector.end()
constexpr int E9 = 1e9 + 7;
constexpr int NUFFIN = 1023;
extern void setHintLen(int l);
extern void setHint(int i, int j, bool b);
extern int getLength();
extern bool getHint(int j);
extern bool goTo(int x);
void bettersethint(int p, int x, int y) {
for(int i = 0 ; i < 10 ; ++i) {
setHint(p, i, x&1);
x >>= 1;
}
for(int i = 0 ; i < 10 ; ++i) {
setHint(p, 10+i, x&1);
x >>= 1;
}
}
pii bettergethint(int p) {
int x = 0, y = 0;
for(int i = 0 ; i < 10 ; ++i) {
x <<= 1;
x += (int)getHint(i);
}
for(int i = 0 ; i < 10 ; ++i) {
x <<= 1;
x += (int)getHint(10+i);
}
return {x,y};
}
void dfs(vvec &g, int p, int par, pii next) {
int n = (int)g[p].size();
for(int i = 0 ; i < n ; ++i) {
pii nx = next;
if(i+1 < n) nx = {p, g[p][i+1]};
dfs(g, g[p][i], p, nx);
}
if(n == 1) bettersethint(p, next.first, next.second);
else bettersethint(p, g[p][0], NUFFIN);
}
void assignHints(int subtask , int N, int A[], int B[]) {
setHintLen(20);
vvec g(N);
for(int i = 0 ; i < N-1 ; ++i) {
g[A[i]].push_back(B[i]);
g[B[i]].push_back(A[i]);
}
}
void speedrun(int subtask, int N, int start) {
int p = start;
vec par(N, -1);
while(p != -1) {
auto [x,y] = bettergethint(p);
if(x == NUFFIN) break;
if(y == NUFFIN) {
assert(goTo(x));
par[x] = p;
p = x;
} else {
while(p != -1 && p != x) {
assert(goTo(par[p]));
p = par[p];
}
assert(p != -1);
assert(goTo(y));
par[y] = p;
p = y;
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Runtime Error
Test #1:
score: 0
Runtime Error
input:
1 1 1000 1 119 1 453 1 454 2 59 3 113 3 657 3 824 4 494 5 33 5 550 5 937 6 287 7 222 7 577 7 742 8 626 9 896 10 204 11 638 12 305 12 552 12 791 13 246 14 840 15 95 15 316 15 772 16 109 16 551 16 846 17 581 18 142 19 601 19 744 19 977 20 361 20 404 20 845 21 245 21 410 21 518 22 351 23 971 24 497 24 ...
output:
1 1 20
input:
output:
result:
Subtask #2:
score: 0
Runtime Error
Test #5:
score: 0
Runtime Error
input:
1 2 1000 1 133 2 133 3 133 4 133 5 133 6 133 7 133 8 133 9 133 10 133 11 133 12 133 13 133 14 133 15 133 16 133 17 133 18 133 19 133 20 133 21 133 22 133 23 133 24 133 25 133 26 133 27 133 28 133 29 133 30 133 31 133 32 133 33 133 34 133 35 133 36 133 37 133 38 133 39 133 40 133 41 133 42 133 43 133...
output:
1 1 20
input:
output:
result:
Subtask #3:
score: 0
Runtime Error
Test #7:
score: 0
Runtime Error
input:
1 3 1000 1 20 1 569 2 69 2 72 3 510 3 811 4 278 4 994 5 890 5 918 6 97 6 577 7 11 7 791 8 138 8 653 9 219 9 539 10 22 10 151 11 527 12 195 12 420 13 187 13 293 14 265 14 476 15 594 15 988 16 424 16 881 17 407 17 613 18 178 18 471 19 400 19 896 20 95 21 221 21 949 22 624 23 247 23 361 24 140 24 169 2...
output:
1 1 20
input:
output:
result:
Subtask #4:
score: 0
Runtime Error
Test #10:
score: 0
Runtime Error
input:
1 4 1000 1 103 1 881 2 195 2 740 3 224 4 558 5 749 5 788 6 189 7 221 8 362 9 267 9 547 10 205 10 813 10 926 11 23 12 687 13 225 14 366 14 768 15 58 15 156 15 869 16 79 16 225 17 61 17 437 18 500 18 534 18 768 18 989 19 300 20 909 21 970 22 245 22 425 23 528 23 669 23 809 23 890 24 121 24 778 25 845 ...
output:
1 1 20
input:
output:
result:
Subtask #5:
score: 0
Runtime Error
Test #16:
score: 0
Runtime Error
input:
1 5 1000 1 296 1 974 2 414 3 777 4 158 4 918 5 535 5 799 5 952 6 290 7 17 7 420 8 223 9 600 10 743 11 189 11 239 11 530 11 619 12 27 12 451 13 580 14 165 15 552 15 753 16 883 16 936 17 292 17 398 17 904 18 355 18 678 19 807 20 577 21 392 21 744 22 600 23 582 23 717 23 915 24 70 24 254 24 492 25 115 ...
output:
1 1 20