結果

問題 No.92 逃走経路
ユーザー noynote
提出日時 2017-04-23 11:46:00
言語 C++11
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 2,041 bytes
コンパイル時間 1,789 ms
コンパイル使用メモリ 179,268 KB
実行使用メモリ 814,088 KB
最終ジャッジ日時 2024-07-21 20:03:00
合計ジャッジ時間 4,860 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other WA * 3 MLE * 1 -- * 14
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
const int INF = 2000000000;
int d[1005];
set<pair<int, int>> table; //
vector<int> visit;
class Edge{
public:
int to, cost;
Edge(int to, int cost) : to(to) ,cost(cost) {}
};
class Node{
public:
int dis;
bool isUsed;
Node(){
this->dis = INF;
this->isUsed = 0;
}
};
typedef vector<vector<Edge>> AdjList;
void dijkstra(AdjList g, int start, int n, int k){
vector<Node> node(n);
queue<int> q;
q.push(start);
node[start].dis = 0;
while(not q.empty()){
int current = q.front(); q.pop();
if(k == node[current].dis){
visit.emplace_back(current);
break;
}
table.insert(make_pair(current, node[current].dis));
rep(i,g[current].size()){
int next = g[current][i].to;
if(node[next].isUsed == 0 && d[node[current].dis] == g[current][i].cost){
node[next].dis = node[current].dis + 1;
if(table.find(make_pair(next, node[next].dis)) != table.end()) continue;
q.push(next);
}
}
}
return;
}
int main(){
int n, m, k;
cin >> n >> m >> k;
AdjList g(n);
rep(i,m){
int a, b, c;
cin >> a >> b >> c;
a--; b--;
g[a].emplace_back(Edge{b,c});
g[b].emplace_back(Edge{a,c});
}
rep(i,k) cin >> d[i];
rep(i,n){
dijkstra(g,i,n,k);
}
cout << visit.size() << endl;
for(auto it = visit.begin(); it != visit.end(); it++){
if(it != visit.begin()) cout << ' ';
cout << *it + 1;
}
cout << endl;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0