# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
817694 | Meloric | Monkey and Apple-trees (IZhO12_apple) | C++14 | 62 ms | 1032 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define pb push_back
#define int int64_t
#define pii pair<int, int>
#define X first
#define Y second
#define all(x) (x).begin(),(x).end()
#define lb lower_bound
#define ub upper_bound
using namespace std;
const int inf = 1e18;
void p(auto A){
for(auto e : A)cout << e << ' ';
cout << '\n';
}
const int MAXM = 100000, MAXN = 1e9+5;
array<int, MAXM*70> VAL, LC, RC;
int node = 0;
void upd(int& u, int tl, int tr, int l, int r){
if(tl > r || tr < l)return;
if(VAL[u])return;
if(!u)u=++node;
if(tl >= l && tr <= r)return VAL[u]=1, void();
int tm = (tl+tr)/2;
upd(LC[u], tl, tm, l, r);
upd(RC[u], tm+1, tr, l, r);
}
int qer(int u, int tl, int tr, int l, int r){
if(!u)return 0;
if(tl > r || tr < l)return 0;
if(VAL[u])return min(r, tr) - max(l, tl) + 1;
int tm = (tl+tr)/2;
return qer(LC[u], tl, tm, l, r) + qer(RC[u], tm+1, tr, l, r);
}
void solve(){
int m; cin >> m;
int C=0;
int root=0;
for(int i = 0; i< m; i++){
int d, x, y; cin >> d >> x >> y;
x+=C; y+=C;
if(d==1){
C=qer(root, 0, MAXN, x, y);
cout << C << '\n';
}else{
upd(root, 0, MAXN, x, y);
}
}
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t = 1;
//cin >> t;
while(t--)solve();
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |