제출 #799161

#제출 시각아이디문제언어결과실행 시간메모리
799161alittlemiddle게임 (IOI13_game)C++14
컴파일 에러
0 ms0 KiB
#include "game.h"
#include<bits/stdc++.h>
#define el '\n'
#define fi first
#define sc second
#define pii pair<int, int>
#define all(v) v.begin(), v.end()
using namespace std;
using ll=long long;
using ull=unsigned long long;
using ld=long double;
const int mod=1e9+7;
const int N=6e6+11;
ll m, n;
ll gcd(ll x, ll y)
{
    return __gcd(x, y);
}
ll ss[N];
int L[N], R[N], root[N], lazy[N];
int cur = 1;
void down(int id, int l, int r)
{
    int mid = (l + r) >> 1;
    if (lazy[id] <= mid)
    {
        L[id] = ++cur;
        ss[L[id]] = ss[id];
        lazy[L[id]] = lazy[id];
    }
    else
    {
        R[id] = ++cur;
        ss[R[id]] = ss[id];
        lazy[R[id]] = lazy[id];
    }
    lazy[id] = 0;
}
void update1(int id, int l, int r, int pos, ll val)
{
    if (l==r)
    {
        ss[id] = val;
        return;
    }
    if(lazy[id])
    {
        if(lazy[id]==pos) ss[id] = val;
        else down(id, l, r);
    }
    int mid = (l+r)>>1;
    if(pos<=mid)
    {
        if (!L[id])
        {
            L[id] = ++cur;
            ss[L[id]] = val;
            lazy[L[id]] = pos;
        }
        else update1(L[id], l, mid, pos, val);
    }
    else
    {
        if(!R[id])
        {
            R[id] = ++cur;
            ss[R[id]] = val;
            lazy[R[id]] = pos;
        }
        else update1(R[id], mid + 1, r, pos, val);
    }
    ll s1 = 0, s2 = 0;
    if(L[id]) s1=ss[L[id]];
    if(R[id]) s2=ss[R[id]];
    ss[id] = gcd(s1, s2);
}
ll get1(int id, int l, int r, int a, int b)
{
    if(a>r || l>b) return 0;
    if(a<=l && r<=b) return ss[id];
    if(lazy[id])
    {
        if(a<=lazy[id] && lazy[id]<=b) return ss[id];
        else return 0;
    }
    int mid=(l+r)>>1;
    ll s1=0, s2=0;
    if(L[id]) s1 = get1(L[id], l, mid, a, b);
    if(R[id]) s2 = get1(R[id], mid+1, r, a, b);
    return gcd(s1, s2);
}
void update2(int id, int l, int r, int a, int b, ll val)
{
    if(l==r)
    {
        if (!root[id]) root[id] = ++cur;
        update1(root[id], 1, 2e9, b, val);
    }
    else
    {
        int mid = (l + r) >> 1;
        if (a <= mid)
        {
            if (!L[id]) L[id] = ++cur;
            update2(L[id], l, mid, a, b, val);
        }
        else
        {
            if (!R[id]) R[id] = ++cur;
            update2(R[id], mid + 1, r, a, b, val);
        }
        ll s1 = 0, s2 = 0;
        if(L[id]) s1 = get1(root[L[id]], 1, 2e9, b, b);
        if(R[id]) s2 = get1(root[R[id]], 1, 2e9, b, b);
        ll s3 = gcd(s1, s2);
        if(!root[id]) root[id] = ++cur;
        update1(root[id], 1, 2e9, b, s3);
    }
}
ll get2(int id, int l, int r, int a, int b, int u, int v)
{
    if(a>r || l>b) return 0;
    if(a<=l && r<=b)
    {
        if (root[id]) return get1(root[id], 1, 2e9, u, v);
        else return 0;
    }
    else
    {
        int mid=(l+r)>>1;
        ll s1 = 0, s2 = 0;
        if (L[id]) s1 = get2(L[id], l, mid, a, b, u, v);
        if (R[id]) s2 = get2(R[id], mid + 1, r, a, b, u, v);
        return gcd(s1, s2);
    }
}
void init(int R, int C)
{
    //ioi kho nhu cai dau khac
}

void update(int P, int Q, long long K)
{
    update2(1, 1, 2e9, P+1, Q+1, K);
}

long long calculate(int P, int Q, int U, int V)
{
    return get(1, 1, 2e9, P+1, Q+1, U+1, V+1);
}

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

game.cpp: In function 'long long int calculate(int, int, int, int)':
game.cpp:149:45: error: no matching function for call to 'get(int, int, double, int, int, int, int)'
  149 |     return get(1, 1, 2e9, P+1, Q+1, U+1, V+1);
      |                                             ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from game.cpp:2:
