結果

問題 No.1477 Lamps on Graph
ユーザー chocono2230chocono2230
提出日時 2021-04-16 20:32:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,352 bytes
コンパイル時間 2,286 ms
コンパイル使用メモリ 209,952 KB
実行使用メモリ 11,744 KB
最終ジャッジ日時 2023-09-15 21:25:52
合計ジャッジ時間 11,916 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 WA -
testcase_04 AC 2 ms
4,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 2 ms
4,380 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 217 ms
11,336 KB
testcase_34 AC 256 ms
11,616 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
権限があれば一括ダウンロードができます

ソースコード

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), stk(n, 0);
  rep(i, k) {
    int in;
    cin >> in;
    in--;
    co.at(in)++;
  }
  sort(ALL(a));
  vector<int> ans;
  for(auto [c, now] : a) {
    co.at(now) += stk.at(now);
    int add = stk.at(now);
    if(co.at(now) % 2 != 0) {
      add++;
      ans.push_back(now);
    }
    for(auto nx : gr.at(now)) {
      if(aa.at(nx) <= c) continue;
      stk.at(nx) += add;
    }
  }
  cout << ans.size() << endl;
  for(auto i : ans) {
    cout << i+1 << endl;
  }
  return 0;
}
0