結果
問題 |
No.2779 Don't make Pair
|
ユーザー |
![]() |
提出日時 | 2024-06-08 13:06:49 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 111 ms / 2,000 ms |
コード長 | 866 bytes |
コンパイル時間 | 2,056 ms |
コンパイル使用メモリ | 203,864 KB |
最終ジャッジ日時 | 2025-02-21 20:52:25 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 24 |
ソースコード
#include <bits/stdc++.h> using namespace std; void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); } int main() { fast_io(); int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } vector<bool> ok_l(n), ok_r(n); set<int> st; for (int i = 0; i < n; i++) { st.insert(a[i]); if (st.size() == i + 1) { ok_l[i] = true; } } st.clear(); for (int i = n - 1; i >= 0; i--) { st.insert(a[i]); if (st.size() == n - i) { ok_r[i] = true; } } vector<int> ans; for (int i = 0; i < n - 1; i++) { if (ok_l[i] && ok_r[i + 1]) { ans.push_back(i + 1); } } cout << ans.size() << endl; for (int i : ans) { cout << i << " "; } cout << endl; }