比赛 |
20150408 |
评测结果 |
AAAAAAAAAAAA |
题目名称 |
牛的路线 |
最终得分 |
100 |
用户昵称 |
wolf. |
运行时间 |
0.102 s |
代码语言 |
C++ |
内存使用 |
0.31 MiB |
提交时间 |
2015-04-08 21:20:11 |
显示代码纯文本
#include<iostream>
#include<fstream>
#include<bitset>
#include<vector>
#include<deque>
#include<map>
#include<set>
#include<queue>
#include<string>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<cstdio>
using namespace std;
#if defined wolf
const string ok="OK";
const string kk=" ";
ofstream nnew("cowroute.in",ios::app);
ifstream fin("cowroute.in");
#define fout cout
#define Endl endl
#else
ifstream fin("cowroute.in");
ofstream fout("cowroute.out");
#endif
const int IMAX=999999999;
int main(){
int a,b,n;
fin>>a>>b>>n;
int ans=IMAX;
for(int i=0;i!=n;++i){
bool ra=0,rb=0;
int cost,p;
fin>>cost>>p;
for(int j=0;j!=p;++j){
int r;
fin>>r;
if(r==a){
ra=1;
}
if(r==b&&ra){
rb=1;
}
}
if(ra&&rb&&cost<ans){
ans=cost;
}
}
if(ans==IMAX){
fout<<-1;
return 0;
}
fout<<ans;
//-------------------------*/
#if defined wolf
cout<<endl<<(double)clock()/CLOCKS_PER_SEC<<'s'<<endl;
#endif
return 0;
}
//Designed by wolf
//Wed Apr 08 2015