結果

問題 No.1477 Lamps on Graph
ユーザー jutamajutama
提出日時 2021-04-16 20:26:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 186 ms / 2,000 ms
コード長 1,772 bytes
コンパイル時間 3,603 ms
コンパイル使用メモリ 167,904 KB
実行使用メモリ 11,748 KB
最終ジャッジ日時 2023-09-15 21:09:04
合計ジャッジ時間 8,923 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 1 ms
4,384 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,384 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,384 KB
testcase_12 AC 73 ms
7,220 KB
testcase_13 AC 77 ms
6,872 KB
testcase_14 AC 85 ms
7,756 KB
testcase_15 AC 32 ms
5,196 KB
testcase_16 AC 26 ms
5,288 KB
testcase_17 AC 30 ms
5,220 KB
testcase_18 AC 126 ms
8,384 KB
testcase_19 AC 75 ms
7,352 KB
testcase_20 AC 24 ms
4,596 KB
testcase_21 AC 109 ms
7,448 KB
testcase_22 AC 12 ms
4,380 KB
testcase_23 AC 40 ms
5,516 KB
testcase_24 AC 111 ms
8,556 KB
testcase_25 AC 32 ms
4,756 KB
testcase_26 AC 113 ms
8,804 KB
testcase_27 AC 36 ms
5,464 KB
testcase_28 AC 51 ms
6,748 KB
testcase_29 AC 51 ms
6,064 KB
testcase_30 AC 72 ms
5,652 KB
testcase_31 AC 42 ms
5,532 KB
testcase_32 AC 186 ms
11,692 KB
testcase_33 AC 140 ms
11,324 KB
testcase_34 AC 180 ms
11,748 KB
testcase_35 AC 153 ms
11,044 KB
testcase_36 AC 151 ms
11,040 KB
testcase_37 AC 110 ms
10,900 KB
testcase_38 AC 123 ms
10,944 KB
testcase_39 AC 147 ms
11,024 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <atcoder/all>
#include <bitset>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using namespace atcoder;

//* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *//

void input() {
    
    
}


void solve() {
    
    using pii = pair<int, int>;
    
    int N, M; cin >> N >> M;
    vector<pii> A(N), Ar(N);
    vector<vector<int>> edges(N);
    vector<int> B(N);
    
    for(int i = 0; i < N; i++) {
        int a; cin >> a;
        A[i] = {i, a};
        Ar[i] = {a, i};
    }
    sort(Ar.begin(), Ar.end());
    
    for(int i = 0; i < M; i++) {
        int u, v; cin >> u >> v;
        u--; v--;
        edges[u].push_back(v);
        edges[v].push_back(u);
    }
    int K; cin >> K;
    for(int i = 0; i < K; i++) {
        int b; cin >> b;
        b--;
        B[b] = 1;
    }
    
    vector<int> ans;
    for(int i = 0; i < N; i++) {
        int Ai = Ar[i].first;
        int ni = Ar[i].second;
        
        if(B[ni]) {
            ans.push_back(ni);
            
            for(auto e : edges[ni]) {
                if(Ai < A[e].second) {
                    B[e] ^= 1;
                }
            }
        }
    }
    
    int Z = (int)ans.size();
    cout << Z << endl;
    for(int i = 0; i < Z; i++) {
        cout << ans[i]+1 << endl;
    }
    
    
    
    
    
    
}

//* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *//

int main() {
    
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
    std::cin.tie(0);
    ios::sync_with_stdio(false);
    
    input();
    solve();
    
    return 0;
}
0