結果
問題 |
No.2779 Don't make Pair
|
ユーザー |
|
提出日時 | 2024-07-04 00:40:07 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 188 ms / 2,000 ms |
コード長 | 874 bytes |
コンパイル時間 | 3,331 ms |
コンパイル使用メモリ | 260,348 KB |
実行使用メモリ | 16,824 KB |
最終ジャッジ日時 | 2024-07-04 00:40:17 |
合計ジャッジ時間 | 7,615 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 24 |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; #ifdef LOCAL #include <algo/debug.h> #else #define debug(...) void(0) #endif int main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll N; cin >> N; vector<ll> A(N); for(int i = 0; i < N; i++) cin >> A[i]; map<ll, ll> MP1, MP2; for(int i = 0; i < N; i++) MP2[A[i]]++; set<ll> S1, S2; for(auto&&[a, b]: MP2) { if(b >= 2) { S2.emplace(a); } } vector<int> ans; for(int i = 0; i < N - 1; i++) { MP2[A[i]]--; MP1[A[i]]++; if(MP2[A[i]] <= 1) S2.erase(A[i]); if(MP1[A[i]] >= 2) S1.emplace(A[i]); if(S1.empty() && S2.empty()) { ans.push_back(i + 1); } } cout << int(ans.size()) << endl; for(auto&&a : ans) { cout << a << " "; }cout << endl; }