結果

問題 No.92 逃走経路
ユーザー kotatsugamekotatsugame
提出日時 2017-10-04 22:58:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 54 ms / 5,000 ms
コード長 788 bytes
コンパイル時間 954 ms
コンパイル使用メモリ 79,676 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2024-04-28 06:06:32
合計ジャッジ時間 2,238 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 36 ms
11,264 KB
testcase_06 AC 6 ms
5,376 KB
testcase_07 AC 6 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 4 ms
5,376 KB
testcase_10 AC 54 ms
11,136 KB
testcase_11 AC 38 ms
11,264 KB
testcase_12 AC 38 ms
11,264 KB
testcase_13 AC 4 ms
5,376 KB
testcase_14 AC 7 ms
5,376 KB
testcase_15 AC 11 ms
5,376 KB
testcase_16 AC 8 ms
5,376 KB
testcase_17 AC 9 ms
5,376 KB
testcase_18 AC 8 ms
5,376 KB
testcase_19 AC 7 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    8 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
vector<pair<int,int> >G[150];
vector<int>ans[1010];
int n,m,k;
main()
{
	cin>>n>>m>>k;
	for(int i=0;i<m;i++)
	{
		int a,b,c;cin>>a>>b>>c;
		G[a].push_back(make_pair(b,c));
		G[b].push_back(make_pair(a,c));
	}
	for(int i=0;i++<n;)ans[0].push_back(i);
	for(int i=0;i<k;i++)
	{
		int C;cin>>C;
		for(int j=0;j<ans[i].size();j++)
		{
			for(int k=0;k<G[ans[i][j]].size();k++)
			{
				if(G[ans[i][j]][k].second==C)
				{
					ans[i+1].push_back(G[ans[i][j]][k].first);
				}
			}
		}
		sort(ans[i+1].begin(),ans[i+1].end());
		ans[i+1].erase(unique(ans[i+1].begin(),ans[i+1].end()),ans[i+1].end());
	}
	cout<<ans[k].size()<<endl;
	for(int i=0;i<ans[k].size();i++)
	{
		cout<<(i?" ":"")<<ans[k][i];
	}
	cout<<endl;
}
0