Asa's Website

B - Dice II

cpaojitp1

最終更新日

Table of Contents

Loading...

問題

https://onlinejudge.u-aizu.ac.jp/courses/lesson/2/ITP1/11/ITP1_11_B

問題文

Dice I と同じ方法で、サイコロを作る。
上面と前面の数が与えられるので、右側の面の数を答えてね。

制約

サンプル

I/O 1

1 2 3 4 5 6 3 6 5 1 3 3 2
3 5 6

考察

全部チェックする。ハードコーディング。

(Dice 構造体を作って確認できるようにすればいいのに...)

コード

https://onlinejudge.u-aizu.ac.jp/status/users/a01sa01to/submissions/1/ITP1_11_B/judge/6370998/C++17

bool chk(const vector<int>& v, int& a, int& b) { rep(i, 4) { if (v[i % 4] == a && v[(i + 1) % 4] == b) return true; } return false; } int main() { int dice[6]; rep(i, 6) cin >> dice[i]; int q; cin >> q; while (q--) { int a, b; cin >> a >> b; a = find(dice, dice + 6, a) - dice + 1; b = find(dice, dice + 6, b) - dice + 1; if (chk({ 2, 3, 5, 4 }, a, b)) { cout << dice[0] << endl; } if (chk({ 1, 4, 6, 3 }, a, b)) { cout << dice[1] << endl; } if (chk({ 1, 2, 6, 5 }, a, b)) { cout << dice[2] << endl; } if (chk({ 1, 5, 6, 2 }, a, b)) { cout << dice[3] << endl; } if (chk({ 1, 3, 6, 4 }, a, b)) { cout << dice[4] << endl; } if (chk({ 2, 4, 5, 3 }, a, b)) { cout << dice[5] << endl; } } return 0; }