제출 #672937

#제출 시각아이디문제언어결과실행 시간메모리
672937Alihan_8Monkey and Apple-trees (IZhO12_apple)C++17
0 / 100
45 ms33256 KiB
#include <bits/stdc++.h> // include <ext/pb_ds/assoc_container.hpp> // include <ext/pb_ds/tree_policy.hpp> // using namespace __gnu_pbds; using namespace std; #define all(x) x.begin(), x.end() #define pb push_back // define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> #define mpr make_pair #define ln '\n' void IO(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);} #define int long long const int N = 1e6+1; int T[N*4], lazy[N*4]; void push(int v, int l, int r){ if ( !lazy[v] ) return; if ( l != r ){ lazy[v*2] = lazy[v]; lazy[v*2+1] = lazy[v]; } T[v] = (r-l+1); lazy[v] = 0; } void upd(int v, int l, int r, int tl, int tr){ push(v, l, r); if ( l > tr or r < tl ) return; if ( tl <= l and tr >= r ){ lazy[v]++; push(v, l, r); return; } int md = (l+r)>>1; upd(v*2, l, md, tl, tr), upd(v*2+1, md+1, r, tl, tr); T[v] = T[v*2]+T[v*2+1]; } int get(int v, int l, int r, int tl, int tr){ push(v, l, r); if ( l > tr or tl > r ) return 0; if ( tl <= l and tr >= r ) return T[v]; int md = (l+r)>>1; return get(v*2, l, md, tl, tr)+get(v*2+1, md+1, r, tl, tr); } signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int q; cin >> q; int C = 0; while ( q-- ){ int t, x, y; cin >> t >> x >> y; x += C, y += C; if ( t == 1 ){ int res = get(1, 1, N-1, x, y); cout << res << ln; C = res; } else upd(1, 1, N-1, x, y); } cout << '\n'; }

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

apple.cpp: In function 'void IO(std::string)':
apple.cpp:11:29: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 | void IO(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
      |                      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
apple.cpp:11:70: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 | void IO(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
      |                                                               ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...