結果
| 問題 |
No.1053 ゲーミング棒
|
| コンテスト | |
| ユーザー |
risujiroh
|
| 提出日時 | 2020-05-15 21:28:10 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 770 bytes |
| コンパイル時間 | 2,306 ms |
| コンパイル使用メモリ | 200,936 KB |
| 最終ジャッジ日時 | 2025-01-10 11:14:22 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 31 WA * 3 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif
template <class S> auto rle(const S& s) {
vector<decltype(make_pair(s[0], 1))> res;
for (auto c : s)
if (empty(res) or res.back().first != c) res.emplace_back(c, 1);
else ++res.back().second;
return res;
}
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int n;
cin >> n;
vector<int> a(n);
for (auto&& e : a) cin >> e;
auto v = rle(a);
set<int> se;
int m = size(v);
for (int t = 0; t < m; ++t) {
if (se.count(v[t].first)) {
if (t == m - 1) {
cout << "1\n";
exit(0);
} else {
cout << "-1\n";
exit(0);
}
}
se.insert(v[t].first);
}
cout << "0\n";
}
risujiroh