8362022-01-20 11:25:20kicsiboglarKazamatacpp11Accepted 40/4057ms8120 KiB
#include <iostream>
#include <vector>

#define ll long long 

using namespace std;

ll n, m, i, j, act, last;

int main()
{
    cin >> n;
    vector <ll> x(n, 0);
    vector <bool> seen(n, false);
    for (i = 0; i < n; ++i) cin >> x[i];

    ll db = 0;
    i = 0;
    while (db!=n)
    {
        if (act != 0)
        {
            if (last >= i)
            {
                x[i] = (x[i] + 1) % n;
            }
            else 
            {
                x[i] = (x[i] + act) % n;
                /*j = 1;
                while (j <= act)
                {
                    x[i] = (x[i] + 1) % n;
                    ++j;
                }*/
            }
            if (!seen[x[i]])
            {
                seen[x[i]] = true;
                db++;
            }
           
        }
        else if (!seen[x[i]])
        {
            seen[x[i]] = true;
            db++;
        }
        if (seen[i]) ++i;
        else
        {
            last = i;
            act++;
            i = 0;
        }
    }
    cout << act;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/02ms1736 KiB
2Accepted0/023ms2752 KiB
3Accepted2/21ms2104 KiB
4Accepted2/21ms2108 KiB
5Accepted2/21ms2108 KiB
6Accepted2/21ms2116 KiB
7Accepted2/21ms2128 KiB
8Accepted2/21ms2132 KiB
9Accepted2/21ms2140 KiB
10Accepted2/21ms2140 KiB
11Accepted2/243ms4024 KiB
12Accepted2/245ms4600 KiB
13Accepted2/245ms5160 KiB
14Accepted2/257ms5812 KiB
15Accepted2/243ms6284 KiB
16Accepted2/243ms6836 KiB
17Accepted2/239ms7384 KiB
18Accepted2/243ms7948 KiB
19Accepted2/241ms8112 KiB
20Accepted2/248ms8116 KiB
21Accepted2/248ms8116 KiB
22Accepted2/246ms8120 KiB