結果

問題 No.1477 Lamps on Graph
ユーザー tabae326tabae326
提出日時 2021-04-16 20:17:22
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 79 ms / 2,000 ms
コード長 1,069 bytes
コンパイル時間 2,118 ms
コンパイル使用メモリ 208,904 KB
実行使用メモリ 13,228 KB
最終ジャッジ日時 2023-09-15 20:42:06
合計ジャッジ時間 6,061 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 45 ms
8,176 KB
testcase_13 AC 40 ms
7,636 KB
testcase_14 AC 53 ms
9,032 KB
testcase_15 AC 25 ms
5,868 KB
testcase_16 AC 17 ms
5,652 KB
testcase_17 AC 16 ms
5,416 KB
testcase_18 AC 43 ms
9,124 KB
testcase_19 AC 37 ms
7,724 KB
testcase_20 AC 16 ms
5,020 KB
testcase_21 AC 37 ms
7,912 KB
testcase_22 AC 11 ms
4,564 KB
testcase_23 AC 32 ms
6,744 KB
testcase_24 AC 60 ms
9,724 KB
testcase_25 AC 22 ms
5,504 KB
testcase_26 AC 53 ms
9,904 KB
testcase_27 AC 29 ms
6,472 KB
testcase_28 AC 34 ms
7,544 KB
testcase_29 AC 32 ms
6,632 KB
testcase_30 AC 22 ms
6,172 KB
testcase_31 AC 18 ms
5,588 KB
testcase_32 AC 71 ms
13,168 KB
testcase_33 AC 68 ms
12,588 KB
testcase_34 AC 58 ms
13,228 KB
testcase_35 AC 79 ms
12,208 KB
testcase_36 AC 77 ms
12,204 KB
testcase_37 AC 67 ms
12,020 KB
testcase_38 AC 71 ms
12,092 KB
testcase_39 AC 75 ms
12,084 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

void solve() {
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n);
    rep(i, 0, n) cin >> a[i];
    vector<vector<ll>> G(n);
    rep(i, 0, m) {
        ll u, v;
        cin >> u >> v;
        u--; v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    ll k;
    cin >> k;
    vector<ll> cnt(n, 0);
    rep(i, 0, k) {
        ll u;
        cin >> u;
        u--;
        cnt[u] = 1;
    }
    vector<ll> idx(n);
    iota(idx.begin(), idx.end(), 0);
    sort(idx.begin(), idx.end(), [&](auto l, auto r) {
        return a[l] < a[r];
    } );
    vector<ll> ans;
    for(auto i : idx) {
        if(cnt[i] % 2 == 0) continue;
        ans.push_back(i+1);
        for(auto j : G[i]) {
            if(a[i] < a[j]) cnt[j]++;
        }
    }
    cout << ans.size() << "\n";
    for(auto e : ans) cout << e << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}
0