結果

問題 No.479 頂点は要らない
ユーザー mogurockermogurocker
提出日時 2017-10-25 19:39:29
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 187 ms / 1,500 ms
コード長 1,126 bytes
コンパイル時間 1,573 ms
コンパイル使用メモリ 155,608 KB
実行使用メモリ 18,980 KB
最終ジャッジ日時 2023-08-14 00:53:32
合計ジャッジ時間 6,044 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,832 KB
testcase_01 AC 2 ms
5,680 KB
testcase_02 AC 2 ms
5,800 KB
testcase_03 AC 3 ms
5,932 KB
testcase_04 AC 3 ms
5,736 KB
testcase_05 AC 3 ms
5,792 KB
testcase_06 AC 3 ms
5,676 KB
testcase_07 AC 3 ms
5,676 KB
testcase_08 AC 3 ms
5,744 KB
testcase_09 AC 3 ms
5,736 KB
testcase_10 AC 3 ms
5,752 KB
testcase_11 AC 3 ms
5,780 KB
testcase_12 AC 3 ms
5,692 KB
testcase_13 AC 3 ms
5,748 KB
testcase_14 AC 3 ms
5,796 KB
testcase_15 AC 2 ms
5,720 KB
testcase_16 AC 3 ms
5,928 KB
testcase_17 AC 2 ms
5,676 KB
testcase_18 AC 4 ms
5,780 KB
testcase_19 AC 4 ms
5,932 KB
testcase_20 AC 4 ms
5,924 KB
testcase_21 AC 3 ms
5,808 KB
testcase_22 AC 3 ms
5,856 KB
testcase_23 AC 4 ms
5,916 KB
testcase_24 AC 4 ms
6,000 KB
testcase_25 AC 3 ms
5,808 KB
testcase_26 AC 174 ms
18,604 KB
testcase_27 AC 187 ms
18,492 KB
testcase_28 AC 113 ms
18,980 KB
testcase_29 AC 106 ms
17,108 KB
testcase_30 AC 103 ms
17,176 KB
testcase_31 AC 99 ms
17,232 KB
testcase_32 AC 107 ms
17,228 KB
testcase_33 AC 164 ms
15,964 KB
testcase_34 AC 175 ms
16,604 KB
testcase_35 AC 187 ms
16,244 KB
testcase_36 AC 110 ms
12,680 KB
testcase_37 AC 162 ms
16,268 KB
testcase_38 AC 142 ms
14,892 KB
testcase_39 AC 87 ms
12,252 KB
testcase_40 AC 105 ms
13,620 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define FORR(x, arr) for(auto& x:arr)
#define ITR(x, c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;
typedef pair<int, int> P;

int n, m;
vector<int> g[100005];
bool vis[100005], used[100005];
set<P> st;

void hoge(int cur) {
	vis[cur] = true;
	FORR(e, g[cur]) {
		if (vis[e] || st.empty()) continue;
		vis[e] = true;
		used[e] = true;
		FORR(f, g[e]) {
			st.erase({e, f});
			st.erase({f, e});
		}
	}
}

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n >> m;
	FOR(i, m) {
		int u, v;
		cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
		st.insert({u, v});
		st.insert({v, u});
	}
	for (int i = n-1; i >= 0; i--) {
		if (vis[i]) continue;
		hoge(i);
	}
	string ans = "";
	FOR(i, n) {
		ans += (used[i] ? "1" : "0");
	}
	reverse(ALL(ans));
	int pos = 0;
	while (ans[pos] == '0') pos++;
	cout << ans.substr(pos) << endl;
	return 0;
}
0