結果

問題 No.1477 Lamps on Graph
ユーザー kappybarkappybar
提出日時 2021-04-16 22:24:45
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 257 ms / 2,000 ms
コード長 1,351 bytes
コンパイル時間 1,688 ms
コンパイル使用メモリ 173,276 KB
実行使用メモリ 10,976 KB
最終ジャッジ日時 2023-09-16 01:16:38
合計ジャッジ時間 7,860 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 112 ms
6,788 KB
testcase_13 AC 114 ms
6,288 KB
testcase_14 AC 133 ms
7,160 KB
testcase_15 AC 55 ms
4,772 KB
testcase_16 AC 39 ms
4,820 KB
testcase_17 AC 43 ms
4,960 KB
testcase_18 AC 167 ms
7,676 KB
testcase_19 AC 105 ms
6,752 KB
testcase_20 AC 38 ms
4,380 KB
testcase_21 AC 143 ms
6,860 KB
testcase_22 AC 23 ms
4,376 KB
testcase_23 AC 71 ms
5,120 KB
testcase_24 AC 166 ms
7,916 KB
testcase_25 AC 52 ms
4,480 KB
testcase_26 AC 160 ms
8,048 KB
testcase_27 AC 64 ms
5,476 KB
testcase_28 AC 80 ms
6,164 KB
testcase_29 AC 82 ms
5,700 KB
testcase_30 AC 95 ms
5,436 KB
testcase_31 AC 58 ms
5,064 KB
testcase_32 AC 257 ms
10,924 KB
testcase_33 AC 210 ms
10,748 KB
testcase_34 AC 248 ms
10,976 KB
testcase_35 AC 219 ms
10,192 KB
testcase_36 AC 213 ms
10,248 KB
testcase_37 AC 171 ms
10,188 KB
testcase_38 AC 196 ms
10,216 KB
testcase_39 AC 213 ms
10,080 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define chmin(x,y) x = min((x),(y))
#define chmax(x,y) x = max((x),(y))
#define popcount(x) __builtin_popcount(x)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
const int INF = 1e9;
const long long LINF = 1e17;
const int MOD = 1000000007;
//const int MOD = 998244353;
const double PI = 3.14159265358979323846;

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<vector<int>> G(n);
    rep(i,m){
        int u,v;
        cin >> u >> v;
        --u;--v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    int k;
    cin >> k;
    vector<int> on(n,0);
    rep(i,k){
        int b;
        cin >> b;
        --b;
        on[b] = 1;
    }

    vector<int> id(n);
    iota(id.begin(),id.end(),0);
    sort(id.begin(),id.end(),[&](int l,int r){
        return a[l] < a[r];
    });

    int ans = 0;
    vector<int> res;

    for(int _i=0;_i<n;_i++){
        int i = id[_i];
        if(on[i] == 1){
            ++ans;
            on[i] = 0;
            res.push_back(i);
            for(int j:G[i]){
                if(a[j] > a[i]) on[j] = 1 - on[j];
            }
        }
    }
    cout << ans << endl;
    for(int i:res) cout << i+1 << endl;

    return 0;
}
0