-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaoj1228.cpp
More file actions
86 lines (82 loc) · 1.63 KB
/
aoj1228.cpp
File metadata and controls
86 lines (82 loc) · 1.63 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for(int i = a; i < (int)b; i++)
#define pb push_back
#define mp make_pair
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef long long ll;
const int INF = 1<<28;
const ll MOD = 1000000007;
const int dy[] = {1, 1, 0, -1, -1, 0}, dx[] = {0, 1, 1, 0, -1, -1};
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n; cin >> n;
REP(_, n) {
string in1, in2, in;
cin >> in1;
if(in1 == "-") {
cout << "true" << endl;
continue;
}
cin >> in2;
if(in2 == "-") {
cout << "false" << endl;
continue;
}
cin >> in;
if(in1.size() != in2.size()) {
cout << "false" << endl;
continue;
}
bool b[250][250] = {};
pi p(120, 120);
REP(i, in1.size()) {
p.first += dx[in1[i] - 'a'];
p.second += dy[in1[i] - 'a'];
b[p.first][p.second] = true;
cout << p.first << ' ' << p.second << ' ';
}
bool flg = false;
REP(j, 6) {
p = mp(120, 120);
int cnt = 0;
REP(i, in2.size()) {
p.first += dx[(in2[i] - 'a' + j) % 6];
p.second += dy[(in2[i] - 'a' + j) % 6];
if(b[p.first][p.second])
cnt++;
}
if(cnt == in2.size()) {
flg = true;
break;
}
}
if(flg)
cout << "true" << endl;
else
cout << "false" << endl;
}
return 0;
}