奶牛路线

#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int a, b, n;
    scanf("%d%d%d", &a, &b, &n);
    int ans = 1e9;
    for(int i = 1; i <= n; i ++)
    {
        int res, m;
        scanf("%d%d",&res, &m);
        bool f1 = false, f2 = false;
        for(int i = 1; i <= m; i ++)
        {
            int x;
            scanf("%d", &x);
            if(x == a) f1 = true;
            if(x == b && f1) f2 = true;
        }
        if(f1 && f2) ans = min(ans, res);
    }
    if(ans == 1e9) puts("-1");
    else printf("%d\n", ans);
    return 0;
}
全部评论

相关推荐

不亏是提前批,神仙打架,鼠鼠不配了
站队站对牛:现在92都报工艺岗了
投递韶音科技等公司7个岗位
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-04 18:25
点赞 评论 收藏
分享
05-20 21:57
已编辑
门头沟学院 Java
喜欢吃卤蛋的悲伤蛙在...:建信融通没消息吧,我2说有实习挂简历不理了
点赞 评论 收藏
分享
程序员小白条:你是沟通了900个,不是投了900份简历,你能投900份,意味着对面都要回复你900次,你早就找到实习了,没亮点就是这样的,别局限地区,时间投的也要早,现在都要7月了
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务