71102023-12-30 17:05:02tomi7Parti (75 pont)cpp17Time limit exceeded 44/75400ms4784 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){
	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;
		/*	for(int ii=0;ii<n;ii++){
				cout<< azaz[ii]<<' ';
				cout<<a[i].first<<' '<<a[i].second<<'\n';
			}
			cout << endl;*/
			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
base44/75
1Accepted0/03ms1876 KiB
2Time limit exceeded0/0400ms2276 KiB
3Accepted3/33ms2384 KiB
4Accepted3/33ms2492 KiB
5Wrong answer0/33ms2708 KiB
6Accepted3/33ms2924 KiB
7Accepted3/33ms3004 KiB
8Accepted4/43ms3008 KiB
9Accepted4/43ms3120 KiB
10Accepted4/44ms3152 KiB
11Accepted4/43ms3224 KiB
12Accepted4/44ms3240 KiB
13Accepted4/47ms3424 KiB
14Accepted4/48ms3356 KiB
15Time limit exceeded0/4400ms3460 KiB
16Time limit exceeded0/4365ms3732 KiB
17Time limit exceeded0/4365ms4476 KiB
18Time limit exceeded0/4374ms4608 KiB
19Time limit exceeded0/4345ms4396 KiB
20Time limit exceeded0/4354ms4564 KiB
21Time limit exceeded0/4352ms4784 KiB
22Accepted4/43ms3992 KiB