제출 #1060659

#제출 시각아이디문제언어결과실행 시간메모리
1060659wood자리 배치 (IOI18_seats)C++17
컴파일 에러
0 ms0 KiB
#include "seats.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define vi vector<int>
#define vp32 vector<p32>
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define MOD %1000000007
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <class T>
using Tree =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//never guess
//never debug without reviewing code
//never try adding ones or substracting them
//only step by step debug when necessay

constexpr int N = 3e6;

    int size = 1, xmin[N] , xmax[N] = {0},ymin[N],ymax[N] = {0};
    void segtree(int n){
        while(size<n) size*=2;
        fill(xmin,xmin+N,INT_MAX);
        fill(ymin,ymin+N,INT_MAX);
    }

    void sset(int i, int xx, int yy, int x, int lx, int rx);
    void sset(int i, int xx, int yy){
        sset(i,xx,yy,0,0,size);
    }
    void sset(int i, int xx, int yy, int x, int lx, int rx){
        if(rx-lx==1){
            xmin[x]=xmax[x]=xx;
            ymin[x]=ymax[x]=yy;
            return;
        }
        int m = (lx+rx)/2;
        if(i<m)sset(i,xx,yy,2*x+1,lx,m);
        else sset(i,xx,yy,2*x+2,m,rx);
        xmin[x] = min(xmin[2*x+1],xmin[2*x+2]);
        ymin[x] = min(ymin[2*x+1],ymin[2*x+2]);
        xmax[x] = max(xmax[2*x+1],xmax[2*x+2]);
        ymax[x] = max(ymax[2*x+1],ymax[2*x+2]);
    }

    vi getrange(int l, int r, int x, int lx, int rx);
    vi getrange(int l ,int r){
        return getrange(l,r,0,0,size);
    }
    vi getrange(int l, int r, int x, int lx, int rx){
        if(lx>=r||rx<=l)return vi({INT_MAX,0,INT_MAX,0});
        else if(lx>=l&&rx<=r)return vi({xmin[x],xmax[x],ymin[x],ymax[x]});
        int m = (rx+lx)/2;
        vi a = getrange(l,r,2*x+1,lx,m), b = getrange(l,r,2*x+2,m,rx);
        return vi({min(a[0],b[0]),max(a[1],b[1]),min(a[2],b[2]), max(a[3],b[3])});
    }

vi xs, ys;
void give_initial_chart(int H, int W, std::vector<int> R, std::vector<int> C) {
    segtree(H*W);
    for(int i = 0; i<H*W; i++){
        xmin[i+size-1] = xmax[i+size-1] = R[i];
        xs.pb(R[i]);
        ymin[i+size-1] = ymax[i+size-1] = C[i];
        ys.pb(C[i]);
    }
    for(int x = size-2; x>=0; x--){
        xmin[x] = min(xmin[2*x+1],xmin[2*x+2]);
        ymin[x] = min(ymin[2*x+1],ymin[2*x+2]);
        xmax[x] = max(xmax[2*x+1],xmax[2*x+2]);
        ymax[x] = max(ymax[2*x+1],ymax[2*x+2]);
    }
}

int swap_seats(int a, int b) {
    int cur = 1;
    swap(xs[a],xs[b]); swap(ys[a],ys[b]);
    sset(a,xs[a],ys[a]);
    sset(b,xs[b],ys[b]);
    int cnt = 0;
    while(cur<=xs.size()){
        vi v = getrange(0,cur);
        if((v[1]-v[0]+1)*(v[3]-v[2]+1)==cur){
            cnt++;
            cur++;
        }
        else cur =(v[1]-v[0]+1)*(v[3]-v[2]+1);
    }
    return cnt;
}

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

seats.cpp: In function 'void segtree(int)':
seats.cpp:29:15: error: reference to 'size' is ambiguous
   29 |         while(size<n) size*=2;
      |               ^~~~
In file included from /usr/include/c++/10/vector:69,
                 from seats.h:3,
                 from seats.cpp:1:
/usr/include/c++/10/bits/range_access.h:254:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  254 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:245:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  245 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
seats.cpp:27:9: note:                 'int size'
   27 |     int size = 1, xmin[N] , xmax[N] = {0},ymin[N],ymax[N] = {0};
      |         ^~~~
seats.cpp:29:23: error: reference to 'size' is ambiguous
   29 |         while(size<n) size*=2;
      |                       ^~~~
In file included from /usr/include/c++/10/vector:69,
                 from seats.h:3,
                 from seats.cpp:1:
