結果

問題 No.92 逃走経路
ユーザー fura
提出日時 2020-04-15 22:20:10
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 794 bytes
コンパイル時間 2,123 ms
コンパイル使用メモリ 197,704 KB
最終ジャッジ日時 2025-01-09 19:20:50
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:15:25: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   15 |         int n,m,k; scanf("%d%d%d",&n,&m,&k);
      |                    ~~~~~^~~~~~~~~~~~~~~~~~~
main.cpp:18:33: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   18 |                 int u,v,c; scanf("%d%d%d",&u,&v,&c); u--; v--;
      |                            ~~~~~^~~~~~~~~~~~~~~~~~~
main.cpp:26:29: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   26 |                 int d; scanf("%d",&d);
      |                        ~~~~~^~~~~~~~~

ソースコード

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

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
template<class T> struct edge{
int to;
T wt;
edge(int to,const T& wt):to(to),wt(wt){}
};
template<class T> using weighted_graph=vector<vector<edge<T>>>;
int main(){
int n,m,k; scanf("%d%d%d",&n,&m,&k);
weighted_graph<int> G(n);
rep(i,m){
int u,v,c; scanf("%d%d%d",&u,&v,&c); u--; v--;
G[u].emplace_back(v,c);
G[v].emplace_back(u,c);
}
bool dp[1001][100]={};
rep(u,n) dp[0][u]=true;
rep(t,k){
int d; scanf("%d",&d);
rep(u,n) if(dp[t][u]) {
for(auto e:G[u]) if(e.wt==d) {
dp[t+1][e.to]=true;
}
}
}
vector<int> ans;
rep(u,n) if(dp[k][u]) ans.emplace_back(u);
printf("%lu\n",ans.size());
rep(i,ans.size()) printf("%d%c",ans[i]+1,i+1<ans.size()?' ':'\n');
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0