結果

問題 No.1717 Levi-Civita Triangle
ユーザー SSRSSSRS
提出日時 2021-10-22 22:35:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,441 bytes
コンパイル時間 1,493 ms
コンパイル使用メモリ 171,348 KB
実行使用メモリ 4,468 KB
最終ジャッジ日時 2023-10-24 13:56:21
合計ジャッジ時間 6,924 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 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 24 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 5 ms
4,348 KB
testcase_12 AC 15 ms
4,348 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 RE -
testcase_43 RE -
testcase_44 RE -
権限があれば一括ダウンロードができます

ソースコード

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;
    }
  }
  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 {
    assert(false);
    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