結果
| 問題 |
No.1053 ゲーミング棒
|
| コンテスト | |
| ユーザー |
QCFium
|
| 提出日時 | 2020-04-18 15:58:06 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 663 bytes |
| コンパイル時間 | 1,594 ms |
| コンパイル使用メモリ | 168,784 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-19 09:11:37 |
| 合計ジャッジ時間 | 3,443 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 31 WA * 3 |
ソースコード
#include <bits/stdc++.h>
int ri() {
int n;
scanf("%d", &n);
return n;
}
int main() {
int n = ri();
int a[n];
for (auto &i : a) i = ri() - 1;
std::vector<int> compressed;
for (int i = 0; i < n; i++) if (!i || a[i - 1] != a[i]) compressed.push_back(a[i]);
bool possible = true;
int cnt[n];
memset(cnt, 0, sizeof(cnt));
std::vector<int> twos;
for (int i = 0; i < (int) compressed.size(); i++) {
if (++cnt[compressed[i]] >= 3) possible = false;
if (cnt[compressed[i]] == 2) twos.push_back(i);
}
for (auto i : twos) if (i && i + 1 < (int) compressed.size()) possible = false;
puts(possible ? twos.size() ? "1" : "0" : "-1");
return 0;
}
QCFium