結果

問題 No.92 逃走経路
ユーザー どららどらら
提出日時 2015-06-21 02:01:55
言語 C++11
(gcc 11.4.0)
結果
MLE  
実行時間 -
コード長 1,450 bytes
コンパイル時間 847 ms
コンパイル使用メモリ 83,888 KB
実行使用メモリ 653,172 KB
最終ジャッジ日時 2023-09-21 22:16:24
合計ジャッジ時間 14,410 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iostream>
#include <queue>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;

int N, M, K;
vector< pair<int,int> > G[105];


bool solve(int x, const vector<int>& v){
  queue< pair<int,int> > que;
  que.push(make_pair(x, 0));
  while(!que.empty()){
    pair<int,int> p = que.front(); que.pop();
    if(p.second >= v.size()) return true;
    rep(i,G[p.first].size()){
      if(G[p.first][i].first == v[p.second]){
        que.push(make_pair(G[p.first][i].second, p.second+1));
      }
    }
  }
  return false;
}

int main(){
  cin >> N >> M >> K;
  rep(i,M){
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    G[a].push_back(make_pair(c,b));
    G[b].push_back(make_pair(c,a));
  }
  vector<int> v;
  rep(i,K){
    int a;
    cin >> a;
    v.push_back(a);
  }
  reverse(ALLOF(v));

  vector<int> ret;
  rep(i,N){
    if(solve(i, v)){
      ret.push_back(i+1);
    }
  }

  cout << ret.size() << endl;
  rep(i,ret.size()){
    if(i!=0) cout << " ";
    cout << ret[i];
  }
  if(ret.size()!=0) cout << endl;
  
  return 0;
}
0