Submission #817691

# Submission time Handle Problem Language Result Execution time Memory
817691 2023-08-09T15:04:38 Z Meloric Monkey and Apple-trees (IZhO12_apple) C++14
100 / 100
45 ms 2980 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 r - l + 1;
	int tm = (tl+tr)/2;
	return qer(LC[u], tl, tm, l, min(r, tm)) + qer(RC[u], tm+1, tr, max(l, tm+1), 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 324 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 468 KB Output is correct
6 Correct 4 ms 456 KB Output is correct
7 Correct 4 ms 468 KB Output is correct
8 Correct 15 ms 1336 KB Output is correct
9 Correct 29 ms 2348 KB Output is correct
10 Correct 34 ms 2400 KB Output is correct
11 Correct 29 ms 2396 KB Output is correct
12 Correct 32 ms 2532 KB Output is correct
13 Correct 38 ms 2772 KB Output is correct
14 Correct 37 ms 2892 KB Output is correct
15 Correct 29 ms 2888 KB Output is correct
16 Correct 29 ms 2980 KB Output is correct
17 Correct 38 ms 2792 KB Output is correct
18 Correct 45 ms 2888 KB Output is correct
19 Correct 31 ms 2936 KB Output is correct
20 Correct 31 ms 2916 KB Output is correct