제출 #416843

#제출 시각아이디문제언어결과실행 시간메모리
416843DEQK벽 (IOI14_wall)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #define ll long long #define ls u << 1 #define rs u << 1 | 1 using namespace std; const int N = 2e6 + 11; int kp[N * 4]; int mn[N * 4], mx[N * 4]; void push(int u) { if(kp[u] == -1) return; mn[ls] = mn[rs] = kp[u]; mx[ls] = mx[rs] = kp[u]; kp[ls] = kp[rs] = kp[u]; kp[u] = -1; } void add(int ql,int qr,int x,int u,int l,int r) { if(ql > r || l > qr || mn[u] >= x) return; if(ql <= l && r <= qr) { if(mx[u] <= x) { kp[u] = x; return; } } push(u); int m = l + r >> 1; add(ql, qr, x, ls, l, m); add(ql, qr, x, rs, m + 1, r); mn[u] = min(mn[ls], mn[rs]); mx[u] = max(mx[ls], mx[rs]); } void del(int ql,int qr,int x,int u,int l,int r) { if(ql > r || l > qr || mx[u] <= x) return; if(ql <= l && r <= qr) { if(mn[u] >= x) { kp[u] = x; return; } } push(u); int m = l + r >> 1; del(ql, qr, x, ls, l, m); del(ql, qr, x, rs, m + 1, r); mn[u] = min(mn[ls], mn[rs]); mx[u] = max(mx[ls], mx[rs]); } int get(int p,int u,int l,int r) { if(l == r) { return mn[u]; } push(u); int m = l + r >> 1; if(p <= m) return get(p, ls, l, m); else return get(p, rs, m + 1, r); } void buildWall(int n,int k, vector<int> op, vector<int> left, vector<int> right, vector<int> height, vector<int> finalHeight) { memset(kp, -1, sizeof(kp)); for(int i = 0; i < k; i++) { int l = left[i], r = right[i], type = op[i], x = op[i]; if(type == 1) { add(l, r, x, 1, 0, n - 1); } else { del(l, r, x, 1, 0, n - 1); } } for(int i = 0; i < n; i++) { finalHeight[i] = get(i, 1, 0, n - 1); } }

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

wall.cpp: In function 'void add(int, int, int, int, int, int)':
wall.cpp:26:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   26 |  int m = l + r >> 1;
      |          ~~^~~
wall.cpp: In function 'void del(int, int, int, int, int, int)':
wall.cpp:41:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   41 |  int m = l + r >> 1;
      |          ~~^~~
wall.cpp: In function 'int get(int, int, int, int)':
wall.cpp:52:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   52 |  int m = l + r >> 1;
      |          ~~^~~
/usr/bin/ld: /tmp/ccJ4793m.o: in function `main':
grader.cpp:(.text.startup+0x133): undefined reference to `buildWall(int, int, int*, int*, int*, int*, int*)'
collect2: error: ld returned 1 exit status