Submission #987124

#TimeUsernameProblemLanguageResultExecution timeMemory
987124SunbaeMonkey and Apple-trees (IZhO12_apple)C++17
0 / 100
427 ms262144 KiB
#include <bits/stdc++.h> using namespace std; struct Vertex{ Vertex *l = nullptr, *r = nullptr; int low, high, sum = 0; bool op = false; Vertex(int L, int R){low = L; high = R;} ~Vertex(){if(l) delete l; if(r) delete r;} void propagate(){ if(low != high){ int mid = low + ((high-low)>>1); if(!l) l = new Vertex(low, mid); if(!r) r = new Vertex(mid+1, high); l->op = r->op = true; } op = false; } void upd(int L, int R){ if(op){sum = (high-low+1); propagate();} if(low > R || high < L) return; if(L <= low && high <= R){ sum = high-low+1; op = true; propagate(); return; } int mid = low + ((high-low)>>1); if(!l) l = new Vertex(low, mid); if(!r) r = new Vertex(mid+1, high); l->upd(L, R); r->upd(L, R); sum = ((l)? l->sum : 0) + ((r)? r->sum : 0); } int qry(int L, int R){ if(op){sum = (high-low+1); propagate();} if(low > R || high < L) return 0; if(L <= low && high <= R) return sum; int mid = low + ((high-low)>>1); if(!l) l = new Vertex(low, mid); if(!r) r = new Vertex(mid+1, high); return ((l)? l->qry(L, R) : 0) + ((r)? r->qry(L, R) : 0); } }; signed main(){ int q, c = 0; scanf("%d", &q); Vertex* seg = new Vertex(0, 1e9+1); while(q--){ int t, x, y; scanf("%d %d %d", &t, &x, &y); if(t == 1){ printf("%d\n", c = seg->qry(x+c, y+c)); }else{ seg->upd(x+c, y+c); } } }

Compilation message (stderr)

apple.cpp: In member function 'void Vertex::propagate()':
apple.cpp:11:4: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   11 |    if(!l) l = new Vertex(low, mid); if(!r) r = new Vertex(mid+1, high);
      |    ^~
apple.cpp:11:37: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   11 |    if(!l) l = new Vertex(low, mid); if(!r) r = new Vertex(mid+1, high);
      |                                     ^~
apple.cpp: In member function 'void Vertex::upd(int, int)':
apple.cpp:23:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   23 |   if(!l) l = new Vertex(low, mid); if(!r) r = new Vertex(mid+1, high);
      |   ^~
apple.cpp:23:36: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   23 |   if(!l) l = new Vertex(low, mid); if(!r) r = new Vertex(mid+1, high);
      |                                    ^~
apple.cpp: In member function 'int Vertex::qry(int, int)':
apple.cpp:32:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   32 |   if(!l) l = new Vertex(low, mid); if(!r) r = new Vertex(mid+1, high);
      |   ^~
apple.cpp:32:36: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   32 |   if(!l) l = new Vertex(low, mid); if(!r) r = new Vertex(mid+1, high);
      |                                    ^~
apple.cpp: In function 'int main()':
apple.cpp:37:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |  int q, c = 0; scanf("%d", &q);
      |                ~~~~~^~~~~~~~~~
apple.cpp:40:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |   int t, x, y; scanf("%d %d %d", &t, &x, &y);
      |                ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...