You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
# include <bits/stdc++.h>
using namespace std ;
int main ( ) {
//cin读入优化
std : : ios : : sync_with_stdio ( false ) ;
//输入+输出重定向
freopen ( " ../1295.in " , " r " , stdin ) ;
int n , m ;
cin > > n > > m ;
vector < vector < int > > a ( n + 1 , vector < int > ( n + 1 , 0 ) ) ;
for ( int i = 1 ; i < = m ; i + + ) {
int x , y ;
cin > > x > > y ;
int v = i % 2 = = 0 ? 1 : - 1 ; //偶数为1, 奇数-1, 就是说先手的-1, 后手的1
a [ x ] [ y ] = v ;
//检查比赛是不是已经停止
//只要有一方的 n 个棋子在同一行或者同一列或者同一条对角线上,就是四个方向检查
//行
int r1 = 0 ;
for ( int j = 1 ; j < = n ; j + + ) {
r1 + = a [ x ] [ j ] ;
}
//列
int r2 = 0 ;
for ( int j = 1 ; j < = n ; j + + ) {
r2 + = a [ j ] [ y ] ;
}
//左上到右下
int r3 = 0 ;
for ( int j = 1 ; j < = n ; j + + ) {
r3 + = a [ j ] [ j ] ;
}
//右上到左下
int r4 = 0 ;
for ( int j = 1 ; j < = n ; j + + ) {
r4 + = a [ j ] [ n - j + 1 ] ;
}
if ( r1 = = - n | | r2 = = - n | | r3 = = - n | | r4 = = - n ) {
cout < < i < < " milk! " < < endl ;
return 0 ;
} else if ( r1 = = n | | r2 = = n | | r3 = = n | | r4 = = n ) {
cout < < i < < " juice! " < < endl ;
return 0 ;
}
}
cout < < " drawn! " < < endl ;
//关闭文件
fclose ( stdin ) ;
return 0 ;
}