結果
問題 | No.92 逃走経路 |
ユーザー | tottoripaper |
提出日時 | 2015-03-03 21:21:31 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 4 ms / 5,000 ms |
コード長 | 1,320 bytes |
コンパイル時間 | 412 ms |
コンパイル使用メモリ | 58,920 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-09-06 06:37:14 |
合計ジャッジ時間 | 1,434 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
4,376 KB |
testcase_01 | AC | 1 ms
4,380 KB |
testcase_02 | AC | 1 ms
4,376 KB |
testcase_03 | AC | 1 ms
4,380 KB |
testcase_04 | AC | 2 ms
4,380 KB |
testcase_05 | AC | 4 ms
4,376 KB |
testcase_06 | AC | 2 ms
4,376 KB |
testcase_07 | AC | 2 ms
4,380 KB |
testcase_08 | AC | 1 ms
4,380 KB |
testcase_09 | AC | 2 ms
4,380 KB |
testcase_10 | AC | 4 ms
4,380 KB |
testcase_11 | AC | 4 ms
4,380 KB |
testcase_12 | AC | 4 ms
4,376 KB |
testcase_13 | AC | 2 ms
4,376 KB |
testcase_14 | AC | 2 ms
4,380 KB |
testcase_15 | AC | 3 ms
4,376 KB |
testcase_16 | AC | 3 ms
4,376 KB |
testcase_17 | AC | 4 ms
4,376 KB |
testcase_18 | AC | 3 ms
4,376 KB |
testcase_19 | AC | 3 ms
4,376 KB |
ソースコード
#include <cstdio> #include <vector> #include <tuple> typedef std::tuple<int,int,int> T; int N, M, K; std::vector<T> es; int d[1000]; bool used[2][101]; int main(){ scanf("%d %d %d", &N, &M, &K); for(int i=0;i<M;i++){ int a, b, c; scanf("%d %d %d", &a, &b, &c); es.push_back(std::make_tuple(a, b, c)); } for(int i=0;i<K;i++){ scanf("%d", d+i); } for(const T& t : es){ if(std::get<2>(t) == d[0]){ used[0][std::get<0>(t)] = true; used[0][std::get<1>(t)] = true; } } int prev = 0, next = 1; for(int i=1;i<K;i++){ for(int j=1;j<=N;j++){used[next][j] = false;} for(const T& t : es){ if(std::get<2>(t) == d[i]){ if(used[prev][std::get<0>(t)]){ used[next][std::get<1>(t)] = true; } if(used[prev][std::get<1>(t)]){ used[next][std::get<0>(t)] = true; } } } prev = !prev; next = !next; } std::vector<int> cs; for(int i=1;i<=N;i++){ if(used[prev][i]){ cs.push_back(i); } } printf("%d\n", cs.size()); for(int i=0;i<cs.size();i++){ printf("%d%c", cs[i], " \n"[i+1==cs.size()]); } }