Poj 1231 the alphabet game

Source: Internet
Author: User

[Description]: The input K and P, K represents several letters, that is, the input has several lines, P indicates that each letter has several, in the form of coordinates (x, Y ). now let's divide the same letter into a rectangle and ask if it can be implemented.

[Analysis]: Alas, low-level mistakes !!! Remember! Accumulation!

/* Date: 2014/11/04 time: 21: 38by: vidattention: coordinate creation is the key to understanding this problem and organizing ideas. In my coordinate system, the X axis points to the right, and the Y axis points to the bottom, just like the figure in the question! * // 228 K 0 Ms # include <iostream> using namespace STD; # define max (x, y) (x)> (y )? (X) :( y) # define min (x, y) (x) <(y )? (X) :( y) # define INF 000000000int lef [27], righ [27], up [27], under [27]; bool check (int n) {for (INT I = 0; I <n; I ++) {for (Int J = 0; j <n; j ++) {if (I = J) continue; If (LEF [J]> = lef [I] & lef [J] <= righ [I]) | (righ [J] <= righ [I] & righ [J]> = lef [I]) & (up [J]> = up [I] & up [J] <= under [I]) | (under [J] <= under [I] & under [J]> = up [I]) return 0 ;}} return 1 ;} int main () {int T, K, P; int X, Y; CIN> T; while (t --) {CIN> K> P; for (INT I = 0; I <K; I ++) {int LL = inf, RR = 0, uup = inf, UN = 0; For (Int J = 0; j <p; j ++) {CIN> x> Y; LL = min (LL, x), RR = max (RR, x ), uup = min (uup, Y), UN = max (UN, Y);} lef [I] = ll, righ [I] = RR, up [I] = uup, under [I] = UN;} For (INT I = 0; I <K; I ++) {for (Int J = 0; j <K; j ++) {if (I = J) continue; If (LEF [I]> lef [J] & lef [I] <righ [J]) lef [I] = lef [J]; If (righ [I] <righ [J] & righ [I]> lef [J]) righ [I] = righ [J]; If (up [I]> up [J] & up [I] <under [J]) up [I] = up [J]; If (under [I] <under [J] & under [I]> up [J]) under [I] = under [J] ;}} if (check (k) cout <"yes" <Endl; else cout <"no" <Endl;} return 0 ;}


Poj 1231 the alphabet game

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.