結果

問題 No.1582 Vertexes vs Edges
ユーザー Daniel Murphy
提出日時 2021-07-02 22:14:17
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 503 bytes
コンパイル時間 2,963 ms
コンパイル使用メモリ 191,288 KB
最終ジャッジ日時 2025-01-22 16:08:23
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 3 WA * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define ll long long

const int MAXN = 1e5+5;

//vector<int> adj[MAXN];
int w[MAXN];

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);

	int n; cin >> n;
	for (int i = 0; i < n - 1; ++i) {
		int u, v; cin >> u >> v;
		//adj[u].push_back(v);
		//adj[v].push_back(u);
		w[u]++;
		w[v]++;
	}
	if (n == 2) {
		cout << 1 << "\n";
		return 0;
	}

	int cnt = 0;
	for (int i = 1; i <= n; ++i) {
		if (w[i] == 1) cnt++;
	}
	cout << n - cnt << "\n";

	return 0;
}
0