84032024-01-15 15:52:15anonIntervallumok (45 pont)cpp17Accepted 45/4543ms11176 KiB
#include <bits/stdc++.h>
#define FastIO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
typedef long long ll;
const ll INF = (1LL << 62);
int main() {
    FastIO;
    bool ok;
    ll i, j, ms, st, N;
    cin >> N;
    vector<ll> A(N);
    for(i = 0; i < N; i++)
        cin >> A[i];
    vector<pair<ll, vector<ll>>> ans;
    for(i = N; i > 1; i--) {
        if(N % i)
            continue;
        ms = -INF;
        for(j = 0; j < N; j += i)
            ms = max(ms, A[j + i - 1] - A[j]);
        ok = true;
        pair<ll, vector<ll>> na = { ms, {} };
        for(j = i - 1; j < N && ok; j += i) {
            st = max(na.second.empty() ? -INF : (na.second.back() + ms + 1), A[j] - ms);
            if(st > A[j - i + 1]) {
                ok = false;
                break;
            }
            na.second.push_back(st);
        }
        if(ok)
            ans.push_back(na);
    }
    cout << ans.size() << '\n';
    for(const auto &x : ans) {
        cout << x.second.size() << ' ' << x.first << '\n';
        for(const auto &y : x.second)
            cout << y << '\n';
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base45/45
1Accepted0/03ms1832 KiB
2Accepted0/03ms2044 KiB
3Accepted1/13ms2232 KiB
4Accepted1/13ms2420 KiB
5Accepted1/13ms2396 KiB
6Accepted1/14ms2724 KiB
7Accepted1/118ms4188 KiB
8Accepted2/23ms3100 KiB
9Accepted2/217ms5248 KiB
10Accepted2/220ms5936 KiB
11Accepted2/218ms5612 KiB
12Accepted2/219ms6176 KiB
13Accepted2/218ms6008 KiB
14Accepted2/24ms4168 KiB
15Accepted2/26ms4484 KiB
16Accepted2/27ms4644 KiB
17Accepted2/29ms5256 KiB
18Accepted2/29ms5212 KiB
19Accepted2/225ms7248 KiB
20Accepted2/243ms10720 KiB
21Accepted2/243ms11176 KiB
22Accepted2/237ms9848 KiB
23Accepted2/241ms10544 KiB
24Accepted2/212ms4912 KiB
25Accepted2/223ms7132 KiB
26Accepted2/230ms8832 KiB
27Accepted2/217ms5388 KiB