結果
問題 | No.1477 Lamps on Graph |
ユーザー |
![]() |
提出日時 | 2021-04-16 20:07:34 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 280 ms / 2,000 ms |
コード長 | 893 bytes |
コンパイル時間 | 4,542 ms |
コンパイル使用メモリ | 255,548 KB |
最終ジャッジ日時 | 2025-01-20 18:25:07 |
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 38 |
ソースコード
#include <stdio.h> #include <bits/stdc++.h> #include <atcoder/all> using namespace atcoder; using mint = modint998244353; using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf 1000000001 int main(){ int N,M; cin>>N>>M; vector<int> A(N); vector<pair<int,int>> P; rep(i,N){ cin>>A[i]; P.emplace_back(A[i],i); } vector<vector<int>> E(N); rep(i,M){ int u,v; cin>>u>>v; u--;v--; E[u].push_back(v); E[v].push_back(u); } vector<int> b(N,0); int K; cin>>K; rep(i,K){ int B; cin>>B; b[B-1] = 1; } sort(P.begin(),P.end()); vector<int> ans; rep(i,P.size()){ int ind = P[i].second; if(b[ind]){ ans.push_back(ind+1); b[ind] ^= 1; rep(j,E[ind].size()){ if(A[ind] < A[E[ind][j]]){ b[E[ind][j]] ^= 1; } } } } cout<<ans.size()<<endl; rep(i,ans.size()){ cout<<ans[i]<<endl; } return 0; }