Submission #689686

# Submission time Handle Problem Language Result Execution time Memory
689686 2023-01-29T05:54:03 Z true22 Progression (NOI20_progression) C++14
15 / 100
3000 ms 4080 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long double ld;

typedef pair<ll, ll> pl;
typedef vector<ll> vl;   
typedef vector<pl> vp;

#define nl "\n"
#define fr first
#define sc second
#define pb push_back

#define all(x) x.begin(), x.end()
#define fur(i, a, b) for(ll i = a; i <= b; ++i)
#define ruf(i, a, b) for(ll i = a; i >= b; --i)
#define pv(x) for(auto k : x){cout << k << " ";} cout << nl

ll n;
vl d;

void patch(ll l, ll r, ll s, ll c){
    fur(i, l, r)
        d[i] += s + (i - l)*c;
}

void rewrite(ll l, ll r, ll s, ll c){
    fur(i, l, r)
        d[i] = s + (i - l)*c;
}

ll lenpro(ll l, ll r){
    if (l == r){
        return 1;
    }
    
    ll mxl = 1;
    ll k = d[l + 1] - d[l];
    ll len = 1;
    fur(i, l + 1, r){
        if (d[i] - d[i - 1] == k){
            len++;
            mxl = max(len, mxl);
        }else{
            len = 2;
            k = d[i] - d[i - 1]; 
        }
    }   
    return mxl;
}


void solve(){
    ll t;
    cin >> t;
    if (t == 3){
     //   cout << "evaluate" << nl;
        ll l, r;
        cin >> l >> r;
    //    cout << "in [" << l << ", " << r << "] : " << lenpro(l, r) << nl; 
        cout << lenpro(l, r) << nl;
    }else if (t == 2){
        // rewrite
        ll l, r, s, c;
        cin >> l >> r >> s >> c;
        rewrite(l, r, s, c);
    }else{
        ll l, r, s, c;
        cin >> l >> r >> s >> c;
        patch(l, r, s, c);
    }
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);

    ll q;
    cin >> n >> q;
    d.resize(n + 1);
    fur(i, 1, n)
        cin >> d[i];

    while(q--){
        
        solve();
    }
    
    return 0;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 3007 ms 3312 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 328 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 324 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 169 ms 4080 KB Output is correct
2 Correct 68 ms 1308 KB Output is correct
3 Correct 65 ms 1228 KB Output is correct
4 Correct 67 ms 1264 KB Output is correct
5 Correct 73 ms 1280 KB Output is correct
6 Correct 76 ms 1340 KB Output is correct
7 Correct 68 ms 1276 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Execution timed out 3047 ms 3084 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 239 ms 3432 KB Output is correct
2 Correct 80 ms 1036 KB Output is correct
3 Correct 80 ms 1012 KB Output is correct
4 Correct 74 ms 900 KB Output is correct
5 Correct 78 ms 952 KB Output is correct
6 Correct 78 ms 972 KB Output is correct
7 Correct 77 ms 972 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Execution timed out 3023 ms 3896 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 169 ms 4080 KB Output is correct
2 Correct 68 ms 1308 KB Output is correct
3 Correct 65 ms 1228 KB Output is correct
4 Correct 67 ms 1264 KB Output is correct
5 Correct 73 ms 1280 KB Output is correct
6 Correct 76 ms 1340 KB Output is correct
7 Correct 68 ms 1276 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Execution timed out 3047 ms 3084 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3007 ms 3312 KB Time limit exceeded
2 Halted 0 ms 0 KB -