結果
| 問題 |
No.3094 Stapler
|
| コンテスト | |
| ユーザー |
ripity
|
| 提出日時 | 2025-04-06 16:21:07 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 170 ms / 2,000 ms |
| コード長 | 1,051 bytes |
| コンパイル時間 | 3,679 ms |
| コンパイル使用メモリ | 257,816 KB |
| 実行使用メモリ | 32,804 KB |
| 最終ジャッジ日時 | 2025-10-23 22:22:21 |
| 合計ジャッジ時間 | 14,951 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 72 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll = long long;
using mint = modint1000000007;
// {min, cnt_min}
using S = array<int, 2>;
S op(S x, S y) {
if(x[0] < y[0]) return x;
if(x[0] > y[0]) return y;
return S{x[0], x[1] + y[1]};
}
S e() {
return S{INT_MAX, 0};
}
S mapping(int f, S x) {
return S{x[0] + f, x[1]};
}
int composition(int f, int g) {
return f + g;
}
int id() {
return 0;
}
int main() {
int N, Q;
cin >> N >> Q;
using query = array<int, 3>;
vector<query> qry(Q);
vector<S> _seg(N, S{0, 1});
lazy_segtree<S, op, e, int, mapping, composition, id> seg(_seg);
for(int i = 0; i < Q; i++) {
int t;
cin >> t;
if(t == 1) {
int l, r;
cin >> l >> r;
l--, r--;
seg.apply(l, r, 1);
qry[i][0] = t; qry[i][1] = l; qry[i][2] = r;
}else if(t == 2) {
int q, l, r;
cin >> q;
q--, l = qry[q][1], r = qry[q][2];
seg.apply(l, r, -1);
}else {
cout << seg.all_prod()[1] << "\n";
}
}
}
ripity