結果

問題 No.1477 Lamps on Graph
ユーザー umezoumezo
提出日時 2021-04-16 22:57:57
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 259 ms / 2,000 ms
コード長 846 bytes
コンパイル時間 2,370 ms
コンパイル使用メモリ 207,596 KB
実行使用メモリ 11,380 KB
最終ジャッジ日時 2023-09-16 02:11:33
合計ジャッジ時間 8,741 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
5,764 KB
testcase_01 AC 3 ms
5,772 KB
testcase_02 AC 3 ms
5,900 KB
testcase_03 AC 3 ms
5,708 KB
testcase_04 AC 3 ms
5,840 KB
testcase_05 AC 3 ms
5,696 KB
testcase_06 AC 3 ms
5,688 KB
testcase_07 AC 3 ms
5,692 KB
testcase_08 AC 3 ms
5,784 KB
testcase_09 AC 4 ms
5,704 KB
testcase_10 AC 3 ms
5,700 KB
testcase_11 AC 4 ms
5,704 KB
testcase_12 AC 120 ms
8,316 KB
testcase_13 AC 120 ms
7,852 KB
testcase_14 AC 144 ms
8,540 KB
testcase_15 AC 58 ms
7,004 KB
testcase_16 AC 42 ms
6,732 KB
testcase_17 AC 45 ms
6,812 KB
testcase_18 AC 162 ms
8,192 KB
testcase_19 AC 110 ms
8,036 KB
testcase_20 AC 42 ms
6,660 KB
testcase_21 AC 145 ms
7,772 KB
testcase_22 AC 25 ms
6,364 KB
testcase_23 AC 73 ms
7,248 KB
testcase_24 AC 173 ms
9,048 KB
testcase_25 AC 54 ms
7,016 KB
testcase_26 AC 165 ms
9,112 KB
testcase_27 AC 67 ms
7,168 KB
testcase_28 AC 85 ms
7,704 KB
testcase_29 AC 86 ms
7,324 KB
testcase_30 AC 96 ms
6,612 KB
testcase_31 AC 59 ms
6,792 KB
testcase_32 AC 259 ms
11,380 KB
testcase_33 AC 210 ms
10,784 KB
testcase_34 AC 246 ms
11,176 KB
testcase_35 AC 225 ms
10,632 KB
testcase_36 AC 219 ms
10,636 KB
testcase_37 AC 173 ms
10,568 KB
testcase_38 AC 194 ms
10,564 KB
testcase_39 AC 219 ms
10,572 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

vector<int> G[100100];
int B[100100];

int main(){
  int n,m;
  cin>>n>>m;
  vector<pair<int,int>> A(n);
  vector<int> AA(n);
  rep(i,n){
    int a;
    cin>>a;
    AA[i]=a;
    A[i]={a,i};
  }
  sort(ALL(A));
  rep(i,m){
    int u,v;
    cin>>u>>v;
    u--,v--;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  int k;
  cin>>k;
  rep(i,k){
    int b;
    cin>>b;
    b--;
    B[b]=1;
  }
  vector<int> C;
  rep(i,n){
    int ta=A[i].first;
    int ti=A[i].second;
    if(B[ti]==1){
      C.push_back(ti+1);
      B[ti]=0;
      for(auto x:G[ti]){
        if(AA[x]>ta) B[x]=1-B[x];
      }
    }
  }
  cout<<(int)C.size()<<endl;
  rep(i,(int)C.size()) cout<<C[i]<<endl;
  
  return 0;
}
0