結果

問題 No.1477 Lamps on Graph
ユーザー firiexpfiriexp
提出日時 2021-04-16 20:29:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,276 bytes
コンパイル時間 1,032 ms
コンパイル使用メモリ 113,144 KB
実行使用メモリ 14,112 KB
最終ジャッジ日時 2023-09-15 21:20:01
合計ジャッジ時間 6,971 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 2 ms
4,376 KB
testcase_08 WA -
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 58 ms
6,540 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 27 ms
4,380 KB
testcase_16 AC 15 ms
4,684 KB
testcase_17 AC 17 ms
5,020 KB
testcase_18 WA -
testcase_19 AC 50 ms
7,208 KB
testcase_20 AC 23 ms
4,484 KB
testcase_21 AC 68 ms
9,100 KB
testcase_22 AC 14 ms
4,380 KB
testcase_23 AC 40 ms
5,104 KB
testcase_24 WA -
testcase_25 AC 30 ms
4,796 KB
testcase_26 WA -
testcase_27 AC 28 ms
4,800 KB
testcase_28 AC 32 ms
5,920 KB
testcase_29 AC 45 ms
5,920 KB
testcase_30 AC 37 ms
7,004 KB
testcase_31 AC 26 ms
5,500 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 68 ms
8,800 KB
testcase_38 WA -
testcase_39 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> A(n);
    for (auto &&i : A) scanf("%d", &i);
    vector<vector<int>> G(n);
    for (int i = 0; i < m; ++i) {
        int u, v;
        scanf("%d %d", &u, &v);
        u--; v--;
        if(A[u] < A[v]) G[u].emplace_back(v);
        if(A[v] < A[u]) G[v].emplace_back(u);
    }
    auto f = [&](int a, int b){ return A[a] < A[b]; };
    set<int, decltype(f)> s(f);
    int k;
    cin >> k;
    for (int i = 0; i < k; ++i) {
        int x;
        scanf("%d", &x);
        s.emplace(x-1);
    }
    vector<int> ans;
    while(!s.empty()){
        int a = *s.begin();
        ans.emplace_back(a);
        s.erase(a);
        for (auto &&b : G[a]) {
            if(s.count(b)) s.erase(b);
            else s.emplace(b);
        }
    }
    cout << ans.size() << "\n";
    for (auto &&i : ans) {
        cout << i+1 << "\n";
    }
    return 0;
}
0