結果

問題 No.92 逃走経路
ユーザー mamekinmamekin
提出日時 2014-12-07 20:02:08
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 7 ms / 5,000 ms
コード長 1,523 bytes
コンパイル時間 946 ms
コンパイル使用メモリ 99,252 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-02 09:34:10
合計ジャッジ時間 2,031 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 6 ms
4,380 KB
testcase_06 AC 6 ms
4,380 KB
testcase_07 AC 5 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 6 ms
4,380 KB
testcase_11 AC 6 ms
4,380 KB
testcase_12 AC 7 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 5 ms
4,376 KB
testcase_16 AC 4 ms
4,380 KB
testcase_17 AC 6 ms
4,384 KB
testcase_18 AC 5 ms
4,380 KB
testcase_19 AC 5 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

class Edge
{
public:
    int to, cost;
    Edge(int to, int cost){
        this->to = to;
        this->cost = cost;
    }
};

int main()
{
    int n, m, k;
    cin >> n >> m >> k;

    vector<vector<Edge> > edges(n+1);
    for(int i=0; i<m; ++i){
        int a, b, c;
        cin >> a >> b >> c;
        edges[a].push_back(Edge(b, c));
        edges[b].push_back(Edge(a, c));
    }

    vector<bool> curr(n+1, true);
    while(--k >= 0){
        int d;
        cin >> d;

        vector<bool> next(n+1, false);
        for(int i=1; i<=n; ++i){
            if(!curr[i])
                continue;
            for(unsigned j=0; j<edges[i].size(); ++j){
                if(edges[i][j].cost == d)
                    next[edges[i][j].to] = true;
            }
        }
        curr.swap(next);
    }

    vector<int> ret;
    for(int i=1; i<=n; ++i){
        if(curr[i])
            ret.push_back(i);
    }

    cout << ret.size() << endl;
    cout << ret[0];
    for(unsigned i=1; i<ret.size(); ++i)
        cout << ' ' << ret[i];
    cout << endl;

    return 0;
}
0