/usr/include/c++/10/utility:223:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(std::pair<_Tp1, _Tp2>&)'
  223 |     get(std::pair<_Tp1, _Tp2>& __in) noexcept
      |     ^~~
/usr/include/c++/10/utility:223:5: note:   template argument deduction/substitution failed:
game.cpp:149:45: note:   mismatched types 'std::pair<_Tp1, _Tp2>' and 'int'
  149 |     return get(1, 1, 2e9, P+1, Q+1, U+1, V+1);
      |                                             ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from game.cpp:2:
/usr/include/c++/10/utility:228:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(std::pair<_Tp1, _Tp2>&&)'
  228 |     get(std::pair<_Tp1, _Tp2>&& __in) noexcept
      |     ^~~
/usr/include/c++/10/utility:228:5: note:   template argument deduction/substitution failed:
game.cpp:149:45: note:   mismatched types 'std::pair<_Tp1, _Tp2>' and 'int'
  149 |     return get(1, 1, 2e9, P+1, Q+1, U+1, V+1);
      |                                             ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from game.cpp:2:
/usr/include/c++/10/utility:233:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(const std::pair<_Tp1, _Tp2>&)'
  233 |     get(const std::pair<_Tp1, _Tp2>& __in) noexcept
      |     ^~~
/usr/include/c++/10/utility:233:5: note:   template argument deduction/substitution failed:
game.cpp:149:45: note:   mismatched types 'const std::pair<_Tp1, _Tp2>' and 'int'
  149 |     return get(1, 1, 2e9, P+1, Q+1, U+1, V+1);
      |                                             ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from game.cpp:2:
/usr/include/c++/10/utility:238:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(const std::pair<_Tp1, _Tp2>&&)'
  238 |     get(const std::pair<_Tp1, _Tp2>&& __in) noexcept
      |     ^~~
/usr/include/c++/10/utility:238:5: note:   template argument deduction/substitution failed:
game.cpp:149:45: note:   mismatched types 'const std::pair<_Tp1, _Tp2>' and 'int'
  149 |     return get(1, 1, 2e9, P+1, Q+1, U+1, V+1);
      |                                             ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from game.cpp:2:
/usr/include/c++/10/utility:247:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp& std::get(std::pair<_T1, _T2>&)'
  247 |     get(pair<_Tp, _Up>& __p) noexcept
      |     ^~~
/usr/include/c++/10/utility:247:5: note:   template argument deduction/substitution failed:
game.cpp:149:45: note:   mismatched types 'std::pair<_T1, _T2>' and 'int'
  149 |     return get(1, 1, 2e9, P+1, Q+1, U+1, V+1);
      |                                             ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from game.cpp:2:
/usr/include/c++/10/utility:252:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp& std::get(const std::pair<_T1, _T2>&)'
  252 |     get(const pair<_Tp, _Up>& __p) noexcept
      |     ^~~
/usr/include/c++/10/utility:252:5: note:   template argument deduction/substitution failed:
game.cpp:149:45: note:   mismatched types 'const std::pair<_T1, _T2>' and 'int'
  149 |     return get(1, 1, 2e9, P+1, Q+1, U+1, V+1);
      |                                             ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from game.cpp:2:
/usr/include/c++/10/utility:257:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp&& std::get(std::pair<_T1, _T2>&&)'
  257 |     get(pair<_Tp, _Up>&& __p) noexcept
      |     ^~~
/usr/include/c++/10/utility:257:5: note:   template argument deduction/substitution failed:
game.cpp:149:45: note:   mismatched types 'std::pair<_T1, _T2>' and 'int'
  149 |     return get(1, 1, 2e9, P+1, Q+1, U+1, V+1);
      |                                             ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from game.cpp:2:
/usr/include/c++/10/utility:262:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp&& std::get(const std::pair<_T1, _T2>&&)'
  262 |     get(const pair<_Tp, _Up>&& __p) noexcept
      |     ^~~
/usr/include/c++/10/utility:262:5: note:   template argument deduction/substitution failed:
game.cpp:149:45: note:   mismatched types 'const std::pair<_T1, _T2>' and 'int'
  149 |     return get(1, 1, 2e9, P+1, Q+1, U+1, V+1);
      |                                             ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from game.cpp:2:
/usr/include/c++/10/utility:267:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp& std::get(std::pair<_Up, _Tp>&)'
  267 |     get(pair<_Up, _Tp>& __p) noexcept
      |     ^~~
