A - Probably English

実行時間制限: 2 sec / メモリ制限: 1024 MiB

配点 : 100

問題文

英小文字からなる N 個の文字列 W_1,W_2,\dots,W_N が与えられます。
これらのうち一つ以上が and, not, that, the, you のいずれかと一致するなら Yes 、そうでないなら No と出力してください。

制約

  • N1 以上 100 以下の整数
  • 1 \le |W_i| \le 50 ( |W_i| は文字列 W_i の長さ )
  • W_i は英小文字からなる

入力

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

N
W_1 W_2 \dots W_N

出力

答えを出力せよ。


入力例 1

10
in that case you should print yes and not no

出力例 1

Yes

例えば W_4= you なので、 Yes と出力します。


入力例 2

10
in diesem fall sollten sie no und nicht yes ausgeben

出力例 2

No

文字列 W_i はいずれも、 and, not, that, the, you のいずれとも一致しません。

Score : 100 points

Problem Statement

You are given N strings W_1,W_2,\dots,W_N consisting of lowercase English letters.
If one or more of these strings equal and, not, that, the, or you, then print Yes; otherwise, print No.

Constraints

  • N is an integer between 1 and 100, inclusive.
  • 1 \le |W_i| \le 50 (|W_i| is the length of W_i.)
  • W_i consists of lowercase English letters.

Input

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

N
W_1 W_2 \dots W_N

Output

Print the answer.


Sample Input 1

10
in that case you should print yes and not no

Sample Output 1

Yes

We have, for instance, W_4= you, so you should print Yes.


Sample Input 2

10
in diesem fall sollten sie no und nicht yes ausgeben

Sample Output 2

No

None of the strings W_i equals any of and, not, that, the, and you.

B - Online Shopping

実行時間制限: 2 sec / メモリ制限: 1024 MiB

配点 : 100

問題文

AtCoder 社は、オンラインショップでグッズを販売しています。

高橋君はそこで N 種類の商品を購入することにしました。
1 以上 N 以下の整数 i について、i 種類目の商品は 1P_i 円で、高橋君は Q_i 個購入します。

また、高橋君は送料を支払う必要があります。
送料は購入する商品の合計金額が S 円以上なら 0 円、そうでないならば K 円です。

高橋君が支払う金額は購入する商品の合計金額と送料の和です。
高橋君が支払う金額を求めてください。

制約

  • 1\leq N\leq 100
  • 1\leq S\leq 10000
  • 1\leq K\leq 10000
  • 1\leq P_i\leq 10000
  • 1\leq Q_i\leq 100
  • 入力はすべて整数

入力

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

N S K
P_1 Q_1
P_2 Q_2
\vdots
P_N Q_N

出力

高橋君がオンラインショッピングで支払う金額を出力せよ。


入力例 1

2 2000 500
1000 1
100 6

出力例 1

2100

高橋君は 11000 円の商品を 1 個と、 1100 円の商品を 6 つ購入します。
よって、購入する商品の合計金額は 1000\times 1+100\times 6=1600 円となります。
このとき購入する商品の合計金額は 2000 円未満であるため、送料は 500 円となります。
よって、高橋君の支払う金額は 1600+500=2100 円となります。


入力例 2

3 2000 500
1000 1
100 6
5000 1

出力例 2

6600

購入する商品の合計金額は 1000\times 1+100\times 6+5000\times 1=6600 円となります。
このとき購入する商品の合計金額は 2000 円以上であるため、送料は 0 円となります。
よって、高橋君の支払う金額は 6600+0=6600 円となります。


入力例 3

2 2000 500
1000 1
1000 1

出力例 3

2000

1 個あたりの価格が同じ商品が複数存在することもあります。

Score : 100 points

Problem Statement

AtCoder Inc. sells merchandise through its online shop.

Takahashi has decided to purchase N types of products from there.
For each integer i from 1 to N, the i-th type of product has a price of P_i yen each, and he will buy Q_i of this.

Additionally, he must pay a shipping fee.
The shipping fee is 0 yen if the total price of the products purchased is S yen or above, and K yen otherwise.

