結果

問題 No.1477 Lamps on Graph
ユーザー 沙耶花沙耶花
提出日時 2021-04-16 20:07:34
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 260 ms / 2,000 ms
コード長 893 bytes
コンパイル時間 5,165 ms
コンパイル使用メモリ 265,932 KB
実行使用メモリ 11,668 KB
最終ジャッジ日時 2023-09-15 20:18:03
合計ジャッジ時間 10,794 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 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 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 115 ms
6,860 KB
testcase_13 AC 117 ms
6,652 KB
testcase_14 AC 139 ms
7,440 KB
testcase_15 AC 55 ms
4,796 KB
testcase_16 AC 40 ms
5,356 KB
testcase_17 AC 43 ms
4,824 KB
testcase_18 AC 170 ms
8,296 KB
testcase_19 AC 110 ms
6,940 KB
testcase_20 AC 39 ms
4,376 KB
testcase_21 AC 145 ms
7,432 KB
testcase_22 AC 22 ms
4,380 KB
testcase_23 AC 72 ms
5,372 KB
testcase_24 AC 172 ms
8,068 KB
testcase_25 AC 52 ms
4,604 KB
testcase_26 AC 162 ms
8,644 KB
testcase_27 AC 64 ms
5,540 KB
testcase_28 AC 82 ms
6,488 KB
testcase_29 AC 84 ms
5,832 KB
testcase_30 AC 96 ms
5,604 KB
testcase_31 AC 58 ms
5,292 KB
testcase_32 AC 260 ms
11,668 KB
testcase_33 AC 214 ms
11,104 KB
testcase_34 AC 250 ms
11,500 KB
testcase_35 AC 222 ms
10,704 KB
testcase_36 AC 215 ms
10,704 KB
testcase_37 AC 171 ms
10,692 KB
testcase_38 AC 192 ms
10,644 KB
testcase_39 AC 211 ms
10,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000001

int main(){
	
	int N,M;
	cin>>N>>M;
	
	vector<int> A(N);
	vector<pair<int,int>> P;
	rep(i,N){
		cin>>A[i];
		P.emplace_back(A[i],i);
	}
	
	vector<vector<int>> E(N);
	rep(i,M){
		int u,v;
		cin>>u>>v;
		u--;v--;
		E[u].push_back(v);
		E[v].push_back(u);
	}
	
	vector<int> b(N,0);
	int K;
	cin>>K;
	
	rep(i,K){
		int B;
		cin>>B;
		b[B-1] = 1;
	}
	
	sort(P.begin(),P.end());
	vector<int> ans;
	
	rep(i,P.size()){
		int ind = P[i].second;
		if(b[ind]){
			ans.push_back(ind+1);
			b[ind] ^= 1;
			rep(j,E[ind].size()){
				if(A[ind] < A[E[ind][j]]){
					b[E[ind][j]] ^= 1;
				}
			}
		}
	}
	
	cout<<ans.size()<<endl;
	rep(i,ans.size()){
		cout<<ans[i]<<endl;
	}
	
    return 0;
}
0