Swust OJ 188--Space (reading test instructions is important)

Source: Internet
Author: User

Title Link: http://acm.swust.edu.cn/problem/188/

Time limit (ms): + Memory Limit (KB): 65535 the river Bird has come to a very strange planet, on this planet, there are two two-dimensional coordinate system xx and yy, the coordinates between the two coordinate systems have the following function relationship:
F (x) =x^2+2*x+3
F (Y) =3*y+2
For example, the point on the XX coordinate system (3,4) is mapped by this relationship to get the point on the YY coordinate system (18,14). This mapping relationship is one; at the same time, there is a mapping relationship between the points on the X coordinate system (a, B) and the YY coordinate system (C,D) where the distance between them is d=|a-d|+|b-c|. This is the mapping relationship two.
Because for each point in the xx coordinate system, there is a unique point in the YY coordinate system and it corresponds, now for the XX and YY points in accordance with the mapping relationship two matching, and each point on XX only and yy on a point to match, yy on each point only and xx on a point to match, Now your task is to find the smallest of the D maximums in all possible matching relationships.
Description The first line to enter a number case, which represents the total number of test data below, each of the following case consists of two parts:
The first part inputs N, which represents the number of points on the XX coordinate system (1<=N<=100)
The second part inputs the coordinates of these n points on the xx coordinate system (XI,YI) (0<=xi<=500,0<=yi<=500)
Input minimum output of the D maximum in all possible matching relationships
12345 123 41 2
Sample Input
1 25
Sample Output Problem Solving ideas: according to test instructions to be, but allThe minimum of D maximum in a matching relationship I don't know what it means (all kinds of WA), I'm drunk too ~ ~
Find out all correspondence points, the origin set and the mapping point set one by one pair, has the largest d,at this point, the original points correspond to the minimum d of the mapping point seten~~, if you don't understand, just look at the code.The code is as follows:
1#include <iostream>2#include <cmath>3 using namespacestd;4  5InlineintMapping_x (intx) {6     returnx* (x +2) +3;7 }8InlineintMapping_y (inty) {9     return 3* y +2;Ten } OneInlineintMapping_dis (intXinty) { A     returnABS (X-y); - } - intMain () { the     intT, N, I, J, K, Maxn, Max, ptr[101][4]; -CIN >>T; -      while(t--){ -CIN >>N; +Max =0x7ffffff; -          for(i =0; I < n; i++){ +CIN >> ptr[i][0] >> ptr[i][1]; Aptr[i][2] = mapping_x (ptr[i][0]); atptr[i][3] = mapping_y (ptr[i][1]); -         } -          for(i =0; I < n; i++){ -              for(MAXN = j =0; J < N; J + +){ -K = Mapping_dis (ptr[i][0], ptr[j][3]) + Mapping_dis (ptr[i][1], ptr[j][2]); -MAXN = maxn>k?maxn:k; in             } -max = Max < MAXN?MAX:MAXN; to         } +cout << Max <<Endl; -     } the     return 0; *}
View Code

Swust OJ 188--Space (reading test instructions is important)

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.