Submission #105476

#TimeUsernameProblemLanguageResultExecution timeMemory
105476realityBitaro, who Leaps through Time (JOI19_timeleap)C++17
4 / 100
3007 ms3044 KiB
#include "bits/stdc++.h" using namespace std; #define fi first #define se second #define ll long long #define dbg(v) cerr<<#v<<" = "<<v<<'\n' #define vi vector<int> #define vl vector <ll> #define pii pair<int,int> #define vii vector < pii > #define mp make_pair #define db long double #define pb push_back #define all(s) s.begin(),s.end() template < class P , class Q > ostream& operator<<(ostream& stream, pair < P , Q > v){ stream << "(" << v.fi << ',' << v.se << ")"; return stream;} template < class T > ostream& operator<<(ostream& stream, const vector<T> v){ stream << "[ "; for (int i=0; i<(int)v.size(); i++) stream << v[i] << " "; stream << "]"; return stream;} template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;} template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;} const int N = 1e6 + 5; int l[N],r[N]; int main(void) { int n,q; cin.tie(0); ios_base :: sync_with_stdio(0); cin>>n>>q; for (int i = 1;i < n;++i) cin>>l[i]>>r[i]; while (q --) { int tp; cin>>tp; if (tp == 1) { int pos,lf,rg; cin>>pos>>lf>>rg; l[pos] = lf; r[pos] = rg; } else { int a,b,c,d; cin>>a>>b>>c>>d; ll ans = 0; if (a > c) { for (int i = a;i > c;--i) { smax(b,l[i - 1]); ans += max(0,b - (r[i - 1] - 1)); smin(b,r[i - 1] - 1); ++b; } ans += max(0,b - d); } else { for (int i = a;i < c;++i) { smax(b,l[i]); ans += max(0,b - (r[i] - 1)); smin(b,r[i] - 1); ++b; } ans += max(0,b - d); } cout << ans << '\n'; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...