# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1079752 | Bula | Monkey and Apple-trees (IZhO12_apple) | C++17 | 317 ms | 207948 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mod = 1e9 + 7, N = 1e9;
struct node{
node *lc, *rc;
int s = 0, lz = -1;
node() : s(0), lz(0), lc(nullptr), rc(nullptr){}
} *rt;
void push(node *&v, int l, int r){
if(v->lz == -1) return;
if(v->lc == nullptr) v->lc = new node();
if(v->rc == nullptr) v->rc = new node();
int m = (l + r) / 2;
v->lc->s = v->lz * (m - l + 1);
v->rc->s = v->lz * (r - m);
v->lc->lz = v->lz;
v->rc->lz = v->lz;
v->lz = -1;
}
void up(node *&v, int l, int r, int L, int R, int x){
if(l > R || r < L) return;
if(v == nullptr) v = new node();
if(L <= l && r <= R){
v->s = 1LL * (r - l + 1) * x;
v->lz = x;
return;
}
push(v, l, r);
int m = (l + r) / 2;
up(v->lc, l, m, L, R, x);
up(v->rc, m + 1, r, L, R, x);
v->s = v->lc->s + v->rc->s;
}
int get(node *&v, int l, int r, int L, int R){
if(r < L || l > R || v == nullptr) return 0LL;
if(L <= l && r <= R) return v->s;
push(v, l, r);
int m = (l + r) / 2;
return get(v->lc, l, m, L, R) + get(v->rc, m + 1, r, L, R);
}
main(){
ios::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
int tt = 1; //cin >> tt;
while(tt--){
int q;
cin >> q;
int c = 0;
while(q--){
int t, x , y;
cin >> t >> x >> y;
if(t == 1){
c = get(rt, 1, N, x + c, y + c);
cout << c << '\n';
}else{
up(rt, 1, N, x + c, y + c, 1);
}
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |