이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define x first
#define y second
#define all(v) v.begin(), v.end()
#define chkmax(a, b) a = max(a, b)
#define chkmin(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
const int block = 600;
const int MAX_N = 3e5 + 5;
pii dpl[MAX_N], dpr[MAX_N];
vii optl[MAX_N], optr[MAX_N];
void Update(int l, int r) {
}
int Query(int l, int r) {
}
int L[MAX_N], R[MAX_N], t[MAX_N], a[MAX_N], b[MAX_N], c[MAX_N], d[MAX_N];
int l[MAX_N], r[MAX_N];
int main() {
int n, q;
cin >> n >> q;
for (int i = 0; i + 1 < n; i++) cin >> L[i] >> R[i];
for (int i = 0; i < q; i++) {
cin >> t[i] >> a[i] >> b[i] >> c[i];
if (t[i] == 2) cin >> d[i];
}
for (int i = 0; i < q; i++) a[i]--, c[i]--;
for (int i = 0; i < n; i++) R[i]--;
for (int i = 0; i < n; i++) l[i] = L[i], r[i] = R[i];
for (int i = 0; i < q; i++) {
if (t[i] == 1) {
l[a[i]] = b[i], r[a[i]] = c[i];
continue;
}
if (a[i] <= c[i]) {
ll ti = b[i], ans = 0;
for (int j = a[i]; j < c[i]; j++) {
if (ti < l[j]) ti = l[j];
else if (ti > r[j]) ans += ti - r[j], ti = r[j];
ti++;
}
ans += max<ll>(0, ti - d[i]);
cout << ans << '\n';
} else {
ll ti = b[i], ans = 0;
for (int j = a[i] - 1; j >= c[i]; j--) {
if (ti < l[j]) ti = l[j];
else if (ti >= r[j]) ans += ti - r[j], ti = r[j];
ti++;
}
ans += max<ll>(0, ti - d[i]);
cout << ans << '\n';
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
timeleap.cpp: In function 'int Query(int, int)':
timeleap.cpp:26:1: warning: no return statement in function returning non-void [-Wreturn-type]
26 | }
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |