21812022-12-29 11:19:43kohumarkBürokrácia (40)cpp11Accepted 40/4048ms5896 KiB
#include <bits/stdc++.h>
using namespace std;

int main(){
	int n; cin >> n; 
	int s[n]; int v[n];
	for(int i=0; i<n; i++){
		char t; cin >> t;
		v[i]=0;
		if(t=='V'){
			cin >> s[i];
		}
		else s[i]=0;
	}
	for(int i=n-1; i>-1; i--){
		if(v[i]==0&&s[i]!=0) v[s[i]-1]=1;
	}
	int counter=0;
	for(int i=0; i<n; i++) if(v[i]==0) counter++;
	cout << counter << '\n';
	for(int i=0; i<n; i++) if(v[i]==0) cout << i+1 << ' ';
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1880 KiB
2Accepted1/12ms2328 KiB
3Accepted1/12ms2128 KiB
4Accepted1/12ms2324 KiB
5Accepted1/121ms4104 KiB
6Accepted1/148ms4308 KiB
7Accepted1/146ms4512 KiB
8Accepted2/246ms4592 KiB
9Accepted2/246ms4720 KiB
10Accepted2/246ms4872 KiB
11Accepted2/246ms5080 KiB
12Accepted2/225ms5148 KiB
13Accepted2/227ms5248 KiB
14Accepted2/243ms5248 KiB
15Accepted2/235ms5248 KiB
16Accepted2/225ms5376 KiB
17Accepted2/225ms5484 KiB
18Accepted2/225ms5688 KiB
19Accepted2/223ms5764 KiB
20Accepted2/223ms5768 KiB
21Accepted2/221ms5768 KiB
22Accepted2/246ms5764 KiB
23Accepted4/448ms5896 KiB