이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |