結果

問題 No.1477 Lamps on Graph
ユーザー gojira_kugojira_ku
提出日時 2021-04-16 21:04:23
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 280 ms / 2,000 ms
コード長 2,553 bytes
コンパイル時間 2,020 ms
コンパイル使用メモリ 207,620 KB
実行使用メモリ 10,520 KB
最終ジャッジ日時 2023-09-15 22:36:52
合計ジャッジ時間 8,413 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,724 KB
testcase_01 AC 3 ms
5,788 KB
testcase_02 AC 4 ms
5,956 KB
testcase_03 AC 3 ms
5,736 KB
testcase_04 AC 3 ms
5,660 KB
testcase_05 AC 3 ms
5,668 KB
testcase_06 AC 3 ms
5,692 KB
testcase_07 AC 3 ms
5,688 KB
testcase_08 AC 3 ms
5,660 KB
testcase_09 AC 4 ms
5,668 KB
testcase_10 AC 3 ms
5,864 KB
testcase_11 AC 3 ms
5,760 KB
testcase_12 AC 108 ms
7,272 KB
testcase_13 AC 114 ms
7,072 KB
testcase_14 AC 130 ms
7,432 KB
testcase_15 AC 53 ms
6,536 KB
testcase_16 AC 38 ms
6,596 KB
testcase_17 AC 41 ms
6,344 KB
testcase_18 AC 169 ms
7,500 KB
testcase_19 AC 107 ms
7,096 KB
testcase_20 AC 40 ms
6,240 KB
testcase_21 AC 148 ms
7,276 KB
testcase_22 AC 25 ms
6,280 KB
testcase_23 AC 70 ms
6,668 KB
testcase_24 AC 167 ms
7,904 KB
testcase_25 AC 53 ms
6,428 KB
testcase_26 AC 159 ms
7,688 KB
testcase_27 AC 60 ms
6,636 KB
testcase_28 AC 75 ms
7,000 KB
testcase_29 AC 81 ms
6,712 KB
testcase_30 AC 97 ms
6,372 KB
testcase_31 AC 57 ms
6,240 KB
testcase_32 AC 280 ms
10,520 KB
testcase_33 AC 225 ms
9,408 KB
testcase_34 AC 248 ms
7,576 KB
testcase_35 AC 221 ms
8,964 KB
testcase_36 AC 210 ms
8,704 KB
testcase_37 AC 150 ms
8,380 KB
testcase_38 AC 179 ms
8,504 KB
testcase_39 AC 204 ms
8,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _DEBUG
#include "bits/stdc++.h"
//#include <atcoder/all>
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,a5,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#define debug_6(x1,x2,x3,x4,x5,x6) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<", "#x6<<": "<<x6<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_6,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define puba(a) emplace_back(a)
#define pubamp(a,b) emplace_back(mp(a,b))
typedef long long ll;
typedef long double ld;
using namespace std;
//using namespace atcoder;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
vint adj[100001];
bool on[100001];
int A[100001];
int main(){
	int N,M;
	scan(N>>M);
	rep(i,N) scan(A[i]);
	rep(i,M){
		int u,v;
		scan(u>>v);
		u--; v--;
		if(A[u]<A[v]) adj[u].puba(v);
		if(A[v]<A[u]) adj[v].puba(u);
	}
	priority_queue<pint> pq;
	int K;
	scan(K);
	rep(k,K){
		int u;
		scan(u);
		u--;
		on[u]=1;
		pq.push(mp(-A[u],u));
	}
	vint ans;
	while(!pq.empty()){
		int u=pq.top().second;
		pq.pop();
		if(!on[u]){
			continue;
		}
		on[u]=0;
		ans.puba(u);
		for(const auto& v:adj[u]){
			on[v]^=1;
			if(on[v]) pq.push(mp(-A[v],v));
		}
	}
	prin(ans.size());
	for(const auto& u:ans){
		prin(u+1);
	}
	return 0;
}
0