結果

問題 No.92 逃走経路
ユーザー natsugirnatsugir
提出日時 2014-12-07 19:35:02
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 99 ms / 5,000 ms
コード長 1,216 bytes
コンパイル時間 679 ms
コンパイル使用メモリ 84,116 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-02 09:23:17
合計ジャッジ時間 2,142 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<map>
#include<set>
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)

template<class T> inline T &amin(T &a, T b) { if (a>b) a=b; return a; }
template<class T> inline T &amax(T &a, T b) { if (a<b) a=b; return a; }

int N, M, K;
map<int, vector<pair<int, int> > > mp; // cost -> [(v, v)]
int main() {
    scanf("%d%d%d", &N, &M, &K);
    REP (i, M) {
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	mp[c].push_back(make_pair(a, b));
    }

    int D;

    set<int> se;
    REP (i, N) se.insert(i+1);
    REP (i, K) {
    
	scanf("%d", &D);
	set<int> nxt;
	REP (i, mp[D].size()) {
	    int v = mp[D][i].first, w = mp[D][i].second;
	    if (se.count(w)) nxt.insert(v);
	    if (se.count(v)) nxt.insert(w);
	}
	se.swap(nxt);
    }

    printf("%d\n", (int)se.size());
    bool sp = false;
    EACH (it, se) {
	if (sp) putchar(' ');
	sp = true;
	printf("%d", *it);
    }
    putchar('\n');
    
    return 0;
}
0