// Topcoder Single Round Match 590 Round 1 - Division II, Level One
using System;
using System.Collections.Generic;
using System.Linq;
public class FoxAndGomoku
{
public String win ( String[] board )
{
int cx = board[0].Length;
int cy = board.Length;
for ( int y = 0; y < cy; y++ )
{
for ( int x = 0; x < cx; x++ )
{
int cnt1=0;
int cnt2=0;
int cnt3=0;
int cnt4=0;
for ( int i = 0; i < 5; i++ )
{
if ( ( y + i ) >= 0 && ( y + i ) < cy )
if ( board[y + i][x] == 'o' )
cnt1++;
if ( ( x + i ) >= 0 && ( x + i ) < cx )
if ( board[y][x + i] == 'o' )
cnt2++;
if ( ( ( x + i ) >= 0 && ( x + i ) < cx ) && ( ( y
+ i ) >= 0 && ( y + i ) < cy ) )
if ( board[y + i][x + i] == 'o' )
cnt3++;
if ( ( ( x - i ) >= 0 && ( x - i ) < cx ) && ( ( y
+ i ) >= 0 && ( y + i ) < cy ) )
if ( board[y + i][x - i] == 'o' )
cnt4++;
}
if ( cnt1 >= 5 || cnt2 >= 5 || cnt3 >= 5 || cnt4 >= 5 )
return "found";
}
}
return "not found";
}
static void Main ( string[] args ) { }
}
No comments:
Post a Comment