結果
| 問題 |
No.1477 Lamps on Graph
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-04-16 20:21:29 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,296 bytes |
| コンパイル時間 | 1,669 ms |
| コンパイル使用メモリ | 109,060 KB |
| 最終ジャッジ日時 | 2025-01-20 18:36:26 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 23 WA * 15 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:23:29: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
23 | for (auto &&i : A) scanf("%d", &i);
| ~~~~~^~~~~~~~~~
main.cpp:27:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
27 | scanf("%d %d", &u, &v);
| ~~~~~^~~~~~~~~~~~~~~~~
main.cpp:38:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
38 | scanf("%d", &x);
| ~~~~~^~~~~~~~~~
ソースコード
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>
static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;
template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;
int main() {
int n, m;
cin >> n >> m;
vector<int> A(n);
for (auto &&i : A) scanf("%d", &i);
vector<vector<int>> G(n);
for (int i = 0; i < m; ++i) {
int u, v;
scanf("%d %d", &u, &v);
u--; v--;
G[u].emplace_back(v);
G[v].emplace_back(u);
}
auto f = [&](int a, int b){ return A[a] < A[b]; };
set<int, decltype(f)> s(f);
int k;
cin >> k;
for (int i = 0; i < k; ++i) {
int x;
scanf("%d", &x);
s.emplace(x-1);
}
vector<int> ans;
while(!s.empty()){
int a = *s.begin();
ans.emplace_back(a);
s.erase(a);
for (auto &&b : G[a]) {
if(A[a] < A[b]) {
if(s.count(b)) s.erase(b);
else s.emplace(b);
}
}
}
cout << ans.size() << "\n";
for (auto &&i : ans) {
cout << i+1 << "\n";
}
return 0;
}