Submission #526254

# Submission time Handle Problem Language Result Execution time Memory
526254 2022-02-14T05:09:12 Z tmn2005 Monkey and Apple-trees (IZhO12_apple) C++17
0 / 100
1 ms 332 KB
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

#define ar array
#define fr first
#define sc second

#define vec vector
#define ret return

#define ins insert
#define mk make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front

#define int long long

#define pii pair<int,int>

#define all(s) s.begin(), s.end()
#define allr(s) s.rbegin(), s.rend()

#define NeedForSpeed ios::sync_with_stdio(0),cin.tie(0);
const int N = 2e6+12,INF = 1e9,mod = 1e9+7;
const int dx[4] = {1, 0,-1, 0}, dy[4] = {0, 1, 0,-1};
bool iswowel(char n){ n = toupper(n); if(n == 'A' || n == 'O' || n == 'U' || n == 'E' || n == 'I') return true; else return false;}
int n, m, k, x, y, l, r, o, ans, res, ok, mx, mn = INF;
int a, b, c;
int t[N<<1], lz[N<<1];

void push(int v, int d){
	if(!lz[v])ret;
	
	t[v] = d;
	if(d > 1){
		lz[v*2] = 1;
		lz[v*2+1] = 1;
	}
	lz[v] = 0;
}
int get(int v, int l, int r, int ql, int qr){
	if(r < ql || qr < l)
		ret 0;
	if(ql <= l && r <= qr)
		ret t[v];
	int m = l + r >> 1;
	ret(get(v*2, l, m, ql, qr) + get(v*2+1, m+1, r, ql, qr));
}
void update(int v, int l, int r, int ql, int qr){
	push(v, r - l + 1);
	if(r < ql || qr < l)
		ret;
	if(ql <= l && r <= qr){
		lz[v] = 1;
		push(v, r - l + 1);
		ret;
	}
	int m = l + r >> 1;
	update(v*2, l, m, ql, qr);
	update(v*2+1, m+1, r, ql, qr);
	t[v] = t[v*2] + t[v*2+1];
}
main(){
	NeedForSpeed
    cin>>n;
    for(int i=1; i<=n; i++){
    	cin>>o>>l>>r;
    	if(o == 1){
    		int tmp = get(1, 1, 1e6, l+c, r+c);
    		cout<<tmp<<"\n";
    		c = tmp;
		}
		else{
			update(1, 1, 1e6, l+c, r+c);
		}
	}




	return 0;
}




Compilation message

apple.cpp: In function 'long long int get(long long int, long long int, long long int, long long int, long long int)':
apple.cpp:50:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   50 |  int m = l + r >> 1;
      |          ~~^~~
apple.cpp: In function 'void update(long long int, long long int, long long int, long long int, long long int)':
apple.cpp:62:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   62 |  int m = l + r >> 1;
      |          ~~^~~
apple.cpp: At global scope:
apple.cpp:67:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   67 | main(){
      | ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -