7572022-01-09 12:35:36vandrasKazamatacpp14Time limit exceeded 0/40298ms1824 KiB
#include <bits/stdc++.h>
using namespace std;

int n, vis[100005];

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

	cin >> n;
	vector<int> keys;

	int ans = 0;

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

		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);
			keys = nkeys;
			++ans;
		}

	}

	cout << ans << '\n';


	return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/40
1Accepted0/02ms1824 KiB
2Time limit exceeded0/0296ms928 KiB
3Time limit exceeded0/2298ms1132 KiB
4Time limit exceeded0/2296ms1076 KiB
5Time limit exceeded0/2287ms1012 KiB
6Time limit exceeded0/2298ms1028 KiB
7Time limit exceeded0/2289ms1032 KiB
8Time limit exceeded0/2252ms1036 KiB
9Time limit exceeded0/2289ms988 KiB
10Time limit exceeded0/2291ms1044 KiB
11Time limit exceeded0/2298ms984 KiB
12Time limit exceeded0/2282ms1068 KiB
13Time limit exceeded0/2298ms1020 KiB
14Time limit exceeded0/2291ms1040 KiB
15Time limit exceeded0/2296ms1116 KiB
16Time limit exceeded0/2298ms1136 KiB
17Time limit exceeded0/2298ms1148 KiB
18Time limit exceeded0/2296ms1104 KiB
19Time limit exceeded0/2296ms1184 KiB
20Time limit exceeded0/2298ms1196 KiB
21Time limit exceeded0/2296ms1148 KiB
22Time limit exceeded0/2289ms1228 KiB