He will pay the total price of the products purchased plus the shipping fee.
Calculate the amount he will pay.

Constraints

  • 1\leq N\leq 100
  • 1\leq S\leq 10000
  • 1\leq K\leq 10000
  • 1\leq P_i\leq 10000
  • 1\leq Q_i\leq 100
  • All input values are integers.

Input

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

N S K
P_1 Q_1
P_2 Q_2
\vdots
P_N Q_N

Output

Print the amount Takahashi will pay for online shopping.


Sample Input 1

2 2000 500
1000 1
100 6

Sample Output 1

2100

Takahashi buys one product for 1000 yen and six products for 100 yen each.
Thus, the total price of the products is 1000\times 1+100\times 6=1600 yen.
Since the total amount for the products is less than 2000 yen, the shipping fee will be 500 yen.
Therefore, the amount Takahashi will pay is 1600+500=2100 yen.


Sample Input 2

3 2000 500
1000 1
100 6
5000 1

Sample Output 2

6600

The total price of the products is 1000\times 1+100\times 6+5000\times 1=6600 yen.
Since the total amount for the products is not less than 2000 yen, the shipping fee will be 0 yen.
Therefore, the amount Takahashi will pay is 6600+0=6600 yen.


Sample Input 3

2 2000 500
1000 1
1000 1

Sample Output 3

2000

There may be multiple products with the same price per item.

C - Takahashi's Failure

実行時間制限: 2 sec / メモリ制限: 1024 MiB

配点 : 200

問題文

高橋君の家には N 個の食品があり、i 番目の食品のおいしさは A_i です。
また、高橋君には嫌いな食品が K 個あり、具体的には i=1,2,\ldots,K について、B_i 番目の食品が嫌いです。

高橋君は N 個の食品のうち、おいしさが最大の食品から 1 つを選んで食べようと考えています。 高橋君が嫌いな食品を食べる可能性があるならば Yes を、食べる可能性が無いならば No を出力してください。

制約

  • 1\leq K\leq N\leq 100
  • 1\leq A_i\leq 100
  • 1\leq B_i\leq N
  • B_i はすべて相異なる
  • 入力はすべて整数

入力

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

N K
A_1 A_2 \ldots A_N
B_1 B_2 \ldots B_K

出力

高橋君が嫌いな食品を食べる可能性があるならば Yes を、無いならば No を出力せよ。


入力例 1

5 3
6 8 10 7 10
2 3 4

出力例 1

Yes

5 個の食品の中でおいしさが最大の食品は食品 352 つであり、この 2 つのいずれかを食べます。
高橋君が嫌いな食品は 2,3,43 つであり、そのうち食品 3 を食べる可能性があります。
よって、Yes を出力します。


入力例 2

5 2
100 100 100 1 1
5 4

出力例 2

No

おいしさが最大の食品は食品 1,2,33 つであり、高橋君は嫌いな食品を食べる可能性はありません。


入力例 3

2 1
100 1
2

出力例 3

No

おいしさが最大の食品は食品 1 であり、高橋君は嫌いな食品を食べる可能性はありません。

Score : 200 points

Problem Statement

Takahashi has N foods in his house. The i-th food has the tastiness of A_i.
He dislikes K of these foods: for each i=1,2,\ldots,K, he dislikes the B_i-th food.

Out of the foods with the greatest tastiness among the N foods, Takahashi will randomly choose one and eat it.
If he has a chance to eat something he dislikes, print Yes; otherwise, print No.

Constraints

  • 1\leq K\leq N\leq 100
  • 1\leq A_i\leq 100
  • 1\leq B_i\leq N
  • All B_i are distinct.
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

N K
A_1 A_2 \ldots A_N
B_1 B_2 \ldots B_K

Output

If Takahashi has a chance to eat a food he dislikes, print Yes; otherwise, print No.


Sample Input 1

5 3
6 8 10 7 10
2 3 4

Sample Output 1

Yes

