Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
英大文字・英小文字からなる空でない文字列 S が与えられます。以下の条件が満たされているか判定してください。
- S の先頭の文字は大文字であり、それ以外の文字はすべて小文字である。
制約
- 1 \leq |S| \leq 100(|S| は文字列 S の長さ)
- S の各文字は英大文字または英小文字である。
入力
入力は以下の形式で標準入力から与えられる。
S
出力
条件が満たされていれば Yes、そうでなければ No を出力せよ。
入力例 1
Capitalized
出力例 1
Yes
Capitalized の先頭の文字 C は大文字であり、それ以外の文字 apitalized はすべて小文字であるため、Yes を出力します。
入力例 2
AtCoder
出力例 2
No
AtCoder は先頭以外にも大文字 C を含むため、No を出力します。
入力例 3
yes
出力例 3
No
yes の先頭の文字 y は大文字でないため、No を出力します。
入力例 4
A
出力例 4
Yes
Score: 100 points
Problem Statement
You are given a non-empty string S consisting of uppercase and lowercase English letters. Determine whether the following condition is satisfied:
- The first character of S is uppercase, and all other characters are lowercase.
Constraints
- 1 \leq |S| \leq 100 (|S| is the length of the string S.)
- Each character of S is an uppercase or lowercase English letter.
Input
The input is given from Standard Input in the following format:
S
Output
If the condition is satisfied, print Yes; otherwise, print No.
Sample Input 1
Capitalized
Sample Output 1
Yes
The first character C of Capitalized is uppercase, and all other characters apitalized are lowercase, so you should print Yes.
Sample Input 2
AtCoder
Sample Output 2
No
AtCoder contains an uppercase letter C that is not at the beginning, so you should print No.
Sample Input 3
yes
Sample Output 3
No
The first character y of yes is not uppercase, so you should print No.
Sample Input 4
A
Sample Output 4
Yes
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
英小文字からなる長さが奇数の文字列 S が与えられます。
S の中央の文字を出力してください。
中央の文字とは
ある長さが奇数の文字列 T について、 T の長さを |T| として、T の前から \frac{|T|+1}{2} 番目の文字を中央の文字とします。制約
- S は英小文字からなる長さが奇数の文字列
- S の長さは 1 以上 99 以下
入力
入力は以下の形式で標準入力から与えられる。
S
出力
答えを出力せよ。
入力例 1
atcoder
出力例 1
o
atcoder の中央の文字は o です。
入力例 2
a
出力例 2
a
Score : 100 points
Problem Statement
You are given an odd-length string S consisting of lowercase English letters.
Print the central character of S.
What is the central character?
For an odd-length string T, its central character is the \frac{|T|+1}{2}-th character from the beginning, where |T| is the length of T.Constraints
- S is an odd-length string consisting of lowercase English letters.
- The length of S is between 1 and 99 (inclusive).
Input
Input is given from Standard Input in the following format:
S
Output
Print the answer.
Sample Input 1
atcoder
Sample Output 1
o
The central character of atcoder is o.
Sample Input 2
a
Sample Output 2
a
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 250 点
問題文
縦 N 行 横 N 列からなる 2 つのグリッド S,T があります。グリッドの上から i 行目、左から j 列目のマスをマス (i,j) と表します。
グリッド S,T の各マスは白または黒のいずれかに塗られています。S_{i,j} が . のとき S のマス (i,j) は白く、S_{i,j} が # のとき S のマス (i,j) は黒く塗られています。T についても同様です。
次の 2 種類の操作を好きな順序で好きな回数行うとき、グリッド S をグリッド T と一致させるために必要な操作回数の最小値を求めてください。
- グリッド S のマスを 1 つ選び、色を変更する
- グリッド S 全体を 90 度右に回転する
制約
- 1\leq N \leq 100
- N は整数
- S_{i,j},T_{i,j} は
.または#
入力
入力は以下の形式で標準入力から与えられる。
N
S_{1,1}S_{1,2}\dots S_{1,N}
\vdots
S_{N,1}S_{N,2}\dots S_{N,N}
T_{1,1}T_{1,2}\dots T_{1,N}
\vdots
T_{N,1}T_{N,2}\dots T_{N,N}
出力
答えを出力せよ。
入力例 1
4 ###. ..#. ..#. ..#. ...# ...# ###. ....
出力例 1
2
下図のようにして 2 回の操作で S を T と一致させることができます。

