记录编号 | 157697 | 评测结果 | AAAAAAAAAAAA | ||
---|---|---|---|---|---|
题目名称 | [USACO Jan15] 牛的路线 | 最终得分 | 100 | ||
用户昵称 | 是否通过 | 通过 | |||
代码语言 | C++ | 运行时间 | 0.368 s | ||
提交时间 | 2015-04-09 19:59:25 | 内存使用 | 0.31 MiB | ||
#include<cstdio> #include<iostream> using namespace std; int a,b,m,ans=999999,e; int main() { freopen("cowroute.in","r",stdin); freopen("cowroute.out","w",stdout); cin>>a>>b>>m; for(int i=1;i<=m;i++) { int c,d,now; cin>>c>>d; now=0; for(int j=1;j<=d;j++) { cin>>e; if(e==a) { now=1; //cout<<a<<endl; //cout<<i<<" "<<e<<" "<<j<<endl; //cout<<now<<endl; } if(e==b&&now==1) { if(ans>c) ans=c; } } } if(ans==999999) printf("%d",-1); else printf("%d",ans); return 0; }