結果

問題 No.1477 Lamps on Graph
ユーザー HaaHaa
提出日時 2021-04-16 20:10:56
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 269 ms / 2,000 ms
コード長 1,019 bytes
コンパイル時間 2,307 ms
コンパイル使用メモリ 177,848 KB
実行使用メモリ 14,156 KB
最終ジャッジ日時 2023-09-15 20:24:04
合計ジャッジ時間 8,984 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
5,888 KB
testcase_01 AC 3 ms
5,548 KB
testcase_02 AC 3 ms
5,712 KB
testcase_03 AC 4 ms
5,620 KB
testcase_04 AC 4 ms
5,616 KB
testcase_05 AC 3 ms
5,664 KB
testcase_06 AC 4 ms
5,616 KB
testcase_07 AC 3 ms
5,600 KB
testcase_08 AC 4 ms
5,676 KB
testcase_09 AC 4 ms
5,916 KB
testcase_10 AC 4 ms
5,876 KB
testcase_11 AC 3 ms
5,724 KB
testcase_12 AC 128 ms
10,044 KB
testcase_13 AC 124 ms
9,532 KB
testcase_14 AC 151 ms
10,956 KB
testcase_15 AC 62 ms
8,168 KB
testcase_16 AC 42 ms
7,580 KB
testcase_17 AC 47 ms
7,556 KB
testcase_18 AC 172 ms
10,308 KB
testcase_19 AC 122 ms
9,572 KB
testcase_20 AC 45 ms
7,196 KB
testcase_21 AC 154 ms
9,404 KB
testcase_22 AC 30 ms
6,888 KB
testcase_23 AC 93 ms
8,744 KB
testcase_24 AC 195 ms
11,408 KB
testcase_25 AC 60 ms
7,828 KB
testcase_26 AC 182 ms
10,956 KB
testcase_27 AC 70 ms
8,296 KB
testcase_28 AC 91 ms
9,176 KB
testcase_29 AC 86 ms
8,760 KB
testcase_30 AC 97 ms
7,840 KB
testcase_31 AC 60 ms
7,768 KB
testcase_32 AC 269 ms
14,156 KB
testcase_33 AC 223 ms
13,616 KB
testcase_34 AC 252 ms
14,020 KB
testcase_35 AC 231 ms
13,056 KB
testcase_36 AC 227 ms
13,264 KB
testcase_37 AC 178 ms
12,948 KB
testcase_38 AC 197 ms
13,212 KB
testcase_39 AC 227 ms
13,108 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) v.begin(),v.end()
constexpr ll MOD=998244353;
constexpr ll INF=2e18;

int main(){
    int n, m; cin >> n >> m;
    VI a(n); vector<P> p(n);
    REP(i,n){
        cin >> a[i];
        p[i]={a[i],i};
    }
    sort(ALL(p));
    VVI g(110000);
    int u, v;
    REP(i,m){
        cin >> u >> v;
        u--, v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    VI f(n,0);
    int k; cin >> k;
    int b;
    REP(i,k){
        cin >> b;
        f[b-1]=1;
    }
    int z=0; VI ans;
    REP(i,n){
        if(f[p[i].second]){
            z++;
            ans.push_back(p[i].second+1);
            for(auto to:g[p[i].second]){
                if(p[i].first<a[to])
                    f[to]=!f[to];
            }
        }
    }
    cout << z << endl;
    for(auto i:ans)
        cout << i << endl;
    return 0;
}
0