結果
| 問題 |
No.92 逃走経路
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2014-12-07 20:30:32 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 796 bytes |
| コンパイル時間 | 479 ms |
| コンパイル使用メモリ | 62,184 KB |
| 実行使用メモリ | 9,760 KB |
| 最終ジャッジ日時 | 2024-06-11 16:29:58 |
| 合計ジャッジ時間 | 12,873 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 2 |
| other | TLE * 1 -- * 17 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:29:18: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘std::set<int>::size_type’ {aka ‘long unsigned int’} [-Wformat=]
29 | printf("%d\n",result.size());
| ~^ ~~~~~~~~~~~~~
| | |
| int std::set<int>::size_type {aka long unsigned int}
| %ld
main.cpp:18:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
18 | scanf("%d%d%d",&N,&M,&K);
| ~~~~~^~~~~~~~~~~~~~~~~~~
main.cpp:22:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
22 | scanf("%d%d%d",&a,&b,&c);
| ~~~~~^~~~~~~~~~~~~~~~~~~
main.cpp:27:34: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
27 | for(int i=0;i<K;i++)scanf("%d",&d[i]);
| ~~~~~^~~~~~~~~~~~
ソースコード
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cstdio>
using namespace std;
set<int>result;
void dfs(/*const*/ vector<map<int,vector<int> > >&v,const vector<int> &d,int cur,int depth){
if(depth==d.size())result.insert(cur+1);
for(auto &it:v[cur][d[depth]]){
dfs(v,d,it,depth+1);
}
}
int main(){
int N,M,K;
scanf("%d%d%d",&N,&M,&K);
vector<map<int,vector<int> > >v(N);
for(int i=0;i<M;i++){
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
v[a-1][c].push_back(b-1);
v[b-1][c].push_back(a-1);
}
vector<int>d(K);
for(int i=0;i<K;i++)scanf("%d",&d[i]);
for(int i=0;i<N;i++)dfs(v,d,i,0);
printf("%d\n",result.size());
bool f=false;
for(auto &it:result){
if(f)putchar(' ');
f=true;
printf("%d",it);
}
puts("");
}