結果

問題 No.1053 ゲーミング棒
ユーザー motmot
提出日時 2020-05-15 21:47:44
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 84 ms / 2,000 ms
コード長 1,395 bytes
コンパイル時間 1,997 ms
コンパイル使用メモリ 93,636 KB
実行使用メモリ 8,632 KB
最終ジャッジ日時 2023-10-19 13:12:36
合計ジャッジ時間 3,182 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=3.14159265359;

int main() {
    int N;
    cin>>N;
    vector<int> A(N);
    for(int i=0;i<N;++i){
        cin>>A[i];
    }
    map<int, int> amap;
    int now = A[0];
    amap[now]++;
    bool ok = true;
    vector<int> arr;
    arr.push_back(now);
    for(int i=1;i<N;++i){
        if(now!=A[i]){
            if(amap[A[i]]>0){
                now = A[i];
                for(int j=i;j<N;++j){
                    if(A[j]!=now){
                        ok = false;
                    }
                }
                if(A[N-1]!=A[0]){
                    ok = false;
                }
                break;
            }
            else{
                arr.push_back(A[i]);
                now = A[i];
                amap[A[i]]++;
            }
        }
        else amap[A[i]]++;
    }
    if(ok){
        if(arr.size()==1) cout<<0<<endl;
        else if(A[0]==A[N-1]) cout<<1<<endl;
        else cout<<0<<endl;
    }
    else cout<<-1<<endl;
}

0