#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, n+1)
#define RREP(i, n) for (int i = (n)-1; i >= 0; i--)
#define pb push_back
#define pii pair<int, int>
#define f first
#define s second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)((x).size())
#define endl '\n'
const ll maxn = 3e5+5;
const ll inf = (1ll<<60);
const ll mod = 1e9+7;
signed main(){
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int n, q; cin>>n>>q;
vector<pii> vc(n);
REP1(i, n-1){
cin>>vc[i].f>>vc[i].s;
}
REP(z, q){
int t; cin>>t;
if (t == 1){
int x; cin>>x;
cin>>vc[x].f>>vc[x].s;
}
else {
int a, b, c, d; cin>>a>>b>>c>>d;
int res = 0, cur = b;
FOR(i, a, c){
if (cur < vc[i].f){
cur = vc[i].f+1;
}
else if (vc[i].f <= cur && cur < vc[i].s){
cur++;
}
else {
res += (cur-vc[i].s)+1;
cur = vc[i].s;
}
}
for (int i = a; i > c; i--){
if (cur < vc[i-1].f){
cur = vc[i-1].f+1;
}
else if (vc[i].f <= cur && cur < vc[i-1].s){
cur++;
}
else {
res += (cur-vc[i-1].s)+1;
cur = vc[i-1].s;
}
}
res += max(0ll, cur-d);
cout<<res<<endl;
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3033 ms |
10660 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |