Submission #989469

# Submission time Handle Problem Language Result Execution time Memory
989469 2024-05-28T08:25:29 Z Sunbae Monkey and Apple-trees (IZhO12_apple) C++17
0 / 100
220 ms 191052 KB
#include <cstdio>
const int N = 1e5 + 5, M = 1e9;
int L, R, l[6000000], r[6000000], s[6000000], lz[6000000], ALLOC = 2;
void pg(int ind, int low, int high){
	if(low != high){
		if(!l[ind]) l[ind] = ALLOC++; if(!r[ind]) r[ind] = ALLOC++; 
		lz[l[ind]] = lz[r[ind]] = lz[ind];
	}
	lz[ind] = 0;
}
void upd(int ind, int low, int high){
	if(lz[ind]){s[ind] = high-low+1; pg(ind, low, high); }
	if(low > R || high < L) return;
	if(L <= low && high <= R){s[ind] = high-low+1; lz[ind] = true; pg(ind, low, high); return;}
	if(!l[ind]) l[ind] = ALLOC++; if(!r[ind]) r[ind] = ALLOC++; 
	int mid = low + ((high-low)>>1);
	upd(l[ind], low, mid); upd(r[ind], mid+1, high);
	s[ind] = ((l[ind])? s[l[ind]] : 0) + ((r[ind])? s[r[ind]] : 0);
}
int qry(int ind, int low, int high){
	if(lz[ind]){s[ind] = high-low+1; pg(ind, low, high);}
	if(low > R || high < L) return 0;
	if(L <= low && high <= R) return s[ind];
	int mid = low + ((high-low)>>1);
	return ((l[ind])? qry(l[ind], low, mid) : 0) + ((r[ind])? qry(r[ind], mid+1, high) : 0);
}
signed main(){
	int m, c = 0, d; scanf("%d", &m);
	while(m--){
		scanf("%d %d %d", &d, &L, &R); L += c; R += c;
		if(d == 1) printf("%d\n", c = qry(1, 1, M));
		else upd(1, 1, M);
	}
}

Compilation message

apple.cpp: In function 'void pg(int, int, int)':
apple.cpp:6:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
    6 |   if(!l[ind]) l[ind] = ALLOC++; if(!r[ind]) r[ind] = ALLOC++;
      |   ^~
apple.cpp:6:33: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
    6 |   if(!l[ind]) l[ind] = ALLOC++; if(!r[ind]) r[ind] = ALLOC++;
      |                                 ^~
apple.cpp: In function 'void upd(int, int, int)':
apple.cpp:15:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   15 |  if(!l[ind]) l[ind] = ALLOC++; if(!r[ind]) r[ind] = ALLOC++;
      |  ^~
apple.cpp:15:32: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   15 |  if(!l[ind]) l[ind] = ALLOC++; if(!r[ind]) r[ind] = ALLOC++;
      |                                ^~
apple.cpp: In function 'int main()':
apple.cpp:28:24: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |  int m, c = 0, d; scanf("%d", &m);
      |                   ~~~~~^~~~~~~~~~
apple.cpp:30:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |   scanf("%d %d %d", &d, &L, &R); L += c; R += c;
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 0 ms 2392 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 8 ms 4956 KB Output is correct
5 Correct 9 ms 5468 KB Output is correct
6 Correct 9 ms 5468 KB Output is correct
7 Correct 10 ms 5468 KB Output is correct
8 Correct 66 ms 27716 KB Output is correct
9 Correct 155 ms 45908 KB Output is correct
10 Correct 157 ms 51308 KB Output is correct
11 Correct 190 ms 55376 KB Output is correct
12 Correct 167 ms 55412 KB Output is correct
13 Correct 142 ms 68880 KB Output is correct
14 Correct 150 ms 69516 KB Output is correct
15 Runtime error 220 ms 191052 KB Execution killed with signal 11
16 Halted 0 ms 0 KB -