結果
| 問題 |
No.479 頂点は要らない
|
| コンテスト | |
| ユーザー |
femto
|
| 提出日時 | 2017-01-27 23:12:36 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 46 ms / 1,500 ms |
| コード長 | 729 bytes |
| コンパイル時間 | 1,695 ms |
| コンパイル使用メモリ | 170,120 KB |
| 実行使用メモリ | 9,960 KB |
| 最終ジャッジ日時 | 2024-12-23 16:58:12 |
| 合計ジャッジ時間 | 3,818 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int check[100000];
int del[100000];
vector<int> G[100000];
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n, m;
cin >> n >> m;
for(int i = 0; i < m; i++) {
int a, b;
cin >> a >> b;
G[a].push_back(i);
G[b].push_back(i);
}
for(int i = n - 1; i >= 0; i--) {
bool ok = true;
for(auto id : G[i]) {
if(check[id]) {
ok = false;
break;
}
}
if(ok) {
for(auto id : G[i]) {
check[id] = 1;
}
del[i] = 1;
}
}
string s;
for(int i = 0; i < n; i++) {
if(del[i]) s += '0';
else s += '1';
}
while(s.back() == '0') s.pop_back();
reverse(s.begin(), s.end());
if(s == "") s = "0";
cout << s << endl;
}
femto