結果

問題 No.479 頂点は要らない
ユーザー femtofemto
提出日時 2017-01-27 23:10:46
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 39 ms / 1,500 ms
コード長 776 bytes
コンパイル時間 1,712 ms
コンパイル使用メモリ 168,576 KB
実行使用メモリ 10,040 KB
最終ジャッジ日時 2023-08-25 04:44:52
合計ジャッジ時間 3,798 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,700 KB
testcase_01 AC 3 ms
5,720 KB
testcase_02 AC 3 ms
5,700 KB
testcase_03 AC 3 ms
5,800 KB
testcase_04 AC 3 ms
5,716 KB
testcase_05 AC 3 ms
5,688 KB
testcase_06 AC 3 ms
5,768 KB
testcase_07 AC 3 ms
5,772 KB
testcase_08 AC 3 ms
5,684 KB
testcase_09 AC 3 ms
5,720 KB
testcase_10 AC 3 ms
5,824 KB
testcase_11 AC 4 ms
5,696 KB
testcase_12 AC 3 ms
5,716 KB
testcase_13 AC 3 ms
5,696 KB
testcase_14 AC 3 ms
5,736 KB
testcase_15 AC 3 ms
5,740 KB
testcase_16 AC 3 ms
5,772 KB
testcase_17 AC 3 ms
5,692 KB
testcase_18 AC 3 ms
5,696 KB
testcase_19 AC 3 ms
5,768 KB
testcase_20 AC 4 ms
5,748 KB
testcase_21 AC 4 ms
5,728 KB
testcase_22 AC 3 ms
5,820 KB
testcase_23 AC 4 ms
5,744 KB
testcase_24 AC 4 ms
5,756 KB
testcase_25 AC 3 ms
5,760 KB
testcase_26 AC 39 ms
9,804 KB
testcase_27 AC 39 ms
9,992 KB
testcase_28 AC 29 ms
10,040 KB
testcase_29 AC 31 ms
9,248 KB
testcase_30 AC 31 ms
9,280 KB
testcase_31 AC 32 ms
9,192 KB
testcase_32 AC 32 ms
9,216 KB
testcase_33 AC 34 ms
9,312 KB
testcase_34 AC 36 ms
9,508 KB
testcase_35 AC 33 ms
8,980 KB
testcase_36 AC 18 ms
7,660 KB
testcase_37 AC 36 ms
9,720 KB
testcase_38 AC 31 ms
9,112 KB
testcase_39 AC 23 ms
8,260 KB
testcase_40 AC 26 ms
8,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

struct Edge {
	int id, to;
};

int check[100000];
int del[100000];
vector<Edge> G[100000];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n, m;
	cin >> n >> m;
	for(int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		G[a].push_back({ i, b });
		G[b].push_back({ i, a });
	}

	for(int i = n - 1; i >= 0; i--) {
		bool ok = true;
		for(auto e : G[i]) {
			if(check[e.id]) {
				ok = false;
				break;
			}
		}
		if(ok) {
			for(auto e : G[i]) {
				check[e.id] = 1;
			}
			del[i] = 1;
		}
	}

	string s;
	for(int i = 0; i < n; i++) {
		if(del[i]) s += '0';
		else s += '1';
	}
	while(s.back() == '0') s.pop_back();
	reverse(s.begin(), s.end());
	if(s == "") s = "0";
	cout << s << endl;
}
0