結果

問題 No.479 頂点は要らない
ユーザー startcppstartcpp
提出日時 2017-01-29 17:07:49
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,216 bytes
コンパイル時間 510 ms
コンパイル使用メモリ 63,716 KB
実行使用メモリ 10,024 KB
最終ジャッジ日時 2023-08-25 14:39:49
合計ジャッジ時間 4,068 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
6,800 KB
testcase_01 AC 4 ms
6,840 KB
testcase_02 AC 5 ms
6,784 KB
testcase_03 AC 4 ms
6,716 KB
testcase_04 AC 4 ms
6,696 KB
testcase_05 AC 4 ms
6,704 KB
testcase_06 AC 4 ms
6,720 KB
testcase_07 AC 4 ms
6,776 KB
testcase_08 AC 4 ms
6,712 KB
testcase_09 AC 4 ms
6,716 KB
testcase_10 AC 4 ms
6,852 KB
testcase_11 AC 4 ms
6,848 KB
testcase_12 AC 4 ms
6,976 KB
testcase_13 AC 4 ms
6,716 KB
testcase_14 AC 4 ms
6,776 KB
testcase_15 AC 4 ms
6,924 KB
testcase_16 WA -
testcase_17 AC 4 ms
6,724 KB
testcase_18 AC 4 ms
6,848 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 4 ms
6,736 KB
testcase_22 AC 4 ms
6,744 KB
testcase_23 AC 4 ms
6,788 KB
testcase_24 AC 5 ms
6,752 KB
testcase_25 WA -
testcase_26 AC 94 ms
10,024 KB
testcase_27 AC 96 ms
9,940 KB
testcase_28 AC 77 ms
9,944 KB
testcase_29 AC 77 ms
8,616 KB
testcase_30 AC 74 ms
8,600 KB
testcase_31 AC 76 ms
8,656 KB
testcase_32 AC 74 ms
8,616 KB
testcase_33 AC 75 ms
8,868 KB
testcase_34 AC 78 ms
9,112 KB
testcase_35 AC 77 ms
8,376 KB
testcase_36 AC 43 ms
7,692 KB
testcase_37 AC 83 ms
9,036 KB
testcase_38 AC 66 ms
8,572 KB
testcase_39 AC 47 ms
8,256 KB
testcase_40 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

const int depth = 17;
const int INF = 114514;
class Segtree {
	int data[1 << (depth + 1)];
public:
	Segtree() {
		for (int i = 0; i < (1 << (depth + 1)); i++) { data[i] = -INF; }
	}
	void update(int pos, int x) {
		pos += (1 << depth) - 1;
		data[pos] = x;
		while (pos > 0) {
			pos = (pos - 1) / 2;
			data[pos] = max(data[pos * 2 + 1], data[pos * 2 + 2]);
		}
	}
	int getMax() {
		return data[0];
	}
	int getNum(int pos) {
		return data[pos + (1 << depth) - 1];
	}
};

Segtree seg;
vector<int> eid[100000];	//eid[i] = 頂点iにくっついている辺の番号

int main() {
	int n, m, i, a, b;
	
	cin >> n >> m;
	for (i = 0; i < m; i++) {
		cin >> a >> b;
		seg.update(i, a);	//辺iを消すにはa番以上の頂点を消す必要がある
		eid[a].push_back(i);
		eid[b].push_back(i);
	}
	
	static bool used[100000] = {false};
	while (true) {
		int id = seg.getMax();
		if (id < 0) break;
		//頂点idを消す
		for (i = 0; i < eid[id].size(); i++) {
			seg.update(eid[id][i], -INF);
		}
		used[id] = true;
	}
	
	for (i = m - 1; i >= 0; i--) if (used[i]) break;
	for (; i >= 0; i--) cout << used[i];
	cout << endl;
	return 0;
}
0