A - CBC

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 100

問題文

英大文字と英小文字からなる文字列 S が与えられます。S の英大文字のみを元の順序で連結して得られる文字列を出力してください。

制約

  • S は英大文字と英小文字からなる文字列である
  • S の長さは 1 以上 100 以下である

入力

入力は以下の形式で標準入力から与えられる。

S

出力

S の英大文字のみを元の順序で連結して得られる文字列を出力せよ。


入力例 1

AtCoderBeginnerContest

出力例 1

ACBC

S の英大文字のみを元の順序で連結して得られる文字列は ACBC です。よって、ACBC を出力します。


入力例 2

PaymentRequired

出力例 2

PR

入力例 3

program

出力例 3



S に英大文字が含まれないことがあることに注意してください。

Score : 100 points

Problem Statement

You are given a string S consisting of uppercase and lowercase English letters. Print the string obtained by concatenating only the uppercase letters of S in their original order.

Constraints

  • S is a string of uppercase and lowercase English letters.
  • The length of S is between 1 and 100, inclusive.

Input

The input is given from Standard Input in the following format:

S

Output

Print the string obtained by concatenating only the uppercase letters of S in their original order.


Sample Input 1

AtCoderBeginnerContest

Sample Output 1

ACBC

The string obtained by concatenating only the uppercase letters of S in their original order is ACBC. Hence, print ACBC.


Sample Input 2

PaymentRequired

Sample Output 2

PR

Sample Input 3

program

Sample Output 3



Note that S may contain no uppercase letters.

B - Not Found

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 100

問題文

英小文字からなる長さ 1 以上 25 以下の文字列 S が与えられます。
S に含まれない英小文字をひとつ出力してください。
但し、そのようなものが複数ある場合はどれを出力しても構いません。

制約

  • S は英小文字からなる長さ 1 以上 25 以下の文字列

入力

入力は以下の形式で標準入力から与えられる。

S

出力

S に含まれない英小文字をひとつ出力せよ。そのようなものが複数ある場合はどれを出力しても構わない。


入力例 1

a

出力例 1

d

S= a です。
a 以外の英小文字、 b, c, ..., z が正解となります。


入力例 2

abcdfhijklmnopqrstuvwxyz

出力例 2

e

S 中に含まれない英小文字は eg です。


入力例 3

qazplwsxokmedcijnrfvuhbgt

出力例 3

y

Score : 100 points

Problem Statement

You are given a string S of length between 1 and 25 consisting of lowercase English letters.
Output one lowercase English letter that does not appear in S.
If there are multiple such letters, you may output any one of them.

Constraints

  • S is a string of length between 1 and 25 (inclusive) consisting of lowercase English letters.

Input

The input is given from Standard Input in the following format:

S

Output

Output one lowercase English letter that does not appear in S. If there are multiple such letters, you may output any one of them.


Sample Input 1

a

Sample Output 1

d

S= a.
Any lowercase English letter other than a (that is, b, c, …, or z) is a correct answer.


Sample Input 2

abcdfhijklmnopqrstuvwxyz

Sample Output 2

e

The lowercase English letters not included in S are e and g.


Sample Input 3

qazplwsxokmedcijnrfvuhbgt

Sample Output 3

y
C - Postal Card

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 200

問題文

数字のみからなる長さ 6 の文字列が N 個与えられます。i \, (i = 1, 2, \dots, N) 番目のものを S_i と表します。

さらに、数字のみからなる長さ 3 の文字列が M 個与えられます。j \, (j = 1, 2, \dots, M) 番目のものを T_j と表します。

S_1, S_2, \dots, S_N のうち、末尾 3 文字が T_1, T_2, \dots, T_M のいずれかに一致するものの個数を求めてください。

制約

  • 1 \leq N, M \leq 1000
  • N, M は整数
  • 全ての i = 1, 2, \dots, N に対し、S_i は数字のみからなる長さ 6 の文字列
  • 全ての j = 1, 2, \dots, M に対し、T_j は数字のみからなる長さ 3 の文字列

入力

入力は以下の形式で標準入力から与えられる。

N M
S_1
S_2
\vdots
S_N
T_1
T_2
\vdots
T_M

出力

答えを出力せよ。


入力例 1

3 3
142857
004159
071028
159
287
857

出力例 1

2

S_1 の末尾 3 文字は 857 であり、これは T_3 に一致します。
S_2 の末尾 3 文字は 159 であり、これは T_1 に一致します。
S_3 の末尾 3 文字は 028 であり、これは T_1, T_2, T_3 のいずれにも一致しません。

以上から、答えは 2 です。


入力例 2

5 4
235983
109467
823476
592801
000333
333
108
467
983

出力例 2

3

入力例 3

