結果

問題 No.1053 ゲーミング棒
ユーザー i_mrhji_mrhj
提出日時 2020-05-15 22:00:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,448 bytes
コンパイル時間 899 ms
コンパイル使用メモリ 100,740 KB
実行使用メモリ 9,456 KB
最終ジャッジ日時 2023-10-19 14:18:26
合計ジャッジ時間 2,452 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 1 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 1 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 WA -
testcase_12 WA -
testcase_13 AC 1 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 1 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 40 ms
9,456 KB
testcase_24 AC 42 ms
9,456 KB
testcase_25 AC 43 ms
9,456 KB
testcase_26 AC 43 ms
9,456 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 19 ms
5,892 KB
testcase_31 AC 20 ms
6,688 KB
testcase_32 AC 19 ms
5,892 KB
testcase_33 AC 20 ms
6,688 KB
testcase_34 AC 20 ms
6,688 KB
testcase_35 AC 26 ms
6,816 KB
testcase_36 AC 27 ms
6,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <complex>

#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;


ll powMod(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll t = powMod(x, n/2, mod);
  t = t * t % mod;
  if (n & 1) return t * x % mod;
  return t;
}

ll gcd(ll a, ll b) {
  if (a == 0 || b == 0) return a + b;
  if (b > a) return gcd(b, a);
  return gcd(b, a % b);
}




int main(void) {

  int n, a[100100];
  cin >> n;
  rep(i, n) cin >> a[i];


  vector< vector<int> > v(n + 1);

  vector<int> b;
  int k = a[0];
  int j = 0;
  while (a[j] == a[0]) j++;
  for (int i = j; i < n; i++) b.push_back(a[i]);

  if (j == n) {
    cout << 0 << endl;
    return 0;
  }

  rep(i, b.size()) v[b[i]].push_back(i);

  bool f = true;
  rep(i, n) {
    if (v[i].size() > 1) {
      rep(j, v[i].size()-1) {
	if (v[i][j+1]-v[i][j] > 1) f = false;
	if (!f) break;
      }
    }
    if (!f) break;
  }

  if (!f) cout << -1 << endl;
  else {
    if (a[0] == a[n-1]) cout << 1 << endl;
    else cout << 0 << endl;
  }

  return 0;

}
0