/usr/include/c++/10/utility:267:5: note:   template argument deduction/substitution failed:
game.cpp:149:45: note:   mismatched types 'std::pair<_Up, _Tp>' and 'int'
  149 |     return get(1, 1, 2e9, P+1, Q+1, U+1, V+1);
      |                                             ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from game.cpp:2:
/usr/include/c++/10/utility:272:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp& std::get(const std::pair<_Up, _Tp>&)'
  272 |     get(const pair<_Up, _Tp>& __p) noexcept
      |     ^~~
/usr/include/c++/10/utility:272:5: note:   template argument deduction/substitution failed:
game.cpp:149:45: note:   mismatched types 'const std::pair<_Up, _Tp>' and 'int'
  149 |     return get(1, 1, 2e9, P+1, Q+1, U+1, V+1);
      |                                             ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from game.cpp:2:
/usr/include/c++/10/utility:277:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp&& std::get(std::pair<_Up, _Tp>&&)'
  277 |     get(pair<_Up, _Tp>&& __p) noexcept
      |     ^~~
/usr/include/c++/10/utility:277:5: note:   template argument deduction/substitution failed:
game.cpp:149:45: note:   mismatched types 'std::pair<_Up, _Tp>' and 'int'
  149 |     return get(1, 1, 2e9, P+1, Q+1, U+1, V+1);
      |                                             ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from game.cpp:2:
/usr/include/c++/10/utility:282:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp&& std::get(const std::pair<_Up, _Tp>&&)'
  282 |     get(const pair<_Up, _Tp>&& __p) noexcept
      |     ^~~
/usr/include/c++/10/utility:282:5: note:   template argument deduction/substitution failed:
game.cpp:149:45: note:   mismatched types 'const std::pair<_Up, _Tp>' and 'int'
  149 |     return get(1, 1, 2e9, P+1, Q+1, U+1, V+1);
      |                                             ^
In file included from /usr/include/c++/10/tuple:39,
                 from /usr/include/c++/10/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71,
                 from game.cpp:2:
/usr/include/c++/10/array:334:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr _Tp& std::get(std::array<_Tp, _Nm>&)'
  334 |     get(array<_Tp, _Nm>& __arr) noexcept
      |     ^~~
/usr/include/c++/10/array:334:5: note:   template argument deduction/substitution failed:
game.cpp:149:45: note:   mismatched types 'std::array<_Tp, _Nm>' and 'int'
  149 |     return get(1, 1, 2e9, P+1, Q+1, U+1, V+1);
      |                                             ^
In file included from /usr/include/c++/10/tuple:39,
                 from /usr/include/c++/10/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71,
                 from game.cpp:2:
/usr/include/c++/10/array:343:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr _Tp&& std::get(std::array<_Tp, _Nm>&&)'
  343 |     get(array<_Tp, _Nm>&& __arr) noexcept
      |     ^~~
/usr/include/c++/10/array:343:5: note:   template argument deduction/substitution failed:
game.cpp:149:45: note:   mismatched types 'std::array<_Tp, _Nm>' and 'int'
  149 |     return get(1, 1, 2e9, P+1, Q+1, U+1, V+1);
      |                                             ^
In file included from /usr/include/c++/10/tuple:39,
                 from /usr/include/c++/10/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71,
                 from game.cpp:2:
/usr/include/c++/10/array:351:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr const _Tp& std::get(const std::array<_Tp, _Nm>&)'
  351 |     get(const array<_Tp, _Nm>& __arr) noexcept
      |     ^~~
/usr/include/c++/10/array:351:5: note:   template argument deduction/substitution failed:
game.cpp:149:45: note:   mismatched types 'const std::array<_Tp, _Nm>' and 'int'
  149 |     return get(1, 1, 2e9, P+1, Q+1, U+1, V+1);
      |                                             ^
In file included from /usr/include/c++/10/tuple:39,
                 from /usr/include/c++/10/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71,
                 from game.cpp:2:
/usr/include/c++/10/array:360:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr const _Tp&& std::get(const std::array<_Tp, _Nm>&&)'
  360 |     get(const array<_Tp, _Nm>&& __arr) noexcept
      |     ^~~
/usr/include/c++/10/array:360:5: note:   template argument deduction/substitution failed:
game.cpp:149:45: note:   mismatched types 'const std::array<_Tp, _Nm>' and 'int'
  149 |     return get(1, 1, 2e9, P+1, Q+1, U+1, V+1);
      |                                             ^
In file included from /usr/include/c++/10/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71,
                 from game.cpp:2:
