Submission #798961

#TimeUsernameProblemLanguageResultExecution timeMemory
798961alittlemiddleGame (IOI13_game)C++14
Compilation error
0 ms0 KiB
#include "game.h"
#include<bits/stdc++.h>
int m, n;
struct node1
{
    int l, r, sum;
    node1 *left, *right;
    node1(int _l, int _r)
    {
        l = _l;
        r = _r;
        sum = 0;
        left = right = NULL;
    }
    void update(int i, int v)
    {
        if (r < i || i < l) return;
        if (l==r && l==i)
        {
            sum = v;
            return;
        }
        int mid=(l+r)>>1;
        if(left==NULL) left = new node1(l, mid);
        if(right==NULL) right = new node1(mid+1, r);
        left->update(i, v);
        right->update(i, v);
        sum = __gcd(left->sum,  right->sum);
    }

    int get(int a, int b)
    {
        if (r < a || b < l) return 0;
        if (a <= l && r <= b) return sum;
        int mid=(l+r)>>1;
        if(left==NULL) left = new node1(l, mid);
        if(right==NULL) right = new node1(mid+1, r);
        return __gcd(left->get(a, b) , right->get(a, b));
    }
};
struct node2
{
    int l, r, sum;
    node2 *left, *right;
    node1 *node;
    node2(int _l, int _r)
    {
        l = _l;
        r = _r;
        sum = 0;
        left = right = NULL;
        node = new node1(1, n);
    }
    void update(int x, int y, int val)
    {
        if (r<x || x<l) return;
        node->update(y, val);
        if (l==r) return;
        int mid=(l+r)>>1;
        if(left==NULL) left = new node2(l, mid);
        if(right==NULL) right = new node2(mid+1, r);
        left->update(x, y, val);
        right->update(x, y, val);
    }
    int get(int x, int y, int u, int v)
    {
        if (r<x || u<l) return 0;
        if (x <= l && r <= u) return node->get(y, v);
        int mid=(l+r)>>1;
        if(left==NULL) left = new node2(l, mid);
        if(right==NULL) right = new node2(mid+1, r);
        return __gcd(left->get(x, y, u, v) , right->get(x, y, u, v));
    }
};
node2* root;
void init(int R, int C)
{
    m = R;
    n = C;
    root = new node2(1, R);
}

void update(int P, int Q, long long K)
{
    root->update(P + 1, Q + 1, K);
}

long long calculate(int P, int Q, int U, int V)
{
    return root->get(P + 1, U + 1, Q + 1, V + 1);
}

Compilation message (stderr)

game.cpp: In member function 'void node1::update(int, int)':
game.cpp:28:15: error: '__gcd' was not declared in this scope
   28 |         sum = __gcd(left->sum,  right->sum);
      |               ^~~~~
game.cpp:28:15: note: suggested alternatives:
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from game.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:1219:5: note:   'std::__gcd'
 1219 |     __gcd(_EuclideanRingElement __m, _EuclideanRingElement __n)
      |     ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:84,
                 from game.cpp:2:
/usr/include/c++/10/numeric:102:5: note:   'std::__detail::__gcd'
  102 |     __gcd(_Mn __m, _Nn __n)
      |     ^~~~~
game.cpp: In member function 'int node1::get(int, int)':
game.cpp:38:16: error: '__gcd' was not declared in this scope
   38 |         return __gcd(left->get(a, b) , right->get(a, b));
      |                ^~~~~
game.cpp:38:16: note: suggested alternatives:
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from game.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:1219:5: note:   'std::__gcd'
 1219 |     __gcd(_EuclideanRingElement __m, _EuclideanRingElement __n)
      |     ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:84,
                 from game.cpp:2:
/usr/include/c++/10/numeric:102:5: note:   'std::__detail::__gcd'
  102 |     __gcd(_Mn __m, _Nn __n)
      |     ^~~~~
game.cpp: In member function 'int node2::get(int, int, int, int)':
game.cpp:72:16: error: '__gcd' was not declared in this scope
   72 |         return __gcd(left->get(x, y, u, v) , right->get(x, y, u, v));
      |                ^~~~~
game.cpp:72:16: note: suggested alternatives:
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from game.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:1219:5: note:   'std::__gcd'
 1219 |     __gcd(_EuclideanRingElement __m, _EuclideanRingElement __n)
      |     ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:84,
                 from game.cpp:2:
/usr/include/c++/10/numeric:102:5: note:   'std::__detail::__gcd'
  102 |     __gcd(_Mn __m, _Nn __n)
      |     ^~~~~