zoukankan      html  css  js  c++  java
  • cf754 B. Ilya and tic-tac-toe game

    呵呵呵,这个题简直是一直在乱做,真是最近太弱了

     1 #include<bits/stdc++.h>
     2 #define lowbit(x) x&(-x) 
     3 #define LL long long 
     4 #define N 200005
     5 #define M 1000005
     6 #define mod 2147483648LL
     7 #define inf 0x7ffffffff
     8 using namespace std;
     9 inline int ra()
    10 {
    11     int x=0,f=1; char ch=getchar();
    12     while (ch<'0' || ch>'9'){if (ch=='-') f=-1; ch=getchar();}
    13     while (ch>='0' && ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    14     return x*f;
    15 }
    16 int a[6][6];
    17 bool can(int x, int y)
    18 {
    19     if (x<1 || x>4) return 0;
    20     if (y<1 || y>4) return 0;
    21     return 1;
    22 }
    23 bool check(int x, int y)
    24 {
    25     int tot=a[x][y];
    26     tot+=a[x-1][y]; 
    27     tot+=a[x+1][y]; 
    28     if (tot>=20) return 1; tot=a[x][y];
    29     tot+=a[x][y-1];
    30     tot+=a[x][y+1];
    31     if (tot>=20) return 1; tot=a[x][y];
    32     tot+=a[x-1][y-1];
    33     tot+=a[x+1][y+1];
    34     if (tot>=20) return 1; tot=a[x][y];
    35     tot+=a[x-1][y+1];
    36     tot+=a[x+1][y-1];
    37     if (tot>=20) return 1;
    38     return 0;
    39 } 
    40 int main()
    41 {
    42     for (int i=0; i<=5; i++)
    43         for (int j=0; j<=5; j++)
    44              a[i][j]=-100;
    45     for (int i=1; i<=4; i++)
    46     {
    47         string ch; cin>>ch;
    48         for (int j=1; j<=4; j++)
    49         {
    50             if (ch[j-1]=='x') a[i][j]=10;
    51             if (ch[j-1]=='.') a[i][j]=0;
    52         }
    53     }
    54     for (int i=1; i<=4; i++)
    55         for (int j=1; j<=4; j++)
    56         {
    57             if ((a[i][j]==10 || a[i][j]==0) && check(i,j)) 
    58             {
    59                 cout<<"YES";
    60                 return 0;
    61             }
    62         }
    63     cout<<"NO";
    64     return 0;
    65 }
  • 相关阅读:
    eclipse lua
    eclipse新建python项Project interpreter not specified
    Laravel Debugbar
    Java中枚举类型简单学习
    SG函数题目
    关于解决博弈论问题的SG函数
    三种典型的博弈论问题
    Java I/O 对象序列化
    Java I/O 文件加锁,压缩
    Java I/O NIO学习
  • 原文地址:https://www.cnblogs.com/ccd2333/p/6261966.html
Copyright © 2011-2022 走看看