結果
| 問題 |
No.1053 ゲーミング棒
|
| コンテスト | |
| ユーザー |
m4c_physics99
|
| 提出日時 | 2020-05-15 22:16:57 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 900 bytes |
| コンパイル時間 | 1,750 ms |
| コンパイル使用メモリ | 169,780 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-19 10:57:55 |
| 合計ジャッジ時間 | 3,173 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 32 WA * 2 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
int visited[110000];
int main()
{
int n;cin >>n ;
int a[n+1];
rep(i,n)cin >> a[i];
vector<int> c;
int now = a[0];
rep(i,n-1){
if(a[i+1] != now){
c.push_back(now);
now = a[i+1];
}
}
c.push_back(now);
bool ok = true;
int m = c.size();
if(m == 1){
cout << 0 << endl;
return 0;
}
int flag = 0;
for(auto p:c){
if(visited[p]){
if(c[0] != c[m-1]){
ok = false;
}
flag = 1;
}
visited[p] = 1;
}
if(ok){
if(flag)cout << 1 << endl;
else cout << 0 << endl;
}
else{
cout << -1 << endl;
}
return 0;
}
m4c_physics99