-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDRAGON.cpp
More file actions
58 lines (43 loc) · 684 Bytes
/
Copy pathDRAGON.cpp
File metadata and controls
58 lines (43 loc) · 684 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;
const char *str[] = {
"+FX","+YF","-FX","-YF"
};
const int next_to[2][4] = {
{0,0,2,2},
{1,3,1,3}
};
char bit[32];
int solve(int pos, int state)
{
if(pos < 0)
return state;
return solve(pos-1, next_to[bit[pos]][state]);
}
int main()
{
int T;
cin >> T;
while(T--)
{
int N, P, Q, L;
cin >> N >> P >> L;
int left = P % 3;
Q = (P + L + 3) / 3;
P /= 3;
string ans = "";
while(P < Q)
{
int pos = 0;
for(int i=P; i; i/=2)
bit[pos++] = i % 2;
int find = solve(pos-1,0);
ans += str[find];
P++;
}
cout << ans.substr(left,L) << endl;
}
return 0;
}