Background
HNSDFZ's classmates are going to rehearse a dance to celebrate the Spring Festival.
Describe
The performers rank in n rows, forming a forward triangle (on the screen, i.e. downward). And as for everyone, he might face forward (a small forward triangle), or a back triangle (a small backward positive triangle).
However, these people have obvious differences in clothing-part in winter uniforms and others in summer uniforms.
Now give everyone's clothing situation, please ask you to wear the summer school uniform the largest positive triangle, the output contains the number of people.
Input format
The first row is N.
Next n Row, the first row of 2*i-1 a valid character (' # ' or '-', respectively, the students wear winter uniforms or summer uniforms). A space appears in the input file, and the space is just to preserve the shape of the entire triangle.
Output format
Number of outputs.
Test Sample 1 input
5
#-##----#
-----#-
---#-
-#-
-
Output
9
Note
n<=100
Note that triangles can only face down.
#include <iostream>#include<cstdio>#include<string>#include<cstring>#include<algorithm>using namespacestd;Const intMAXN =505;intN,A[MAXN][MAXN],F[MAXN][MAXN],ANS,SUM[MAXN];intMain () {CIN>>N; Charcmd; sum[1] =1; for(inti =1; I <= n;i++){ for(intL =1; l <=2* (n-i) +1; l++){ intj = i + L-1; scanf ("%c",&cmd); while(cmd! ='-'&& cmd! ='#') scanf ("%c",&cmd); if(cmd = ='#') A[i][j] =1; ElseA[I][J] =2; } } for(inti =3; I <=2N1; i + =2) Sum[i] = sum[i-2] +i; for(inti =1; I <= n;i++){ for(intL =1; l <=2* (n-i) +1; l++){ intj = i + L-1; if(A[i][j] = =2) F[i][j] =1; if(L &1) if(A[i][j] = =2&& a[i][j+1] ==2&& a[i][j+2] ==2&& a[i+1][j+1] ==2) F[i][j] =3; Ans=Max (ans,f[i][j]); } } for(intK =5; K <=2N1; k + =2){ for(inti =1; I <= n;i++){ for(intL =1; l <=2* (n-i) +1; l++){ intj = i + L-1; if((L &1) && F[i][j] >= K-2&& f[i][j+2] >= K-2&& f[i+1][j+1] >= K-2) {F[i][j]=K; Ans=Max (ans,k); } }}} cout<<Sum[ans]; return 0;}
The choreography of tyvj1192 spring Prom