21792022-12-29 09:57:47kohumarkBürokrácia (40)cpp11Wrong answer 13/40377ms8160 KiB
#include <bits/stdc++.h>
using namespace std;

int main(){
	int n; cin >> n; int s[n];
	for(int i=0; i<n; i++){
		char t; cin >> t;
		if(t=='V') cin >> s[i];
		else s[i]=0;
		

		int num = s[i];
		if(num!=0){
			while(s[abs(num)-1] != 0){
				s[abs(num)-1] *= -1;
				num = s[abs(num)-1];
			}
		}
	}
	set<int> nact;
	for(int i=0; i<n; i++) if(s[i]>0) nact.insert(s[i]-1);
	int counter=0;
	for(int i=0; i<n; i++) if(s[i]>-1 && !nact.count(i)) counter++;
	cout << counter << '\n';
	for(int i=0; i<n; i++) if(s[i]>-1 && !nact.count(i)) cout << i+1 << ' ';
}
SubtaskSumTestVerdictTimeMemory
base13/40
1Accepted0/03ms1808 KiB
2Accepted1/12ms2064 KiB
3Wrong answer0/12ms2080 KiB
4Wrong answer0/13ms2220 KiB
5Accepted1/123ms3208 KiB
6Time limit exceeded0/1351ms2260 KiB
7Accepted1/171ms8160 KiB
8Wrong answer0/275ms8036 KiB
9Wrong answer0/271ms7804 KiB
10Wrong answer0/275ms7864 KiB
11Wrong answer0/275ms7700 KiB
12Accepted2/232ms5012 KiB
13Wrong answer0/232ms5004 KiB
14Wrong answer0/270ms7988 KiB
15Wrong answer0/256ms7112 KiB
16Accepted2/232ms5536 KiB
17Wrong answer0/232ms5608 KiB
18Wrong answer0/232ms5672 KiB
19Accepted2/224ms5256 KiB
20Accepted2/224ms5284 KiB
21Accepted2/224ms5284 KiB
22Time limit exceeded0/2351ms4164 KiB
23Time limit exceeded0/4377ms4216 KiB