結果
問題 |
No.1053 ゲーミング棒
|
ユーザー |
![]() |
提出日時 | 2020-05-15 23:09:12 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 968 bytes |
コンパイル時間 | 1,263 ms |
コンパイル使用メモリ | 159,824 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-19 13:09:55 |
合計ジャッジ時間 | 2,719 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 WA * 2 |
ソースコード
/** * @FileName f.cpp * @Author kanpurin * @Created 2020.05.15 23:09:04 **/ #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; } } for (int i = ok; i < n; i++) { if (a[i] != a[i-1] && 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 { cout << 0 << endl; } return 0; }