제출 #376167

#제출 시각아이디문제언어결과실행 시간메모리
3761678e7Bitaro, who Leaps through Time (JOI19_timeleap)C++14
4 / 100
53 ms10860 KiB
//Challenge: Accepted #include <iostream> #include <algorithm> #include <vector> #include <utility> #include <set> #define ll long long #define maxn 200005 #define pii pair<ll, ll> #define ff first #define ss second #define mod 1000000007 #define io ios_base::sync_with_stdio(0);cin.tie(0); using namespace std; pii ti[maxn]; int main() { io int n, q; cin >> n >> q; for (int i = 1;i < n;i++) { cin >> ti[i].ff >> ti[i].ss; } while (q--) { int type; cin >> type; if (type == 1) { int p, s, e; cin >> p >> s >> e; ti[p] = make_pair(s, e); } else { int a, b, c, d; cin >> a >> b >> c >> d; ll ans = 0, cur = b, ind = c >= a ? a : a - 1, dir = c >= a ? 1 : -1; for (int pos = a;pos!= c;pos += dir, ind += dir) { if (cur >= ti[ind].ss) { ans += cur - ti[ind].ss + 1; cur = ti[ind].ss; } else { cur = max(cur, ti[ind].ff) + 1; } } if (cur >= d) ans += cur - d; cout << ans << "\n"; } } } /* 3 3 0 5 0 5 2 1 3 3 3 1 2 0 1 2 1 3 3 3 5 5 3 5 4 8 2 6 5 10 2 5 3 1 10 2 2 6 5 6 1 3 4 6 2 3 3 4 3 2 4 5 1 5 7 7 112103440 659752416 86280800 902409187 104535475 965602300 198700180 945132880 137957976 501365807 257419446 565237610 2 4 646977260 7 915994878 2 1 221570340 6 606208433 2 7 948545948 4 604273995 2 7 247791098 5 944822313 2 7 250362511 2 50167280 2 3 364109400 4 555412865 2 7 33882587 7 186961394 7 7 535825574 705426142 964175291 996597835 481817391 649559926 4519006 410772613 74521477 274584126 256535565 899389890 1 6 511428966 602601933 1 1 69986642 201421232 2 3 636443425 4 625975977 1 6 235225515 405336399 2 3 866680458 3 701821857 1 6 180606048 900533151 1 6 612564160 720179605 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...