# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
963732 | ByeWorld | 원숭이와 사과 나무 (IZhO12_apple) | C++14 | 535 ms | 207808 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <random>
#define ll long long
// #define int long long
#define fi first
#define se second
#define pb push_back
#define md ((l+r)>>1)
#define lf (id<<1)
#define rg ((id<<1)|1)
#define ld long double
using namespace std;
typedef pair<int,int> pii;
typedef pair<pii,pii> ipii;
const int MAXN = 3e5+10;
const int MAXA = 1e6+10;
const int INF = 1e9;
const int LOG = 30;
const int MOD = 1e9+7;
int n;
struct node {
int val, laz, l, r;
node *le, *ri;
void bd(int l2, int r2){
val = 0; laz = 0;
l = l2; r = r2;
if(l==r) return;
le = NULL; ri = NULL;
}
void bnc(){
if(le==NULL){
le = new node();
le->l = l; le->r = md;
le->bd(l, md);
}
if(ri==NULL){
ri = new node();
ri->l = md+1; ri->r = r;
ri->bd(md+1, r);
}
if(laz == 0) return;
le->val = (le->r-le->l+1) * laz; le->laz |= laz;
ri->val = (ri->r-ri->l+1) * laz; ri->laz |= laz;
laz = 0;
}
int que(int x, int y){
if(x<=l && r<=y) return val;
if(r<x || y<l) return 0;
bnc();
return le->que(x, y) + ri->que(x, y);
}
int upd(int x, int y, int p){
if(x<=l && r<=y){
laz |= p;
return val = (r-l+1) * p;
}
if(r<x || y<l) return val;
bnc();
return val = le->upd(x, y, 1) + ri->upd(x, y, 1);
}
} A;
signed main() {
// ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin >> n;
A.bd(1, INF); int c = 0;
for(int i=1; i<=n; i++){
int ty, x, y; cin >> ty >> x >> y;
x += c; y += c;
if(ty==2) A.upd(x, y, 1);
else {
int ans = A.que(x, y);
cout << ans << '\n';
c = ans;
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |