Submission #431830

#TimeUsernameProblemLanguageResultExecution timeMemory
431830nvmdavaLand of the Rainbow Gold (APIO17_rainbow)C++17
Compilation error
0 ms0 KiB
#include "rainbow.h" #include <bits/stdc++.h> using namespace std; #define ff first #define ss second const int N = 200005; struct Node{ Node *l = NULL, *r = NULL; ll a; Node* update(int L, int R, int x){ Node* res = new Node(); res -> l = l; res -> r = r; res -> a = a; ++res -> a; if(L == R) return res; int m = (L + R) >> 1; if(x <= m){ if(l == NULL) l = new Node(); res -> l = l -> update(L, m, x); } else { if(r == NULL) r = new Node(); res -> r = r -> update(m + 1, R, x); } return res; } ll query(int L, int R, int le, int ri){ if(R < le || L > ri) return 0; if(le <= L && R <= ri) return a; int m = (L + R) >> 1; return (l == NULL ? 0 : l -> query(L, m, le, ri)) + (r == NULL ? 0 : r -> query(m + 1, R, le, ri)); } }; struct Grid{ Node* seg[N]; void build(set<pair<int, int> >& v){ seg[0] = new Node(); auto it = v.begin(); for(int i = 1; i < N; ++i){ seg[i] = seg[i - 1]; while(it != v.end() && it -> ff == i){ seg[i] = seg[i] -> update(1, N, it -> ss); ++it; } } } ll query(int x1, int y1, int x2, int y2){ if(x1 > x2 || y1 > y2) return 0; return seg[x2] -> query(1, N, y1, y2) - seg[x1 - 1] -> query(1, N, y1, y2); } } riv, dot, lix, liy; void init(int R, int C, int sr, int sc, int M, char *S) { set<pair<int, int> > rivs, dots, lixs, liys; rivs.insert({sr, sc}); for(int i = 0; i < M; ++i){ if(S[i] == 'N') --sr; if(S[i] == 'E') ++sc; if(S[i] == 'S') ++sr; if(S[i] == 'W') --sc; rivs.insert({sr, sc}); } for(auto& a : rivs){ dots.insert({a.ff, a.ss}); dots.insert({a.ff, a.ss + 1}); dots.insert({a.ff + 1, a.ss + 1}); dots.insert({a.ff + 1, a.ss}); lixs.insert({a.ff, a.ss}); lixs.insert({a.ff, a.ss + 1}); liys.insert({a.ff, a.ss}); liys.insert({a.ff + 1, a.ss}); } riv.build(rivs); dot.build(dots); lix.build(lixs); liy.build(liys); } int colour(int x1, int y1, int x2, int y2) { ll t = riv.query(x1, y1, x2, y2); if(t == 0) return 1; return 1 - riv.query(x1, y1, x2, y2) - dot.query(x1 + 1, y1 + 1, x2, y2) + lix.query(x1, y1 + 1, x2, y2) + liy.query(x1 + 1, y1, x2, y2); }

Compilation message (stderr)

rainbow.cpp:11:5: error: 'll' does not name a type
   11 |     ll a;
      |     ^~
rainbow.cpp:33:5: error: 'll' does not name a type
   33 |     ll query(int L, int R, int le, int ri){
      |     ^~
rainbow.cpp: In member function 'Node* Node::update(int, int, int)':
rainbow.cpp:16:16: error: 'struct Node' has no member named 'a'
   16 |         res -> a = a;
      |                ^
rainbow.cpp:16:20: error: 'a' was not declared in this scope
   16 |         res -> a = a;
      |                    ^
rainbow.cpp:17:18: error: 'struct Node' has no member named 'a'
   17 |         ++res -> a;
      |                  ^
rainbow.cpp: At global scope:
rainbow.cpp:57:5: error: 'll' does not name a type
   57 |     ll query(int x1, int y1, int x2, int y2){
      |     ^~
rainbow.cpp: In function 'int colour(int, int, int, int)':
rainbow.cpp:94:5: error: 'll' was not declared in this scope
   94 |     ll t = riv.query(x1, y1, x2, y2);
      |     ^~
rainbow.cpp:95:8: error: 't' was not declared in this scope
   95 |     if(t == 0) return 1;
      |        ^
rainbow.cpp:96:20: error: 'struct Grid' has no member named 'query'
   96 |     return 1 - riv.query(x1, y1, x2, y2) - dot.query(x1 + 1, y1 + 1, x2, y2) + lix.query(x1, y1 + 1, x2, y2) + liy.query(x1 + 1, y1, x2, y2);
      |                    ^~~~~
rainbow.cpp:96:48: error: 'struct Grid' has no member named 'query'
   96 |     return 1 - riv.query(x1, y1, x2, y2) - dot.query(x1 + 1, y1 + 1, x2, y2) + lix.query(x1, y1 + 1, x2, y2) + liy.query(x1 + 1, y1, x2, y2);
      |                                                ^~~~~
rainbow.cpp:96:84: error: 'struct Grid' has no member named 'query'
   96 |     return 1 - riv.query(x1, y1, x2, y2) - dot.query(x1 + 1, y1 + 1, x2, y2) + lix.query(x1, y1 + 1, x2, y2) + liy.query(x1 + 1, y1, x2, y2);
      |                                                                                    ^~~~~
rainbow.cpp:96:116: error: 'struct Grid' has no member named 'query'
   96 |     return 1 - riv.query(x1, y1, x2, y2) - dot.query(x1 + 1, y1 + 1, x2, y2) + lix.query(x1, y1 + 1, x2, y2) + liy.query(x1 + 1, y1, x2, y2);
      |                                                                                                                    ^~~~~