Submission #987130

#TimeUsernameProblemLanguageResultExecution timeMemory
987130SunbaeMonkey and Apple-trees (IZhO12_apple)C11
Compilation error
0 ms0 KiB
#include <stdio.h> 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(1, 1e9); 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.c:3:2: error: unknown type name 'Vertex'
    3 |  Vertex *l = nullptr, *r = nullptr;
      |  ^~~~~~
apple.c:3:12: error: expected ':', ',', ';', '}' or '__attribute__' before '=' token
    3 |  Vertex *l = nullptr, *r = nullptr;
      |            ^
apple.c: In function 'main':
apple.c:37:2: error: unknown type name 'Vertex'; use 'struct' keyword to refer to the type
   37 |  Vertex* seg = new Vertex(1, 1e9);
      |  ^~~~~~
      |  struct 
apple.c:37:16: error: 'new' undeclared (first use in this function)
   37 |  Vertex* seg = new Vertex(1, 1e9);
      |                ^~~
apple.c:37:16: note: each undeclared identifier is reported only once for each function it appears in
apple.c:37:20: error: expected ',' or ';' before 'Vertex'
   37 |  Vertex* seg = new Vertex(1, 1e9);
      |                    ^~~~~~
apple.c:41:26: error: request for member 'qry' in something not a structure or union
   41 |    printf("%d\n", c = seg->qry(x+c, y+c));
      |                          ^~
apple.c:43:7: error: request for member 'upd' in something not a structure or union
   43 |    seg->upd(x+c, y+c);
      |       ^~
apple.c:36:16: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |  int q, c = 0; scanf("%d", &q);
      |                ^~~~~~~~~~~~~~~
apple.c:39:16: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |   int t, x, y; scanf("%d %d %d", &t, &x, &y);
      |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~