제출 #652813

#제출 시각아이디문제언어결과실행 시간메모리
652813amukkalir원숭이와 사과 나무 (IZhO12_apple)C++17
0 / 100
1 ms212 KiB
#include <bits/stdc++.h> using namespace std; const int nax = 1e5; map<long long,int> tree; map<long long,int> lazy; int m; void cek (int idx, int l, int r) { if (!lazy.count(idx)) return; tree[idx] = lazy[idx]; int m = (l+r)>>1; if (l!=r) { lazy[idx<<1] = m-l+1; lazy[idx<<1|1] = r-(m+1)+1; } lazy.erase(idx); } void upd (int fr, int to, int idx = 1, int l = 1, int r = 1e9) { cek(idx, l, r); if (fr <= l && r <= to) { lazy[idx] = r-l+1; cek(idx,l,r) ; } else if (r < fr || l > to) return; else { int m = (l+r)>>1; upd(fr, to, idx<<1,l,m); upd(fr, to, idx<<1|1, m+1,r); tree[idx] = tree[idx<<1] + tree[idx<<1|1]; } } int get (int fr, int to, int idx = 1, int l = 1, int r = 1e9) { cek(idx, l, r); if (!tree.count(idx)) return 0; if (fr <= l && r <= to) return tree[idx]; else if (r < fr || l > to) return 0; else { int m = (l+r)>>1; return get(fr, to, idx<<1, l, m) + get(fr, to, idx<<1|1, m+1, r); } } signed main() { scanf("%d", &m); int c = 0; while (m--) { int d, x, y; scanf("%d %d %d", &d, &x, &y); x += c; y += c; if (d == 1) { int ans = get(x, y); c += ans; printf("%d\n",ans); } else { upd(x,y); } } } /* */

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

apple.cpp: In function 'int main()':
apple.cpp:49:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   49 |     scanf("%d", &m);
      |     ~~~~~^~~~~~~~~~
apple.cpp:53:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   53 |         scanf("%d %d %d", &d, &x, &y);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...