結果

問題 No.1103 Directed Length Sum
ユーザー QCFiumQCFium
提出日時 2020-07-14 18:34:57
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,528 bytes
コンパイル時間 1,628 ms
コンパイル使用メモリ 173,916 KB
実行使用メモリ 84,684 KB
最終ジャッジ日時 2023-08-11 08:29:45
合計ジャッジ時間 5,518 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:39:15: 警告: ‘void* memset(void*, int, size_t)’ specified size between 18446744071562068017 and 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=]
   39 |         memset(used, 0, sizeof(used));
      |         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>

struct FastIO {
	char buf[20000000];
	char *ptr = buf;
	void read() {
		int size;
		size = fread(buf, 1, sizeof(buf) - 1, stdin);
		buf[size] = '\0';
		ptr = buf;
	}
	FastIO () {
		read();
	}
	void inc() {
		ptr++;
		// if (++ptr == buf + sizeof(buf) || !*ptr) read();
	}
	template<typename Integer> Integer read() {
		bool neg = false;
		Integer res = 0;
		while ((*ptr < '0' || *ptr > '9') && *ptr != '-') inc();
		if (*ptr == '-') neg = true, inc();
		while (*ptr >= '0' && *ptr <= '9') res = res * 10 + *ptr - '0', inc();
		return neg ? -res : res;
	}
} fastio;
#define ri fastio.read<int>
#define rs64 fastio.read<int64_t>


std::vector<std::vector<int> > hen;

int main() {
	int n = ri();
	int degree[n];
	memset(degree, 0, sizeof(degree));
	bool used[n];
	memset(used, 0, sizeof(used));
	std::pair<int, int> hens[n - 1];
	for (int i = 0; i + 1 < n; i++) {
		hens[i].first = ri() - 1;
		hens[i].second = ri() - 1;
		degree[hens[i].first]++;
		used[hens[i].second] = true;
	}
	
	int root = std::find(used, used + n, 0) - used;
	hen.resize(n);
	for (int i = 0; i < n; i++) hen[i].resize(degree[i]);
	for (auto i : hens) hen[i.first][--degree[i.first]] = i.second;
	
	return 0;
	
	int depth[n];
	depth[root] = 0;
	std::queue<int> que;
	que.push(root);
	int64_t res = 0;
	while (que.size()) {
		int i = que.front();
		que.pop();
		res += (int64_t) depth[i] * (depth[i] + 1) / 2;
		for (auto j : hen[i]) depth[j] = depth[i] + 1, que.push(j);
	}
	printf("%d\n", (int) (res % 1000000007));
	return 0;
}
0