結果

問題 No.92 逃走経路
ユーザー tktk_snsn
提出日時 2021-04-27 22:29:11
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 26 ms / 5,000 ms
コード長 1,146 bytes
コンパイル時間 938 ms
コンパイル使用メモリ 97,708 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-06 17:30:45
合計ジャッジ時間 1,926 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <vector>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <unordered_map>
using namespace std;
template<class T> inline bool chmax(T& a, T b){ if (a < b){ a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b){ if (a > b){ a = b; return true; } return false; }
set<int> G[101][101];
int dp[101][1001];
int main() {
int n, m, k;
cin >> n >> m >> k;
for (int i=0;i<m;++i) {
int a, b, c;
cin >> a >> b >> c;
a--; b--;
G[a][b].insert(c);
G[b][a].insert(c);
}
for(int i=0; i<n; ++i) dp[i][0] = 1;
for(int i=0; i<k; ++i) {
int d; cin >> d;
for (int s=0; s<n; ++s) {
if (!dp[s][i]) continue;
for (int t=0; t<n; ++t) {
if (G[s][t].find(d) != G[s][t].end()) dp[t][i+1] = 1;
}
}
}
vector<int> ans;
for(int i=0; i<n; ++i) if (dp[i][k]) ans.push_back(i+1);
cout << ans.size() << endl;
for(int i=0; i<ans.size(); ++i) {
if(i) cout << " ";
cout << ans[i];
}
cout << endl;
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0