POJ 2706 Connect

来源:互联网 发布:男士休闲西服品牌 知乎 编辑:程序博客网 时间:2024/06/03 22:50

题目大意:

题目中给出一种游戏,有黑白两种颜色的棋子,黑色为先手。给定棋盘大小,双方下的棋子的位置和顺序,问黑子下的最后一步棋是否为决定自己胜利的那一步棋(及下了这一步棋后黑棋赢,不下就不赢)。游戏规则如下:

规定黑棋为先手,白棋为后手。­

放下棋子A后,若A8个马步方位,至少存在1个同色的棋子,且当连接A与这些棋子时,其连线不切割已经有的线,则连接。­

黑棋的目标是连出一条从X轴的0列到N列的路;­

白棋的目标是连出一条从Y轴的0行到N行的路。­

就是说某一方要赢棋,当且仅当其把自己的两个“终域”连接在一起,完全阻隔对方的连接。­

按照以上规则,判断黑棋所走的最后一步是否为赢棋的一步。

 (图为黑子的马步方位,在这些位置有同色棋子且连接线不切割其他已存在的线,                                                   就连接)

解题思路:

1、每下一步棋,记录棋的位置,可连接的其他棋子的位置,并标记这些棋子之间连接。

2、棋子全部下完后在BFS检查是否有一条可以赢的连接线,如果没有输出no。

3、如果有,再次BFS,当遇到最后一个点时不将他放入队列,看是否还能BFS一条路。

4、如果能输出no,不能输出yes。


注意:

1、判断是否可以连接时,要考虑全所有情况。

2、BFS时最后一步棋可能是连接线的第一个棋子,要注意所有棋子都要判断。

(感谢大牛博客的指点)

下面是代码:

