제출 #337889

#제출 시각아이디문제언어결과실행 시간메모리
337889Azimjon벽 (IOI14_wall)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "wall.h" const int INF = 1e9; const int N = 2e6 + 10; int ka[N], ki[N], ish[N]; int* a; int n; bool ha = 0; void minim(int, int, int, int, int, int); void maxim(int, int, int, int, int, int); void init() { for (int i = 0; i < N; i++) { ka[i] = 0; ki[i] = INF; } } void minim(int v, int l, int r, int tl, int tr, int h) { if (r < tl || tr < l) return; if (tl <= l && r <= tr) { ki[v] = min(ki[v], h); ka[v] = min(ka[v], ki[v]); ish[v] = 1; return; } int m = (l + r) / 2; if (ish[v]) { ish[v] = 0; ish[2 * v] = ish[2 * v + 1] = 1; maxim(2 * v, l, m, l, m, ka[v]); minim(2 * v, l, m, l, m, ki[v]); maxim(2 * v + 1, m + 1, r, m + 1, r, ka[v]); minim(2 * v + 1, m + 1, r, m + 1, r, ki[v]); } minim(2 * v, l, m, tl, tr, h); minim(2 * v + 1, m + 1, r, tl, tr, h); } void maxim(int v, int l, int r, int tl, int tr, int h) { if (tr < l || r < tl) return; if (tl <= l && r <= tr) { ka[v] = max(ka[v], h); ki[v] = max(ki[v], ka[v]); ish[v] = 1; return; } // cout << __LINE__ << endl; int m = (l + r) / 2; if (ish[v]) { ish[v] = 0; ish[2 * v] = ish[2 * v + 1] = 1; minim(2 * v, l, m, l, m, ki[v]); maxim(2 * v, l, m, l, m, ka[v]); minim(2 * v + 1, m + 1, r, m + 1, r, ki[v]); maxim(2 * v + 1, m + 1, r, m + 1, r, ka[v]); } maxim(2 * v, l, m, tl, tr, h); maxim(2 * v + 1, m + 1, r, tl, tr, h); } int get(int v, int l, int r, int x) { // if (x < l || r < x) return -1; if (l == r) { return ka[v]; } int m = (l + r) / 2; if (x <= m) return get(2 * v, l, m, x); else return get(2 * v + 1, m + 1, r, x); } void buildWall(int nn, int k, int op[], int left[], int right[], int height[], int finalHeight[]) { n = nn; init(); for (int i = 0; i < k; i++) { if (op[i] == 1) { maxim(1, 1, n, left[i] + 1, right[i] + 1, height[i]); // cout << "Maxim succesfull" << endl; } else { ha = 1; minim(1, 1, n, left[i] + 1, right[i] + 1, height[i]); ha = 0; // cout << "Minim succesfull" << endl; } /*for (int i = 1; i <= n; i++) { minim(1, 1, n, i, i, INF); maxim(1, 1, n, i, i, 0); cout << get(1, 1, n, i) << " "; } cout << endl;*/ } for (int i = 1; i <= n; i++) { minim(1, 1, n, i, i, INF); maxim(1, 1, n, i, i, 0); finalHeight[i - 1] = get(1, 1, n, i); } return; }

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

wall.cpp: In function 'void minim(int, int, int, int, int, int)':
wall.cpp:27:11: error: 'min' was not declared in this scope; did you mean 'std::min'?
   27 |   ki[v] = min(ki[v], h);
      |           ^~~
      |           std::min
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from wall.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3450:5: note: 'std::min' declared here
 3450 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
wall.cpp: In function 'void maxim(int, int, int, int, int, int)':
wall.cpp:51:11: error: 'max' was not declared in this scope; did you mean 'std::max'?
   51 |   ka[v] = max(ka[v], h);
      |           ^~~
      |           std::max
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from wall.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3462:5: note: 'std::max' declared here
 3462 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~