結果

問題 No.1477 Lamps on Graph
ユーザー nok0nok0
提出日時 2021-03-02 22:33:23
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 169 ms / 2,000 ms
コード長 907 bytes
コンパイル時間 2,446 ms
コンパイル使用メモリ 202,804 KB
実行使用メモリ 11,512 KB
最終ジャッジ日時 2024-04-14 05:01:18
合計ジャッジ時間 9,067 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 96 ms
7,168 KB
testcase_13 AC 88 ms
6,940 KB
testcase_14 AC 116 ms
7,552 KB
testcase_15 AC 53 ms
6,940 KB
testcase_16 AC 35 ms
6,944 KB
testcase_17 AC 33 ms
6,940 KB
testcase_18 AC 93 ms
8,192 KB
testcase_19 AC 82 ms
7,168 KB
testcase_20 AC 34 ms
6,940 KB
testcase_21 AC 79 ms
7,296 KB
testcase_22 AC 23 ms
6,944 KB
testcase_23 AC 66 ms
6,940 KB
testcase_24 AC 131 ms
8,320 KB
testcase_25 AC 48 ms
6,944 KB
testcase_26 AC 117 ms
8,704 KB
testcase_27 AC 60 ms
6,940 KB
testcase_28 AC 75 ms
6,944 KB
testcase_29 AC 68 ms
6,940 KB
testcase_30 AC 47 ms
6,940 KB
testcase_31 AC 40 ms
6,940 KB
testcase_32 AC 151 ms
11,512 KB
testcase_33 AC 146 ms
11,128 KB
testcase_34 AC 136 ms
11,380 KB
testcase_35 AC 169 ms
10,880 KB
testcase_36 AC 166 ms
10,752 KB
testcase_37 AC 156 ms
10,624 KB
testcase_38 AC 158 ms
10,716 KB
testcase_39 AC 162 ms
10,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

vector<int> res;
int main() {
	int n, m;
	cin >> n >> m;
	vector<int> G[n], a(n);
	for(auto &v : a) cin >> v;
	for(int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v, --u, --v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	vector<int> perm(n), review(n);
	iota(perm.begin(), perm.end(), 0);
	sort(perm.begin(), perm.end(), [&a](const int i, const int j) { return a[i] < a[j]; });
	for(int i = 0; i < n; i++) review[perm[i]] = i;

	vector<int> state(n);
	int k;
	cin >> k;
	for(int i = 0; i < k; i++) {
		int b;
		cin >> b, --b;
		state[review[b]] = 1;
	}

	for(int i = 0; i < n; i++) {
		int &now = perm[i];
		if(!state[i]) continue;
		res.push_back(now + 1);
		state[i] = 0;
		for(int to : G[perm[i]]) {
			if(a[now] >= a[to]) continue;
			state[review[to]] = !state[review[to]];
		}
	}

	cout << res.size() << '\n';
	for(auto &v : res) cout << v << '\n';
}
0