제출 #653572

#제출 시각아이디문제언어결과실행 시간메모리
653572amukkalir원숭이와 사과 나무 (IZhO12_apple)C++17
0 / 100
536 ms262144 KiB
#include <bits/stdc++.h> using namespace std; const int nax = 1e9; struct node { node *l_child, *r_child; int val; node () { l_child=r_child=nullptr; val=0; } }; node *tree, *lazy; int m; void verif(node* &u) { if(!u) u=new node; } void cek (node* &tr, node* &lz, int l, int r) { verif(tr); verif(lz); if(lz->val==0)return; tr->val=r-l+1; if(l!=r) { verif(lz->l_child); lz->l_child->val = 1; verif(lz->r_child); lz->r_child->val = 1; } lz->val=0; } void upd (int fr, int to, node* &now=tree, node* &now_lazy=lazy, int l = 1, int r = nax) { cek(now, now_lazy, l, r); if (fr <= l && r <= to) { now_lazy->val = 1; cek(now, now_lazy, l, r); } else if (r < fr || l > to) { return; } else { int m = (l+r)>>1; upd(fr, to, now->l_child, now_lazy->l_child, l, m); upd(fr, to, now->r_child, now_lazy->r_child, m+1,r); now->val = now->l_child->val + now->r_child->val; } } int get (int fr, int to, node* &now=tree, node* &now_lazy=lazy, int l = 1, int r = nax) { cek(now, now_lazy, l, r); if (fr <= l && r <= to) return now->val; else if (r < fr || l > to) return 0; else { int m = (l+r)>>1; return get(fr, to, now->l_child, now_lazy->l_child, l, m) + get(fr, to, now->r_child, now_lazy->r_child, m+1, r); } } signed main() { verif(tree); verif(lazy); 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:63:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   63 |     scanf("%d", &m);
      |     ~~~~~^~~~~~~~~~
apple.cpp:67:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   67 |         scanf("%d %d %d", &d, &x, &y);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...