Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

一次AC。。模拟筛选

Posted by skywhat at 2015-09-27 20:21:31 on Problem 1970
#include<iostream>
#include<cstdio>
#include<algorithm>

using namespace std;

int grid[21][21]={0};

int dir[4][2]={{0,1},{1,0},{1,1},{-1,1}};

int main()
{
    int t;
    int m=0;
    int i,j;
    int k;
    scanf("%d",&t);
    while(t--)
    {
        for(i=1;i<=19;++i)
        {
            for(j=1;j<=19;++j)
                scanf("%d",&grid[i][j]);
        }
        for(i=1;i<=19;++i)
        {
            for(j=1;j<=19;++j)
            {
                if(grid[i][j]==0)
                    continue;
                for(k=0;k<=3;++k)
                {
                    int x=i-dir[k][0];
                    int y=j-dir[k][1];
                    if(grid[i][j]==grid[x][y])
                        continue;
                    else
                    {
                        x=i,y=j;
                        for(m=1;m<=4;++m)
                        {
                            x+=dir[k][0];y+=dir[k][1];
                            if(grid[i][j]!=grid[x][y])
                                break;
                        }
                        if(m==5)
                        {
                            x+=dir[k][0];y+=dir[k][1];
                            if(grid[i][j]==grid[x][y])
                                continue;
                            else
                                break;
                        }
                    }
                
                }
                if(k<=3)
                    break;
            }
            if(j<=19)
                break;
        }
        if(i<19)
        {
            cout<<grid[i][j]<<endl;
            cout<<i<<" "<<j<<endl;
            
        }
        else
            cout<<"0"<<endl;
    }
    return 0;
}










Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator