結果

問題 No.1477 Lamps on Graph
ユーザー chocono2230chocono2230
提出日時 2021-04-16 20:40:49
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 261 ms / 2,000 ms
コード長 1,264 bytes
コンパイル時間 2,243 ms
コンパイル使用メモリ 210,564 KB
実行使用メモリ 11,200 KB
最終ジャッジ日時 2023-09-15 21:41:41
合計ジャッジ時間 8,434 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,384 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 109 ms
6,972 KB
testcase_13 AC 113 ms
6,532 KB
testcase_14 AC 131 ms
7,500 KB
testcase_15 AC 55 ms
4,852 KB
testcase_16 AC 40 ms
5,120 KB
testcase_17 AC 42 ms
4,840 KB
testcase_18 AC 166 ms
8,288 KB
testcase_19 AC 105 ms
6,992 KB
testcase_20 AC 39 ms
4,380 KB
testcase_21 AC 144 ms
7,016 KB
testcase_22 AC 23 ms
4,376 KB
testcase_23 AC 70 ms
5,224 KB
testcase_24 AC 163 ms
8,016 KB
testcase_25 AC 52 ms
4,752 KB
testcase_26 AC 157 ms
8,464 KB
testcase_27 AC 63 ms
5,328 KB
testcase_28 AC 79 ms
6,500 KB
testcase_29 AC 81 ms
5,632 KB
testcase_30 AC 94 ms
5,396 KB
testcase_31 AC 57 ms
5,096 KB
testcase_32 AC 261 ms
11,176 KB
testcase_33 AC 216 ms
11,200 KB
testcase_34 AC 250 ms
11,060 KB
testcase_35 AC 217 ms
10,784 KB
testcase_36 AC 205 ms
10,624 KB
testcase_37 AC 161 ms
10,532 KB
testcase_38 AC 185 ms
10,464 KB
testcase_39 AC 207 ms
10,596 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> a(n);
  vector<int> aa(n);
  rep(i, n) {
    int in;
    cin >> in;
    a.at(i) = {in, i};
    aa.at(i) = in;
  }
  vector<vector<int>> gr(n, vector<int>());
  rep(i, m){
    int a, b;
    cin >> a >> b;
    a--; b--;
    gr.at(a).push_back(b);
    gr.at(b).push_back(a);
  }
  int k;
  cin >> k;
  vector<int> co(n, 0);
  rep(i, k) {
    int in;
    cin >> in;
    in--;
    co.at(in)++;
  }
  sort(ALL(a));
  vector<int> ans;
  for(auto [c, now] : a) {
    if(co.at(now) % 2 == 0) continue;
    ans.push_back(now);
    for(auto nx : gr.at(now)) {
      if(aa.at(nx) <= c) continue;
      co.at(nx)++;
    }
  }
  cout << ans.size() << endl;
  for(auto i : ans) {
    cout << i+1 << endl;
  }
  return 0;
}
0