/usr/include/c++/10/tuple:1294:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >& std::get(std::tuple<_Elements ...>&)'
 1294 |     get(tuple<_Elements...>& __t) noexcept
      |     ^~~
/usr/include/c++/10/tuple:1294:5: note:   template argument deduction/substitution failed:
game.cpp:149:45: note:   mismatched types 'std::tuple<_Elements ...>' and 'int'
  149 |     return get(1, 1, 2e9, P+1, Q+1, U+1, V+1);
      |                                             ^
In file included from /usr/include/c++/10/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71,
                 from game.cpp:2:
/usr/include/c++/10/tuple:1300:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >& std::get(const std::tuple<_Elements ...>&)'
 1300 |     get(const tuple<_Elements...>& __t) noexcept
      |     ^~~
/usr/include/c++/10/tuple:1300:5: note:   template argument deduction/substitution failed:
game.cpp:149:45: note:   mismatched types 'const std::tuple<_Elements ...>' and 'int'
  149 |     return get(1, 1, 2e9, P+1, Q+1, U+1, V+1);
      |                                             ^
In file included from /usr/include/c++/10/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71,
                 from game.cpp:2:
/usr/include/c++/10/tuple:1306:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >&& std::get(std::tuple<_Elements ...>&&)'
 1306 |     get(tuple<_Elements...>&& __t) noexcept
      |     ^~~
/usr/include/c++/10/tuple:1306:5: note:   template argument deduction/substitution failed:
game.cpp:149:45: note:   mismatched types 'std::tuple<_Elements ...>' and 'int'
  149 |     return get(1, 1, 2e9, P+1, Q+1, U+1, V+1);
      |                                             ^
In file included from /usr/include/c++/10/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71,
                 from game.cpp:2:
/usr/include/c++/10/tuple:1315:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >&& std::get(const std::tuple<_Elements ...>&&)'
 1315 |     get(const tuple<_Elements...>&& __t) noexcept
      |     ^~~
/usr/include/c++/10/tuple:1315:5: note:   template argument deduction/substitution failed:
game.cpp:149:45: note:   mismatched types 'const std::tuple<_Elements ...>' and 'int'
  149 |     return get(1, 1, 2e9, P+1, Q+1, U+1, V+1);
      |                                             ^
In file included from /usr/include/c++/10/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71,
                 from game.cpp:2:
/usr/include/c++/10/tuple:1338:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr _Tp& std::get(std::tuple<_Elements ...>&)'
 1338 |     get(tuple<_Types...>& __t) noexcept
      |     ^~~
/usr/include/c++/10/tuple:1338:5: note:   template argument deduction/substitution failed:
game.cpp:149:45: note:   mismatched types 'std::tuple<_Elements ...>' and 'int'
  149 |     return get(1, 1, 2e9, P+1, Q+1, U+1, V+1);
      |                                             ^
In file included from /usr/include/c++/10/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71,
                 from game.cpp:2:
/usr/include/c++/10/tuple:1344:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr _Tp&& std::get(std::tuple<_Elements ...>&&)'
 1344 |     get(tuple<_Types...>&& __t) noexcept
      |     ^~~
/usr/include/c++/10/tuple:1344:5: note:   template argument deduction/substitution failed:
game.cpp:149:45: note:   mismatched types 'std::tuple<_Elements ...>' and 'int'
  149 |     return get(1, 1, 2e9, P+1, Q+1, U+1, V+1);
      |                                             ^
In file included from /usr/include/c++/10/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71,
                 from game.cpp:2:
/usr/include/c++/10/tuple:1350:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr const _Tp& std::get(const std::tuple<_Elements ...>&)'
 1350 |     get(const tuple<_Types...>& __t) noexcept
      |     ^~~
/usr/include/c++/10/tuple:1350:5: note:   template argument deduction/substitution failed:
game.cpp:149:45: note:   mismatched types 'const std::tuple<_Elements ...>' and 'int'
  149 |     return get(1, 1, 2e9, P+1, Q+1, U+1, V+1);
      |                                             ^
In file included from /usr/include/c++/10/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71,
                 from game.cpp:2:
/usr/include/c++/10/tuple:1357:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr const _Tp&& std::get(const std::tuple<_Elements ...>&&)'
 1357 |     get(const tuple<_Types...>&& __t) noexcept
      |     ^~~
/usr/include/c++/10/tuple:1357:5: note:   template argument deduction/substitution failed:
game.cpp:149:45: note:   mismatched types 'const std::tuple<_Elements ...>' and 'int'
  149 |     return get(1, 1, 2e9, P+1, Q+1, U+1, V+1);
      |                                             ^