結果
| 問題 |
No.2809 Sort Query
|
| コンテスト | |
| ユーザー |
Jikky1618
|
| 提出日時 | 2025-02-04 18:40:06 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,397 bytes |
| コンパイル時間 | 6,270 ms |
| コンパイル使用メモリ | 325,020 KB |
| 実行使用メモリ | 18,560 KB |
| 最終ジャッジ日時 | 2025-02-04 18:40:46 |
| 合計ジャッジ時間 | 34,374 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 2 WA * 64 RE * 5 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef LOCAL
#include <debug.hpp>
#else
#define debug(...)
#endif
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using k_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
cout << fixed << setprecision(20);
int N, Q;
cin >> N >> Q;
vector<int> A(N);
for (int i = 0; i < N; i++) cin >> A[i];
k_set not_sort;
for (int i = 0; i < N; i++) not_sort.insert(i);
k_set st;
while (Q--) {
int type;
cin >> type;
if (type == 1) {
int k, x;
cin >> k >> x, k--;
st.erase(A[k]);
A[k] = x;
not_sort.insert(k);
}
if (type == 2) {
// sort
for (int i : not_sort) st.insert(A[i]);
not_sort.clear();
}
if (type == 3) {
int k;
cin >> k, k--;
if (not_sort.find(k) != not_sort.end()) {
cout << A[k] << '\n';
} else {
// [0, k) にあるソートされていない要素数
int cnt = not_sort.order_of_key(k);
cout << *st.find_by_order(k - cnt) << '\n';
}
}
}
}
Jikky1618