# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1119819 |
2024-11-27T13:24:48 Z |
pera |
Speedrun (RMI21_speedrun) |
C++17 |
|
401 ms |
1324 KB |
#include<bits/stdc++.h>
#include "speedrun.h"
using namespace std;
void assignHints(int subtask , int N , int A[] , int B[]){
vector<vector<int>> g(N + 1);
for(int i = 1;i <= N - 1;i ++){
g[A[i]].emplace_back(B[i]);
g[B[i]].emplace_back(A[i]);
}
vector<int> par(N + 1) , o;
function<void(int)> dfs = [&](int u){
o.emplace_back(u);
for(int v : g[u]){
if(v != par[u]){
par[v] = u;
dfs(v);
}
}
};
dfs(1);
setHintLen(20);
for(int i = 1;i <= N;i ++){
for(int bit = 0;bit < 10;bit ++){
setHint(o[i - 1] , bit + 1, par[o[i - 1]] >> bit & 1);
}
for(int bit = 0;bit < 10;bit ++){
setHint(o[i - 1] , bit + 10 + 1 , o[i % N] >> bit & 1);
}
}
}
void speedrun(int subtask , int N , int v){
int c = 0 , nxt = 0;
vector<int> vis(N + 1);
while(c < N){
c += vis[v] == 0;
vis[v] = 1;
if(nxt == 0){
for(int bit = 0;bit < 10;bit ++){
nxt += (1 << bit) * getHint(bit + 10 + 1);
}
}
assert(0 < nxt && nxt <= N);
if(goTo(nxt) == true){
v = nxt;
nxt = 0;
}else{
int par = 0;
for(int bit = 0;bit < 10;bit ++){
par += (1 << bit) * getHint(bit + 1);
}
assert(0 < par && par <= N);
goTo(par);
v = par;
}
}
return;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
391 ms |
924 KB |
Output is correct |
2 |
Correct |
356 ms |
1080 KB |
Output is correct |
3 |
Correct |
331 ms |
1184 KB |
Output is correct |
4 |
Correct |
351 ms |
1076 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
366 ms |
1076 KB |
Output is correct |
2 |
Correct |
382 ms |
1324 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
304 ms |
924 KB |
Output is correct |
2 |
Correct |
332 ms |
668 KB |
Output is correct |
3 |
Correct |
355 ms |
840 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
373 ms |
928 KB |
Output is correct |
2 |
Correct |
390 ms |
916 KB |
Output is correct |
3 |
Correct |
369 ms |
1080 KB |
Output is correct |
4 |
Correct |
401 ms |
1064 KB |
Output is correct |
5 |
Correct |
348 ms |
820 KB |
Output is correct |
6 |
Correct |
355 ms |
1072 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
344 ms |
832 KB |
Output is correct |
2 |
Correct |
369 ms |
1076 KB |
Output is correct |
3 |
Correct |
358 ms |
816 KB |
Output is correct |
4 |
Correct |
356 ms |
828 KB |
Output is correct |
5 |
Correct |
341 ms |
1088 KB |
Output is correct |
6 |
Correct |
353 ms |
1084 KB |
Output is correct |
7 |
Correct |
359 ms |
924 KB |
Output is correct |