結果

問題 No.1477 Lamps on Graph
ユーザー ShibuyapShibuyap
提出日時 2021-05-03 14:02:49
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 265 ms / 2,000 ms
コード長 1,168 bytes
コンパイル時間 2,235 ms
コンパイル使用メモリ 208,524 KB
実行使用メモリ 13,840 KB
最終ジャッジ日時 2023-09-29 09:44:04
合計ジャッジ時間 9,098 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
8,032 KB
testcase_01 AC 5 ms
8,144 KB
testcase_02 AC 5 ms
8,316 KB
testcase_03 AC 5 ms
8,068 KB
testcase_04 AC 5 ms
8,052 KB
testcase_05 AC 5 ms
8,028 KB
testcase_06 AC 4 ms
8,136 KB
testcase_07 AC 4 ms
8,060 KB
testcase_08 AC 5 ms
8,104 KB
testcase_09 AC 4 ms
8,188 KB
testcase_10 AC 4 ms
8,140 KB
testcase_11 AC 5 ms
8,264 KB
testcase_12 AC 122 ms
10,460 KB
testcase_13 AC 122 ms
10,152 KB
testcase_14 AC 148 ms
10,820 KB
testcase_15 AC 60 ms
9,428 KB
testcase_16 AC 44 ms
9,212 KB
testcase_17 AC 46 ms
8,984 KB
testcase_18 AC 171 ms
10,816 KB
testcase_19 AC 114 ms
10,576 KB
testcase_20 AC 42 ms
8,972 KB
testcase_21 AC 151 ms
10,104 KB
testcase_22 AC 26 ms
8,692 KB
testcase_23 AC 77 ms
9,952 KB
testcase_24 AC 179 ms
11,320 KB
testcase_25 AC 56 ms
9,184 KB
testcase_26 AC 168 ms
11,308 KB
testcase_27 AC 69 ms
9,616 KB
testcase_28 AC 88 ms
10,088 KB
testcase_29 AC 88 ms
9,644 KB
testcase_30 AC 97 ms
9,100 KB
testcase_31 AC 61 ms
9,040 KB
testcase_32 AC 265 ms
13,840 KB
testcase_33 AC 218 ms
13,272 KB
testcase_34 AC 251 ms
13,812 KB
testcase_35 AC 235 ms
12,832 KB
testcase_36 AC 226 ms
12,836 KB
testcase_37 AC 178 ms
12,644 KB
testcase_38 AC 196 ms
12,992 KB
testcase_39 AC 226 ms
12,828 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("YES");}else{puts("NO");}
#define MAX_N 200005

vector<int> G[MAX_N];

int main() {
    int n, m;
    cin >> n >> m;
    int a[n] = {};
    rep(i,n) cin >> a[i];
    rep(i,m){
        int u, v;
        cin >> u >> v;
        u--; v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    vector<P> v;
    rep(i,n){
        v.push_back(P(a[i],i));
    }
    sort(v.begin(), v.end());
    int f[n] = {};
    int k; cin >> k;
    rep(i,k){
        int b; cin >> b;
        b--;
        f[b] = 1;
    }
    vector<int> ans;

    rep(i,n){
        int x = v[i].second;
        if(f[x] == 1){
            ans.push_back(x+1);
            f[x] = 0;
            rep(j,G[x].size()){
                int y = G[x][j];
                if(a[x] < a[y]) f[y] = 1 - f[y];
            }
        }
    }

    cout << ans.size() << endl;
    rep(i,ans.size()){
        cout << ans[i] << endl;
    }
    return 0;
}
 
 
0