Among the five foods, the ones with the greatest tastiness are Food 3 and 5, of which he eats one.
He dislikes Food 2, 3, and 4, one of which he has a chance to eat: Food 3.
Therefore, the answer is Yes.


Sample Input 2

5 2
100 100 100 1 1
5 4

Sample Output 2

No

The foods with the greatest tastiness are Food 1, 2, and 3, none of which he has a chance to eat.


Sample Input 3

2 1
100 1
2

Sample Output 3

No

The food with the greatest tastiness is Food 1, which he has no chance to eat.

D - Counterclockwise Rotation

実行時間制限: 2 sec / メモリ制限: 1024 MiB

配点 : 200

問題文

x 軸の正の向きが右、y 軸の正の向きが上であるような xy 座標平面において、点 (a,b) を原点を中心として反時計回りに d 度回転させた点を求めてください。

制約

  • -1000 \leq a,b \leq 1000
  • 1 \leq d \leq 360
  • 入力はすべて整数

入力

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

a b d

出力

求めるべき点を (a',b') とするとき、 a'b' をこの順に空白区切りで出力せよ。
なお、各出力について、解との絶対誤差または相対誤差が 10^{−6} 以下であれば正解として扱われる。


入力例 1

2 2 180

出力例 1

-2 -2

(2,2) を原点を中心として反時計回りに 180 度回転させた点は、(2,2) を原点について対称な位置に移動させた点であり、(-2,-2) となります。


入力例 2

5 0 120

出力例 2

-2.49999999999999911182 4.33012701892219364908

(5,0) を原点を中心として反時計回りに 120 度回転させた点は (-\frac {5}{2} , \frac {5\sqrt{3}}{2}) です。
この例での出力はこれらの値と厳密には一致しませんが、誤差が十分に小さいため正解として扱われます。


入力例 3

0 0 11

出力例 3

0.00000000000000000000 0.00000000000000000000

(a,b) が原点(回転の中心)なので回転させても座標が変わりません。


入力例 4

15 5 360

出力例 4

15.00000000000000177636 4.99999999999999555911

360 度回転させたので座標が変わりません。


入力例 5

-505 191 278

出力例 5

118.85878514480690171240 526.66743699786547949770

Score : 200 points

Problem Statement

In an xy-coordinate plane whose x-axis is oriented to the right and whose y-axis is oriented upwards, rotate a point (a, b) around the origin d degrees counterclockwise and find the new coordinates of the point.

Constraints

  • -1000 \leq a,b \leq 1000
  • 1 \leq d \leq 360
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

a b d

Output

Let the new coordinates of the point be (a', b'). Print a' and b' in this order, with a space in between.
Your output will be considered correct when, for each value printed, the absolute or relative error from the answer is at most 10^{-6}.


Sample Input 1

2 2 180

Sample Output 1

-2 -2

When (2, 2) is rotated around the origin 180 degrees counterclockwise, it becomes the symmetric point of (2, 2) with respect to the origin, which is (-2, -2).


Sample Input 2

5 0 120

Sample Output 2

-2.49999999999999911182 4.33012701892219364908

When (5, 0) is rotated around the origin 120 degrees counterclockwise, it becomes (-\frac {5}{2} , \frac {5\sqrt{3}}{2}).
This sample output does not precisely match these values, but the errors are small enough to be considered correct.


Sample Input 3

0 0 11

Sample Output 3

0.00000000000000000000 0.00000000000000000000

Since (a, b) is the origin (the center of rotation), a rotation does not change its coordinates.


Sample Input 4

15 5 360

Sample Output 4

15.00000000000000177636 4.99999999999999555911

A 360-degree rotation does not change the coordinates of a point.


Sample Input 5

-505 191 278

Sample Output 5

118.85878514480690171240 526.66743699786547949770
E - Bipartize

実行時間制限: 2 sec / メモリ制限: 1024 MiB



配点 : 350

問題文

N 頂点 M 辺の単純な無向グラフがあります。 グラフは頂点 1, 頂点 2,\ldots, 頂点 N からなり、i 番目 (1\le i\le M) の辺は頂点 u _ i と頂点 v _ i を結んでいます。

