HDU ACM 4500 Small Q series Story-the reverse of the cock silk

Source: Internet
Author: User

Analysis: Water problem, pay attention to the calculation of a position of the score of his own does not count, plus and minus are absolute values (at first it was also misunderstood).

#include <iostream> #include <cmath>using namespace Std;int a[25][25];int main () {int I,j,n,m;int maxv,maxi, Maxj,tmp;while (cin>>n>>m && n+m) {for (i=0;i<n;i++) for (j=0;j<m;j++) cin>>a[i][j]; Maxv=-100000000;for (i=0;i<n;i++) for (j=0;j<m;j++) {tmp=0;if (i>0) {if (a[i][j]*a[i-1][j]<0) Tmp+=abs (a[ I-1][J]); Elsetmp-=abs (A[i-1][j]);} if (j>0) {if (a[i][j]*a[i][j-1]<0)    tmp+=abs (a[i][j-1]); Elsetmp-=abs (A[i][j-1]);} if (i<n-1) {if (a[i][j]*a[i+1][j]<0) Tmp+=abs (A[i+1][j]); Elsetmp-=abs (A[i+1][j]);} if (j<m-1) {if (a[i][j]*a[i][j+1]<0) Tmp+=abs (a[i][j+1]); Elsetmp-=abs (a[i][j+1]);} if (maxv<tmp) {maxv=tmp;maxi=i;maxj=j;}} cout<<maxi+1<< "<<maxj+1<<" "<<MAXV<<ENDL;} return 0;}


HDU ACM 4500 Small Q series Story-the reverse of the cock silk

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.