結果

問題 No.1053 ゲーミング棒
ユーザー rokahikou1rokahikou1
提出日時 2020-05-15 22:49:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,346 bytes
コンパイル時間 961 ms
コンパイル使用メモリ 104,736 KB
実行使用メモリ 8,708 KB
最終ジャッジ日時 2023-10-19 15:58:10
合計ジャッジ時間 3,042 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 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 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 55 ms
8,708 KB
testcase_24 AC 69 ms
8,708 KB
testcase_25 AC 67 ms
8,708 KB
testcase_26 AC 72 ms
8,708 KB
testcase_27 AC 2 ms
4,348 KB
testcase_28 AC 2 ms
4,348 KB
testcase_29 AC 2 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 WA -
testcase_34 WA -
testcase_35 AC 23 ms
4,348 KB
testcase_36 AC 24 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    vector<int> B;
    int now = -1;
    rep(i, N) {
        if(now != A[i])
            B.pb(A[i]);
        now = A[i];
    }
    map<int, int> mp;
    rep(i, B.size()) { mp[B[i]]++; }
    int ok = 2;
    int cnt = 0;
    for(auto x : mp) {
        if(x.second > 1) {
            if(cnt == 0) {
                ok = 1;
            } else {
                ok = 0;
            }
            cnt++;
        }
    }

    if(ok == 2) {
        cout << 0 << endl;
        return 0;
    }

    if(ok == 1) {
        if(B.front() != B.back())
            ok = 0;
    }
    if(ok) {
        cout << 1 << endl;
    } else {
        cout << -1 << endl;
    }
    return 0;
}
0