Submission #817694

# Submission time Handle Problem Language Result Execution time Memory
817694 2023-08-09T15:05:53 Z Meloric Monkey and Apple-trees (IZhO12_apple) C++14
100 / 100
62 ms 1032 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(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();
}


Compilation message

apple.cpp:15:8: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   15 | void p(auto A){
      |        ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 3 ms 468 KB Output is correct
5 Correct 4 ms 464 KB Output is correct
6 Correct 4 ms 468 KB Output is correct
7 Correct 4 ms 460 KB Output is correct
8 Correct 20 ms 740 KB Output is correct
9 Correct 30 ms 952 KB Output is correct
10 Correct 39 ms 964 KB Output is correct
11 Correct 32 ms 964 KB Output is correct
12 Correct 29 ms 864 KB Output is correct
13 Correct 38 ms 1020 KB Output is correct
14 Correct 62 ms 1032 KB Output is correct
15 Correct 29 ms 1008 KB Output is correct
16 Correct 46 ms 1032 KB Output is correct
17 Correct 40 ms 1016 KB Output is correct
18 Correct 39 ms 956 KB Output is correct
19 Correct 29 ms 972 KB Output is correct
20 Correct 29 ms 992 KB Output is correct