結果
問題 | No.92 逃走経路 |
ユーザー | 777yuuki12323 |
提出日時 | 2017-07-04 18:00:17 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,835 bytes |
コンパイル時間 | 593 ms |
コンパイル使用メモリ | 76,228 KB |
実行使用メモリ | 17,576 KB |
最終ジャッジ日時 | 2024-10-05 15:35:02 |
合計ジャッジ時間 | 1,434 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
コンパイルメッセージ
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 ); | ~~~~~^~~~~~~~~~~~ In file included from /usr/include/c++/11/bits/char_traits.h:39, from /usr/include/c++/11/ios:40, from /usr/include/c++/11/ostream:38, from /usr/include/c++/11/iostream:39, from main.cpp:1: In function ‘typename __gnu_cxx::__enable_if<std::__is_scalar<_Tp>::__value, void>::__type std::__fill_a1(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = bool*; _Tp = int]’, inlined from ‘void std::__fill_a(_FIte, _FIte, const _Tp&) [with _FIte = bool*; _Tp = int]’ at /usr/include/c++/11/bits/stl_algobase.h:969:21, inlined from ‘void std::fill(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = bool*; _Tp = int]’ at /usr/include/c++/11/bits/stl_algobase.h:999:20, inlined from ‘int main()’ at main.cpp:89:6: /usr/include/c++/11/bits/stl_algobase.h:924:18: warning: ‘void* __builtin_memset(void*, int, long unsigned int)’ writing 14099456 bytes into a region of size 14086912 overflows the destination [-Wstringop-overflow=] 924 | *__first = __tmp; | ~~~~~~~~~^~~~~~~ main.cpp: In function ‘int main()’: main.cpp:37:6: note: destination object ‘P’ of size 14086912 37 | bool P[1123][112][112]; | ^ In file included from /usr/include/c++/11/bits/char_traits.h:39, from /usr/include/c++/11/ios:40, from /usr/include/c++/11/ostream:38,
ソースコード
#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]; bool P[1123][112][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+1; } } } for( i = 0; i < K; i++ ){ for( j = 0; j < M-cnt; j++ ){ if( d[i] == s[j] ){ d[i] = j+1; } } } fill( P[0][0], P[1123][112], 0 ); for( i = 0; i < M; i++ ){ P[c[i]][b[i]][a[i]] = 1; P[c[i]][a[i]][b[i]] = 1; } fill( dp[0], dp[1], 1 ); fill( dp[1], dp[K+1], 0 ); int k; for( i = 0; i < K; i++ ){ for( j = 1; j <= N; j++ ){ if( dp[i][j] ){ for( k = 1; k <= N; k++ ){ if( P[d[i]][j][k]){ idx = k; 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; }