結果

問題 No.92 逃走経路
ユーザー shimomire
提出日時 2014-12-07 19:45:41
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 7 ms / 5,000 ms
コード長 1,730 bytes
コンパイル時間 1,329 ms
コンパイル使用メモリ 130,292 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-11 16:15:25
合計ジャッジ時間 1,782 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

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

#include <ctime>
#include <iostream>// io
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>// container
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <algorithm>// other
#include <utility>
#include <complex>
#include <numeric>
#include <functional>
#include <random>
#include <regex>
using namespace std;
typedef long long ll;
#define ALL(c) (c).begin(),(c).end()
#define FOR(i,l,r) for(int i=(int)l;i<(int)r;++i)
#define REP(i,n) FOR(i,0,n)
#define FORr(i,l,r) for(int i=(int)r-1;i>=(int)l;--i)
#define REPr(i,n) FORr(i,0,n)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define IN(l,v,r) ((l)<=(v) && (v)<(r))
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end())
//debug
#define DUMP(x) cerr << #x << " = " << (x)
#define LINE() cerr<< " (L" << __LINE__ << ")"
template<typename T,typename U> T pmod(T x,U M){return (x%M+M)%M;}
stringstream ss;
int main(){
cin.tie(0); ios::sync_with_stdio(false);
ss <<fixed <<setprecision(20);
cout <<fixed <<setprecision(20);
int N,M,K;cin >> N >> M >> K;
vector<map<int,vector<int>>> es(N);
REP(i,M){
int a,b,c;cin >> a >> b >> c;a--;b--;
es[a][c].push_back(b);
es[b][c].push_back(a);
}
vector<int> ds(K);REP(i,K)cin >>ds[i];
vector<vector<bool> > dp(K+1,vector<bool>(N));
REP(i,N)dp[0][i]=true;
for(int k=1;k<=K;k++){
REP(i,N)if(dp[k-1][i]){
for(int n:es[i][ds[k-1]]){
dp[k][n]=true;
}
}
}
vector<int> res;
REP(i,N)if(dp[K][i])res.push_back(i);
cout << res.size()<<endl;
REP(i,res.size()){
if(i!=0)cout <<" ";
cout << res[i]+1;
}
cout <<endl;
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0