Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 100 点
問題文
数直線上に家 1,2,3 があり、それぞれのある座標は A,B,C です。
家 1 から家 2 まで寄り道をせずにまっすぐ向かう途中で家 3 のある座標を通る場合は Yes
を、そうでない場合は No
を出力してください。
制約
- 0\leq A,B,C\leq 100
- A,B,C は相異なる整数である
入力
入力は以下の形式で標準入力から与えられる。
A B C
出力
家 1 から家 2 まで寄り道をせずにまっすぐ向かう途中で家 3 のある座標を通る場合は Yes
を、そうでない場合は No
を出力せよ。
入力例 1
3 8 5
出力例 1
Yes
座標 3 にある家から座標 8 にある家までまっすぐ向かう途中には、座標 5 を通ります。
入力例 2
7 3 1
出力例 2
No
入力例 3
10 2 4
出力例 3
Yes
入力例 4
31 41 59
出力例 4
No
Score : 100 points
Problem Statement
There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively.
Print Yes
if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print No
otherwise.
Constraints
- 0\leq A,B,C\leq 100
- A, B and C are distinct integers.
Input
Input is given from Standard Input in the following format:
A B C
Output
Print Yes
if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print No
otherwise.
Sample Input 1
3 8 5
Sample Output 1
Yes
We pass the coordinate 5 on the straight way from the house at coordinate 3 to the house at coordinate 8.
Sample Input 2
7 3 1
Sample Output 2
No
Sample Input 3
10 2 4
Sample Output 3
Yes
Sample Input 4
31 41 59
Sample Output 4
No
Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 200 点
問題文
英小文字からなる長さ N の文字列 S と整数 K が与えられます。
S の K 番目の文字と異なる文字全てを *
で置き換えてできる文字列を出力してください。
制約
- 1 \leq K \leq N\leq 10
- S は英小文字からなる長さ N の文字列である
- N,K は整数である
入力
入力は以下の形式で標準入力から与えられる。
N S K
出力
S の K 番目の文字と異なる文字全てを *
で置き換えてできる文字列を出力せよ。
入力例 1
5 error 2
出力例 1
*rr*r
S の 2 番目の文字は r
であり、error
の r
と異なる文字をすべて *
で置き換えると文字列 *rr*r
になります。
入力例 2
6 eleven 5
出力例 2
e*e*e*
入力例 3
9 education 7
出力例 3
******i**
Score : 200 points
Problem Statement
You are given a string S of length N consisting of lowercase English letters, and an integer K.
Print the string obtained by replacing every character in S that differs from the K-th character of S, with *
.
Constraints
- 1 \leq K \leq N\leq 10
- S is a string of length N consisting of lowercase English letters.
- N and K are integers.
Input
Input is given from Standard Input in the following format:
N S K
Output
Print the string obtained by replacing every character in S that differs from the K-th character of S, with *
.
Sample Input 1
5 error 2
Sample Output 1
*rr*r
The second character of S is r
. When we replace every character in error
that differs from r
with *
, we get the string *rr*r
.
Sample Input 2
6 eleven 5
Sample Output 2
e*e*e*
Sample Input 3
9 education 7
Sample Output 3
******i**
Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 300 点
問題文
N 個の石が一列に並んでおり、すべての石は白か黒で塗られています。
石の状態は長さ N の文字列 S で表され、S の i 文字目が .
のとき左から i 個目の石が白であり、#
のとき左から i 個目の石が黒であることを表します。
高橋君は、0 個以上の石の色を黒または白に変更し、黒い石のすぐ右に白い石があるような箇所がないようにしたいです。 色を変更する必要のある石の個数の最小値を求めてください。
制約
- 1 \leq N \leq 2\times 10^5
- S は
.
,#
のみからなる長さ N の文字列である
入力
入力は以下の形式で標準入力から与えられる。
N S
出力
色を変更する必要のある石の個数の最小値を出力せよ。
入力例 1
3 #.#
出力例 1
1
例えば、1 個目の石の色を白に変更すればよいです。
入力例 2
5 #.##.
出力例 2
2
入力例 3
9 .........
出力例 3
0
Score : 300 points
Problem Statement
There are N stones arranged in a row. Every stone is painted white or black.
A string S represents the color of the stones. The i-th stone from the left is white if the i-th character of S is .
, and the stone is black if the character is #
.
Takahashi wants to change the colors of some stones to black or white so that there will be no white stone immediately to the right of a black stone. Find the minimum number of stones that needs to be recolored.
Constraints
- 1 \leq N \leq 2\times 10^5
- S is a string of length N consisting of
.
and#
.
Input
Input is given from Standard Input in the following format:
N S
Output
Print the minimum number of stones that needs to be recolored.
Sample Input 1
3 #.#
Sample Output 1
1
It is enough to change the color of the first stone to white.
Sample Input 2
5 #.##.
Sample Output 2
2
Sample Input 3
9 .........
Sample Output 3
0
Time Limit: 3 sec / Memory Limit: 1024 MB
配点 : 600 点
問題文
N 個の整数が与えられます。i 個目の整数は a_i です。 与えられたすべての整数を赤、緑、青の 3 色のいずれかで塗り、以下の条件を満たすようにする方法の個数を 998244353 で割ったあまりを求めてください。
- 赤、緑、青で塗られた整数の総和をそれぞれ R,G,B とする。三辺の長さがそれぞれ R,G,B であるような正の面積の三角形が存在する。
制約
- 3 \leq N \leq 300
- 1 \leq a_i \leq 300(1\leq i\leq N)
- 入力はすべて整数である
入力
入力は以下の形式で標準入力から与えられる。
N a_1 : a_N
出力
与えられたすべての整数を赤、緑、青の 3 色のいずれかで塗り、条件を満たすようにする方法の個数を 998244353 で割ったあまりを出力せよ。
入力例 1
4 1 1 1 2
出力例 1
18
三角形の三辺の長さがそれぞれ 1,2,2 となるように整数を塗り分けるしかなく、そのような塗り分け方は 18 通り存在します。
入力例 2
6 1 3 2 3 5 2
出力例 2
150
入力例 3
20 3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4
出力例 3
563038556
Score : 600 points
Problem Statement
You are given N integers. The i-th integer is a_i. Find the number, modulo 998244353, of ways to paint each of the integers red, green or blue so that the following condition is satisfied:
- Let R, G and B be the sums of the integers painted red, green and blue, respectively. There exists a triangle with positive area whose sides have lengths R, G and B.
Constraints
- 3 \leq N \leq 300
- 1 \leq a_i \leq 300(1\leq i\leq N)
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
N a_1 : a_N
Output
Print the number, modulo 998244353, of ways to paint each of the integers red, green or blue so that the condition is satisfied.
Sample Input 1
4 1 1 1 2
Sample Output 1
18
We can only paint the integers so that the lengths of the sides of the triangle will be 1, 2 and 2, and there are 18 such ways.
Sample Input 2
6 1 3 2 3 5 2
Sample Output 2
150
Sample Input 3
20 3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4
Sample Output 3
563038556