Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define all(x) begin(x),end(x)
- using namespace std;
- using ll = long long;
- void InitIO(string s = "") {
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- cout.tie(nullptr);
- if (s.size()) {
- freopen((s + ".in").c_str(), "r", stdin);
- freopen((s + ".out").c_str(), "w", stdout);
- }
- }
- int type[3][5];
- enum {
- GREEN,
- RED,
- BLUE,
- YELLOW
- };
- int pos(int lvl, double x, double y) {
- double h = sqrt(3) / 2;
- y -= h * lvl;
- if (lvl & 1) {
- y = h - y;
- }
- // x < y * tan(30)
- // x < y * tan(30) + (h - y) * tan(30) * 2
- // x < y * tan(30) + (h - y) * tan(30) * 2 + y * tan(30) * 2
- // x < y * tan(30) + (h - y) * tan(30) * 4 + y * tan(30) * 2
- const double PI = acos(-1);
- double tg = tan(PI / 6);
- if (x < y * tg) return 0;
- if (x < y * tg + (h - y) * tg * 2) return 1;
- if (x < y * tg + (h - y) * tg * 2 + y * tg * 2) return 2;
- if (x < y * tg + (h - y) * tg * 4 + y * tg * 2) return 3;
- return 4;
- }
- int main() {
- InitIO();
- string a, b;
- int a1, d1, a2, d2;
- cin >> a >> a1 >> d1;
- cin >> b >> a2 >> d2;
- map<string, int> mp;
- mp["CD"] = -1;
- mp["DB"] = 0;
- mp["BC"] = 1;
- int t1 = mp[a];
- int t2 = mp[b];
- double x1 = 0;
- double x2 = 0;
- const double PI = acos(-1);
- double alpha1 = a1 / 60.0 * PI / 3 - PI / 6;
- double alpha2 = a2 / 60.0 * PI / 3 - PI / 6;
- alpha1 += t1 * PI / 3;
- alpha2 += t2 * PI / 3;
- double yd1 = d1 * cos(alpha1);
- double yd2 = d2 * cos(alpha2);
- double xd1 = x1 + d1 * sin(alpha1);
- double xd2 = x2 + d2 * sin(alpha2);
- double t_x = 2;
- while (xd1 < 0) xd1 += t_x;
- while (xd2 < 0) xd2 += t_x;
- while (xd1 >= t_x) xd1 -= t_x;
- while (xd2 >= t_x) xd2 -= t_x;
- double t_y = 4 * sqrt(3) / 2;
- while (yd1 >= t_y) yd1 -= t_y;
- while (yd2 >= t_y) yd2 -= t_y;
- double h = sqrt(3) / 2;
- int lvl1 = yd1 / h;
- int lvl2 = yd2 / h;
- type[0][0] = GREEN;
- type[0][1] = RED;
- type[0][2] = BLUE;
- type[0][3] = YELLOW;
- type[0][4] = GREEN;
- type[1][0] = BLUE;
- type[1][1] = RED;
- type[1][2] = GREEN;
- type[1][3] = YELLOW;
- type[1][4] = BLUE;
- type[2][0] = BLUE;
- type[2][1] = YELLOW;
- type[2][2] = GREEN;
- type[2][3] = RED;
- type[2][4] = BLUE;
- type[3][0] = GREEN;
- type[3][1] = YELLOW;
- type[3][2] = BLUE;
- type[3][3] = RED;
- type[3][4] = GREEN;
- int x_1 = pos(lvl1, xd1, yd1);
- int x_2 = pos(lvl2, xd2, yd2);
- cout << (type[lvl1][x_1] == type[lvl2][x_2] ? "YES\n" : "NO\n");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement