Submission #1284869

#TimeUsernameProblemLanguageResultExecution timeMemory
1284869zxzuamMonkey and Apple-trees (IZhO12_apple)C++20
0 / 100
145 ms327680 KiB
#include <bits/stdc++.h> #define int long long using ll = long long; using namespace std; constexpr int maxn = 1E7 + 61; vector <int> t(maxn * 4), f(maxn * 4); int C; void push(int v, int tl, int tr) { if(f[v]) { t[v] = (tr - tl + 1); if(tr > tl) { f[v * 2] = f[v * 2 + 1] = f[v]; } f[v] = 0; } } void upd(int v, int tl, int tr, int l, int r) { push(v, tl, tr); if(l > tr || tl > r) return; if(l <= tl && tr <= r) { f[v] = 1; push(v, tl, tr); return; } int tm = (tl + tr) / 2; upd(v * 2, tl, tm, l, r); upd(v * 2 + 1, tm + 1, tr, l, r); t[v] = t[v * 2] + t[v * 2 + 1]; } int get(int v, int tl, int tr, int l, int r) { push(v, tl, tr); if(l > tr || tl > r) return 0; if(l <= tl && tr <= r) return t[v]; int tm = (tl + tr) / 2; return get(v * 2, tl, tm, l, r) + get(v * 2 + 1, tm + 1, tr, l, r); } void orz() { int N; cin >> N; vector <int> D(N + 1), X(N + 1), Y(N + 1); for(int i = 1; i <= N; i++) { cin >> D[i] >> X[i] >> Y[i]; } for(int i = 1; i <= N; i++) { X[i] += C; Y[i] += C; if(D[i] == 2) { upd(1, 1, maxn, X[i], Y[i]); } else{ C = get(1, 1, maxn, X[i], Y[i]); cout << C << '\n'; } } } int32_t main() { ios_base::sync_with_stdio(false), cin.tie(nullptr); freopen("f.in", "r", stdin); freopen("f.out", "w", stdout); int T = 1; //cin >> T; while(T--) orz(); return 0; }

Compilation message (stderr)

apple.cpp: In function 'int32_t main()':
apple.cpp:58:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   58 |     freopen("f.in", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~
apple.cpp:59:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   59 |     freopen("f.out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...