結果

問題 No.806 木を道に
コンテスト
ユーザー Tlapesium
提出日時 2019-03-22 21:46:31
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 437 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,349 ms
コンパイル使用メモリ 211,008 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-06-07 08:41:52
合計ジャッジ時間 3,183 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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 /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/vector:68,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/functional:66,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/x86_64-pc-linux-gnu/bits/stdc++.h:55,
                 from main.cpp:1:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_vector.h:1261:7: note: declared here
 1261 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~

ソースコード

diff #
raw source code

#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