A - UOIAUAI

Time Limit: 2 sec / Memory Limit: 256 MB

配点 : 100

問題文

英小文字 c が与えられるので、c が母音であるか判定してください。ここで、英小文字のうち母音は aeiou5 つです。

制約

  • c は英小文字である。

入力

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

c

出力

c が母音であるとき、vowel と、そうでないとき consonant と出力せよ。


入力例 1

a

出力例 1

vowel

a は母音なので、vowel と出力します。


入力例 2

z

出力例 2

consonant

入力例 3

s

出力例 3

consonant

Score : 100 points

Problem Statement

Given a lowercase English letter c, determine whether it is a vowel. Here, there are five vowels in the English alphabet: a, e, i, o and u.

Constraints

  • c is a lowercase English letter.

Input

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

c

Output

If c is a vowel, print vowel. Otherwise, print consonant.


Sample Input 1

a

Sample Output 1

vowel

Since a is a vowel, print vowel.


Sample Input 2

z

Sample Output 2

consonant

Sample Input 3

s

Sample Output 3

consonant
B - Thin

Time Limit: 2 sec / Memory Limit: 256 MB

配点 : 200

問題文

H ピクセル、横 W ピクセルの画像があります。全てのピクセルは . または * で表されるものとします。上から i 番目、左から j 番目のピクセルを表す文字を C_{i,j} で表します。

この画像を 2 倍縦長にした画像を出力してください。すなわち、縦 2H ピクセル、横 W ピクセルの画像であって、上から i 番目、左から j 番目のピクセルは、C_{(i+1)/2,j} (ただし、割り算は切り捨て)と等しい画像を出力してください。

制約

  • 1≦H, W≦100
  • C_{i,j} . または * である。

入力

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

H W
C_{1,1}...C_{1,W}
:
C_{H,1}...C_{H,W}

出力

与えられた画像を 2 倍縦長にした画像を出力せよ。


入力例 1

2 2
*.
.*

出力例 1

*.
*.
.*
.*

入力例 2

1 4
***.

出力例 2

***.
***.

入力例 3

9 20
.....***....***.....
....*...*..*...*....
...*.....**.....*...
...*.....*......*...
....*.....*....*....
.....**..*...**.....
.......*..*.*.......
........**.*........
.........**.........

出力例 3

.....***....***.....
.....***....***.....
....*...*..*...*....
....*...*..*...*....
...*.....**.....*...
...*.....**.....*...
...*.....*......*...
...*.....*......*...
....*.....*....*....
....*.....*....*....
.....**..*...**.....
.....**..*...**.....
.......*..*.*.......
.......*..*.*.......
........**.*........
........**.*........
.........**.........
.........**.........

Score : 200 points

Problem Statement

There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either . or *. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}.

Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).

Constraints

  • 1≦H, W≦100
  • C_{i,j} is either . or *.

Input

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

H W
C_{1,1}...C_{1,W}
:
C_{H,1}...C_{H,W}

Output

Print the extended image.


Sample Input 1

2 2
*.
.*

Sample Output 1

*.
*.
.*
.*

Sample Input 2

1 4
***.

Sample Output 2

***.
***.

Sample Input 3

9 20
.....***....***.....
....*...*..*...*....
...*.....**.....*...
...*.....*......*...
....*.....*....*....
.....**..*...**.....
.......*..*.*.......
........**.*........
.........**.........

Sample Output 3

.....***....***.....
.....***....***.....
....*...*..*...*....
....*...*..*...*....
...*.....**.....*...
...*.....**.....*...
...*.....*......*...
...*.....*......*...
....*.....*....*....
....*.....*....*....
.....**..*...**.....
.....**..*...**.....
.......*..*.*.......
.......*..*.*.......
........**.*........
........**.*........
.........**.........
.........**.........
C - Daydream

Time Limit: 2 sec / Memory Limit: 256 MB

配点 : 300

問題文

英小文字からなる文字列 S が与えられます。 Tが空文字列である状態から始め、以下の操作を好きな回数繰り返すことで S = T とすることができるか判定してください。

  • T の末尾に dream dreamer erase eraser のいずれかを追加する。

制約

  • 1≦|S|≦10^5
  • S は英小文字からなる。

入力

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

S

出力

S = T とすることができる場合 YES を、そうでない場合 NO を出力せよ。


入力例 1

erasedream

出力例 1

YES

erase dream の順で T の末尾に追加することで S = T とすることができます。


入力例 2

dreameraser

出力例 2

YES