#include <stdio.h>#include <string.h>const int M=23,Mx=255;int map1[M][M];struct node{    int x,y;} po[Mx];bool vis[Mx][Mx];int n,m;int posx[]= {0,-1,-2,-2,-1,1,2,2,1};  //对应于(x,y)的八个方位int posy[]= {0,2,1,-1,-2,-2,-1,1,2};void Link(int re,int ce,int i){    for(int k=1; k<=8; k++)    {        int r=re+posx[k];        int c=ce+posy[k];        if(r>=0 && r<=n && c>=0 && c<=n)  //检查边界        {            if(map1[r][c]!=-1 && map1[r][c]%2==i%2)  //检查颜色            {                switch(k)  //"日"字对角连线                {                case 1:  //30度方位                {                    if(map1[r][c-2]!=-1&&map1[r+1][c]!=-1&&vis[ map1[r][c-2] ][ map1[r+1][c] ])                        break;                    if(c-3>=0 && map1[r][c-3]!=-1&&map1[r+1][c-1]!=-1&&vis[ map1[r][c-3] ][ map1[r+1][c-1] ])                        break;                    if(c+1<=n &&map1[r][c-1]!=-1&&map1[r+1][c+1]!=-1&& vis[ map1[r][c-1] ][ map1[r+1][c+1] ])                        break;                    if(r-1>=0)                    {                        if(map1[r-1][c-2]!=-1&&map1[r+1][c-1]!=-1&&vis[ map1[r-1][c-2] ][ map1[r+1][c-1] ])                            break;                        if(map1[r-1][c-1]!=-1&&map1[r+1][c]!=-1&&vis[ map1[r-1][c-1] ][ map1[r+1][c] ])                            break;                        if(map1[r-1][c]!=-1&&map1[r+1][c-1]!=-1&&vis[ map1[r-1][c] ][ map1[r+1][c-1] ])                            break;                    }                    if(r+2<=n)                    {                        if(map1[r+2][c-2]!=-1&&map1[r][c-1]!=-1&&vis[ map1[r+2][c-2] ][ map1[r][c-1] ])                            break;                        if(map1[r+2][c-1]!=-1&&map1[r][c-2]!=-1&&vis[ map1[r+2][c-1] ][ map1[r][c-2] ])                            break;                        if(map1[r+2][c]!=-1&&map1[r][c-1]!=-1&&vis[ map1[r+2][c] ][ map1[r][c-1] ])                            break;                    }                    int a=map1[re][ce];                    int b=map1[r][c];                    vis[a][b]=vis[b][a]=true;                    break;                }                case 2:  //60度方位                {                    if(map1[r][c-1]!=-1&&map1[r+2][c]!=-1&&vis[ map1[r][c-1] ][ map1[r+2][c] ])                        break;                    if(r-1>=0 &&map1[r-1][c-1]!=-1&&map1[r+1][c]!=-1&& vis[ map1[r-1][c-1] ][ map1[r+1][c] ])                        break;                    if(r+3<=n &&map1[r+1][c-1]!=-1&&map1[r+3][c]!=-1&& vis[ map1[r+1][c-1] ][ map1[r+3][c] ])                        break;                    if(c-2>=0)                    {                        if(map1[r][c-2]!=-1&&map1[r+1][c]!=-1&&vis[ map1[r][c-2] ][ map1[r+1][c] ])                            break;                        if(map1[r+1][c-2]!=-1&&map1[r+2][c]!=-1&&vis[ map1[r+1][c-2] ][ map1[r+2][c] ])                            break;                        if(map1[r+2][c-2]!=-1&&map1[r+1][c]!=-1&&vis[ map1[r+2][c-2] ][ map1[r+1][c] ])                            break;                    }                    if(c+1<=n)                    {                        if(map1[r][c-1]!=-1&&map1[r+1][c+1]!=-1&&vis[ map1[r][c-1] ][ map1[r+1][c+1] ])                            break;                        if(map1[r+1][c-1]!=-1&&map1[r][c+1]!=-1&&vis[ map1[r+1][c-1] ][ map1[r][c+1] ])                            break;                        if(map1[r+1][c-1]!=-1&&map1[r+2][c+1]!=-1&&vis[ map1[r+1][c-1] ][ map1[r+2][c+1] ])                            break;                    }                    int a=map1[re][ce];                    int b=map1[r][c];                    vis[a][b]=vis[b][a]=true;                    break;                }                case 3:  //120度方位                {                    if(map1[r][c+1]!=-1&&map1[r+2][c]!=-1&&vis[ map1[r][c+1] ][ map1[r+2][c] ])                        break;                    if(r-1>=0 && map1[r-1][c+1]!=-1&&map1[r+1][c]!=-1&&vis[ map1[r-1][c+1] ][ map1[r+1][c] ])                        break;                    if(r+3<=n && map1[r+1][c+1]!=-1&&map1[r+3][c]!=-1&&vis[ map1[r+1][c+1] ][ map1[r+3][c] ])                        break;                    if(c-1>=0)                    {                        if(map1[r][c-1]!=-1&&map1[r+1][c+1]!=-1&&vis[ map1[r][c-1] ][ map1[r+1][c+1] ])                            break;                        if(map1[r+1][c-1]!=-1&&map1[r][c+1]!=-1&&vis[ map1[r+1][c-1] ][ map1[r][c+1] ])                            break;                        if(map1[r+2][c-1]!=-1&&map1[r+1][c+1]!=-1&&vis[ map1[r+2][c-1] ][ map1[r+1][c+1] ])                            break;                    }                    if(c+2<=n)                    {                        if(map1[r+1][c]!=-1&&map1[r][c+2]!=-1&&vis[ map1[r+1][c] ][ map1[r][c+2] ])                            break;                        if(map1[r+2][c]!=-1&&map1[r+1][c+2]!=-1&&vis[ map1[r+2][c] ][ map1[r+1][c+2] ])                            break;                        if(map1[r+1][c]!=-1&&map1[r+2][c+2]!=-1&&vis[ map1[r+1][c] ][ map1[r+2][c+2] ])                            break;                    }                    int a=map1[re][ce];                    int b=map1[r][c];                    vis[a][b]=vis[b][a]=true;                    break;                }                case 4:  //150度方位                {                    if(map1[r][c+2]!=-1&&map1[r+1][c]!=-1&&vis[ map1[r][c+2] ][ map1[r+1][c] ])                        break;                    if(c-1>=0 &&map1[r+1][c-1]!=-1&&map1[r][c+1]!=-1&& vis[ map1[r+1][c-1] ][ map1[r][c+1] ])                        break;                    if(c+3<=n &&map1[r+1][c+1]!=-1&&map1[r][c+3]!=-1&& vis[ map1[r+1][c+1] ][ map1[r][c+3] ])                        break;                    if(r-1>=0)                    {                        if(map1[r-1][c]!=-1&&map1[r+1][c+1]!=-1&&vis[ map1[r-1][c] ][ map1[r+1][c+1] ])                            break;                        if(map1[r-1][c+1]!=-1&&map1[r+1][c]!=-1&&vis[ map1[r-1][c+1] ][ map1[r+1][c] ])                            break;                        if(map1[r-1][c+2]!=-1&&map1[r+1][c+1]!=-1&&vis[ map1[r-1][c+2] ][ map1[r+1][c+1] ])                            break;                    }                    if(r+2<=n)                    {                        if(map1[r][c+1]!=-1&&map1[r+2][c]!=-1&&vis[ map1[r][c+1] ][ map1[r+2][c] ])                            break;                        if(map1[r][c+1]!=-1&&map1[r+2][c+2]!=-1&&vis[ map1[r][c+1] ][ map1[r+2][c+2] ])                            break;                        if(map1[r][c+2]!=-1&&map1[r+2][c+1]!=-1&&vis[ map1[r][c+2] ][ map1[r+2][c+1] ])                            break;                    }                    int a=map1[re][ce];                    int b=map1[r][c];                    vis[a][b]=vis[b][a]=true;                    break;                }                case 5:  //210度方位                {                    if(map1[r-1][c]!=-1&&map1[r][c+2]!=-1&&vis[ map1[r-1][c] ][ map1[r][c+2] ])                        break;                    if(c-1>=0 &&map1[r-1][c-1]!=-1&&map1[r][c+1]!=-1&& vis[ map1[r-1][c-1] ][ map1[r][c+1] ])                        break;                    if(c+3<=n &&map1[r-1][c+1]!=-1&&map1[r][c+3]!=-1&& vis[ map1[r-1][c+1] ][ map1[r][c+3] ])                        break;                    if(r-2>=0)                    {                        if(map1[r-2][c]!=-1&&map1[r][c+1]!=-1&&vis[ map1[r-2][c] ][ map1[r][c+1] ])                            break;                        if(map1[r-2][c+1]!=-1&&map1[r][c+2]!=-1&&vis[ map1[r-2][c+1] ][ map1[r][c+2] ])                            break;                        if(map1[r-2][c+2]!=-1&&map1[r][c+1]!=-1&&vis[ map1[r-2][c+2] ][ map1[r][c+1] ])                            break;                    }                    if(r+1<=n)                    {                        if(map1[r][c]!=-1&&map1[r-1][c+1]!=-1&&vis[ map1[r][c] ][ map1[r-1][c+1] ])                            break;                        if(map1[r+1][c+1]!=-1&&map1[r-1][c]!=-1&&vis[ map1[r+1][c+1] ][ map1[r-1][c] ])                            break;                        if(map1[r+1][c+2]!=-1&&map1[r-1][c+1]!=-1&&vis[ map1[r+1][c+2] ][ map1[r-1][c+1] ])                            break;                    }                    int a=map1[re][ce];                    int b=map1[r][c];                    vis[a][b]=vis[b][a]=true;                    break;                }                case 6:  //240度方位                {                    if(map1[r-2][c]!=-1&&map1[r][c+1]!=-1&&vis[ map1[r-2][c] ][ map1[r][c+1] ])                        break;                    if(r-3>=0 && map1[r-3][c]!=-1&&map1[r-1][c+1]!=-1&&vis[ map1[r-3][c] ][ map1[r-1][c+1] ])                        break;                    if(r+1<=n &&map1[r-1][c]!=-1&&map1[r+1][c+1]!=-1&& vis[ map1[r-1][c] ][ map1[r+1][c+1] ])                        break;                    if(c-1>=0)                    {                        if(map1[r-2][c-1]!=-1&&map1[r-1][c+1]!=-1&&vis[ map1[r-2][c-1] ][ map1[r-1][c+1] ])                            break;                        if(map1[r-1][c-1]!=-1&&map1[r][c+1]!=-1&&vis[ map1[r-1][c-1] ][ map1[r][c+1] ])                            break;                        if(map1[r][c-1]!=-1&&map1[r-1][c+1]!=-1&&vis[ map1[r][c-1] ][ map1[r-1][c+1] ])                            break;                    }                    if(c+2<=n)                    {                        if(map1[r-1][c]!=-1&&map1[r-2][c+2]!=-1&&vis[ map1[r-1][c] ][ map1[r-2][c+2] ])                            break;                        if(map1[r-2][c]!=-1&&map1[r-1][c+2]!=-1&&vis[ map1[r-2][c] ][ map1[r-1][c+2] ])                            break;                        if(map1[r-1][c]!=-1&&map1[r][c+2]!=-1&&vis[ map1[r-1][c] ][ map1[r][c+2] ])                            break;                    }                    int a=map1[re][ce];                    int b=map1[r][c];                    vis[a][b]=vis[b][a]=true;                    break;                }                case 7:  //300度方位                {                    if(map1[r-2][c]!=-1&&map1[r][c-1]!=-1&&vis[ map1[r-2][c] ][ map1[r][c-1] ])                        break;                    if(r-3>=0 && map1[r-3][c]!=-1&&map1[r-1][c-1]!=-1&&vis[ map1[r-3][c] ][ map1[r-1][c-1] ])                        break;                    if(r+1<=n &&map1[r-1][c]!=-1&&map1[r+1][c-1]!=-1&& vis[ map1[r-1][c] ][ map1[r+1][c-1] ])                        break;                    if(c-2>=0)                    {                        if(map1[r-2][c-2]!=-1&&map1[r-1][c]!=-1&&vis[ map1[r-2][c-2] ][ map1[r-1][c] ])                            break;                        if(map1[r-1][c-2]!=-1&&map1[r-2][c]!=-1&&vis[ map1[r-1][c-2] ][ map1[r-2][c] ])                            break;                        if(map1[r][c-2]!=-1&&map1[r-1][c]!=-1&&vis[ map1[r][c-2] ][ map1[r-1][c] ])                            break;                    }                    if(c+1<=n)                    {                        if(map1[r-1][c-1]!=-1&&map1[r-2][c+1]!=-1&&vis[ map1[r-1][c-1] ][ map1[r-2][c+1] ])                            break;                        if(map1[r][c-1]!=-1&&map1[r-1][c+1]!=-1&&vis[ map1[r][c-1] ][ map1[r-1][c+1] ])                            break;                        if(map1[r-1][c-1]!=-1&&map1[r][c+1]!=-1&&vis[ map1[r-1][c-1] ][ map1[r][c+1] ])                            break;                    }                    int a=map1[re][ce];                    int b=map1[r][c];                    vis[a][b]=vis[b][a]=true;                    break;                }                case 8:  //330度方位                {                    if(map1[r][c-2]!=-1&&map1[r-1][c]!=-1&&vis[ map1[r][c-2] ][ map1[r-1][c] ])                        break;                    if(c-3>=0 &&map1[r][c-3]!=-1&&map1[r-1][c-1]!=-1&& vis[ map1[r][c-3] ][ map1[r-1][c-1] ])                        break;                    if(c+1<=n &&map1[r][c-1]!=-1&&map1[r-1][c+1]!=-1&& vis[ map1[r][c-1] ][ map1[r-1][c+1] ])                        break;                    if(r-2>=0)                    {                        if(map1[r-2][c-2]!=-1&&map1[r][c-1]!=-1&&vis[ map1[r-2][c-2] ][ map1[r][c-1] ])                            break;                        if(map1[r-2][c-1]!=-1&&map1[r][c-2]!=-1&&vis[ map1[r-2][c-1] ][ map1[r][c-2] ])                            break;                        if(map1[r-2][c]!=-1&&map1[r][c-1]!=-1&&vis[ map1[r-2][c] ][ map1[r][c-1] ])                            break;                    }                    if(r+1<=n)                    {                        if(map1[r-1][c-1]!=-1&&map1[r+1][c-2]!=-1&&vis[ map1[r-1][c-1] ][ map1[r+1][c-2] ])                            break;                        if(map1[r-1][c-1]!=-1&&map1[r+1][c]!=-1&&vis[ map1[r-1][c-1] ][ map1[r+1][c] ])                            break;                        if(map1[r-1][c]!=-1&&map1[r+1][c-1]!=-1&&vis[ map1[r-1][c] ][ map1[r+1][c-1] ])                            break;                    }                    int a=map1[re][ce];                    int b=map1[r][c];                    vis[a][b]=vis[b][a]=true;                    break;                }                }            }        }    }    return;}bool Check(bool flag){    int NUM;    if(!flag)  //通过舍弃最后一步棋,检查最后一步棋是否为决定赢棋的一步        NUM=m;    for(int k=0; k<=n; k++)    {        int p=map1[0][k];        if(p!=-1 && p!=NUM-1 && p%2==0)        {            int queue[Mx];            bool vist[Mx]= {false};            int head=0;            int tail=0;            queue[tail]=p;            tail++;            vist[p]=true;            while(head<tail)            {                int s=queue[head];                head++;                if(po[s].x==n)                {                    return true;                }                for(int i=0; i<=m; i++)                {                    int x=-1;                    if(vis[s][i])                    {                        x=i;                    }                    if(x!=-1&&!vist[x])                    {                        vist[x]=true;                        if(!flag && x==NUM-1)                            continue;                        queue[tail++]=x;                    }                }            }        }    }    return false;}int main(){    int i,x,y;    while(scanf("%d%d",&n,&m),n||m)    {        memset(map1,-1,sizeof(map1));        memset(vis,false,sizeof(vis));        for(i=0; i<m; i++)        {            scanf("%d%d",&po[i].x,&po[i].y);            map1[po[i].x][po[i].y]=i;            Link(po[i].x,po[i].y,i);        }        if(Check(true) && !Check(false))        {            printf("yes\n");        }        else        {            printf("no\n");        }    }    return 0;}



