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

## ~~~~(>_<)~~~~ 求大神给组数据告诉我哪错了

Posted by Superloser at 2014-10-10 18:28:11 on Problem 1471
```#include <map>
#include <queue>
#include <cmath>
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define pi 3.1415926
#define INF 123456789
using namespace std;
char str[505][505];
int flag[505][505], n;
int dfs(int x, int y){
int b = y, f = 0, e = y, q;
int xx = x;
int sum1 = 0;
if((y + x) % 2 == 1){
while(1){
for(q = b; q <= e; q ++){
if(flag[xx][q] != 1){
f = 1;
break;
}
}
if(f) break;
else
sum1 ++;
if(b == 0 || e == 2 * n - 1 || xx == n - 1)
break;
b --; e ++; xx ++;
}
}
else{
while(1){
for(q = b; q <= e; q ++){
if(flag[xx][q] != 1){
f = 1;
break;
}
}
if(f) break;
else
sum1 ++;
if(b == 0 || e == 2 * n - 1 || xx == 0)
break;
b --; e ++; xx --;
}
}
return sum1;
}
int main(){
int i, j, Max, sum, tt = 0, qq, s ,summ;
while(~scanf("%d", &n), n){
getchar();
for(i = 0; i < n; i ++){
gets(str[i]);
}
memset(flag, 0, sizeof(flag));
for(i = 0; i < n; i ++){
for(j = 0; j < strlen(str[i]); j ++){
if(str[i][j] == '-')
flag[i][j] = 1;
else if(str[i][j] == '#')
flag[i][j] = 2;
}
}
for(i = 0, Max = -1; i < n;i ++){
for(j = 0; j < strlen(str[i]); j ++){
if(flag[i][j] == 1){
sum = dfs(i, j);
if(sum > Max)   Max = sum;
}
}
}
for(i = 1, s = 1, summ = 1; i < Max; i ++){
s += 2;
summ += s;
}
printf("Triangle #%d\n", ++ tt);
printf("The largest triangle area is %d.\n\n", summ);
}
return 0;
}
/*
3
##-#-
---
#
3
-----
-#-
-
5
###-####-
#---###
--#--
--#
#
5
#-##----#
-----#-
---#-
-#-
-
4
#-#-#--
#---#
##-
-
*/
```

Followed by: