답안 #764777

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
764777 2023-06-24T04:04:33 Z vjudge1 Network (BOI15_net) C++17
0 / 100
0 ms 212 KB
#include <bits/stdc++.h>
#define int long long
#define ull unsigned long long
#define mps make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define sz(x) (x).size() 
#define all(x) (x).begin(), (x).end()
#define booster ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fopen(s) freopen(s".in","r",stdin);freopen(s".out","w",stdout)
 
using namespace std;

vector <pair<int,int>> v2;

vector <int> v;

map <int,int> cnt;

signed main()
{ 
	booster

	int n;
	cin >> n;

	for(int i = 1; i <= n - 1; i++){
		int x,y;
		cin >> x >> y;

		cnt[y]++;		
	}

	for(int i = 1; i <= n; i++){
		if(cnt[i] == 0){
			v.pb(i);
		}	
	}

	for(int i = 1; i < sz(v); i++) {
		if(i == sz(v) - 1){
			for(int j = 1; j <= n; j++){
				if(cnt[j] != 0){
					v2.pb(mps(j, v[i]));
					break;
				}
			}
		}
		else {
			v2.pb(mps(v[0], v[i]));
		}
	}

	cout << sz(v2) << '\n';

	for(auto i : v2){
		cout << i.F << ' ' << i.S << '\n';
 	}

	return 0;
}

Compilation message

net.cpp: In function 'int main()':
net.cpp:42:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |  for(int i = 1; i < sz(v); i++) {
      |                   ^
net.cpp:43:8: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |   if(i == sz(v) - 1){
      |      ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Breaking single line is causing network to disconnect.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Breaking single line is causing network to disconnect.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Breaking single line is causing network to disconnect.
2 Halted 0 ms 0 KB -