結果
| 問題 |
No.92 逃走経路
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2014-12-07 20:36:45 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 99 ms / 5,000 ms |
| コード長 | 942 bytes |
| コンパイル時間 | 728 ms |
| コンパイル使用メモリ | 67,780 KB |
| 実行使用メモリ | 7,936 KB |
| 最終ジャッジ日時 | 2024-06-11 17:04:15 |
| 合計ジャッジ時間 | 1,876 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 18 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:36:18: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘std::set<int>::size_type’ {aka ‘long unsigned int’} [-Wformat=]
36 | printf("%d\n",result.size());
| ~^ ~~~~~~~~~~~~~
| | |
| int std::set<int>::size_type {aka long unsigned int}
| %ld
main.cpp:25:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
25 | scanf("%d%d%d",&N,&M,&K);
| ~~~~~^~~~~~~~~~~~~~~~~~~
main.cpp:29:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
29 | scanf("%d%d%d",&a,&b,&c);
| ~~~~~^~~~~~~~~~~~~~~~~~~
main.cpp:34:34: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
34 | 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;
set<pair<int,int> >memo;
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);
}else{
pair<int,int> x=make_pair(cur,depth);
if(memo.find(x)!=memo.end())return;
for(auto &it:v[cur][d[depth]]){
dfs(v,d,it,depth+1);
}
memo.insert(x);
}
}
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("");
}