結果

問題 No.92 逃走経路
コンテスト
ユーザー どらら
提出日時 2015-06-21 02:01:55
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
MLE  
実行時間 -
コード長 1,450 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 755 ms
コンパイル使用メモリ 114,664 KB
実行使用メモリ 811,692 KB
最終ジャッジ日時 2026-03-29 06:48:51
合計ジャッジ時間 13,591 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 2
other MLE * 1 -- * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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