Tianda ACM 1090. City Hall

Source: Internet
Author: User

The key to this question is how you choose to calculate the bricks that need to be added, starting from the height of the child or from the big height. The main subject is a new array to store the number of bricks starting from the largest (maximum height) brick. In the Code "for (int k=m;k>=1;k--)"

Then through the following str[iii][j]= ' 1 '; To make up, and then calculate the number of bricks of the second largest height. And so on, come to a conclusion.

#include <iostream>#include<cstring>using namespacestd;Const intM = $;intMain () {intM,n; CharStr[m][m]; intPp[m]; CIN>>m>>N;    GetChar (); intI,j,k,ii,c;  for(i=0; i<m;i++) gets (Str[i]);  for(k=m;k>=1; k--)    {        intCount =0;  for(j=0; j<n;j++)        {             for(i=0; i<m;i++)            {                if(str[i][j]=='0') {C=0;  for(ii=i;ii<m;ii++)                  {                    if(str[ii][j]=='0') C++; Else{II--;  Break; }                   }                  if(c==k) {Count++;  for(intiii=i;iii<=ii;iii++) Str[iii][j]='1'; } I=II; } }} pp[k-1]=count; }     for(i=0; i<m;i++)      if(pp[i]!=0) cout<<i+1<<" "<<pp[i]<<Endl; return 0;}

Tianda ACM 1090. City Hall

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.