Submission #989466

#TimeUsernameProblemLanguageResultExecution timeMemory
989466SunbaeMonkey and Apple-trees (IZhO12_apple)C++17
0 / 100
221 ms190536 KiB
#include <cstdio> const int N = 1e5 + 5, M = 1e9; int L, R, l[5979471], r[5979471], s[5979471], lz[5979471], 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 (stderr)

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 timeMemoryGrader output
Fetching results...