Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
高橋君の住む AtCoder 国には「長さが 5 の倍数である文字列を書いてはならない」という奇妙な法律があります。
高橋君は文字列 S を書きました。高橋君がこの法律に違反しているかどうか判定してください。
制約
- S は長さ 1 以上 10 以下の文字列
- S は英小文字からなる文字列
入力
入力は以下の形式で標準入力から与えられる。
S
出力
高橋君が法律に違反しているのであれば Yes を、違反していないのであれば No を出力せよ。
入力例 1
legal
出力例 1
Yes
legal は長さが 5 の文字列です。よって、高橋君は法律に違反しているため Yes と出力してください。
入力例 2
atcoder
出力例 2
No
atcoder は長さが 7 の文字列です。よって、高橋君は法律に違反していないため No と出力してください。
入力例 3
illegal
出力例 3
No
Score : 100 points
Problem Statement
In the country of AtCoder where Takahashi lives, there is a peculiar law: "You must not write a string whose length is a multiple of 5."
Takahashi wrote a string S. Determine whether he is violating this law.
Constraints
- S is a string of length between 1 and 10, inclusive.
- S consists of lowercase English letters.
Input
The input is given from Standard Input in the following format:
S
Output
If Takahashi is violating the law, output Yes; otherwise, output No.
Sample Input 1
legal
Sample Output 1
Yes
legal is a string of length 5. Thus, Takahashi is violating the law, so output Yes.
Sample Input 2
atcoder
Sample Output 2
No
atcoder is a string of length 7. Thus, Takahashi is not violating the law, so output No.
Sample Input 3
illegal
Sample Output 3
No
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
長さ N の整数列 A=(A_1,A_2,\dots,A_N) と整数 X が与えられます。
i=1,2,\dots,N の順に以下を行ってください。
- もし A_i<X なら、 X=A_i に更新した上で
1を出力する。 - そうでないなら
0を出力する。
制約
- 入力は全て整数
- 1 \le N,X,A_i \le 100
入力
入力は以下の形式で標準入力から与えられる。
N X A_1 A_2 \dots A_N
出力
N 行出力せよ。
そのうち k 行目には、 i=k についての出力をせよ。
入力例 1
5 10 6 4 7 1 3
出力例 1
1 1 0 1 0
- 最初、 X=10 です。
- i=1 について、 A_1=6<X=10 なので、 X=6 に更新した上で
1を出力します。 - i=2 について、 A_2=4<X=6 なので、 X=4 に更新した上で
1を出力します。 - i=3 について、 A_3=7 \ge X=4 なので、
0を出力します。 - i=4 について、 A_4=1<X=4 なので、 X=1 に更新した上で
1を出力します。 - i=5 について、 A_5=3 \ge X=1 なので、
0を出力します。
入力例 2
1 1 1
出力例 2
0
入力例 3
8 20 9 19 14 17 17 4 18 4
出力例 3
1 0 0 0 0 1 0 0
Score : 100 points
Problem Statement
You are given a length-N integer sequence A=(A_1,A_2,\dots,A_N) and an integer X.
For i=1,2,\dots,N in this order, do the following.
- If A_i<X, update X=A_i and output
1. - Otherwise, output
0.
Constraints
- All input values are integers.
- 1 \le N,X,A_i \le 100
Input
The input is given from Standard Input in the following format:
N X A_1 A_2 \dots A_N
Output
Output N lines.
The k-th line should contain the output for i=k.
Sample Input 1
5 10 6 4 7 1 3
Sample Output 1
1 1 0 1 0
- Initially, X=10.
- For i=1: since A_1=6<X=10, update X=6 and output
1. - For i=2: since A_2=4<X=6, update X=4 and output
1. - For i=3: since A_3=7 \ge X=4, output
0. - For i=4: since A_4=1<X=4, update X=1 and output
1. - For i=5: since A_5=3 \ge X=1, output
0.
Sample Input 2
1 1 1
Sample Output 2
0
Sample Input 3
8 20 9 19 14 17 17 4 18 4
Sample Output 3
1 0 0 0 0 1 0 0
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
正整数 N が与えられるので、下記で定まる長さ (N+1) の文字列 s_0s_1\ldots s_N を出力してください。
各 i = 0, 1, 2, \ldots, N について、
- 1 以上 9 以下の N の約数 j であって、i が N/j の倍数であるものが存在するとき、そのような j のうち最小のものに対応する数字を s_i とする。(よって、この場合 s_i は
1、2、\ldots 、9のいずれかである。)- そのような j が存在しないとき、s_i は
-とする。
制約
- 1 \leq N \leq 1000
- 入力はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
N
出力
答えを出力せよ。
入力例 1
12
出力例 1
1-643-2-346-1
以下で、いくつかの i について s_i の決め方を説明します。
-
i = 0 について、1 以上 9 以下の N の約数 j であって i が N/j の倍数であるものは、j = 1, 2, 3, 4, 6 の 5 個です。そのうち最小のものは 1 であるので、s_0 =
1です。 -
i = 4 について、1 以上 9 以下の N の約数 j であって i が N/j の倍数であるものは、j = 3, 6 の 2 個です。そのうち最小のものは 3 であるので、s_4 =
3です。 -
i = 11 について、1 以上 9 以下の N の約数 j であって i が N/j の倍数であるものは存在しないので、s_{11} =
-です。
入力例 2
7
出力例 2
17777771
入力例 3
1
出力例 3
11
Score : 200 points
Problem Statement
You are given a positive integer N. Print a string of length (N+1), s_0s_1\ldots s_N, defined as follows.
For each i = 0, 1, 2, \ldots, N,
- if there is a divisor j of N that is between 1 and 9, inclusive, and i is a multiple of N/j, then s_i is the digit corresponding to the smallest such j (s_i will thus be one of
1,2, ...,9);- if no such j exists, then s_i is
-.
Constraints
- 1 \leq N \leq 1000
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N
Output
Print the answer.
Sample Input 1
12
Sample Output 1
1-643-2-346-1
We will explain how to determine s_i for some i.
-
For i = 0, the divisors j of N between 1 and 9 such that i is a multiple of N/j are 1, 2, 3, 4, 6. The smallest of these is 1, so s_0 =
1. -
For i = 4, the divisors j of N between 1 and 9 such that i is a multiple of N/j are 3, 6. The smallest of these is 3, so s_4 =
3. -
For i = 11, there are no divisors j of N between 1 and 9 such that i is a multiple of N/j, so s_{11} =
-.
Sample Input 2
7
Sample Output 2
17777771
Sample Input 3
1
Sample Output 3
11
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
英小文字からなる 3 つの文字列 S_1, S_2, S_3 と、1、2、3 のみからなる文字列 T が与えられます。
T の各文字に対応する文字列を連結してできる文字列を出力してください。より厳密には、以下の指示にしたがって文字列を出力してください。
- 1 \leq i \leq |T| を満たす整数 i に対し、文字列 s_i を次のように定める。
- T の i 文字目が
1のとき、S_1 - T の i 文字目が
2のとき、S_2 - T の i 文字目が
3のとき、S_3
- T の i 文字目が
- s_1, s_2, \dots, s_{|T|} をこの順に連結してできる文字列を出力する。
制約
- 1 \leq |S_1|, |S_2|, |S_3| \leq 10
- 1 \leq |T| \leq 1000
- S_1, S_2, S_3 は英小文字からなる。
- T は
1、2、3のみからなる。
入力
入力は以下の形式で標準入力から与えられる。
S_1 S_2 S_3 T
出力
答えを出力せよ。
入力例 1
mari to zzo 1321
出力例 1
marizzotomari
s_1 = mari, s_2 = zzo, s_3 = to, s_4 = mari であるので、これらを連結してできる文字列である marizzotomari を出力します。
入力例 2
abra cad abra 123
出力例 2
abracadabra
入力例 3
a b c 1
出力例 3
a
Score : 200 points
Problem Statement
You are given three strings S_1, S_2, S_3 consisting of lowercase English letters, and a string T consisting of 1, 2, 3.
Concatenate the three strings according to the characters in T and print the resulting string. Formally, conform to the following instructions.
- For each integer i such that 1 \leq i \leq |T|, let the string s_i be defined as follows:
- S_1, if the i-th character of T is
1; - S_2, if the i-th character of T is
2; - S_3, if the i-th character of T is
3.
- S_1, if the i-th character of T is
- Concatenate the strings s_1, s_2, \dots, s_{|T|} in this order and print the resulting string.
Constraints
- 1 \leq |S_1|, |S_2|, |S_3| \leq 10
- 1 \leq |T| \leq 1000
- S_1, S_2, and S_3 consist of lowercase English letters.
- T consists of
1,2, and3.
Input
Input is given from Standard Input in the following format:
S_1 S_2 S_3 T
Output
Print the answer.
Sample Input 1
mari to zzo 1321
Sample Output 1
marizzotomari
We have s_1 = mari, s_2 = zzo, s_3 = to, s_4 = mari. Concatenate these and print the resulting string: marizzotomari.
Sample Input 2
abra cad abra 123
Sample Output 2
abracadabra
Sample Input 3
a b c 1
Sample Output 3
a
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 300 点
問題文
ある地方に、1 から N の番号がついた N 個の街と、1 から M の番号がついた M 本の道路があります。
i 番目の道路は街 A_i と街 B_i を双方向に結び、長さは C_i です。
好きな街からスタートして同じ街を二度以上通らずに別の街へ移動するときの、通る道路の長さの和としてありえる最大値を求めてください。
制約
- 2 \leq N \leq 10
- 1 \leq M \leq \frac{N(N-1)}{2}
- 1\leq A_i < B_i \leq N
- (A_i,B_i) は相異なる
- 1\leq C_i \leq 10^8
- 入力は全て整数である
入力
入力は以下の形式で標準入力から与えられる。
N M A_1 B_1 C_1 \vdots A_M B_M C_M
出力
答えを出力せよ。
入力例 1
4 4 1 2 1 2 3 10 1 3 100 1 4 1000
出力例 1
1110
4\to 1\to 3\to 2 と移動すると、通る道路の長さの和は 1110 となります。
入力例 2
10 1 5 9 1
出力例 2
1
道路と繋がっていない街が存在するかもしれません。
入力例 3
10 13 1 2 1 1 10 1 2 3 1 3 4 4 4 7 2 4 8 1 5 8 1 5 9 3 6 8 1 6 9 5 7 8 1 7 9 4 9 10 3
出力例 3
20

Score : 300 points
Problem Statement
A region has N towns numbered 1 to N, and M roads numbered 1 to M.
The i-th road connects town A_i and town B_i bidirectionally with length C_i.
Find the maximum possible total length of the roads you traverse when starting from a town of your choice and getting to another town without passing through the same town more than once.
Constraints
- 2 \leq N \leq 10
- 1 \leq M \leq \frac{N(N-1)}{2}
- 1 \leq A_i < B_i \leq N
- The pairs (A_i,B_i) are distinct.
- 1\leq C_i \leq 10^8
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N M A_1 B_1 C_1 \vdots A_M B_M C_M
Output
Print the answer.
Sample Input 1
4 4 1 2 1 2 3 10 1 3 100 1 4 1000
Sample Output 1
1110
If you travel as 4\to 1\to 3\to 2, the total length of the roads you traverse is 1110.
Sample Input 2
10 1 5 9 1
Sample Output 2
1
There may be a town that is not connected to a road.
Sample Input 3
10 13 1 2 1 1 10 1 2 3 1 3 4 4 4 7 2 4 8 1 5 8 1 5 9 3 6 8 1 6 9 5 7 8 1 7 9 4 9 10 3
Sample Output 3
20
