結果

問題 No.1477 Lamps on Graph
ユーザー auauaauaua
提出日時 2021-04-16 20:13:21
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,459 bytes
コンパイル時間 1,661 ms
コンパイル使用メモリ 176,164 KB
実行使用メモリ 821,260 KB
最終ジャッジ日時 2023-09-15 20:31:04
合計ジャッジ時間 7,722 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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