結果
| 問題 |
No.479 頂点は要らない
|
| ユーザー |
arrows
|
| 提出日時 | 2017-01-28 01:03:30 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 79 ms / 1,500 ms |
| コード長 | 923 bytes |
| コンパイル時間 | 607 ms |
| コンパイル使用メモリ | 74,332 KB |
| 実行使用メモリ | 9,848 KB |
| 最終ジャッジ日時 | 2024-12-23 18:42:47 |
| 合計ジャッジ時間 | 2,800 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
ソースコード
#include <iostream>
#include <vector>
using namespace std;
int main()
{
int N, M;
cin >> N >> M;
vector<vector<int>> G(N);
for (int i = 0; i < M; i++) {
int a, b;
cin >> a >> b;
G[a].emplace_back(b);
G[b].emplace_back(a);
}
vector<int> res;
vector<bool> del(N);
for (int i = N - 1; i >= 0; i--) {
bool d = 1;
for (auto& v : G[i]) {
if (del[v]) {
d = 0;
break;
}
}
if (d) {
del[i] = 1;
res.emplace_back(0);
} else {
res.emplace_back(1);
}
}
bool one = 0;
for (int i = 0; i < N; i++) {
if (one) {
cout << res[i];
} else {
if (res[i] == 1) {
one = 1;
cout << 1;
}
}
}
cout << endl;
return 0;
}
arrows