이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define f first
#define s second
#define endl "\n"
const int N = 2e5 + 5, mod = 1e9 + 7; //!
int t, d[N], a[N];
main() {
ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
int n, q;
cin >> n >> q;
for(int i = 1; i <= n; i++) {
cin >> a[i];
if(i > 1) {
d[i - 1] = a[i] - a[i - 1];
}
}
// ai - a(i - 1) - (a(i - 1) - a(i - 2)) = ai - 2*a(i-1) + a(i-2)
for(int i = 1; i <= q; i++) {
int t;
cin >> t;
if(t < 3) {
int l, r, s, c;
cin >> l >> r >> s >> c;
if(t == 1) {
for(int j = l; j <= r; j++) a[j] += (j - l) * c + s;
if(l > 1)
d[l - 1] += s;
for(int j = l ; j <= r - 1; j++) {
d[j] += c;
}
d[r] -= s + (r - l) * c;
}
else {
for(int j = l; j <= r; j++) a[j] = (j - l) * c + s;
for(int j = l ; j <= r - 1; j++) {
d[j] = c;
}
d[l - 1] = a[l] - a[l - 1];
d[r] = d[r + 1] - d[r];
}
continue;
}
int l, r;
cin >> l >> r;
int ans = 2;
ans = min(ans, r - l + 1);
r -= 1;
for(int k = l; k <= r; k++) {
int j = k - 1;
while(j < r && d[k] == d[j + 1]) ++j;
ans = max(ans, j - k + 2);
k = j;
}
cout << ans << endl;
}
}
컴파일 시 표준 에러 (stderr) 메시지
Progression.cpp:10:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
10 | main() {
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |