結果

問題 No.1053 ゲーミング棒
ユーザー 山下山下
提出日時 2020-05-15 22:11:08
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 928 bytes
コンパイル時間 1,727 ms
コンパイル使用メモリ 172,180 KB
実行使用メモリ 4,408 KB
最終ジャッジ日時 2023-10-19 14:37:35
合計ジャッジ時間 3,312 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
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 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 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 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 31 ms
4,408 KB
testcase_24 AC 31 ms
4,408 KB
testcase_25 AC 30 ms
4,408 KB
testcase_26 AC 31 ms
4,408 KB
testcase_27 AC 2 ms
4,348 KB
testcase_28 AC 2 ms
4,348 KB
testcase_29 AC 1 ms
4,348 KB
testcase_30 AC 17 ms
4,348 KB
testcase_31 AC 17 ms
4,348 KB
testcase_32 AC 17 ms
4,348 KB
testcase_33 AC 17 ms
4,348 KB
testcase_34 AC 17 ms
4,348 KB
testcase_35 AC 23 ms
4,348 KB
testcase_36 AC 23 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod = 1000000007;

ll r(ll x, ll y) {
  if (y == 0) return 1;
  else if (y % 2 == 0) return r(x, y/2) * r(x, y/2) % mod;
  else return x * r(x, (y-1)/2) % mod * r(x, (y-1)/2) % mod;
}

int main() {
  ll n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<int> b(1);
  b[0] = a[0];
  for (int i = 1; i < n; i++) {
    if (b.back() != a[i]) b.push_back(a[i]);
  }
  int m = b.size();
  bool FF = 1;
  if (b[0] == b[m-1]) {
    m--;
    FF = 0;
  }
  int now = 10000000;
  bool F = 1;
  vector<bool> f(n, 0);
  for (int i = 0; i < m; i++) {
    if (now != b[i]) {
      now = b[i];
      if (f[now]) {
        F = 0;
        break;
      } 
      f[now] = 1;
    }
  }
  if (F&&!FF && m != 0) cout << 1 <<endl;
  else if (F&&!FF && m == 0) cout << 0 <<endl;
  else if (F&&FF) cout << 0 <<endl;
  else cout << -1 <<endl;
}
0