4 4
000000
123456
987111
000000
000
111
999
111

出力例 3

3

Score : 200 points

Problem Statement

You are given N strings of length six each, consisting of digits. Let S_i be the i-th (i = 1, 2, \dots, N) of them.

You are also given M strings of length three each, consisting of digits. Let T_j be the j-th (j = 1, 2, \dots, M) of them.

Find the number of strings among S_1, S_2, \dots, S_N whose last three characters coincide with one or more of T_1, T_2, \dots, T_M.

Constraints

  • 1 \leq N, M \leq 1000
  • N and M are integers.
  • S_i is a string of length 6 consisting of digits, for all i = 1, 2, \dots, N.
  • T_j is a string of length 3 consisting of digits, for all j = 1, 2, \dots, M.

Input

The input is given from Standard Input in the following format:

N M
S_1
S_2
\vdots
S_N
T_1
T_2
\vdots
T_M

Output

Print the answer.


Sample Input 1

3 3
142857
004159
071028
159
287
857

Sample Output 1

2

The last three characters of S_1 are 857, which coincide with T_3.
The last three characters of S_2 are 159, which coincide with T_1.
The last three characters of S_3 are 028, which do not coincide with T_1, T_2, or T_3.

Thus, the answer is 2.


Sample Input 2

5 4
235983
109467
823476
592801
000333
333
108
467
983

Sample Output 2

3

Sample Input 3

4 4
000000
123456
987111
000000
000
111
999
111

Sample Output 3

3
D - Most Minority

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 200

問題文

1,2,\dots,N ( N は奇数 ) が、 M 回の 01 かを選択する投票を行いました。
各人の各回の投票は N 個の長さ M0, 1 からなる文字列 S_1,S_2,\dots,S_N として与えられ、 S_ij 文字目は人 ij 回目の投票への内容を表します。

各回の投票で、少数派であった人は 1 点を得ます。
より厳密には、次のルールで得点が与えられます。

  • その回の投票で 0 を選択した人が x 人、 1 を選択した人が y 人いたとします。
    • x=0 または y=0 である場合、その投票では全員に 1 点が与えられる。
    • そうでなく x<y である場合、その投票で 0 に投票した人のみに 1 点が与えられる。
    • そうでない場合、その投票で 1 に投票した人のみに 1 点が与えられる。
    • なお、 N が奇数であることから x=y となることはないことに留意してください。

M 回の投票を終えた後、それらの投票における合計の得点が最も高い人を全員求めてください。

制約

  • N1 \le N \le 99 を満たす 奇数
  • M1 \le M \le 100 を満たす整数
  • S_i は長さ M0, 1 からなる文字列

入力

入力は以下の形式で標準入力から与えられる。

N M
S_1
S_2
\vdots
S_N

出力

得点が最も高い人の番号を全て、 番号の昇順に 空白区切りで出力せよ。


入力例 1

3 5
11100
10101
01110

出力例 1

2 3

このケースでは、 3 人が 5 回の投票を行いました。

  • 1 回目の投票では人 11 、人 21 、人 30 に投票しました。よって、人 3 のみが 1 点を得ます。
  • 2 回目の投票では人 11 、人 20 、人 31 に投票しました。よって、人 2 のみが 1 点を得ます。
  • 3 回目の投票では人 11 、人 21 、人 31 に投票しました。よって、全員が 1 点を得ます。
  • 4 回目の投票では人 10 、人 20 、人 31 に投票しました。よって、人 3 のみが 1 点を得ます。
  • 5 回目の投票では人 10 、人 21 、人 30 に投票しました。よって、人 2 のみが 1 点を得ます。

この結果、人 1 は合計 1 点、人 2 は合計 3 点、人 3 は合計 3 点を得ました。
よって、人 2,3 が合計の得点が最も高い人です。これらを番号の昇順に出力してください。


入力例 2

5 4
0000
0000
0000
0000
0000

出力例 2

1 2 3 4 5

入力例 3

7 8
11010011
01000000
01111100
10111000
10011110
10100101
10010110

出力例 3

1 2 3

Score : 200 points

Problem Statement

People 1,2,\dots,N (where N is odd) conducted M votes where each person chooses either 0 or 1.
Each person's vote for each round is given as N strings S_1,S_2,\dots,S_N of length M consisting of 0 and 1, where the j-th character of S_i represents person i's vote content for the j-th vote.

In each vote, people who were in the minority receive 1 point.
More precisely, points are given according to the following rules:

  • Suppose x people chose 0 and y people chose 1 in that vote.
    • If x=0 or y=0, everyone receives 1 point for that vote.
    • Otherwise, if x<y, only people who voted 0 in that vote receive 1 point.
    • Otherwise, only people who voted 1 in that vote receive 1 point.
    • Note that since N is odd, x=y never occurs.

