답안 #1109391

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1109391 2024-11-06T15:42:34 Z ro9669 Progression (NOI20_progression) C++17
15 / 100
26 ms 9288 KB
#include <bits/stdc++.h>
#define fi first
#define se second
#define all(v) v.begin() , v.end()
#define sz(v) int(v.size())
#define unq(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
using namespace std;

typedef long long ll;
typedef pair<int , int> ii;
typedef pair<long long , int> lli;

const int maxN = int(2e5)+7;

int n , q; ll a[maxN] , b[maxN];

void solve(){
    cin >> n >> q;
    for (int i = 1 ; i <= n ; i++) cin >> a[i];
    for (int i = 1 ; i <= q ; i++){
        int t; cin >> t;
        if (t == 1){
            int l , r , s , c;
            cin >> l >> r >> s >> c;
            for (int i = l ; i <= r ; i++){
                a[i] += 1ll * c * (i - l) + s;
            }
        }
        if (t == 2){
            int l , r , s , c;
            cin >> l >> r >> s >> c;
            for (int i = l ; i <= r ; i++){
                a[i] = 1ll * c * (i - l) + s;
            }
        }
        if (t == 3){
            int l , r;
            cin >> l >> r;
            int ans = 1;
            for (int i = l ; i < r ; i++) b[i] = a[i + 1] - a[i];
            int i = l , j = i - 1;
            while (i < r){
                while (j + 1 < r && b[i] == b[j + 1]) j++;
                ans = max(ans , j - i + 2);
                i = j + 1;
            }
            cout << ans << "\n";
        }
    }
}

#define name "A"

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    if (fopen(name".INP" , "r")){
        freopen(name".INP" , "r" , stdin);
        freopen(name".ans" , "w" , stdout);
    }
    int t = 1; //cin >> t;
    while (t--) solve();
    return 0;
}

Compilation message

Progression.cpp: In function 'int main()':
Progression.cpp:57:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   57 |         freopen(name".INP" , "r" , stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
Progression.cpp:58:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   58 |         freopen(name".ans" , "w" , stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 26 ms 9288 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2384 KB Output is correct
2 Correct 2 ms 2384 KB Output is correct
3 Correct 1 ms 2552 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2384 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 2 ms 2384 KB Output is correct
9 Correct 1 ms 2384 KB Output is correct
10 Correct 2 ms 2384 KB Output is correct
11 Correct 2 ms 2384 KB Output is correct
12 Correct 2 ms 2384 KB Output is correct
13 Correct 2 ms 2384 KB Output is correct
14 Correct 2 ms 2384 KB Output is correct
15 Correct 2 ms 2464 KB Output is correct
16 Correct 2 ms 2384 KB Output is correct
17 Correct 2 ms 2384 KB Output is correct
18 Correct 2 ms 2556 KB Output is correct
19 Correct 1 ms 2384 KB Output is correct
20 Correct 1 ms 2384 KB Output is correct
21 Correct 2 ms 2552 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 21 ms 4944 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 15 ms 4944 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 21 ms 4944 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 26 ms 9288 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -