結果
| 問題 |
No.230 Splarraay スプラレェーイ
|
| コンテスト | |
| ユーザー |
houren
|
| 提出日時 | 2022-09-14 23:11:33 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 132 ms / 5,000 ms |
| コード長 | 1,470 bytes |
| コンパイル時間 | 2,012 ms |
| コンパイル使用メモリ | 174,724 KB |
| 実行使用メモリ | 15,104 KB |
| 最終ジャッジ日時 | 2024-12-15 11:36:17 |
| 合計ジャッジ時間 | 4,288 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/lazysegtree>
using namespace atcoder;
using ll = long long;
using P = pair<ll,ll>;
#define fix(x) fixed << setprecision(x)
#define asc(x) x, vector<x>, greater<x>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
template<class T>bool chmin(T&a, const T&b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool chmax(T&a, const T&b){if(a<b){a=b;return 1;}return 0;}
struct S{
ll val;
int siz;
};
using F = ll;
const F ID = 8e18;
S op(S a, S b){ return {a.val+b.val, a.siz+b.siz}; }
S e(){ return {0, 0}; }
S mapping(F f, S x){
if(f != ID) x.val = f*x.siz;
return x;
}
F composition(F f, F g){ return (f == ID ? g : f); }
F id(){ return ID; }
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
int n,q;
cin >> n >> q;
vector<S> vec(n,{0,1});
lazy_segtree<S, op, e, F, mapping, composition, id> sega(vec), segb(vec);
ll a = 0, b = 0;
rep(i,q){
int x, l, r;
cin >> x >> l >> r;
r++;
if(x==0){
ll p = sega.prod(l, r).val, q = segb.prod(l, r).val;
if(p>q) a += p;
else if(p<q) b += q;
}else if(x==1){
sega.apply(l,r,1);
segb.apply(l,r,0);
}else{
sega.apply(l,r,0);
segb.apply(l,r,1);
}
}
cout << a+sega.all_prod().val << " " << b+segb.all_prod().val << '\n';
return 0;
}
houren