7602022-01-09 12:39:11vandrasKazamatacpp14Accepted 40/4016ms9844 KiB
#include <bits/stdc++.h>
using namespace std;

int n, vis[100005], x, ans=0;

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

	cin >> n;
	vector<int> keys;

	for(int i = 0; i < n; ++i){
		cin >> x;
		x = (x+ans)%n;

		if(!vis[x]) keys.push_back(x);
		vis[x] = 1;

		while(!vis[i]){
			vector<int> nkeys;
			for(int k : keys){
				if(!vis[(k+1)%n]) nkeys.push_back((k+1)%n);
				vis[(k+1)%n] = 1;
			}
			swap(keys, nkeys);
			++ans;
		}

	}

	cout << ans << '\n';


	return 0;
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/02ms1832 KiB
2Accepted0/08ms2528 KiB
3Accepted2/21ms2148 KiB
4Accepted2/21ms2152 KiB
5Accepted2/21ms2156 KiB
6Accepted2/21ms2160 KiB
7Accepted2/21ms2176 KiB
8Accepted2/21ms2176 KiB
9Accepted2/21ms2192 KiB
10Accepted2/21ms2192 KiB
11Accepted2/214ms3472 KiB
12Accepted2/214ms4064 KiB
13Accepted2/214ms4640 KiB
14Accepted2/216ms5216 KiB
15Accepted2/214ms5788 KiB
16Accepted2/214ms6372 KiB
17Accepted2/216ms6944 KiB
18Accepted2/214ms7524 KiB
19Accepted2/214ms8104 KiB
20Accepted2/214ms8676 KiB
21Accepted2/214ms9256 KiB
22Accepted2/214ms9844 KiB