Bzoj 1567: [Jsoi2008]blue Mary's campaign map

Source: Internet
Author: User

IME limit:10 Sec Memory limit:162 MB
submit:1009 solved:576
[Submit] [Status] [Discuss] Descriptionblue Mary has recently been fascinated by the RPG game of playing StarCraft (StarCraft). She is trying to find more campaign maps to further improve her level. Because Blue Mary's technology has reached a certain height, so for a campaign map that can be used in the same way, she will be able to understand this type of battle by playing one, and then she will not be interested in playing this kind of map again. Many of the online maps are of the same play, so Blue Mary needs you to write a program to help her determine which maps belong to the same class. Specifically, Blue Mary has encoded the campaign map as a matrix of n*n, with a 32-bit (signed) positive integer inside each lattice of the matrix. For two matrices, their similarity is defined as the edge length of their largest public square matrix. The greater the similarity of the two matrices, the more likely the two battle maps are to belong to the same class. The first line of input contains a positive integer n. The following n rows, each containing n positive integers, represent a matrix of the first battle map. The following n rows, each containing n positive integers, represent a matrix of the second campaign map. Output contains only one row. This line has only a positive integer that indicates how similar the two matrices are. Sample Input3
1 2 3
4 5 6
7 8 9
5 6 7
8 9 1
2 3 4

Sample Output2

HINT

Sample explanation:

Sub-matrices:
5 6
8 9
Maximum common matrix for two maps

Conventions:
N<=50

Source

%%% Social Building

Positive solution of violent pressure

Dragon Slayer Blades click on Send

#include <cstdio>#include<cctype>#include<map>#defineN 55using namespaceStd;map<int,BOOL>Q,q;inlinevoidRead (int&x) {RegisterCharCh=GetChar ();  for(x=0;! IsDigit (CH); ch=GetChar ());  for(; isdigit (CH); x=x*Ten+ch-'0', ch=GetChar ());}intA[n][n],b[n][n],n,ans;intMain () {Read (n);  for(intI=1; i<=n;++i) for(intj=1; j<=n;++j) Read (A[i][j]);  for(intI=1; i<=n;++i) for(intj=1; j<=n;++j) Read (B[i][j]);  for(inti=n;i>=1;--i) { for(intj=1; j<=n-i+1;++j) for(intk=1; k<=n-i+1;++k) for(intL=1; l<=n-i+1;++l) for(intA=1; a<=n-i+1;++a) {BOOLflag=true;  for(intb=0; b<i;++b) { for(intC=0; c<i;++c)if(a[j+b][k+c]!=b[l+b][a+c]) {flag=false;  Break; }                 if(flag==false) Break; }               if(flag) {printf ("%d\n", i);return 0;} }    }    return 0;    Fclose (stdin); Fclose (stdout);}intsb=Main ();intMainintargcChar*argv[]) {;}

Bzoj 1567: [Jsoi2008]blue Mary's campaign map

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.