結果
| 問題 |
No.1477 Lamps on Graph
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-04-24 04:57:36 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 262 ms / 2,000 ms |
| コード長 | 668 bytes |
| コンパイル時間 | 778 ms |
| コンパイル使用メモリ | 79,820 KB |
| 実行使用メモリ | 10,700 KB |
| 最終ジャッジ日時 | 2024-07-04 08:58:43 |
| 合計ジャッジ時間 | 8,738 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 38 |
コンパイルメッセージ
main.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
8 | main()
| ^~~~
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int N,M;
vector<int>G[1<<17];
bool on[1<<17];
main()
{
cin>>N>>M;
vector<pair<int,int> >A(N);
for(int i=0;i<N;i++)
{
cin>>A[i].first;
A[i].second=i;
}
for(int i=0;i<M;i++)
{
int u,v;cin>>u>>v;
u--,v--;
if(A[u].first>A[v].first)swap(u,v);
if(A[u].first<A[v].first)G[u].push_back(v);
}
int K;cin>>K;
for(;K--;)
{
int b;cin>>b;
on[b-1]=true;
}
vector<int>ans;
sort(A.begin(),A.end());
for(pair<int,int>p:A)
{
int u=p.second;
if(on[u])
{
ans.push_back(u);
for(int v:G[u])on[v]=!on[v];
}
}
cout<<ans.size()<<endl;
for(int u:ans)cout<<u+1<<endl;
}