結果

問題 No.1477 Lamps on Graph
ユーザー kotatsugamekotatsugame
提出日時 2021-04-24 04:57:36
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 257 ms / 2,000 ms
コード長 668 bytes
コンパイル時間 697 ms
コンパイル使用メモリ 78,576 KB
実行使用メモリ 10,580 KB
最終ジャッジ日時 2023-09-17 13:26:57
合計ジャッジ時間 7,545 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
6,444 KB
testcase_01 AC 4 ms
6,392 KB
testcase_02 AC 4 ms
6,400 KB
testcase_03 AC 4 ms
6,452 KB
testcase_04 AC 4 ms
6,556 KB
testcase_05 AC 4 ms
6,412 KB
testcase_06 AC 4 ms
6,464 KB
testcase_07 AC 4 ms
6,392 KB
testcase_08 AC 4 ms
6,620 KB
testcase_09 AC 4 ms
6,488 KB
testcase_10 AC 4 ms
6,552 KB
testcase_11 AC 4 ms
6,552 KB
testcase_12 AC 107 ms
7,948 KB
testcase_13 AC 110 ms
7,716 KB
testcase_14 AC 131 ms
8,044 KB
testcase_15 AC 54 ms
7,204 KB
testcase_16 AC 40 ms
6,896 KB
testcase_17 AC 43 ms
6,944 KB
testcase_18 AC 165 ms
8,256 KB
testcase_19 AC 105 ms
8,060 KB
testcase_20 AC 39 ms
7,084 KB
testcase_21 AC 142 ms
7,656 KB
testcase_22 AC 24 ms
6,768 KB
testcase_23 AC 69 ms
7,300 KB
testcase_24 AC 161 ms
8,420 KB
testcase_25 AC 52 ms
7,256 KB
testcase_26 AC 154 ms
8,412 KB
testcase_27 AC 61 ms
7,212 KB
testcase_28 AC 79 ms
7,960 KB
testcase_29 AC 79 ms
7,532 KB
testcase_30 AC 94 ms
6,960 KB
testcase_31 AC 59 ms
7,012 KB
testcase_32 AC 257 ms
10,580 KB
testcase_33 AC 208 ms
9,532 KB
testcase_34 AC 242 ms
7,636 KB
testcase_35 AC 211 ms
9,440 KB
testcase_36 AC 203 ms
9,504 KB
testcase_37 AC 157 ms
9,200 KB
testcase_38 AC 179 ms
9,444 KB
testcase_39 AC 201 ms
9,340 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:8:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    8 | main()
      | ^~~~

ソースコード

diff #

#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;
}
0