Submission #1109391

#TimeUsernameProblemLanguageResultExecution timeMemory
1109391ro9669Progression (NOI20_progression)C++17
15 / 100
26 ms9288 KiB
#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 (stderr)

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);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...