結果
| 問題 |
No.1053 ゲーミング棒
|
| コンテスト | |
| ユーザー |
🍮かんプリン
|
| 提出日時 | 2020-05-15 23:34:25 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 27 ms / 2,000 ms |
| コード長 | 1,062 bytes |
| コンパイル時間 | 2,017 ms |
| コンパイル使用メモリ | 159,856 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-19 13:55:10 |
| 合計ジャッジ時間 | 2,511 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 34 |
ソースコード
/**
* @FileName f.cpp
* @Author kanpurin
* @Created 2020.05.15 23:34:07
**/
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int main() {
int n;
cin >> n;
vector< int > a(n);
vector< int > used(n, -1);
bool same = true;
for (int i = 0; i < n; i++) {
cin >> a[i];
if (i > 0 && a[0] != a[i]) {
same = false;
}
}
if (same) {
cout << 0 << endl;
return 0;
}
int ok = -1;
for (int i = 1; i < n; i++) {
if (ok == -1 && a[i] != a[0]) {
ok = i;
break;
}
}
used[a[0]-1] = 1;
for (int i = ok; i < n; i++) {
if (a[i] != a[i-1] && abs(used[a[i]-1]) == 1) {
used[a[i]-1] = 0;
}
else if (a[i] != a[i-1]) {
puts("-1");
return 0;
}
}
if (a[0] == a[a.size()-1]) {
cout << 1 << endl;
}
else if (used[a[0]-1] == 0) {
cout << -1 << endl;
}
else {
cout << 0 << endl;
}
return 0;
}
🍮かんプリン