제출 #951569

#제출 시각아이디문제언어결과실행 시간메모리
951569EsgeerWall (IOI14_wall)C++17
컴파일 에러
0 ms0 KiB
#ifndef Local #pragma GCC optimize("O3,unroll-loops") #endif #include <bits/stdc++.h> using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <unistd.h> using namespace __gnu_pbds; template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; //#define int long long #define vi vector<int> #define vvi vector<vi> #define pii pair<int, int> #define vpi vector<pii> #define vvpi vector<vpi> #define vb vector<bool> #define vvb vector<vb> #define endl '\n' #define sp << " " << #define F(i, s, n) for(int i = s; i < n; i++) #define pb push_back #define fi first #define se second int mod = 998244353; int inf = 1e16; const int N = 5e5+5; #include "wall.h" struct Node { int mn, mx; }; struct Update { int mn, mx, last; }; Node merge(Node a, Node b) { return {-inf, inf}; } Update merge(Update a, Update b) { Update c = {max(a.mn, b.mn), min(a.mx, b.mx), b.last}; if(b.last == 2) c.last = a.last; if(c.mn > c.mx) { if(c.last) c.mn = c.mx; else c.mx = c.mn; } return c; } Node merge(Node a, Update b) { Node c = {max(a.mn, b.mn), min(a.mx, b.mx)}; if(c.mn > c.mx) { if(b.last) c.mn = c.mx; else c.mx = c.mn; } return c; } Node t[4*N]; Update lazy[4*N]; int a[N]; void push(int node, int l, int r) { t[node] = merge(t[node], lazy[node]); if(l != r) { lazy[node*2+1] = merge(lazy[node*2+1], lazy[node]); lazy[node*2+2] = merge(lazy[node*2+2], lazy[node]); } lazy[node] = {-inf, inf, 2}; } void build(int node, int l, int r) { lazy[node] = {-inf, inf, 2}; if(l == r) { t[node] = {-inf, inf}; return; } int mid = (l + r) >> 1; build(node*2+1, l, mid); build(node*2+2, mid+1, r); } void update(int node, int l, int r, int L, int R, int a, int b) { push(node, l, r); if(l > R || r < L) return; if(l >= L && r <= R) { if(b == 0) lazy[node] = {a, inf, 0}; else lazy[node] = {-inf, a, 1}; push(node, l, r); return; } int mid = (l + r) >> 1; update(node*2+1, l, mid, L, R, a, b); update(node*2+2, mid+1, r, L, R, a, b); } Node query(int node, int l, int r, int idx) { push(node, l, r); if(l > idx || r < idx) return {-inf, inf}; if(l == r) { return t[node]; } int mid = (l + r) >> 1; if(idx <= mid) return query(node*2+1, l, mid, idx); else return query(node*2+2, mid+1, r, idx); } void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]) { build(0, 0, n-1); F(i, 0, k) { if(op[i] == 1) { update(0, 0, n-1, left[i], right[i], height[i], 0); } else { update(0, 0, n-1, left[i], right[i], height[i], 1); } } F(i, 0, n) { Node q = query(0, 0, n-1, i); finalHeight[i] = min(max(q.mn, 0ll), q.mx); } } /* void solve() { int op[] = {1, 2, 2, 1, 1, 2}; int left[] = {1, 4, 3, 0, 2, 6}; int right[] = {8, 9, 6, 5, 2, 7}; int heights[] = {4, 1, 5, 3, 5, 0}; int res[6]; buildWall(10, 6, op, left, right, heights, res); F(i, 0, 10) cout << res[i] << " "; cout << endl; } void setIO() { ios_base::sync_with_stdio(0); cin.tie(0); #ifdef Local freopen("local.in", "r", stdin); freopen("local.out", "w", stdout); #else // freopen("poetry.in","r",stdin); // freopen("poetry.out","w",stdout); #endif } signed main() { setIO(); int t = 1; //cin >> t; while(t--) solve(); }*/

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

wall.cpp:27:11: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+16' to '2147483647' [-Woverflow]
   27 | int inf = 1e16;
      |           ^~~~
wall.cpp: In function 'void buildWall(int, int, int*, int*, int*, int*, int*)':
wall.cpp:119:43: error: no matching function for call to 'max(int&, long long int)'
  119 |         finalHeight[i] = min(max(q.mn, 0ll), q.mx);
      |                                           ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from wall.cpp:4:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
wall.cpp:119:43: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
  119 |         finalHeight[i] = min(max(q.mn, 0ll), q.mx);
      |                                           ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from wall.cpp:4:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
wall.cpp:119:43: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
  119 |         finalHeight[i] = min(max(q.mn, 0ll), q.mx);
      |                                           ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from wall.cpp:4:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
wall.cpp:119:43: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  119 |         finalHeight[i] = min(max(q.mn, 0ll), q.mx);
      |                                           ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from wall.cpp:4:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
wall.cpp:119:43: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  119 |         finalHeight[i] = min(max(q.mn, 0ll), q.mx);
      |                                           ^