結果

問題 No.1477 Lamps on Graph
ユーザー seven_threeseven_three
提出日時 2021-04-16 20:16:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 261 ms / 2,000 ms
コード長 1,203 bytes
コンパイル時間 1,004 ms
コンパイル使用メモリ 103,320 KB
実行使用メモリ 11,412 KB
最終ジャッジ日時 2023-09-15 20:37:54
合計ジャッジ時間 7,742 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
5,116 KB
testcase_01 AC 4 ms
5,168 KB
testcase_02 AC 4 ms
5,460 KB
testcase_03 AC 3 ms
5,116 KB
testcase_04 AC 3 ms
5,332 KB
testcase_05 AC 3 ms
5,252 KB
testcase_06 AC 3 ms
5,184 KB
testcase_07 AC 4 ms
5,156 KB
testcase_08 AC 3 ms
5,224 KB
testcase_09 AC 3 ms
5,180 KB
testcase_10 AC 4 ms
5,332 KB
testcase_11 AC 4 ms
5,320 KB
testcase_12 AC 120 ms
8,064 KB
testcase_13 AC 122 ms
7,776 KB
testcase_14 AC 147 ms
8,736 KB
testcase_15 AC 59 ms
6,816 KB
testcase_16 AC 43 ms
6,640 KB
testcase_17 AC 45 ms
6,612 KB
testcase_18 AC 172 ms
8,600 KB
testcase_19 AC 112 ms
8,264 KB
testcase_20 AC 42 ms
6,180 KB
testcase_21 AC 151 ms
7,812 KB
testcase_22 AC 24 ms
5,932 KB
testcase_23 AC 76 ms
7,236 KB
testcase_24 AC 176 ms
8,960 KB
testcase_25 AC 55 ms
6,544 KB
testcase_26 AC 165 ms
8,968 KB
testcase_27 AC 71 ms
7,232 KB
testcase_28 AC 87 ms
7,564 KB
testcase_29 AC 87 ms
7,100 KB
testcase_30 AC 96 ms
6,768 KB
testcase_31 AC 59 ms
6,452 KB
testcase_32 AC 261 ms
11,412 KB
testcase_33 AC 218 ms
11,244 KB
testcase_34 AC 254 ms
11,392 KB
testcase_35 AC 233 ms
10,716 KB
testcase_36 AC 223 ms
10,560 KB
testcase_37 AC 177 ms
10,624 KB
testcase_38 AC 198 ms
10,644 KB
testcase_39 AC 225 ms
10,604 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int a[100010], b[100010], in[100010];
vector<pair<int, int>> vec;
vector<vector<int>> v(100010);
vector<int> ans;
bool bo[100010] = { false };
int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		vec.emplace_back(make_pair(a[i], i));
	}
	sort(vec.begin(), vec.end());
	for (int i = 1; i <= n; i++) {
		in[i] = vec[i - 1].second;
	}
	for (int i = 0; i < m; i++) {
		int c, d;
		cin >> c >> d;
		v[c].emplace_back(d);
		v[d].emplace_back(c);
	}
	int k;
	cin >> k;
	for (int i = 0; i < k; i++) {
		int b1;
		cin >> b1;
		bo[b1] = true;
	}
	for (int i = 1; i <= n; i++) {
		if (bo[in[i]]) {
			bo[in[i]] = false;
			for (int j = 0; j < v[in[i]].size(); j++) {
				if (a[in[i]] < a[v[in[i]][j]]) {
					bo[v[in[i]][j]] = !bo[v[in[i]][j]];
				}
			}
			ans.emplace_back(in[i]);
		}
	}
	cout << ans.size() << endl;
	for (int i = 0; i < ans.size(); i++) {
		cout << ans[i] << endl;
	}
}
0