dream eraser の順で T の末尾に追加することで S = T とすることができます。


入力例 3

dreamerer

出力例 3

NO

Score : 300 points

Problem Statement

You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times:

  • Append one of the following at the end of T: dream, dreamer, erase and eraser.

Constraints

  • 1≦|S|≦10^5
  • S consists of lowercase English letters.

Input

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

S

Output

If it is possible to obtain S = T, print YES. Otherwise, print NO.


Sample Input 1

erasedream

Sample Output 1

YES

Append erase and dream at the end of T in this order, to obtain S = T.


Sample Input 2

dreameraser

Sample Output 2

YES

Append dream and eraser at the end of T in this order, to obtain S = T.


Sample Input 3

dreamerer

Sample Output 3

NO
D - Connectivity

Time Limit: 2 sec / Memory Limit: 256 MB

配点 : 400

問題文

N 個の都市があり、K 本の道路と L 本の鉄道が都市の間に伸びています。 i 番目の道路は p_i 番目と q_i 番目の都市を双方向に結び、 i 番目の鉄道は r_i 番目と s_i 番目の都市を双方向に結びます。 異なる道路が同じ 2 つの都市を結ぶことはありません。同様に、異なる鉄道が同じ 2 つの都市を結ぶことはありません。

ある都市から別の都市に何本かの道路を通って到達できるとき、それらの都市は道路で連結しているとします。また、すべての都市はそれ自身と道路で連結しているとみなします。
鉄道についても同様に定めます。

全ての都市について、その都市と道路・鉄道のどちらでも連結している都市の数を求めてください。

制約

  • 2 ≦ N ≦ 2*10^5
  • 1 ≦ K, L≦ 10^5
  • 1 ≦ p_i, q_i, r_i, s_i ≦ N
  • p_i < q_i
  • r_i < s_i
  • i ≠ j のとき、(p_i, q_i) ≠ (p_j, q_j)
  • i ≠ j のとき、(r_i, s_i) ≠ (r_j, s_j)

入力

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

N K L
p_1 q_1
:
p_K q_K
r_1 s_1
:
r_L s_L

出力

N 個の整数を出力せよ。i 番目の数は i 番目の都市と道路・鉄道の両方で連結している都市の数である。


入力例 1

4 3 1
1 2
2 3
3 4
2 3

出力例 1

1 2 2 1

1, 2, 3, 4 番目の都市は全て互いに道路で連結しています。

鉄道で連結している都市は 2, 3 のみなので、答えは順に 1, 2, 2, 1 となります。


入力例 2

4 2 2
1 2
2 3
1 4
2 3

出力例 2

1 2 2 1

入力例 3

7 4 4
1 2
2 3
2 5
6 7
3 5
4 5
3 4
6 7

出力例 3

1 1 2 1 2 2 2

Score : 400 points

Problem Statement

There are N cities. There are also K roads and L railways, extending between the cities. The i-th road bidirectionally connects the p_i-th and q_i-th cities, and the i-th railway bidirectionally connects the r_i-th and s_i-th cities. No two roads connect the same pair of cities. Similarly, no two railways connect the same pair of cities.

We will say city A and B are connected by roads if city B is reachable from city A by traversing some number of roads. Here, any city is considered to be connected to itself by roads. We will also define connectivity by railways similarly.

For each city, find the number of the cities connected to that city by both roads and railways.

Constraints

  • 2 ≦ N ≦ 2*10^5
  • 1 ≦ K, L≦ 10^5
  • 1 ≦ p_i, q_i, r_i, s_i ≦ N
  • p_i < q_i
  • r_i < s_i
  • When i ≠ j, (p_i, q_i) ≠ (p_j, q_j)
  • When i ≠ j, (r_i, s_i) ≠ (r_j, s_j)

Input

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

N K L
p_1 q_1
:
p_K q_K
r_1 s_1
:
r_L s_L

Output

Print N integers. The i-th of them should represent the number of the cities connected to the i-th city by both roads and railways.


Sample Input 1

4 3 1
1 2
2 3
3 4
2 3

Sample Output 1

1 2 2 1

All the four cities are connected to each other by roads.

By railways, only the second and third cities are connected. Thus, the answers for the cities are 1, 2, 2 and 1, respectively.


Sample Input 2

4 2 2
1 2
2 3
1 4
2 3

Sample Output 2

1 2 2 1

Sample Input 3

7 4 4
1 2
2 3
2 5
6 7
3 5
4 5
3 4
6 7

Sample Output 3

1 1 2 1 2 2 2