#include "monster.h"
#include<bits/stdc++.h>
using namespace std;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
map<pair<int,int>,int>mp;
bool query(int a, int b) {
return Query(a, b);
if(mp.find({a, b})!=mp.end()) return mp[{a, b}];
if(Query(a, b)) {
mp[{a, b}]=1;
mp[{b, a}]=0;
} else {
mp[{b, a}]=1;
mp[{a, b}]=0;
}
return mp[{a, b}];
}
vector<int>cd(vector<int>T) {
if(T.size()==1) return T;
vector<int>A, B;
rep(i, T.size()/2) A.pb(T[i]);
for(int i=T.size()/2; i<T.size(); ++i) B.pb(T[i]);
A=cd(A);
B=cd(B);
int l1=0, l2=0;
vector<int>P;
while(l1<A.size() && l2<B.size()) {
if(query(A[l1], B[l2])==false) P.pb(A[l1++]);
else P.pb(B[l2++]);
}
while(l1<A.size()) P.pb(A[l1++]);
while(l2<B.size()) P.pb(B[l2++]);
return P;
}
vector<int>Solve(int n) {
vector<int>T(n);
rep(i, n) T[i]=i;
T=cd(T);
string s="";
if(query(T[0], T[2])) s+="1"; else s+="0";
if(query(T[0], T[3])) s+="1"; else s+="0";
if(query(T[1], T[3])) s+="1"; else s+="0";
int l=0;
if(s=="001" || s=="011" || s=="101") {
l=1;
} else if(s=="000" || s=="010") {
reverse(T.begin(), T.begin()+2);
l=2;
} else if(s=="110") {
reverse(T.begin(), T.begin()+3);
l=3;
} else if(s=="111") {
l=4;
while(l<n) {
if(query(T[l-2], T[l])==false) break;
++l;
}
reverse(T.begin(), T.begin()+l);
} else {
l=4;
while(l<n) {
if(query(T[0], T[l])==true) {
swap(T[0], T[2]);
break;
}
if(query(T[1], T[l])==true) {
swap(T[1], T[2]);
break;
}
if(query(T[2], T[l])==true) {
swap(T[0], T[1]);
break;
}
++l;
}
++l;
reverse(T.begin()+3, T.begin()+l);
}
while(l<n) {
int p=l;
while(query(T[l-1], T[p])==false) ++p;
reverse(T.begin()+l, T.begin()+p+1);
l=p+1;
}
vector<int>P(n);
rep(i, n) P[T[i]]=i;
return P;
}
Compilation message
monster.cpp: In function 'std::vector<int> cd(std::vector<int>)':
monster.cpp:4:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
4 | #define rep(a, b) for(int a = 0; a < (b); ++a)
| ^
monster.cpp:25:3: note: in expansion of macro 'rep'
25 | rep(i, T.size()/2) A.pb(T[i]);
| ^~~
monster.cpp:26:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
26 | for(int i=T.size()/2; i<T.size(); ++i) B.pb(T[i]);
| ~^~~~~~~~~
monster.cpp:31:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
31 | while(l1<A.size() && l2<B.size()) {
| ~~^~~~~~~~~
monster.cpp:31:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
31 | while(l1<A.size() && l2<B.size()) {
| ~~^~~~~~~~~
monster.cpp:35:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
35 | while(l1<A.size()) P.pb(A[l1++]);
| ~~^~~~~~~~~
monster.cpp:36:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
36 | while(l2<B.size()) P.pb(B[l2++]);
| ~~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
424 KB |
Output is correct |
16 |
Correct |
7 ms |
344 KB |
Output is correct |
17 |
Correct |
7 ms |
344 KB |
Output is correct |
18 |
Correct |
7 ms |
344 KB |
Output is correct |
19 |
Correct |
6 ms |
436 KB |
Output is correct |
20 |
Correct |
7 ms |
440 KB |
Output is correct |
21 |
Correct |
0 ms |
344 KB |
Output is correct |
22 |
Correct |
0 ms |
344 KB |
Output is correct |
23 |
Correct |
1 ms |
344 KB |
Output is correct |
24 |
Correct |
1 ms |
344 KB |
Output is correct |
25 |
Correct |
1 ms |
344 KB |
Output is correct |
26 |
Correct |
5 ms |
344 KB |
Output is correct |
27 |
Correct |
0 ms |
344 KB |
Output is correct |
28 |
Correct |
0 ms |
344 KB |
Output is correct |
29 |
Correct |
0 ms |
344 KB |
Output is correct |
30 |
Correct |
0 ms |
344 KB |
Output is correct |
31 |
Correct |
1 ms |
344 KB |
Output is correct |
32 |
Correct |
4 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
424 KB |
Output is correct |
16 |
Correct |
7 ms |
344 KB |
Output is correct |
17 |
Correct |
7 ms |
344 KB |
Output is correct |
18 |
Correct |
7 ms |
344 KB |
Output is correct |
19 |
Correct |
6 ms |
436 KB |
Output is correct |
20 |
Correct |
7 ms |
440 KB |
Output is correct |
21 |
Correct |
0 ms |
344 KB |
Output is correct |
22 |
Correct |
0 ms |
344 KB |
Output is correct |
23 |
Correct |
1 ms |
344 KB |
Output is correct |
24 |
Correct |
1 ms |
344 KB |
Output is correct |
25 |
Correct |
1 ms |
344 KB |
Output is correct |
26 |
Correct |
5 ms |
344 KB |
Output is correct |
27 |
Correct |
0 ms |
344 KB |
Output is correct |
28 |
Correct |
0 ms |
344 KB |
Output is correct |
29 |
Correct |
0 ms |
344 KB |
Output is correct |
30 |
Correct |
0 ms |
344 KB |
Output is correct |
31 |
Correct |
1 ms |
344 KB |
Output is correct |
32 |
Correct |
4 ms |
344 KB |
Output is correct |
33 |
Correct |
36 ms |
600 KB |
Output is correct |
34 |
Correct |
54 ms |
600 KB |
Output is correct |
35 |
Correct |
44 ms |
592 KB |
Output is correct |
36 |
Correct |
47 ms |
436 KB |
Output is correct |
37 |
Correct |
43 ms |
592 KB |
Output is correct |
38 |
Correct |
46 ms |
344 KB |
Output is correct |
39 |
Correct |
42 ms |
460 KB |
Output is correct |
40 |
Correct |
35 ms |
592 KB |
Output is correct |
41 |
Correct |
50 ms |
436 KB |
Output is correct |
42 |
Correct |
47 ms |
592 KB |
Output is correct |
43 |
Correct |
24 ms |
436 KB |
Output is correct |
44 |
Correct |
27 ms |
440 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
54 ms |
432 KB |
Output is correct |
2 |
Correct |
43 ms |
344 KB |
Output is correct |
3 |
Correct |
42 ms |
592 KB |
Output is correct |
4 |
Correct |
43 ms |
344 KB |
Output is correct |
5 |
Correct |
50 ms |
344 KB |
Output is correct |
6 |
Correct |
41 ms |
452 KB |
Output is correct |
7 |
Correct |
43 ms |
436 KB |
Output is correct |
8 |
Correct |
43 ms |
592 KB |
Output is correct |
9 |
Correct |
48 ms |
440 KB |
Output is correct |
10 |
Correct |
55 ms |
440 KB |
Output is correct |
11 |
Correct |
54 ms |
596 KB |
Output is correct |
12 |
Correct |
42 ms |
344 KB |
Output is correct |
13 |
Correct |
35 ms |
456 KB |
Output is correct |
14 |
Correct |
39 ms |
344 KB |
Output is correct |
15 |
Correct |
21 ms |
436 KB |
Output is correct |
16 |
Correct |
28 ms |
436 KB |
Output is correct |
17 |
Correct |
38 ms |
344 KB |
Output is correct |
18 |
Correct |
27 ms |
344 KB |
Output is correct |