結果
問題 | No.2779 Don't make Pair |
ユーザー |
![]() |
提出日時 | 2024-06-27 00:26:50 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 209 ms / 2,000 ms |
コード長 | 856 bytes |
コンパイル時間 | 3,417 ms |
コンパイル使用メモリ | 257,100 KB |
実行使用メモリ | 8,832 KB |
最終ジャッジ日時 | 2024-06-27 00:26:58 |
合計ジャッジ時間 | 8,259 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 24 |
ソースコード
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #define _GLIBCXX_DEBUG #else #define Debug(...) void(0) #endif #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { int n; cin >> n; vector<int> a(n); rep(i, n) cin >> a[i]; map<int, int> left, right; rep(i, n) right[a[i]]++; int left_cnt = 0, right_cnt = 0; for (auto [k, v] : right) { if (v > 1) right_cnt++; } vector<int> ans(0); rep(i, n - 1) { int x = a[i]; right[x]--; if (right[x] == 1) right_cnt--; if (right[x] == 0) right.erase(x); left[x]++; if (left[x] == 2) left_cnt++; if (left_cnt == 0 && right_cnt == 0) ans.push_back(i + 1); } cout << ans.size() << endl; for (int x : ans) cout << x << ' '; cout << endl; return 0; }