After finishing M votes, find all people who have the highest total score from those votes.

Constraints

  • N is an odd number satisfying 1 \le N \le 99.
  • M is an integer satisfying 1 \le M \le 100.
  • S_i is a string of length M consisting of 0 and 1.

Input

The input is given from Standard Input in the following format:

N M
S_1
S_2
\vdots
S_N

Output

Output all person numbers with the highest score in ascending order of person number, separated by spaces.


Sample Input 1

3 5
11100
10101
01110

Sample Output 1

2 3

In this case, three people conducted five votes.

  • In the 1st vote, person 1 voted 1, person 2 voted 1, person 3 voted 0. Thus, only person 3 receives 1 point.
  • In the 2nd vote, person 1 voted 1, person 2 voted 0, person 3 voted 1. Thus, only person 2 receives 1 point.
  • In the 3rd vote, person 1 voted 1, person 2 voted 1, person 3 voted 1. Thus, everyone receives 1 point.
  • In the 4th vote, person 1 voted 0, person 2 voted 0, person 3 voted 1. Thus, only person 3 receives 1 point.
  • In the 5th vote, person 1 voted 0, person 2 voted 1, person 3 voted 0. Thus, only person 2 receives 1 point.

As a result, person 1 received a total of 1 points, person 2 received a total of 3 points, and person 3 received a total of 3 points.
Therefore, persons 2 and 3 have the highest total score. Output these in ascending order of person number.


Sample Input 2

5 4
0000
0000
0000
0000
0000

Sample Output 2

1 2 3 4 5

Sample Input 3

7 8
11010011
01000000
01111100
10111000
10011110
10100101
10010110

Sample Output 3

1 2 3
E - PC on the Table

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 300

問題文

高橋君は部屋に PC を沢山置こうとしています。そこで最大何台の PC を部屋に置けるか調べるプログラムを書くことにしました。

H 個の長さ W., T からなる文字列 S_1,S_2,\ldots,S_H が与えられます。

高橋君は以下の操作を 0 回以上何回でも行うことができます。

  • 1\leq i \leq H, 1 \leq j \leq W-1 を満たす整数であって、 S_ij 番目の文字も j+1 番目の文字も T であるようなものを選ぶ。 S_ij 番目の文字を P で置き換え、S_ij+1 番目の文字を C で置き換える。

高橋君が操作回数の最大化を目指すとき、操作終了後の S_1,S_2,\ldots,S_H としてあり得るものの一例を出力してください。

制約

  • 1\leq H \leq 100
  • 2\leq W \leq 100
  • HW は整数である
  • S_i., T からなる長さ W の文字列

入力

入力は以下の形式で標準入力から与えられる。

H W 
S_1
S_2
\vdots
S_H

出力

高橋君が操作回数の最大化を目指すとき、操作終了後の S_1,S_2,\ldots,S_H としてあり得るものの一例を改行区切りで出力せよ。

解が複数存在する場合、どれを出力しても正答とみなされる。


入力例 1

2 3
TTT
T.T

出力例 1

PCT
T.T

可能な操作回数の最大値は 1 です。

例えば、 (i,j)=(1,1) として操作を行うと、S_1PCT に変化します。


入力例 2

3 5
TTT..
.TTT.
TTTTT

出力例 2

PCT..
.PCT.
PCTPC

Score : 300 points

Problem Statement

Planning to place many PCs in his room, Takahashi has decided to write a code that finds how many PCs he can place in his room.

You are given H strings S_1,S_2,\ldots,S_H, each of length W, consisting of . and T.

Takahashi may perform the following operation any number of times (possibly zero):

  • Choose integers satisfying 1\leq i \leq H and 1 \leq j \leq W-1 such that the j-th and (j+1)-th characters of S_i are both T. Replace the j-th character of S_i with P, and (j+1)-th with C.

He tries to maximize the number of times he performs the operation. Find possible resulting S_1,S_2,\ldots,S_H.

Constraints

  • 1\leq H \leq 100
  • 2\leq W \leq 100
  • H and W are integers.
  • S_i is a string of length W consisting of . and T.

Input

The input is given from Standard Input in the following format:

H W 
S_1
S_2
\vdots
S_H

Output

Print a sequence of strings, S_1,S_2,\ldots,S_H, separated by newlines, possibly resulting from maximizing the number of times he performs the operation.

If multiple solutions exist, print any of them.


Sample Input 1

2 3
TTT
T.T

Sample Output 1

PCT
T.T

He can perform the operation at most once.

For example, an operation with (i,j)=(1,1) makes S_1 PCT.


Sample Input 2

3 5
TTT..
.TTT.
TTTTT

Sample Output 2

PCT..
.PCT.
PCTPC