229412026-01-16 09:18:53ZsomiHírlánccpp17Wrong answer 0/80600ms2484 KiB
#include <iostream>
#include <vector>
using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> tanulok(n + 1), a(n + 1), startok;
	for (int i = 1; i < n + 1; i++)
	{
		cin >> tanulok[i];
		a[tanulok[i]]++;
	}

	for (int i = 1; i < n + 1; i++)
	{
		if (a[i] == 0)
			startok.push_back(i);
	}

	//for (auto a : startok)
	//	cout << a;

	int max = 0, maxi;
	for (int i = 0; i < startok.size(); i++)
	{
		vector<bool> tanulokVolt(n + 1, false);
		int kov = tanulok[startok[i]], most = startok[i], jelenleg = 1;

		while (!tanulokVolt[kov])
		{
			tanulokVolt[most] = true;
			jelenleg++;
			most = kov;
			kov = tanulok[most];
		}

		if (jelenleg > max)
		{
			max = jelenleg;
			maxi = startok[i];
		}
	}

	cout << maxi << " " << max;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted1ms316 KiB
subtask20/20
2Accepted2ms332 KiB
3Accepted1ms316 KiB
4Accepted2ms316 KiB
5Accepted2ms316 KiB
6Accepted2ms316 KiB
7Accepted2ms316 KiB
8Accepted3ms316 KiB
9Accepted4ms420 KiB
10Wrong answer2ms316 KiB
11Wrong answer1ms316 KiB
12Wrong answer1ms316 KiB
subtask30/18
13Wrong answer71ms1848 KiB
14Wrong answer71ms1980 KiB
15Wrong answer70ms1984 KiB
16Wrong answer71ms1984 KiB
17Wrong answer71ms1980 KiB
18Wrong answer71ms1844 KiB
19Wrong answer71ms2036 KiB
20Wrong answer70ms1980 KiB
21Wrong answer70ms1844 KiB
22Wrong answer71ms1844 KiB
subtask40/42
23Accepted1ms316 KiB
24Accepted2ms332 KiB
25Accepted1ms316 KiB
26Accepted2ms316 KiB
27Accepted2ms316 KiB
28Accepted2ms316 KiB
29Accepted2ms316 KiB
30Accepted3ms316 KiB
31Accepted4ms420 KiB
32Wrong answer2ms316 KiB
33Wrong answer1ms316 KiB
34Wrong answer1ms316 KiB
35Wrong answer71ms1848 KiB
36Wrong answer71ms1980 KiB
37Wrong answer70ms1984 KiB
38Wrong answer71ms1984 KiB
39Wrong answer71ms1980 KiB
40Wrong answer71ms1844 KiB
41Wrong answer71ms2036 KiB
42Wrong answer70ms1980 KiB
43Wrong answer70ms1844 KiB
44Wrong answer71ms1844 KiB
45Accepted104ms2480 KiB
46Accepted203ms2472 KiB
47Time limit exceeded582ms2480 KiB
48Time limit exceeded600ms2480 KiB
49Time limit exceeded578ms2480 KiB
50Time limit exceeded574ms2392 KiB
51Time limit exceeded583ms2356 KiB
52Time limit exceeded580ms2236 KiB
53Time limit exceeded580ms2480 KiB
54Time limit exceeded583ms2484 KiB