题目描述
blablabla
状态机枚举
C++ 代码
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int INF = 1e9;
int A, B,n;
int main()
{
cin >> A >> B >> n;
int res = INF;
while (n -- )
{
int cost, cnt;
cin >> cost >> cnt;
int st = 0; // 状态机 枚举
while (cnt -- )
{
int x;
cin >> x;
if (st ==0 && x == A) st =1; // 可以走到A;
else if (st == 1 && x == B ) st =2; // 可以走到B
}
if(st ==2 )
res = min(res,cost);
}
if(res == INF) res =-1;
cout << res;
return 0;
}