結果
問題 | No.92 逃走経路 |
ユーザー |
![]() |
提出日時 | 2014-12-14 11:30:18 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 5 ms / 5,000 ms |
コード長 | 1,012 bytes |
コンパイル時間 | 297 ms |
コンパイル使用メモリ | 43,392 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-11 21:07:22 |
合計ジャッジ時間 | 963 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:51:19: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wformat=] 51 | printf( "%d\n", v.size() ); | ~^ ~~~~~~~~ | | | | int std::vector<int>::size_type {aka long unsigned int} | %ld main.cpp:19:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 19 | scanf( "%d%d%d", &N, &M, &K ); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ main.cpp:23:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 23 | scanf( "%d%d%d", &a, &b, &c ); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ main.cpp:29:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 29 | scanf( "%d", d+i ); | ~~~~~^~~~~~~~~~~~~
ソースコード
#include<cstdio>#include<cstring>#include<vector>#define repi(i,a,b) for(int i=(a);i<(b);++i)#define rep(i,a) repi(i,0,a)#define repd(i,a) for(int i=(a);i>=0;--i)#define clr(a,v) memset((a),(v),sizeof(a))#define all(a) (a).begin(), (a).end()typedef std::pair<int, int> P;int N, M, K;int d[1000];std::vector<P> G[100];bool dp[1001][100];int main(){scanf( "%d%d%d", &N, &M, &K );rep( i, M ){int a, b, c;scanf( "%d%d%d", &a, &b, &c );--a; --b;G[a].push_back( P( b, c ) );G[b].push_back( P( a, c ) );}rep( i, K )scanf( "%d", d+i );rep( j, N )dp[0][j] = true;rep( i, K ){rep( j, N ) rep( k, G[j].size() ){const P &e = G[j][k];if( e.second != d[i] )continue;dp[i+1][e.first] |= dp[i][j];}}std::vector<int> v;rep( j, N ) if( dp[K][j] )v.push_back( j+1 );printf( "%d\n", v.size() );rep( i, v.size() )printf( "%d%c", v[i], i==v.size()-1?'\n':' ' );return 0;}