結果
問題 |
No.1053 ゲーミング棒
|
ユーザー |
![]() |
提出日時 | 2020-05-15 21:26:48 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 692 bytes |
コンパイル時間 | 567 ms |
コンパイル使用メモリ | 59,772 KB |
最終ジャッジ日時 | 2025-01-10 11:13:32 |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 WA * 5 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:11:15: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | scanf ("%d", &N); | ~~~~~~^~~~~~~~~~ main.cpp:13:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 13 | scanf ("%d", &A[i]); | ~~~~~~^~~~~~~~~~~~~
ソースコード
#include <stdio.h> #include <algorithm> #include <vector> using namespace std; vector<int> wow[1001001]; int N, A[100100]; int main() { scanf ("%d", &N); for (int i = 0; i < N; i++){ scanf ("%d", &A[i]); wow[A[i]].push_back(i); } bool g = 1; int r = 0; for (int i = 1; i <= N; i++) if (!wow[i].empty()){ sort(wow[i].begin(), wow[i].end()); if (wow[i].size() == wow[i].back() - wow[i][0] + 1) continue; bool e = 0; for (int j = 1; j < wow[i].size(); j++){ if (wow[i].size() == (wow[i][j - 1] - wow[i][0] + 1) + (wow[i].back() - wow[i][j] + 1)) e = 1; } if (!e) g = 0; else r++; } if (!g || r > 1) puts("-1"); else if (r) puts("1"); else puts("0"); return 0; }