結果
問題 | No.2779 Don't make Pair |
ユーザー |
![]() |
提出日時 | 2024-06-07 22:00:19 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 103 ms / 2,000 ms |
コード長 | 1,106 bytes |
コンパイル時間 | 5,660 ms |
コンパイル使用メモリ | 266,684 KB |
実行使用メモリ | 6,872 KB |
最終ジャッジ日時 | 2024-12-26 08:01:27 |
合計ジャッジ時間 | 8,736 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 24 |
ソースコード
#include <bits/stdc++.h>#include <atcoder/all>using namespace std;using namespace atcoder;int op(int a, int b) {return max(a, b);}int e() {return 0;}int main() {int n;cin >> n;vector<int> a(n);for (int i = 0; i < n; i++) {cin >> a[i];}vector<int> v = a;sort(v.begin(), v.end());v.erase(unique(v.begin(), v.end()), v.end());int sz = v.size();segtree<int, op, e> seg1(sz), seg2(sz);for (int i = 0; i < n; i++) {int id = lower_bound(v.begin(), v.end(), a[i]) - v.begin();int now = seg2.get(id);seg2.set(id, now + 1);}vector<int> ans;for (int i = 0; i < n - 1; i++) {int id = lower_bound(v.begin(), v.end(), a[i]) - v.begin();int now1 = seg1.get(id);seg1.set(id, now1 + 1);int now2 = seg2.get(id);seg2.set(id, now2 - 1);if (seg1.all_prod() <= 1 && seg2.all_prod() <= 1) {ans.push_back(i + 1);}}cout << ans.size() << endl;for (int x : ans) {cout << x << " ";}cout << endl;}