結果
| 問題 |
No.92 逃走経路
|
| コンテスト | |
| ユーザー |
natsugir
|
| 提出日時 | 2014-12-07 19:35:02 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 95 ms / 5,000 ms |
| コード長 | 1,216 bytes |
| コンパイル時間 | 744 ms |
| コンパイル使用メモリ | 82,640 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-11 16:10:37 |
| 合計ジャッジ時間 | 1,608 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 18 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:23:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
23 | scanf("%d%d%d", &N, &M, &K);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~
main.cpp:26:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
26 | scanf("%d%d%d", &a, &b, &c);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~
main.cpp:36:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
36 | scanf("%d", &D);
| ~~~~~^~~~~~~~~~
ソースコード
#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;
}
natsugir