#include "speedrun.h"
#include <bits/stdc++.h>
using namespace std;
const int MAX = 2002;
int par[MAX];
vector<int> g[MAX];
vector<int> tour;
string convert(int a){
string s = "";
while(a){
if(a % 2) s += '1';
else s += '0';
a /= 2;
}
while(s.size() < 10){
s += '0';
}
return s;
}
int convert2(string s){
int a = 0;
for(int i = 0; i < s.size(); i++){
a += (1 << i) * (s[i] == '1');
}
return a;
}
void dfs(int node, int p){
par[node] = p;
tour.push_back(node);
for(int to : g[node]){
if(to == p) continue;
dfs(to, node);
}
}
void assignHints(int subtask, int N, int A[], int B[]) {
for(int i = 1; i < N; i++){
g[A[i]].push_back(B[i]);
g[B[i]].push_back(A[i]);
}
setHintLen(20);
dfs(1, 0);
for(int i = 1; i <= N; i++){
string s = convert(par[i]);
for(int j = 1; j <= 10; j++){
setHint(i, j, (s[j - 1] == '1'));
}
}
for(int i = 1; i <= N; i++){
if(i == N) continue;
string s = convert(tour[i]);
for(int j = 11; j <= 20; j++){
setHint(tour[i - 1], j, (s[j - 11] == '1'));
}
}
for(int j = 11; j <= 20; j++){
setHint(tour[N - 1], j, 0);
}
}
void speedrun(int subtask, int N, int start) {
int nxt = -1, p = 0;
while(true){
string s1 = "", s2 = "";
for(int j = 1; j <= 10; j++){
if(getHint(j)){
s1 += '1';
}
else{
s1 += '0';
}
}
for(int j = 11; j <= 20; j++){
if(getHint(j)){
s2 += '1';
}
else{
s2 += '0';
}
}
p = convert2(s1);
if(nxt == -1){
nxt = convert2(s2);
}
if(nxt == 0) break;
if(goTo(nxt)){
start = nxt;
nxt = -1;
}
else{
goTo(p);
start = p;
}
}
}
Compilation message
speedrun.cpp: In function 'int convert2(std::string)':
speedrun.cpp:27:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
27 | for(int i = 0; i < s.size(); i++){
| ~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
98 ms |
904 KB |
Solution didn't visit every node |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
99 ms |
1420 KB |
Solution didn't visit every node |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
93 ms |
916 KB |
Solution didn't visit every node |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
93 ms |
1428 KB |
Solution didn't visit every node |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
109 ms |
1672 KB |
Solution didn't visit every node |
2 |
Halted |
0 ms |
0 KB |
- |