結果

問題 No.1477 Lamps on Graph
ユーザー 👑 NachiaNachia
提出日時 2021-04-16 20:54:01
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 902 bytes
コンパイル時間 889 ms
コンパイル使用メモリ 88,688 KB
実行使用メモリ 11,340 KB
最終ジャッジ日時 2023-09-15 22:15:34
合計ジャッジ時間 4,973 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 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 2 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 46 ms
6,936 KB
testcase_13 AC 41 ms
6,596 KB
testcase_14 AC 55 ms
7,428 KB
testcase_15 AC 26 ms
5,004 KB
testcase_16 AC 18 ms
5,352 KB
testcase_17 AC 17 ms
5,264 KB
testcase_18 AC 46 ms
8,328 KB
testcase_19 AC 38 ms
7,056 KB
testcase_20 AC 16 ms
4,380 KB
testcase_21 AC 40 ms
7,220 KB
testcase_22 AC 11 ms
4,380 KB
testcase_23 AC 32 ms
5,648 KB
testcase_24 AC 59 ms
8,512 KB
testcase_25 AC 22 ms
4,732 KB
testcase_26 AC 55 ms
8,632 KB
testcase_27 AC 30 ms
5,480 KB
testcase_28 AC 36 ms
6,556 KB
testcase_29 AC 32 ms
5,648 KB
testcase_30 AC 23 ms
5,736 KB
testcase_31 AC 19 ms
5,400 KB
testcase_32 AC 71 ms
11,340 KB
testcase_33 AC 69 ms
10,952 KB
testcase_34 AC 63 ms
11,320 KB
testcase_35 AC 80 ms
10,980 KB
testcase_36 AC 79 ms
10,664 KB
testcase_37 AC 70 ms
10,448 KB
testcase_38 AC 74 ms
10,644 KB
testcase_39 AC 78 ms
10,964 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
using ll=long long;
using ull=unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

int N,M;
vector<vector<int>> E;
vector<int> A;
int K;
vector<int> X;

int main(){
  scanf("%d%d",&N,&M);
  A.resize(N);
  rep(i,N) scanf("%d",&A[i]);
  E.resize(N);
  rep(i,M){
    int u,v; scanf("%d%d",&u,&v); u--; v--;
    E[u].push_back(v);
    E[v].push_back(u);
  }
  scanf("%d",&K);
  X.assign(N,0);
  rep(i,N){ int b; scanf("%d",&b); b--; X[b]=1; }
  
  vector<pair<int,int>> Ord;
  rep(i,N) Ord.push_back({A[i],i});
  sort(Ord.begin(),Ord.end());

  vector<int> ans;
  rep(i,N){
    int p = Ord[i].second;
    if(X[p]==0) continue;
    ans.push_back(p);
    X[p] ^= 1;
    for(int e:E[p]) if(A[e]>A[p]) X[e] ^= 1;
  }

  printf("%d\n",(int)ans.size());
  for(int a:ans) printf("%d\n",a+1);
  return 0;
}
0