Submission #376224

#TimeUsernameProblemLanguageResultExecution timeMemory
376224wiwihoBitaro, who Leaps through Time (JOI19_timeleap)C++14
4 / 100
3 ms620 KiB
#include <bits/stdc++.h> #define eb emplace_back #define printv(a, b) { \ for(auto pv : a) b << pv << " "; \ b << "\n"; \ } #define mp make_pair #define F first #define S second using namespace std; typedef long long ll; using pll = pair<ll, ll>; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); int n, q; cin >> n >> q; assert(n <= 2000 && q <= 2000); vector<ll> l(n), r(n); for(int i = 1; i < n; i++) cin >> l[i] >> r[i]; while(q--){ int t; cin >> t; if(t == 1){ int x, c, d; cin >> x >> c >> d; l[x] = c; r[x] = d; continue; } ll a, b, c, d; cin >> a >> b >> c >> d; //cerr << a << " " << c << "\n"; ll ans = 0; ll now = b; if(a < c){ for(int i = a; i < c; i++){ now = max(now, l[i]); if(now >= r[i]){ ans += now - r[i] + 1; now = r[i] - 1; } now++; //cerr << i << " " << now << "\n"; } } else{ for(int i = a - 1; i >= c; i--){ now = max(now, l[i]); if(now >= r[i]){ ans += now - r[i] + 1; now = r[i] - 1; } now++; //cerr << i << " " << now << "\n"; } } if(now > d) ans += now - d; cout << ans << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...