入力例 2
13 .#..###..##.. #.#.#..#.#.#. #.#.###..#... ###.#..#.#.#. #.#.###..##.. ............. ..#...#....#. .##..#.#..##. #.#..#.#.#.#. ####.#.#.#### ..#..#.#...#. ..#...#....#. ............. ............. .#....#...#.. .#...#.#..#.. ####.#.#.#### .#.#.###..#.# .##....#..##. .#....#...#.. ............. ..##..###.#.# .#.#.#..#.### .#.#..###.#.# .#.#.#..#.#.# ..##..###..#.
出力例 2
5
Score : 250 points
Problem Statement
There are two grids S and T, each with N rows and N columns. Let (i,j) denote the cell at the i-th row from the top and the j-th column from the left.
Each cell of grids S and T is colored either white or black. Cell (i,j) of S is white if S_{i,j} is ., and black if S_{i,j} is #. The same applies to T.
You may perform the following two types of operations any number of times in any order. Find the minimum number of operations required to make grid S identical to grid T.
- Choose one cell of grid S and change its color.
- Rotate the entire grid S 90 degrees clockwise.
Constraints
- 1 \le N \le 100
- N is an integer.
- Each of S_{i,j} and T_{i,j} is
.or#.
Input
The input is given from Standard Input in the following format:
N
S_{1,1}S_{1,2}\dots S_{1,N}
\vdots
S_{N,1}S_{N,2}\dots S_{N,N}
T_{1,1}T_{1,2}\dots T_{1,N}
\vdots
T_{N,1}T_{N,2}\dots T_{N,N}
Output
Output the minimum number of operations required.
Sample Input 1
4 ###. ..#. ..#. ..#. ...# ...# ###. ....
Sample Output 1
2
You can match S to T in two operations as shown below.

