結果
| 問題 |
No.479 頂点は要らない
|
| ユーザー |
rapurasu
|
| 提出日時 | 2017-03-10 15:47:27 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 111 ms / 1,500 ms |
| コード長 | 1,419 bytes |
| コンパイル時間 | 1,873 ms |
| コンパイル使用メモリ | 162,160 KB |
| 実行使用メモリ | 15,268 KB |
| 最終ジャッジ日時 | 2024-06-24 07:52:14 |
| 合計ジャッジ時間 | 4,609 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000000
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
typedef long long LL;
int N;
int M;
vector<int>G[100001];//辺の相手
vector<int>num[100001];//辺番号
bool used[100001];
bool in[100001];
int main(){
cin>>N>>M;
REP(i,M){
int a,b;
cin>>a>>b;
G[a].push_back(b);
num[a].push_back(i);
G[b].push_back(a);
num[b].push_back(i);
}
REP(i,100001){
used[i]=false;
in[i]=false;
}
REP(i,N){
bool check=false;
REP(j,G[i].size()){
if(used[num[i][j]]==false){
used[num[i][j]]=true;
check=true;
}
}
if(check){
in[i]=true;
}
}
for(int i=N-1;i>=0;i--){
bool check=false;
REP(j,G[i].size()){
if(used[num[i][j]]==false){
check=true;
}
if(in[G[i][j]]==false){
check=true;
}
}
if(check==false){
in[i]=false;
REP(j,G[i].size()){
used[num[i][j]]=false;
}
}
}
bool check=false;
for(int i=N-1;i>=0;i--){
if(in[i]){
check=true;
cout<<1;
}else{
if(check){
cout<<0;
}
}
}
cout<<endl;
return 0;
}
rapurasu