結果

問題 No.1477 Lamps on Graph
ユーザー chocoruskchocorusk
提出日時 2021-04-16 22:15:30
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 257 ms / 2,000 ms
コード長 1,404 bytes
コンパイル時間 3,372 ms
コンパイル使用メモリ 190,516 KB
実行使用メモリ 10,188 KB
最終ジャッジ日時 2023-09-16 01:03:06
合計ジャッジ時間 9,547 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,744 KB
testcase_01 AC 3 ms
5,792 KB
testcase_02 AC 3 ms
5,752 KB
testcase_03 AC 3 ms
5,800 KB
testcase_04 AC 3 ms
5,796 KB
testcase_05 AC 4 ms
5,808 KB
testcase_06 AC 3 ms
5,740 KB
testcase_07 AC 3 ms
5,752 KB
testcase_08 AC 3 ms
5,796 KB
testcase_09 AC 3 ms
6,032 KB
testcase_10 AC 4 ms
5,988 KB
testcase_11 AC 3 ms
5,744 KB
testcase_12 AC 108 ms
7,348 KB
testcase_13 AC 111 ms
7,284 KB
testcase_14 AC 130 ms
7,960 KB
testcase_15 AC 53 ms
6,644 KB
testcase_16 AC 40 ms
6,448 KB
testcase_17 AC 43 ms
6,528 KB
testcase_18 AC 161 ms
7,648 KB
testcase_19 AC 103 ms
7,332 KB
testcase_20 AC 39 ms
6,340 KB
testcase_21 AC 141 ms
7,376 KB
testcase_22 AC 23 ms
6,260 KB
testcase_23 AC 68 ms
6,848 KB
testcase_24 AC 160 ms
7,900 KB
testcase_25 AC 51 ms
6,516 KB
testcase_26 AC 154 ms
8,092 KB
testcase_27 AC 60 ms
6,892 KB
testcase_28 AC 78 ms
7,192 KB
testcase_29 AC 78 ms
6,996 KB
testcase_30 AC 94 ms
6,480 KB
testcase_31 AC 58 ms
6,472 KB
testcase_32 AC 257 ms
10,188 KB
testcase_33 AC 209 ms
9,208 KB
testcase_34 AC 234 ms
7,308 KB
testcase_35 AC 211 ms
8,868 KB
testcase_36 AC 202 ms
8,868 KB
testcase_37 AC 157 ms
8,692 KB
testcase_38 AC 177 ms
8,996 KB
testcase_39 AC 203 ms
8,916 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
vector<int> g[100010];
int b[100010];
vector<int> ans;
int main()
{
    int n, m; cin>>n>>m;
    int a[100010];
    for(int i=0; i<n; i++) cin>>a[i];
    for(int i=0; i<m; i++){
        int u, v; cin>>u>>v;
        u--; v--;
        if(a[u]<a[v]) g[u].push_back(v);
        else if(a[v]<a[u]) g[v].push_back(u);
    }
    int k; cin>>k;
    for(int i=0; i<k; i++){
        int x; cin>>x; x--;
        b[x]=1;
    }
    vector<int> ind(n);
    for(int i=0; i<n; i++) ind[i]=i;
    sort(ind.begin(), ind.end(), [&](int i, int j){ return a[i]<a[j];});
    for(auto i:ind){
        if(b[i]){
            b[i]^=1;
            for(auto j:g[i]){
                b[j]^=1;
            }
            ans.push_back(i+1);
        }
    }
    cout<<ans.size()<<endl;
    for(auto x:ans) cout<<x<<endl;
    return 0;
}
0