71112023-12-30 17:08:46tomi7Parti (75 pont)cpp17Wrong answer 72/7578ms8016 KiB
// Source: https://usaco.guide/general/io

#include <bits/stdc++.h>
using namespace std;

vector<int> azaz;
	vector<pair<int, int>> a;
int ezazooooyeah(int n){
	bool b=false;
	for(int i=0;i<n;i++){
		if(azaz[i]==1 || azaz[i]==0){
		//	cout << i << endl;
			azaz[a[i].first-1]--;
			azaz[a[i].second-1]--;
			azaz[i]=-1;
			b=true;
		/*	for(int ii=0;ii<n;ii++){
				cout<< azaz[ii]<<' ';
				cout<<a[i].first<<' '<<a[i].second<<'\n';
			}
			cout << endl;*/
		}
	}
	if(b){
	return ezazooooyeah(n);
	}
	int valasz=0;
	for(int i=0;i<n;i++){
		if(azaz[i]>=2){
			valasz++;
		}
	}
	return valasz;
}

int main() {
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		pair<int, int> x;
		cin>>x.first>>x.second;
		a.push_back(x);
		azaz.push_back(0);
	}
	for(int i=0;i<n;i++){
		azaz[a[i].first-1]++;
		azaz[a[i].second-1]++;
	}
	cout<<ezazooooyeah(n)<<'\n';
	for(int i=0;i<n;i++){
		if(azaz[i]>=2){
			cout<<i+1<<' ';
		}
	}
}
SubtaskSumTestVerdictTimeMemory
base72/75
1Accepted0/03ms1872 KiB
2Accepted0/039ms3704 KiB
3Accepted3/33ms2284 KiB
4Accepted3/33ms2392 KiB
5Wrong answer0/33ms2588 KiB
6Accepted3/33ms2680 KiB
7Accepted3/33ms2788 KiB
8Accepted4/43ms3044 KiB
9Accepted4/43ms3148 KiB
10Accepted4/44ms3240 KiB
11Accepted4/43ms3352 KiB
12Accepted4/44ms3616 KiB
13Accepted4/44ms3880 KiB
14Accepted4/44ms3932 KiB
15Accepted4/439ms5648 KiB
16Accepted4/446ms5732 KiB
17Accepted4/454ms6924 KiB
18Accepted4/461ms6968 KiB
19Accepted4/470ms7464 KiB
20Accepted4/478ms7800 KiB
21Accepted4/478ms8016 KiB
22Accepted4/43ms4924 KiB