結果

問題 No.1477 Lamps on Graph
ユーザー firiexpfiriexp
提出日時 2021-04-16 20:21:29
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,296 bytes
コンパイル時間 1,483 ms
コンパイル使用メモリ 111,612 KB
実行使用メモリ 14,924 KB
最終ジャッジ日時 2023-09-15 20:55:29
合計ジャッジ時間 7,702 ms
ジャッジサーバーID
(参考情報)
judge14 / 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,380 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 2 ms
4,376 KB
testcase_08 WA -
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 60 ms
7,084 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 30 ms
4,704 KB
testcase_16 AC 17 ms
4,940 KB
testcase_17 AC 18 ms
5,248 KB
testcase_18 WA -
testcase_19 AC 55 ms
7,648 KB
testcase_20 AC 25 ms
4,884 KB
testcase_21 AC 71 ms
9,436 KB
testcase_22 AC 15 ms
4,376 KB
testcase_23 AC 44 ms
5,396 KB
testcase_24 WA -
testcase_25 AC 33 ms
4,940 KB
testcase_26 WA -
testcase_27 AC 31 ms
5,260 KB
testcase_28 AC 36 ms
6,544 KB
testcase_29 AC 49 ms
6,316 KB
testcase_30 AC 39 ms
6,992 KB
testcase_31 AC 25 ms
5,784 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 81 ms
10,028 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--;
        G[u].emplace_back(v);
        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(A[a] < A[b]) {
                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