제출 #681017

#제출 시각아이디문제언어결과실행 시간메모리
681017nutella게임 (IOI13_game)C++11
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "game.h" using namespace std; using ll = long long; #define gcd(a, b) __gcd(a, b) struct segtree { int l, r; ll d = 0; segtree *left = nullptr, *right = nullptr; void pull() { d = gcd(left ? left->d : 0, right ? right->d : 0); } void update(int i, ll k) { if (l + 1 == r) { d = k; } else { int mid = (l + r) / 2; if (i < mid) { if (!left) { left = new segtree({l, mid}); } left->update(i, k); } else { if (!right) { right = new segtree({mid, r}); } right->update(i, k); } pull(); } } ll query(int lx, int rx) { if (lx >= r || rx <= l) { return 0; } else if (lx <= l && r <= rx) { return d; } else { ll ans = 0; if (left) { ans = gcd(ans, left->query(lx, rx)); } if (right) { ans = gcd(ans, right->query(lx, rx)); } return ans; } } }; int R, C; struct SegmentTree { int l, r; segtree *st = nullptr; SegmentTree *left = nullptr, *right = nullptr; void build_st() { if (!st) { st = new segtree({0, C}); } } ll simple_query(int y) { if (!st) { return 0; } else { return st->query(y, y + 1); } } void update(int x, int y, ll k) { build_st(); if (l + 1 == r) { st->update(y, k); } else { int mid = (l + r) / 2; if (x < mid) { if (!left) { left = new SegmentTree({l, mid}); } left->update(x, y, k); } else { if (!right) { right = new SegmentTree({mid, r}); } right->update(x, y, k); } st->update(y, gcd((left ? left->simple_query(y) : 0), (right ? right->simple_query(y) : 0))); } } ll query(int lx, int rx, int ly, int ry) { if (l >= rx || lx >= r) { return 0; } else if (lx <= l && r <= rx) { if (!st) { return 0; } else { return st->query(ly, ry); } } else { ll ans = 0; if (left) { ans = gcd(ans, left->query(lx, rx, ly, ry)); } if (right) { ans = gcd(ans, right->query(lx, rx, ly, ry)); } return ans; } } }; SegmentTree *root = nullptr; void init(int R, int C) { ::R = R, ::C = C; root = new SegmentTree({0, R}); } void update(int P, int Q, ll K) { root->update(P, Q, K); } ll calculate(int P, int Q, int U, int V) { return root->query(P, U + 1, Q, V + 1); }

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

game.cpp: In member function 'void segtree::update(int, ll)':
game.cpp:27:48: error: no matching function for call to 'segtree::segtree(<brace-enclosed initializer list>)'
   27 |                     left = new segtree({l, mid});
      |                                                ^
game.cpp:9:8: note: candidate: 'segtree::segtree()'
    9 | struct segtree {
      |        ^~~~~~~
game.cpp:9:8: note:   candidate expects 0 arguments, 1 provided
game.cpp:9:8: note: candidate: 'constexpr segtree::segtree(const segtree&)'
game.cpp:9:8: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const segtree&'
game.cpp:9:8: note: candidate: 'constexpr segtree::segtree(segtree&&)'
game.cpp:9:8: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'segtree&&'
game.cpp:32:49: error: no matching function for call to 'segtree::segtree(<brace-enclosed initializer list>)'
   32 |                     right = new segtree({mid, r});
      |                                                 ^
game.cpp:9:8: note: candidate: 'segtree::segtree()'
    9 | struct segtree {
      |        ^~~~~~~
game.cpp:9:8: note:   candidate expects 0 arguments, 1 provided
game.cpp:9:8: note: candidate: 'constexpr segtree::segtree(const segtree&)'
game.cpp:9:8: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const segtree&'
game.cpp:9:8: note: candidate: 'constexpr segtree::segtree(segtree&&)'
game.cpp:9:8: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'segtree&&'
game.cpp: In member function 'void SegmentTree::build_st()':
game.cpp:71:36: error: no matching function for call to 'segtree::segtree(<brace-enclosed initializer list>)'
   71 |             st = new segtree({0, C});
      |                                    ^
game.cpp:9:8: note: candidate: 'segtree::segtree()'
    9 | struct segtree {
      |        ^~~~~~~
game.cpp:9:8: note:   candidate expects 0 arguments, 1 provided
game.cpp:9:8: note: candidate: 'constexpr segtree::segtree(const segtree&)'
game.cpp:9:8: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const segtree&'
game.cpp:9:8: note: candidate: 'constexpr segtree::segtree(segtree&&)'
game.cpp:9:8: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'segtree&&'
game.cpp: In member function 'void SegmentTree::update(int, int, ll)':
game.cpp:93:52: error: no matching function for call to 'SegmentTree::SegmentTree(<brace-enclosed initializer list>)'
   93 |                     left = new SegmentTree({l, mid});
      |                                                    ^
game.cpp:63:8: note: candidate: 'SegmentTree::SegmentTree()'
   63 | struct SegmentTree {
      |        ^~~~~~~~~~~
game.cpp:63:8: note:   candidate expects 0 arguments, 1 provided
game.cpp:63:8: note: candidate: 'constexpr SegmentTree::SegmentTree(const SegmentTree&)'
game.cpp:63:8: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const SegmentTree&'
game.cpp:63:8: note: candidate: 'constexpr SegmentTree::SegmentTree(SegmentTree&&)'
game.cpp:63:8: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'SegmentTree&&'
game.cpp:99:53: error: no matching function for call to 'SegmentTree::SegmentTree(<brace-enclosed initializer list>)'
   99 |                     right = new SegmentTree({mid, r});
      |                                                     ^
game.cpp:63:8: note: candidate: 'SegmentTree::SegmentTree()'
   63 | struct SegmentTree {
      |        ^~~~~~~~~~~
game.cpp:63:8: note:   candidate expects 0 arguments, 1 provided
game.cpp:63:8: note: candidate: 'constexpr SegmentTree::SegmentTree(const SegmentTree&)'
game.cpp:63:8: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const SegmentTree&'
game.cpp:63:8: note: candidate: 'constexpr SegmentTree::SegmentTree(SegmentTree&&)'
game.cpp:63:8: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'SegmentTree&&'
game.cpp: In function 'void init(int, int)':
game.cpp:138:34: error: no matching function for call to 'SegmentTree::SegmentTree(<brace-enclosed initializer list>)'
  138 |     root = new SegmentTree({0, R});
      |                                  ^
game.cpp:63:8: note: candidate: 'SegmentTree::SegmentTree()'
   63 | struct SegmentTree {
      |        ^~~~~~~~~~~
game.cpp:63:8: note:   candidate expects 0 arguments, 1 provided
game.cpp:63:8: note: candidate: 'constexpr SegmentTree::SegmentTree(const SegmentTree&)'
game.cpp:63:8: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const SegmentTree&'
game.cpp:63:8: note: candidate: 'constexpr SegmentTree::SegmentTree(SegmentTree&&)'
game.cpp:63:8: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'SegmentTree&&'