結果

問題 No.1898 Battle and Exchange
ユーザー polylogKpolylogK
提出日時 2021-12-23 14:13:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,501 bytes
コンパイル時間 7,893 ms
コンパイル使用メモリ 229,548 KB
実行使用メモリ 7,440 KB
最終ジャッジ日時 2023-10-22 04:35:43
合計ジャッジ時間 18,091 ms
ジャッジサーバーID
(参考情報)
judge9 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 RE -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 RE -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 WA -
testcase_43 RE -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 RE -
testcase_54 RE -
testcase_55 RE -
testcase_56 RE -
testcase_57 RE -
testcase_58 RE -
testcase_59 RE -
testcase_60 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "testlib.h"
#include <cassert>
#include <set>
#include <queue>

int main(int argc, char* argv[]) {
	registerValidation(argc, argv);

	using i64 = long long;

	// 入力
	const i64 N = inf.readInt(2, 50'000); inf.readSpace();
	const i64 M = inf.readInt(N - 1, std::min<i64>(N * (N - 1) / 2, 50'000)); inf.readEoln();

	std::vector<int> U(M), V(M);
	for(int i = 0; i < M; i++) {
		U[i] = inf.readInt(1, N); inf.readSpace();
		V[i] = inf.readInt(1, N); inf.readEoln();
	}

	std::vector<int> A(N), B(N), C(N);
	for(int i = 0; i < N; i++) {
		A[i] = inf.readInt(1, 1'000'000'000); inf.readSpace();
		B[i] = inf.readInt(1, 1'000'000'000); inf.readSpace();
		C[i] = inf.readInt(1, 1'000'000'000); inf.readEoln();
	}
	inf.readEof();

	{ // 自己ループ・多重辺のチェック
		std::set<std::pair<int, int>> edges;

		for(int i = 0; i < M; i++) {
			if(!(U[i] < V[i])) std::swap(U[i], V[i]);

			assert(U[i] != V[i]); // 自己ループ
			assert(!edges.count({U[i], V[i]})); // 多重辺

			edges.insert({U[i], V[i]});
		}
	}

	{ // 連結性のチェック
		std::vector<std::vector<int>> g(N);
		for(int i = 0; i < M; i++) {
			g[U[i] - 1].push_back(V[i] - 1);
			g[V[i] - 1].push_back(U[i] - 1);
		}

		std::vector<bool> used(N);
		std::queue<int> qu({0});
		while(!qu.empty()) {
			int v = qu.front(); qu.pop();

			if(used[v]) continue;
			used[v] = true;

			for(int to: g[v]) qu.push(to);
		}

		assert(std::all_of(begin(used), end(used), [](bool x) { return x; }));
	}

	return 0;
}
0