Algorithm Training secret Love

Source: Internet
Author: User

algorithm training secret lovetime limit: 1.0s memory limit: 256.0MBDescription of the problem in a high school, he was afraid to look for her, although in other people's eyes, it is a simple thing. Secret Love is the only thing he can do. He can only calisthenics every day, looking at her position, to see her heart-to-heart movements, just enough. The colored bricks on the playground, your position, is where they can stand, their relationship is like brick and brick as fixed, can not be shaken. Remember the first brick workers, the whole playground by square brick (the whole playground can be regarded as r row C column matrix, each element of the matrix is a square brick), square bricks have two kinds, one is blue, the other is red. We define the "love indicator" between him and her as the area of the largest solid color square, please write a program to find the "Love indicator". Input format the first line two positive integers r and C.
Next, Row C describes the entire playground, and the red bricks are used as a means of blue bricks. The output format is a number that represents the "love indicator" between him and her. Sample Input 5 8
0 0 0 1 1 1 0 1
1 1 0 1 1 1 1 1
0 1 1 1 1 1 0 1
1 0 1 1 1 1 1 0
1 1 1 0 1 1 0 1 Sample output 9 data size and convention 40% data r,c<=10;
70% of Data r,c<=50;
100% of Data r,c<=200; Plainly is a square area, the children of the secret love is so strange to think ...
ImportJava.util.Scanner; Public classMain {Static ints[][]=New int[200] [200]; Static intIspure (intX1,intY1,intW) {//W is width        intI,j,pure=S[x1][y1];  for(i=0;i<w;i++)             for(j=0;j<w;j++){                if(s[x1+i][y1+j]!=pure)return0;//there are different colors of return 0                }                        return1; }     Public Static voidMain (string[] args) {//TODO auto-generated Method StubScanner sc=NewScanner (system.in); intr,c,i,j,w; intMax=0, M; R=Sc.nextint (); C=Sc.nextint (); if(r>c) m=R; Elsem=C;  for(i=0;i<r;i++)             for(j=0;j<c;j++) S[i][j]=Sc.nextint ();  for(i=0;i<r;i++)             for(j=0;j<c;j++)            {                 for(w=max+1;w<=m;w++) {//the length of the side to look for each time is greater than the length of the found side, W cannot exceed the long edge.                     if(I+w<=r && j+w<=c) {                        if(Ispure (i,j,w) ==1) max=W; }                    Else  Break; }} System.out.println (Max*max); }}

Algorithm Training secret Love

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.