結果

問題 No.479 頂点は要らない
ユーザー kurenai3110kurenai3110
提出日時 2017-04-11 18:27:24
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 78 ms / 1,500 ms
コード長 860 bytes
コンパイル時間 588 ms
コンパイル使用メモリ 69,536 KB
実行使用メモリ 9,448 KB
最終ジャッジ日時 2023-09-25 11:13:41
合計ジャッジ時間 3,383 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 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 77 ms
9,444 KB
testcase_27 AC 78 ms
9,448 KB
testcase_28 AC 64 ms
9,332 KB
testcase_29 AC 64 ms
6,688 KB
testcase_30 AC 65 ms
6,828 KB
testcase_31 AC 64 ms
6,688 KB
testcase_32 AC 65 ms
6,684 KB
testcase_33 AC 62 ms
6,716 KB
testcase_34 AC 67 ms
7,068 KB
testcase_35 AC 60 ms
5,736 KB
testcase_36 AC 34 ms
4,380 KB
testcase_37 AC 67 ms
7,544 KB
testcase_38 AC 55 ms
6,440 KB
testcase_39 AC 38 ms
5,940 KB
testcase_40 AC 47 ms
7,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main()
{
	int n, m; cin >> n >> m;

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

	vector<int>cnt(m);
	int size = 0;
	int last = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < V[i].size();j++) {
			if (cnt[V[i][j]] == 0)size++;
			cnt[V[i][j]]++;
		}

		if (size == m) {
			last = i;
			break;
		}
	}

	string ans = "";
	for (int i = last; i >= 0; i--) {
		bool iranai = true;
		for (int j = 0; j < V[i].size(); j++) {
			if (cnt[V[i][j]] == 1) {
				iranai = false;
				break;
			}
		}

		if (iranai) {
			for (int j = 0; j < V[i].size(); j++)cnt[V[i][j]]--;
			ans += '0';
		}
		else {
			ans += '1';
		}
	}

	cout << ans << endl;

    return 0;
}
0