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

谁帮我找找。。。de了半天bug找不到问题,有什么变態数据。。。

Posted by KatrineYang at 2016-10-01 14:00:30 on Problem 3251
#include <iostream>
#include <stdio.h>
using namespace std;

void g(int n, int &J, int &B){
	if(n==1) J++;
	else if(n==-1) B++;
}

int main() {
	int N;
	scanf("%d", &N);
	int oc[110][110];
	for(int i = 0; i < N; i++){
		char hehe[110];
		scanf("%s", hehe);
		for(int j = 0; j < N; j++){
			if(hehe[j] == 'J') oc[i][j] = 1;
			else if(hehe[j] == 'B') oc[i][j] = -1;
			else oc[i][j] = 0;
		}
	}
	int mx = 0;
	for(int l = N-1; l > 0; l--){
		for(int i = 0; i < N-l; i++){
			for(int j = 0; j < N-l; j++){
				int cntJ = 0;
				int cntB = 0;
				g(oc[i][j], cntJ, cntB);
				g(oc[i][j+l], cntJ, cntB);
				g(oc[i+l][j], cntJ, cntB);
				g(oc[i+l][j+l], cntJ, cntB);
				if(cntJ==4 || (cntJ==3 && cntB==0)){
					mx = l;
					goto done;
				}
			}
		}
	}
	done:
	printf("%d\n", mx*mx);
	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