結果

問題 No.1477 Lamps on Graph
ユーザー kappybarkappybar
提出日時 2021-04-16 22:22:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,335 bytes
コンパイル時間 1,725 ms
コンパイル使用メモリ 174,336 KB
実行使用メモリ 10,748 KB
最終ジャッジ日時 2023-09-16 01:13:27
合計ジャッジ時間 8,678 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 WA -
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 WA -
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 113 ms
6,764 KB
testcase_13 AC 116 ms
6,264 KB
testcase_14 AC 139 ms
7,120 KB
testcase_15 AC 56 ms
4,952 KB
testcase_16 AC 40 ms
5,088 KB
testcase_17 AC 43 ms
5,004 KB
testcase_18 AC 169 ms
7,528 KB
testcase_19 AC 107 ms
6,816 KB
testcase_20 AC 39 ms
4,376 KB
testcase_21 AC 142 ms
6,704 KB
testcase_22 AC 22 ms
4,376 KB
testcase_23 AC 73 ms
5,076 KB
testcase_24 AC 170 ms
7,768 KB
testcase_25 AC 51 ms
4,664 KB
testcase_26 AC 160 ms
8,292 KB
testcase_27 AC 63 ms
5,272 KB
testcase_28 AC 83 ms
6,340 KB
testcase_29 AC 84 ms
5,796 KB
testcase_30 AC 93 ms
5,276 KB
testcase_31 AC 57 ms
5,324 KB
testcase_32 AC 257 ms
10,744 KB
testcase_33 AC 207 ms
10,504 KB
testcase_34 WA -
testcase_35 AC 226 ms
10,068 KB
testcase_36 AC 218 ms
10,244 KB
testcase_37 AC 173 ms
10,016 KB
testcase_38 AC 188 ms
10,196 KB
testcase_39 AC 213 ms
10,200 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]){
                on[j] = 1 - on[j];
            }
        }
    }
    cout << ans << endl;
    for(int i:res) cout << i+1 << endl;

    return 0;
}
0