#include "books.h"
#include<bits/stdc++.h>
using namespace std;
int n = 0;
vector<int> p;
bool caso(int a, int b, int c = -1, int d = -1){
if(c == -1) return p[0] == a && p[1] == b;
if(d == -1) return p[0] == a && p[1] == b && p[2] == c;
return p[0] == a && p[1] == b && p[2] == c && p[3] == d;
}
long long minimum_walk(vector<int> _p, int s) {
p = _p;
n = p.size();
if(n == 1) return 0;
if(n == 2){
if(caso(0, 1)) return 0;
if(caso(1, 0)) return 2;
}
if(n == 3){
if(caso(0, 1, 2)) return 0;
if(caso(0, 2, 1)) return 4;
if(caso(1, 0, 2)) return 2;
if(caso(1, 2, 0)) return 4;
if(caso(2, 0, 1)) return 4;
if(caso(2, 1, 0)) return 4;
}
if(n == 4){
if(caso(0, 1, 2, 3)) return 0;
if(caso(0, 1, 3, 2)) return 6;
if(caso(0, 2, 1, 3)) return 4;
if(caso(0, 2, 3, 1)) return 6;
if(caso(0, 3, 1, 2)) return 6;
if(caso(0, 3, 2, 1)) return 6;
if(caso(1, 0, 2, 3)) return 2;
if(caso(1, 0, 3, 2)) return 6;
if(caso(1, 2, 0, 3)) return 4;
if(caso(1, 2, 3, 0)) return 6;
if(caso(1, 3, 0, 2)) return 6;
if(caso(1, 3, 2, 0)) return 6;
if(caso(2, 0, 1, 3)) return 4;
if(caso(2, 0, 3, 1)) return 6;
if(caso(2, 1, 0, 3)) return 4;
if(caso(2, 1, 3, 0)) return 6;
if(caso(2, 3, 0, 1)) return 8;
if(caso(2, 3, 1, 0)) return 8;
if(caso(3, 0, 1, 2)) return 6;
if(caso(3, 0, 2, 1)) return 6;
if(caso(3, 1, 0, 2)) return 6;
if(caso(3, 1, 2, 0)) return 6;
if(caso(3, 2, 0, 1)) return 8;
if(caso(3, 2, 1, 0)) return 8;
}
}
Compilation message
books.cpp: In function 'long long int minimum_walk(std::vector<int>, int)':
books.cpp:59:1: warning: control reaches end of non-void function [-Wreturn-type]
59 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
264 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
264 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Incorrect |
1 ms |
204 KB |
3rd lines differ - on the 1st token, expected: '338572', found: '8' |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
264 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Incorrect |
1 ms |
204 KB |
3rd lines differ - on the 1st token, expected: '338572', found: '8' |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
3rd lines differ - on the 1st token, expected: '3304', found: '6' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
264 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Incorrect |
1 ms |
204 KB |
3rd lines differ - on the 1st token, expected: '338572', found: '8' |
20 |
Halted |
0 ms |
0 KB |
- |