测试数据:



Sample Input
4 5
0 2 2 4 4 2 3 2 2 3
 
4 5
0 2 2 4 4 2 3 2 2 1
 
7 11
0 3 6 5 3 2 5 7 7 2 4 4 5 3 5 2 4 5 4 0 2 4
 
5 9
3 1 3 3 0 2 2 5 2 3 2 1 4 3 4 0 5 1
 
4 5
0 1 2 0 1 3 2 2 4 1
 
8 17
2 2 2 3 2 4 2 0 3 1 1 6 3 5 4 1 5 1 4 5 5 5 6 0 6 2 6 3 6 4 1 8 4 3
 
8 21
2 2 2 3 2 4 2 0 3 1 1 6 3 5 4 1 5 1 4 5 5 5 6 0 6 2 6 3 6 4 1 8 0 1 5 8 8 5 3 7 4 3
 
8 21
2 2 2 3 2 4 2 0 3 1 1 6 3 5 4 1 5 1 4 5 5 5 6 0 6 2 6 3 6 4 1 8 0 1 5 8 8 5 4 4 4 3
 
8 21
2 2 2 3 2 4 2 0 3 1 1 6 3 5 4 1 5 1 4 5 5 5 6 0 6 2 6 3 6 4 1 8 0 1 5 8 8 3 4 4 4 3
 
