結果

問題 No.1477 Lamps on Graph
ユーザー abc3abc3
提出日時 2021-04-16 23:32:39
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 356 ms / 2,000 ms
コード長 1,404 bytes
コンパイル時間 2,298 ms
コンパイル使用メモリ 215,960 KB
実行使用メモリ 16,484 KB
最終ジャッジ日時 2023-09-16 03:12:33
合計ジャッジ時間 9,870 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 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,380 KB
testcase_12 AC 142 ms
9,212 KB
testcase_13 AC 154 ms
8,836 KB
testcase_14 AC 176 ms
9,960 KB
testcase_15 AC 67 ms
5,744 KB
testcase_16 AC 53 ms
6,804 KB
testcase_17 AC 59 ms
6,464 KB
testcase_18 AC 235 ms
12,392 KB
testcase_19 AC 148 ms
9,900 KB
testcase_20 AC 46 ms
4,892 KB
testcase_21 AC 204 ms
10,852 KB
testcase_22 AC 25 ms
4,376 KB
testcase_23 AC 84 ms
5,892 KB
testcase_24 AC 235 ms
11,264 KB
testcase_25 AC 62 ms
5,416 KB
testcase_26 AC 224 ms
12,252 KB
testcase_27 AC 76 ms
6,532 KB
testcase_28 AC 105 ms
8,816 KB
testcase_29 AC 104 ms
6,984 KB
testcase_30 AC 126 ms
8,076 KB
testcase_31 AC 77 ms
7,136 KB
testcase_32 AC 356 ms
16,440 KB
testcase_33 AC 301 ms
16,048 KB
testcase_34 AC 300 ms
16,484 KB
testcase_35 AC 324 ms
15,500 KB
testcase_36 AC 306 ms
15,452 KB
testcase_37 AC 228 ms
15,460 KB
testcase_38 AC 264 ms
15,440 KB
testcase_39 AC 299 ms
15,396 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

    #include <bits/stdc++.h>
    using namespace std;
    #include <math.h>
    #include <iomanip>
    #include <cstdint>
    #include <string>
    #include <sstream>
    template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
    template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
    #define rep(i,n) for (int i = 0; i < (n); ++i)
    typedef long long ll;
    using P=pair<ll,ll>;
    const int INF=1001001001;
    const int mod=998244353;

    int main(){
      int n,m;
      cin>>n>>m;
      vector<int>a(n);
      vector<P>p(n);
      rep(i,n){
        cin>>a[i];
        p[i]=P(a[i],i);
      }
      vector<vector<int>>G(n);
      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;
      map<int,int>mp;
      rep(i,k){
        int b;
        cin>>b;
        b--;
        mp[b]=1;
      }
      sort(p.begin(),p.end());
      
      int z=0;
      vector<int>x;
      rep(i,n){
        int val=p[i].first,j=p[i].second;
        if(mp[j]){
          x.push_back(j+1);
          mp[j]=0;
          z++;
          for(int u:G[j]){
            if(a[u]>val){
              mp[u]^=1;
            }
          }
        }
      }
      cout<<z<<endl;
      for(int u:x){
        cout<<u<<endl;
      }
      return 0;
    }
0