結果

問題 No.1477 Lamps on Graph
ユーザー ayoiyouyoeyoayoiyouyoeyo
提出日時 2021-04-16 21:07:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,202 bytes
コンパイル時間 3,394 ms
コンパイル使用メモリ 178,304 KB
実行使用メモリ 12,588 KB
最終ジャッジ日時 2023-09-15 22:48:28
合計ジャッジ時間 12,383 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 1 ms
4,376 KB
testcase_05 WA -
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 1 ms
4,376 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 266 ms
12,588 KB
testcase_33 WA -
testcase_34 AC 245 ms
9,536 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<bitset>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
#include<cassert>
#include<random>
using namespace std;
#include<atcoder/all>
using namespace atcoder;


#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e17;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll id;
	ll fr;
	ll to;
	ll d;
};

using mint = modint;

typedef vector<ll> vll;
typedef vector <vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

vmint f, finv, inv;

void cominit(ll N) {
	ll MOD = modint::mod();//デフォルトが998244353に注意

	f.assign(N + 1, 1);
	finv.assign(N + 1, 1);
	inv.assign(N + 1, 1);
	inv[1] = 1;

	repn(i, N) {
		f[i] = f[i - 1] * i;
		if (i > 1)inv[i] = -inv[MOD % i] * (MOD / i);
		finv[i] = finv[i - 1] * inv[i];
	}
}

mint com(ll a, ll b) {
	if (a < 0 || b < 0 || a < b) { return 0; }
	return f[a] * finv[b] * finv[a - b];
}


/////////////////////////////////////


int main() {
	ll N, M;
	cin >> N >> M;
	vll A(N);
	rep(i, N)cin >> A[i];

	vvll g(N);
	rep(i, M) {
		ll u, v;
		cin >> u >> v;
		u--; v--;

		if (A[u] < A[v]) { g[u].push_back(v); }
		if (A[u] > A[v]) { g[v].push_back(u); }
	}

	vll on(N);
	ll K;
	cin >> K;
	rep(i, K) {
		ll b;
		cin >> b;
		on[b - 1]++;
	}

	vector<P> p(N);
	rep(i, N)p[i] = { A[i],i };
	sort(p.begin(), p.end());

	vll lis;

	rep(i, N) {
		ll x = p[i].second;
		if (on[x] == 0) { continue; }
		
		lis.push_back(x);
		for (ll y : g[x]) {
			on[y] = 1 - on[x];
		}
	}

	cout << lis.size() << endl;
	for (ll x : lis) {
		cout << x+1 << endl;
	}


}
0