Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 150 点
問題文
(1,2,3,4,5) を並び替えた整数列 A=(A_1,A_2,A_3,A_4,A_5) が与えられます。
A の隣り合う 2 つの項を入れ替える操作を ちょうど 1 回 行うことで A を昇順にすることができるか判定してください。
制約
- A は (1,2,3,4,5) を並び替えてできる長さ 5 の整数列
入力
入力は以下の形式で標準入力から与えられる。
A_1 A_2 A_3 A_4 A_5
出力
ちょうど 1 回の操作で A を昇順にすることができるならば Yes を、できないならば No を出力せよ。
入力例 1
1 2 4 3 5
出力例 1
Yes
A_3 と A_4 を入れ替えることで A=(1,2,3,4,5) となり、 A を昇順に並び替えることができます。したがって、 Yes を出力してください。
入力例 2
5 3 2 4 1
出力例 2
No
どのような操作をしても A を昇順に並び替えることはできません。
入力例 3
1 2 3 4 5
出力例 3
No
ちょうど 1 回操作をする必要があります。
入力例 4
2 1 3 4 5
出力例 4
Yes
Score : 150 points
Problem Statement
You are given an integer sequence A=(A_1,A_2,A_3,A_4,A_5) obtained by permuting (1,2,3,4,5).
Determine whether A can be sorted in ascending order by performing exactly one operation of swapping two adjacent elements in A.
Constraints
- A is an integer sequence of length 5 obtained by permuting (1,2,3,4,5).
Input
The input is given from Standard Input in the following format:
A_1 A_2 A_3 A_4 A_5
Output
If A can be sorted in ascending order by exactly one operation, print Yes; otherwise, print No.
Sample Input 1
1 2 4 3 5
Sample Output 1
Yes
By swapping A_3 and A_4, A becomes (1,2,3,4,5), so it can be sorted in ascending order. Therefore, print Yes.
Sample Input 2
5 3 2 4 1
Sample Output 2
No
No matter what operation is performed, it is impossible to sort A in ascending order.
Sample Input 3
1 2 3 4 5
Sample Output 3
No
You must perform exactly one operation.
Sample Input 4
2 1 3 4 5
Sample Output 4
Yes
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
整数 A,B が与えられるので、 A+B の値を答えてください。
但し、この問題は N 択問題であり、 i 番の選択肢は C_i です。
正解となる 選択肢の番号 を出力してください。
制約
- 入力は全て整数
- 1 \le N \le 300
- 1 \le A,B \le 1000
- 1 \le C_i \le 2000
- C_i は相異なる。すなわち、同じ選択肢が複数存在することはない。
- A+B=C_i なる i が丁度 1 つ存在する。すなわち、正解となる選択肢が必ずただ 1 つ存在する。
入力
入力は以下の形式で標準入力から与えられる。
N A B C_1 C_2 \dots C_N
出力
答えを整数として出力せよ。
入力例 1
3 125 175 200 300 400
出力例 1
2
125+175 = 300 です。
1 番の選択肢は 200 、 2 番の選択肢は 300 、 3 番の選択肢は 400 です。
よって正解となる選択肢の番号は 2 番であり、これを出力します。
入力例 2
1 1 1 2
出力例 2
1
1 択問題である場合もあります。
入力例 3
5 123 456 135 246 357 468 579
出力例 3
5
Score : 100 points
Problem Statement
Given integers A and B, find A+B.
This is a N-choice problem; the i-th choice is C_i.
Print the index of the correct choice.
Constraints
- All values in the input are integers.
- 1 \le N \le 300
- 1 \le A,B \le 1000
- 1 \le C_i \le 2000
- C_i are pairwise distinct. In other words, no two choices have the same value.
- There is exactly one i such that A+B=C_i. In other words, there is always a unique correct choice.
Input
The input is given from Standard Input in the following format:
N A B C_1 C_2 \dots C_N
Output
Print the answer as an integer.
Sample Input 1
3 125 175 200 300 400
Sample Output 1
2
We have 125+175 = 300.
The first, second, and third choices are 200, 300, and 400, respectively.
Thus, the 2-nd choice is correct, so 2 should be printed.
Sample Input 2
1 1 1 2
Sample Output 2
1
The problem may be a one-choice problem.
Sample Input 3
5 123 456 135 246 357 468 579
Sample Output 3
5
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
1 から N までの番号がついた N 人の参加者が、1 から M までの番号がついた M 問からなるコンテストに参加します。
1 以上 N 以下の整数 i 、1 以上 M 以下の整数 j について、S_i の j 番目の文字が o のとき参加者 i は問題 j を解くことが可能で、S_i の j 番目の文字が x のとき参加者 i は問題 j を解くことが不可能です。
このコンテストは、二人の参加者でペアを組んで参加します。二人が協力することで M 問全てを解くことが可能であるようなペアの個数を答えてください。
より厳密には、1\leq x < y\leq N を満たす整数の組 (x,y) であって、 1 以上 M 以下の任意の整数 j について、参加者 x か参加者 y の少なくとも一方は問題 j を解くことが可能であるという条件を満たすものの個数を答えてください。
制約
- N は 2 以上 30 以下の整数
- M は 1 以上 30 以下の整数
- S_i は
o,xからなる長さ M の文字列
入力
入力は以下の形式で標準入力から与えられる。
N M S_1 S_2 \vdots S_N
出力
答えを出力せよ。
入力例 1
5 5 ooooo oooxx xxooo oxoxo xxxxx
出力例 1
5
参加者 1 と 2 のペア、参加者 1 と 3 のペア、参加者 1 と 4 のペア、参加者 1 と 5 のペア、参加者 2 と 3 のペアの 5 個のペアが条件を満たします。
例えば参加者 2 と 4 のペアは、問題 4 が解けないので条件を満たしません。
入力例 2
3 2 ox xo xx
出力例 2
1
入力例 3
2 4 xxxx oxox
出力例 3
0
Score : 200 points
Problem Statement
N participants, numbered 1 to N, will participate in a contest with M problems, numbered 1 to M.
For an integer i between 1 and N and an integer j between 1 and M, participant i can solve problem j if the j-th character of S_i is o, and cannot solve it if that character is x.
The participants must be in pairs. Print the number of ways to form a pair of participants who can collectively solve all the M problems.
More formally, print the number of pairs (x,y) of integers satisfying 1\leq x < y\leq N such that for any integer j between 1 and M, at least one of participant x and participant y can solve problem j.
Constraints
- N is an integer between 2 and 30, inclusive.
- M is an integer between 1 and 30, inclusive.
- S_i is a string of length M consisting of
oandx.
Input
The input is given from Standard Input in the following format:
N M S_1 S_2 \vdots S_N
Output
Print the answer.
Sample Input 1
5 5 ooooo oooxx xxooo oxoxo xxxxx
Sample Output 1
5
The following five pairs satisfy the condition: participants 1 and 2, participants 1 and 3, participants 1 and 4, participants 1 and 5, and participants 2 and 3.
On the other hand, the pair of participants 2 and 4, for instance, does not satisfy the condition because they cannot solve problem 4.
Sample Input 2
3 2 ox xo xx
Sample Output 2
1
Sample Input 3
2 4 xxxx oxox
Sample Output 3
0
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
長さ N の整数列 A=(A_1,A_2,\ldots,A_N) 及び整数 L,R が与えられます。ここで L,R は L\leq R を満たします。
i=1,2,\ldots,N について以下の 2 つの条件を共に満たす整数 X_i を求めてください。なお、求める整数は常に一意に定まります。
- L\leq X_i \leq R
- L 以上 R 以下であるようなどの整数 Y についても |X_i - A_i| \leq |Y-A_i| を満たす
制約
- 1\leq N\leq 2\times 10^5
- 1\leq L\leq R \leq 10^9
- 1\leq A_i\leq 10^9
- 入力は全て整数
入力
入力は以下の形式で標準入力から与えられる。
N L R A_1 \ldots A_N
出力
i=1,2,\ldots,N について X_i を空白区切りで出力せよ。
入力例 1
5 4 7 3 1 4 9 7
出力例 1
4 4 4 7 7
i=1 では、
- |4-3|=1
- |5-3|=2
- |6-3|=3
- |7-3|=4
より X_i = 4 です。
入力例 2
3 10 10 11 10 9
出力例 2
10 10 10
Score : 200 points
Problem Statement
You are given an integer sequence A=(A_1,A_2,\ldots,A_N) of length N and integers L and R such that L\leq R.
For each i=1,2,\ldots,N, find the integer X_i that satisfies both of the following conditions. Note that the integer to be found is always uniquely determined.
- L\leq X_i \leq R.
- For every integer Y such that L \leq Y \leq R, it holds that |X_i - A_i| \leq |Y - A_i|.
Constraints
- 1\leq N\leq 2\times 10^5
- 1\leq L\leq R \leq 10^9
- 1\leq A_i\leq 10^9
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N L R A_1 \ldots A_N
Output
Print X_i for i=1,2,\ldots,N, separated by spaces.
Sample Input 1
5 4 7 3 1 4 9 7
Sample Output 1
4 4 4 7 7
For i=1:
- |4-3|=1
- |5-3|=2
- |6-3|=3
- |7-3|=4
Thus, X_i = 4.
Sample Input 2
3 10 10 11 10 9
Sample Output 2
10 10 10
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 250 点
問題文
N 人のプレイヤーが参加するプログラミングコンテスト World Tour Finals が行われており、競技時間の半分が過ぎました。 このコンテストでは M 問の問題が出題されており、問題 i の点数 A_i は 500 以上 2500 以下の 100 の倍数です。
各 i = 1, \ldots, N について、プレイヤー i がどの問題を既に解いたかを表す文字列 S_i が与えられます。
S_i は o, x からなる長さ M の文字列で、S_i の j 文字目が o のときプレイヤー i は問題 j を既に解いており、x のときまだ解いていません。
ただし、どのプレイヤーもまだ全ての問題を解いてはいません。
プレイヤー i の総合得点は、解いた問題の点数の合計に、ボーナス点 i 点を加えた点数として計算されます。
さて、各 i = 1, \ldots, N について以下の質問に答えてください。
- プレイヤー i がまだ解いていない問題を少なくとも何問解くことで、プレイヤー i の総合得点が他のプレイヤー全員の現在の総合得点を上回ることができますか?
なお、問題文中の条件と制約から、プレイヤー i が全ての問題を解くことで、他のプレイヤー全員の現在の総合得点を上回ることができることが証明できます。 このことから、答えは常に定義されることに注意してください。
制約
- 2\leq N\leq 100
- 1\leq M\leq 100
- 500\leq A_i\leq 2500
- A_i は 100 の倍数
- S_i は
o,xからなる長さ M の文字列 - S_i には
xが一個以上含まれる - 入力される数値は全て整数
入力
入力は以下の形式で標準入力から与えられる。
N M A_1 A_2 \ldots A_M S_1 S_2 \vdots S_N
出力
N 行出力せよ。 i 行目にはプレイヤー i に関する質問の答えを出力せよ。
入力例 1
3 4 1000 500 700 2000 xxxo ooxx oxox
出力例 1
0 1 1
競技時間の半分の経過時の各プレイヤーの総合得点は、プレイヤー 1 が 2001 点、プレイヤー 2 が 1502 点、プレイヤー 3 が 1703 点です。
プレイヤー 1 は 1 問も解かずとも、他のプレイヤー全員の総合得点を上回っています。
プレイヤー 2 は、例えば問題 4 を解けば総合得点が 3502 点となり、他のプレイヤー全員の総合得点を上回ります。
プレイヤー 3 も、例えば問題 4 を解けば総合得点が 3703 点となり、他のプレイヤー全員の総合得点を上回ります。
入力例 2
5 5 1000 1500 2000 2000 2500 xxxxx oxxxx xxxxx oxxxx oxxxx
出力例 2
1 1 1 1 0
入力例 3
7 8 500 500 500 500 500 500 500 500 xxxxxxxx oxxxxxxx ooxxxxxx oooxxxxx ooooxxxx oooooxxx ooooooxx
出力例 3
7 6 5 4 3 2 0
Score : 250 points
Problem Statement
The programming contest World Tour Finals is underway, where N players are participating, and half of the competition time has passed. There are M problems in this contest, and the score A_i of problem i is a multiple of 100 between 500 and 2500, inclusive.
For each i = 1, \ldots, N, you are given a string S_i that indicates which problems player i has already solved.
S_i is a string of length M consisting of o and x, where the j-th character of S_i is o if player i has already solved problem j, and x if they have not yet solved it.
Here, none of the players have solved all the problems yet.
The total score of player i is calculated as the sum of the scores of the problems they have solved, plus a bonus score of i points.
For each i = 1, \ldots, N, answer the following question.
- At least how many of the problems that player i has not yet solved must player i solve to exceed all other players' current total scores?
Note that under the conditions in this statement and the constraints, it can be proved that player i can exceed all other players' current total scores by solving all the problems, so the answer is always defined.
Constraints
- 2\leq N\leq 100
- 1\leq M\leq 100
- 500\leq A_i\leq 2500
- A_i is a multiple of 100.
- S_i is a string of length M consisting of
oandx. - S_i contains at least one
x. - All numeric values in the input are integers.
Input
The input is given from Standard Input in the following format:
N M A_1 A_2 \ldots A_M S_1 S_2 \vdots S_N
Output
Print N lines. The i-th line should contain the answer to the question for player i.
Sample Input 1
3 4 1000 500 700 2000 xxxo ooxx oxox
Sample Output 1
0 1 1
The players' total scores at the halfway point of the competition time are 2001 points for player 1, 1502 points for player 2, and 1703 points for player 3.
Player 1 is already ahead of all other players' total scores without solving any more problems.
Player 2 can, for example, solve problem 4 to have a total score of 3502 points, which would exceed all other players' total scores.
Player 3 can also, for example, solve problem 4 to have a total score of 3703 points, which would exceed all other players' total scores.
Sample Input 2
5 5 1000 1500 2000 2000 2500 xxxxx oxxxx xxxxx oxxxx oxxxx
Sample Output 2
1 1 1 1 0
Sample Input 3
7 8 500 500 500 500 500 500 500 500 xxxxxxxx oxxxxxxx ooxxxxxx oooxxxxx ooooxxxx oooooxxx ooooooxx
Sample Output 3
7 6 5 4 3 2 0