結果

問題 No.479 頂点は要らない
ユーザー finefine
提出日時 2017-01-28 00:17:44
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 59 ms / 1,500 ms
コード長 799 bytes
コンパイル時間 1,583 ms
コンパイル使用メモリ 173,516 KB
実行使用メモリ 9,708 KB
最終ジャッジ日時 2023-08-25 11:16:04
合計ジャッジ時間 4,633 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 59 ms
9,512 KB
testcase_27 AC 56 ms
9,708 KB
testcase_28 AC 33 ms
9,608 KB
testcase_29 AC 33 ms
7,068 KB
testcase_30 AC 33 ms
7,064 KB
testcase_31 AC 33 ms
6,984 KB
testcase_32 AC 33 ms
6,660 KB
testcase_33 AC 37 ms
6,944 KB
testcase_34 AC 40 ms
7,428 KB
testcase_35 AC 32 ms
5,900 KB
testcase_36 AC 17 ms
4,620 KB
testcase_37 AC 43 ms
7,264 KB
testcase_38 AC 33 ms
6,668 KB
testcase_39 AC 24 ms
5,940 KB
testcase_40 AC 30 ms
7,000 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> P;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vector<P> edges(m);
	vector< vector<int> > g(n);
	for (int i = 0; i < m; i++) {
		cin >> edges[i].first >> edges[i].second;
		g[edges[i].first].push_back(i);
		g[edges[i].second].push_back(i);
	}
	vector<bool> used(m, false);
	bool flag2 = false;
	for (int i = n - 1; i >= 0; i--) {
		bool flag = false;
		for (int j : g[i]) {
			if (used[j]) continue;
			if (i < edges[j].first || i < edges[j].second) {
				flag = true;
				break;
			}
		}
		if (flag) {
			for (int j : g[i]) {
				used[j] = true;
			}
		}
		if (flag && !flag2) flag2 = true;
		if (!flag2) continue;
		if (flag) cout << 1;
		else cout << 0;
	}
	cout << endl;
	return 0;
}
0