Coder-Strike 2014 - Finals (online edition, Div. 2 A、B)

A. Pasha and Hamsters
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Pasha has two hamsters: Arthur and Alexander. Pasha put n apples in front of them. Pasha knows which apples Arthur likes. Similarly, Pasha knows which apples Alexander likes. Pasha doesn't want any conflict between the hamsters (as they may like the same apple), so he decided to distribute the apples between the hamsters on his own. He is going to give some apples to Arthur and some apples to Alexander. It doesn't matter how many apples each hamster gets but it is important that each hamster gets only the apples he likes. It is possible that somebody doesn't get any apples.

Help Pasha distribute all the apples between the hamsters. Note that Pasha wants to distribute all the apples, not just some of them.

Input

The first line contains integers nab (1 ≤ n ≤ 100; 1 ≤ a, b ≤ n) — the number of apples Pasha has, the number of apples Arthur likes and the number of apples Alexander likes, correspondingly.

The next line contains a distinct integers — the numbers of the apples Arthur likes. The next line contains b distinct integers — the numbers of the apples Alexander likes.

Assume that the apples are numbered from 1 to n. The input is such that the answer exists.

Output

Print n characters, each of them equals either 1 or 2. If the i-h character equals 1, then the i-th apple should be given to Arthur, otherwise it should be given to Alexander. If there are multiple correct answers, you are allowed to print any of them.

Sample test(s)
input
4 2 3
1 2
2 3 4
output
1 1 2 2
input
5 5 2
3 4 1 2 5
2 3
output
1 1 1 1 1

题解:简单。

AC code:

#include <iostream>
using namespace std;
int main()
{
	int apple[105],n,i,m,k,x;
	while(cin>>n>>m>>k)
	{
        for(i=1;i<=n;i++)
			apple[i]=0;
          for(i=1;i<=m;i++)
		  {
			  cin>>x;
			  if(apple[x]==0)
			  {
				  apple[x]=1;
			  }
		  }
		  for(i=1;i<=k;i++)
		  {
			  cin>>x;
			  if(apple[x]==0)
				  apple[x]=2;
		  }
		  for(i=1;i<=n-1;i++)
			  cout<<apple[i]<<" ";
		  cout<<apple[i]<<endl;
	}
  return 0;
}

B. Start Up
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Recently, a start up by two students of a state university of city F gained incredible popularity. Now it's time to start a new company. But what do we call it?

The market analysts came up with a very smart plan: the name of the company should be identical to its reflection in a mirror! In other words, if we write out the name of the company on a piece of paper in a line (horizontally, from left to right) with large English letters, then put this piece of paper in front of the mirror, then the reflection of the name in the mirror should perfectly match the line written on the piece of paper.

There are many suggestions for the company name, so coming up to the mirror with a piece of paper for each name wouldn't be sensible. The founders of the company decided to automatize this process. They asked you to write a program that can, given a word, determine whether the word is a 'mirror' word or not.

Input

The first line contains a non-empty name that needs to be checked. The name contains at most 105 large English letters. The name will be written with the next sans serif font:

Output

Print 'YES' (without the quotes), if the given name matches its mirror reflection. Otherwise, print 'NO' (without the quotes).

Sample test(s)
input
AHA
output
YES
input
Z
output
NO
input
XO
output
NO

题解:回文字符+字母是否对称,注意对称字母

AC code:

#include <iostream>
#include <string.h>
using namespace std;
char str[100005];
int main()
{
   int l,i,flag,flag1;
   while(cin>>str)
   {
	   flag=1;flag1=1;
	   l = strlen(str);
	    for(i=0;i<l;i++)
		   if(str[i]!=str[l-i-1])
		   {
			   flag=0;break;
		   }
		   for(i=0;i<l;i++)
		   {
			   if(str[i]!='A' && str[i]!='H' && str[i]!='I'&&str[i]!='M' &&str[i]!='O' && str[i]!='T' && str[i]!='U' && str[i]!='V' && str[i]!='W' &&str[i]!='X' &&str[i]!='Y')
			   {
				   flag1=0;
				   break;
			   }
		   }
		   if(flag && flag1)
			   cout<<"YES"<<endl;
		   else
			   cout<<"NO"<<endl;
   }
	return 0;
}



  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值