zoukankan      html  css  js  c++  java
  • CCPC A(模拟)

    Secrete Master Plan

    Time Limit: 3000/1000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others)
     
     

    Master 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 are only four numbers written in dots on a piece of sheet. The numbers form a 2×2 matrix, but Fei didn't know the correct direction to hold the sheet. What a pity!

    Given two 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.

    title

    Input

    The first line of the input gives the number of test cases, T(1T104). T test cases follow. Each test case contains 4 lines. Each line contains two integers ai0 and ai1 (1ai0,ai1100). The first two lines stands for the original plan, the 3rd and 4th line stands for the plan Fei opened.

    Output

    For 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 input and output

    Sample InputSample Output
    4
    1 2
    3 4
    1 2
    3 4
    
    1 2
    3 4
    3 1
    4 2
    
    1 2
    3 4
    3 2
    4 1
    
    1 2
    3 4
    4 3
    2 1
    Case #1: POSSIBLE
    Case #2: POSSIBLE
    Case #3: IMPOSSIBLE
    

    题解:要善于把复杂问题简单化,而不是复杂化,自己用数组模拟了半天,好神经;

    代码:

     1 #include<iostream>
     2 #include<cstdio>
     3 #include<cstring>
     4 #include<cmath>
     5 #include<algorithm>
     6 using namespace std;
     7 const int INF=0x3f3f3f3f;
     8 int main(){
     9     int a,b,c,d,x,y,z,w;
    10     int T,cnt=0;
    11     scanf("%d",&T);
    12     while(T--){
    13         scanf("%d%d%d%d",&b,&a,&c,&d);
    14         scanf("%d%d%d%d",&y,&x,&z,&w);
    15         bool t1=(a==x&&b==y&&c==z&&d==w);
    16         bool t2=(a==y&&b==z&&c==w&&d==x);
    17         bool t3=(a==z&&b==w&&c==x&&d==y);
    18         bool t4=(a==w&&b==x&&c==y&&d==z);
    19         int flot=0;
    20         if(t1||t2||t3||t4)flot=1;
    21         printf("Case #%d: ",++cnt);
    22         if(flot)puts("POSSIBLE");
    23         else puts("IMPOSSIBLE");
    24     }
    25     return 0;
    26 }
  • 相关阅读:
    linux 查看磁盘空间大小
    CSS里常见的块级元素和行内元素
    bootstrap改变上传文件按钮样式,并显示已上传文件名
    深度剖析:PHP中json_encode与json_decode
    2016 版 Laravel 系列入门教程
    支付宝私钥和公钥的生成方法
    iOS企业包安装注意事项详解(解决提示iPhone未受信任的问题)
    libevent的入门学习-库的安装【转】
    ibevent 和 libev 提高网络应用性能【转】
    libevent学习笔记 一、基础知识【转】
  • 原文地址:https://www.cnblogs.com/handsomecui/p/4922956.html
Copyright © 2011-2022 走看看