結果

問題 No.1717 Levi-Civita Triangle
ユーザー SSRSSSRS
提出日時 2021-10-22 22:33:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,190 bytes
コンパイル時間 1,698 ms
コンパイル使用メモリ 170,560 KB
実行使用メモリ 5,008 KB
最終ジャッジ日時 2023-10-24 13:53:54
合計ジャッジ時間 3,725 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 5 ms
4,348 KB
testcase_07 AC 21 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 4 ms
4,348 KB
testcase_12 AC 13 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 WA -
testcase_17 AC 29 ms
4,676 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 4 ms
4,348 KB
testcase_22 AC 21 ms
4,348 KB
testcase_23 WA -
testcase_24 AC 2 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 WA -
testcase_27 AC 10 ms
4,348 KB
testcase_28 AC 2 ms
4,348 KB
testcase_29 AC 2 ms
4,348 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 30 ms
4,676 KB
testcase_33 WA -
testcase_34 AC 36 ms
4,940 KB
testcase_35 AC 36 ms
4,940 KB
testcase_36 AC 35 ms
4,940 KB
testcase_37 WA -
testcase_38 AC 36 ms
4,940 KB
testcase_39 WA -
testcase_40 AC 37 ms
4,940 KB
testcase_41 AC 36 ms
4,940 KB
testcase_42 AC 35 ms
4,940 KB
testcase_43 WA -
testcase_44 AC 36 ms
4,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
    }
  }
  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;
      }
    }
  }
}
0