21782022-12-29 09:51:21kohumarkBürokrácia (40)cpp11Wrong answer 8/40372ms7844 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];
		while(abs(num) != 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
base8/40
1Accepted0/03ms1808 KiB
2Accepted1/12ms2000 KiB
3Wrong answer0/12ms2080 KiB
4Wrong answer0/13ms2224 KiB
5Accepted1/121ms3056 KiB
6Time limit exceeded0/1367ms2092 KiB
7Runtime error0/143ms3460 KiB
8Runtime error0/248ms3552 KiB
9Wrong answer0/270ms7844 KiB
10Wrong answer0/271ms7504 KiB
11Wrong answer0/274ms7640 KiB
12Runtime error0/213ms3928 KiB
13Wrong answer0/232ms4908 KiB
14Wrong answer0/268ms7412 KiB
15Wrong answer0/256ms6616 KiB
16Runtime error0/214ms4320 KiB
17Runtime error0/214ms4456 KiB
18Wrong answer0/232ms5488 KiB
19Accepted2/224ms4772 KiB
20Accepted2/224ms4848 KiB
21Accepted2/224ms4868 KiB
22Time limit exceeded0/2372ms3812 KiB
23Time limit exceeded0/4340ms3856 KiB