• Emag eht htiw Em Pleh(imitate)


    Emag eht htiw Em Pleh
    Time Limit: 1000MS   Memory Limit: 65536K
    Total Submissions: 2901   Accepted: 1917

    Description

    This problem is a reverse case of the problem 2996. You are given the output of the problem H and your task is to find the corresponding input.

    Input

    according to output of problem 2996.

    Output

    according to input of problem 2996.

    Sample Input

    White: Ke1,Qd1,Ra1,Rh1,Bc1,Bf1,Nb1,a2,c2,d2,f2,g2,h2,a3,e4
    Black: Ke8,Qd8,Ra8,Rh8,Bc8,Ng8,Nc6,a7,b7,c7,d7,e7,f7,h7,h6

    Sample Output

    +---+---+---+---+---+---+---+---+
    |.r.|:::|.b.|:q:|.k.|:::|.n.|:r:|
    +---+---+---+---+---+---+---+---+
    |:p:|.p.|:p:|.p.|:p:|.p.|:::|.p.|
    +---+---+---+---+---+---+---+---+
    |...|:::|.n.|:::|...|:::|...|:p:|
    +---+---+---+---+---+---+---+---+
    |:::|...|:::|...|:::|...|:::|...|
    +---+---+---+---+---+---+---+---+
    |...|:::|...|:::|.P.|:::|...|:::|
    +---+---+---+---+---+---+---+---+
    |:P:|...|:::|...|:::|...|:::|...|
    +---+---+---+---+---+---+---+---+
    |.P.|:::|.P.|:P:|...|:P:|.P.|:P:|
    +---+---+---+---+---+---+---+---+
    |:R:|.N.|:B:|.Q.|:K:|.B.|:::|.R.|
    +---+---+---+---+---+---+---+---+

    Source

     1 #include<stdio.h>
     2 #include<string.h>
     3 #include<ctype.h>
     4 char chess[20][40] ;
     5 char st[40] = "+---+---+---+---+---+---+---+---+" ;
     6 char s1[40] = "|...|:::|...|:::|...|:::|...|:::|" ,s2[40] = "|:::|...|:::|...|:::|...|:::|...|" ;
     7 char color[100] ;
     8 char ch ;
     9 int row , col;
    10 
    11 int main ()
    12 {
    13    // freopen ("a.txt" , "r" , stdin) ;
    14     for (int i = 1 ; i <= 17 ; i++) {
    15         if (i & 1) {
    16             strcpy (chess[i] , st) ;
    17         }
    18         else {
    19             if ((i >> 1) & 1)
    20                 strcpy (chess[i] , s1) ;
    21             else
    22                 strcpy (chess[i] , s2) ;
    23         }
    24     }
    25     gets (color) ;
    26     int len = strlen (color) ;
    27     color [len] = ',' ;
    28     color [len + 1] = '' ;
    29     color [6] = ',' ;
    30 
    31     for (int i = 7 ; color[i] != '' ; i ++) {
    32         int cnt = 0 ;
    33         if (color[i] == ',') {
    34             for (int j = i - 1 ; cnt < 3 ; j-- , cnt++) {
    35                 if (cnt == 0)
    36                     row = (9 - (color[j] - '0') ) * 2 ;
    37                 if (cnt == 1)
    38                     col = (color [j] - 'a') * 4 + 2 ;
    39                 if (cnt == 2) {
    40                     if (color[j] == ',')
    41                         ch = 'P' ;
    42                     else
    43                         ch = color[j] ;
    44                 }
    45             }
    46         }
    47         chess[row][col] = ch ;
    48     }
    49 
    50     gets (color) ;
    51     len = strlen (color) ;
    52     color [len] = ',' ;
    53     color [len + 1] = '' ;
    54     color [6] = ',' ;
    55 
    56     for (int i = 7 ; color[i] != '' ; i ++) {
    57         int cnt = 0 ;
    58         if (color[i] == ',') {
    59             for (int j = i - 1 ; cnt < 3 ; j-- , cnt++) {
    60                 if (cnt == 0)
    61                     row = (9 - (color[j] - '0') ) * 2 ;
    62                 if (cnt == 1)
    63                     col = (color [j] - 'a') * 4 + 2 ;
    64                 if (cnt == 2) {
    65                     if (color[j] == ',')
    66                         ch = 'p' ;
    67                     else
    68                         ch = tolower (color[j]) ;
    69                 }
    70             }
    71         }
    72         chess[row][col] = ch ;
    73     }
    74 
    75     for (int i = 1 ; i <= 17 ; i++)
    76         puts (chess[i]) ;
    77 
    78     return 0 ;
    79 }
    View Code
  • 相关阅读:
    model number
    LeetCode: Largest Rectangle in Histogram 解题报告
    Leetcode:Edit Distance 解题报告
    Leetcode:Interleaving String 解题报告
    Leetcode:Scramble String 解题报告
    Leetcode:【DP】Longest Palindromic Substring 解题报告
    Leetcode:Longest Substring Without Repeating Characters 解题报告
    Leetcode: Remove Duplicates from Sorted List II 解题报告
    Leetcode:Flatten Binary Tree to Linked List 解题报告
    LeetCode: Convert Sorted Array to Binary Search Tree 解题报告
  • 原文地址:https://www.cnblogs.com/get-an-AC-everyday/p/4306954.html
Copyright © 2020-2023  润新知