8 21
2 2 2 3 2 4 2 0 3 1 1 6 3 5 4 1 5 1 4 5 5 5 6 0 6 2 6 3 6 4 1 8 0 1 5 8 8 5 3 3 4 3
 
10 99
5 4 7 9 7 3 8 7 1 8 8 10 5 5 5 3 10 7 7 10 4 1 2 2 9 5 3 5 3 9 9 8 4 8 4 2 2 1 2 4 10 4 4 0 0 7 7 0 1 1 9 7 1 7 9 10 0 1 3 7 10 1 7 1 2 3 7 7 7 2 4 5 5 1 6 0 7 4 9 3 3 6 1 4 9 1 2 5 0 9 5 10 4 4 1 3 2 6 1 2 9 9 5 8 4 3 3 10 8 6 1 10 4 7 7 8 6 7 2 10 6 6 5 9 10 6 3 0 5 2 3 3 0 5 8 2 10 5 5 0 4 6 8 8 1 9 2 0 2 9 8 5 0 3 2 8 7 6 1 6 8 1 5 7 7 5 3 4 8 3 6 4 9 6 2 7 0 6 1 0 10 8 6 8 5 6 4 10 10 2 6 1 10 3 4 9 3 1
 
20 221
0 4 8 15 15 3 3 2 1 15 8 11 1 18 6 1 6 4 12 1 16 13 19 1 9 18 5 17 15 12 6 7 19 5 14 15 12 9 6 19 16 6 13 9 3 15 15 13 19 11 9 11 20 14 2 11 12 15 18 4 19 4 12 16 17 10 17 20 2 9 6 20 0 16 19 9 8 18 11 13 14 13 13 17 4 19 14 1 14 12 10 15 6 10 12 10 2 6 17 16 19 18 12 17 13 2 14 2 18 9 17 3 20 5 14 16 7 6 5 5 15 2 6 12 8 6 16 18 1 17 9 16 14 5 8 2 7 1 15 7 15 8 2 1 4 3 1 2 15 4 10 14 10 7 12 19 1 7 3 14 6 15 15 14 11 19 12 4 17 18 6 5 10 2 17 0 9 13 1 5 0 1 13 7 5 16 8 5 9 8 16 3 3 16 18 13 11 6 3 9 8 7 10 19 8 13 15 10 7 4 12 7 8 17 4 14 7 17 11 16 0 13 16 11 6 6 16 2 2 17 8 3 16 15 1 10 2 15 4 2 9 4 12 2 19 8 15 5 14 14 16 9 16 5 9 10 3 7 2 13 7 13 6 9 3 13 10 1 15 18 14 3 2 19 5 0 4 11 7 14 12 3 13 20 17 7 16 17 12 6 18 18 18 14 5 20 12 8 16 0 15 9 5 4 2 3 8 10 20 10 14 7 14 17 8 16 4 5 19 2 10 18 11 18 6 17 11 10 3 8 10 13 13 11 1 6 10 5 7 15 5 12 14 6 7 9 10 3 8 19 8 1 11 4 7 0 13 19 7 12 19 16 17 14 3 12 5 13 12 11 3 0 18 12 3 5 3 19 6 2 0 3 17 17 7 10 13 3 4 15 17 19 20 7 8 8 7 2 10 11 18 17 11 9 15 1 19 0 16 4 13 16 5 8 11 3 20 18 16 19 19 13 18 16 14 19 5 19 15 16 17 2 2 5 9 7 16 7 14 9 0 5
 
