結果

問題 No.1053 ゲーミング棒
ユーザー わなわな
提出日時 2020-05-16 03:39:57
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 828 bytes
コンパイル時間 628 ms
コンパイル使用メモリ 73,012 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-19 19:48:43
合計ジャッジ時間 1,996 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21 WA * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    long long N;
    cin >> N;
    vector<long long> a(N);
    for(int i = 0; i < N; i++){
        cin >>  a[i];
        a[i]--;
    }
    vector<int> used(N, 0);
    used[a[0]] = 1;
    int cnt = 1;
    for(int i = 1; i < N; i++){
        if(a[i] != a[i - 1] && used[a[i]] == 1 && i != N - 1){
            cout << -1 << endl;
            return 0;
        }
        else if(used[a[i]] == 1 && i == N - 1 && a[0] != a[i]){
            cout << -1 << endl;
            return 0;
        }
        else if(a[i] != a[i - 1] && used[a[i]] == 0) {
            cnt++;
            used[a[i]] = 1;
        }
    }
    if(cnt == N){
        cout << 0 << endl;
        return 0;
    }
    else{
        cout << 1 << endl;
        return 0;
    }
}
0