Sample Input 2
13 .#..###..##.. #.#.#..#.#.#. #.#.###..#... ###.#..#.#.#. #.#.###..##.. ............. ..#...#....#. .##..#.#..##. #.#..#.#.#.#. ####.#.#.#### ..#..#.#...#. ..#...#....#. ............. ............. .#....#...#.. .#...#.#..#.. ####.#.#.#### .#.#.###..#.# .##....#..##. .#....#...#.. ............. ..##..###.#.# .#.#.#..#.### .#.#..###.#.# .#.#.#..#.#.# ..##..###..#.
Sample Output 2
5
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 150 点
問題文
文字列 T が以下の 3 つの条件をすべてみたすとき、かつそのときに限り、T を 1122 文字列 と呼びます。
- \lvert T \rvert は偶数である。ここで、\lvert T \rvert は T の長さを表す。
- 1\leq i\leq \frac{\lvert T \rvert}{2} をみたす整数 i について、T の (2i-1) 文字目と 2i 文字目は等しい。
- 各文字は T にちょうど 0 個または 2 個現れる。すなわち、T に含まれる文字は T にちょうど 2 回ずつ登場する。
英小文字のみからなる文字列 S が与えられるので、S が 1122 文字列であるならば Yes を、そうでないならば No を出力してください。
制約
- S は英小文字のみからなる長さ 1 以上 100 以下の文字列
入力
入力は以下の形式で標準入力から与えられる。
S
出力
S が 1122 文字列ならば Yes を、そうでないならば No を出力せよ。
入力例 1
aabbcc
出力例 1
Yes
S=aabbcc は 1122 文字列の条件をすべてみたしているため、Yes を出力します。
入力例 2
aab
出力例 2
No
S=aab は長さが奇数であり、 1 つめの条件をみたしていないため、No を出力します。
入力例 3
zzzzzz
出力例 3
No
S=zzzzzz は z が 6 個含まれており、 3 つめの条件をみたしていないため、No を出力します。
Score : 150 points
Problem Statement
A string T is called a 1122 string if and only if it satisfies all of the following three conditions:
- \lvert T \rvert is even. Here, \lvert T \rvert denotes the length of T.
- For each integer i satisfying 1\leq i\leq \frac{|T|}{2}, the (2i-1)-th and 2i-th characters of T are equal.
- Each character appears in T exactly zero or two times. That is, every character contained in T appears exactly twice in T.
Given a string S consisting of lowercase English letters, print Yes if S is a 1122 string, and No otherwise.
Constraints
- S is a string of length between 1 and 100, inclusive, consisting of lowercase English letters.
Input
The input is given from Standard Input in the following format:
S
Output
If S is a 1122 string, print Yes; otherwise, print No.
Sample Input 1
aabbcc
Sample Output 1
Yes
S=aabbcc satisfies all the conditions for a 1122 string, so print Yes.
Sample Input 2
aab
Sample Output 2
No
S=aab has an odd length and does not satisfy the first condition, so print No.
Sample Input 3
zzzzzz
Sample Output 3
No
S=zzzzzz contains six zs and does not satisfy the third condition, so print No.
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 300 点
問題文
1 から N の番号がついた N 人の人がいます。人 i は数 A_i を持っています。
「自分と同じ数を持っている人が自分以外の N-1 人の中に存在しない」という条件を満たす人のうち、持っている数が最大である人の番号を求めてください。
条件を満たす人が存在しない場合、代わりにそのことを報告してください。
制約
- 1 \leq N \leq 3\times 10^5
- 1 \leq A_i \leq 10^9
- 入力は全て整数である
入力
入力は以下の形式で標準入力から与えられる。
N A_1 A_2 \ldots A_N
出力
「自分と同じ数を持っている人が自分以外の N-1 人の中に存在しない」という条件を満たす人が存在しない場合、-1 と出力せよ。
条件を満たす人が存在する場合、そのうち、持っている数が最大である人の番号を出力せよ。
入力例 1
9 2 9 9 7 9 2 4 5 8
出力例 1
9
「自分と同じ数を持っている人が自分以外の N-1 人の中に存在しない」という条件を満たすのは人 4,7,8,9 の 4 人です。
これらの人が持っている数はそれぞれ 7,4,5,8 であり、最大の数を持っているのは人 9 です。
よって答えは 9 となります。
入力例 2
4 1000000000 1000000000 998244353 998244353
出力例 2
-1
条件を満たす人が存在しない場合、-1 を出力してください。
Score : 300 points
Problem Statement
There are N people, labeled 1 to N. Person i has an integer A_i.
Among the people who satisfy the condition "None of the other N-1 people has the same integer as themselves," find the one with the greatest integer, and print that person's label.
If no person satisfies the condition, report that fact instead.
Constraints
- 1 \leq N \leq 3\times 10^5
- 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 A_1 A_2 \ldots A_N
Output
If no person satisfies the condition "None of the other N-1 people has the same integer as themselves," print -1.
Otherwise, among those who satisfy it, print the label of the person whose integer is the largest.
Sample Input 1
9 2 9 9 7 9 2 4 5 8
Sample Output 1
9
Those who satisfy the condition are the persons labeled 4, 7, 8, and 9.
Their integers are 7, 4, 5, and 8, respectively, and the person with the largest integer is the person labeled 9.
Thus, the answer is 9.
Sample Input 2
4 1000000000 1000000000 998244353 998244353
Sample Output 2
-1
If no person satisfies the condition, print -1.