// Author: 4uckd3v - Nguyen Cao Duc
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX_N = 3e5;
const int MOD = 1e9 + 7;
struct Query {
int type, l, r, s, c;
Query() {};
Query(int type, int l, int r) : type(type), l(l), r(r) {};
Query(int type, int l, int r, int s, int c) : type(type), l(l), r(r), s(s), c(c) {};
};
int n, q;
int a[MAX_N + 5];
vector<Query> queries;
namespace SUBTASK_1 {
const int N = MAX_N;
bool checkSubtask() {
for (const Query &query : queries)
if (query.l != 1 || query.r != n) return false;
return true;
};
void Solve() {
int res = 1, cnt = 1;
if (n > 1) res = 2, cnt = 2;
for (int i = 3; i <= n; i++) {
if (a[i] - a[i - 1] == a[i - 1] - a[i - 2])
cnt++;
else
cnt = 2;
res = max(res, cnt);
};
for (const Query &query : queries) {
int type = query.type, l = query.l, r = query.r;
if (type == 3) {
cout << res << '\n';
continue;
};
if (type == 2) res = n;
};
};
}; // namespace SUBTASK_1
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
if (fopen("MAIN.INP", "r")) {
freopen("MAIN.INP", "r", stdin);
freopen("MAIN.OUT", "w", stdout);
};
cin >> n >> q;
for (int i = 1; i <= n; i++) {
cin >> a[i];
};
queries.resize(q);
for (Query &query : queries) {
cin >> query.type >> query.l >> query.r;
if (query.type != 3) cin >> query.s >> query.c;
};
SUBTASK_1::Solve();
};
컴파일 시 표준 에러 (stderr) 메시지
Progression.cpp: In function 'int main()':
Progression.cpp:59:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
59 | freopen("MAIN.INP", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Progression.cpp:60:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
60 | freopen("MAIN.OUT", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# | 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... |