Submission #105869

#TimeUsernameProblemLanguageResultExecution timeMemory
105869Alexa2001Bitaro, who Leaps through Time (JOI19_timeleap)C++17
4 / 100
261 ms22820 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int Nmax = 3e5 + 5; int q, n, L[Nmax], R[Nmax], a[Nmax], b[Nmax], c[Nmax], d[Nmax]; void subtask1() { int i, tip, a, b, c, d; while(q--) { cin >> tip >> a >> b >> c; if(tip == 2) cin >> d; if(tip == 1) { L[a] = b; R[a] = c; continue; } int t = b; ll ans = 0; if(a <= c) { for(i=a; i<c; ++i) { if(t >= R[i]) ans += t - R[i] + 1, t = R[i] - 1; else if(t < L[i]) t = L[i]; ++t; } if(t > d) ans += t - d; } else { for(i=a; i>c; --i) { if(t >= R[i-1]) ans += t - R[i-1] + 1, t = R[i-1] - 1; else if(t < L[i-1]) t = L[i-1]; ++t; } if(t > d) ans += t - d; } cout << ans << '\n'; } } int main() { // freopen("input", "r", stdin); cin.sync_with_stdio(false); int i; cin >> n >> q; for(i=1; i<n; ++i) cin >> L[i] >> R[i]; if(n <= 1000 && q <= 1000) { subtask1(); exit(0); } int tip; for(i=1; i<=q; ++i) cin >> tip >> a[i] >> b[i] >> c[i] >> d[i]; //solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...