제출 #964291

#제출 시각아이디문제언어결과실행 시간메모리
964291n3rm1n게임 (IOI13_game)C++17
컴파일 에러
0 ms0 KiB
#include<iostream> #define endl '\n' using namespace std; void speed() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } struct segment_tree_2d { struct segment_tree { struct node { node *l, *r; int val; node() { l = nullptr; r = nullptr; val = 0; }; node(_val) { l = nullptr; r = nullptr; val = _val; } }; node *root; segment_tree *l, *r; segment_tree() { root = new node(); /// ? *l = nullptr; *r = nullptr; } void merge_nodes(node *tree) { if(tree -> l == nullptr) tree -> l = new node(); if(tree -> r == nullptr) tree -> r = new node(); tree -> val = (tree -> l -> val + tree -> r -> val); } void update(node *tree, int l, int r, int pos, int k) { if(l == r) { tree -> val = k; return; } int mid = (l + r)/2; if(pos <= mid) { if(tree -> l == nullptr) tree -> l = new node(); update(tree -> l, l, mid, pos, k); } else { if(tree -> r == nullptr) tree -> r = new node(); update(tree -> r, mid+1, r, pos, k); } tree -> val = (l -> val) + (r -> val); /// merge? } int query(node *tree, int l, int r, int ql, int qr) { if(tree == nullptr)return 0; if(ql <= l && r <= qr)return tree -> val; if(ql > r || qr < l)return 0; int mid = (l + r)/2; return (query(tree -> l, l, mid, ql, qr) + query(tree -> r, mid+1, r, ql, qr)); } void update(int pos, int x) { update(1, 1, n, pos, x); } int query(int ql, int qr) { return query(1, 1, n, ql, qr); } }; segment_tree *root; segment_tree_2d() { root = new segment_tree(); } void merge_tree(segment_tree *tree, int pos) /// opravqsh samo edna poziciq vyv vseki moment { if(tree -> l == nullptr) tree -> l = new segment_tree(); if(tree -> r == nullptr) tree -> r = new segment_tree(); int fh = tree -> l -> query() tree -> val = } }; int main() { speed(); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

game.cpp:25:17: warning: unnecessary parentheses in declaration of '_val' [-Wparentheses]
   25 |             node(_val)
      |                 ^
game.cpp:25:18: error: field '_val' has incomplete type 'segment_tree_2d::segment_tree::node'
   25 |             node(_val)
      |                  ^~~~
game.cpp:15:16: note: definition of 'struct segment_tree_2d::segment_tree::node' is not complete until the closing brace
   15 |         struct node
      |                ^~~~
game.cpp:30:13: error: expected ';' at end of member declaration
   30 |             }
      |             ^
      |              ;
game.cpp: In constructor 'segment_tree_2d::segment_tree::segment_tree()':
game.cpp:39:18: error: no match for 'operator=' (operand types are 'segment_tree_2d::segment_tree' and 'std::nullptr_t')
   39 |             *l = nullptr;
      |                  ^~~~~~~
game.cpp:13:12: note: candidate: 'constexpr segment_tree_2d::segment_tree& segment_tree_2d::segment_tree::operator=(const segment_tree_2d::segment_tree&)'
   13 |     struct segment_tree
      |            ^~~~~~~~~~~~
game.cpp:13:12: note:   no known conversion for argument 1 from 'std::nullptr_t' to 'const segment_tree_2d::segment_tree&'
game.cpp:13:12: note: candidate: 'constexpr segment_tree_2d::segment_tree& segment_tree_2d::segment_tree::operator=(segment_tree_2d::segment_tree&&)'
game.cpp:13:12: note:   no known conversion for argument 1 from 'std::nullptr_t' to 'segment_tree_2d::segment_tree&&'
game.cpp:40:18: error: no match for 'operator=' (operand types are 'segment_tree_2d::segment_tree' and 'std::nullptr_t')
   40 |             *r = nullptr;
      |                  ^~~~~~~
game.cpp:13:12: note: candidate: 'constexpr segment_tree_2d::segment_tree& segment_tree_2d::segment_tree::operator=(const segment_tree_2d::segment_tree&)'
   13 |     struct segment_tree
      |            ^~~~~~~~~~~~
game.cpp:13:12: note:   no known conversion for argument 1 from 'std::nullptr_t' to 'const segment_tree_2d::segment_tree&'
game.cpp:13:12: note: candidate: 'constexpr segment_tree_2d::segment_tree& segment_tree_2d::segment_tree::operator=(segment_tree_2d::segment_tree&&)'
game.cpp:13:12: note:   no known conversion for argument 1 from 'std::nullptr_t' to 'segment_tree_2d::segment_tree&&'
game.cpp: In member function 'void segment_tree_2d::segment_tree::update(segment_tree_2d::segment_tree::node*, int, int, int, int)':
game.cpp:71:30: error: base operand of '->' is not a pointer
   71 |             tree -> val = (l -> val) + (r -> val); /// merge?
      |                              ^~
game.cpp:71:43: error: base operand of '->' is not a pointer
   71 |             tree -> val = (l -> val) + (r -> val); /// merge?
      |                                           ^~
game.cpp: In member function 'void segment_tree_2d::segment_tree::update(int, int)':
game.cpp:85:26: error: 'n' was not declared in this scope
   85 |             update(1, 1, n, pos, x);
      |                          ^
game.cpp: In member function 'int segment_tree_2d::segment_tree::query(int, int)':
game.cpp:89:32: error: 'n' was not declared in this scope
   89 |             return query(1, 1, n, ql, qr);
      |                                ^
game.cpp: In member function 'void segment_tree_2d::merge_tree(segment_tree_2d::segment_tree*, int)':
game.cpp:107:37: error: no matching function for call to 'segment_tree_2d::segment_tree::query()'
  107 |         int fh = tree -> l -> query()
      |                                     ^
game.cpp:74:13: note: candidate: 'int segment_tree_2d::segment_tree::query(segment_tree_2d::segment_tree::node*, int, int, int, int)'
   74 |         int query(node *tree, int l, int r, int ql, int qr)
      |             ^~~~~
game.cpp:74:13: note:   candidate expects 5 arguments, 0 provided
game.cpp:87:13: note: candidate: 'int segment_tree_2d::segment_tree::query(int, int)'
   87 |         int query(int ql, int qr)
      |             ^~~~~
game.cpp:87:13: note:   candidate expects 2 arguments, 0 provided
game.cpp:107:13: warning: unused variable 'fh' [-Wunused-variable]
  107 |         int fh = tree -> l -> query()
      |             ^~