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

N^4 水过

Posted by youshiki at 2016-09-30 15:58:39 on Problem 3251
/*
 * You Siki
 * Born to be King!
 */

#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<algorithm>

//using namespace std;

const int LIMIT = 100000;

char in[LIMIT], *p = in;

__inline int nextInt(void) {

    register int res = 0;

    while (*p < '0' || *p > '9')++p;

    while (*p >= '0' && *p <= '9')
        res = res * 10 + *p++ - '0';

    return res;

}

signed main(void) {
	
#ifndef ONLINE_JUDGE
	freopen("bigsq.in", "r", stdin);
	freopen("bigsq.out", "w", stdout);
#endif

	fread(p, 1, LIMIT, stdin);
	
	register int n = nextInt();
	
	register int map[105][105], ans = 0;
	
	for (register int i = 1; i <= n; ++i) {
		
		while (*p == ' ' || *p == '\n')++p;
		
		for (register int j = 1; j <= n; ++j, ++p) {
			
			if (*p == '*')
				map[i][j] = 0;
			
			else if (*p == 'J')
				map[i][j] = 1;
				
			else
				map[i][j] = -1;
				
		}
						
	}
	
	register int x1, y1, x2, y2, x3, y3, x4, y4, a, b, t, dx, dy;
		
	for (x1 = 1; x1 <= n; ++x1)
		for (y1 = 1; y1 <= n; ++y1)if (~(a = map[x1][y1]))
		
			for (x2 = n; x2 >= x1; --x2)
				for (y2 = n; y2 >= y1 ; --y2)if (~(b = map[x2][y2])) {
					
					dx = x1 - x2, dy = y1 - y2;
					t = dx * dx + dy * dy;
					
					if (t > ans && (dx || dy)) {
						
						x3 = x1 - dy, y3 = y1 + dx;
						
						if (x3 > n || y3 < 1)continue;
						
						x4 = x2 - dy, y4 = y2 + dx;
						
						if (x4 > n || y4 < 1)continue;
						
						if (a + b + map[x3][y3] + map[x4][y4] > 2)
							ans = t;
							
					}
					
				}
					
	printf("%d\n", ans);

}

/*

注意不要干没意义的事,这样就不会TLE

*/

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