結果
| 問題 |
No.1477 Lamps on Graph
|
| コンテスト | |
| ユーザー |
srjywrdnprkt
|
| 提出日時 | 2023-04-22 09:23:00 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,317 bytes |
| コンパイル時間 | 1,295 ms |
| コンパイル使用メモリ | 119,004 KB |
| 最終ジャッジ日時 | 2025-02-12 12:59:07 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 1 |
| other | AC * 4 WA * 30 TLE * 3 MLE * 1 |
ソースコード
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <complex>
#include <cassert>
using namespace std;
template<typename T> using pq = priority_queue<T, vector<T>, greater<T>>;
int main(){
long long N, M, A, B, C, start, K;
long long from, alt, d;
cin >> N >> M;
pq<pair<long long, long long>> que;
vector<long long> num(N), ans;
deque<bool> color(N);
for (int i=0; i<N; i++) cin >> num[i];
vector<vector<long long>> E(N);
for (int i=0; i < M; i++){
cin >> A >> B;
A--; B--;
E[A].push_back(B);
E[B].push_back(A);
}
cin >> K;
for (int i=0; i<K; i++){
cin >> B; B--;
color[B] = 1;
que.push({num[B], B});
}
while(!que.empty()){
tie(d, from) = que.top();
que.pop();
color[from] = 0;
ans.push_back(from+1);
for (auto to : E[from]){
if (num[to] > num[from]){
color[to] ^= 1;
if (color[to] == 1){
que.push({num[to], to});
}
}
}
}
cout << ans.size() << endl;
for (auto x : ans) cout << x << endl;
return 0;
}
srjywrdnprkt