# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
937960 | Muaath_5 | 게임 (IOI13_game) | C++17 | 컴파일 에러 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "game.h"
#include <bits/stdc++.h>
#define ll long long
#define OUT 0ll
ll gcd2(ll x, ll y) {
if (y == 0) return x;
return gcd2(y, x % y);
}
#define merge gcd2
using namespace std;
static int R = 1 << 30, C = 1 << 30;
struct ynode {
ll val = OUT;
unique_ptr<ynode> left = nullptr, right = nullptr;
};
struct xnode {
unique_ptr<xnode> left, right;
unique_ptr<ynode> yy;
};
ll query_y(const int& qy1, const int& qy2, ynode* node, int l = 0, int r = C - 1)
{
if (node == nullptr || r < qy1 || qy2 < l) return OUT;
if (qy1 <= l && r <= qy2) return node->val;
const int mid = (l + r) / 2;
return merge(
query_y(qy1, qy2, node->left, l, mid),
query_y(qy1, qy2, node->right, mid + 1, r)
);
}
ll query_x(const int& qx1, const int& qy1, const int& qx2, const int& qy2, xnode* node, int l = 0, int r = R - 1)
{
if (node == nullptr || r < qx1 || qx2 < l) return OUT;
if (qx1 <= l && r <= qx2) return query_y(qy1, qy2, node->yy);
const int mid = (l + r) / 2;
return merge(
query_x(qx1, qy1, qx2, qy2, node->left, l, mid),
query_x(qx1, qy1, qx2, qy2, node->right, mid + 1, r)
);
}
void update_y(const int& qy, const ll& val, ynode* node, int l = 0, int r = C - 1)
{
if (l == r) {
node->val = val;
return;
}
const int mid = (l + r) / 2;
if (qy <= mid) {
if (!node->left) node->left = new ynode();
update_y(qy, val, node->left, l, mid);
}
else {
if (!node->right) node->right = new ynode();
update_y(qy, val, node->right, mid + 1, r);
}
ll m1 = OUT, m2 = OUT;
if (node->left) m1 = node->left->val;
if (node->right) m2 = node->right->val;
node->val = merge(m1, m2);
}
void update_x(const int& qx, const int& qy, const ll& val, xnode* node, int l = 0, int r = R - 1)
{
if (!node->yy) node->yy = new ynode();
if (l == r) {
update_y(qy, val, node->yy);
return;
}
const int mid = (l + r) / 2;
if (qx <= mid) {
if (!node->left) node->left = new xnode();
update_x(qx, qy, val, node->left, l, mid);
}
else {
if (!node->right) node->right = new xnode();
update_x(qx, qy, val, node->right, mid + 1, r);
}
update_y(qy, merge(
(node->left && node->left->yy ? query_y(qy, qy, node->left->yy) : OUT),
(node->right && node->right->yy ? query_y(qy, qy, node->right->yy) : OUT)
), node->yy);
}
xnode* root;
void init(int r, int c) { R = r, C = c, root = new xnode(); }
void update(int x, int y, long long k) { update_x(x, y, k, root); }
long long calculate(int x1, int y1, int x2, int y2) { return query_x(x1, y1, x2, y2, root); }
컴파일 시 표준 에러 (stderr) 메시지
game.cpp: In function 'long long int query_y(const int&, const int&, ynode*, int, int)': game.cpp:32:33: error: cannot convert 'std::unique_ptr<ynode>' to 'ynode*' 32 | query_y(qy1, qy2, node->left, l, mid), | ~~~~~~^~~~ | | | std::unique_ptr<ynode> game.cpp:26:51: note: initializing argument 3 of 'long long int query_y(const int&, const int&, ynode*, int, int)' 26 | ll query_y(const int& qy1, const int& qy2, ynode* node, int l = 0, int r = C - 1) | ~~~~~~~^~~~ game.cpp:33:33: error: cannot convert 'std::unique_ptr<ynode>' to 'ynode*' 33 | query_y(qy1, qy2, node->right, mid + 1, r) | ~~~~~~^~~~~ | | | std::unique_ptr<ynode> game.cpp:26:51: note: initializing argument 3 of 'long long int query_y(const int&, const int&, ynode*, int, int)' 26 | ll query_y(const int& qy1, const int& qy2, ynode* node, int l = 0, int r = C - 1) | ~~~~~~~^~~~ game.cpp: In function 'long long int query_x(const int&, const int&, const int&, const int&, xnode*, int, int)': game.cpp:40:62: error: cannot convert 'std::unique_ptr<ynode>' to 'ynode*' 40 | if (qx1 <= l && r <= qx2) return query_y(qy1, qy2, node->yy); | ~~~~~~^~ | | | std::unique_ptr<ynode> game.cpp:26:51: note: initializing argument 3 of 'long long int query_y(const int&, const int&, ynode*, int, int)' 26 | ll query_y(const int& qy1, const int& qy2, ynode* node, int l = 0, int r = C - 1) | ~~~~~~~^~~~ game.cpp:44:43: error: cannot convert 'std::unique_ptr<xnode>' to 'xnode*' 44 | query_x(qx1, qy1, qx2, qy2, node->left, l, mid), | ~~~~~~^~~~ | | | std::unique_ptr<xnode> game.cpp:37:83: note: initializing argument 5 of 'long long int query_x(const int&, const int&, const int&, const int&, xnode*, int, int)' 37 | ll query_x(const int& qx1, const int& qy1, const int& qx2, const int& qy2, xnode* node, int l = 0, int r = R - 1) | ~~~~~~~^~~~ game.cpp:45:43: error: cannot convert 'std::unique_ptr<xnode>' to 'xnode*' 45 | query_x(qx1, qy1, qx2, qy2, node->right, mid + 1, r) | ~~~~~~^~~~~ | | | std::unique_ptr<xnode> game.cpp:37:83: note: initializing argument 5 of 'long long int query_x(const int&, const int&, const int&, const int&, xnode*, int, int)' 37 | ll query_x(const int& qx1, const int& qy1, const int& qx2, const int& qy2, xnode* node, int l = 0, int r = R - 1) | ~~~~~~~^~~~ game.cpp: In function 'void update_y(const int&, const long long int&, ynode*, int, int)': game.cpp:58:49: error: no match for 'operator=' (operand types are 'std::unique_ptr<ynode>' and 'ynode*') 58 | if (!node->left) node->left = new ynode(); | ^ In file included from /usr/include/c++/10/bits/locale_conv.h:41, from /usr/include/c++/10/locale:43, from /usr/include/c++/10/iomanip:43, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:72, from game.cpp:2: /usr/include/c++/10/bits/unique_ptr.h:371:19: note: candidate: 'std::unique_ptr<_Tp, _Dp>& std::unique_ptr<_Tp, _Dp>::operator=(std::unique_ptr<_Tp, _Dp>&&) [with _Tp = ynode; _Dp = std::default_delete<ynode>]' 371 | unique_ptr& operator=(unique_ptr&&) = default; | ^~~~~~~~ /usr/include/c++/10/bits/unique_ptr.h:371:29: note: no known conversion for argument 1 from 'ynode*' to 'std::unique_ptr<ynode>&&' 371 | unique_ptr& operator=(unique_ptr&&) = default; | ^~~~~~~~~~~~ /usr/include/c++/10/bits/unique_ptr.h:386:2: note: candidate: 'template<class _Up, class _Ep> typename std::enable_if<std::__and_<std::__and_<std::is_convertible<typename std::unique_ptr<_Up, _Ep>::pointer, typename std::__uniq_ptr_impl<_Tp, _Dp>::pointer>, std::__not_<std::is_array<_Up> > >, std::is_assignable<_T2&, _U2&&> >::value, std::unique_ptr<_Tp, _Dp>&>::type std::unique_ptr<_Tp, _Dp>::operator=(std::unique_ptr<_Up, _Ep>&&) [with _Up = _Up; _Ep = _Ep; _Tp = ynode; _Dp = std::default_delete<ynode>]' 386 | operator=(unique_ptr<_Up, _Ep>&& __u) noexcept | ^~~~~~~~ /usr/include/c++/10/bits/unique_ptr.h:386:2: note: template argument deduction/substitution failed: game.cpp:58:49: note: mismatched types 'std::unique_ptr<_Tp, _Dp>' and 'ynode*' 58 | if (!node->left) node->left = new ynode(); | ^ In file included from /usr/include/c++/10/bits/locale_conv.h:41, from /usr/include/c++/10/locale:43, from /usr/include/c++/10/iomanip:43, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:72, from game.cpp:2: /usr/include/c++/10/bits/unique_ptr.h:395:7: note: candidate: 'std::unique_ptr<_Tp, _Dp>& std::unique_ptr<_Tp, _Dp>::operator=(std::nullptr_t) [with _Tp = ynode; _Dp = std::default_delete<ynode>; std::nullptr_t = std::nullptr_t]' 395 | operator=(nullptr_t) noexcept | ^~~~~~~~ /usr/include/c++/10/bits/unique_ptr.h:395:17: note: no known conversion for argument 1 from 'ynode*' to 'std::nullptr_t' 395 | operator=(nullptr_t) noexcept | ^~~~~~~~~ game.cpp:59:33: error: cannot convert 'std::unique_ptr<ynode>' to 'ynode*' 59 | update_y(qy, val, node->left, l, mid); | ~~~~~~^~~~ | | | std::unique_ptr<ynode> game.cpp:50:52: note: initializing argument 3 of 'void update_y(const int&, const long long int&, ynode*, int, int)' 50 | void update_y(const int& qy, const ll& val, ynode* node, int l = 0, int r = C - 1) | ~~~~~~~^~~~ game.cpp:62:51: error: no match for 'operator=' (operand types are 'std::unique_ptr<ynode>' and 'ynode*') 62 | if (!node->right) node->right = new ynode(); | ^ In file included from /usr/include/c++/10/bits/locale_conv.h:41, from /usr/include/c++/10/locale:43, from /usr/include/c++/10/iomanip:43, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:72, from game.cpp:2: /usr/include/c++/10/bits/unique_ptr.h:371:19: note: candidate: 'std::unique_ptr<_Tp, _Dp>& std::unique_ptr<_Tp, _Dp>::operator=(std::unique_ptr<_Tp, _Dp>&&) [with _Tp = ynode; _Dp = std::default_delete<ynode>]' 371 | unique_ptr& operator=(unique_ptr&&) = default; | ^~~~~~~~ /usr/include/c++/10/bits/unique_ptr.h:371:29: note: no known conversion for argument 1 from 'ynode*' to 'std::unique_ptr<ynode>&&' 371 | unique_ptr& operator=(unique_ptr&&) = default; | ^~~~~~~~~~~~ /usr/include/c++/10/bits/unique_ptr.h:386:2: note: candidate: 'template<class _Up, class _Ep> typename std::enable_if<std::__and_<std::__and_<std::is_convertible<typename std::unique_ptr<_Up, _Ep>::pointer, typename std::__uniq_ptr_impl<_Tp, _Dp>::pointer>, std::__not_<std::is_array<_Up> > >, std::is_assignable<_T2&, _U2&&> >::value, std::unique_ptr<_Tp, _Dp>&>::type std::unique_ptr<_Tp, _Dp>::operator=(std::unique_ptr<_Up, _Ep>&&) [with _Up = _Up; _Ep = _Ep; _Tp = ynode; _Dp = std::default_delete<ynode>]' 386 | operator=(unique_ptr<_Up, _Ep>&& __u) noexcept | ^~~~~~~~ /usr/include/c++/10/bits/unique_ptr.h:386:2: note: template argument deduction/substitution failed: game.cpp:62:51: note: mismatched types 'std::unique_ptr<_Tp, _Dp>' and 'ynode*' 62 | if (!node->right) node->right = new ynode(); | ^ In file included from /usr/include/c++/10/bits/locale_conv.h:41, from /usr/include/c++/10/locale:43, from /usr/include/c++/10/iomanip:43, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:72, from game.cpp:2: /usr/include/c++/10/bits/unique_ptr.h:395:7: note: candidate: 'std::unique_ptr<_Tp, _Dp>& std::unique_ptr<_Tp, _Dp>::operator=(std::nullptr_t) [with _Tp = ynode; _Dp = std::default_delete<ynode>; std::nullptr_t = std::nullptr_t]' 395 | operator=(nullptr_t) noexcept | ^~~~~~~~ /usr/include/c++/10/bits/unique_ptr.h:395:17: note: no known conversion for argument 1 from 'ynode*' to 'std::nullptr_t' 395 | operator=(nullptr_t) noexcept | ^~~~~~~~~ game.cpp:63:33: error: cannot convert 'std::unique_ptr<ynode>' to 'ynode*' 63 | update_y(qy, val, node->right, mid + 1, r); | ~~~~~~^~~~~ | | | std::unique_ptr<ynode> game.cpp:50:52: note: initializing argument 3 of 'void update_y(const int&, const long long int&, ynode*, int, int)' 50 | void update_y(const int& qy, const ll& val, ynode* node, int l = 0, int r = C - 1) | ~~~~~~~^~~~ game.cpp: In function 'void update_x(const int&, const int&, const long long int&, xnode*, int, int)': game.cpp:73:41: error: no match for 'operator=' (operand types are 'std::unique_ptr<ynode>' and 'ynode*') 73 | if (!node->yy) node->yy = new ynode(); | ^ In file included from /usr/include/c++/10/bits/locale_conv.h:41, from /usr/include/c++/10/locale:43, from /usr/include/c++/10/iomanip:43, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:72, from game.cpp:2: /usr/include/c++/10/bits/unique_ptr.h:371:19: note: candidate: 'std::unique_ptr<_Tp, _Dp>& std::unique_ptr<_Tp, _Dp>::operator=(std::unique_ptr<_Tp, _Dp>&&) [with _Tp = ynode; _Dp = std::default_delete<ynode>]' 371 | unique_ptr& operator=(unique_ptr&&) = default; | ^~~~~~~~ /usr/include/c++/10/bits/unique_ptr.h:371:29: note: no known conversion for argument 1 from 'ynode*' to 'std::unique_ptr<ynode>&&' 371 | unique_ptr& operator=(unique_ptr&&) = default; | ^~~~~~~~~~~~ /usr/include/c++/10/bits/unique_ptr.h:386:2: note: candidate: 'template<class _Up, class _Ep> typename std::enable_if<std::__and_<std::__and_<std::is_convertible<typename std::unique_ptr<_Up, _Ep>::pointer, typename std::__uniq_ptr_impl<_Tp, _Dp>::pointer>, std::__not_<std::is_array<_Up> > >, std::is_assignable<_T2&, _U2&&> >::value, std::unique_ptr<_Tp, _Dp>&>::type std::unique_ptr<_Tp, _Dp>::operator=(std::unique_ptr<_Up, _Ep>&&) [with _Up = _Up; _Ep = _Ep; _Tp = ynode; _Dp = std::default_delete<ynode>]' 386 | operator=(unique_ptr<_Up, _Ep>&& __u) noexcept | ^~~~~~~~ /usr/include/c++/10/bits/unique_ptr.h:386:2: note: template argument deduction/substitution failed: game.cpp:73:41: note: mismatched types 'std::unique_ptr<_Tp, _Dp>' and 'ynode*' 73 | if (!node->yy) node->yy = new ynode(); | ^ In file included from /usr/include/c++/10/bits/locale_conv.h:41, from /usr/include/c++/10/locale:43, from /usr/include/c++/10/iomanip:43, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:72, from game.cpp:2: /usr/include/c++/10/bits/unique_ptr.h:395:7: note: candidate: 'std::unique_ptr<_Tp, _Dp>& std::unique_ptr<_Tp, _Dp>::operator=(std::nullptr_t) [with _Tp = ynode; _Dp = std::default_delete<ynode>; std::nullptr_t = std::nullptr_t]' 395 | operator=(nullptr_t) noexcept | ^~~~~~~~ /usr/include/c++/10/bits/unique_ptr.h:395:17: note: no known conversion for argument 1 from 'ynode*' to 'std::nullptr_t' 395 | operator=(nullptr_t) noexcept | ^~~~~~~~~ game.cpp:75:33: error: cannot convert 'std::unique_ptr<ynode>' to 'ynode*' 75 | update_y(qy, val, node->yy); | ~~~~~~^~ | | | std::unique_ptr<ynode> game.cpp:50:52: note: initializing argument 3 of 'void update_y(const int&, const long long int&, ynode*, int, int)' 50 | void update_y(const int& qy, const ll& val, ynode* node, int l = 0, int r = C - 1) | ~~~~~~~^~~~ game.cpp:80:49: error: no match for 'operator=' (operand types are 'std::unique_ptr<xnode>' and 'xnode*') 80 | if (!node->left) node->left = new xnode(); | ^ In file included from /usr/include/c++/10/bits/locale_conv.h:41, from /usr/include/c++/10/locale:43, from /usr/include/c++/10/iomanip:43, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:72, from game.cpp:2: /usr/include/c++/10/bits/unique_ptr.h:371:19: note: candidate: 'std::unique_ptr<_Tp, _Dp>& std::unique_ptr<_Tp, _Dp>::operator=(std::unique_ptr<_Tp, _Dp>&&) [with _Tp = xnode; _Dp = std::default_delete<xnode>]' 371 | unique_ptr& operator=(unique_ptr&&) = default; | ^~~~~~~~ /usr/include/c++/10/bits/unique_ptr.h:371:29: note: no known conversion for argument 1 from 'xnode*' to 'std::unique_ptr<xnode>&&' 371 | unique_ptr& operator=(unique_ptr&&) = default; | ^~~~~~~~~~~~ /usr/include/c++/10/bits/unique_ptr.h:386:2: note: candidate: 'template<class _Up, class _Ep> typename std::enable_if<std::__and_<std::__and_<std::is_convertible<typename std::unique_ptr<_Up, _Ep>::pointer, typename std::__uniq_ptr_impl<_Tp, _Dp>::pointer>, std::__not_<std::is_array<_Up> > >, std::is_assignable<_T2&, _U2&&> >::value, std::unique_ptr<_Tp, _Dp>&>::type std::unique_ptr<_Tp, _Dp>::operator=(std::unique_ptr<_Up, _Ep>&&) [with _Up = _Up; _Ep = _Ep; _Tp = xnode; _Dp = std::default_delete<xnode>]' 386 | operator=(unique_ptr<_Up, _Ep>&& __u) noexcept | ^~~~~~~~ /usr/include/c++/10/bits/unique_ptr.h:386:2: note: template argument deduction/substitution failed: game.cpp:80:49: note: mismatched types 'std::unique_ptr<_Tp, _Dp>' and 'xnode*' 80 | if (!node->left) node->left = new xnode(); | ^ In file included from /usr/include/c++/10/bits/locale_conv.h:41, from /usr/include/c++/10/locale:43, from /usr/include/c++/10/iomanip:43, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:72, from game.cpp:2: /usr/include/c++/10/bits/unique_ptr.h:395:7: note: candidate: 'std::unique_ptr<_Tp, _Dp>& std::unique_ptr<_Tp, _Dp>::operator=(std::nullptr_t) [with _Tp = xnode; _Dp = std::default_delete<xnode>; std::nullptr_t = std::nullptr_t]' 395 | operator=(nullptr_t) noexcept | ^~~~~~~~ /usr/include/c++/10/bits/unique_ptr.h:395:17: note: no known conversion for argument 1 from 'xnode*' to 'std::nullptr_t' 395 | operator=(nullptr_t) noexcept | ^~~~~~~~~ game.cpp:81:37: error: cannot convert 'std::unique_ptr<xnode>' to 'xnode*' 81 | update_x(qx, qy, val, node->left, l, mid); | ~~~~~~^~~~ | | | std::unique_ptr<xnode> game.cpp:71:67: note: initializing argument 4 of 'void update_x(const int&, const int&, const long long int&, xnode*, int, int)' 71 | void update_x(const int& qx, const int& qy, const ll& val, xnode* node, int l = 0, int r = R - 1) | ~~~~~~~^~~~ game.cpp:84:51: error: no match for 'operator=' (operand types are 'std::unique_ptr<xnode>' and 'xnode*') 84 | if (!node->right) node->right = new xnode(); | ^ In file included from /usr/include/c++/10/bits/locale_conv.h:41, from /usr/include/c++/10/locale:43, from /usr/include/c++/10/iomanip:43, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:72, from game.cpp:2: /usr/include/c++/10/bits/unique_ptr.h:371:19: note: candidate: 'std::unique_ptr<_Tp, _Dp>& std::unique_ptr<_Tp, _Dp>::operator=(std::unique_ptr<_Tp, _Dp>&&) [with _Tp = xnode; _Dp = std::default_delete<xnode>]' 371 | unique_ptr& operator=(unique_ptr&&) = default; | ^~~~~~~~ /usr/include/c++/10/bits/unique_ptr.h:371:29: note: no known conversion for argument 1 from 'xnode*' to 'std::unique_ptr<xnode>&&' 371 | unique_ptr& operator=(unique_ptr&&) = default; | ^~~~~~~~~~~~ /usr/include/c++/10/bits/unique_ptr.h:386:2: note: candidate: 'template<class _Up, class _Ep> typename std::enable_if<std::__and_<std::__and_<std::is_convertible<typename std::unique_ptr<_Up, _Ep>::pointer, typename std::__uniq_ptr_impl<_Tp, _Dp>::pointer>, std::__not_<std::is_array<_Up> > >, std::is_assignable<_T2&, _U2&&> >::value, std::unique_ptr<_Tp, _Dp>&>::type std::unique_ptr<_Tp, _Dp>::operator=(std::unique_ptr<_Up, _Ep>&&) [with _Up = _Up; _Ep = _Ep; _Tp = xnode; _Dp = std::default_delete<xnode>]' 386 | operator=(unique_ptr<_Up, _Ep>&& __u) noexcept | ^~~~~~~~ /usr/include/c++/10/bits/unique_ptr.h:386:2: note: template argument deduction/substitution failed: game.cpp:84:51: note: mismatched types 'std::unique_ptr<_Tp, _Dp>' and 'xnode*' 84 | if (!node->right) node->right = new xnode(); | ^ In file included from /usr/include/c++/10/bits/locale_conv.h:41,