結果
問題 | No.1717 Levi-Civita Triangle |
ユーザー |
![]() |
提出日時 | 2021-10-22 22:40:15 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 42 ms / 2,000 ms |
コード長 | 1,421 bytes |
コンパイル時間 | 1,585 ms |
コンパイル使用メモリ | 173,272 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-23 06:21:50 |
合計ジャッジ時間 | 3,486 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 42 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ int N; cin >> N; vector<int> A(N * 2 + 1); for (int i = 0; i <= N * 2; i++){ cin >> A[i]; } bool ok = false; for (int i = 0; i <= N * 2 - 1; i++){ if (A[i] == A[i + 1]){ ok = true; } } for (int i = 0; i <= N * 2 - 3; i++){ int x = (A[i + 1] - A[i] + 3) % 3; int y = (A[i + 2] - A[i + 1] + 3) % 3; int z = (A[i + 3] - A[i + 2] + 3) % 3; if (x == y && y == z){ ok = true; } } for (int i = 0; i <= N * 2 - 3; i++){ vector<bool> used(3, false); for (int j = 0; j < 4; j++){ used[A[i + j]] = true; } for (int j = 0; j < 3; j++){ if (!used[j]){ ok = true; } } } if (ok){ cout << 0 << endl; } else { for (int i = 0; i < 3; i++){ vector<int> B(N * 2 + 1); for (int j = 0; j <= N * 2; j++){ B[j] = (A[j] + i) % 3; } bool ok2 = true; for (int j = 0; j < N * 2; j++){ if (abs(B[j + 1] - B[j]) >= 2){ ok2 = false; } } if (ok2){ swap(A, B); break; } } if (A[0] == 1){ cout << 0 << endl; } else if (A[0] == 0){ if (N % 2 == 1){ cout << 1 << endl; } else { cout << 2 << endl; } } else { if (N % 2 == 0){ cout << 1 << endl; } else { cout << 2 << endl; } } } }