23392023-01-10 15:30:35sztomiKazamatacpp11Accepted 40/4017ms6040 KiB
#include <bits/stdc++.h>

using namespace std;

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

    int n;
    cin >> n;
    vector<int> a(n);
    vector<bool> megvan(n, false);
    for(int& x : a){
        cin >> x;
    }

    int ki = 0;
    vector<int> uj;
    for(int i = 0; i < n; i++){
        megvan[(a[i]+ki)%n] = true;
        uj.push_back((a[i]+ki)%n);
        while(!megvan[i]){
            vector<int> temp;
            for(int x : uj){
                if(!megvan[(x+1)%n]){
                    megvan[(x+1)%n] = true;
                    temp.push_back((x+1)%n);
                }
            }
            swap(uj, temp);
            ki++;
        }
/*
        cout << "i: " << i << " ki: " << ki << "\n";
        for(int i = 0; i < n; i++){
            cout << i << " : " << megvan[i] << "\n";
        }
        cout << "------------\n";
*/
    }
    cout << ki << "\n";

}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1828 KiB
2Accepted0/09ms3276 KiB
3Accepted2/22ms2436 KiB
4Accepted2/22ms2592 KiB
5Accepted2/22ms2596 KiB
6Accepted2/22ms2804 KiB
7Accepted2/22ms3032 KiB
8Accepted2/22ms3220 KiB
9Accepted2/22ms3180 KiB
10Accepted2/22ms3300 KiB
11Accepted2/216ms5080 KiB
12Accepted2/216ms5124 KiB
13Accepted2/217ms5440 KiB
14Accepted2/216ms5512 KiB
15Accepted2/217ms5500 KiB
16Accepted2/217ms5832 KiB
17Accepted2/217ms5820 KiB
18Accepted2/217ms5872 KiB
19Accepted2/214ms5908 KiB
20Accepted2/214ms5428 KiB
21Accepted2/217ms6024 KiB
22Accepted2/214ms6040 KiB