結果
問題 |
No.92 逃走経路
|
ユーザー |
![]() |
提出日時 | 2017-07-03 13:16:54 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,749 bytes |
コンパイル時間 | 791 ms |
コンパイル使用メモリ | 75,464 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-05 11:07:53 |
合計ジャッジ時間 | 1,568 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 7 WA * 11 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:52:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 52 | scanf("%d %d %d", a+i, b+i, c+i); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ main.cpp:57:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 57 | scanf("%d", d+i ); | ~~~~~^~~~~~~~~~~~
ソースコード
#include <iostream> #include <cstdio> #include <cmath> #include <algorithm> #include <string> #include <map> #include <bitset> #include <vector> #include <queue> typedef long long ll; #define fi first #define se second const ll mod = 1000000007; // 123456789 using namespace std; /////////////////////////////////////////////// // // /////////////////////////////////////////////// //////////////////////////////////////////////// //////////////////////////////////////////////// int N; int M; int K; int cost; int c[1123]; int s[1123]; int d[1123]; int a[1123]; int b[1123]; int path[1123][112]; bool dp[1123][112]; int ans = 0; int idx; int OUT[112]; int main(){ int i; int j; int flag = 0; cin>>N>>M>>K; for( i = 0; i < M; i++ ){ scanf("%d %d %d", a+i, b+i, c+i); s[i] = c[i]; } for( i = 0; i < K; i++ ){ scanf("%d", d+i ); } sort( s, s+M ); int cnt = 0; for( i = 1; i < M; i++ ){ if( s[i] == s[i-1] ){ s[i-1] = mod; cnt++; } } sort( s, s+M ); for( i = 0; i < M; i++ ){ for( j = 0; j < M-cnt; j++ ){ if( c[i] == s[j] ){ c[i] = j; } } } for( i = 0; i < K; i++ ){ for( j = 0; j < M-cnt; j++ ){ if( d[i] == s[j] ){ d[i] = j; } } } fill( path[0], path[1123], 0 ); for( i = 0; i < M; i++ ){ path[c[i]][b[i]] = a[i]; path[c[i]][a[i]] = b[i]; } fill( dp[0], dp[1], 1 ); fill( dp[1], dp[K+1], 0 ); for( i = 0; i < K; i++ ){ for( j = 1; j <= N; j++ ){ if( dp[i][j] ){ idx = path[d[i]][j]; dp[i+1][idx] = 1; } } } for( i = 1; i <= N; i++ ){ OUT[ans] = i; if( dp[K][i] ) ans++; } cout<<ans<<endl; for( i = 0; i < ans; i++ ){ if( i ) printf(" "); printf("%d", OUT[i] ); } puts(""); return 0; }