20 221
0 4 8 15 15 3 3 2 1 15 8 11 1 18 6 1 6 4 12 1 16 13 19 1 9 18 5 17 15 12 6 7 19 5 14 15 12 9 6 19 16 6 13 9 3 15 15 13 19 11 9 11 20 14 2 11 12 15 18 4 19 4 12 16 17 10 17 20 2 9 6 20 0 16 19 9 8 18 11 13 14 13 13 17 4 19 14 1 14 12 10 15 6 10 12 10 2 6 17 16 19 18 12 17 13 2 14 2 18 9 17 3 20 5 14 16 7 6 5 5 15 2 6 12 8 6 16 18 1 17 9 16 14 5 8 2 7 1 15 7 15 8 2 1 4 3 1 2 15 4 10 14 10 7 12 19 1 7 3 14 6 15 15 14 11 19 12 4 17 18 6 5 10 2 17 0 9 13 1 5 0 1 13 7 5 16 8 5 9 8 16 3 3 16 18 13 11 6 3 9 8 7 10 19 8 13 15 10 7 4 12 7 8 17 4 14 7 17 11 16 0 13 16 11 6 6 16 2 2 17 8 3 16 15 1 10 2 15 4 2 9 4 12 2 19 8 15 5 14 14 16 9 16 5 9 10 3 7 2 13 7 13 6 9 3 13 10 1 15 18 14 3 2 19 5 0 4 11 7 14 12 3 13 20 17 7 16 17 12 6 18 18 18 14 5 20 12 8 16 0 15 9 5 4 2 3 8 10 20 10 14 7 14 17 8 16 4 5 19 2 10 18 11 18 6 17 11 10 3 8 10 13 13 11 1 6 10 5 7 15 5 12 14 6 7 9 10 3 8 19 8 1 11 4 7 0 13 19 7 12 19 16 17 14 3 12 5 13 12 11 3 0 18 12 3 5 3 19 6 2 0 3 17 17 7 10 13 3 4 15 17 19 20 7 8 8 7 2 10 11 18 17 11 9 15 1 19 0 16 4 13 16 5 8 11 3 20 18 16 19 19 13 18 16 14 19 5 19 15 16 17 2 2 5 9 7 16 7 14 9 1 14
 
