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

来个暴力代码。呵呵,大神飘过,勿笑。

Posted by lanjiangzhou at 2013-04-28 00:23:54 on Problem 1970
// I'm lanjiangzhou
//C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <time.h>
//C++
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <cctype>
#include <stack>
#include <string>
#include <list>
#include <queue>
#include <map>
#include <vector>
#include <deque>
#include <set>
using namespace std;

//*************************OUTPUT*************************
#ifdef WIN32
#define INT64 "%I64d"
#define UINT64 "%I64u"
#else
#define INT64 "%lld"
#define UINT64 "%llu"
#endif

//**************************CONSTANT***********************
#define INF 0x3f3f3f3f

// aply for the memory of the stack
//#pragma comment (linker, "/STACK:1024000000,1024000000")
//end

const int maxn =110;
int a[maxn][maxn];


int main() {
	int t;
	scanf("%d",&t);
	while(t--){
		int l=1000,r=1000;
		memset(a,0,sizeof(a));
		int i,j;
		for(i=0;i<=30;i++)
		{
			for(j=0;j<=30;j++)
			{
				a[i][j]=3;
			}
		}
		int flag1=0,flag2=0; 
		for(i=1;i<=19;i++){
			for( j=1;j<=19;j++){
				scanf("%d",&a[i][j]);
			}
		}
		//同一行
		for( i=1;i<=19;i++){
			for( j=1;j<=19;j++){
				if(a[i][j]==1&&a[i][j+1]==1&&a[i][j+2]==1&&a[i][j+3]==1&&a[i][j+4]==1&&a[i][j+5]!=1&&a[i][j-1]!=1){
					if(i<l){
						l=i;
						r=j;
						flag1=1;
					}
				}
				else if(a[i][j]==2&&a[i][j+1]==2&&a[i][j+2]==2&&a[i][j+3]==2&&a[i][j+4]==2&&a[i][j+5]!=2&&a[i][j-1]!=2){
					if(i<l){
						l=i;
						r=j;
						flag2=1;
					}
				}
			}
		}
		//同一列
		for( i=1;i<=19;i++){
			for( j=1;j<=19;j++){
				if(a[i][j]==1&&a[i+1][j]==1&&a[i+2][j]==1&&a[i+3][j]==1&&a[i+4][j]==1&&a[i+5][j]!=1&&a[i-1][j]!=1){
					if(i<l){
						l=i;
						r=j;
						flag1=1;
					}
				}
				else if(a[i][j]==2&&a[i+1][j]==2&&a[i+2][j]==2&&a[i+3][j]==2&&a[i+4][j]==2&&a[i+5][j]!=2&&a[i-1][j]!=2){
					if(i<l){
						l=i;
						r=j;
						flag2=1;
					}
				}
			}
		}
		//flag=0;
		//副对角线
		for(i=1;i<=19;i++){
			for( j=1;j<=19;j++){
				if(a[i][j]==1&&a[i+1][j+1]==1&&a[i+2][j+2]==1&&a[i+3][j+3]==1&&a[i+4][j+4]==1&&a[i+5][j+5]!=1&&a[i-1][j-1]!=1){
					if(i<l){
						l=i;
						r=j;
						flag1=1;
					}
				}
				else if(a[i][j]==2&&a[i+1][j+1]==2&&a[i+2][j+2]==2&&a[i+3][j+3]==2&&a[i+4][j+4]==2&&a[i+5][j+5]!=2&&a[i-1][j-1]!=2){
					if(i<l){
						l=i;
						r=j;
						flag2=1;
					}
				}
			}
		}
		//flag=0;
		//主对角线
		for( i=19;i>=1;i--){
			for( j=1;j<=19;j++){
				if(a[i][j]==1&&a[i-1][j+1]==1&&a[i-2][j+2]==1&&a[i-3][j+3]==1&&a[i-4][j+4]==1&&a[i-5][j+5]!=1&&a[i+1][j-1]!=1){
					if(i<l){
						l=i;
						r=j;
						flag1=1;
					}
				}
				else if(a[i][j]==2&&a[i-1][j+1]==2&&a[i-2][j+2]==2&&a[i-3][j+3]==2&&a[i-4][j+4]==2&&a[i-5][j+5]!=2&&a[i+1][j-1]!=2){
					if(i<l){
						l=i;
						r=j;
						flag2=1;
					}
				}
			}
		}
		if(flag1==0&&flag2==0){
			printf("0\n");
		}
		else if(flag1){
			printf("1\n");
			printf("%d %d\n",l,r);
		}
		else if(flag2){
			printf("2\n");
			printf("%d %d\n",l,r);
		}

	}
	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