/usr/include/c++/10/bits/range_access.h:254:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  254 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:245:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  245 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
seats.cpp:27:9: note:                 'int size'
   27 |     int size = 1, xmin[N] , xmax[N] = {0},ymin[N],ymax[N] = {0};
      |         ^~~~
seats.cpp: In function 'void sset(int, int, int)':
seats.cpp:36:26: error: reference to 'size' is ambiguous
   36 |         sset(i,xx,yy,0,0,size);
      |                          ^~~~
In file included from /usr/include/c++/10/vector:69,
                 from seats.h:3,
                 from seats.cpp:1:
/usr/include/c++/10/bits/range_access.h:254:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  254 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:245:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  245 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
seats.cpp:27:9: note:                 'int size'
   27 |     int size = 1, xmin[N] , xmax[N] = {0},ymin[N],ymax[N] = {0};
      |         ^~~~
seats.cpp: In function 'std::vector<int> getrange(int, int)':
seats.cpp:55:33: error: reference to 'size' is ambiguous
   55 |         return getrange(l,r,0,0,size);
      |                                 ^~~~
In file included from /usr/include/c++/10/vector:69,
                 from seats.h:3,
                 from seats.cpp:1:
/usr/include/c++/10/bits/range_access.h:254:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  254 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:245:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  245 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
seats.cpp:27:9: note:                 'int size'
   27 |     int size = 1, xmin[N] , xmax[N] = {0},ymin[N],ymax[N] = {0};
      |         ^~~~
seats.cpp: In function 'void give_initial_chart(int, int, std::vector<int>, std::vector<int>)':
seats.cpp:69:16: error: reference to 'size' is ambiguous
   69 |         xmin[i+size-1] = xmax[i+size-1] = R[i];
      |                ^~~~
In file included from /usr/include/c++/10/vector:69,
                 from seats.h:3,
                 from seats.cpp:1:
/usr/include/c++/10/bits/range_access.h:254:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  254 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:245:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  245 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
seats.cpp:27:9: note:                 'int size'
   27 |     int size = 1, xmin[N] , xmax[N] = {0},ymin[N],ymax[N] = {0};
      |         ^~~~
seats.cpp:69:33: error: reference to 'size' is ambiguous
   69 |         xmin[i+size-1] = xmax[i+size-1] = R[i];
      |                                 ^~~~
In file included from /usr/include/c++/10/vector:69,
                 from seats.h:3,
                 from seats.cpp:1:
/usr/include/c++/10/bits/range_access.h:254:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  254 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:245:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  245 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
seats.cpp:27:9: note:                 'int size'
   27 |     int size = 1, xmin[N] , xmax[N] = {0},ymin[N],ymax[N] = {0};
      |         ^~~~
seats.cpp:71:16: error: reference to 'size' is ambiguous
   71 |         ymin[i+size-1] = ymax[i+size-1] = C[i];
      |                ^~~~
In file included from /usr/include/c++/10/vector:69,
                 from seats.h:3,
                 from seats.cpp:1:
/usr/include/c++/10/bits/range_access.h:254:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  254 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:245:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  245 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
seats.cpp:27:9: note:                 'int size'
   27 |     int size = 1, xmin[N] , xmax[N] = {0},ymin[N],ymax[N] = {0};
      |         ^~~~
seats.cpp:71:33: error: reference to 'size' is ambiguous
   71 |         ymin[i+size-1] = ymax[i+size-1] = C[i];
      |                                 ^~~~
In file included from /usr/include/c++/10/vector:69,
                 from seats.h:3,
                 from seats.cpp:1:
/usr/include/c++/10/bits/range_access.h:254:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  254 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:245:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  245 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
seats.cpp:27:9: note:                 'int size'
   27 |     int size = 1, xmin[N] , xmax[N] = {0},ymin[N],ymax[N] = {0};
      |         ^~~~
seats.cpp:74:17: error: reference to 'size' is ambiguous
   74 |     for(int x = size-2; x>=0; x--){
      |                 ^~~~
In file included from /usr/include/c++/10/vector:69,
                 from seats.h:3,
                 from seats.cpp:1:
/usr/include/c++/10/bits/range_access.h:254:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  254 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:245:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  245 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
seats.cpp:27:9: note:                 'int size'
   27 |     int size = 1, xmin[N] , xmax[N] = {0},ymin[N],ymax[N] = {0};
      |         ^~~~
seats.cpp: In function 'int swap_seats(int, int)':
seats.cpp:88:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   88 |     while(cur<=xs.size()){
      |           ~~~^~~~~~~~~~~