Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
英小文字からなる文字列 S,T が与えられるので、 T が S の(連続する)部分文字列かどうか判定してください。
なお、文字列 X に以下の操作を 0 回以上施して文字列 Y が得られる時、またその時に限り Y は X の(連続する)部分文字列であると言います。
- 以下の 2 つの操作から 1 つを選択して、その操作を行う。
- X の先頭の 1 文字を削除する。
- X の末尾の 1 文字を削除する。
例えば tag
は voltage
の(連続する)部分文字列ですが、 ace
は atcoder
の(連続する)部分文字列ではありません。
制約
- S,T は英小文字からなる
- 1 \le |S|,|T| \le 100 ( |X| は文字列 X の長さ )
入力
入力は以下の形式で標準入力から与えられる。
S T
出力
T が S の(連続する)部分文字列なら Yes
、そうでないなら No
と出力せよ。
入力例 1
voltage tag
出力例 1
Yes
tag
は voltage
の(連続する)部分文字列です。
入力例 2
atcoder ace
出力例 2
No
ace
は atcoder
の(連続する)部分文字列ではありません。
入力例 3
gorilla gorillagorillagorilla
出力例 3
No
入力例 4
toyotasystems toyotasystems
出力例 4
Yes
S=T である場合もあります。
Score : 200 points
Problem Statement
You are given strings S and T consisting of lowercase English letters. Determine whether T is a (contiguous) substring of S.
A string Y is said to be a (contiguous) substring of X if and only if Y can be obtained by performing the operation below on X zero or more times.
- Do one of the following.
- Delete the first character in X.
- Delete the last character in X.
For instance, tag
is a (contiguous) substring of voltage
, while ace
is not a (contiguous) substring of atcoder
.
Constraints
- S and T consist of lowercase English letters.
- 1 \le |S|,|T| \le 100 (|X| denotes the length of a string X.)
Input
The input is given from Standard Input in the following format:
S T
Output
If T is a (contiguous) substring of S, print Yes
; otherwise, print No
.
Sample Input 1
voltage tag
Sample Output 1
Yes
tag
is a (contiguous) substring of voltage
.
Sample Input 2
atcoder ace
Sample Output 2
No
ace
is not a (contiguous) substring of atcoder
.
Sample Input 3
gorilla gorillagorillagorilla
Sample Output 3
No
Sample Input 4
toyotasystems toyotasystems
Sample Output 4
Yes
It is possible that S=T.
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
整数 A,B が K 進法表記で与えられます。
A \times B を 10 進法表記で出力してください。
注記
K 進法表記については、Wikipedia「位取り記数法」 を参照してください。
制約
- 2 \leq K \leq 10
- 1 \leq A,B \leq 10^5
- A,B は K 進法表記で与えられる
入力
入力は以下の形式で標準入力から与えられる。
K A B
出力
答えを出力せよ。
入力例 1
2 1011 10100
出力例 1
220
2 進法表記の 1011
を 、10 進法表記すると 11 です。
2 進法表記の 10100
を、 10 進法表記すると 20 です。
11 \times 20 = 220 なので 220 を出力します。
入力例 2
7 123 456
出力例 2
15642
7 進法表記の 123
を 、10 進法表記すると 66 です。
7 進法表記の 456
を、 10 進法表記すると 237 です。
66 \times 237 = 15642 なので 15642 を出力します。
Score : 200 points
Problem Statement
You are given integers A and B, in base K.
Print A \times B in decimal.
Notes
For base-K representation, see Wikipedia's article on Positional notation.
Constraints
- 2 \leq K \leq 10
- 1 \leq A,B \leq 10^5
- A and B are in base-K representation.
Input
Input is given from Standard Input in the following format:
K A B
Output
Print the answer.
Sample Input 1
2 1011 10100
Sample Output 1
220
1011
in base 2 corresponds to 11 in base 10.
10100
in base 2 corresponds to 20 in base 10.
We have 11 \times 20 = 220, so print 220.
Sample Input 2
7 123 456
Sample Output 2
15642
123
in base 7 corresponds to 66 in base 10.
456
in base 7 corresponds to 237 in base 10.
We have 66 \times 237 = 15642, so print 15642.
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 300 点
問題文
10 進法で表記したときに 0,2 のみからなる正整数のうち、 K 番目に小さいものを求めてください。
制約
- K は 1 以上 10^{18} 以下の整数
入力
入力は以下の形式で標準入力から与えられる。
K
出力
答えを整数として出力せよ。
ただし、たとえ答えが大きな整数であっても、求める答えを正確に整数として出力する必要がある。たとえば、 2.34e+22
のような指数表記や、 0523
のような先頭に不要な 0 を付けたような表記は許されない。
入力例 1
3
出力例 1
22
10 進法で表記した時に 0,2 のみからなる正整数を小さい方から並べると、 2,20,22,\dots となります。
このうち K=3 番目である 22 を出力してください。
入力例 2
11
出力例 2
2022
入力例 3
923423423420220108
出力例 3
220022020000202020002022022000002020002222002200002022002200
たとえ答えが大きな整数であっても、求める答えを正確に整数として出力する必要があることに注意してください。
Score : 300 points
Problem Statement
Among the positive integers that consist of 0's and 2's when written in base 10, find the K-th smallest integer.
Constraints
- K is an integer between 1 and 10^{18} (inclusive).
Input
Input is given from Standard Input in the following format:
K
Output
Print the answer as an integer.
Here, the exact value must be printed as an integer, even if it is big. Exponential notations such as 2.34e+22
, for example, or unnecessary leading zeros such as 0523
are not allowed.
Sample Input 1
3
Sample Output 1
22
The positive integers that consist of 0's and 2's when written in base 10 are 2,20,22,\dots in ascending order.
The (K=) 3-rd of them, which is 22, should be printed.
Sample Input 2
11
Sample Output 2
2022
Sample Input 3
923423423420220108
Sample Output 3
220022020000202020002022022000002020002222002200002022002200
Note that the exact value of the answer must be printed as an integer, even if it is big.
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 300 点
問題文
英小文字、,
、"
からなる長さ N の文字列 S が与えられます。S に含まれる "
の個数は偶数であることが保証されています。
S に含まれる "
の個数を 2K 個とすると、各 i=1,2,\ldots,K について 2i-1 番目の "
から 2i 番目の "
までの文字のことを 括られた文字 と呼びます。
あなたの仕事は、 S に含まれる ,
のうち、括られた文字 でないもの を .
で置き換えて得られる文字列を答えることです。
制約
- N は 1 以上 2\times 10^5 以下の整数
- S は英小文字、
,
、"
からなる長さ N の文字列 - S に含まれる
"
の個数は偶数
入力
入力は以下の形式で標準入力から与えられる。
N S
出力
答えを出力せよ。
入力例 1
8 "a,b"c,d
出力例 1
"a,b"c.d
S のうち "a,b"
が括られた文字であり、c,d
は括られた文字ではありません。
S に含まれる ,
のうち、括られた文字でないのは S の左から 7 番目の文字なので、7 番目の文字を .
で置き換えたものが答えとなります。
入力例 2
5 ,,,,,
出力例 2
.....
入力例 3
20 a,"t,"c,"o,"d,"e,"r,
出力例 3
a."t,"c."o,"d."e,"r.
Score : 300 points
Problem Statement
You are given a string S of length N consisting of lowercase English letters, ,
, and "
. It is guaranteed that S contains an even number of "
.
Let 2K be the number of "
in S. For each i=1,2,\ldots,K, the characters from the (2i-1)-th "
through the (2i)-th "
are said to be enclosed.
Your task is to replace each ,
in S that is not an enclosed character with .
and print the resulting string.
Constraints
- N is an integer between 1 and 2\times 10^5, inclusive.
- S is a string of length N consisting of lowercase English letters,
,
, and"
. - S contains an even number of
"
.
Input
The input is given from Standard Input in the following format:
N S
Output
Print the answer.
Sample Input 1
8 "a,b"c,d
Sample Output 1
"a,b"c.d
In S, "a,b"
are enclosed characters, and c,d
are not.
The ,
in S that is not an enclosed character is the seventh character from the left in S, so replace that character with .
to get the answer.
Sample Input 2
5 ,,,,,
Sample Output 2
.....
Sample Input 3
20 a,"t,"c,"o,"d,"e,"r,
Sample Output 3
a."t,"c."o,"d."e,"r.
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 400 点
問題文
英大文字および英小文字からなる長さ N の文字列 S が与えられます。
これから、文字列 S に対して Q 回の操作を行います。 i 番目 (1\leq i\leq Q) の操作は整数 2 つと文字 1 つからなる組 (t _ i,x _ i,c _ i) で表され、それぞれ次のような操作を表します。
- t _ i=1 のとき、S の x _ i 文字目を c _ i に変更する。
- t _ i=2 のとき、S に含まれる大文字すべてをそれぞれ小文字に変更する(x _ i,c _ i は操作に使用しない)。
- t _ i=3 のとき、S に含まれる小文字すべてをそれぞれ大文字に変更する(x _ i,c _ i は操作に使用しない)。
Q 回の操作がすべて終わったあとの S を出力してください。
制約
- 1\leq N\leq5\times10^5
- S は英大文字および英小文字からなる長さ N の文字列
- 1\leq Q\leq5\times10^5
- 1\leq t _ i\leq3\ (1\leq i\leq Q)
- t _ i=1 ならば 1\leq x _ i\leq N\ (1\leq i\leq Q)
- c _ i は英大文字もしくは英小文字
- t _ i\neq 1 ならば x _ i=0 かつ c _ i=
'a'
- N,Q,t _ i,x _ i はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
N S Q t _ 1 x _ 1 c _ 1 t _ 2 x _ 2 c _ 2 \vdots t _ Q x _ Q c _ Q
出力
答えを 1 行で出力せよ。
入力例 1
7 AtCoder 5 1 4 i 3 0 a 1 5 b 2 0 a 1 4 Y
出力例 1
atcYber
はじめ、文字列 S は AtCoder
です。
- 1 番目の操作では、4 文字目を
i
に変更します。変更後の S はAtCider
です。 - 2 番目の操作では、すべての小文字を大文字に変更します。変更後の S は
ATCIDER
です。 - 3 番目の操作では、5 文字目を
b
に変更します。変更後の S はATCIbER
です。 - 4 番目の操作では、すべての大文字を小文字に変更します。変更後の S は
atciber
です。 - 5 番目の操作では、4 文字目を
Y
に変更します。変更後の S はatcYber
です。
すべての操作が終わったあとの S は atcYber
なので、atcYber
と出力してください。
入力例 2
35 TheQuickBrownFoxJumpsOverTheLazyDog 10 2 0 a 1 19 G 1 13 m 1 2 E 1 21 F 2 0 a 1 27 b 3 0 a 3 0 a 1 15 i
出力例 2
TEEQUICKBROWMFiXJUGPFOVERTBELAZYDOG
Score : 400 points
Problem Statement
You are given a string S of length N consisting of uppercase and lowercase English letters.
Let us perform Q operations on the string S. The i-th operation (1\leq i\leq Q) is represented by a tuple (t _ i,x _ i,c _ i) of two integers and one character, as follows.
- If t _ i=1, change the x _ i-th character of S to c _ i.
- If t _ i=2, convert all uppercase letters in S to lowercase (do not use x _ i,c _ i for this operation).
- If t _ i=3, convert all lowercase letters in S to uppercase (do not use x _ i,c _ i for this operation).
Print the S after the Q operations.
Constraints
- 1\leq N\leq5\times10^5
- S is a string of length N consisting of uppercase and lowercase English letters.
- 1\leq Q\leq5\times10^5
- 1\leq t _ i\leq3\ (1\leq i\leq Q)
- If t _ i=1, then 1\leq x _ i\leq N\ (1\leq i\leq Q).
- c _ i is an uppercase or lowercase English letter.
- If t _ i\neq 1, then x _ i=0 and c _ i=
'a'
. - N,Q,t _ i,x _ i are all integers.
Input
The input is given from Standard Input in the following format:
N S Q t _ 1 x _ 1 c _ 1 t _ 2 x _ 2 c _ 2 \vdots t _ Q x _ Q c _ Q
Output
Print the answer in a single line.
Sample Input 1
7 AtCoder 5 1 4 i 3 0 a 1 5 b 2 0 a 1 4 Y
Sample Output 1
atcYber
Initially, the string S is AtCoder
.
- The first operation changes the 4-th character to
i
, changing S toAtCider
. - The second operation converts all lowercase letters to uppercase, changing S to
ATCIDER
. - The third operation changes the 5-th character to
b
, changing S toATCIbER
. - The fourth operation converts all uppercase letters to lowercase, changing S to
atciber
. - The fifth operation changes the 4-th character to
Y
, changing S toatcYber
.
After the operations, the string S is atcYber
, so print atcYber
.
Sample Input 2
35 TheQuickBrownFoxJumpsOverTheLazyDog 10 2 0 a 1 19 G 1 13 m 1 2 E 1 21 F 2 0 a 1 27 b 3 0 a 3 0 a 1 15 i
Sample Output 2
TEEQUICKBROWMFiXJUGPFOVERTBELAZYDOG