結果

問題 No.1477 Lamps on Graph
ユーザー monnumonnu
提出日時 2021-04-16 20:41:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 261 ms / 2,000 ms
コード長 1,018 bytes
コンパイル時間 1,693 ms
コンパイル使用メモリ 174,968 KB
実行使用メモリ 11,396 KB
最終ジャッジ日時 2023-09-15 21:42:37
合計ジャッジ時間 8,095 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 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 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 116 ms
6,996 KB
testcase_13 AC 116 ms
6,560 KB
testcase_14 AC 145 ms
7,440 KB
testcase_15 AC 57 ms
4,888 KB
testcase_16 AC 40 ms
5,200 KB
testcase_17 AC 44 ms
4,960 KB
testcase_18 AC 169 ms
8,048 KB
testcase_19 AC 111 ms
6,928 KB
testcase_20 AC 40 ms
4,384 KB
testcase_21 AC 147 ms
7,076 KB
testcase_22 AC 22 ms
4,376 KB
testcase_23 AC 71 ms
5,148 KB
testcase_24 AC 172 ms
8,004 KB
testcase_25 AC 53 ms
4,692 KB
testcase_26 AC 164 ms
8,580 KB
testcase_27 AC 66 ms
5,428 KB
testcase_28 AC 84 ms
6,580 KB
testcase_29 AC 85 ms
5,684 KB
testcase_30 AC 95 ms
5,432 KB
testcase_31 AC 58 ms
5,308 KB
testcase_32 AC 261 ms
11,008 KB
testcase_33 AC 217 ms
11,396 KB
testcase_34 AC 253 ms
11,240 KB
testcase_35 AC 231 ms
10,816 KB
testcase_36 AC 221 ms
10,760 KB
testcase_37 AC 174 ms
10,516 KB
testcase_38 AC 203 ms
10,488 KB
testcase_39 AC 212 ms
10,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
using ll=long long;
using Graph=vector<vector<int>>;
#define MAX 200003
#define MOD 998244353
#define INF 1000000000

int main(){
  int N,M;
  cin>>N>>M;
  vector<int> A(N);
  vector<pair<int,int>> order(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
    order[i].first=A[i];
    order[i].second=i;
  }
  sort(order.begin(),order.end());
  Graph G(N);
  for(int i=0;i<M;i++){
    int u,v;
    cin>>u>>v;
    u--;v--;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  int K;
  cin>>K;
  vector<int> light(N,0);
  for(int i=0;i<K;i++){
    int B;
    cin>>B;
    B--;
    light[B]=1;
  }

  vector<int> ans;
  for(int i=0;i<N;i++){
    int v=order[i].second;
    if(light[v]==1){
      ans.push_back(v);
      light[v]=0;
      for(auto nv:G[v]){
        if(A[nv]>A[v]){
          light[nv]=1-light[nv];
        }
      }
    }
  }

  cout<<ans.size()<<endl;
  for(int i=0;i<ans.size();i++){
    cout<<ans[i]+1<<endl;
  }
}
0