結果

問題 No.1053 ゲーミング棒
ユーザー RhoRho
提出日時 2020-05-15 21:48:01
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 82 ms / 2,000 ms
コード長 562 bytes
コンパイル時間 2,259 ms
コンパイル使用メモリ 174,912 KB
実行使用メモリ 12,024 KB
最終ジャッジ日時 2023-10-19 13:15:07
合計ジャッジ時間 3,327 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,432 KB
testcase_01 AC 3 ms
6,432 KB
testcase_02 AC 3 ms
6,432 KB
testcase_03 AC 3 ms
6,436 KB
testcase_04 AC 3 ms
6,432 KB
testcase_05 AC 3 ms
6,432 KB
testcase_06 AC 3 ms
6,432 KB
testcase_07 AC 3 ms
6,432 KB
testcase_08 AC 3 ms
6,432 KB
testcase_09 AC 3 ms
6,432 KB
testcase_10 AC 3 ms
6,432 KB
testcase_11 AC 3 ms
6,436 KB
testcase_12 AC 3 ms
6,436 KB
testcase_13 AC 3 ms
6,432 KB
testcase_14 AC 3 ms
6,432 KB
testcase_15 AC 3 ms
6,432 KB
testcase_16 AC 3 ms
6,432 KB
testcase_17 AC 3 ms
6,432 KB
testcase_18 AC 3 ms
6,432 KB
testcase_19 AC 3 ms
6,432 KB
testcase_20 AC 3 ms
6,432 KB
testcase_21 AC 3 ms
6,432 KB
testcase_22 AC 3 ms
6,432 KB
testcase_23 AC 69 ms
12,024 KB
testcase_24 AC 82 ms
12,024 KB
testcase_25 AC 82 ms
12,024 KB
testcase_26 AC 82 ms
12,024 KB
testcase_27 AC 3 ms
6,368 KB
testcase_28 AC 3 ms
6,432 KB
testcase_29 AC 3 ms
6,368 KB
testcase_30 AC 18 ms
6,776 KB
testcase_31 AC 18 ms
6,840 KB
testcase_32 AC 18 ms
6,840 KB
testcase_33 AC 18 ms
6,840 KB
testcase_34 AC 17 ms
6,840 KB
testcase_35 AC 24 ms
6,840 KB
testcase_36 AC 24 ms
6,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
int a[100006];
vector<int>G[100006];
signed main(){
    int n;cin>>n;
    rep(i,n)cin>>a[i];
    vector<int>v;
    int now=a[0];
    rep(i,n+1){
        if(now!=a[i]){
            v.push_back(now);
            now=a[i];
        }
    }
    set<int>S;
    int flg=0;
    for(int e:v){
        if(S.find(e)!=S.end())flg++;
        S.insert(e);
    }
    if(flg>1)flg=-1;
    else if(flg==1){
        if(v[0]!=v[v.size()-1])flg=-1;
    }
    cout<<flg<<endl;
}
0