# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1066894 |
2024-08-20T08:32:41 Z |
김은성(#11121) |
Speedrun (RMI21_speedrun) |
C++17 |
|
227 ms |
940 KB |
#include "speedrun.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> child[1009];
vector<int> graph[1009];
int par[1009];
void settree(int v){
for(int u: graph[v]){
if(par[v] == u)
continue;
par[u] = v;
child[v].push_back(u);
settree(u);
}
}
int leftchild(){
int ans = 0;
for(int i=0; i<10; i++){
if(getHint(i+1))
ans |= (1<<i);
}
return ans;
}
int rightsibling(){
int ans = 0;
for(int i=0; i<10; i++){
if(getHint(i+11))
ans |= (1<<i);
}
return ans;
}
int parent(){
int ans = 0;
for(int i=0; i<10; i++){
if(getHint(i+21))
ans |= (1<<i);
}
return ans;
}
void setnumber(int v, int offset, int mask){
for(int i=0; i<10; i++){
if(mask & (1<<i))
setHint(v, i+offset, 1);
}
}
void assignHints(int subtask, int N, int A[], int B[]) { /* your solution here */
setHintLen(30);
int i;
for(i=1; i<N; i++){
graph[A[i]].push_back(B[i]);
graph[B[i]].push_back(A[i]);
}
settree(1);
for(i=1; i<=N; i++){
setnumber(i, 1, child[i].empty() ? 0 : child[i][0]);
int rs = 0;
if(par[i]){
int idx = find(child[par[i]].begin(), child[par[i]].end(), i) - child[par[i]].begin();
if(idx+1 < child[par[i]].size())
rs = child[par[i]][idx+1];
}
setnumber(i, 11, rs ? rs : par[i]);
}
}
int n;
bool ch[1009];
void dfs(int p, int v){
int i;
ch[v] = 1;
int l = leftchild(), r = rightsibling();
//printf("v=%d l=%d r=%d\n", v,l, r);
if(l){
goTo(l);
dfs(v, l);
goTo(v);
}
if(r && !ch[r]){
goTo(p);
goTo(r);
dfs(v, r);
goTo(v);
}
}
void speedrun(int subtask, int N, int start) { /* your solution here */
n = N;
while(rightsibling()){
start = rightsibling();
goTo(start);
}
dfs(0, 1);
}
Compilation message
speedrun.cpp: In function 'void assignHints(int, int, int*, int*)':
speedrun.cpp:59:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
59 | if(idx+1 < child[par[i]].size())
| ~~~~~~^~~~~~~~~~~~~~~~~~~~~~
speedrun.cpp: In function 'void dfs(int, int)':
speedrun.cpp:68:6: warning: unused variable 'i' [-Wunused-variable]
68 | int i;
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
62 ms |
716 KB |
Used too many wrong interactions |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
The length is too large |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
The length is too large |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
227 ms |
684 KB |
Used too many wrong interactions |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
48 ms |
940 KB |
Used too many wrong interactions |
2 |
Halted |
0 ms |
0 KB |
- |