| 比赛 | 
    20150408 | 
    评测结果 | 
    AWAWAWAWWWAW | 
    | 题目名称 | 
    牛的路线 | 
    最终得分 | 
    41 | 
    | 用户昵称 | 
    ok | 
    运行时间 | 
    0.072 s  | 
    | 代码语言 | 
    C++ | 
    内存使用 | 
    0.29 MiB  | 
    | 提交时间 | 
    2015-04-08 19:28:42 | 
显示代码纯文本
#include <cstdio>
#include <cstdlib>
using namespace std;
int main()
{
	int a,b,c,n,nn,s,i,j,res,pan=0,ppp=0;
	freopen ("cowroute.in","r",stdin);
	freopen ("cowroute.out","w",stdout);
	scanf("%d%d%d",&a,&b,&n);
	res=10000;
	for(i=1;i<=n;i++)
	{
		scanf("%d%d",&s,&nn);
		if(s<res)
		{
			pan=0;
			for(j=1;j<=nn;j++)
			{
				scanf("%d",&c);
				if(c==a) pan++;
				if(c==b&&pan==1)
				{
					ppp=1;
					res=s;
				}
			}
		}
	}
	if(ppp) printf("%d\n",res);
	else printf("-1\n");
	return 0;
}