# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
850139 |
2023-09-15T19:53:13 Z |
divad |
Speedrun (RMI21_speedrun) |
C++14 |
|
116 ms |
1620 KB |
#include <bits/stdc++.h>
#include "speedrun.h"
#define pii pair<int, int>
using namespace std;
const int NMAX = 1002;
vector<int> v[NMAX];
int n,l,t[NMAX],tour[NMAX],pos[NMAX],k;
int st[NMAX];
void euler(int nod, int tata = -1){
if(tata > 0){
t[nod] = tata;
}
if(!pos[nod]){
tour[++k] = nod;
pos[nod] = k;
}
for(int fiu: v[nod]){
if(fiu == tata){
continue;
}
euler(fiu, nod);
}
}
pii split(int x){
x >>= 1;
int mask = (1<<10)-1;
return {x&mask, x>>10};
}
void assignHints (int subtask , int N, int A[], int B[]){
setHintLen(41);
n = N;
for(int i = 1; i < N; i++){
v[A[i]].push_back(B[i]);
v[B[i]].push_back(A[i]);
}
euler(1);
for(int i = 1; i <= n; i++){
int val = t[i] + ((tour[pos[i]+1]) << 10);
val <<= 1;
pii aux = split(val);
for(int j = 1; j <= 20; j++){
int bt = ((val>>j)&1);
setHint(i, j, bt);
}
}
}
int getWholeHint(){
int ans = 0;
for(int i = 1; i <= 20; i++){
ans += (1<<i)*getHint(i);
}
return ans;
}
void speedrun(int subtask , int N, int start){
n = N;
l = getLength();
while(start != 1){
int val = getWholeHint();
start = split(val).first;
goTo(start);
}
int vf = 0;
st[++vf] = 1;
int cnt = 1;
while(cnt != n){
int nxt = split(getWholeHint()).second;
while(!goTo(nxt)){
vf--;
goTo(st[vf]);
}
goTo(nxt);
st[++vf] = nxt;
cnt++;
}
}
Compilation message
speedrun.cpp: In function 'void assignHints(int, int, int*, int*)':
speedrun.cpp:44:13: warning: variable 'aux' set but not used [-Wunused-but-set-variable]
44 | pii aux = split(val);
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
116 ms |
1368 KB |
Output is correct |
2 |
Correct |
114 ms |
1536 KB |
Output is correct |
3 |
Correct |
105 ms |
1360 KB |
Output is correct |
4 |
Correct |
104 ms |
1488 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
The length is too large |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
The length is too large |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
104 ms |
1364 KB |
Output is correct |
2 |
Correct |
106 ms |
1620 KB |
Output is correct |
3 |
Correct |
97 ms |
1108 KB |
Output is correct |
4 |
Correct |
110 ms |
1244 KB |
Output is correct |
5 |
Correct |
100 ms |
1372 KB |
Output is correct |
6 |
Correct |
102 ms |
1256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
The length is too large |
2 |
Halted |
0 ms |
0 KB |
- |