10 97
5 4 7 9 7 3 8 7 1 8 8 10 5 5 5 3 10 7 7 10 4 1 2 2 9 5 3 5 3 9 9 8 4 8 4 2 2 1 2 4 10 4 4 0 0 7 7 0 1 1 9 7 1 7 9 10 0 1 3 7 10 1 7 1 2 3 7 7 7 2 4 5 5 1 6 0 7 4 9 3 3 6 1 4 9 1 2 5 0 9 5 10 4 4 1 3 2 6 1 2 9 9 5 8 4 3 3 10 8 6 1 10 4 7 7 8 6 7 2 10 6 6 5 9 10 6 3 0 5 2 3 3 0 5 8 2 10 5 5 0 4 6 8 8 1 9 2 0 2 9 8 5 0 3 2 8 7 6 1 6 8 1 5 7 7 5 3 4 8 3 6 4 9 6 2 7 0 6 1 0 10 8 6 8 5 6 4 10 10 2 6 1 10 3

10 99
5 4 7 9 7 3 8 7 1 8 8 10 5 5 5 3 10 7 7 10 4 1 2 2 9 5 3 5 3 9 9 8 4 8 4 2 2 1 2 4 10 4 4 0 0 7 7 0 1 1 9 7 1 7 9 10 0 1 3 7 10 1 7 1 2 3 7 7 7 2 4 5 5 1 6 0 7 4 9 3 3 6 1 4 9 1 2 5 0 9 5 10 4 4 1 3 2 6 1 2 9 9 5 8 4 3 3 10 8 6 1 10 4 7 7 8 6 7 2 10 6 6 5 9 10 6 3 0 5 2 3 3 0 5 8 2 10 5 5 0 4 6 8 8 1 9 2 0 2 9 8 5 0 3 2 8 7 6 1 6 8 1 5 7 7 5 3 4 8 3 6 4 9 6 2 7 0 6 1 0 10 8 6 8 5 6 4 10 10 2 6 1 10 3 4 9 1 5
 
0 0
 
Sample Output
no
yes
yes
yes
no
no
yes
no
yes
no
yes
yes
no
no
no


原创粉丝点击