結果

問題 No.479 頂点は要らない
ユーザー chocoruskchocorusk
提出日時 2018-09-22 11:47:28
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 142 ms / 1,500 ms
コード長 1,002 bytes
コンパイル時間 632 ms
コンパイル使用メモリ 84,148 KB
実行使用メモリ 14,084 KB
最終ジャッジ日時 2023-09-25 10:59:47
合計ジャッジ時間 4,292 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,888 KB
testcase_01 AC 3 ms
5,824 KB
testcase_02 AC 3 ms
5,976 KB
testcase_03 AC 3 ms
5,688 KB
testcase_04 AC 3 ms
5,692 KB
testcase_05 AC 3 ms
5,752 KB
testcase_06 AC 2 ms
5,696 KB
testcase_07 AC 4 ms
5,684 KB
testcase_08 AC 3 ms
5,756 KB
testcase_09 AC 3 ms
5,752 KB
testcase_10 AC 2 ms
5,760 KB
testcase_11 AC 3 ms
5,744 KB
testcase_12 AC 3 ms
5,748 KB
testcase_13 AC 3 ms
5,700 KB
testcase_14 AC 2 ms
5,884 KB
testcase_15 AC 3 ms
5,744 KB
testcase_16 AC 3 ms
5,692 KB
testcase_17 AC 2 ms
5,716 KB
testcase_18 AC 3 ms
5,704 KB
testcase_19 AC 4 ms
5,824 KB
testcase_20 AC 3 ms
5,840 KB
testcase_21 AC 3 ms
5,772 KB
testcase_22 AC 4 ms
5,852 KB
testcase_23 AC 3 ms
5,880 KB
testcase_24 AC 4 ms
6,012 KB
testcase_25 AC 3 ms
5,884 KB
testcase_26 AC 142 ms
13,956 KB
testcase_27 AC 137 ms
14,084 KB
testcase_28 AC 92 ms
13,896 KB
testcase_29 AC 82 ms
10,140 KB
testcase_30 AC 81 ms
10,132 KB
testcase_31 AC 81 ms
10,080 KB
testcase_32 AC 82 ms
10,140 KB
testcase_33 AC 89 ms
10,492 KB
testcase_34 AC 96 ms
10,592 KB
testcase_35 AC 69 ms
8,328 KB
testcase_36 AC 36 ms
6,940 KB
testcase_37 AC 104 ms
11,052 KB
testcase_38 AC 81 ms
10,020 KB
testcase_39 AC 60 ms
9,372 KB
testcase_40 AC 78 ms
10,996 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int main()
{
	int n, m;
	cin>>n>>m;
	int b[100001];
	fill(b, b+n, -1);
	set<int> st;
	vector<int> g[100000];
	for(int i=0; i<n; i++) st.insert(i);
	for(int i=0; i<m; i++){
		int a, b;
		cin>>a>>b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	while(!st.empty()){
		auto itr=st.end(); itr--;
		int mx=*itr;
		b[mx]=0;
		st.erase(itr);
      vector<int> v;
      for(auto x:g[mx]){
        if(b[x]>0) continue;
        v.push_back(x);
        b[x]=1;
        st.erase(x);
      }
      for(auto x:v){
			for(auto y:g[x]){
				if(b[y]<0) b[y]=0;
			}
		}
	}
	int i=n-1;
	for(; i>=0; i--){
		if(b[i]==1) break;
	}
	string ans;
	for(; i>=0; i--){
		if(b[i]==1) ans+='1';
		else ans+='0';
	}
	cout<<ans<<endl;
	return 0;
}
0