結果
| 問題 |
No.1053 ゲーミング棒
|
| コンテスト | |
| ユーザー |
root__786
|
| 提出日時 | 2020-05-22 14:01:58 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 43 ms / 2,000 ms |
| コード長 | 668 bytes |
| コンパイル時間 | 2,831 ms |
| コンパイル使用メモリ | 196,068 KB |
| 最終ジャッジ日時 | 2025-01-10 13:52:47 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 34 |
ソースコード
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
int n;
cin >> n;
long a[n];
for(int i=0;i<n;i++)cin >> a[i];
vector<int>b;
int ii=0;
while(ii<n){
int tmp = a[ii];
b.push_back(tmp);
while(a[ii] == tmp)ii++;
}
vector<bool>d(n+1,false);
int ans = 0;
for(int i=0;i<b.size();i++){
if(!d[b[i]]){
d[b[i]] = true;
}else{
if(!(i==b.size()-1 && b[i]==b[0])){
ans = -1;
break;
}else{
ans = 1;
}
}
}
cout << ans << endl;
}
root__786