제출 #136665

#제출 시각아이디문제언어결과실행 시간메모리
136665turbat원숭이와 사과 나무 (IZhO12_apple)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define N 1000000000 int m, x, y, c, d, s; struct segment{ segment *l; segment *r; int cnt = 0; } root; void update (segment *seg, int L, int R, int l, int r){ if (seg->cnt == R - L + 1) return; if (L > r || R < l) return; if (l <= L && R <= r){ seg->cnt = R - L + 1; return; } int mid = (L + R)/2; if (!seg->l) seg->l = new segment(); update(seg->l, L, mid, l, r); if (!seg->r) seg->r = new segment(); update(seg->r, mid + 1, R, l, r); seg->cnt = seg->l->cnt + seg->r->cnt; } int query(segment *seg, int L, int R, int l, int r){ if (L > r || R < l) return 0; if (l <= L && R <= r) return seg->cnt; int mid = (L + R)/2, ans = 0; if (seg->l) ans = query(seg->l, L, mid, l, r); if (seg->r) ans += query(seg->r, mid + 1, R, l, r); return ans; } int main (){ cin >> m; while (m--){ cin >> d>> x>> y; if (d == 2) update(root, 1, N, x + c, y + c); else { c = query(root, 1, N, x + c, y + c); cout << c<< endl; } } }

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

apple.cpp: In function 'int main()':
apple.cpp:36:50: error: cannot convert 'segment' to 'segment*' for argument '1' to 'void update(segment*, int, int, int, int)'
       if (d == 2) update(root, 1, N, x + c, y + c);
                                                  ^
apple.cpp:38:42: error: cannot convert 'segment' to 'segment*' for argument '1' to 'int query(segment*, int, int, int, int)'
        c = query(root, 1, N, x + c, y + c);
                                          ^