結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,784 KB
testcase_01 AC 3 ms
5,860 KB
testcase_02 AC 3 ms
5,696 KB
testcase_03 AC 2 ms
5,824 KB
testcase_04 AC 3 ms
5,692 KB
testcase_05 AC 3 ms
5,824 KB
testcase_06 AC 3 ms
5,756 KB
testcase_07 AC 3 ms
6,056 KB
testcase_08 AC 3 ms
5,720 KB
testcase_09 AC 3 ms
5,696 KB
testcase_10 AC 3 ms
5,936 KB
testcase_11 AC 3 ms
5,692 KB
testcase_12 AC 3 ms
5,972 KB
testcase_13 AC 3 ms
5,696 KB
testcase_14 AC 3 ms
5,748 KB
testcase_15 AC 3 ms
5,764 KB
testcase_16 AC 2 ms
5,692 KB
testcase_17 AC 3 ms
5,760 KB
testcase_18 AC 3 ms
5,700 KB
testcase_19 AC 3 ms
5,936 KB
testcase_20 AC 4 ms
5,836 KB
testcase_21 AC 3 ms
6,044 KB
testcase_22 AC 4 ms
5,896 KB
testcase_23 AC 4 ms
5,832 KB
testcase_24 AC 4 ms
5,784 KB
testcase_25 AC 4 ms
5,828 KB
testcase_26 AC 139 ms
13,960 KB
testcase_27 AC 139 ms
13,956 KB
testcase_28 AC 92 ms
14,000 KB
testcase_29 AC 81 ms
10,252 KB
testcase_30 AC 81 ms
10,276 KB
testcase_31 AC 82 ms
10,132 KB
testcase_32 AC 83 ms
10,128 KB
testcase_33 AC 93 ms
10,508 KB
testcase_34 AC 99 ms
10,752 KB
testcase_35 AC 70 ms
8,324 KB
testcase_36 AC 37 ms
6,832 KB
testcase_37 AC 102 ms
11,124 KB
testcase_38 AC 78 ms
9,856 KB
testcase_39 AC 61 ms
9,536 KB
testcase_40 AC 82 ms
10,960 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