답안 #817667

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
817667 2023-08-09T14:52:52 Z Meloric 원숭이와 사과 나무 (IZhO12_apple) C++14
0 / 100
1 ms 340 KB
#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(VAL[u])return min(tr, r) - max(tl, l) + 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();
}


Compilation message

apple.cpp:15:8: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   15 | void p(auto A){
      |        ^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -