結果

問題 No.479 頂点は要らない
ユーザー mogurockermogurocker
提出日時 2017-10-25 19:39:29
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 260 ms / 1,500 ms
コード長 1,126 bytes
コンパイル時間 1,620 ms
コンパイル使用メモリ 169,588 KB
実行使用メモリ 18,956 KB
最終ジャッジ日時 2024-05-01 14:05:10
合計ジャッジ時間 6,222 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,760 KB
testcase_01 AC 3 ms
5,760 KB
testcase_02 AC 4 ms
5,760 KB
testcase_03 AC 4 ms
5,760 KB
testcase_04 AC 3 ms
5,632 KB
testcase_05 AC 3 ms
5,760 KB
testcase_06 AC 4 ms
5,760 KB
testcase_07 AC 4 ms
5,760 KB
testcase_08 AC 4 ms
5,760 KB
testcase_09 AC 4 ms
5,632 KB
testcase_10 AC 4 ms
5,632 KB
testcase_11 AC 4 ms
5,760 KB
testcase_12 AC 4 ms
5,760 KB
testcase_13 AC 3 ms
5,760 KB
testcase_14 AC 4 ms
5,632 KB
testcase_15 AC 4 ms
5,760 KB
testcase_16 AC 4 ms
5,760 KB
testcase_17 AC 4 ms
5,888 KB
testcase_18 AC 4 ms
5,632 KB
testcase_19 AC 5 ms
5,888 KB
testcase_20 AC 5 ms
5,888 KB
testcase_21 AC 4 ms
5,888 KB
testcase_22 AC 5 ms
5,888 KB
testcase_23 AC 5 ms
6,016 KB
testcase_24 AC 5 ms
5,888 KB
testcase_25 AC 4 ms
5,888 KB
testcase_26 AC 260 ms
18,688 KB
testcase_27 AC 246 ms
18,560 KB
testcase_28 AC 133 ms
18,956 KB
testcase_29 AC 120 ms
17,024 KB
testcase_30 AC 119 ms
17,024 KB
testcase_31 AC 119 ms
17,152 KB
testcase_32 AC 120 ms
17,152 KB
testcase_33 AC 228 ms
15,744 KB
testcase_34 AC 237 ms
16,640 KB
testcase_35 AC 245 ms
16,256 KB
testcase_36 AC 136 ms
12,672 KB
testcase_37 AC 233 ms
16,256 KB
testcase_38 AC 192 ms
14,720 KB
testcase_39 AC 114 ms
12,288 KB
testcase_40 AC 148 ms
13,568 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