結果

問題 No.1477 Lamps on Graph
ユーザー sou1649sou1649
提出日時 2021-04-16 22:14:08
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 199 ms / 2,000 ms
コード長 2,222 bytes
コンパイル時間 4,760 ms
コンパイル使用メモリ 264,704 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2023-09-16 00:59:52
合計ジャッジ時間 10,105 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,388 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 70 ms
6,884 KB
testcase_13 AC 76 ms
6,428 KB
testcase_14 AC 85 ms
7,308 KB
testcase_15 AC 32 ms
4,812 KB
testcase_16 AC 26 ms
5,136 KB
testcase_17 AC 30 ms
5,016 KB
testcase_18 AC 129 ms
7,980 KB
testcase_19 AC 75 ms
6,736 KB
testcase_20 AC 23 ms
4,384 KB
testcase_21 AC 112 ms
7,124 KB
testcase_22 AC 12 ms
4,384 KB
testcase_23 AC 41 ms
5,208 KB
testcase_24 AC 111 ms
7,928 KB
testcase_25 AC 31 ms
4,824 KB
testcase_26 AC 114 ms
8,468 KB
testcase_27 AC 37 ms
5,240 KB
testcase_28 AC 50 ms
6,184 KB
testcase_29 AC 52 ms
5,476 KB
testcase_30 AC 74 ms
5,332 KB
testcase_31 AC 43 ms
5,020 KB
testcase_32 AC 199 ms
11,068 KB
testcase_33 AC 150 ms
10,604 KB
testcase_34 AC 182 ms
11,136 KB
testcase_35 AC 151 ms
10,348 KB
testcase_36 AC 155 ms
10,348 KB
testcase_37 AC 106 ms
10,128 KB
testcase_38 AC 128 ms
10,280 KB
testcase_39 AC 152 ms
10,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#if __has_include(<atcoder/all>)
    #include <atcoder/all>
    using namespace atcoder;
#endif

using namespace std;
using Graph = vector<vector<int>>;
using vst= vector<string>;
using vin= vector<int>;
using ll=long long;
using ull=unsigned long long;
using vll= vector<ll>;
using P=pair<int ,int>;
using pqi=priority_queue<int, vector<int>, greater<int>>;
using pqp=priority_queue<P, vector<P>, greater<P>>;

//const long double pi=acos(-1);
#define ft first
#define sd second
#define fn front
#define pb push_back
#define eb emplace_back
#define it insert
#define vvi vector<vector<int>>
#define si(v) int((v).size())
#define pq priority_queue
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rell(i,n) for (ll i=0; i< (ll)(n); i++)
#define sot(x) sort(x.begin(), x.end())
#define rese(x) reverse(x.begin(), x.end())
#define gsot(x) sort(x.begin(), x.end(), greater<ll>());
#define vnn(x,y,s,name) vector<vector<int>> name(x, vector<int>(y,s))
#define mse(x) memset(x, 0, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define mii(x,y,z) min(x,min(y,z))
#define maa(x,y,z) max(x,max(y,z))
#define cps CLOCKS_PER_SEC
#define yes cout<<"Yes"<<"\n"
#define no cout<<"No"<<"\n"
#define cset(x) cout<<fixed<<setprecision(x)


//const int INF=1001001001;
//const ll INF=1e18;
//998244353  1000000007


int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    vin a(n);
    pqp q;
    P t;
    rep(i,n){
        cin>>a[i];
        t.ft=a[i];
        t.sd=i;
        q.push(t);
    }
    Graph G(n);
    rep(i,m){
        int u,v;
        cin>>u>>v;
        u--;
        v--;
        G[u].eb(v);
        G[v].eb(u);
    }
    int k;
    cin>>k;
    vector<bool> l(n,false);
    rep(i,k){
        int b;
        cin>>b;
        b--;
        l[b]=true;
    }
    vector<int> r;
    while(!q.empty()){
        auto h=q.top();
        q.pop();
        if(l[h.sd]==false) continue;
        else{
            r.eb(h.sd);
            l[h.sd]=true;
            for(auto g:G[h.sd]){
                if(a[g]>h.ft)
                l[g]=(!l[g]);
            }
        }
    }
    cout<<r.size()<<endl;
    for(auto x:r) cout<<x+1<<endl;
}


















0