結果
問題 | No.1053 ゲーミング棒 |
ユーザー |
|
提出日時 | 2020-05-15 21:29:07 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 102 ms / 2,000 ms |
コード長 | 499 bytes |
コンパイル時間 | 2,250 ms |
コンパイル使用メモリ | 199,452 KB |
最終ジャッジ日時 | 2025-01-10 11:15:30 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:17:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 17 | int n; scanf("%d",&n); | ~~~~~^~~~~~~~~ main.cpp:19:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 19 | rep(i,n) scanf("%d",&a[i]); | ~~~~~^~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; bool check(vector<int> a){ set<int> S; rep(i,a.size()){ if(S.count(a[i])>0) return false; S.emplace(a[i]); } return true; } int main(){ int n; scanf("%d",&n); vector<int> a(n); rep(i,n) scanf("%d",&a[i]); a.erase(unique(a.begin(),a.end()),a.end()); if(check(a)){ puts("0"); } else if(a.front()==a.back()){ a.pop_back(); puts(check(a)?"1":"-1"); } else{ puts("-1"); } return 0; }