답안 #894576

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
894576 2023-12-28T13:11:03 Z raul2008487 벽 (IOI14_wall) C++17
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
#include "wall.h"
#define ll long long
#define vl vector<ll>
#define pll pair<ll,ll>
#define in insert
#define fi first
#define se second
#define all(v) v.begin(), v.end()
using namespace std;
const ll sz = 2e6+6;
const ll inf = 1000000000000000;
vector<array<ll, 2>> st;
ll res[sz];
void comp(ll x1, ll x2){
    st[x2][0] = min(st[x2][0], st[x][0]);
    st[x2][1] = max(st[x2][1], st[x][1]);
}
void push(ll v, ll l, ll r){
    if(l == r){return ;}
    comp(v, v*2);
    comp(v, v*2+1);
    st[v] = {0, inf};
}
void update(ll v, ll tl, ll tr, ll l, ll r, ll val, ll  type){
    if(tl > r || tr <l){return ;}
    if(tl >= l && tr <= r){
        if(type == 1){
            st[v][0] = min(st[v][0], val);
            st[v][1] = min(st[v][1], val);
        }
        else{
            st[v][0] = max(st[v][0], val);
            st[v][1] = max(st[v][1], val);
        }
        return ;
    }
    push(v, tl, tr);
    ll tm = (tl+tr)>>1;
    update(v*2, tl, tm, l, r, val, type);
    update(v*2+1, tm+1, tr, l, r, val, type);
}
void trav(ll v, ll tl, ll tr){
    if(tl > tr){
        return ;
    }
    if(tl == tr){
        res[tl - 1] = st[v][0];
        return ;
    }
    push(v, tl, tr);
    ll tm = (tl + tr)>>1;
    trav(v*2, tl, tm);
    trav(v*2+1, tm+1, tr);
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
    ll i, j, sz, z = 0;
    st.assign(sz*4 {0, inf});
    for(i=0;i<k;i++){
        update(1, 1, n, left[i] + 1, right[i] + 1, height[i], op[i]);
    }
    trav(1, 1, n);
    for(i=0;i<n;i++){
        finalHeight[i] = max(z, res[i]);
    }
}

/*
10 6
1 1 8 4
0 4 9 1
0 3 6 5
1 0 5 3
1 2 2 5
0 6 7 0
*/

Compilation message

wall.cpp: In function 'void comp(long long int, long long int)':
wall.cpp:16:35: error: 'x' was not declared in this scope; did you mean 'x1'?
   16 |     st[x2][0] = min(st[x2][0], st[x][0]);
      |                                   ^
      |                                   x1
wall.cpp: In function 'void buildWall(int, int, int*, int*, int*, int*, int*)':
wall.cpp:58:19: error: expected ')' before '{' token
   58 |     st.assign(sz*4 {0, inf});
      |              ~    ^~
      |                   )
wall.cpp:58:28: error: no matching function for call to 'std::vector<std::array<long long int, 2> >::assign(long long int)'
   58 |     st.assign(sz*4 {0, inf});
      |                            ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from wall.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:749:7: note: candidate: 'void std::vector<_Tp, _Alloc>::assign(std::vector<_Tp, _Alloc>::size_type, const value_type&) [with _Tp = std::array<long long int, 2>; _Alloc = std::allocator<std::array<long long int, 2> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::value_type = std::array<long long int, 2>]'
  749 |       assign(size_type __n, const value_type& __val)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:749:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/10/bits/stl_vector.h:768:2: note: candidate: 'template<class _InputIterator, class> void std::vector<_Tp, _Alloc>::assign(_InputIterator, _InputIterator) [with _InputIterator = _InputIterator; <template-parameter-2-2> = <template-parameter-1-2>; _Tp = std::array<long long int, 2>; _Alloc = std::allocator<std::array<long long int, 2> >]'
  768 |  assign(_InputIterator __first, _InputIterator __last)
      |  ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:768:2: note:   template argument deduction/substitution failed:
wall.cpp:58:28: note:   candidate expects 2 arguments, 1 provided
   58 |     st.assign(sz*4 {0, inf});
      |                            ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from wall.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:794:7: note: candidate: 'void std::vector<_Tp, _Alloc>::assign(std::initializer_list<_Tp>) [with _Tp = std::array<long long int, 2>; _Alloc = std::allocator<std::array<long long int, 2> >]'
  794 |       assign(initializer_list<value_type> __l)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:794:43: note:   no known conversion for argument 1 from 'long long int' to 'std::initializer_list<std::array<long long int, 2> >'
  794 |       assign(initializer_list<value_type> __l)
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
wall.cpp:57:11: warning: unused variable 'j' [-Wunused-variable]
   57 |     ll i, j, sz, z = 0;
      |           ^