結果

問題 No.1477 Lamps on Graph
ユーザー sapphire__15sapphire__15
提出日時 2021-04-16 20:20:34
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 263 ms / 2,000 ms
コード長 2,398 bytes
コンパイル時間 1,471 ms
コンパイル使用メモリ 138,172 KB
実行使用メモリ 10,820 KB
最終ジャッジ日時 2023-09-15 20:51:14
合計ジャッジ時間 7,699 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 111 ms
6,848 KB
testcase_13 AC 115 ms
6,284 KB
testcase_14 AC 134 ms
7,200 KB
testcase_15 AC 54 ms
5,132 KB
testcase_16 AC 40 ms
4,820 KB
testcase_17 AC 43 ms
4,884 KB
testcase_18 AC 168 ms
7,740 KB
testcase_19 AC 108 ms
6,648 KB
testcase_20 AC 39 ms
4,380 KB
testcase_21 AC 146 ms
6,788 KB
testcase_22 AC 22 ms
4,380 KB
testcase_23 AC 70 ms
5,088 KB
testcase_24 AC 168 ms
7,832 KB
testcase_25 AC 52 ms
4,692 KB
testcase_26 AC 160 ms
8,200 KB
testcase_27 AC 63 ms
5,212 KB
testcase_28 AC 80 ms
6,260 KB
testcase_29 AC 81 ms
5,708 KB
testcase_30 AC 96 ms
5,148 KB
testcase_31 AC 57 ms
5,000 KB
testcase_32 AC 263 ms
10,768 KB
testcase_33 AC 214 ms
10,576 KB
testcase_34 AC 250 ms
10,820 KB
testcase_35 AC 224 ms
10,128 KB
testcase_36 AC 215 ms
10,128 KB
testcase_37 AC 162 ms
10,112 KB
testcase_38 AC 184 ms
10,212 KB
testcase_39 AC 209 ms
10,128 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <cmath>
#include <complex>
#include <functional>
#include <cassert>
#include <stack>
#include <numeric>
#include <iomanip>
#include <limits>
#include <random>
#include <unordered_map>

typedef int64_t ll;
typedef std::pair<int, int> Pii;
typedef std::pair<ll, ll> Pll;
typedef std::pair<double, double> Pdd;

#define rip(_i, _n, _s) for (int _i = (_s); _i < (int)(_n); _i++)
#define all(_l) _l.begin(), _l.end()
#define rall(_l) _l.rbegin(), _l.rend()
#define MM << " " <<

template<typename _T>
using MaxHeap = std::priority_queue<_T>;
template<typename _T>
using MinHeap = std::priority_queue<_T, std::vector<_T>, std::greater<_T>>;

template<typename _T>
inline bool chmax(_T &_l, const _T _b) {
    if (_l < _b) {
        _l = _b;
        return true;
    }
    return false;
}
template<typename _T>
inline bool chmin(_T &_l, const _T _b) {
    if (_l > _b) {
        _l = _b;
        return true;
    }
    return false;
}

template<typename _T>
void vdeb(const std::vector<_T> &bb) {
    for (unsigned int i = 0;i < bb.size();i++) {
        if (i == bb.size() - 1) std::cout << bb[i];
        else std::cout << bb[i] << ' ';
    }
    std::cout << '\n';
}
template<typename _T>
void vdeb(const std::vector<std::vector<_T>> &bb) {
    for (unsigned int i = 0;i < bb.size();i++) {
        std::cout << i << ' ';
        vdeb(bb[i]);
    }
    std::cout << '\n';
}

using namespace std;

int main() {
    int n, m; cin >> n >> m;
    vector<Pii> da(n);
    vector<int> p(n);
    rip(i,n,0) {
        cin >> da[i].first;
        p[i] = da[i].first;
        da[i].second = i;
    }
    vector<vector<int>> g(n, vector<int>(0));
    rip(i,m,0) {
        int a,b; cin >> a >> b;
        --a;--b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int k; cin >> k;
    vector<bool> ju(n);
    rip(i,k,0) {
        int x; cin >> x;
        --x;
        ju[x] = true;
    }
    sort(all(da));
    vector<int> ans;
    rip(i,n,0) {
        if(ju[da[i].second]) {
            ans.push_back(da[i].second+1);
            ju[da[i].second] = false;
            for(auto &&j : g[da[i].second]) {
                if(da[i].first < p[j]) ju[j] = ju[j] ^ true;
            }
        }
    }
    cout << ans.size() << endl;
    for(auto &&i: ans) cout << i << endl;
}
0