結果

問題 No.806 木を道に
ユーザー TlapesiumTlapesium
提出日時 2019-03-22 21:46:31
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 437 bytes
コンパイル時間 1,719 ms
コンパイル使用メモリ 193,648 KB
最終ジャッジ日時 2025-01-06 23:48:02
ジャッジサーバーID
(参考情報)
judge4 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 1
other AC * 5 WA * 22
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:16:32: warning: ignoring return value of ‘std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = int; _Alloc = std::allocator<int>; reference = int&; size_type = long unsigned int]’, declared with attribute ‘nodiscard’ [-Wunused-result]
   16 |                 mat[a]++; mat[b];
      |                                ^
In file included from /usr/include/c++/13/vector:66,
                 from /usr/include/c++/13/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:53,
                 from main.cpp:1:
/usr/include/c++/13/bits/stl_vector.h:1126:7: note: declared here
 1126 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int N;
	cin >> N;
	vector<int> mat(N, 0);
	for (int i = 0; i < N; i++) {
		int a, b;
		cin >> a >> b;
		mat[a]++; mat[b];
	}
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (mat[i] > 2)ans += mat[i] - 2;
	}
	cout << ans << endl;
}
0