71762024-01-01 20:03:39tomi7Parti (75 pont)cpp17Wrong answer 72/7575ms7348 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]++;
	}
	bool b=true;
	cout<<ezazooooyeah(n)<<'\n';
	for(int i=0;i<n;i++){
		if(azaz[i]>=2){
			cout<<i+1<<' ';
			b=false;
		}
	}
	if(b){
		cout<<0<<'\n';
	}
}
SubtaskSumTestVerdictTimeMemory
base72/75
1Accepted0/03ms1872 KiB
2Accepted0/037ms3760 KiB
3Accepted3/33ms2488 KiB
4Accepted3/33ms2672 KiB
5Wrong answer0/33ms2888 KiB
6Accepted3/33ms2900 KiB
7Accepted3/33ms2976 KiB
8Accepted4/43ms3104 KiB
9Accepted4/43ms3344 KiB
10Accepted4/44ms3452 KiB
11Accepted4/43ms3528 KiB
12Accepted4/44ms3624 KiB
13Accepted4/44ms3512 KiB
14Accepted4/44ms3768 KiB
15Accepted4/437ms5180 KiB
16Accepted4/445ms5300 KiB
17Accepted4/452ms6504 KiB
18Accepted4/459ms6724 KiB
19Accepted4/467ms7112 KiB
20Accepted4/474ms7292 KiB
21Accepted4/475ms7348 KiB
22Accepted4/43ms4112 KiB