| 记录编号 | 
        157877 | 
        评测结果 | 
        AAAAAAAAAAAA | 
    
    
        | 题目名称 | 
        1926.[USACO Jan15] 牛的路线 | 
        最终得分 | 
        100 | 
            
    
    
        | 用户昵称 | 
         wolf. | 
        是否通过 | 
        通过 | 
    
    
        | 代码语言 | 
        C++ | 
        运行时间 | 
        0.110 s  | 
    
    
        | 提交时间 | 
        2015-04-10 23:01:38 | 
        内存使用 | 
        0.31 MiB  | 
        
    
    
    
    		显示代码纯文本
		
		#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