結果

問題 No.1477 Lamps on Graph
ユーザー auauaauaua
提出日時 2021-04-16 20:17:46
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 173 ms / 2,000 ms
コード長 1,459 bytes
コンパイル時間 1,892 ms
コンパイル使用メモリ 177,212 KB
実行使用メモリ 13,264 KB
最終ジャッジ日時 2023-09-15 20:42:46
合計ジャッジ時間 7,304 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
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 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 93 ms
7,036 KB
testcase_13 AC 90 ms
7,104 KB
testcase_14 AC 114 ms
7,476 KB
testcase_15 AC 48 ms
5,000 KB
testcase_16 AC 29 ms
4,840 KB
testcase_17 AC 29 ms
5,060 KB
testcase_18 AC 95 ms
9,544 KB
testcase_19 AC 77 ms
7,272 KB
testcase_20 AC 33 ms
4,740 KB
testcase_21 AC 82 ms
8,508 KB
testcase_22 AC 23 ms
4,376 KB
testcase_23 AC 64 ms
5,536 KB
testcase_24 AC 137 ms
9,172 KB
testcase_25 AC 45 ms
5,008 KB
testcase_26 AC 116 ms
9,084 KB
testcase_27 AC 55 ms
5,308 KB
testcase_28 AC 66 ms
6,336 KB
testcase_29 AC 67 ms
5,808 KB
testcase_30 AC 49 ms
6,528 KB
testcase_31 AC 36 ms
5,624 KB
testcase_32 AC 169 ms
13,264 KB
testcase_33 AC 157 ms
11,796 KB
testcase_34 AC 128 ms
10,464 KB
testcase_35 AC 173 ms
11,160 KB
testcase_36 AC 163 ms
11,192 KB
testcase_37 AC 134 ms
9,836 KB
testcase_38 AC 145 ms
10,316 KB
testcase_39 AC 164 ms
11,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
#define double long double
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
//typedef long double ld;
typedef complex<double> Complex;
const ll INF=1e9+7;
const ll MOD=998244353;
const ll inf=INF*INF;
const ll mod=MOD;
const ll MAX=200010;





signed main(){
    ll n,m;cin>>n>>m;
    vector<ll>a(n);
    vector<vector<ll> >G(n);
    rep(i,n)cin>>a[i];
    rep(i,m){
        ll u,v;cin>>u>>v;
        u--;v--;
        if(a[u]<a[v])G[u].pb(v);
        if(a[v]<a[u])G[v].pb(u);
    }
    ll k;cin>>k;
    priority_queue<pll,vector<pll>,greater<pll> >q;
    vector<ll>l(n);
    rep(i,k){
        ll b;cin>>b;
        b--;
        l[b]=1;
        q.push(mp(a[b],b));
    }
    vector<ll>ans(0);
    while(!q.empty()){
        pll p=q.top();
        ll d=p.se;
        q.pop();
        if(l[d]==0)continue;
        l[d]=0;
        ans.pb(d+1);
        for(auto e:G[d]){
            l[e]=1-l[e];
            if(l[e]){
                q.push(mp(a[e],e));
            }
        }
    }
    cout<<ans.size()<<endl;
    rep(i,ans.size()){
        cout<<ans[i]<<endl;
    }
}
0