結果
| 問題 |
No.479 頂点は要らない
|
| ユーザー |
walkre
|
| 提出日時 | 2017-01-28 01:33:28 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 57 ms / 1,500 ms |
| コード長 | 1,703 bytes |
| コンパイル時間 | 1,853 ms |
| コンパイル使用メモリ | 176,660 KB |
| 実行使用メモリ | 10,200 KB |
| 最終ジャッジ日時 | 2024-12-23 19:54:32 |
| 合計ジャッジ時間 | 3,932 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
os << "[";
for (const auto &v : vec) {
os << v << ",";
}
os << "]";
return os;
}
void solve(){
int n,m;
cin >> n >> m;
vector<vector<int>> graph(n);
rep(i,0,m){
int a,b;
cin >> a >> b;
graph[a].push_back(b);
graph[b].push_back(a);
}
vector<bool> used(n);
priority_queue<int,vector<int>> que;
int count=0;
rep(i,0,n) que.push(i);
while(count<m){
auto u=que.top();
que.pop();
if(used[u]) continue;
vector<int> vs;
for(auto v:graph[u]){
if(used[v]) continue;
vs.push_back(v);
}
for(int v:vs){
used[v]=true;
for(auto w:graph[v]){
if(used[w]) continue;
++count;
}
}
}
vector<int> ans(n);
rep(i,0,n){
if(used[i]) ans[i]=1;
else ans[i]=0;
}
for(int i=n-1; i>=0; --i){
if(ans[i]){
for(int j=i; j>=0; --j) cout << ans[j];
cout << endl;
return;
}
}
cout << 0 << endl;
}
int main(){
std::cin.tie(0);
std::ios::sync_with_stdio(false);
cout.setf(ios::fixed);
cout.precision(10);
solve();
return 0;
}
walkre