結果
問題 | No.2779 Don't make Pair |
ユーザー |
|
提出日時 | 2024-07-06 06:14:12 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 760 bytes |
コンパイル時間 | 1,855 ms |
コンパイル使用メモリ | 176,536 KB |
実行使用メモリ | 14,464 KB |
最終ジャッジ日時 | 2024-07-06 06:14:17 |
合計ジャッジ時間 | 4,971 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 WA * 2 |
other | AC * 14 WA * 10 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)n; i++) int main() { int N; cin >> N; map<int, vector<int>> mp; rep(i, N) { int Ai; cin >> Ai; mp[Ai].push_back(i); } int l = -1, r = N; for (auto it = mp.begin(); it != mp.end(); it++) { if ((it->second).size() > 2) { l = N, r = -1; } if ((it->second).size() == 2) { l = max((it->second)[0], l); r = min((it->second)[1], r); } } if (l > r) { cout << 0 << endl; } else if (l < 0) { cout << N-1 << endl; rep(i, N-1) cout << i+1 << " "; cout << endl; } else { cout << r - l << endl; for (int i = l; i < r; i++) cout << i+1 << " "; cout << endl; } return 0; }