Submission #1208790

#TimeUsernameProblemLanguageResultExecution timeMemory
1208790pera게임 (IOI13_game)C++20
Compilation error
0 ms0 KiB
#include "bits/stdc++.h"
#include "game.h"
long long gcd2(long long X, long long Y) {
    long long tmp;
    while (X != Y && Y != 0) {
        tmp = X;
        X = Y;
        Y = tmp % Y;
    }
    return X;
}
int N , M;
struct NODE{
   NODE *l , *r;
   long long G = 0;
};
struct node{
   node *l , *r;
   NODE *v;
} *root;

void init(int R, int C) {
   N = R;
   M = C;
}
void upd(NODE *&u , int l , int r , int p , long long x){
   if(!u){
      u = new NODE();
   }
   if(l == r){
      u->G = x;
      return;
   }
   int m = (l + r) / 2;
   if(p <= m){
      upd(u->l , l , m , p , x);
   }else{
      upd(u->r , m + 1 , r , p , x);
   }
   if(!u->l){
      u->l = new NODE();
   }
   if(!u->r){
      u->r = new NODE();
   }
   u->G = gcd2(u->l->G , u->r->G);
};
void update(node* &u , int l , int r , int p , int q , long long x){
   if(l > r){
      return;
   }
   if(!u){
      u = new node();
   }
   upd(u->v , 1 , M , q , x);
   if(l == r){
      return;
   }
   int m = (l + r) / 2;
   if(p <= m){
      update(u->l , l , m , p , q , x);
   }else{
      update(u->r , m + 1 , r , p , q , x);
   }
}
void update(int P, int Q, long long K) {
   ++P , ++Q;
   update(root , 1 , N , P , Q , K);
}
long long query(NODE *&u , int l , int r , int L , int R){
   if(l > r || r < L || l > R || !u){
      return 0LL;
   }
   if(L <= l && r <= R){
      return u->G;
   }
   int m = (l + r) / 2;
   return gcd2(query(u->l , l , m , L , R) , query(u->r , m + 1 , r , L , R));
}
long long query(node*&u , int l , int r , int L , int R, int LL , int RR){
   if(l > r || r < L || l > R || !u){
      return 0LL;
   }
   if(L <= l && r <= R){
      return query(u->v , 1 , M , LL , RR);
   }
   int m = (l + r) / 2;
   return gcd2(query(u->l , l , m , L , R , LL , RR) , query(u->r , m + 1 , r , L , R , LL , RR));
};
long long calculate(int P, int Q, int U, int V) {
   ++P , ++Q , ++U , ++V;
   swap(Q , U);
   return query(root , 1 , N , P , Q , U , V);
}

Compilation message (stderr)

game.cpp: In function 'long long int calculate(int, int, int, int)':
game.cpp:92:4: error: 'swap' was not declared in this scope
   92 |    swap(Q , U);
      |    ^~~~
game.cpp:92:4: note: suggested alternatives:
In file included from /usr/include/c++/11/regex:63,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:110,
                 from game.cpp:1:
/usr/include/c++/11/bits/regex.h:2165:5: note:   'std::__cxx11::swap'
 2165 |     swap(match_results<_Bi_iter, _Alloc>& __lhs,
      |     ^~~~
In file included from /usr/include/c++/11/bits/stl_pair.h:59,
                 from /usr/include/c++/11/bits/stl_algobase.h:64,
                 from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from game.cpp:1:
/usr/include/c++/11/bits/move.h:196:5: note:   'std::swap'
  196 |     swap(_Tp& __a, _Tp& __b)
      |     ^~~~
/usr/include/c++/11/bits/move.h:196:5: note:   'std::swap'
In file included from /usr/include/c++/11/compare:39,
                 from /usr/include/c++/11/bits/stl_pair.h:65,
                 from /usr/include/c++/11/bits/stl_algobase.h:64,
                 from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from game.cpp:1:
/usr/include/c++/11/concepts:227:43: note:   'std::ranges::__cust::swap'
  227 |       inline constexpr __cust_swap::_Swap swap{};
      |                                           ^~~~
In file included from /usr/include/c++/11/exception:153,
                 from /usr/include/c++/11/ios:39,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from game.cpp:1:
/usr/include/c++/11/bits/exception_ptr.h:223:5: note:   'std::__exception_ptr::swap'
  223 |     swap(exception_ptr& __lhs, exception_ptr& __rhs)
      |     ^~~~
In file included from /usr/include/c++/11/filesystem:45,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:129,
                 from game.cpp:1:
/usr/include/c++/11/bits/fs_path.h:692:15: note:   'std::filesystem::__cxx11::swap'
  692 |   inline void swap(path& __lhs, path& __rhs) noexcept { __lhs.swap(__rhs); }
      |               ^~~~
In file included from /usr/include/c++/11/compare:39,
                 from /usr/include/c++/11/bits/stl_pair.h:65,
                 from /usr/include/c++/11/bits/stl_algobase.h:64,
                 from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from game.cpp:1:
/usr/include/c++/11/concepts:167:35: note:   'std::ranges::__cust_swap::swap'
  167 |       template<typename _Tp> void swap(_Tp&, _Tp&) = delete;
      |                                   ^~~~