結果

問題 No.479 頂点は要らない
ユーザー femtofemto
提出日時 2017-01-27 23:12:36
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 42 ms / 1,500 ms
コード長 729 bytes
コンパイル時間 1,761 ms
コンパイル使用メモリ 168,228 KB
実行使用メモリ 9,828 KB
最終ジャッジ日時 2023-08-25 10:28:58
合計ジャッジ時間 4,534 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,792 KB
testcase_01 AC 3 ms
5,792 KB
testcase_02 AC 3 ms
5,716 KB
testcase_03 AC 3 ms
5,716 KB
testcase_04 AC 3 ms
5,736 KB
testcase_05 AC 3 ms
5,712 KB
testcase_06 AC 4 ms
5,792 KB
testcase_07 AC 3 ms
5,916 KB
testcase_08 AC 4 ms
5,988 KB
testcase_09 AC 3 ms
5,704 KB
testcase_10 AC 3 ms
5,864 KB
testcase_11 AC 3 ms
5,732 KB
testcase_12 AC 3 ms
6,008 KB
testcase_13 AC 3 ms
5,736 KB
testcase_14 AC 4 ms
5,720 KB
testcase_15 AC 3 ms
5,720 KB
testcase_16 AC 3 ms
5,728 KB
testcase_17 AC 3 ms
5,708 KB
testcase_18 AC 4 ms
5,704 KB
testcase_19 AC 3 ms
6,040 KB
testcase_20 AC 3 ms
5,764 KB
testcase_21 AC 3 ms
5,748 KB
testcase_22 AC 4 ms
5,784 KB
testcase_23 AC 4 ms
5,768 KB
testcase_24 AC 4 ms
5,840 KB
testcase_25 AC 3 ms
5,760 KB
testcase_26 AC 41 ms
9,828 KB
testcase_27 AC 42 ms
9,736 KB
testcase_28 AC 29 ms
9,640 KB
testcase_29 AC 31 ms
8,344 KB
testcase_30 AC 31 ms
8,500 KB
testcase_31 AC 30 ms
8,484 KB
testcase_32 AC 30 ms
8,344 KB
testcase_33 AC 33 ms
8,564 KB
testcase_34 AC 36 ms
8,660 KB
testcase_35 AC 30 ms
7,952 KB
testcase_36 AC 17 ms
6,976 KB
testcase_37 AC 36 ms
8,684 KB
testcase_38 AC 29 ms
8,248 KB
testcase_39 AC 22 ms
7,680 KB
testcase_40 AC 28 ms
8,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int check[100000];
int del[100000];
vector<int> 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);
		G[b].push_back(i);
	}

	for(int i = n - 1; i >= 0; i--) {
		bool ok = true;
		for(auto id : G[i]) {
			if(check[id]) {
				ok = false;
				break;
			}
		}
		if(ok) {
			for(auto id : G[i]) {
				check[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