結果
| 問題 |
No.1053 ゲーミング棒
|
| コンテスト | |
| ユーザー |
risujiroh
|
| 提出日時 | 2020-05-15 21:31:29 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 82 ms / 2,000 ms |
| コード長 | 799 bytes |
| コンパイル時間 | 2,853 ms |
| コンパイル使用メモリ | 201,060 KB |
| 最終ジャッジ日時 | 2025-01-10 11:17:28 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 34 |
ソースコード
#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 and v[0].first == v[t].first) {
cout << "1\n";
exit(0);
} else {
cout << "-1\n";
exit(0);
}
}
se.insert(v[t].first);
}
cout << "0\n";
}
risujiroh