# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
682165 | 2023-01-16T02:46:40 Z | vuavisao | Progression (NOI20_progression) | C++14 | 3000 ms | 24140 KB |
#include<bits/stdc++.h> #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #define ll long long using namespace std; const ll N = 3e5 + 10; struct que { ll type = 0; ll l = 0, r = 0; ll s = 0, c = 0; que() {}; friend istream& operator >> (istream& is, que& other) { is >> other.type >> other.l >> other.r; if(other.type <= 2) is >> other.s >> other.c; return is; } }; ll n, q; ll a[N]; que qq[N]; namespace sub1 { bool check() { for(ll i = 1; i <= q; ++ i) { if(qq[i].l != 1 || qq[i].r != n) return false; } return true; } ll res = 1; void solve() { for(ll i = 1, j; i < n; i = j - 1) { j = i + 1; ll s = a[j] - a[i]; while(j <= n && a[j] - a[j - 1] == s) ++ j; res = max(res, j - i); } for(ll i = 1; i <= q; ++ i) { const auto& psy = qq[i]; if(psy.type == 3) cout << res << '\n'; else if(psy.type == 2) { res = n; } } } } namespace sub2 { void solve() { auto get_far = [&] (ll l, ll r) -> ll { ll res = 1; for(ll i = l, j; i < r; i = j - 1) { j = i + 1; ll s = a[j] - a[i]; while(j <= r && a[j] - a[j - 1] == s) ++ j; res = max(res, j - i); } return res; }; for(ll i = 1; i <= q; ++ i) { const auto& psy = qq[i]; ll type = psy.type; if(type == 1) { ll add[2] = {psy.s, psy.c}; for(ll i = psy.l; i <= psy.r; ++ i) { a[i] += add[0]; add[0] += add[1]; } } else if(type == 2) { ll add[2] = {psy.s, psy.c}; for(ll i = psy.l; i <= psy.r; ++ i) { a[i] = add[0]; add[0] += add[1]; } } else { // cout << psy.l << ' ' << psy.r << '\n'; cout << get_far(psy.l, psy.r) << '\n'; } } } } int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (fopen("Progression.inp", "r")) { freopen("Progression.inp", "r", stdin); freopen("Progression.out", "w", stdout); } cin >> n >> q; for(ll i = 1; i <= n; ++ i) cin >> a[i]; for(ll i = 1; i <= q; ++ i) cin >> qq[i]; if(sub1::check()) { sub1::solve(); return 0; } // if(sub3::check()) { // sub3::solve(); // return 0; // } sub2::solve(); return 0; } /// Code by vuavisao
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 127 ms | 22948 KB | Output is correct |
2 | Correct | 94 ms | 15236 KB | Output is correct |
3 | Correct | 102 ms | 15180 KB | Output is correct |
4 | Correct | 74 ms | 15244 KB | Output is correct |
5 | Correct | 73 ms | 15364 KB | Output is correct |
6 | Correct | 78 ms | 15308 KB | Output is correct |
7 | Correct | 90 ms | 15180 KB | Output is correct |
8 | Correct | 7 ms | 12000 KB | Output is correct |
9 | Correct | 6 ms | 11988 KB | Output is correct |
10 | Correct | 6 ms | 11988 KB | Output is correct |
11 | Correct | 114 ms | 22996 KB | Output is correct |
12 | Correct | 121 ms | 22860 KB | Output is correct |
13 | Correct | 132 ms | 23244 KB | Output is correct |
14 | Correct | 115 ms | 23336 KB | Output is correct |
15 | Correct | 120 ms | 23080 KB | Output is correct |
16 | Correct | 137 ms | 22860 KB | Output is correct |
17 | Correct | 120 ms | 22824 KB | Output is correct |
18 | Correct | 124 ms | 22840 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 11988 KB | Output is correct |
2 | Correct | 6 ms | 12080 KB | Output is correct |
3 | Correct | 6 ms | 12076 KB | Output is correct |
4 | Correct | 7 ms | 12076 KB | Output is correct |
5 | Correct | 6 ms | 12080 KB | Output is correct |
6 | Correct | 6 ms | 12116 KB | Output is correct |
7 | Correct | 6 ms | 11988 KB | Output is correct |
8 | Correct | 6 ms | 12092 KB | Output is correct |
9 | Correct | 6 ms | 11988 KB | Output is correct |
10 | Correct | 6 ms | 11988 KB | Output is correct |
11 | Correct | 7 ms | 12080 KB | Output is correct |
12 | Correct | 6 ms | 11988 KB | Output is correct |
13 | Correct | 6 ms | 11988 KB | Output is correct |
14 | Correct | 5 ms | 11988 KB | Output is correct |
15 | Correct | 6 ms | 11988 KB | Output is correct |
16 | Correct | 7 ms | 11988 KB | Output is correct |
17 | Correct | 6 ms | 11988 KB | Output is correct |
18 | Correct | 6 ms | 12088 KB | Output is correct |
19 | Correct | 6 ms | 11988 KB | Output is correct |
20 | Correct | 6 ms | 11988 KB | Output is correct |
21 | Correct | 6 ms | 12020 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 143 ms | 21344 KB | Output is correct |
2 | Correct | 67 ms | 14668 KB | Output is correct |
3 | Correct | 66 ms | 14732 KB | Output is correct |
4 | Correct | 78 ms | 14728 KB | Output is correct |
5 | Correct | 84 ms | 14864 KB | Output is correct |
6 | Correct | 70 ms | 14860 KB | Output is correct |
7 | Correct | 67 ms | 14852 KB | Output is correct |
8 | Correct | 6 ms | 11988 KB | Output is correct |
9 | Correct | 6 ms | 11984 KB | Output is correct |
10 | Correct | 5 ms | 11988 KB | Output is correct |
11 | Execution timed out | 3080 ms | 19444 KB | Time limit exceeded |
12 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 322 ms | 24140 KB | Output is correct |
2 | Correct | 83 ms | 15388 KB | Output is correct |
3 | Correct | 79 ms | 15372 KB | Output is correct |
4 | Correct | 78 ms | 15368 KB | Output is correct |
5 | Correct | 79 ms | 15420 KB | Output is correct |
6 | Correct | 97 ms | 15312 KB | Output is correct |
7 | Correct | 82 ms | 15356 KB | Output is correct |
8 | Correct | 6 ms | 11988 KB | Output is correct |
9 | Correct | 6 ms | 12076 KB | Output is correct |
10 | Correct | 5 ms | 12084 KB | Output is correct |
11 | Execution timed out | 3087 ms | 20816 KB | Time limit exceeded |
12 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 143 ms | 21344 KB | Output is correct |
2 | Correct | 67 ms | 14668 KB | Output is correct |
3 | Correct | 66 ms | 14732 KB | Output is correct |
4 | Correct | 78 ms | 14728 KB | Output is correct |
5 | Correct | 84 ms | 14864 KB | Output is correct |
6 | Correct | 70 ms | 14860 KB | Output is correct |
7 | Correct | 67 ms | 14852 KB | Output is correct |
8 | Correct | 6 ms | 11988 KB | Output is correct |
9 | Correct | 6 ms | 11984 KB | Output is correct |
10 | Correct | 5 ms | 11988 KB | Output is correct |
11 | Execution timed out | 3080 ms | 19444 KB | Time limit exceeded |
12 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 127 ms | 22948 KB | Output is correct |
2 | Correct | 94 ms | 15236 KB | Output is correct |
3 | Correct | 102 ms | 15180 KB | Output is correct |
4 | Correct | 74 ms | 15244 KB | Output is correct |
5 | Correct | 73 ms | 15364 KB | Output is correct |
6 | Correct | 78 ms | 15308 KB | Output is correct |
7 | Correct | 90 ms | 15180 KB | Output is correct |
8 | Correct | 7 ms | 12000 KB | Output is correct |
9 | Correct | 6 ms | 11988 KB | Output is correct |
10 | Correct | 6 ms | 11988 KB | Output is correct |
11 | Correct | 114 ms | 22996 KB | Output is correct |
12 | Correct | 121 ms | 22860 KB | Output is correct |
13 | Correct | 132 ms | 23244 KB | Output is correct |
14 | Correct | 115 ms | 23336 KB | Output is correct |
15 | Correct | 120 ms | 23080 KB | Output is correct |
16 | Correct | 137 ms | 22860 KB | Output is correct |
17 | Correct | 120 ms | 22824 KB | Output is correct |
18 | Correct | 124 ms | 22840 KB | Output is correct |
19 | Correct | 6 ms | 11988 KB | Output is correct |
20 | Correct | 6 ms | 12080 KB | Output is correct |
21 | Correct | 6 ms | 12076 KB | Output is correct |
22 | Correct | 7 ms | 12076 KB | Output is correct |
23 | Correct | 6 ms | 12080 KB | Output is correct |
24 | Correct | 6 ms | 12116 KB | Output is correct |
25 | Correct | 6 ms | 11988 KB | Output is correct |
26 | Correct | 6 ms | 12092 KB | Output is correct |
27 | Correct | 6 ms | 11988 KB | Output is correct |
28 | Correct | 6 ms | 11988 KB | Output is correct |
29 | Correct | 7 ms | 12080 KB | Output is correct |
30 | Correct | 6 ms | 11988 KB | Output is correct |
31 | Correct | 6 ms | 11988 KB | Output is correct |
32 | Correct | 5 ms | 11988 KB | Output is correct |
33 | Correct | 6 ms | 11988 KB | Output is correct |
34 | Correct | 7 ms | 11988 KB | Output is correct |
35 | Correct | 6 ms | 11988 KB | Output is correct |
36 | Correct | 6 ms | 12088 KB | Output is correct |
37 | Correct | 6 ms | 11988 KB | Output is correct |
38 | Correct | 6 ms | 11988 KB | Output is correct |
39 | Correct | 6 ms | 12020 KB | Output is correct |
40 | Correct | 143 ms | 21344 KB | Output is correct |
41 | Correct | 67 ms | 14668 KB | Output is correct |
42 | Correct | 66 ms | 14732 KB | Output is correct |
43 | Correct | 78 ms | 14728 KB | Output is correct |
44 | Correct | 84 ms | 14864 KB | Output is correct |
45 | Correct | 70 ms | 14860 KB | Output is correct |
46 | Correct | 67 ms | 14852 KB | Output is correct |
47 | Correct | 6 ms | 11988 KB | Output is correct |
48 | Correct | 6 ms | 11984 KB | Output is correct |
49 | Correct | 5 ms | 11988 KB | Output is correct |
50 | Execution timed out | 3080 ms | 19444 KB | Time limit exceeded |
51 | Halted | 0 ms | 0 KB | - |