結果

問題 No.479 頂点は要らない
ユーザー tak0kadatak0kada
提出日時 2017-02-15 00:42:17
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 77 ms / 1,500 ms
コード長 884 bytes
コンパイル時間 737 ms
コンパイル使用メモリ 73,608 KB
実行使用メモリ 7,524 KB
最終ジャッジ日時 2023-08-28 17:05:14
合計ジャッジ時間 4,672 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 76 ms
7,524 KB
testcase_27 AC 77 ms
7,456 KB
testcase_28 AC 62 ms
6,072 KB
testcase_29 AC 64 ms
5,508 KB
testcase_30 AC 65 ms
5,348 KB
testcase_31 AC 65 ms
5,348 KB
testcase_32 AC 65 ms
5,500 KB
testcase_33 AC 65 ms
5,536 KB
testcase_34 AC 69 ms
5,620 KB
testcase_35 AC 61 ms
4,380 KB
testcase_36 AC 34 ms
4,380 KB
testcase_37 AC 68 ms
5,928 KB
testcase_38 AC 57 ms
5,392 KB
testcase_39 AC 40 ms
4,924 KB
testcase_40 AC 49 ms
5,740 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <vector>
#include <iostream>
#include <utility>

/*
  n-th node costs 2^(n+1) yen, while buying all (0...n-1)th nodes costs 2^n-1 yen.
*/

using namespace std;

int main(void)
{
	// input
	int n, m;
	cin >> n >> m;
	cin.ignore();
	vector<vector<int>> adj_list(n);

	for ( int i = 0; i < m; ++i )
	{
		int node0, node1;
		cin >> node0 >> node1;
		cin.ignore();
		if ( node0 < node1 )
		{
			swap(node0, node1);
		}
		adj_list.at(node0).push_back(node1);
	}

	vector<bool> buy_flag(n, 0);
	for ( int i = n - 1; i >= 0; --i )
	{
		if ( buy_flag.at(i) == 1)
			continue;
		for ( const auto node: adj_list.at(i) )
		{
			buy_flag.at(node) = 1;
		}
	}

	// output
	bool noshow_zero = true;
	for ( auto i = n - 1; i >= 0; --i )
	{
		if ( noshow_zero )
		{
			if ( buy_flag.at(i) == 0)
				continue;
			else
				noshow_zero = false;
		}
		cout << buy_flag.at(i);
	}
	cout << endl;

}
0