题意:
就是用个deque模拟游戏操作
。。n太小。。直接暴力就过了
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <deque>
#include <set>
#include <vector>
using namespace std;
int t1[15];
int t2[15];
deque<int> sb1;
deque<int> sb2;
int main()
{
int n,k1,k2;
int i;
cin>>n;
scanf("%d",&k1);
for (i=1;i<=k1;i++)
{
scanf("%d",&t1[i]);
sb1.push_back(t1[i]);
}
scanf("%d",&k2);
for (i=1;i<=k2;i++)
{
scanf("%d",&t2[i]);
sb2.push_back(t2[i]);
}
int tt=10000;
int flag=0;
int turn=0;
while(tt--)
{
if (sb1.empty()||sb2.empty())
{flag=1;break;}
turn++;
int a1=sb1.front();
sb1.pop_front();
int a2=sb2.front();
sb2.pop_front();
if (a1>a2)
{
sb1.push_back(a2);
sb1.push_back(a1);
}
else
{
sb2.push_back(a1);
sb2.push_back(a2);
}
}
if (flag)
{
if (sb1.empty())
printf("%d %d\n",turn,2);
else
printf("%d %d\n",turn,1);
}
else
printf("-1\n");
return 0;
}