結果

問題 No.1717 Levi-Civita Triangle
ユーザー SenioriousSeniorious
提出日時 2022-10-29 15:52:13
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 19 ms / 2,000 ms
コード長 971 bytes
コンパイル時間 1,868 ms
コンパイル使用メモリ 198,464 KB
実行使用メモリ 5,228 KB
最終ジャッジ日時 2023-09-20 19:20:33
合計ジャッジ時間 3,859 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 4 ms
4,380 KB
testcase_07 AC 12 ms
4,456 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 3 ms
4,376 KB
testcase_12 AC 8 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 3 ms
4,376 KB
testcase_17 AC 14 ms
4,736 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 3 ms
4,376 KB
testcase_22 AC 11 ms
4,404 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 5 ms
4,380 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 15 ms
4,732 KB
testcase_33 AC 18 ms
5,100 KB
testcase_34 AC 18 ms
5,096 KB
testcase_35 AC 18 ms
5,104 KB
testcase_36 AC 18 ms
5,020 KB
testcase_37 AC 18 ms
5,228 KB
testcase_38 AC 18 ms
5,100 KB
testcase_39 AC 18 ms
5,032 KB
testcase_40 AC 18 ms
4,996 KB
testcase_41 AC 19 ms
5,068 KB
testcase_42 AC 19 ms
5,000 KB
testcase_43 AC 19 ms
5,048 KB
testcase_44 AC 19 ms
5,152 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define File(a) freopen(a ".in", "r", stdin), freopen(a ".out", "w", stdout)

const int N = 200005;

int f(int a, int b, int c);

int a[2][N];
int n;

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= 2 * n + 1; ++i) scanf("%d", a[0] + i);
  for (int i = 1; i <= 2 * n - 1; ++i) a[1][i] = f(a[0][i], a[0][i + 1], a[0][i + 2]);
  bool flag = true;
  for (int i = 1; i <= 2 * n - 1; ++i) {
    if (i & 1) {
      flag = flag && a[1][i];
      if (i > 2) flag = flag && (a[1][i] != a[1][i - 2]);
    } else {
      flag = flag && !a[1][i];
    }
  }
  if (flag)
    printf("%d\n", a[1][2 * n - 1]);
  else
    puts("0");
  return 0;
}

int f(int a, int b, int c) {
  if (a == 0 && b == 1 && c == 2) return 1;
  if (a == 1 && b == 2 && c == 0) return 1;
  if (a == 2 && b == 0 && c == 1) return 1;
  if (a == 2 && b == 1 && c == 0) return 2;
  if (a == 1 && b == 0 && c == 2) return 2;
  if (a == 0 && b == 2 && c == 1) return 2;
  return 0;
}
0