HDU-5540 Secrete Master Plan

Source: Internet
Author: User

Time limit:3000/1000 MS (java/others) Memory limit:65535/65535 K (java/others)
Total submission (s): 801 Accepted Submission (s): 470

Problem Descriptionmaster Mind Kongming gave Fei Zhang a secrete master plan stashed in a pocket. The plan instructs how to deploy soldiers on the four corners of the city wall. Unfortunately, when Fei opened the pocket he found there is only four numbers written in dots on a piece of sheet. The Numbers form 2x2 matrix, but Fei didn ' t know the correct direction to the sheet. What a pity!

Given Secrete master plans. The first one is the master ' s original plan. The second one is the plan opened by Fei. As Kongming had many pockets to hand out, he might give Fei the wrong pocket. Determine if Fei receives the right pocket.

Inputthe first line of the input gives the number of test cases, T(1≤t≤4) .TTest cases follow. Each test case contains 4 lines. Each line contains integersai0 andai1 (1≤ai0,ai1≤ ). The first and lines stands for the original plan, the 3rD and 4tH line stands for the plan Fei opened.

Outputfor each test case, output one line containing " Case #x: y", where x is the test case number
(starting from 1) and y is either "POSSIBLE" or "impossible" (quotes for clarity).

Sample Input41 23 41 23 4 1 23 43 14 2 1 23 43 24 1 1 23 44 32 1

Sample outputcase #1: possiblecase #2: possiblecase #3: impossiblecase #4: POSSIBLE

Test instructions

The given matrix can be rotated to get the next matrix.

Compare whether the two elements are equal before and after the clockwise.

The AC code is attached:

1#include <bits/stdc++.h>2 using namespacestd;3 4 intMain () {5     intT;6Cin>>T;7     intans=1;8      while(t--){9         inta1,b1,c1,d1,a2,b2,c2,d2;TenCin>>a1>>b1>>c1>>d1>>a2>>b2>>c2>>D2; One         if(a2==a1&&b1==b2&&c1==C2) { Acout<<"Case #"<<ans++<<": POSSIBLE"<<Endl; -             Continue; -         } the         if(b2==a1&&a2==c1&&d2==B1) { -cout<<"Case #"<<ans++<<": POSSIBLE"<<Endl; -             Continue; -         } +         if(c2==a1&&d2==c1&&a2==B1) { -cout<<"Case #"<<ans++<<": POSSIBLE"<<Endl; +             Continue; A         } at         if(d2==a1&&c2==b1&&b2==C1) { -cout<<"Case #"<<ans++<<": POSSIBLE"<<Endl; -             Continue; -         } -cout<<"Case #"<<ans++<<": Impossible"<<Endl; -     } in     return 0; -}

HDU-5540 Secrete Master Plan

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.