あなたは、次の操作を 0 回以上行います。

  • まだ削除されていない辺をひとつ選び、削除する。

あなたの目的はグラフを二部グラフにすることです。 操作を行ったあとのグラフを二部グラフにするために、最低でも何回操作を行う必要があるか求めてください。

グラフが単純であるとは

グラフが単純であるとは、自己ループ(u _ i=v _ i となる辺)や多重辺(u _ i=u _ j かつ v _ i=v _ j となる辺のペア)が存在しないことをいいます。

二部グラフとは

二部グラフとは、頂点をそれぞれ黒か白のどちらか一色で塗り、次の条件を満たすことができるグラフのことをいいます。

  • どの辺についても、その辺が結んでいるふたつの頂点に塗られた色は異なる。

制約

  • 2\le N\le10
  • 1\le M\le\dfrac{N(N-1)}2
  • 1\le u _ i\lt v _ i\le N\ (1\le i\le M)
  • 与えられるグラフは単純
  • 入力はすべて整数

入力

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

N M
u _ 1 v _ 1
u _ 2 v _ 2
\vdots
u _ M v _ M

出力

操作を行ったあとのグラフを二部グラフにするために、行う必要がある操作の回数を出力せよ。


入力例 1

5 8
1 2
1 3
1 4
2 3
2 5
3 4
3 5
4 5

出力例 1

2

例えば、頂点 1 と頂点 3 を結ぶ辺、頂点 3 と頂点 5 を結ぶ辺の 2 つを削除することでグラフを二部グラフにすることができます。

操作を 1 回以下行うことでグラフを二部グラフにすることはできないため、2 を出力してください。


入力例 2

2 1
1 2

出力例 2

0

グラフははじめから二部グラフです。 よって、行う必要がある操作の回数は 0 回です。


入力例 3

10 20
5 9
1 4
3 8
1 6
4 10
5 7
5 6
3 7
3 6
5 10
1 3
3 4
6 7
1 2
4 7
1 5
1 9
9 10
4 5
8 9

出力例 3

5

Score : 350 points

Problem Statement

There is a simple undirected graph with N vertices and M edges. The graph consists of vertex 1, vertex 2,\ldots, vertex N, and the i-th edge (1\le i\le M) connects vertices u _ i and v _ i.

You will perform the following operation zero or more times:

  • Choose one edge that has not been deleted yet, and delete it.

Your goal is to make the graph bipartite. Find the minimum number of operations needed to make the graph after the operations bipartite.

What it means for a graph to be simple?

A graph is simple if and only if it has no self-loops (edges where u _ i=v _ i) or multi-edges (pairs of edges where u _ i=u _ j and v _ i=v _ j).

What is a bipartite graph?

A bipartite graph is a graph where it is possible to color each vertex black or white satisfying the following condition:

  • For every edge, the two vertices connected by that edge have different colors.

Constraints

  • 2\le N\le10
  • 1\le M\le\dfrac{N(N-1)}2
  • 1\le u _ i\lt v _ i\le N\ (1\le i\le M)
  • The given graph is simple.
  • All input values are integers.

Input

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

N M
u _ 1 v _ 1
u _ 2 v _ 2
\vdots
u _ M v _ M

Output

Print the number of operations that need to be performed to make the graph bipartite.


Sample Input 1

5 8
1 2
1 3
1 4
2 3
2 5
3 4
3 5
4 5

Sample Output 1

2

You can make the graph bipartite by deleting two edges: for example, the edge connecting vertices 1 and 3, and the edge connecting vertices 3 and 5.

It is impossible to make the graph bipartite by performing one or less operations, so print 2.


Sample Input 2

2 1
1 2

Sample Output 2

0

The graph is bipartite from the beginning. Thus, the number of operations that need to be performed is 0.


Sample Input 3

10 20
5 9
1 4
3 8
1 6
4 10
5 7
5 6
3 7
3 6
5 10
1 3
3 4
6 7
1 2
4 7
1 5
1 9
9 10
4 5
8 9

Sample Output 3

5