結果
| 問題 |
No.479 頂点は要らない
|
| ユーザー |
|
| 提出日時 | 2017-02-15 00:42:17 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 80 ms / 1,500 ms |
| コード長 | 884 bytes |
| コンパイル時間 | 972 ms |
| コンパイル使用メモリ | 74,112 KB |
| 実行使用メモリ | 7,936 KB |
| 最終ジャッジ日時 | 2024-12-29 22:47:53 |
| 合計ジャッジ時間 | 4,395 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
ソースコード
#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;
}