码迷,mamicode.com
首页 > 其他好文 > 详细

cf 47B

时间:2015-01-10 21:00:54      阅读:220      评论:0      收藏:0      [点我收藏+]

标签:

G - Coins
Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u
Appoint description: 

Description

One day Vasya came across three Berland coins. They didn‘t have any numbers that‘s why Vasya didn‘t understand how their denominations differ. He supposed that if one coin is heavier than the other one, then it should be worth more. Vasya weighed all the three pairs of coins on pan balance scales and told you the results. Find out how the deminations of the coins differ or if Vasya has a mistake in the weighting results. No two coins are equal.

Input

The input data contains the results of all the weighting, one result on each line. It is guaranteed that every coin pair was weighted exactly once. Vasya labelled the coins with letters «A», «B» and «C». Each result is a line that appears as (letter)(> or < sign)(letter). For example, if coin "A" proved lighter than coin "B", the result of the weighting is A<B.

Output

It the results are contradictory, print Impossible. Otherwise, print without spaces the rearrangement of letters «A», «B» and «C» which represent the coins in the increasing order of their weights.

Sample Input

Input
A>B
C<B
A>C
Output
CBA
Input
A<B
B>C
C>A
Output
ACB
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<queue>
#include<set>
#include<vector>
using namespace std;
int cnt[200];
int main()
{
      char s[4];
      for(int i=0;i<3;i++)
      {
            scanf("%s",s);
            if(s[1]==‘<‘)
                  cnt[s[2]]++;
            else
                  cnt[s[0]]++;
      }
      if(cnt[‘A‘]&&cnt[‘B‘]&&cnt[‘C‘])
      {
            printf("Impossible\n");
      }
      else
      {
           for(int i=0;i<3;i++)
           {
                 for(int j=0;j<3;j++)
                 {
                       if(cnt[‘A‘+j]==i)
                              printf("%c",(char)(‘A‘+j));
                 }
           }
      }
      printf("\n");
      return 0;
}

  

cf 47B

标签:

原文地址:http://www.cnblogs.com/a972290869/p/4215570.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!