output_description stringlengths 15 956 | submission_id stringlengths 10 10 | status stringclasses 3 values | problem_id stringlengths 6 6 | input_description stringlengths 9 2.55k | attempt stringlengths 1 13.7k | problem_description stringlengths 7 5.24k | samples stringlengths 2 2.72k |
|---|---|---|---|---|---|---|---|
Print `Yes` if S is easily playable, and `No` otherwise.
* * * | s929381402 | Accepted | p02910 | Input is given from Standard Input in the following format:
S | print("YNeos"[any(c == "RL"[~i % 2] for i, c in enumerate(input())) :: 2])
| Statement
Takahashi will do a tap dance. The dance is described by a string S where each
character is `L`, `R`, `U`, or `D`. These characters indicate the positions on
which Takahashi should step. He will follow these instructions one by one in
order, starting with the first character.
S is said to be _easily playable_ if and only if it satisfies both of the
following conditions:
* Every character in an odd position (1-st, 3-rd, 5-th, \ldots) is `R`, `U`, or `D`.
* Every character in an even position (2-nd, 4-th, 6-th, \ldots) is `L`, `U`, or `D`.
Your task is to print `Yes` if S is easily playable, and `No` otherwise. | [{"input": "RUDLUDR", "output": "Yes\n \n\nEvery character in an odd position (1-st, 3-rd, 5-th, 7-th) is `R`, `U`, or\n`D`.\n\nEvery character in an even position (2-nd, 4-th, 6-th) is `L`, `U`, or `D`.\n\nThus, S is easily playable.\n\n* * *"}, {"input": "DULL", "output": "No\n \n\nThe 3-rd character is not `R`, `U`, nor `D`, so S is not easily playable.\n\n* * *"}, {"input": "UUUUUUUUUUUUUUU", "output": "Yes\n \n\n* * *"}, {"input": "ULURU", "output": "No\n \n\n* * *"}, {"input": "RDULULDURURLRDULRLR", "output": "Yes"}] |
If S and T can be made equal, print `Yes`; otherwise, print `No`.
* * * | s450120792 | Accepted | p03252 | Input is given from Standard Input in the following format:
S
T | # abc110_c.py
# https://atcoder.jp/contests/abc110/tasks/abc110_c
# C - String Transformation /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 300点
# 問題文
# 英小文字のみからなる文字列 S, Tが与えられます。
# 文字列 Sに対して、次の操作を何度でも行うことができます。
# 操作: 2つの異なる英小文字 c1, c2 を選び、S に含まれる全ての c1 を c2 に、c2 を c1に置き換える
# 0回以上操作を行って、S を Tに一致させられるか判定してください。
# 制約
# 1≤|S|≤2×10^5
# |S|=|T|
# S, Tは英小文字のみからなる
# 入力
# 入力は以下の形式で標準入力から与えられる。
# S
# T
# 出力
# Sを Tに一致させられる場合は Yes、そうでない場合は No を出力せよ。
# 入力例 1
# azzel
# apple
# 出力例 1
# Yes
# 次のように操作を行えば、azzel を apple にできます。
# c1として e を、c2として l を選ぶと、azzel が azzle になる
# c1として z を、c2として p を選ぶと、azzle が apple になる
# 入力例 2
# chokudai
# redcoder
# 出力例 2
# No
# どのように操作を行っても chokudai を redcoder にできません。
# 入力例 3
# abcdefghijklmnopqrstuvwxyz
# ibyhqfrekavclxjstdwgpzmonu
# 出力例 3
# Yes
def calculation(lines):
# N = int(lines[0])
# X, Y = list(map(int, lines[0].split()))
S = lines[0]
T = lines[1]
ns = list()
nt = list()
for c in "abcdefghijklmnopqrstuvwxyz":
s = len(S) - len(S.replace(c, ""))
ns.append(s)
t = len(T) - len(T.replace(c, ""))
nt.append(t)
ns.sort()
nt.sort()
if ns == nt:
return ["Yes"]
else:
return ["No"]
# 引数を取得
def get_input_lines(lines_count):
lines = list()
for _ in range(lines_count):
lines.append(input())
return lines
# テストデータ
def get_testdata(pattern):
if pattern == 1:
lines_input = ["azzel", "apple"]
lines_export = ["Yes"]
if pattern == 2:
lines_input = ["chokudai", "redcoder"]
lines_export = ["No"]
if pattern == 3:
lines_input = ["abcdefghijklmnopqrstuvwxyz", "ibyhqfrekavclxjstdwgpzmonu"]
lines_export = ["Yes"]
return lines_input, lines_export
# 動作モード判別
def get_mode():
import sys
args = sys.argv
if len(args) == 1:
mode = 0
else:
mode = int(args[1])
return mode
# 主処理
def main():
import time
started = time.time()
mode = get_mode()
if mode == 0:
lines_input = get_input_lines(2)
else:
lines_input, lines_export = get_testdata(mode)
lines_result = calculation(lines_input)
for line_result in lines_result:
print(line_result)
# if mode > 0:
# print(f'lines_input=[{lines_input}]')
# print(f'lines_export=[{lines_export}]')
# print(f'lines_result=[{lines_result}]')
# if lines_result == lines_export:
# print('OK')
# else:
# print('NG')
# finished = time.time()
# duration = finished - started
# print(f'duration=[{duration}]')
# 起動処理
if __name__ == "__main__":
main()
| Statement
You are given strings S and T consisting of lowercase English letters.
You can perform the following operation on S any number of times:
Operation: Choose two distinct lowercase English letters c_1 and c_2, then
replace every occurrence of c_1 with c_2, and every occurrence of c_2 with
c_1.
Determine if S and T can be made equal by performing the operation zero or
more times. | [{"input": "azzel\n apple", "output": "Yes\n \n\n`azzel` can be changed to `apple`, as follows:\n\n * Choose `e` as c_1 and `l` as c_2. `azzel` becomes `azzle`.\n * Choose `z` as c_1 and `p` as c_2. `azzle` becomes `apple`.\n\n* * *"}, {"input": "chokudai\n redcoder", "output": "No\n \n\nNo sequences of operation can change `chokudai` to `redcoder`.\n\n* * *"}, {"input": "abcdefghijklmnopqrstuvwxyz\n ibyhqfrekavclxjstdwgpzmonu", "output": "Yes"}] |
If S and T can be made equal, print `Yes`; otherwise, print `No`.
* * * | s850610124 | Runtime Error | p03252 | Input is given from Standard Input in the following format:
S
T | S = input()
T = input()
def check(A, B[Numeron App](https://numeron-app.herokuapp.com)[i]
elif d[A[i]] != B[i]:
return False
return True
print("Yes" if check(S, T) and check(T, S) else "No") | Statement
You are given strings S and T consisting of lowercase English letters.
You can perform the following operation on S any number of times:
Operation: Choose two distinct lowercase English letters c_1 and c_2, then
replace every occurrence of c_1 with c_2, and every occurrence of c_2 with
c_1.
Determine if S and T can be made equal by performing the operation zero or
more times. | [{"input": "azzel\n apple", "output": "Yes\n \n\n`azzel` can be changed to `apple`, as follows:\n\n * Choose `e` as c_1 and `l` as c_2. `azzel` becomes `azzle`.\n * Choose `z` as c_1 and `p` as c_2. `azzle` becomes `apple`.\n\n* * *"}, {"input": "chokudai\n redcoder", "output": "No\n \n\nNo sequences of operation can change `chokudai` to `redcoder`.\n\n* * *"}, {"input": "abcdefghijklmnopqrstuvwxyz\n ibyhqfrekavclxjstdwgpzmonu", "output": "Yes"}] |
If S and T can be made equal, print `Yes`; otherwise, print `No`.
* * * | s445436829 | Wrong Answer | p03252 | Input is given from Standard Input in the following format:
S
T | s = len(set(input()))
t = len(set(input()))
print("Yes") if s == t else print("No")
| Statement
You are given strings S and T consisting of lowercase English letters.
You can perform the following operation on S any number of times:
Operation: Choose two distinct lowercase English letters c_1 and c_2, then
replace every occurrence of c_1 with c_2, and every occurrence of c_2 with
c_1.
Determine if S and T can be made equal by performing the operation zero or
more times. | [{"input": "azzel\n apple", "output": "Yes\n \n\n`azzel` can be changed to `apple`, as follows:\n\n * Choose `e` as c_1 and `l` as c_2. `azzel` becomes `azzle`.\n * Choose `z` as c_1 and `p` as c_2. `azzle` becomes `apple`.\n\n* * *"}, {"input": "chokudai\n redcoder", "output": "No\n \n\nNo sequences of operation can change `chokudai` to `redcoder`.\n\n* * *"}, {"input": "abcdefghijklmnopqrstuvwxyz\n ibyhqfrekavclxjstdwgpzmonu", "output": "Yes"}] |
If S and T can be made equal, print `Yes`; otherwise, print `No`.
* * * | s167486557 | Accepted | p03252 | Input is given from Standard Input in the following format:
S
T | import sys
from collections import deque
sys.setrecursionlimit(4100000)
def inputs(num_of_input):
ins = [input() for i in range(num_of_input)]
return ins
def solve(inputs):
S = inputs[0]
T = inputs[1]
appeared = {}
appeared_count = {}
for i, _ in enumerate(S):
if T[i] in appeared:
if not appeared[T[i]] == S[i]:
return "No"
else:
appeared[T[i]] = S[i]
if S[i] in appeared_count:
appeared_count[S[i]] += 1
else:
appeared_count[S[i]] = 1
for k, v in appeared_count.items():
if v > 1:
return "No"
return "Yes"
def string_to_int(string):
return list(map(int, string.split()))
if __name__ == "__main__":
ret = solve(inputs(2))
print(ret)
| Statement
You are given strings S and T consisting of lowercase English letters.
You can perform the following operation on S any number of times:
Operation: Choose two distinct lowercase English letters c_1 and c_2, then
replace every occurrence of c_1 with c_2, and every occurrence of c_2 with
c_1.
Determine if S and T can be made equal by performing the operation zero or
more times. | [{"input": "azzel\n apple", "output": "Yes\n \n\n`azzel` can be changed to `apple`, as follows:\n\n * Choose `e` as c_1 and `l` as c_2. `azzel` becomes `azzle`.\n * Choose `z` as c_1 and `p` as c_2. `azzle` becomes `apple`.\n\n* * *"}, {"input": "chokudai\n redcoder", "output": "No\n \n\nNo sequences of operation can change `chokudai` to `redcoder`.\n\n* * *"}, {"input": "abcdefghijklmnopqrstuvwxyz\n ibyhqfrekavclxjstdwgpzmonu", "output": "Yes"}] |
If S and T can be made equal, print `Yes`; otherwise, print `No`.
* * * | s741991810 | Runtime Error | p03252 | Input is given from Standard Input in the following format:
S
T | function main(arg) {
arg = arg.split("\n")
var s = arg[0]
var t = arg[1]
while (1) {
if (s === "") {
break
}
s = s.split(s[0]).join("")
t = t.split(t[0]).join("")
if (s.length !== t.length) {
console.log('No')
return;
}
}
console.log('Yes')
}
main(require('fs').readFileSync('/dev/stdin', 'utf8')); | Statement
You are given strings S and T consisting of lowercase English letters.
You can perform the following operation on S any number of times:
Operation: Choose two distinct lowercase English letters c_1 and c_2, then
replace every occurrence of c_1 with c_2, and every occurrence of c_2 with
c_1.
Determine if S and T can be made equal by performing the operation zero or
more times. | [{"input": "azzel\n apple", "output": "Yes\n \n\n`azzel` can be changed to `apple`, as follows:\n\n * Choose `e` as c_1 and `l` as c_2. `azzel` becomes `azzle`.\n * Choose `z` as c_1 and `p` as c_2. `azzle` becomes `apple`.\n\n* * *"}, {"input": "chokudai\n redcoder", "output": "No\n \n\nNo sequences of operation can change `chokudai` to `redcoder`.\n\n* * *"}, {"input": "abcdefghijklmnopqrstuvwxyz\n ibyhqfrekavclxjstdwgpzmonu", "output": "Yes"}] |
If S and T can be made equal, print `Yes`; otherwise, print `No`.
* * * | s306774560 | Runtime Error | p03252 | Input is given from Standard Input in the following format:
S
T | S=list(input())
T=list(input())
N=len(S)
l=[]
i=0
for i in range(N):
if i==N
break
elif S[i] in S[i+1::]:
l.append([i,S[i+1::].index(S[i])])
else:
continue
l2=[]
for i in range(N):
if i==N:
break
elif T[i] in T[i+1::]:
l.append([i,T[i+1::].index(S[T])])
else:
continue
if l==l2:
print('Yes')
else:
print('No') | Statement
You are given strings S and T consisting of lowercase English letters.
You can perform the following operation on S any number of times:
Operation: Choose two distinct lowercase English letters c_1 and c_2, then
replace every occurrence of c_1 with c_2, and every occurrence of c_2 with
c_1.
Determine if S and T can be made equal by performing the operation zero or
more times. | [{"input": "azzel\n apple", "output": "Yes\n \n\n`azzel` can be changed to `apple`, as follows:\n\n * Choose `e` as c_1 and `l` as c_2. `azzel` becomes `azzle`.\n * Choose `z` as c_1 and `p` as c_2. `azzle` becomes `apple`.\n\n* * *"}, {"input": "chokudai\n redcoder", "output": "No\n \n\nNo sequences of operation can change `chokudai` to `redcoder`.\n\n* * *"}, {"input": "abcdefghijklmnopqrstuvwxyz\n ibyhqfrekavclxjstdwgpzmonu", "output": "Yes"}] |
If S and T can be made equal, print `Yes`; otherwise, print `No`.
* * * | s195505403 | Runtime Error | p03252 | Input is given from Standard Input in the following format:
S
T | s=input()
t=input()
n=len(s)
dic={}
ans='Yes'
for i in range(n):
if s[i] in dic:
if dic[t[i]]==t[i]:
continue
else:
ans='No'
break
if t[i] not in dic:
dic[t[i]]=s[i]
else:
if dic[t[i]]==s[i]:
continue
else dic[t[i]] !=s[i]:
ans='No'
break
print(ans) | Statement
You are given strings S and T consisting of lowercase English letters.
You can perform the following operation on S any number of times:
Operation: Choose two distinct lowercase English letters c_1 and c_2, then
replace every occurrence of c_1 with c_2, and every occurrence of c_2 with
c_1.
Determine if S and T can be made equal by performing the operation zero or
more times. | [{"input": "azzel\n apple", "output": "Yes\n \n\n`azzel` can be changed to `apple`, as follows:\n\n * Choose `e` as c_1 and `l` as c_2. `azzel` becomes `azzle`.\n * Choose `z` as c_1 and `p` as c_2. `azzle` becomes `apple`.\n\n* * *"}, {"input": "chokudai\n redcoder", "output": "No\n \n\nNo sequences of operation can change `chokudai` to `redcoder`.\n\n* * *"}, {"input": "abcdefghijklmnopqrstuvwxyz\n ibyhqfrekavclxjstdwgpzmonu", "output": "Yes"}] |
If S and T can be made equal, print `Yes`; otherwise, print `No`.
* * * | s684216533 | Runtime Error | p03252 | Input is given from Standard Input in the following format:
S
T | if __name__ == '__main__':
S = list(input())
T = list(input())
letter = []
for i in range(len(S)):
letter.append(T[i]) if S[i] == T[i]:
continue
else:
if S[i] in letter:
break
else:
s = S[i]
for j in range(len(S)):
if S[j] == s:
S[j] = T[i]
elif S[j] == T[i]:
S[j] = s
if S == T:
print('Yes')
else:
print('No') | Statement
You are given strings S and T consisting of lowercase English letters.
You can perform the following operation on S any number of times:
Operation: Choose two distinct lowercase English letters c_1 and c_2, then
replace every occurrence of c_1 with c_2, and every occurrence of c_2 with
c_1.
Determine if S and T can be made equal by performing the operation zero or
more times. | [{"input": "azzel\n apple", "output": "Yes\n \n\n`azzel` can be changed to `apple`, as follows:\n\n * Choose `e` as c_1 and `l` as c_2. `azzel` becomes `azzle`.\n * Choose `z` as c_1 and `p` as c_2. `azzle` becomes `apple`.\n\n* * *"}, {"input": "chokudai\n redcoder", "output": "No\n \n\nNo sequences of operation can change `chokudai` to `redcoder`.\n\n* * *"}, {"input": "abcdefghijklmnopqrstuvwxyz\n ibyhqfrekavclxjstdwgpzmonu", "output": "Yes"}] |
If S and T can be made equal, print `Yes`; otherwise, print `No`.
* * * | s648775487 | Runtime Error | p03252 | Input is given from Standard Input in the following format:
S
T | if __name__ == '__main__':
S = list(input())
T = list(input())
letter = []
for i in range(len(S)):
letter.append(T[i]) if S[i] == T[i]:
continue
else:
if S[i] in letter:
break
else:
s = S[i]
for j in range(len(S)):
if S[j] == s:
S[j] = T[i]
elif S[j] == T[i]:
S[j] = s
if S == T:
print('Yes')
else:
print('No') | Statement
You are given strings S and T consisting of lowercase English letters.
You can perform the following operation on S any number of times:
Operation: Choose two distinct lowercase English letters c_1 and c_2, then
replace every occurrence of c_1 with c_2, and every occurrence of c_2 with
c_1.
Determine if S and T can be made equal by performing the operation zero or
more times. | [{"input": "azzel\n apple", "output": "Yes\n \n\n`azzel` can be changed to `apple`, as follows:\n\n * Choose `e` as c_1 and `l` as c_2. `azzel` becomes `azzle`.\n * Choose `z` as c_1 and `p` as c_2. `azzle` becomes `apple`.\n\n* * *"}, {"input": "chokudai\n redcoder", "output": "No\n \n\nNo sequences of operation can change `chokudai` to `redcoder`.\n\n* * *"}, {"input": "abcdefghijklmnopqrstuvwxyz\n ibyhqfrekavclxjstdwgpzmonu", "output": "Yes"}] |
If S and T can be made equal, print `Yes`; otherwise, print `No`.
* * * | s148464098 | Runtime Error | p03252 | Input is given from Standard Input in the following format:
S
T | s = list(str(input()))
t = list(str(input()))
def judge(S,T):
start = [-1 for i in range(26) ]
goal = [-1 for i in range(26)]
for i in range(len(S)):
a = ord(S[i]) - ord('a')
b = ord(T[i]) - ord('a')
if start[a] != -1 or goal[b] != -1:
if start[a]!= b or goal[b] !=a:
print("No")
break
else:
start[a] = b
goal[b] =a
if i==len(S)-1:
print("Yes")
judge(s,t) | Statement
You are given strings S and T consisting of lowercase English letters.
You can perform the following operation on S any number of times:
Operation: Choose two distinct lowercase English letters c_1 and c_2, then
replace every occurrence of c_1 with c_2, and every occurrence of c_2 with
c_1.
Determine if S and T can be made equal by performing the operation zero or
more times. | [{"input": "azzel\n apple", "output": "Yes\n \n\n`azzel` can be changed to `apple`, as follows:\n\n * Choose `e` as c_1 and `l` as c_2. `azzel` becomes `azzle`.\n * Choose `z` as c_1 and `p` as c_2. `azzle` becomes `apple`.\n\n* * *"}, {"input": "chokudai\n redcoder", "output": "No\n \n\nNo sequences of operation can change `chokudai` to `redcoder`.\n\n* * *"}, {"input": "abcdefghijklmnopqrstuvwxyz\n ibyhqfrekavclxjstdwgpzmonu", "output": "Yes"}] |
If S and T can be made equal, print `Yes`; otherwise, print `No`.
* * * | s918738269 | Runtime Error | p03252 | Input is given from Standard Input in the following format:
S
T | use std::collections::{HashMap,HashSet};
#[allow(unused_macros)]
macro_rules! invec {
( $t:ty ) => {{
let mut s = String::new();
match std::io::stdin().read_line(&mut s) {
Ok(0) => Vec::<$t>::new(),
Ok(n) => s
.trim()
.split_whitespace()
.map(|s| s.parse::<$t>().unwrap())
.collect::<Vec<$t>>(),
Err(_) => Vec::<$t>::new(),
}
}};
}
#[allow(unused_macros)]
macro_rules! input {
( $($t:ty),* ) => {{
let mut s = String::new();
std::io::stdin().read_line(&mut s);
let mut splits = s.trim().split_whitespace();
($(
{
splits.next().unwrap().parse::<$t>().unwrap()
},
)*)
}}
}
// #[allow(unused_must_use)]
// fn trans(s: &Vec<u8>, s_i: u8, t_i: u8) -> Vec<u8> {
// let mut res = Vec::<u8>::with_capacity(s.len());
// for i in 0..s.len() {
// if s[i] == s_i {
// res.push(t_i);
// } else if s[i] == t_i {
// res.push(s_i);
// } else {
// res.push(s[i]);
// };
// }
// return res;
// }
#[allow(unused_must_use)]
#[allow(unused_variables)]
fn solve() {
let (s,) = input!(String);
let (t,) = input!(String);
let mut m = HashMap::new();
let mut t = t.chars();
for c in s.chars() {
let aft = t.next().unwrap();
if let Some(val) = m.get(&c) {
if val == &aft {
println!("continue");
continue;
} else {
println!("No");
std::process::exit(0);
}
}
m.insert(c, aft);
}
let set = m.values().collect::<HashSet<_>>();
if set.len() == m.len() {
println!("Yes");
} else {
println!("No");
}
}
fn main() {
solve();
}
| Statement
You are given strings S and T consisting of lowercase English letters.
You can perform the following operation on S any number of times:
Operation: Choose two distinct lowercase English letters c_1 and c_2, then
replace every occurrence of c_1 with c_2, and every occurrence of c_2 with
c_1.
Determine if S and T can be made equal by performing the operation zero or
more times. | [{"input": "azzel\n apple", "output": "Yes\n \n\n`azzel` can be changed to `apple`, as follows:\n\n * Choose `e` as c_1 and `l` as c_2. `azzel` becomes `azzle`.\n * Choose `z` as c_1 and `p` as c_2. `azzle` becomes `apple`.\n\n* * *"}, {"input": "chokudai\n redcoder", "output": "No\n \n\nNo sequences of operation can change `chokudai` to `redcoder`.\n\n* * *"}, {"input": "abcdefghijklmnopqrstuvwxyz\n ibyhqfrekavclxjstdwgpzmonu", "output": "Yes"}] |
If S and T can be made equal, print `Yes`; otherwise, print `No`.
* * * | s814085226 | Runtime Error | p03252 | Input is given from Standard Input in the following format:
S
T | S = input()
T = input()
s = list(S)
t = list(T)
a = set(s)
b = set(t)
A = 0
B = 0
c = len(a)
for i in range(c):
d = S.count("a[i]")
A += d**3
for i in range(c):
e = S.count("b[i]")
B += e**3
if len(s) - len(a) == len(t) - len(b) and A == B:
print("Yes")
else:
print("No")
| Statement
You are given strings S and T consisting of lowercase English letters.
You can perform the following operation on S any number of times:
Operation: Choose two distinct lowercase English letters c_1 and c_2, then
replace every occurrence of c_1 with c_2, and every occurrence of c_2 with
c_1.
Determine if S and T can be made equal by performing the operation zero or
more times. | [{"input": "azzel\n apple", "output": "Yes\n \n\n`azzel` can be changed to `apple`, as follows:\n\n * Choose `e` as c_1 and `l` as c_2. `azzel` becomes `azzle`.\n * Choose `z` as c_1 and `p` as c_2. `azzle` becomes `apple`.\n\n* * *"}, {"input": "chokudai\n redcoder", "output": "No\n \n\nNo sequences of operation can change `chokudai` to `redcoder`.\n\n* * *"}, {"input": "abcdefghijklmnopqrstuvwxyz\n ibyhqfrekavclxjstdwgpzmonu", "output": "Yes"}] |
If S and T can be made equal, print `Yes`; otherwise, print `No`.
* * * | s498077848 | Runtime Error | p03252 | Input is given from Standard Input in the following format:
S
T | s=input()
t=input()
d={}
for i in range(len(s)):
if s[i]!=t[i]:
if s[i] in d:
if d[s[i]]!=t[i]
print('No')
exit()
else:
pass
else:
d[s[i]]=t[i]
else:
if s[i] in d and d[s[i]]!=t[i]:
print('No')
exit()
print('Yes') | Statement
You are given strings S and T consisting of lowercase English letters.
You can perform the following operation on S any number of times:
Operation: Choose two distinct lowercase English letters c_1 and c_2, then
replace every occurrence of c_1 with c_2, and every occurrence of c_2 with
c_1.
Determine if S and T can be made equal by performing the operation zero or
more times. | [{"input": "azzel\n apple", "output": "Yes\n \n\n`azzel` can be changed to `apple`, as follows:\n\n * Choose `e` as c_1 and `l` as c_2. `azzel` becomes `azzle`.\n * Choose `z` as c_1 and `p` as c_2. `azzle` becomes `apple`.\n\n* * *"}, {"input": "chokudai\n redcoder", "output": "No\n \n\nNo sequences of operation can change `chokudai` to `redcoder`.\n\n* * *"}, {"input": "abcdefghijklmnopqrstuvwxyz\n ibyhqfrekavclxjstdwgpzmonu", "output": "Yes"}] |
If S and T can be made equal, print `Yes`; otherwise, print `No`.
* * * | s966165492 | Runtime Error | p03252 | Input is given from Standard Input in the following format:
S
T | n, m, x, y = [int(i) for i in input().split(" ")]
x_range = [int(i) for i in input().split(" ")]
y_range = [int(i) for i in input().split(" ")]
war = True
for z in range(x, y + 1):
if x < z <= y and max(x_range) < z <= max(y_range[:m]):
war = False
print("War" if war else "No War")
| Statement
You are given strings S and T consisting of lowercase English letters.
You can perform the following operation on S any number of times:
Operation: Choose two distinct lowercase English letters c_1 and c_2, then
replace every occurrence of c_1 with c_2, and every occurrence of c_2 with
c_1.
Determine if S and T can be made equal by performing the operation zero or
more times. | [{"input": "azzel\n apple", "output": "Yes\n \n\n`azzel` can be changed to `apple`, as follows:\n\n * Choose `e` as c_1 and `l` as c_2. `azzel` becomes `azzle`.\n * Choose `z` as c_1 and `p` as c_2. `azzle` becomes `apple`.\n\n* * *"}, {"input": "chokudai\n redcoder", "output": "No\n \n\nNo sequences of operation can change `chokudai` to `redcoder`.\n\n* * *"}, {"input": "abcdefghijklmnopqrstuvwxyz\n ibyhqfrekavclxjstdwgpzmonu", "output": "Yes"}] |
If S and T can be made equal, print `Yes`; otherwise, print `No`.
* * * | s602425175 | Runtime Error | p03252 | Input is given from Standard Input in the following format:
S
T | S = input()
T = input()
# print()
if len(S)>=10**5+9*10**4:
print("Yes")
elif len(S)>= 10**5+8**4:
print(“No”)
else:
for i in range(len(S)):
if S[i] != T[i]:
S = S.translate(str.maketrans({S[i]:T[i],T[i]:S[i]}))
# S=S.replace(S[i],T[i])
if S==T:
print("Yes")
else:
print("No") | Statement
You are given strings S and T consisting of lowercase English letters.
You can perform the following operation on S any number of times:
Operation: Choose two distinct lowercase English letters c_1 and c_2, then
replace every occurrence of c_1 with c_2, and every occurrence of c_2 with
c_1.
Determine if S and T can be made equal by performing the operation zero or
more times. | [{"input": "azzel\n apple", "output": "Yes\n \n\n`azzel` can be changed to `apple`, as follows:\n\n * Choose `e` as c_1 and `l` as c_2. `azzel` becomes `azzle`.\n * Choose `z` as c_1 and `p` as c_2. `azzle` becomes `apple`.\n\n* * *"}, {"input": "chokudai\n redcoder", "output": "No\n \n\nNo sequences of operation can change `chokudai` to `redcoder`.\n\n* * *"}, {"input": "abcdefghijklmnopqrstuvwxyz\n ibyhqfrekavclxjstdwgpzmonu", "output": "Yes"}] |
If S and T can be made equal, print `Yes`; otherwise, print `No`.
* * * | s423109228 | Runtime Error | p03252 | Input is given from Standard Input in the following format:
S
T | s=input()
t=input()
n=len(s)
dic={}
ans='Yes'
for i in range(n):
if t[i] not in dic:
dic[t[i]]=s[i]
else:
if dic[t[i]]==s[i]:
continue
else :
ans='No'
break
if len(dic)!len(set(dic.values())):
ans='No'
print(ans) | Statement
You are given strings S and T consisting of lowercase English letters.
You can perform the following operation on S any number of times:
Operation: Choose two distinct lowercase English letters c_1 and c_2, then
replace every occurrence of c_1 with c_2, and every occurrence of c_2 with
c_1.
Determine if S and T can be made equal by performing the operation zero or
more times. | [{"input": "azzel\n apple", "output": "Yes\n \n\n`azzel` can be changed to `apple`, as follows:\n\n * Choose `e` as c_1 and `l` as c_2. `azzel` becomes `azzle`.\n * Choose `z` as c_1 and `p` as c_2. `azzle` becomes `apple`.\n\n* * *"}, {"input": "chokudai\n redcoder", "output": "No\n \n\nNo sequences of operation can change `chokudai` to `redcoder`.\n\n* * *"}, {"input": "abcdefghijklmnopqrstuvwxyz\n ibyhqfrekavclxjstdwgpzmonu", "output": "Yes"}] |
If S and T can be made equal, print `Yes`; otherwise, print `No`.
* * * | s184190266 | Wrong Answer | p03252 | Input is given from Standard Input in the following format:
S
T | print("No")
| Statement
You are given strings S and T consisting of lowercase English letters.
You can perform the following operation on S any number of times:
Operation: Choose two distinct lowercase English letters c_1 and c_2, then
replace every occurrence of c_1 with c_2, and every occurrence of c_2 with
c_1.
Determine if S and T can be made equal by performing the operation zero or
more times. | [{"input": "azzel\n apple", "output": "Yes\n \n\n`azzel` can be changed to `apple`, as follows:\n\n * Choose `e` as c_1 and `l` as c_2. `azzel` becomes `azzle`.\n * Choose `z` as c_1 and `p` as c_2. `azzle` becomes `apple`.\n\n* * *"}, {"input": "chokudai\n redcoder", "output": "No\n \n\nNo sequences of operation can change `chokudai` to `redcoder`.\n\n* * *"}, {"input": "abcdefghijklmnopqrstuvwxyz\n ibyhqfrekavclxjstdwgpzmonu", "output": "Yes"}] |
If S and T can be made equal, print `Yes`; otherwise, print `No`.
* * * | s174096233 | Wrong Answer | p03252 | Input is given from Standard Input in the following format:
S
T | S, T = set(input()), set(input())
print("Yes" if S == T or len(S - T) == len(T - S) else "No")
| Statement
You are given strings S and T consisting of lowercase English letters.
You can perform the following operation on S any number of times:
Operation: Choose two distinct lowercase English letters c_1 and c_2, then
replace every occurrence of c_1 with c_2, and every occurrence of c_2 with
c_1.
Determine if S and T can be made equal by performing the operation zero or
more times. | [{"input": "azzel\n apple", "output": "Yes\n \n\n`azzel` can be changed to `apple`, as follows:\n\n * Choose `e` as c_1 and `l` as c_2. `azzel` becomes `azzle`.\n * Choose `z` as c_1 and `p` as c_2. `azzle` becomes `apple`.\n\n* * *"}, {"input": "chokudai\n redcoder", "output": "No\n \n\nNo sequences of operation can change `chokudai` to `redcoder`.\n\n* * *"}, {"input": "abcdefghijklmnopqrstuvwxyz\n ibyhqfrekavclxjstdwgpzmonu", "output": "Yes"}] |
If S and T can be made equal, print `Yes`; otherwise, print `No`.
* * * | s760310758 | Wrong Answer | p03252 | Input is given from Standard Input in the following format:
S
T | s = str(input())
t = str(input())
print("Yes")
| Statement
You are given strings S and T consisting of lowercase English letters.
You can perform the following operation on S any number of times:
Operation: Choose two distinct lowercase English letters c_1 and c_2, then
replace every occurrence of c_1 with c_2, and every occurrence of c_2 with
c_1.
Determine if S and T can be made equal by performing the operation zero or
more times. | [{"input": "azzel\n apple", "output": "Yes\n \n\n`azzel` can be changed to `apple`, as follows:\n\n * Choose `e` as c_1 and `l` as c_2. `azzel` becomes `azzle`.\n * Choose `z` as c_1 and `p` as c_2. `azzle` becomes `apple`.\n\n* * *"}, {"input": "chokudai\n redcoder", "output": "No\n \n\nNo sequences of operation can change `chokudai` to `redcoder`.\n\n* * *"}, {"input": "abcdefghijklmnopqrstuvwxyz\n ibyhqfrekavclxjstdwgpzmonu", "output": "Yes"}] |
If S and T can be made equal, print `Yes`; otherwise, print `No`.
* * * | s288913850 | Wrong Answer | p03252 | Input is given from Standard Input in the following format:
S
T | s = list(input().strip())
t = list(input().strip())
ss = [s.count(i) for i in set(s)]
tt = [t.count(i) for i in set(t)]
print("Yes" if ss == tt else "No")
| Statement
You are given strings S and T consisting of lowercase English letters.
You can perform the following operation on S any number of times:
Operation: Choose two distinct lowercase English letters c_1 and c_2, then
replace every occurrence of c_1 with c_2, and every occurrence of c_2 with
c_1.
Determine if S and T can be made equal by performing the operation zero or
more times. | [{"input": "azzel\n apple", "output": "Yes\n \n\n`azzel` can be changed to `apple`, as follows:\n\n * Choose `e` as c_1 and `l` as c_2. `azzel` becomes `azzle`.\n * Choose `z` as c_1 and `p` as c_2. `azzle` becomes `apple`.\n\n* * *"}, {"input": "chokudai\n redcoder", "output": "No\n \n\nNo sequences of operation can change `chokudai` to `redcoder`.\n\n* * *"}, {"input": "abcdefghijklmnopqrstuvwxyz\n ibyhqfrekavclxjstdwgpzmonu", "output": "Yes"}] |
If S and T can be made equal, print `Yes`; otherwise, print `No`.
* * * | s967973750 | Accepted | p03252 | Input is given from Standard Input in the following format:
S
T | import sys
## io ##
def IS():
return sys.stdin.readline().rstrip()
def II():
return int(IS())
def MII():
return list(map(int, IS().split()))
def MIIZ():
return list(map(lambda x: x - 1, MII()))
## dp ##
def DD2(d1, d2, init=0):
return [[init] * d2 for _ in range(d1)]
def DD3(d1, d2, d3, init=0):
return [DD2(d2, d3, init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str:
return format(x, "b") # rev => int(res, 2)
def to_oct(x: int) -> str:
return format(x, "o") # rev => int(res, 8)
def to_hex(x: int) -> str:
return format(x, "x") # rev => int(res, 16)
MOD = 10**9 + 7
def divc(x, y) -> int:
return -(-x // y)
def divf(x, y) -> int:
return x // y
def gcd(x, y):
while y:
x, y = y, x % y
return x
def lcm(x, y):
return x * y // gcd(x, y)
def enumerate_divs(n):
"""Return a tuple list of divisor of n"""
return [(i, n // i) for i in range(1, int(n**0.5) + 1) if n % i == 0]
def get_primes(MAX_NUM=10**3):
"""Return a list of prime numbers n or less"""
is_prime = [True] * (MAX_NUM + 1)
is_prime[0] = is_prime[1] = False
for i in range(2, int(MAX_NUM**0.5) + 1):
if not is_prime[i]:
continue
for j in range(i * 2, MAX_NUM + 1, i):
is_prime[j] = False
return [i for i in range(MAX_NUM + 1) if is_prime[i]]
def prime_factor(n):
"""Return a list of prime factorization numbers of n"""
res = []
for i in range(2, int(n**0.5) + 1):
while n % i == 0:
res.append(i)
n //= i
if n != 1:
res.append(n)
return res
## libs ##
from itertools import (
accumulate as acc,
combinations as combi,
product,
combinations_with_replacement as combi_dup,
)
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
import string
# ======================================================#
def main():
s = IS()
t = IS()
tidx = {a: [] for a in string.ascii_lowercase}
sidx = {a: [] for a in string.ascii_lowercase}
for i, ti in enumerate(t):
tidx[ti].append(i)
for i, si in enumerate(s):
sidx[si].append(i)
for k, idx in tidx.items():
tmp = set()
for i in idx:
tmp.add(s[i])
if len(tmp) > 1:
print("No")
return None
for k, idx in sidx.items():
tmp = set()
for i in idx:
tmp.add(t[i])
if len(tmp) > 1:
print("No")
return None
print("Yes")
if __name__ == "__main__":
main()
| Statement
You are given strings S and T consisting of lowercase English letters.
You can perform the following operation on S any number of times:
Operation: Choose two distinct lowercase English letters c_1 and c_2, then
replace every occurrence of c_1 with c_2, and every occurrence of c_2 with
c_1.
Determine if S and T can be made equal by performing the operation zero or
more times. | [{"input": "azzel\n apple", "output": "Yes\n \n\n`azzel` can be changed to `apple`, as follows:\n\n * Choose `e` as c_1 and `l` as c_2. `azzel` becomes `azzle`.\n * Choose `z` as c_1 and `p` as c_2. `azzle` becomes `apple`.\n\n* * *"}, {"input": "chokudai\n redcoder", "output": "No\n \n\nNo sequences of operation can change `chokudai` to `redcoder`.\n\n* * *"}, {"input": "abcdefghijklmnopqrstuvwxyz\n ibyhqfrekavclxjstdwgpzmonu", "output": "Yes"}] |
If S and T can be made equal, print `Yes`; otherwise, print `No`.
* * * | s945248468 | Runtime Error | p03252 | Input is given from Standard Input in the following format:
S
T |
def get_input(inp):
li = inp.split("\n")
def inner():
return li.pop(0)
return inner
INPUT = """azzel
apple
"""
input = get_input(INPUT)
#######################################################
a = input()
b = input()
k = []
l = []
np=0
nq=0
for i in range(0,len(a)):
if a[i] not in k:
k.append(a[i])
np+=1
if b[i] not in l:
l.append(b[i])
nq+=1
if i != 0:
if not (k.index(a[i])==l.index(b[i]) and ((a[i-1]==a[i] and b[i-1] == b[i]) or ( a[i-1] != a[i] and b[i-1]!= b[i])):
np*=0
if np == nq:
print("Yes")
else:
print("No") | Statement
You are given strings S and T consisting of lowercase English letters.
You can perform the following operation on S any number of times:
Operation: Choose two distinct lowercase English letters c_1 and c_2, then
replace every occurrence of c_1 with c_2, and every occurrence of c_2 with
c_1.
Determine if S and T can be made equal by performing the operation zero or
more times. | [{"input": "azzel\n apple", "output": "Yes\n \n\n`azzel` can be changed to `apple`, as follows:\n\n * Choose `e` as c_1 and `l` as c_2. `azzel` becomes `azzle`.\n * Choose `z` as c_1 and `p` as c_2. `azzle` becomes `apple`.\n\n* * *"}, {"input": "chokudai\n redcoder", "output": "No\n \n\nNo sequences of operation can change `chokudai` to `redcoder`.\n\n* * *"}, {"input": "abcdefghijklmnopqrstuvwxyz\n ibyhqfrekavclxjstdwgpzmonu", "output": "Yes"}] |
If S and T can be made equal, print `Yes`; otherwise, print `No`.
* * * | s206173711 | Runtime Error | p03252 | Input is given from Standard Input in the following format:
S
T | t = Counter(list(input()))
| Statement
You are given strings S and T consisting of lowercase English letters.
You can perform the following operation on S any number of times:
Operation: Choose two distinct lowercase English letters c_1 and c_2, then
replace every occurrence of c_1 with c_2, and every occurrence of c_2 with
c_1.
Determine if S and T can be made equal by performing the operation zero or
more times. | [{"input": "azzel\n apple", "output": "Yes\n \n\n`azzel` can be changed to `apple`, as follows:\n\n * Choose `e` as c_1 and `l` as c_2. `azzel` becomes `azzle`.\n * Choose `z` as c_1 and `p` as c_2. `azzle` becomes `apple`.\n\n* * *"}, {"input": "chokudai\n redcoder", "output": "No\n \n\nNo sequences of operation can change `chokudai` to `redcoder`.\n\n* * *"}, {"input": "abcdefghijklmnopqrstuvwxyz\n ibyhqfrekavclxjstdwgpzmonu", "output": "Yes"}] |
If S and T can be made equal, print `Yes`; otherwise, print `No`.
* * * | s760133205 | Accepted | p03252 | Input is given from Standard Input in the following format:
S
T | S = input()
T = input()
N = len(S)
memo_s = {
"a": -1,
"b": -1,
"c": -1,
"d": -1,
"e": -1,
"f": -1,
"g": -1,
"h": -1,
"i": -1,
"j": -1,
"k": -1,
"l": -1,
"m": -1,
"n": -1,
"o": -1,
"p": -1,
"q": -1,
"r": -1,
"s": -1,
"t": -1,
"u": -1,
"v": -1,
"w": -1,
"x": -1,
"y": -1,
"z": -1,
}
memo_t = {
"a": -1,
"b": -1,
"c": -1,
"d": -1,
"e": -1,
"f": -1,
"g": -1,
"h": -1,
"i": -1,
"j": -1,
"k": -1,
"l": -1,
"m": -1,
"n": -1,
"o": -1,
"p": -1,
"q": -1,
"r": -1,
"s": -1,
"t": -1,
"u": -1,
"v": -1,
"w": -1,
"x": -1,
"y": -1,
"z": -1,
}
for i in range(N):
if memo_s[S[i]] == -1 and memo_t[T[i]] == -1:
memo_s[S[i]] = T[i]
memo_t[T[i]] = S[i]
else:
if memo_s[S[i]] != T[i] or memo_t[T[i]] != S[i]:
print("No")
quit()
print("Yes")
| Statement
You are given strings S and T consisting of lowercase English letters.
You can perform the following operation on S any number of times:
Operation: Choose two distinct lowercase English letters c_1 and c_2, then
replace every occurrence of c_1 with c_2, and every occurrence of c_2 with
c_1.
Determine if S and T can be made equal by performing the operation zero or
more times. | [{"input": "azzel\n apple", "output": "Yes\n \n\n`azzel` can be changed to `apple`, as follows:\n\n * Choose `e` as c_1 and `l` as c_2. `azzel` becomes `azzle`.\n * Choose `z` as c_1 and `p` as c_2. `azzle` becomes `apple`.\n\n* * *"}, {"input": "chokudai\n redcoder", "output": "No\n \n\nNo sequences of operation can change `chokudai` to `redcoder`.\n\n* * *"}, {"input": "abcdefghijklmnopqrstuvwxyz\n ibyhqfrekavclxjstdwgpzmonu", "output": "Yes"}] |
If S and T can be made equal, print `Yes`; otherwise, print `No`.
* * * | s772915084 | Accepted | p03252 | Input is given from Standard Input in the following format:
S
T | s, t = [0] * 26, [0] * 26
for a, b in zip(input(), input()):
s[ord(a) - ord("a")] += 1
t[ord(b) - ord("a")] += 1
u, v = [], []
for a, b in zip(s, t):
if a != b:
u.append(a)
v.append(b)
print("YNeos"[sorted(u) != sorted(v) :: 2])
| Statement
You are given strings S and T consisting of lowercase English letters.
You can perform the following operation on S any number of times:
Operation: Choose two distinct lowercase English letters c_1 and c_2, then
replace every occurrence of c_1 with c_2, and every occurrence of c_2 with
c_1.
Determine if S and T can be made equal by performing the operation zero or
more times. | [{"input": "azzel\n apple", "output": "Yes\n \n\n`azzel` can be changed to `apple`, as follows:\n\n * Choose `e` as c_1 and `l` as c_2. `azzel` becomes `azzle`.\n * Choose `z` as c_1 and `p` as c_2. `azzle` becomes `apple`.\n\n* * *"}, {"input": "chokudai\n redcoder", "output": "No\n \n\nNo sequences of operation can change `chokudai` to `redcoder`.\n\n* * *"}, {"input": "abcdefghijklmnopqrstuvwxyz\n ibyhqfrekavclxjstdwgpzmonu", "output": "Yes"}] |
If S and T can be made equal, print `Yes`; otherwise, print `No`.
* * * | s563040576 | Accepted | p03252 | Input is given from Standard Input in the following format:
S
T | A = input()
B = input()
dA = [-1] * 26
dB = [-1] * 26
cA = 0
cB = 0
pA = []
pB = []
le = len(A)
for i in range(le):
v = ord(A[i]) - ord("a")
if dA[v] == -1:
dA[v] = cA
pA.append(cA)
cA += 1
else:
pA.append(dA[v])
for i in range(le):
v = ord(B[i]) - ord("a")
if dB[v] == -1:
dB[v] = cB
pB.append(cB)
cB += 1
else:
pB.append(dB[v])
s = le
for i in range(le):
if pA[i] == pB[i]:
s -= 1
if s == 0:
print("Yes")
else:
print("No")
| Statement
You are given strings S and T consisting of lowercase English letters.
You can perform the following operation on S any number of times:
Operation: Choose two distinct lowercase English letters c_1 and c_2, then
replace every occurrence of c_1 with c_2, and every occurrence of c_2 with
c_1.
Determine if S and T can be made equal by performing the operation zero or
more times. | [{"input": "azzel\n apple", "output": "Yes\n \n\n`azzel` can be changed to `apple`, as follows:\n\n * Choose `e` as c_1 and `l` as c_2. `azzel` becomes `azzle`.\n * Choose `z` as c_1 and `p` as c_2. `azzle` becomes `apple`.\n\n* * *"}, {"input": "chokudai\n redcoder", "output": "No\n \n\nNo sequences of operation can change `chokudai` to `redcoder`.\n\n* * *"}, {"input": "abcdefghijklmnopqrstuvwxyz\n ibyhqfrekavclxjstdwgpzmonu", "output": "Yes"}] |
If S and T can be made equal, print `Yes`; otherwise, print `No`.
* * * | s515535624 | Wrong Answer | p03252 | Input is given from Standard Input in the following format:
S
T | l = list(input())
m = list(input())
def list_difference(list1, list2):
result = list1.copy()
for value in list2:
if value in result:
result.remove(value)
return result
aa = list_difference(l, m)
bb = list_difference(m, l)
print(["No", "Yes"][len(aa) == len(bb)])
| Statement
You are given strings S and T consisting of lowercase English letters.
You can perform the following operation on S any number of times:
Operation: Choose two distinct lowercase English letters c_1 and c_2, then
replace every occurrence of c_1 with c_2, and every occurrence of c_2 with
c_1.
Determine if S and T can be made equal by performing the operation zero or
more times. | [{"input": "azzel\n apple", "output": "Yes\n \n\n`azzel` can be changed to `apple`, as follows:\n\n * Choose `e` as c_1 and `l` as c_2. `azzel` becomes `azzle`.\n * Choose `z` as c_1 and `p` as c_2. `azzle` becomes `apple`.\n\n* * *"}, {"input": "chokudai\n redcoder", "output": "No\n \n\nNo sequences of operation can change `chokudai` to `redcoder`.\n\n* * *"}, {"input": "abcdefghijklmnopqrstuvwxyz\n ibyhqfrekavclxjstdwgpzmonu", "output": "Yes"}] |
If S and T can be made equal, print `Yes`; otherwise, print `No`.
* * * | s511266190 | Accepted | p03252 | Input is given from Standard Input in the following format:
S
T | # きりみんちゃんの配信からきました
# 登場回数が同一ならいけそうなのでそうする
s, t = input(), input()
sd, td = {}, {}
for sv in s:
if sv in sd:
sd[sv] += 1
else:
sd[sv] = 1
for tv in t:
if tv in td:
td[tv] += 1
else:
td[tv] = 1
sort_sk, sort_tk = sorted(sd.values()), sorted(td.values())
print("Yes" if sort_sk == sort_tk else "No")
| Statement
You are given strings S and T consisting of lowercase English letters.
You can perform the following operation on S any number of times:
Operation: Choose two distinct lowercase English letters c_1 and c_2, then
replace every occurrence of c_1 with c_2, and every occurrence of c_2 with
c_1.
Determine if S and T can be made equal by performing the operation zero or
more times. | [{"input": "azzel\n apple", "output": "Yes\n \n\n`azzel` can be changed to `apple`, as follows:\n\n * Choose `e` as c_1 and `l` as c_2. `azzel` becomes `azzle`.\n * Choose `z` as c_1 and `p` as c_2. `azzle` becomes `apple`.\n\n* * *"}, {"input": "chokudai\n redcoder", "output": "No\n \n\nNo sequences of operation can change `chokudai` to `redcoder`.\n\n* * *"}, {"input": "abcdefghijklmnopqrstuvwxyz\n ibyhqfrekavclxjstdwgpzmonu", "output": "Yes"}] |
Print the number of triples that satisfy the condition.
* * * | s075367111 | Runtime Error | p03225 | Input is given from Standard Input in the following format:
H W
s_{11}...s_{1W}
:
s_{H1}...s_{HW} | H, W = map(int, input().split())
X = [[[0, 1][a == "#"] for a in input()] for i in range(H)]
def countRD(n, i, j):
return ccc(n, i, j, 1, 1)
def countRU(n, i, j):
return ccc(n, i, j, -1, 1)
def countLD(n, i, j):
return ccc(n, i, j, 1, -1)
def countLU(n, i, j):
return ccc(n, i, j, -1, -1)
def countR(n, i, j):
return cc(n, i, j, 0, 1)
def countL(n, i, j):
return cc(n, i, j, 0, -1)
def countD(n, i, j):
return cc(n, i, j, 1, 0)
def countU(n, i, j):
return cc(n, i, j, -1, 0)
def ccc(n, i, j, DU, RL):
c = 0
for k in range(1, n):
if i + k * DU >= 0 and i + k * DU < H:
if j + (n - k) * RL >= 0 and j + (n - k) * RL < W:
c += X[i + k * DU][j + (n - k) * RL]
return c
def cc(n, i, j, DU, RL):
ret = 0
if i + n * DU >= 0 and i + n * DU < H:
if j + n * RL >= 0 and j + n * RL < W:
ret = X[i + n * DU][j + n * RL]
return ret
ans = 0
for i in range(H):
for j in range(W):
for n in range(
1, min(max(i + j, H - i + W - j), max(i + W - j, H - i + J)) + 2
):
if countR(n, i, j) and countD(n, i, j):
ans += countLU(n, i, j)
if countR(n, i, j) and countU(n, i, j):
ans += countLD(n, i, j)
if countL(n, i, j) and countD(n, i, j):
ans += countRU(n, i, j)
if countL(n, i, j) and countU(n, i, j):
ans += countRD(n, i, j)
if countR(n, i, j) and countD(n, i, j) and countL(n, i, j):
ans += 1
if countR(n, i, j) and countD(n, i, j) and countU(n, i, j):
ans += 1
if countR(n, i, j) and countU(n, i, j) and countL(n, i, j):
ans += 1
if countD(n, i, j) and countU(n, i, j) and countL(n, i, j):
ans += 1
print(ans)
| Statement
There are some coins in the xy-plane. The positions of the coins are
represented by a grid of characters with H rows and W columns. If the
character at the i-th row and j-th column, s_{ij}, is `#`, there is one coin
at point (i,j); if that character is `.`, there is no coin at point (i,j).
There are no other coins in the xy-plane.
There is no coin at point (x,y) where 1\leq i\leq H,1\leq j\leq W does not
hold. There is also no coin at point (x,y) where x or y (or both) is not an
integer. Additionally, two or more coins never exist at the same point.
Find the number of triples of different coins that satisfy the following
condition:
* Choosing any two of the three coins would result in the same Manhattan distance between the points where they exist.
Here, the Manhattan distance between points (x,y) and (x',y') is
|x-x'|+|y-y'|. Two triples are considered the same if the only difference
between them is the order of the coins. | [{"input": "5 4\n #.##\n .##.\n #...\n ..##\n ...#", "output": "3\n \n\n((1,1),(1,3),(2,2)),((1,1),(2,2),(3,1)) and ((1,3),(3,1),(4,4)) satisfy the\ncondition.\n\n* * *"}, {"input": "13 27\n ......#.........#.......#..\n #############...#.....###..\n ..............#####...##...\n ...#######......#...#######\n ...#.....#.....###...#...#.\n ...#######....#.#.#.#.###.#\n ..............#.#.#...#.#..\n #############.#.#.#...###..\n #...........#...#...#######\n #..#######..#...#...#.....#\n #..#.....#..#...#...#.###.#\n #..#######..#...#...#.#.#.#\n #..........##...#...#.#####", "output": "870"}] |
Print the number of triples that satisfy the condition.
* * * | s089421321 | Runtime Error | p03225 | Input is given from Standard Input in the following format:
H W
s_{11}...s_{1W}
:
s_{H1}...s_{HW} |
def distance(a,b):
return abs(a[0]-b[0])+abs(a[1]-b[1])
n=0
H,W=input().split()
r=[]
for i in range(H):
r.append(input().split())
stones=[]
for i in range(H):
for j in range(W):
if(r[i][j]=="#"):
stones.append([j,i])
for i in range(len(stones)):
for j in range(i,(len(stones)):
d=distance(stones[i],stones[j])
for k in range(j,len(stones)):
if(distance(stones[i],stones[k])==distance(stones[j],stones[k])==d):
n+=1
print(n)
| Statement
There are some coins in the xy-plane. The positions of the coins are
represented by a grid of characters with H rows and W columns. If the
character at the i-th row and j-th column, s_{ij}, is `#`, there is one coin
at point (i,j); if that character is `.`, there is no coin at point (i,j).
There are no other coins in the xy-plane.
There is no coin at point (x,y) where 1\leq i\leq H,1\leq j\leq W does not
hold. There is also no coin at point (x,y) where x or y (or both) is not an
integer. Additionally, two or more coins never exist at the same point.
Find the number of triples of different coins that satisfy the following
condition:
* Choosing any two of the three coins would result in the same Manhattan distance between the points where they exist.
Here, the Manhattan distance between points (x,y) and (x',y') is
|x-x'|+|y-y'|. Two triples are considered the same if the only difference
between them is the order of the coins. | [{"input": "5 4\n #.##\n .##.\n #...\n ..##\n ...#", "output": "3\n \n\n((1,1),(1,3),(2,2)),((1,1),(2,2),(3,1)) and ((1,3),(3,1),(4,4)) satisfy the\ncondition.\n\n* * *"}, {"input": "13 27\n ......#.........#.......#..\n #############...#.....###..\n ..............#####...##...\n ...#######......#...#######\n ...#.....#.....###...#...#.\n ...#######....#.#.#.#.###.#\n ..............#.#.#...#.#..\n #############.#.#.#...###..\n #...........#...#...#######\n #..#######..#...#...#.....#\n #..#.....#..#...#...#.###.#\n #..#######..#...#...#.#.#.#\n #..........##...#...#.#####", "output": "870"}] |
Print the number of triples that satisfy the condition.
* * * | s840154665 | Wrong Answer | p03225 | Input is given from Standard Input in the following format:
H W
s_{11}...s_{1W}
:
s_{H1}...s_{HW} | def distance(a, b):
return abs(a[0] - b[0]) + abs(a[1] - b[1])
n = 0
H, W = input().split()
H = int(H)
W = int(W)
r = []
for i in range(H):
r.append(input().split())
stones = []
print(r)
for i in range(H):
for j in range(W):
if r[i][0][j] == "#":
stones.append([j, i])
for i in range(len(stones)):
for j in range(i + 1, len(stones)):
d = distance(stones[i], stones[j])
for k in range(j + 1, len(stones)):
if distance(stones[i], stones[k]) == distance(stones[j], stones[k]) == d:
n += 1
print(stones[i], stones[j], stones[k])
print(n)
| Statement
There are some coins in the xy-plane. The positions of the coins are
represented by a grid of characters with H rows and W columns. If the
character at the i-th row and j-th column, s_{ij}, is `#`, there is one coin
at point (i,j); if that character is `.`, there is no coin at point (i,j).
There are no other coins in the xy-plane.
There is no coin at point (x,y) where 1\leq i\leq H,1\leq j\leq W does not
hold. There is also no coin at point (x,y) where x or y (or both) is not an
integer. Additionally, two or more coins never exist at the same point.
Find the number of triples of different coins that satisfy the following
condition:
* Choosing any two of the three coins would result in the same Manhattan distance between the points where they exist.
Here, the Manhattan distance between points (x,y) and (x',y') is
|x-x'|+|y-y'|. Two triples are considered the same if the only difference
between them is the order of the coins. | [{"input": "5 4\n #.##\n .##.\n #...\n ..##\n ...#", "output": "3\n \n\n((1,1),(1,3),(2,2)),((1,1),(2,2),(3,1)) and ((1,3),(3,1),(4,4)) satisfy the\ncondition.\n\n* * *"}, {"input": "13 27\n ......#.........#.......#..\n #############...#.....###..\n ..............#####...##...\n ...#######......#...#######\n ...#.....#.....###...#...#.\n ...#######....#.#.#.#.###.#\n ..............#.#.#...#.#..\n #############.#.#.#...###..\n #...........#...#...#######\n #..#######..#...#...#.....#\n #..#.....#..#...#...#.###.#\n #..#######..#...#...#.#.#.#\n #..........##...#...#.#####", "output": "870"}] |
Print the number of triples that satisfy the condition.
* * * | s877786671 | Wrong Answer | p03225 | Input is given from Standard Input in the following format:
H W
s_{11}...s_{1W}
:
s_{H1}...s_{HW} | import itertools
import sys
H, W = [int(i) for i in input().split(" ")]
cross = [[0] * (H + W - 1) for _ in range(H + W - 1)]
for i, line in enumerate(sys.stdin):
for j, c in enumerate(line.strip()):
if c == "#":
cross[i + j][i - j + W - 1] = 1
across = [[0] + list(itertools.accumulate(xs)) for xs in cross]
r_cross = [[xs[i] for xs in cross] for i in range(H + W - 1)]
across2 = [[0] + list(itertools.accumulate(xs)) for xs in r_cross]
r = 0
for i in range(H + W - 1):
for j in range(H + W - 1):
if cross[i][j] != 1:
continue
for k in range(j + 1, H + W - 1):
if cross[i][k] == 1:
if i - (k - j) >= 0:
r += across[i - (k - j)][k + 1] - across[i - (k - j)][j]
if i + (k - j) < H + W - 1:
r += across[i + (k - j)][k + 1] - across[i + (k - j)][j]
print(r)
| Statement
There are some coins in the xy-plane. The positions of the coins are
represented by a grid of characters with H rows and W columns. If the
character at the i-th row and j-th column, s_{ij}, is `#`, there is one coin
at point (i,j); if that character is `.`, there is no coin at point (i,j).
There are no other coins in the xy-plane.
There is no coin at point (x,y) where 1\leq i\leq H,1\leq j\leq W does not
hold. There is also no coin at point (x,y) where x or y (or both) is not an
integer. Additionally, two or more coins never exist at the same point.
Find the number of triples of different coins that satisfy the following
condition:
* Choosing any two of the three coins would result in the same Manhattan distance between the points where they exist.
Here, the Manhattan distance between points (x,y) and (x',y') is
|x-x'|+|y-y'|. Two triples are considered the same if the only difference
between them is the order of the coins. | [{"input": "5 4\n #.##\n .##.\n #...\n ..##\n ...#", "output": "3\n \n\n((1,1),(1,3),(2,2)),((1,1),(2,2),(3,1)) and ((1,3),(3,1),(4,4)) satisfy the\ncondition.\n\n* * *"}, {"input": "13 27\n ......#.........#.......#..\n #############...#.....###..\n ..............#####...##...\n ...#######......#...#######\n ...#.....#.....###...#...#.\n ...#######....#.#.#.#.###.#\n ..............#.#.#...#.#..\n #############.#.#.#...###..\n #...........#...#...#######\n #..#######..#...#...#.....#\n #..#.....#..#...#...#.###.#\n #..#######..#...#...#.#.#.#\n #..........##...#...#.#####", "output": "870"}] |
Print one longest subsequence that satisfies the conditions. If multiple
solutions exist, any of them will be accepted.
* * * | s947814498 | Wrong Answer | p02967 | Input is given from Standard Input in the following format:
S | if __name__ == "__main__":
string = input()
result = []
for s in string.split():
if result[-2:] == "AA" or "BB" or "CC":
result = []
else:
result.append(s)
print(result)
| Statement
Given is a string S consisting of `A`,`B`, and `C`.
Consider the (not necessarily contiguous) subsequences x of S that satisfy all
of the following conditions:
* `A`, `B`, and `C` all occur the same number of times in x.
* No two adjacent characters in x are the same.
Among these subsequences, find one of the longest. Here a subsequence of S is
a string obtained by deleting zero or more characters from S. | [{"input": "ABBCBCAB", "output": "ACBCAB\n \n\nConsider the subsequence `ACBCAB` of S. It satisfies the conditions and is one\nof the longest with these properties, along with `ABCBCA`. On the other hand,\nthe subsequences `ABCBCAB` and `ABBCCA` do not satisfy the conditions.\n\n* * *"}, {"input": "ABABABABACACACAC", "output": "BABCAC\n \n\n* * *"}, {"input": "ABCABACBCBABABACBCBCBCBCBCAB", "output": "ACABACABABACBCBCBCBCA\n \n\n* * *"}, {"input": "AAA", "output": "It is possible that only the empty string satisfies the condition."}] |
Print one longest subsequence that satisfies the conditions. If multiple
solutions exist, any of them will be accepted.
* * * | s332281925 | Wrong Answer | p02967 | Input is given from Standard Input in the following format:
S | s = []
print(s)
| Statement
Given is a string S consisting of `A`,`B`, and `C`.
Consider the (not necessarily contiguous) subsequences x of S that satisfy all
of the following conditions:
* `A`, `B`, and `C` all occur the same number of times in x.
* No two adjacent characters in x are the same.
Among these subsequences, find one of the longest. Here a subsequence of S is
a string obtained by deleting zero or more characters from S. | [{"input": "ABBCBCAB", "output": "ACBCAB\n \n\nConsider the subsequence `ACBCAB` of S. It satisfies the conditions and is one\nof the longest with these properties, along with `ABCBCA`. On the other hand,\nthe subsequences `ABCBCAB` and `ABBCCA` do not satisfy the conditions.\n\n* * *"}, {"input": "ABABABABACACACAC", "output": "BABCAC\n \n\n* * *"}, {"input": "ABCABACBCBABABACBCBCBCBCBCAB", "output": "ACABACABABACBCBCBCBCA\n \n\n* * *"}, {"input": "AAA", "output": "It is possible that only the empty string satisfies the condition."}] |
Print one longest subsequence that satisfies the conditions. If multiple
solutions exist, any of them will be accepted.
* * * | s517556855 | Wrong Answer | p02967 | Input is given from Standard Input in the following format:
S | s = input()
a = 0
b = 0
c = 0
for i in range(len(s)):
if s[i] == "A":
a = a + 1
if s[i] == "B":
b = b + 1
if s[i] == "C":
c = c + 1
little = 0
if a <= b:
if a <= c:
little = a
if a >= c:
little = c
else:
if b <= c:
little = b
if b >= c:
little = c
dl = ""
for i in range(little):
dl = "" + dl + "ABC"
print(dl)
| Statement
Given is a string S consisting of `A`,`B`, and `C`.
Consider the (not necessarily contiguous) subsequences x of S that satisfy all
of the following conditions:
* `A`, `B`, and `C` all occur the same number of times in x.
* No two adjacent characters in x are the same.
Among these subsequences, find one of the longest. Here a subsequence of S is
a string obtained by deleting zero or more characters from S. | [{"input": "ABBCBCAB", "output": "ACBCAB\n \n\nConsider the subsequence `ACBCAB` of S. It satisfies the conditions and is one\nof the longest with these properties, along with `ABCBCA`. On the other hand,\nthe subsequences `ABCBCAB` and `ABBCCA` do not satisfy the conditions.\n\n* * *"}, {"input": "ABABABABACACACAC", "output": "BABCAC\n \n\n* * *"}, {"input": "ABCABACBCBABABACBCBCBCBCBCAB", "output": "ACABACABABACBCBCBCBCA\n \n\n* * *"}, {"input": "AAA", "output": "It is possible that only the empty string satisfies the condition."}] |
Print one longest subsequence that satisfies the conditions. If multiple
solutions exist, any of them will be accepted.
* * * | s674324915 | Wrong Answer | p02967 | Input is given from Standard Input in the following format:
S | s = input()
ch = s[0]
for i in range(1, len(s)):
if ch != "":
if s[i] != ch[len(ch) - 1]:
ch += s[i]
else:
ch = ch[0 : len(ch) - 1]
else:
ch = s[i]
print(ch)
| Statement
Given is a string S consisting of `A`,`B`, and `C`.
Consider the (not necessarily contiguous) subsequences x of S that satisfy all
of the following conditions:
* `A`, `B`, and `C` all occur the same number of times in x.
* No two adjacent characters in x are the same.
Among these subsequences, find one of the longest. Here a subsequence of S is
a string obtained by deleting zero or more characters from S. | [{"input": "ABBCBCAB", "output": "ACBCAB\n \n\nConsider the subsequence `ACBCAB` of S. It satisfies the conditions and is one\nof the longest with these properties, along with `ABCBCA`. On the other hand,\nthe subsequences `ABCBCAB` and `ABBCCA` do not satisfy the conditions.\n\n* * *"}, {"input": "ABABABABACACACAC", "output": "BABCAC\n \n\n* * *"}, {"input": "ABCABACBCBABABACBCBCBCBCBCAB", "output": "ACABACABABACBCBCBCBCA\n \n\n* * *"}, {"input": "AAA", "output": "It is possible that only the empty string satisfies the condition."}] |
Print one longest subsequence that satisfies the conditions. If multiple
solutions exist, any of them will be accepted.
* * * | s477667244 | Wrong Answer | p02967 | Input is given from Standard Input in the following format:
S | s = input()
a = [0, 0, 0, 0, 0, 0, 0, 0, 0]
b = ["A", "B", "C", "A", "B", "C", "A", "B", "C"]
c = 0
s.replace("AA", "A")
s.replace("BB", "B")
s.replace("CC", "C")
a[0] = s.count("A")
a[1] = s.count("B")
a[2] = s.count("C")
while a[0] != a[1] or a[1] != a[2]:
m = a.index(max(a[0], a[1], a[2])) + 3
for i in range(m):
if c % 2 == 1:
s.replace(b[m - 1] + b[m] + b[m + 1], b[m - 1] + b[m + 1])
c = c + 1
else:
s.replace(b[m + 1] + b[m] + b[m - 1], b[m + 1] + b[m - 1])
c = c + 1
s.replace("AA", "A")
s.replace("BB", "B")
s.replace("CC", "C")
a[0] = s.count("A")
a[1] = s.count("B")
a[2] = s.count("C")
if a[0] == 0 or a[1] == 0 or a[2] == 0:
s = []
break
print(s)
| Statement
Given is a string S consisting of `A`,`B`, and `C`.
Consider the (not necessarily contiguous) subsequences x of S that satisfy all
of the following conditions:
* `A`, `B`, and `C` all occur the same number of times in x.
* No two adjacent characters in x are the same.
Among these subsequences, find one of the longest. Here a subsequence of S is
a string obtained by deleting zero or more characters from S. | [{"input": "ABBCBCAB", "output": "ACBCAB\n \n\nConsider the subsequence `ACBCAB` of S. It satisfies the conditions and is one\nof the longest with these properties, along with `ABCBCA`. On the other hand,\nthe subsequences `ABCBCAB` and `ABBCCA` do not satisfy the conditions.\n\n* * *"}, {"input": "ABABABABACACACAC", "output": "BABCAC\n \n\n* * *"}, {"input": "ABCABACBCBABABACBCBCBCBCBCAB", "output": "ACABACABABACBCBCBCBCA\n \n\n* * *"}, {"input": "AAA", "output": "It is possible that only the empty string satisfies the condition."}] |
Print one longest subsequence that satisfies the conditions. If multiple
solutions exist, any of them will be accepted.
* * * | s360904397 | Wrong Answer | p02967 | Input is given from Standard Input in the following format:
S | abc = "ABC"
acb = "ACB"
bac = "BAC"
bca = "BCA"
cab = "CAB"
cba = "CBA"
aabbcc = [abc, acb, bac, bca, cab, cba]
inds = []
notinds = []
S = str(input())
char = []
for i in aabbcc:
ind = S.find(i)
if ind > 0:
if ind not in inds:
inds.append(ind)
inds.append(ind + 1)
inds.append(ind + 2)
for i in range(len(S)):
if i not in inds:
notinds.append(i)
for i in S:
char.append(i)
notinds.sort()
notinds.reverse()
for i in notinds:
del char[i]
answer = "".join(char)
print(answer)
| Statement
Given is a string S consisting of `A`,`B`, and `C`.
Consider the (not necessarily contiguous) subsequences x of S that satisfy all
of the following conditions:
* `A`, `B`, and `C` all occur the same number of times in x.
* No two adjacent characters in x are the same.
Among these subsequences, find one of the longest. Here a subsequence of S is
a string obtained by deleting zero or more characters from S. | [{"input": "ABBCBCAB", "output": "ACBCAB\n \n\nConsider the subsequence `ACBCAB` of S. It satisfies the conditions and is one\nof the longest with these properties, along with `ABCBCA`. On the other hand,\nthe subsequences `ABCBCAB` and `ABBCCA` do not satisfy the conditions.\n\n* * *"}, {"input": "ABABABABACACACAC", "output": "BABCAC\n \n\n* * *"}, {"input": "ABCABACBCBABABACBCBCBCBCBCAB", "output": "ACABACABABACBCBCBCBCA\n \n\n* * *"}, {"input": "AAA", "output": "It is possible that only the empty string satisfies the condition."}] |
Print one longest subsequence that satisfies the conditions. If multiple
solutions exist, any of them will be accepted.
* * * | s907138267 | Wrong Answer | p02967 | Input is given from Standard Input in the following format:
S | import re
s = input()
rgxa = re.compile(r"A{2,}")
rgxb = re.compile(r"B{2,}")
rgxc = re.compile(r"C{2,}")
s = re.sub(rgxa, "A", s)
s = re.sub(rgxb, "B", s)
s = re.sub(rgxc, "C", s)
na = s.count("A")
nb = s.count("B")
nc = s.count("C")
while not na == nb == nc:
if max(na, nb, nc) == na:
if "BAC" in s:
s = s.replace("BAC", "BC", 1)
na -= 1
elif "CAB" in s:
s = s.replace("CAB", "CB", 1)
na -= 1
if max(na, nb, nc) == nb:
if "ABC" in s:
s = s.replace("ABC", "AC", 1)
nb -= 1
elif "CBA" in s:
s = s.replace("CBA", "CA", 1)
nb -= 1
if max(na, nb, nc) == nc:
if "ACB" in s:
s = s.replace("ACB", "AB", 1)
nc -= 1
elif "BCA" in s:
s = s.replace("BCA", "BA", 1)
nc -= 1
print(s)
| Statement
Given is a string S consisting of `A`,`B`, and `C`.
Consider the (not necessarily contiguous) subsequences x of S that satisfy all
of the following conditions:
* `A`, `B`, and `C` all occur the same number of times in x.
* No two adjacent characters in x are the same.
Among these subsequences, find one of the longest. Here a subsequence of S is
a string obtained by deleting zero or more characters from S. | [{"input": "ABBCBCAB", "output": "ACBCAB\n \n\nConsider the subsequence `ACBCAB` of S. It satisfies the conditions and is one\nof the longest with these properties, along with `ABCBCA`. On the other hand,\nthe subsequences `ABCBCAB` and `ABBCCA` do not satisfy the conditions.\n\n* * *"}, {"input": "ABABABABACACACAC", "output": "BABCAC\n \n\n* * *"}, {"input": "ABCABACBCBABABACBCBCBCBCBCAB", "output": "ACABACABABACBCBCBCBCA\n \n\n* * *"}, {"input": "AAA", "output": "It is possible that only the empty string satisfies the condition."}] |
Print n integers in a line with spaces in between. The i-th integer should be
b_i.
* * * | s950517481 | Runtime Error | p03675 | Input is given from Standard Input in the following format:
n
a_1 a_2 ... a_n | #!/usr/bin/env python3
n = int(input())
a = input().split()
l = []
r = []
for a_i in a:
r += [a_i]
l, r = r, l
print(*reversed(l), *r)
| Statement
You are given an integer sequence of length n, a_1, ..., a_n. Let us consider
performing the following n operations on an empty sequence b.
The i-th operation is as follows:
1. Append a_i to the end of b.
2. Reverse the order of the elements in b.
Find the sequence b obtained after these n operations. | [{"input": "4\n 1 2 3 4", "output": "4 2 1 3\n \n\n * After step 1 of the first operation, b becomes: 1.\n * After step 2 of the first operation, b becomes: 1.\n * After step 1 of the second operation, b becomes: 1, 2.\n * After step 2 of the second operation, b becomes: 2, 1.\n * After step 1 of the third operation, b becomes: 2, 1, 3.\n * After step 2 of the third operation, b becomes: 3, 1, 2.\n * After step 1 of the fourth operation, b becomes: 3, 1, 2, 4.\n * After step 2 of the fourth operation, b becomes: 4, 2, 1, 3.\n\nThus, the answer is `4 2 1 3`.\n\n* * *"}, {"input": "3\n 1 2 3", "output": "3 1 2\n \n\nAs shown above in Sample Output 1, b becomes 3, 1, 2 after step 2 of the third\noperation. Thus, the answer is `3 1 2`.\n\n* * *"}, {"input": "1\n 1000000000", "output": "1000000000\n \n\n* * *"}, {"input": "6\n 0 6 7 6 7 0", "output": "0 6 6 0 7 7"}] |
Print n integers in a line with spaces in between. The i-th integer should be
b_i.
* * * | s512478214 | Runtime Error | p03675 | Input is given from Standard Input in the following format:
n
a_1 a_2 ... a_n | a
| Statement
You are given an integer sequence of length n, a_1, ..., a_n. Let us consider
performing the following n operations on an empty sequence b.
The i-th operation is as follows:
1. Append a_i to the end of b.
2. Reverse the order of the elements in b.
Find the sequence b obtained after these n operations. | [{"input": "4\n 1 2 3 4", "output": "4 2 1 3\n \n\n * After step 1 of the first operation, b becomes: 1.\n * After step 2 of the first operation, b becomes: 1.\n * After step 1 of the second operation, b becomes: 1, 2.\n * After step 2 of the second operation, b becomes: 2, 1.\n * After step 1 of the third operation, b becomes: 2, 1, 3.\n * After step 2 of the third operation, b becomes: 3, 1, 2.\n * After step 1 of the fourth operation, b becomes: 3, 1, 2, 4.\n * After step 2 of the fourth operation, b becomes: 4, 2, 1, 3.\n\nThus, the answer is `4 2 1 3`.\n\n* * *"}, {"input": "3\n 1 2 3", "output": "3 1 2\n \n\nAs shown above in Sample Output 1, b becomes 3, 1, 2 after step 2 of the third\noperation. Thus, the answer is `3 1 2`.\n\n* * *"}, {"input": "1\n 1000000000", "output": "1000000000\n \n\n* * *"}, {"input": "6\n 0 6 7 6 7 0", "output": "0 6 6 0 7 7"}] |
Print n integers in a line with spaces in between. The i-th integer should be
b_i.
* * * | s369404625 | Accepted | p03675 | Input is given from Standard Input in the following format:
n
a_1 a_2 ... a_n | n = int(input())
xs = [int(i) for i in input().split()]
if n == 1:
print(xs[0])
else:
output1 = [None] * (n // 2)
output2 = [None] * (n // 2)
suf = 1
if n % 2 == 1:
suf = 2
for i in range(n // 2):
output1[i] = xs[i * 2]
if -(-2 * i - suf) <= n:
output2[i] = xs[-2 * i - suf]
if n % 2 == 1:
output1.append(xs[n - 1])
output1.reverse()
output2.reverse()
print(" ".join([str(i) for i in (output1 + output2)]))
else:
print(" ".join([str(i) for i in (output2 + output1)]))
| Statement
You are given an integer sequence of length n, a_1, ..., a_n. Let us consider
performing the following n operations on an empty sequence b.
The i-th operation is as follows:
1. Append a_i to the end of b.
2. Reverse the order of the elements in b.
Find the sequence b obtained after these n operations. | [{"input": "4\n 1 2 3 4", "output": "4 2 1 3\n \n\n * After step 1 of the first operation, b becomes: 1.\n * After step 2 of the first operation, b becomes: 1.\n * After step 1 of the second operation, b becomes: 1, 2.\n * After step 2 of the second operation, b becomes: 2, 1.\n * After step 1 of the third operation, b becomes: 2, 1, 3.\n * After step 2 of the third operation, b becomes: 3, 1, 2.\n * After step 1 of the fourth operation, b becomes: 3, 1, 2, 4.\n * After step 2 of the fourth operation, b becomes: 4, 2, 1, 3.\n\nThus, the answer is `4 2 1 3`.\n\n* * *"}, {"input": "3\n 1 2 3", "output": "3 1 2\n \n\nAs shown above in Sample Output 1, b becomes 3, 1, 2 after step 2 of the third\noperation. Thus, the answer is `3 1 2`.\n\n* * *"}, {"input": "1\n 1000000000", "output": "1000000000\n \n\n* * *"}, {"input": "6\n 0 6 7 6 7 0", "output": "0 6 6 0 7 7"}] |
Print n integers in a line with spaces in between. The i-th integer should be
b_i.
* * * | s919656111 | Wrong Answer | p03675 | Input is given from Standard Input in the following format:
n
a_1 a_2 ... a_n | input()
n = [x for x in input().split()]
nb = n[::-1]
bs = n[::2]
if len(nb) % 2 == 0:
be = nb[::2]
else:
be = nb[::2]
if len(n) == 1:
print(n[0])
else:
print(" ".join(be + bs))
| Statement
You are given an integer sequence of length n, a_1, ..., a_n. Let us consider
performing the following n operations on an empty sequence b.
The i-th operation is as follows:
1. Append a_i to the end of b.
2. Reverse the order of the elements in b.
Find the sequence b obtained after these n operations. | [{"input": "4\n 1 2 3 4", "output": "4 2 1 3\n \n\n * After step 1 of the first operation, b becomes: 1.\n * After step 2 of the first operation, b becomes: 1.\n * After step 1 of the second operation, b becomes: 1, 2.\n * After step 2 of the second operation, b becomes: 2, 1.\n * After step 1 of the third operation, b becomes: 2, 1, 3.\n * After step 2 of the third operation, b becomes: 3, 1, 2.\n * After step 1 of the fourth operation, b becomes: 3, 1, 2, 4.\n * After step 2 of the fourth operation, b becomes: 4, 2, 1, 3.\n\nThus, the answer is `4 2 1 3`.\n\n* * *"}, {"input": "3\n 1 2 3", "output": "3 1 2\n \n\nAs shown above in Sample Output 1, b becomes 3, 1, 2 after step 2 of the third\noperation. Thus, the answer is `3 1 2`.\n\n* * *"}, {"input": "1\n 1000000000", "output": "1000000000\n \n\n* * *"}, {"input": "6\n 0 6 7 6 7 0", "output": "0 6 6 0 7 7"}] |
Print n integers in a line with spaces in between. The i-th integer should be
b_i.
* * * | s769623945 | Runtime Error | p03675 | Input is given from Standard Input in the following format:
n
a_1 a_2 ... a_n | import math
N = int(input())
a = list(map(int, input().split()))
c = []
for i in range(N + 1):
if a[i] in c:
b = a[i]
j = c.index(a[i])
k = i
L = j + N - k
break
c += [a[i]]
Base = N + 1
Minu = 1
for i in range(0, min(L + 1, N + 1)):
print((Base - Minu) % (10**9 + 7))
Base = int(Base * (N - i) / (i + 2))
Minu = int(Minu * (L - i) / (i + 1))
# print(int(math.factorial(N+1)/(math.factorial(i+1)*math.factorial(N-i))-math.factorial(L)/(math.factorial(i)*math.factorial(L-i))))
for i in range(L + 1, N + 1):
print(Base % (10**9 + 7))
Base = int(Base * (N - i) / (i + 2))
| Statement
You are given an integer sequence of length n, a_1, ..., a_n. Let us consider
performing the following n operations on an empty sequence b.
The i-th operation is as follows:
1. Append a_i to the end of b.
2. Reverse the order of the elements in b.
Find the sequence b obtained after these n operations. | [{"input": "4\n 1 2 3 4", "output": "4 2 1 3\n \n\n * After step 1 of the first operation, b becomes: 1.\n * After step 2 of the first operation, b becomes: 1.\n * After step 1 of the second operation, b becomes: 1, 2.\n * After step 2 of the second operation, b becomes: 2, 1.\n * After step 1 of the third operation, b becomes: 2, 1, 3.\n * After step 2 of the third operation, b becomes: 3, 1, 2.\n * After step 1 of the fourth operation, b becomes: 3, 1, 2, 4.\n * After step 2 of the fourth operation, b becomes: 4, 2, 1, 3.\n\nThus, the answer is `4 2 1 3`.\n\n* * *"}, {"input": "3\n 1 2 3", "output": "3 1 2\n \n\nAs shown above in Sample Output 1, b becomes 3, 1, 2 after step 2 of the third\noperation. Thus, the answer is `3 1 2`.\n\n* * *"}, {"input": "1\n 1000000000", "output": "1000000000\n \n\n* * *"}, {"input": "6\n 0 6 7 6 7 0", "output": "0 6 6 0 7 7"}] |
Print the number of elements p_i (1 < i < n) that satisfy the condition.
* * * | s631207761 | Runtime Error | p02988 | Input is given from Standard Input in the following format:
n
p_1 p_2 ... p_n | S = input()
if (
(S[0] == S[1] and S[2] == S[3] and S[0] != S[2])
or (S[0] == S[2] and S[1] == S[3] and S[0] != S[3])
or (S[0] == S[3] and S[1] == S[2] and S[0] != S[1])
):
print("Yes")
else:
print("No")
| Statement
We have a permutation p = {p_1,\ p_2,\ ...,\ p_n} of {1,\ 2,\ ...,\ n}.
Print the number of elements p_i (1 < i < n) that satisfy the following
condition:
* p_i is the second smallest number among the three numbers p_{i - 1}, p_i, and p_{i + 1}. | [{"input": "5\n 1 3 5 4 2", "output": "2\n \n\np_2 = 3 is the second smallest number among p_1 = 1, p_2 = 3, and p_3 = 5.\nAlso, p_4 = 4 is the second smallest number among p_3 = 5, p_4 = 4, and p_5 =\n2. These two elements satisfy the condition.\n\n* * *"}, {"input": "9\n 9 6 3 2 5 8 7 4 1", "output": "5"}] |
Print the number of elements p_i (1 < i < n) that satisfy the condition.
* * * | s169001684 | Accepted | p02988 | Input is given from Standard Input in the following format:
n
p_1 p_2 ... p_n | input()
P = list(map(int, input().split()))
print(sum(A < B < C or C < B < A for A, B, C in zip(P, P[1:], P[2:])))
| Statement
We have a permutation p = {p_1,\ p_2,\ ...,\ p_n} of {1,\ 2,\ ...,\ n}.
Print the number of elements p_i (1 < i < n) that satisfy the following
condition:
* p_i is the second smallest number among the three numbers p_{i - 1}, p_i, and p_{i + 1}. | [{"input": "5\n 1 3 5 4 2", "output": "2\n \n\np_2 = 3 is the second smallest number among p_1 = 1, p_2 = 3, and p_3 = 5.\nAlso, p_4 = 4 is the second smallest number among p_3 = 5, p_4 = 4, and p_5 =\n2. These two elements satisfy the condition.\n\n* * *"}, {"input": "9\n 9 6 3 2 5 8 7 4 1", "output": "5"}] |
Print the number of elements p_i (1 < i < n) that satisfy the condition.
* * * | s767902634 | Wrong Answer | p02988 | Input is given from Standard Input in the following format:
n
p_1 p_2 ... p_n | n = input()
p = list(map(int, input().split()))
print(sorted(p)[1])
| Statement
We have a permutation p = {p_1,\ p_2,\ ...,\ p_n} of {1,\ 2,\ ...,\ n}.
Print the number of elements p_i (1 < i < n) that satisfy the following
condition:
* p_i is the second smallest number among the three numbers p_{i - 1}, p_i, and p_{i + 1}. | [{"input": "5\n 1 3 5 4 2", "output": "2\n \n\np_2 = 3 is the second smallest number among p_1 = 1, p_2 = 3, and p_3 = 5.\nAlso, p_4 = 4 is the second smallest number among p_3 = 5, p_4 = 4, and p_5 =\n2. These two elements satisfy the condition.\n\n* * *"}, {"input": "9\n 9 6 3 2 5 8 7 4 1", "output": "5"}] |
Print the number of elements p_i (1 < i < n) that satisfy the condition.
* * * | s392069951 | Runtime Error | p02988 | Input is given from Standard Input in the following format:
n
p_1 p_2 ... p_n | import math
# inputList=[]
# for i in range(6):
# inputNum = input()
# inputList.append(inputNum)
inputa = input().split()
inputb = input().split()
a = int(inputa[0])
# b = int(inputa[1])
# c = int(inputa[2])
# x = int(inputb[0])
# y = int(inputb[1])
listb = []
listb = [int(n) for n in inputb]
cnt = 0
for i in range(1, a - 1):
if listb[i - 1] < listb[i] and listb[i] < listb[i + 1]:
cnt += 1
elif listb[i - 1] > listb[i] and listb[i] > listb[i + 1]:
cnt += 1
pritn(cnt)
| Statement
We have a permutation p = {p_1,\ p_2,\ ...,\ p_n} of {1,\ 2,\ ...,\ n}.
Print the number of elements p_i (1 < i < n) that satisfy the following
condition:
* p_i is the second smallest number among the three numbers p_{i - 1}, p_i, and p_{i + 1}. | [{"input": "5\n 1 3 5 4 2", "output": "2\n \n\np_2 = 3 is the second smallest number among p_1 = 1, p_2 = 3, and p_3 = 5.\nAlso, p_4 = 4 is the second smallest number among p_3 = 5, p_4 = 4, and p_5 =\n2. These two elements satisfy the condition.\n\n* * *"}, {"input": "9\n 9 6 3 2 5 8 7 4 1", "output": "5"}] |
Print the number of elements p_i (1 < i < n) that satisfy the condition.
* * * | s466634200 | Wrong Answer | p02988 | Input is given from Standard Input in the following format:
n
p_1 p_2 ... p_n | # 132b
N = int(input())
p_list = list(map(int, input().split()))
# pi−1, pi, pi+1の 3 つの数の中で、pi が 2 番目に小さい。
# pi (1<i<n) がいくつあるかを出力してください。
ans = 0
| Statement
We have a permutation p = {p_1,\ p_2,\ ...,\ p_n} of {1,\ 2,\ ...,\ n}.
Print the number of elements p_i (1 < i < n) that satisfy the following
condition:
* p_i is the second smallest number among the three numbers p_{i - 1}, p_i, and p_{i + 1}. | [{"input": "5\n 1 3 5 4 2", "output": "2\n \n\np_2 = 3 is the second smallest number among p_1 = 1, p_2 = 3, and p_3 = 5.\nAlso, p_4 = 4 is the second smallest number among p_3 = 5, p_4 = 4, and p_5 =\n2. These two elements satisfy the condition.\n\n* * *"}, {"input": "9\n 9 6 3 2 5 8 7 4 1", "output": "5"}] |
Print the number of elements p_i (1 < i < n) that satisfy the condition.
* * * | s732890771 | Wrong Answer | p02988 | Input is given from Standard Input in the following format:
n
p_1 p_2 ... p_n | _, p = open(0)
p = p.split()
print(sum(sorted(a)[1] == a[1] for a in zip(p, p[1:], p[2:])))
| Statement
We have a permutation p = {p_1,\ p_2,\ ...,\ p_n} of {1,\ 2,\ ...,\ n}.
Print the number of elements p_i (1 < i < n) that satisfy the following
condition:
* p_i is the second smallest number among the three numbers p_{i - 1}, p_i, and p_{i + 1}. | [{"input": "5\n 1 3 5 4 2", "output": "2\n \n\np_2 = 3 is the second smallest number among p_1 = 1, p_2 = 3, and p_3 = 5.\nAlso, p_4 = 4 is the second smallest number among p_3 = 5, p_4 = 4, and p_5 =\n2. These two elements satisfy the condition.\n\n* * *"}, {"input": "9\n 9 6 3 2 5 8 7 4 1", "output": "5"}] |
Print the number of elements p_i (1 < i < n) that satisfy the condition.
* * * | s539535528 | Runtime Error | p02988 | Input is given from Standard Input in the following format:
n
p_1 p_2 ... p_n | s = input()
all[20]
for val int range(s):
all[val] = input()
count = 0
for val in range(s - 2)
if all[val] < all[val + 1] and all[val + 1] < all[val + 2]
count += 1 | Statement
We have a permutation p = {p_1,\ p_2,\ ...,\ p_n} of {1,\ 2,\ ...,\ n}.
Print the number of elements p_i (1 < i < n) that satisfy the following
condition:
* p_i is the second smallest number among the three numbers p_{i - 1}, p_i, and p_{i + 1}. | [{"input": "5\n 1 3 5 4 2", "output": "2\n \n\np_2 = 3 is the second smallest number among p_1 = 1, p_2 = 3, and p_3 = 5.\nAlso, p_4 = 4 is the second smallest number among p_3 = 5, p_4 = 4, and p_5 =\n2. These two elements satisfy the condition.\n\n* * *"}, {"input": "9\n 9 6 3 2 5 8 7 4 1", "output": "5"}] |
Print the number of elements p_i (1 < i < n) that satisfy the condition.
* * * | s219448657 | Wrong Answer | p02988 | Input is given from Standard Input in the following format:
n
p_1 p_2 ... p_n | def second_smallest(numbers):
m1, m2 = float("inf"), float("inf")
for x in numbers:
if x <= m1:
m1, m2 = x, m1
elif x < m2:
m2 = x
return m2
n = int(input())
numbers = input()
numbers = [int(x) for x in numbers.split()]
print(numbers)
smallest = set()
for i in range(len(numbers)):
if (i + 2) >= len(numbers):
break
min_number = second_smallest([numbers[i], numbers[i + 1], numbers[i + 2]])
if not (min_number in smallest):
smallest.add(min_number)
print(len(smallest))
| Statement
We have a permutation p = {p_1,\ p_2,\ ...,\ p_n} of {1,\ 2,\ ...,\ n}.
Print the number of elements p_i (1 < i < n) that satisfy the following
condition:
* p_i is the second smallest number among the three numbers p_{i - 1}, p_i, and p_{i + 1}. | [{"input": "5\n 1 3 5 4 2", "output": "2\n \n\np_2 = 3 is the second smallest number among p_1 = 1, p_2 = 3, and p_3 = 5.\nAlso, p_4 = 4 is the second smallest number among p_3 = 5, p_4 = 4, and p_5 =\n2. These two elements satisfy the condition.\n\n* * *"}, {"input": "9\n 9 6 3 2 5 8 7 4 1", "output": "5"}] |
Print the largest possible sum of the integers written on the blackboard after
K operations by E869220.
* * * | s264631037 | Accepted | p03360 | Input is given from Standard Input in the following format:
A B C
K | # region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import (
accumulate,
groupby,
product,
permutations,
combinations,
combinations_with_replacement,
)
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**7)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float("inf")
MOD = 10**9 + 7
PI = math.pi
# endregion
A, B, C = ri_()
K = ri()
print(A + B + C - max(A, B, C) + max(A, B, C) * (2**K))
| Statement
There are three positive integers A, B and C written on a blackboard. E869120
performs the following operation K times:
* Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.
What is the largest possible sum of the integers written on the blackboard
after K operations? | [{"input": "5 3 11\n 1", "output": "30\n \n\nIn this sample, 5, 3, 11 are initially written on the blackboard, and E869120\ncan perform the operation once. \nThere are three choices:\n\n 1. Double 5: The integers written on the board after the operation are 10, 3, 11.\n 2. Double 3: The integers written on the board after the operation are 5, 6, 11.\n 3. Double 11: The integers written on the board after the operation are 5, 3, 22.\n\nIf he chooses 3., the sum of the integers written on the board afterwards is 5\n+ 3 + 22 = 30, which is the largest among 1. through 3.\n\n* * *"}, {"input": "3 3 4\n 2", "output": "22\n \n\nE869120 can perform the operation twice. The sum of the integers eventually\nwritten on the blackboard is maximized as follows:\n\n * First, double 4. The integers written on the board are now 3, 3, 8. \n * Next, double 8. The integers written on the board are now 3, 3, 16. \n\nThen, the sum of the integers eventually written on the blackboard is 3 + 3 +\n16 = 22."}] |
Print the largest possible sum of the integers written on the blackboard after
K operations by E869220.
* * * | s032418401 | Accepted | p03360 | Input is given from Standard Input in the following format:
A B C
K | #!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI():
return list(map(int, stdin.readline().split()))
def LF():
return list(map(float, stdin.readline().split()))
def LI_():
return list(map(lambda x: int(x) - 1, stdin.readline().split()))
def II():
return int(stdin.readline())
def IF():
return float(stdin.readline())
def LS():
return list(map(list, stdin.readline().split()))
def S():
return list(stdin.readline().rstrip())
def IR(n):
return [II() for _ in range(n)]
def LIR(n):
return [LI() for _ in range(n)]
def FR(n):
return [IF() for _ in range(n)]
def LFR(n):
return [LI() for _ in range(n)]
def LIR_(n):
return [LI_() for _ in range(n)]
def SR(n):
return [S() for _ in range(n)]
def LSR(n):
return [LS() for _ in range(n)]
mod = 1000000007
# A
def A():
a, b = LI()
if a <= b:
print(a)
else:
print(a - 1)
return
# B
def B():
a, b, c = LI()
k = II()
print(a + b + c + max(a, b, c) * ((2**k) - 1))
return
# C
def C():
return
# D
def D():
n = II()
ans = []
sosu = [2]
i = 2
while len(ans) != n:
for k in sosu:
if i % k == 0:
i += 1
break
else:
sosu.append(i)
if i % 5 == 1:
ans.append(i)
i += 1
for i in ans:
print(i, end=" ")
print()
return
# Solve
if __name__ == "__main__":
B()
| Statement
There are three positive integers A, B and C written on a blackboard. E869120
performs the following operation K times:
* Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.
What is the largest possible sum of the integers written on the blackboard
after K operations? | [{"input": "5 3 11\n 1", "output": "30\n \n\nIn this sample, 5, 3, 11 are initially written on the blackboard, and E869120\ncan perform the operation once. \nThere are three choices:\n\n 1. Double 5: The integers written on the board after the operation are 10, 3, 11.\n 2. Double 3: The integers written on the board after the operation are 5, 6, 11.\n 3. Double 11: The integers written on the board after the operation are 5, 3, 22.\n\nIf he chooses 3., the sum of the integers written on the board afterwards is 5\n+ 3 + 22 = 30, which is the largest among 1. through 3.\n\n* * *"}, {"input": "3 3 4\n 2", "output": "22\n \n\nE869120 can perform the operation twice. The sum of the integers eventually\nwritten on the blackboard is maximized as follows:\n\n * First, double 4. The integers written on the board are now 3, 3, 8. \n * Next, double 8. The integers written on the board are now 3, 3, 16. \n\nThen, the sum of the integers eventually written on the blackboard is 3 + 3 +\n16 = 22."}] |
Print the largest possible sum of the integers written on the blackboard after
K operations by E869220.
* * * | s916034155 | Accepted | p03360 | Input is given from Standard Input in the following format:
A B C
K | import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque
sys.setrecursionlimit(10000000)
ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]
iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]
lcm = lambda x, y: (x * y) // math.gcd(x, y)
MOD = 10**9 + 7
MAX = float("inf")
def main():
if os.getenv("LOCAL"):
sys.stdin = open("input.txt", "r")
ABC = il()
N = ii()
m = max(ABC)
for n in range(N):
m *= 2
print(sum(ABC) + m - max(ABC))
if __name__ == "__main__":
main()
| Statement
There are three positive integers A, B and C written on a blackboard. E869120
performs the following operation K times:
* Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.
What is the largest possible sum of the integers written on the blackboard
after K operations? | [{"input": "5 3 11\n 1", "output": "30\n \n\nIn this sample, 5, 3, 11 are initially written on the blackboard, and E869120\ncan perform the operation once. \nThere are three choices:\n\n 1. Double 5: The integers written on the board after the operation are 10, 3, 11.\n 2. Double 3: The integers written on the board after the operation are 5, 6, 11.\n 3. Double 11: The integers written on the board after the operation are 5, 3, 22.\n\nIf he chooses 3., the sum of the integers written on the board afterwards is 5\n+ 3 + 22 = 30, which is the largest among 1. through 3.\n\n* * *"}, {"input": "3 3 4\n 2", "output": "22\n \n\nE869120 can perform the operation twice. The sum of the integers eventually\nwritten on the blackboard is maximized as follows:\n\n * First, double 4. The integers written on the board are now 3, 3, 8. \n * Next, double 8. The integers written on the board are now 3, 3, 16. \n\nThen, the sum of the integers eventually written on the blackboard is 3 + 3 +\n16 = 22."}] |
Print the largest possible sum of the integers written on the blackboard after
K operations by E869220.
* * * | s630131401 | Wrong Answer | p03360 | Input is given from Standard Input in the following format:
A B C
K | #!/usr/bin/env python3
import sys
# import time
# import math
# import numpy as np
# import scipy.sparse.csgraph as cs # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall
# import random # random, uniform, randint, randrange, shuffle, sample
# import string # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits
# import re # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from collections import deque # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict # subclass of dict. defaultdict(facroty)
# from collections import Counter # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from datetime import date, datetime # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj
# from datetime.datetime import strptime # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj
# from datetime import timedelta # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available.
# from copy import copy, deepcopy # use deepcopy to copy multi-dimentional matrix without reference
# from functools import reduce # reduce(f, iter[, init])
# from functools import lru_cache # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate # accumulate(iter[, f])
# from operator import itemgetter # itemgetter(1), itemgetter('key')
# from fractions import gcd # for Python 3.4 (previous contest @AtCoder)
def main():
mod = 1000000007 # 10^9+7
inf = float("inf") # sys.float_info.max = 1.79...e+308
# inf = 2 ** 64 - 1 # (for fast JIT compile in PyPy) 1.84...e+19
sys.setrecursionlimit(10**6) # 1000 -> 1000000
def input():
return sys.stdin.readline().rstrip()
def ii():
return int(input())
def mi():
return map(int, input().split())
def mi_0():
return map(lambda x: int(x) - 1, input().split())
def lmi():
return list(map(int, input().split()))
def lmi_0():
return list(map(lambda x: int(x) - 1, input().split()))
def li():
return list(input())
a, b, c = mi()
k = ii()
print(a + b + c + (pow(2, k) - 1) * c)
if __name__ == "__main__":
main()
| Statement
There are three positive integers A, B and C written on a blackboard. E869120
performs the following operation K times:
* Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.
What is the largest possible sum of the integers written on the blackboard
after K operations? | [{"input": "5 3 11\n 1", "output": "30\n \n\nIn this sample, 5, 3, 11 are initially written on the blackboard, and E869120\ncan perform the operation once. \nThere are three choices:\n\n 1. Double 5: The integers written on the board after the operation are 10, 3, 11.\n 2. Double 3: The integers written on the board after the operation are 5, 6, 11.\n 3. Double 11: The integers written on the board after the operation are 5, 3, 22.\n\nIf he chooses 3., the sum of the integers written on the board afterwards is 5\n+ 3 + 22 = 30, which is the largest among 1. through 3.\n\n* * *"}, {"input": "3 3 4\n 2", "output": "22\n \n\nE869120 can perform the operation twice. The sum of the integers eventually\nwritten on the blackboard is maximized as follows:\n\n * First, double 4. The integers written on the board are now 3, 3, 8. \n * Next, double 8. The integers written on the board are now 3, 3, 16. \n\nThen, the sum of the integers eventually written on the blackboard is 3 + 3 +\n16 = 22."}] |
Print the largest possible sum of the integers written on the blackboard after
K operations by E869220.
* * * | s815110491 | Accepted | p03360 | Input is given from Standard Input in the following format:
A B C
K | (*abc,) = map(int, input().split())
print(sum(abc) + max(abc) * ((2 ** int(input())) - 1))
| Statement
There are three positive integers A, B and C written on a blackboard. E869120
performs the following operation K times:
* Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.
What is the largest possible sum of the integers written on the blackboard
after K operations? | [{"input": "5 3 11\n 1", "output": "30\n \n\nIn this sample, 5, 3, 11 are initially written on the blackboard, and E869120\ncan perform the operation once. \nThere are three choices:\n\n 1. Double 5: The integers written on the board after the operation are 10, 3, 11.\n 2. Double 3: The integers written on the board after the operation are 5, 6, 11.\n 3. Double 11: The integers written on the board after the operation are 5, 3, 22.\n\nIf he chooses 3., the sum of the integers written on the board afterwards is 5\n+ 3 + 22 = 30, which is the largest among 1. through 3.\n\n* * *"}, {"input": "3 3 4\n 2", "output": "22\n \n\nE869120 can perform the operation twice. The sum of the integers eventually\nwritten on the blackboard is maximized as follows:\n\n * First, double 4. The integers written on the board are now 3, 3, 8. \n * Next, double 8. The integers written on the board are now 3, 3, 16. \n\nThen, the sum of the integers eventually written on the blackboard is 3 + 3 +\n16 = 22."}] |
Print the largest possible sum of the integers written on the blackboard after
K operations by E869220.
* * * | s446479711 | Accepted | p03360 | Input is given from Standard Input in the following format:
A B C
K | *x, k = map(int, open(0).read().split())
print((2**k - 1) * max(x) + sum(x))
| Statement
There are three positive integers A, B and C written on a blackboard. E869120
performs the following operation K times:
* Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.
What is the largest possible sum of the integers written on the blackboard
after K operations? | [{"input": "5 3 11\n 1", "output": "30\n \n\nIn this sample, 5, 3, 11 are initially written on the blackboard, and E869120\ncan perform the operation once. \nThere are three choices:\n\n 1. Double 5: The integers written on the board after the operation are 10, 3, 11.\n 2. Double 3: The integers written on the board after the operation are 5, 6, 11.\n 3. Double 11: The integers written on the board after the operation are 5, 3, 22.\n\nIf he chooses 3., the sum of the integers written on the board afterwards is 5\n+ 3 + 22 = 30, which is the largest among 1. through 3.\n\n* * *"}, {"input": "3 3 4\n 2", "output": "22\n \n\nE869120 can perform the operation twice. The sum of the integers eventually\nwritten on the blackboard is maximized as follows:\n\n * First, double 4. The integers written on the board are now 3, 3, 8. \n * Next, double 8. The integers written on the board are now 3, 3, 16. \n\nThen, the sum of the integers eventually written on the blackboard is 3 + 3 +\n16 = 22."}] |
Print the largest possible sum of the integers written on the blackboard after
K operations by E869220.
* * * | s568108786 | Accepted | p03360 | Input is given from Standard Input in the following format:
A B C
K | a = sorted(map(int, input().split()))[::-1]
print(a[0] * (2 ** (int(input()))) + sum(a) - a[0])
| Statement
There are three positive integers A, B and C written on a blackboard. E869120
performs the following operation K times:
* Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.
What is the largest possible sum of the integers written on the blackboard
after K operations? | [{"input": "5 3 11\n 1", "output": "30\n \n\nIn this sample, 5, 3, 11 are initially written on the blackboard, and E869120\ncan perform the operation once. \nThere are three choices:\n\n 1. Double 5: The integers written on the board after the operation are 10, 3, 11.\n 2. Double 3: The integers written on the board after the operation are 5, 6, 11.\n 3. Double 11: The integers written on the board after the operation are 5, 3, 22.\n\nIf he chooses 3., the sum of the integers written on the board afterwards is 5\n+ 3 + 22 = 30, which is the largest among 1. through 3.\n\n* * *"}, {"input": "3 3 4\n 2", "output": "22\n \n\nE869120 can perform the operation twice. The sum of the integers eventually\nwritten on the blackboard is maximized as follows:\n\n * First, double 4. The integers written on the board are now 3, 3, 8. \n * Next, double 8. The integers written on the board are now 3, 3, 16. \n\nThen, the sum of the integers eventually written on the blackboard is 3 + 3 +\n16 = 22."}] |
Print the largest possible sum of the integers written on the blackboard after
K operations by E869220.
* * * | s404194636 | Runtime Error | p03360 | Input is given from Standard Input in the following format:
A B C
K | 5 3 11
1
---
30
===
3 3 4
2
---
22
===
| Statement
There are three positive integers A, B and C written on a blackboard. E869120
performs the following operation K times:
* Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.
What is the largest possible sum of the integers written on the blackboard
after K operations? | [{"input": "5 3 11\n 1", "output": "30\n \n\nIn this sample, 5, 3, 11 are initially written on the blackboard, and E869120\ncan perform the operation once. \nThere are three choices:\n\n 1. Double 5: The integers written on the board after the operation are 10, 3, 11.\n 2. Double 3: The integers written on the board after the operation are 5, 6, 11.\n 3. Double 11: The integers written on the board after the operation are 5, 3, 22.\n\nIf he chooses 3., the sum of the integers written on the board afterwards is 5\n+ 3 + 22 = 30, which is the largest among 1. through 3.\n\n* * *"}, {"input": "3 3 4\n 2", "output": "22\n \n\nE869120 can perform the operation twice. The sum of the integers eventually\nwritten on the blackboard is maximized as follows:\n\n * First, double 4. The integers written on the board are now 3, 3, 8. \n * Next, double 8. The integers written on the board are now 3, 3, 16. \n\nThen, the sum of the integers eventually written on the blackboard is 3 + 3 +\n16 = 22."}] |
Print the largest possible sum of the integers written on the blackboard after
K operations by E869220.
* * * | s065829291 | Runtime Error | p03360 | Input is given from Standard Input in the following format:
A B C
K | a=list(map(int,input().split()))
b=int(input())
a.sort()
print(a[0]+a[1]+(a[2]*2**b) | Statement
There are three positive integers A, B and C written on a blackboard. E869120
performs the following operation K times:
* Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.
What is the largest possible sum of the integers written on the blackboard
after K operations? | [{"input": "5 3 11\n 1", "output": "30\n \n\nIn this sample, 5, 3, 11 are initially written on the blackboard, and E869120\ncan perform the operation once. \nThere are three choices:\n\n 1. Double 5: The integers written on the board after the operation are 10, 3, 11.\n 2. Double 3: The integers written on the board after the operation are 5, 6, 11.\n 3. Double 11: The integers written on the board after the operation are 5, 3, 22.\n\nIf he chooses 3., the sum of the integers written on the board afterwards is 5\n+ 3 + 22 = 30, which is the largest among 1. through 3.\n\n* * *"}, {"input": "3 3 4\n 2", "output": "22\n \n\nE869120 can perform the operation twice. The sum of the integers eventually\nwritten on the blackboard is maximized as follows:\n\n * First, double 4. The integers written on the board are now 3, 3, 8. \n * Next, double 8. The integers written on the board are now 3, 3, 16. \n\nThen, the sum of the integers eventually written on the blackboard is 3 + 3 +\n16 = 22."}] |
Print the largest possible sum of the integers written on the blackboard after
K operations by E869220.
* * * | s707142828 | Runtime Error | p03360 | Input is given from Standard Input in the following format:
A B C
K | a=list(map(int,input().split()))
b=int(input())
a.sort()
print(a[0]+a[1]+(a[2]*(2**b)) | Statement
There are three positive integers A, B and C written on a blackboard. E869120
performs the following operation K times:
* Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.
What is the largest possible sum of the integers written on the blackboard
after K operations? | [{"input": "5 3 11\n 1", "output": "30\n \n\nIn this sample, 5, 3, 11 are initially written on the blackboard, and E869120\ncan perform the operation once. \nThere are three choices:\n\n 1. Double 5: The integers written on the board after the operation are 10, 3, 11.\n 2. Double 3: The integers written on the board after the operation are 5, 6, 11.\n 3. Double 11: The integers written on the board after the operation are 5, 3, 22.\n\nIf he chooses 3., the sum of the integers written on the board afterwards is 5\n+ 3 + 22 = 30, which is the largest among 1. through 3.\n\n* * *"}, {"input": "3 3 4\n 2", "output": "22\n \n\nE869120 can perform the operation twice. The sum of the integers eventually\nwritten on the blackboard is maximized as follows:\n\n * First, double 4. The integers written on the board are now 3, 3, 8. \n * Next, double 8. The integers written on the board are now 3, 3, 16. \n\nThen, the sum of the integers eventually written on the blackboard is 3 + 3 +\n16 = 22."}] |
Print the largest possible sum of the integers written on the blackboard after
K operations by E869220.
* * * | s485688648 | Runtime Error | p03360 | Input is given from Standard Input in the following format:
A B C
K | p = input
a = [i for i in p().split()]
print(sum(a) + max(a) * 2 ** int(p()))
| Statement
There are three positive integers A, B and C written on a blackboard. E869120
performs the following operation K times:
* Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.
What is the largest possible sum of the integers written on the blackboard
after K operations? | [{"input": "5 3 11\n 1", "output": "30\n \n\nIn this sample, 5, 3, 11 are initially written on the blackboard, and E869120\ncan perform the operation once. \nThere are three choices:\n\n 1. Double 5: The integers written on the board after the operation are 10, 3, 11.\n 2. Double 3: The integers written on the board after the operation are 5, 6, 11.\n 3. Double 11: The integers written on the board after the operation are 5, 3, 22.\n\nIf he chooses 3., the sum of the integers written on the board afterwards is 5\n+ 3 + 22 = 30, which is the largest among 1. through 3.\n\n* * *"}, {"input": "3 3 4\n 2", "output": "22\n \n\nE869120 can perform the operation twice. The sum of the integers eventually\nwritten on the blackboard is maximized as follows:\n\n * First, double 4. The integers written on the board are now 3, 3, 8. \n * Next, double 8. The integers written on the board are now 3, 3, 16. \n\nThen, the sum of the integers eventually written on the blackboard is 3 + 3 +\n16 = 22."}] |
Print the largest possible sum of the integers written on the blackboard after
K operations by E869220.
* * * | s718607853 | Runtime Error | p03360 | Input is given from Standard Input in the following format:
A B C
K | a, b, c = map(int, input().split(' '))
N = int(input())
max_ = max([a, b, c]
print(a+b+c+max_**N-max_) | Statement
There are three positive integers A, B and C written on a blackboard. E869120
performs the following operation K times:
* Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.
What is the largest possible sum of the integers written on the blackboard
after K operations? | [{"input": "5 3 11\n 1", "output": "30\n \n\nIn this sample, 5, 3, 11 are initially written on the blackboard, and E869120\ncan perform the operation once. \nThere are three choices:\n\n 1. Double 5: The integers written on the board after the operation are 10, 3, 11.\n 2. Double 3: The integers written on the board after the operation are 5, 6, 11.\n 3. Double 11: The integers written on the board after the operation are 5, 3, 22.\n\nIf he chooses 3., the sum of the integers written on the board afterwards is 5\n+ 3 + 22 = 30, which is the largest among 1. through 3.\n\n* * *"}, {"input": "3 3 4\n 2", "output": "22\n \n\nE869120 can perform the operation twice. The sum of the integers eventually\nwritten on the blackboard is maximized as follows:\n\n * First, double 4. The integers written on the board are now 3, 3, 8. \n * Next, double 8. The integers written on the board are now 3, 3, 16. \n\nThen, the sum of the integers eventually written on the blackboard is 3 + 3 +\n16 = 22."}] |
Print the largest possible sum of the integers written on the blackboard after
K operations by E869220.
* * * | s670594869 | Accepted | p03360 | Input is given from Standard Input in the following format:
A B C
K | import sys
stdin = sys.stdin
sys.setrecursionlimit(10**5)
def li():
return map(int, stdin.readline().split())
def li_():
return map(lambda x: int(x) - 1, stdin.readline().split())
def lf():
return map(float, stdin.readline().split())
def ls():
return stdin.readline().split()
def ns():
return stdin.readline().rstrip()
def lc():
return list(ns())
def ni():
return int(stdin.readline())
def nf():
return float(stdin.readline())
a = list(li())
k = ni()
a.sort()
for i in range(k):
a[2] *= 2
a.sort()
print(sum(a))
| Statement
There are three positive integers A, B and C written on a blackboard. E869120
performs the following operation K times:
* Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.
What is the largest possible sum of the integers written on the blackboard
after K operations? | [{"input": "5 3 11\n 1", "output": "30\n \n\nIn this sample, 5, 3, 11 are initially written on the blackboard, and E869120\ncan perform the operation once. \nThere are three choices:\n\n 1. Double 5: The integers written on the board after the operation are 10, 3, 11.\n 2. Double 3: The integers written on the board after the operation are 5, 6, 11.\n 3. Double 11: The integers written on the board after the operation are 5, 3, 22.\n\nIf he chooses 3., the sum of the integers written on the board afterwards is 5\n+ 3 + 22 = 30, which is the largest among 1. through 3.\n\n* * *"}, {"input": "3 3 4\n 2", "output": "22\n \n\nE869120 can perform the operation twice. The sum of the integers eventually\nwritten on the blackboard is maximized as follows:\n\n * First, double 4. The integers written on the board are now 3, 3, 8. \n * Next, double 8. The integers written on the board are now 3, 3, 16. \n\nThen, the sum of the integers eventually written on the blackboard is 3 + 3 +\n16 = 22."}] |
Print the largest possible sum of the integers written on the blackboard after
K operations by E869220.
* * * | s139965039 | Accepted | p03360 | Input is given from Standard Input in the following format:
A B C
K | A, B, C = map(int, input().split())
K = int(input())
if A <= B and B <= C:
print(A + B + C * (2**K))
elif C <= A and A <= B:
print(A + C + B * (2**K))
elif B <= C and C <= A:
print(B + C + A * (2**K))
elif A <= C and C <= B:
print(A + C + B * (2**K))
elif B <= A and A <= C:
print(B + A + C * (2**K))
elif C <= B and B <= A:
print(C + B + A * (2**K))
| Statement
There are three positive integers A, B and C written on a blackboard. E869120
performs the following operation K times:
* Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.
What is the largest possible sum of the integers written on the blackboard
after K operations? | [{"input": "5 3 11\n 1", "output": "30\n \n\nIn this sample, 5, 3, 11 are initially written on the blackboard, and E869120\ncan perform the operation once. \nThere are three choices:\n\n 1. Double 5: The integers written on the board after the operation are 10, 3, 11.\n 2. Double 3: The integers written on the board after the operation are 5, 6, 11.\n 3. Double 11: The integers written on the board after the operation are 5, 3, 22.\n\nIf he chooses 3., the sum of the integers written on the board afterwards is 5\n+ 3 + 22 = 30, which is the largest among 1. through 3.\n\n* * *"}, {"input": "3 3 4\n 2", "output": "22\n \n\nE869120 can perform the operation twice. The sum of the integers eventually\nwritten on the blackboard is maximized as follows:\n\n * First, double 4. The integers written on the board are now 3, 3, 8. \n * Next, double 8. The integers written on the board are now 3, 3, 16. \n\nThen, the sum of the integers eventually written on the blackboard is 3 + 3 +\n16 = 22."}] |
Print the largest possible sum of the integers written on the blackboard after
K operations by E869220.
* * * | s102992368 | Runtime Error | p03360 | Input is given from Standard Input in the following format:
A B C
K | A,B,C = map(int,input().split())
K = int(input())
L = max(A,B,C)
if L ==A:
print((A*(2**K))+B+C
elif L ==B:
print(A+(B*(2**K))+C)
else:
print(A+B+(C*(2**K))) | Statement
There are three positive integers A, B and C written on a blackboard. E869120
performs the following operation K times:
* Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.
What is the largest possible sum of the integers written on the blackboard
after K operations? | [{"input": "5 3 11\n 1", "output": "30\n \n\nIn this sample, 5, 3, 11 are initially written on the blackboard, and E869120\ncan perform the operation once. \nThere are three choices:\n\n 1. Double 5: The integers written on the board after the operation are 10, 3, 11.\n 2. Double 3: The integers written on the board after the operation are 5, 6, 11.\n 3. Double 11: The integers written on the board after the operation are 5, 3, 22.\n\nIf he chooses 3., the sum of the integers written on the board afterwards is 5\n+ 3 + 22 = 30, which is the largest among 1. through 3.\n\n* * *"}, {"input": "3 3 4\n 2", "output": "22\n \n\nE869120 can perform the operation twice. The sum of the integers eventually\nwritten on the blackboard is maximized as follows:\n\n * First, double 4. The integers written on the board are now 3, 3, 8. \n * Next, double 8. The integers written on the board are now 3, 3, 16. \n\nThen, the sum of the integers eventually written on the blackboard is 3 + 3 +\n16 = 22."}] |
Print the largest possible sum of the integers written on the blackboard after
K operations by E869220.
* * * | s622461003 | Wrong Answer | p03360 | Input is given from Standard Input in the following format:
A B C
K | a = input().split()
a = [int(s) for s in a]
k = int(input())
maxi = int(max(a))
ans = 0 - maxi
maxi = maxi * k * 2
for i in a:
ans = ans + int(i)
print(str(maxi + ans))
| Statement
There are three positive integers A, B and C written on a blackboard. E869120
performs the following operation K times:
* Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.
What is the largest possible sum of the integers written on the blackboard
after K operations? | [{"input": "5 3 11\n 1", "output": "30\n \n\nIn this sample, 5, 3, 11 are initially written on the blackboard, and E869120\ncan perform the operation once. \nThere are three choices:\n\n 1. Double 5: The integers written on the board after the operation are 10, 3, 11.\n 2. Double 3: The integers written on the board after the operation are 5, 6, 11.\n 3. Double 11: The integers written on the board after the operation are 5, 3, 22.\n\nIf he chooses 3., the sum of the integers written on the board afterwards is 5\n+ 3 + 22 = 30, which is the largest among 1. through 3.\n\n* * *"}, {"input": "3 3 4\n 2", "output": "22\n \n\nE869120 can perform the operation twice. The sum of the integers eventually\nwritten on the blackboard is maximized as follows:\n\n * First, double 4. The integers written on the board are now 3, 3, 8. \n * Next, double 8. The integers written on the board are now 3, 3, 16. \n\nThen, the sum of the integers eventually written on the blackboard is 3 + 3 +\n16 = 22."}] |
Print the largest possible sum of the integers written on the blackboard after
K operations by E869220.
* * * | s211689534 | Accepted | p03360 | Input is given from Standard Input in the following format:
A B C
K | (*x,) = map(int, input().split())
print(sum(x) + max(x) * (2 ** int(input()) - 1))
| Statement
There are three positive integers A, B and C written on a blackboard. E869120
performs the following operation K times:
* Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.
What is the largest possible sum of the integers written on the blackboard
after K operations? | [{"input": "5 3 11\n 1", "output": "30\n \n\nIn this sample, 5, 3, 11 are initially written on the blackboard, and E869120\ncan perform the operation once. \nThere are three choices:\n\n 1. Double 5: The integers written on the board after the operation are 10, 3, 11.\n 2. Double 3: The integers written on the board after the operation are 5, 6, 11.\n 3. Double 11: The integers written on the board after the operation are 5, 3, 22.\n\nIf he chooses 3., the sum of the integers written on the board afterwards is 5\n+ 3 + 22 = 30, which is the largest among 1. through 3.\n\n* * *"}, {"input": "3 3 4\n 2", "output": "22\n \n\nE869120 can perform the operation twice. The sum of the integers eventually\nwritten on the blackboard is maximized as follows:\n\n * First, double 4. The integers written on the board are now 3, 3, 8. \n * Next, double 8. The integers written on the board are now 3, 3, 16. \n\nThen, the sum of the integers eventually written on the blackboard is 3 + 3 +\n16 = 22."}] |
Print the largest possible sum of the integers written on the blackboard after
K operations by E869220.
* * * | s440049888 | Runtime Error | p03360 | Input is given from Standard Input in the following format:
A B C
K | A,B,C=map(int,input().split())
K=int(input())
print(A+B+C+max(A,B,C)*(2**K-1) | Statement
There are three positive integers A, B and C written on a blackboard. E869120
performs the following operation K times:
* Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.
What is the largest possible sum of the integers written on the blackboard
after K operations? | [{"input": "5 3 11\n 1", "output": "30\n \n\nIn this sample, 5, 3, 11 are initially written on the blackboard, and E869120\ncan perform the operation once. \nThere are three choices:\n\n 1. Double 5: The integers written on the board after the operation are 10, 3, 11.\n 2. Double 3: The integers written on the board after the operation are 5, 6, 11.\n 3. Double 11: The integers written on the board after the operation are 5, 3, 22.\n\nIf he chooses 3., the sum of the integers written on the board afterwards is 5\n+ 3 + 22 = 30, which is the largest among 1. through 3.\n\n* * *"}, {"input": "3 3 4\n 2", "output": "22\n \n\nE869120 can perform the operation twice. The sum of the integers eventually\nwritten on the blackboard is maximized as follows:\n\n * First, double 4. The integers written on the board are now 3, 3, 8. \n * Next, double 8. The integers written on the board are now 3, 3, 16. \n\nThen, the sum of the integers eventually written on the blackboard is 3 + 3 +\n16 = 22."}] |
Print the largest possible sum of the integers written on the blackboard after
K operations by E869220.
* * * | s950879828 | Runtime Error | p03360 | Input is given from Standard Input in the following format:
A B C
K | num = list(map(int, input().split())
k = int(input())
print(max(num)*(2**k-1)+sum(num)) | Statement
There are three positive integers A, B and C written on a blackboard. E869120
performs the following operation K times:
* Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.
What is the largest possible sum of the integers written on the blackboard
after K operations? | [{"input": "5 3 11\n 1", "output": "30\n \n\nIn this sample, 5, 3, 11 are initially written on the blackboard, and E869120\ncan perform the operation once. \nThere are three choices:\n\n 1. Double 5: The integers written on the board after the operation are 10, 3, 11.\n 2. Double 3: The integers written on the board after the operation are 5, 6, 11.\n 3. Double 11: The integers written on the board after the operation are 5, 3, 22.\n\nIf he chooses 3., the sum of the integers written on the board afterwards is 5\n+ 3 + 22 = 30, which is the largest among 1. through 3.\n\n* * *"}, {"input": "3 3 4\n 2", "output": "22\n \n\nE869120 can perform the operation twice. The sum of the integers eventually\nwritten on the blackboard is maximized as follows:\n\n * First, double 4. The integers written on the board are now 3, 3, 8. \n * Next, double 8. The integers written on the board are now 3, 3, 16. \n\nThen, the sum of the integers eventually written on the blackboard is 3 + 3 +\n16 = 22."}] |
Print the largest possible sum of the integers written on the blackboard after
K operations by E869220.
* * * | s387847627 | Wrong Answer | p03360 | Input is given from Standard Input in the following format:
A B C
K | print(max(map(int, input().split())) * int(input()))
| Statement
There are three positive integers A, B and C written on a blackboard. E869120
performs the following operation K times:
* Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.
What is the largest possible sum of the integers written on the blackboard
after K operations? | [{"input": "5 3 11\n 1", "output": "30\n \n\nIn this sample, 5, 3, 11 are initially written on the blackboard, and E869120\ncan perform the operation once. \nThere are three choices:\n\n 1. Double 5: The integers written on the board after the operation are 10, 3, 11.\n 2. Double 3: The integers written on the board after the operation are 5, 6, 11.\n 3. Double 11: The integers written on the board after the operation are 5, 3, 22.\n\nIf he chooses 3., the sum of the integers written on the board afterwards is 5\n+ 3 + 22 = 30, which is the largest among 1. through 3.\n\n* * *"}, {"input": "3 3 4\n 2", "output": "22\n \n\nE869120 can perform the operation twice. The sum of the integers eventually\nwritten on the blackboard is maximized as follows:\n\n * First, double 4. The integers written on the board are now 3, 3, 8. \n * Next, double 8. The integers written on the board are now 3, 3, 16. \n\nThen, the sum of the integers eventually written on the blackboard is 3 + 3 +\n16 = 22."}] |
Print the largest possible sum of the integers written on the blackboard after
K operations by E869220.
* * * | s314584412 | Accepted | p03360 | Input is given from Standard Input in the following format:
A B C
K | line = list(map(int, input().split()))
n = int(input())
line.sort()
line[2] = line[2] * (2**n)
print(sum(line))
| Statement
There are three positive integers A, B and C written on a blackboard. E869120
performs the following operation K times:
* Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.
What is the largest possible sum of the integers written on the blackboard
after K operations? | [{"input": "5 3 11\n 1", "output": "30\n \n\nIn this sample, 5, 3, 11 are initially written on the blackboard, and E869120\ncan perform the operation once. \nThere are three choices:\n\n 1. Double 5: The integers written on the board after the operation are 10, 3, 11.\n 2. Double 3: The integers written on the board after the operation are 5, 6, 11.\n 3. Double 11: The integers written on the board after the operation are 5, 3, 22.\n\nIf he chooses 3., the sum of the integers written on the board afterwards is 5\n+ 3 + 22 = 30, which is the largest among 1. through 3.\n\n* * *"}, {"input": "3 3 4\n 2", "output": "22\n \n\nE869120 can perform the operation twice. The sum of the integers eventually\nwritten on the blackboard is maximized as follows:\n\n * First, double 4. The integers written on the board are now 3, 3, 8. \n * Next, double 8. The integers written on the board are now 3, 3, 16. \n\nThen, the sum of the integers eventually written on the blackboard is 3 + 3 +\n16 = 22."}] |
Print the largest possible sum of the integers written on the blackboard after
K operations by E869220.
* * * | s805357718 | Runtime Error | p03360 | Input is given from Standard Input in the following format:
A B C
K | ABC = sorted(map(int, input().split()))
K = int(input().split())
print(sum(ABC[:2] + ABC[-1:] * 2**K))
| Statement
There are three positive integers A, B and C written on a blackboard. E869120
performs the following operation K times:
* Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.
What is the largest possible sum of the integers written on the blackboard
after K operations? | [{"input": "5 3 11\n 1", "output": "30\n \n\nIn this sample, 5, 3, 11 are initially written on the blackboard, and E869120\ncan perform the operation once. \nThere are three choices:\n\n 1. Double 5: The integers written on the board after the operation are 10, 3, 11.\n 2. Double 3: The integers written on the board after the operation are 5, 6, 11.\n 3. Double 11: The integers written on the board after the operation are 5, 3, 22.\n\nIf he chooses 3., the sum of the integers written on the board afterwards is 5\n+ 3 + 22 = 30, which is the largest among 1. through 3.\n\n* * *"}, {"input": "3 3 4\n 2", "output": "22\n \n\nE869120 can perform the operation twice. The sum of the integers eventually\nwritten on the blackboard is maximized as follows:\n\n * First, double 4. The integers written on the board are now 3, 3, 8. \n * Next, double 8. The integers written on the board are now 3, 3, 16. \n\nThen, the sum of the integers eventually written on the blackboard is 3 + 3 +\n16 = 22."}] |
Print the largest possible sum of the integers written on the blackboard after
K operations by E869220.
* * * | s612823699 | Runtime Error | p03360 | Input is given from Standard Input in the following format:
A B C
K | a, b, c = map(int, input().split())
k = int(input())
ans = max(a, b, c)
for i in range(k):
ans = ans×2
print(ans)
| Statement
There are three positive integers A, B and C written on a blackboard. E869120
performs the following operation K times:
* Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.
What is the largest possible sum of the integers written on the blackboard
after K operations? | [{"input": "5 3 11\n 1", "output": "30\n \n\nIn this sample, 5, 3, 11 are initially written on the blackboard, and E869120\ncan perform the operation once. \nThere are three choices:\n\n 1. Double 5: The integers written on the board after the operation are 10, 3, 11.\n 2. Double 3: The integers written on the board after the operation are 5, 6, 11.\n 3. Double 11: The integers written on the board after the operation are 5, 3, 22.\n\nIf he chooses 3., the sum of the integers written on the board afterwards is 5\n+ 3 + 22 = 30, which is the largest among 1. through 3.\n\n* * *"}, {"input": "3 3 4\n 2", "output": "22\n \n\nE869120 can perform the operation twice. The sum of the integers eventually\nwritten on the blackboard is maximized as follows:\n\n * First, double 4. The integers written on the board are now 3, 3, 8. \n * Next, double 8. The integers written on the board are now 3, 3, 16. \n\nThen, the sum of the integers eventually written on the blackboard is 3 + 3 +\n16 = 22."}] |
Print the largest possible sum of the integers written on the blackboard after
K operations by E869220.
* * * | s364139444 | Runtime Error | p03360 | Input is given from Standard Input in the following format:
A B C
K | a, b, c = list(map(int, input().split(' ')))
N = int(input())
max_ = max([a, b, c]
print(a+b+c+max_**N-max_)
| Statement
There are three positive integers A, B and C written on a blackboard. E869120
performs the following operation K times:
* Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.
What is the largest possible sum of the integers written on the blackboard
after K operations? | [{"input": "5 3 11\n 1", "output": "30\n \n\nIn this sample, 5, 3, 11 are initially written on the blackboard, and E869120\ncan perform the operation once. \nThere are three choices:\n\n 1. Double 5: The integers written on the board after the operation are 10, 3, 11.\n 2. Double 3: The integers written on the board after the operation are 5, 6, 11.\n 3. Double 11: The integers written on the board after the operation are 5, 3, 22.\n\nIf he chooses 3., the sum of the integers written on the board afterwards is 5\n+ 3 + 22 = 30, which is the largest among 1. through 3.\n\n* * *"}, {"input": "3 3 4\n 2", "output": "22\n \n\nE869120 can perform the operation twice. The sum of the integers eventually\nwritten on the blackboard is maximized as follows:\n\n * First, double 4. The integers written on the board are now 3, 3, 8. \n * Next, double 8. The integers written on the board are now 3, 3, 16. \n\nThen, the sum of the integers eventually written on the blackboard is 3 + 3 +\n16 = 22."}] |
Print the largest possible sum of the integers written on the blackboard after
K operations by E869220.
* * * | s125812962 | Runtime Error | p03360 | Input is given from Standard Input in the following format:
A B C
K | a = input().split()
b = input()
c = [int(i) for i in a]
d = 0
for j in c:
d += j
d = d - max(c)
d = d + (max(c)) * (2**b)
| Statement
There are three positive integers A, B and C written on a blackboard. E869120
performs the following operation K times:
* Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.
What is the largest possible sum of the integers written on the blackboard
after K operations? | [{"input": "5 3 11\n 1", "output": "30\n \n\nIn this sample, 5, 3, 11 are initially written on the blackboard, and E869120\ncan perform the operation once. \nThere are three choices:\n\n 1. Double 5: The integers written on the board after the operation are 10, 3, 11.\n 2. Double 3: The integers written on the board after the operation are 5, 6, 11.\n 3. Double 11: The integers written on the board after the operation are 5, 3, 22.\n\nIf he chooses 3., the sum of the integers written on the board afterwards is 5\n+ 3 + 22 = 30, which is the largest among 1. through 3.\n\n* * *"}, {"input": "3 3 4\n 2", "output": "22\n \n\nE869120 can perform the operation twice. The sum of the integers eventually\nwritten on the blackboard is maximized as follows:\n\n * First, double 4. The integers written on the board are now 3, 3, 8. \n * Next, double 8. The integers written on the board are now 3, 3, 16. \n\nThen, the sum of the integers eventually written on the blackboard is 3 + 3 +\n16 = 22."}] |
Print the largest possible sum of the integers written on the blackboard after
K operations by E869220.
* * * | s332296214 | Runtime Error | p03360 | Input is given from Standard Input in the following format:
A B C
K | if __name__ == '__main__':
a = [int(i) for i in input().split()]
n = int(input())
a.sort()
a[2] = a[2]*(2**n)
print(su | Statement
There are three positive integers A, B and C written on a blackboard. E869120
performs the following operation K times:
* Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.
What is the largest possible sum of the integers written on the blackboard
after K operations? | [{"input": "5 3 11\n 1", "output": "30\n \n\nIn this sample, 5, 3, 11 are initially written on the blackboard, and E869120\ncan perform the operation once. \nThere are three choices:\n\n 1. Double 5: The integers written on the board after the operation are 10, 3, 11.\n 2. Double 3: The integers written on the board after the operation are 5, 6, 11.\n 3. Double 11: The integers written on the board after the operation are 5, 3, 22.\n\nIf he chooses 3., the sum of the integers written on the board afterwards is 5\n+ 3 + 22 = 30, which is the largest among 1. through 3.\n\n* * *"}, {"input": "3 3 4\n 2", "output": "22\n \n\nE869120 can perform the operation twice. The sum of the integers eventually\nwritten on the blackboard is maximized as follows:\n\n * First, double 4. The integers written on the board are now 3, 3, 8. \n * Next, double 8. The integers written on the board are now 3, 3, 16. \n\nThen, the sum of the integers eventually written on the blackboard is 3 + 3 +\n16 = 22."}] |
Print the largest possible sum of the integers written on the blackboard after
K operations by E869220.
* * * | s663919684 | Runtime Error | p03360 | Input is given from Standard Input in the following format:
A B C
K | a,b,c = map(int,input().split())
k = int(input())
ans = max(a,b,c)
for i in range(k):
ans = ans × 2
print(ans)
| Statement
There are three positive integers A, B and C written on a blackboard. E869120
performs the following operation K times:
* Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.
What is the largest possible sum of the integers written on the blackboard
after K operations? | [{"input": "5 3 11\n 1", "output": "30\n \n\nIn this sample, 5, 3, 11 are initially written on the blackboard, and E869120\ncan perform the operation once. \nThere are three choices:\n\n 1. Double 5: The integers written on the board after the operation are 10, 3, 11.\n 2. Double 3: The integers written on the board after the operation are 5, 6, 11.\n 3. Double 11: The integers written on the board after the operation are 5, 3, 22.\n\nIf he chooses 3., the sum of the integers written on the board afterwards is 5\n+ 3 + 22 = 30, which is the largest among 1. through 3.\n\n* * *"}, {"input": "3 3 4\n 2", "output": "22\n \n\nE869120 can perform the operation twice. The sum of the integers eventually\nwritten on the blackboard is maximized as follows:\n\n * First, double 4. The integers written on the board are now 3, 3, 8. \n * Next, double 8. The integers written on the board are now 3, 3, 16. \n\nThen, the sum of the integers eventually written on the blackboard is 3 + 3 +\n16 = 22."}] |
Print the largest possible sum of the integers written on the blackboard after
K operations by E869220.
* * * | s628466936 | Runtime Error | p03360 | Input is given from Standard Input in the following format:
A B C
K | import numpy as np
x, y, z = map(int, input().split(' '))
row = np.array([x,y,z])
for times in range(int(input()):
row[row.argmax()] = row.max() * 2
print(np.sum(row)) | Statement
There are three positive integers A, B and C written on a blackboard. E869120
performs the following operation K times:
* Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.
What is the largest possible sum of the integers written on the blackboard
after K operations? | [{"input": "5 3 11\n 1", "output": "30\n \n\nIn this sample, 5, 3, 11 are initially written on the blackboard, and E869120\ncan perform the operation once. \nThere are three choices:\n\n 1. Double 5: The integers written on the board after the operation are 10, 3, 11.\n 2. Double 3: The integers written on the board after the operation are 5, 6, 11.\n 3. Double 11: The integers written on the board after the operation are 5, 3, 22.\n\nIf he chooses 3., the sum of the integers written on the board afterwards is 5\n+ 3 + 22 = 30, which is the largest among 1. through 3.\n\n* * *"}, {"input": "3 3 4\n 2", "output": "22\n \n\nE869120 can perform the operation twice. The sum of the integers eventually\nwritten on the blackboard is maximized as follows:\n\n * First, double 4. The integers written on the board are now 3, 3, 8. \n * Next, double 8. The integers written on the board are now 3, 3, 16. \n\nThen, the sum of the integers eventually written on the blackboard is 3 + 3 +\n16 = 22."}] |
Print the largest possible sum of the integers written on the blackboard after
K operations by E869220.
* * * | s929654626 | Runtime Error | p03360 | Input is given from Standard Input in the following format:
A B C
K | A, B, C = [int(x) for x in input().split()]
print(max(A, B, C) * (2 **int(input())) + sum(A, B, C) - max(A, B, C)) | Statement
There are three positive integers A, B and C written on a blackboard. E869120
performs the following operation K times:
* Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.
What is the largest possible sum of the integers written on the blackboard
after K operations? | [{"input": "5 3 11\n 1", "output": "30\n \n\nIn this sample, 5, 3, 11 are initially written on the blackboard, and E869120\ncan perform the operation once. \nThere are three choices:\n\n 1. Double 5: The integers written on the board after the operation are 10, 3, 11.\n 2. Double 3: The integers written on the board after the operation are 5, 6, 11.\n 3. Double 11: The integers written on the board after the operation are 5, 3, 22.\n\nIf he chooses 3., the sum of the integers written on the board afterwards is 5\n+ 3 + 22 = 30, which is the largest among 1. through 3.\n\n* * *"}, {"input": "3 3 4\n 2", "output": "22\n \n\nE869120 can perform the operation twice. The sum of the integers eventually\nwritten on the blackboard is maximized as follows:\n\n * First, double 4. The integers written on the board are now 3, 3, 8. \n * Next, double 8. The integers written on the board are now 3, 3, 16. \n\nThen, the sum of the integers eventually written on the blackboard is 3 + 3 +\n16 = 22."}] |
Print the expected holeyness of S, \bmod 10^9+7.
* * * | s571648379 | Accepted | p02822 | Input is given from Standard Input in the following format:
N
A_1 B_1
:
A_{N-1} B_{N-1} | # classを使うのをやめてlistで実施する
# dfsを再帰でなくstackを用いて書く
from collections import deque
import sys
input = sys.stdin.readline
def dfs():
stk1 = deque([0])
stk2 = deque([])
while stk1:
v = stk1.pop()
visited[v] = True
stk2.append(v)
for i in range(len(AL[v][CHILDREN])):
u = AL[v][CHILDREN][i]
if visited[u]:
AL[v][CHILDREN][i] = None
continue
stk1.append(u)
for i in range(n - 1, -1, -1):
v = stk2[i]
for u in AL[v][CHILDREN]:
if u is None:
continue
AL[v][SIZE] += AL[u][SIZE]
def anaaki(v):
ret = pow(2, n - 1, p) - 1
for ch in AL[v][CHILDREN]:
if ch is None:
continue
ret -= pow(2, AL[ch][SIZE], p) - 1
ret %= p
ret -= pow(2, n - AL[v][SIZE], p) - 1
ret %= p
return ret
n = int(input())
SIZE = 0
CHILDREN = 1
AL = [[1, []] for _ in range(n)]
visited = [False] * n
p = 10**9 + 7
for i in range(n - 1):
a, b = [int(x) - 1 for x in input().split()]
AL[a][CHILDREN].append(b)
AL[b][CHILDREN].append(a)
dfs()
numer = 0
for i in range(n):
numer += anaaki(i)
numer %= p
denom = pow(2, n, p)
print(numer * pow(denom, p - 2, p) % p)
| Statement
Given is a tree T with N vertices. The i-th edge connects Vertex A_i and B_i
(1 \leq A_i,B_i \leq N).
Now, each vertex is painted black with probability 1/2 and white with
probability 1/2, which is chosen independently from other vertices. Then, let
S be the smallest subtree (connected subgraph) of T containing all the
vertices painted black. (If no vertex is painted black, S is the empty graph.)
Let the _holeyness_ of S be the number of white vertices contained in S. Find
the expected holeyness of S.
Since the answer is a rational number, we ask you to print it \bmod 10^9+7, as
described in Notes. | [{"input": "3\n 1 2\n 2 3", "output": "125000001\n \n\nIf the vertices 1, 2, 3 are painted black, white, black, respectively, the\nholeyness of S is 1.\n\nOtherwise, the holeyness is 0, so the expected holeyness is 1/8.\n\nSince 8 \\times 125000001 \\equiv 1 \\pmod{10^9+7}, we should print 125000001.\n\n* * *"}, {"input": "4\n 1 2\n 2 3\n 3 4", "output": "375000003\n \n\nThe expected holeyness is 3/8.\n\nSince 8 \\times 375000003 \\equiv 3 \\pmod{10^9+7}, we should print 375000003.\n\n* * *"}, {"input": "4\n 1 2\n 1 3\n 1 4", "output": "250000002\n \n\nThe expected holeyness is 1/4.\n\n* * *"}, {"input": "7\n 4 7\n 3 1\n 2 6\n 5 2\n 7 1\n 2 7", "output": "570312505"}] |
Print the expected holeyness of S, \bmod 10^9+7.
* * * | s306457674 | Runtime Error | p02822 | Input is given from Standard Input in the following format:
N
A_1 B_1
:
A_{N-1} B_{N-1} | n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
lr = []
for ai in a[: m // 2]:
for aj in a[: m // 2]:
lr.append(ai + aj)
lr.sort()
print(sum(lr[-m:]))
| Statement
Given is a tree T with N vertices. The i-th edge connects Vertex A_i and B_i
(1 \leq A_i,B_i \leq N).
Now, each vertex is painted black with probability 1/2 and white with
probability 1/2, which is chosen independently from other vertices. Then, let
S be the smallest subtree (connected subgraph) of T containing all the
vertices painted black. (If no vertex is painted black, S is the empty graph.)
Let the _holeyness_ of S be the number of white vertices contained in S. Find
the expected holeyness of S.
Since the answer is a rational number, we ask you to print it \bmod 10^9+7, as
described in Notes. | [{"input": "3\n 1 2\n 2 3", "output": "125000001\n \n\nIf the vertices 1, 2, 3 are painted black, white, black, respectively, the\nholeyness of S is 1.\n\nOtherwise, the holeyness is 0, so the expected holeyness is 1/8.\n\nSince 8 \\times 125000001 \\equiv 1 \\pmod{10^9+7}, we should print 125000001.\n\n* * *"}, {"input": "4\n 1 2\n 2 3\n 3 4", "output": "375000003\n \n\nThe expected holeyness is 3/8.\n\nSince 8 \\times 375000003 \\equiv 3 \\pmod{10^9+7}, we should print 375000003.\n\n* * *"}, {"input": "4\n 1 2\n 1 3\n 1 4", "output": "250000002\n \n\nThe expected holeyness is 1/4.\n\n* * *"}, {"input": "7\n 4 7\n 3 1\n 2 6\n 5 2\n 7 1\n 2 7", "output": "570312505"}] |
Print the expected holeyness of S, \bmod 10^9+7.
* * * | s434907090 | Accepted | p02822 | Input is given from Standard Input in the following format:
N
A_1 B_1
:
A_{N-1} B_{N-1} | import sys
readline = sys.stdin.readline
class Segtree:
def __init__(self, A, intv, initialize=True, segf=max):
self.N = len(A)
self.N0 = 2 ** (self.N - 1).bit_length()
self.intv = intv
self.segf = segf
if initialize:
self.data = [intv] * self.N0 + A + [intv] * (self.N0 - self.N)
for i in range(self.N0 - 1, 0, -1):
self.data[i] = self.segf(self.data[2 * i], self.data[2 * i + 1])
else:
self.data = [intv] * (2 * self.N0)
def update(self, k, x):
k += self.N0
self.data[k] = x
while k > 0:
k = k >> 1
self.data[k] = self.segf(self.data[2 * k], self.data[2 * k + 1])
def query(self, l, r):
L, R = l + self.N0, r + self.N0
s = self.intv
while L < R:
if R & 1:
R -= 1
s = self.segf(s, self.data[R])
if L & 1:
s = self.segf(s, self.data[L])
L += 1
L >>= 1
R >>= 1
return s
def binsearch(self, l, r, check, reverse=False):
L, R = l + self.N0, r + self.N0
SL, SR = [], []
while L < R:
if R & 1:
R -= 1
SR.append(R)
if L & 1:
SL.append(L)
L += 1
L >>= 1
R >>= 1
if reverse:
for idx in SR + SL[::-1]:
if check(self.data[idx]):
break
else:
return -1
while idx < self.N0:
if check(self.data[2 * idx + 1]):
idx = 2 * idx + 1
else:
idx = 2 * idx
return idx - self.N0
else:
for idx in SL + SR[::-1]:
if check(self.data[idx]):
break
else:
return -1
while idx < self.N0:
if check(self.data[2 * idx]):
idx = 2 * idx
else:
idx = 2 * idx + 1
return idx - self.N0
def parorder(Edge, p):
N = len(Edge)
par = [0] * N
par[p] = -1
stack = [p]
order = []
visited = set([p])
ast = stack.append
apo = order.append
while stack:
vn = stack.pop()
apo(vn)
for vf in Edge[vn]:
if vf in visited:
continue
visited.add(vf)
par[vf] = vn
ast(vf)
return par, order
def getcld(p):
res = [[] for _ in range(len(p))]
for i, v in enumerate(p[1:], 1):
res[v].append(i)
return res
N = int(readline())
MOD = 10**9 + 7
Edge = [[] for _ in range(N)]
for _ in range(N - 1):
a, b = map(int, readline().split())
a -= 1
b -= 1
Edge[a].append(b)
Edge[b].append(a)
pow2 = [1] * (N + 3)
for i in range(1, len(pow2)):
pow2[i] = (2 * pow2[i - 1]) % MOD
P, L = parorder(Edge, 0)
dp1 = [0] * N
dp2 = [0] * N
size = [1] * N
for l in L[:0:-1]:
p = P[l]
size[p] += size[l]
for l in L[:0:-1]:
p = P[l]
dp1[l] = (dp1[l] + pow2[size[l] - 1] - 1) % MOD
dp2[l] = (dp2[l] + pow2[size[l] - 1] - 1) % MOD
k = pow2[size[p] - 1 - size[l]]
dp1[p] = (dp1[p] - (pow2[size[l]] - 1) + (2 * k - 1) * dp2[l] + dp1[l]) % MOD
dp2[p] = (dp2[p] + 2 * dp2[l] * k) % MOD
dp1[0] = (dp1[0] + pow2[size[0] - 1] - 1) % MOD
print(dp1[0] * pow(pow(2, N, MOD), MOD - 2, MOD) % MOD)
| Statement
Given is a tree T with N vertices. The i-th edge connects Vertex A_i and B_i
(1 \leq A_i,B_i \leq N).
Now, each vertex is painted black with probability 1/2 and white with
probability 1/2, which is chosen independently from other vertices. Then, let
S be the smallest subtree (connected subgraph) of T containing all the
vertices painted black. (If no vertex is painted black, S is the empty graph.)
Let the _holeyness_ of S be the number of white vertices contained in S. Find
the expected holeyness of S.
Since the answer is a rational number, we ask you to print it \bmod 10^9+7, as
described in Notes. | [{"input": "3\n 1 2\n 2 3", "output": "125000001\n \n\nIf the vertices 1, 2, 3 are painted black, white, black, respectively, the\nholeyness of S is 1.\n\nOtherwise, the holeyness is 0, so the expected holeyness is 1/8.\n\nSince 8 \\times 125000001 \\equiv 1 \\pmod{10^9+7}, we should print 125000001.\n\n* * *"}, {"input": "4\n 1 2\n 2 3\n 3 4", "output": "375000003\n \n\nThe expected holeyness is 3/8.\n\nSince 8 \\times 375000003 \\equiv 3 \\pmod{10^9+7}, we should print 375000003.\n\n* * *"}, {"input": "4\n 1 2\n 1 3\n 1 4", "output": "250000002\n \n\nThe expected holeyness is 1/4.\n\n* * *"}, {"input": "7\n 4 7\n 3 1\n 2 6\n 5 2\n 7 1\n 2 7", "output": "570312505"}] |
Print the expected holeyness of S, \bmod 10^9+7.
* * * | s111348575 | Runtime Error | p02822 | Input is given from Standard Input in the following format:
N
A_1 B_1
:
A_{N-1} B_{N-1} | import sys
from itertools import accumulate
sys.setrecursionlimit(10**5)
def dfs1(v, p):
parent[v] = p
stc = subtree_count[v]
cnt = 1
for u in links[v]:
if u == p:
continue
result = dfs1(u, v)
stc[u] = result
cnt += result
return cnt
def dfs2(v, pc):
# pc: vを根とした時の、parent方面の部分木のノード数
global ans
if len(subtree_count[v]) == 0:
return
p = parent[v]
children, st_counts = map(list, zip(*subtree_count[v].items()))
children.append(p)
st_counts.append(pc)
cl = len(st_counts)
ct = sum(st_counts)
for u, stc in subtree_count[v].items():
dfs2(u, ct - stc + 1)
if cl == 1:
return
prob_fwd = [0] + list(accumulate(st_counts[:-1]))
prob_bwd = [0] + list(accumulate(st_counts[-1:0:-1]))
prob_bwd.reverse()
tmp = 0
for pf, pb in zip(prob_fwd, prob_bwd):
tmp = (tmp + d2s[pf + pb]) % MOD
tmp = (tmp - d2s[ct] * (cl - 1)) % MOD
ans = (ans + (1 - tmp) * d2) % MOD
n = int(input())
links = [set() for _ in range(n)]
for line in sys.stdin:
a, b = map(int, line.split())
a -= 1
b -= 1
links[a].add(b)
links[b].add(a)
root = 0
parent = [-1] * n
subtree_count = [{} for _ in range(n)] # 根がrootの時の、vの子の各部分木のノード数
MOD = 10**9 + 7
d2 = 500000004 # 2^-1 mod 10**9+7
d2s = [1]
for i in range(n):
d2s.append(d2s[-1] * d2 % MOD)
ans = 0
dfs1(root, -1)
# print(parent)
# print(subtree_count)
dfs2(root, 0)
print(ans)
| Statement
Given is a tree T with N vertices. The i-th edge connects Vertex A_i and B_i
(1 \leq A_i,B_i \leq N).
Now, each vertex is painted black with probability 1/2 and white with
probability 1/2, which is chosen independently from other vertices. Then, let
S be the smallest subtree (connected subgraph) of T containing all the
vertices painted black. (If no vertex is painted black, S is the empty graph.)
Let the _holeyness_ of S be the number of white vertices contained in S. Find
the expected holeyness of S.
Since the answer is a rational number, we ask you to print it \bmod 10^9+7, as
described in Notes. | [{"input": "3\n 1 2\n 2 3", "output": "125000001\n \n\nIf the vertices 1, 2, 3 are painted black, white, black, respectively, the\nholeyness of S is 1.\n\nOtherwise, the holeyness is 0, so the expected holeyness is 1/8.\n\nSince 8 \\times 125000001 \\equiv 1 \\pmod{10^9+7}, we should print 125000001.\n\n* * *"}, {"input": "4\n 1 2\n 2 3\n 3 4", "output": "375000003\n \n\nThe expected holeyness is 3/8.\n\nSince 8 \\times 375000003 \\equiv 3 \\pmod{10^9+7}, we should print 375000003.\n\n* * *"}, {"input": "4\n 1 2\n 1 3\n 1 4", "output": "250000002\n \n\nThe expected holeyness is 1/4.\n\n* * *"}, {"input": "7\n 4 7\n 3 1\n 2 6\n 5 2\n 7 1\n 2 7", "output": "570312505"}] |
Print the expected holeyness of S, \bmod 10^9+7.
* * * | s676793457 | Accepted | p02822 | Input is given from Standard Input in the following format:
N
A_1 B_1
:
A_{N-1} B_{N-1} | N = int(input())
E = [[] for i in range(N + 1)]
for i in range(N - 1):
x, y = map(int, input().split())
E[x].append(y)
E[y].append(x)
mod = 10**9 + 7
from collections import deque
Q = deque()
USE = [0] * (N + 1)
Q.append(1)
H = [0] * (N + 1)
H[1] = 1
USE[1] = 1
while Q:
x = Q.pop()
for to in E[x]:
if USE[to] == 0:
USE[to] = 1
H[to] = H[x] + 1
Q.append(to)
EH = [(h, ind + 1) for ind, h in enumerate(H[1:])]
EH.sort(reverse=True)
COME = [1] * (N + 1)
USE = [0] * (N + 1)
for h, ind in EH:
USE[ind] = 1
for to in E[ind]:
if USE[to] == 0:
COME[to] += COME[ind]
ANS = 0
POW2 = [1]
for i in range(N + 1):
POW2.append(POW2[-1] * 2 % mod)
for i in range(1, N + 1):
SCORE = []
for j in E[i]:
if COME[j] < COME[i]:
SCORE.append(COME[j])
if sum(SCORE) < N - 1:
SCORE.append(N - sum(SCORE) - 1)
AV = 1
for s in SCORE:
AV += POW2[s] - 1
ANS += POW2[N - 1] - AV
# print(SCORE,AV)
print((ANS * pow(POW2[N], mod - 2, mod)) % mod)
| Statement
Given is a tree T with N vertices. The i-th edge connects Vertex A_i and B_i
(1 \leq A_i,B_i \leq N).
Now, each vertex is painted black with probability 1/2 and white with
probability 1/2, which is chosen independently from other vertices. Then, let
S be the smallest subtree (connected subgraph) of T containing all the
vertices painted black. (If no vertex is painted black, S is the empty graph.)
Let the _holeyness_ of S be the number of white vertices contained in S. Find
the expected holeyness of S.
Since the answer is a rational number, we ask you to print it \bmod 10^9+7, as
described in Notes. | [{"input": "3\n 1 2\n 2 3", "output": "125000001\n \n\nIf the vertices 1, 2, 3 are painted black, white, black, respectively, the\nholeyness of S is 1.\n\nOtherwise, the holeyness is 0, so the expected holeyness is 1/8.\n\nSince 8 \\times 125000001 \\equiv 1 \\pmod{10^9+7}, we should print 125000001.\n\n* * *"}, {"input": "4\n 1 2\n 2 3\n 3 4", "output": "375000003\n \n\nThe expected holeyness is 3/8.\n\nSince 8 \\times 375000003 \\equiv 3 \\pmod{10^9+7}, we should print 375000003.\n\n* * *"}, {"input": "4\n 1 2\n 1 3\n 1 4", "output": "250000002\n \n\nThe expected holeyness is 1/4.\n\n* * *"}, {"input": "7\n 4 7\n 3 1\n 2 6\n 5 2\n 7 1\n 2 7", "output": "570312505"}] |
Print the expected holeyness of S, \bmod 10^9+7.
* * * | s658125790 | Accepted | p02822 | Input is given from Standard Input in the following format:
N
A_1 B_1
:
A_{N-1} B_{N-1} | class Tree:
C, RL = {}, {}
R, N, D, S, P = None, None, None, None, None
SN = None
def __init__(s, num):
s.N = num
def set(s, a, b):
if a in s.C:
s.C[a].append(b)
else:
s.C[a] = [b]
if b in s.C:
s.C[b].append(a)
else:
s.C[b] = [a]
def makeRank(s, root):
s.R = [0] * s.N # 各ノードのランク
s.R[root] = 1
s.RL[1] = [root] # 各ランクのノード
s.S = [[] for _ in range(s.N)] # 各ノードの子ノード
s.P = [-1] * s.N # 各ノードの親ノード
F = [root]
s.D = 2
while F != []:
Ft = []
s.RL[s.D] = []
for i in F:
for j in s.C[i]:
if s.R[j] == 0:
s.R[j] = s.D
Ft.append(j)
s.RL[s.D].append(j)
s.S[i].append(j)
s.P[j] = i
s.D += 1
F = Ft
def dfs(s, x): # 最遠のノード,距離
t = [-1] * s.N
S = [x]
ans = x
ansn = 0
t[x] = 0
while S != []:
k = S.pop()
for i in s.C[k]:
if t[i] == -1:
t[i] = t[k] + 1
S.append(i)
if t[i] > ansn:
ansn = t[i]
ans = i
return ans, ansn
def getDi(s, x=0): # 直径
a, _ = s.dfs(x)
b, ans = s.dfs(a)
return ans
def getDeep(s, x): # xの子孫のうち一番深い深さ
ans = 0
if x in s.S:
for i in s.S[x]:
ans = max(ans, s.getDeep(i))
return ans + 1
else:
return 0
def getParent(s, x, n): # xのn世代前の親
if n == 0:
return x
if s.P[x] == -1:
return -n
return s.getParent(s.P[x], n - 1)
def countSon(s):
s.SN = [0] * s.N
for i in range(s.D - 1, 0, -1):
for j in s.RL[i]:
cnt = 1
for k in s.S[j]:
cnt += s.SN[k]
s.SN[j] = cnt
class powmod:
F = [1, 2]
Fi = [1, 2]
I = [0, 1]
def __init__(self, num, mod):
self.MOD = mod
k = 2
for i in range(2, num + 1):
self.F.append((self.F[-1] * k) % mod)
self.I.append(mod - self.I[mod % k] * (mod // k) % mod)
self.Fi.append(self.Fi[-1] * self.I[k] % mod)
class Inv:
def __init__(s, mod):
s.MOD = mod
def modpow(s, a, n):
res = 1
while n > 0:
if n & 1:
res = res * a % s.MOD
a = a * a % s.MOD
n >>= 1
return res
def invx(s, a):
return s.modpow(a, s.MOD - 2)
def invL(s, a, n):
ia = s.invx(a)
L = [1] * (n + 1)
for i in range(1, n + 1):
L[i] = L[i - 1] * ia % s.MOD
return L
N = int(input())
AB = [list(map(int, input().split())) for _ in range(N - 1)]
T = Tree(N)
L = [0] * N
for a, b in AB:
T.set(a - 1, b - 1)
L[a - 1] += 1
L[b - 1] += 1
for i in range(N):
if L[i] == 1:
root = i
T.makeRank(root)
T.countSon()
MOD = 10**9 + 7
ans = 0
PM = powmod(N, MOD)
I = Inv(MOD)
y = I.invx(PM.F[N])
ans = 0
for i in range(N):
if i == root:
continue
if T.S[i] == []:
continue
L = []
cnt = 0
for j in T.S[i]:
L.append(T.SN[j])
cnt += T.SN[j]
L.append(N - cnt - 1)
t = PM.F[N - 1] - 1
for j in L:
t = t - PM.F[j] + 1
if t < 0:
t += MOD
ans = (ans + t * y) % MOD
print(ans)
| Statement
Given is a tree T with N vertices. The i-th edge connects Vertex A_i and B_i
(1 \leq A_i,B_i \leq N).
Now, each vertex is painted black with probability 1/2 and white with
probability 1/2, which is chosen independently from other vertices. Then, let
S be the smallest subtree (connected subgraph) of T containing all the
vertices painted black. (If no vertex is painted black, S is the empty graph.)
Let the _holeyness_ of S be the number of white vertices contained in S. Find
the expected holeyness of S.
Since the answer is a rational number, we ask you to print it \bmod 10^9+7, as
described in Notes. | [{"input": "3\n 1 2\n 2 3", "output": "125000001\n \n\nIf the vertices 1, 2, 3 are painted black, white, black, respectively, the\nholeyness of S is 1.\n\nOtherwise, the holeyness is 0, so the expected holeyness is 1/8.\n\nSince 8 \\times 125000001 \\equiv 1 \\pmod{10^9+7}, we should print 125000001.\n\n* * *"}, {"input": "4\n 1 2\n 2 3\n 3 4", "output": "375000003\n \n\nThe expected holeyness is 3/8.\n\nSince 8 \\times 375000003 \\equiv 3 \\pmod{10^9+7}, we should print 375000003.\n\n* * *"}, {"input": "4\n 1 2\n 1 3\n 1 4", "output": "250000002\n \n\nThe expected holeyness is 1/4.\n\n* * *"}, {"input": "7\n 4 7\n 3 1\n 2 6\n 5 2\n 7 1\n 2 7", "output": "570312505"}] |
Print `YES` or `NO`.
* * * | s206381585 | Accepted | p03730 | Input is given from Standard Input in the following format:
A B C | #!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI():
return list(map(int, stdin.readline().split()))
def LF():
return list(map(float, stdin.readline().split()))
def LI_():
return list(map(lambda x: int(x) - 1, stdin.readline().split()))
def II():
return int(stdin.readline())
def IF():
return float(stdin.readline())
def LS():
return list(map(list, stdin.readline().split()))
def S():
return list(stdin.readline().rstrip())
def IR(n):
return [II() for _ in range(n)]
def LIR(n):
return [LI() for _ in range(n)]
def FR(n):
return [IF() for _ in range(n)]
def LFR(n):
return [LI() for _ in range(n)]
def LIR_(n):
return [LI_() for _ in range(n)]
def SR(n):
return [S() for _ in range(n)]
def LSR(n):
return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")
# A
def A():
a, b, c = LS()
if a[-1] == b[0] and b[-1] == c[0]:
print("YES")
else:
print("NO")
return
# B
def B():
a, b, c = LI()
for i in range(1, b):
if a * i % b == c:
print("YES")
return
print("NO")
return
# C
def C():
return
# D
def D():
return
# Solve
if __name__ == "__main__":
B()
| Statement
We ask you to select some number of positive integers, and calculate the sum
of them.
It is allowed to select as many integers as you like, and as large integers as
you wish. You have to follow these, however: each selected integer needs to be
a multiple of A, and you need to select at least one integer.
Your objective is to make the sum congruent to C modulo B. Determine whether
this is possible.
If the objective is achievable, print `YES`. Otherwise, print `NO`. | [{"input": "7 5 1", "output": "YES\n \n\nFor example, if you select 7 and 14, the sum 21 is congruent to 1 modulo 5.\n\n* * *"}, {"input": "2 2 1", "output": "NO\n \n\nThe sum of even numbers, no matter how many, is never odd.\n\n* * *"}, {"input": "1 100 97", "output": "YES\n \n\nYou can select 97, since you may select multiples of 1, that is, all integers.\n\n* * *"}, {"input": "40 98 58", "output": "YES\n \n\n* * *"}, {"input": "77 42 36", "output": "NO"}] |
Print `YES` or `NO`.
* * * | s900347918 | Runtime Error | p03730 | Input is given from Standard Input in the following format:
A B C | from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
from itertools import permutations, combinations, groupby
import sys, bisect, string, math, time, functools, random
def Golf():
(*a,) = map(int, open(0))
def I():
return int(input())
def S_():
return input()
def IS():
return input().split()
def LS():
return [i for i in input().split()]
def LI():
return [int(i) for i in input().split()]
def LI_():
return [int(i) - 1 for i in input().split()]
def NI(n):
return [int(input()) for i in range(n)]
def NI_(n):
return [int(input()) - 1 for i in range(n)]
def StoLI():
return [ord(i) - 97 for i in input()]
def ItoS(n):
return chr(n + 97)
def LtoS(ls):
return "".join([chr(i + 97) for i in ls])
def GI(V, E, Directed=False, index=0):
org_inp = []
g = [[] for i in range(n)]
for i in range(E):
inp = LI()
org_inp.append(inp)
if index == 0:
inp[0] -= 1
inp[1] -= 1
if len(inp) == 2:
a, b = inp
g[a].append(b)
if not Directed:
g[b].append(a)
elif len(inp) == 3:
a, b, c = inp
aa = (inp[0], inp[2])
bb = (inp[1], inp[2])
g[a].append(bb)
if not Directed:
g[b].append(aa)
return g, org_inp
def GGI(h, w, boundary=1, search=[], replacement_of_found=".", mp_def={"#": 1, ".": 0}):
# h,w,g,sg=GGI(h,w,boundary=1,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage
mp = [boundary] * (w + 2)
found = {}
for i in range(h):
s = input()
for char in search:
if char in s:
found[char] = (i + 1) * (w + 2) + s.index(char) + 1
mp_def[char] = mp_def[replacement_of_found]
mp += [boundary] + [mp_def[j] for j in s] + [boundary]
mp += [boundary] * (w + 2)
return h + 2, w + 2, mp, found
def TI(n):
return GI(n, n - 1)
def bit_combination(k, n=2):
return [[tb // (n**bt) % n for bt in range(k)] for tb in range(n**k)]
def show(*inp, end="\n"):
if show_flg:
print(*inp, end=end)
def show2d(g, h, w):
for i in range(h):
show(g[i * w : i * w + w])
YN = ["YES", "NO"]
Yn = ["Yes", "No"]
mo = 10**9 + 7
inf = float("inf")
l_alp = string.ascii_lowercase
# sys.setrecursionlimit(10**7)
input = lambda: sys.stdin.readline().rstrip()
show_flg = False
show_flg = True
a, b, c = LI()
d = math.gcd(a, b)
print(YN[c % d != 0])
| Statement
We ask you to select some number of positive integers, and calculate the sum
of them.
It is allowed to select as many integers as you like, and as large integers as
you wish. You have to follow these, however: each selected integer needs to be
a multiple of A, and you need to select at least one integer.
Your objective is to make the sum congruent to C modulo B. Determine whether
this is possible.
If the objective is achievable, print `YES`. Otherwise, print `NO`. | [{"input": "7 5 1", "output": "YES\n \n\nFor example, if you select 7 and 14, the sum 21 is congruent to 1 modulo 5.\n\n* * *"}, {"input": "2 2 1", "output": "NO\n \n\nThe sum of even numbers, no matter how many, is never odd.\n\n* * *"}, {"input": "1 100 97", "output": "YES\n \n\nYou can select 97, since you may select multiples of 1, that is, all integers.\n\n* * *"}, {"input": "40 98 58", "output": "YES\n \n\n* * *"}, {"input": "77 42 36", "output": "NO"}] |
Print `YES` or `NO`.
* * * | s144894410 | Runtime Error | p03730 | Input is given from Standard Input in the following format:
A B C | A, B, C = map(int, input().split())
if ((A % 2 == 0) and (B % 2 == 0)):
if (C == 0):
print("YES")
else:
print("NO")
else:
if (C != 0):
print("YES")
else:
print("NO")
| Statement
We ask you to select some number of positive integers, and calculate the sum
of them.
It is allowed to select as many integers as you like, and as large integers as
you wish. You have to follow these, however: each selected integer needs to be
a multiple of A, and you need to select at least one integer.
Your objective is to make the sum congruent to C modulo B. Determine whether
this is possible.
If the objective is achievable, print `YES`. Otherwise, print `NO`. | [{"input": "7 5 1", "output": "YES\n \n\nFor example, if you select 7 and 14, the sum 21 is congruent to 1 modulo 5.\n\n* * *"}, {"input": "2 2 1", "output": "NO\n \n\nThe sum of even numbers, no matter how many, is never odd.\n\n* * *"}, {"input": "1 100 97", "output": "YES\n \n\nYou can select 97, since you may select multiples of 1, that is, all integers.\n\n* * *"}, {"input": "40 98 58", "output": "YES\n \n\n* * *"}, {"input": "77 42 36", "output": "NO"}] |
Print `YES` or `NO`.
* * * | s521212572 | Runtime Error | p03730 | Input is given from Standard Input in the following format:
A B C | ans = 0
a, b, c = [ int(v) for v in input().split() ]
for i in range(1,b+1):
if (a * i) % b == c:
ans = 1
break
if ans == 1:
print("YES")
else: | Statement
We ask you to select some number of positive integers, and calculate the sum
of them.
It is allowed to select as many integers as you like, and as large integers as
you wish. You have to follow these, however: each selected integer needs to be
a multiple of A, and you need to select at least one integer.
Your objective is to make the sum congruent to C modulo B. Determine whether
this is possible.
If the objective is achievable, print `YES`. Otherwise, print `NO`. | [{"input": "7 5 1", "output": "YES\n \n\nFor example, if you select 7 and 14, the sum 21 is congruent to 1 modulo 5.\n\n* * *"}, {"input": "2 2 1", "output": "NO\n \n\nThe sum of even numbers, no matter how many, is never odd.\n\n* * *"}, {"input": "1 100 97", "output": "YES\n \n\nYou can select 97, since you may select multiples of 1, that is, all integers.\n\n* * *"}, {"input": "40 98 58", "output": "YES\n \n\n* * *"}, {"input": "77 42 36", "output": "NO"}] |
Print `YES` or `NO`.
* * * | s380846706 | Runtime Error | p03730 | Input is given from Standard Input in the following format:
A B C | A,B,C = [int(i) for i in input().split()]
Flag = False
for i in range(1,B+1):
D = i*A % B
if D = C:
Flag = True
break
if Flag == True:
print('YES')
else:
print('NO')
| Statement
We ask you to select some number of positive integers, and calculate the sum
of them.
It is allowed to select as many integers as you like, and as large integers as
you wish. You have to follow these, however: each selected integer needs to be
a multiple of A, and you need to select at least one integer.
Your objective is to make the sum congruent to C modulo B. Determine whether
this is possible.
If the objective is achievable, print `YES`. Otherwise, print `NO`. | [{"input": "7 5 1", "output": "YES\n \n\nFor example, if you select 7 and 14, the sum 21 is congruent to 1 modulo 5.\n\n* * *"}, {"input": "2 2 1", "output": "NO\n \n\nThe sum of even numbers, no matter how many, is never odd.\n\n* * *"}, {"input": "1 100 97", "output": "YES\n \n\nYou can select 97, since you may select multiples of 1, that is, all integers.\n\n* * *"}, {"input": "40 98 58", "output": "YES\n \n\n* * *"}, {"input": "77 42 36", "output": "NO"}] |
Print `YES` or `NO`.
* * * | s464295407 | Accepted | p03730 | Input is given from Standard Input in the following format:
A B C | a, b, c = (int(x) for x in input().split())
print("YES" if c in [a * (x + 1) % b for x in range(b)] else "NO")
| Statement
We ask you to select some number of positive integers, and calculate the sum
of them.
It is allowed to select as many integers as you like, and as large integers as
you wish. You have to follow these, however: each selected integer needs to be
a multiple of A, and you need to select at least one integer.
Your objective is to make the sum congruent to C modulo B. Determine whether
this is possible.
If the objective is achievable, print `YES`. Otherwise, print `NO`. | [{"input": "7 5 1", "output": "YES\n \n\nFor example, if you select 7 and 14, the sum 21 is congruent to 1 modulo 5.\n\n* * *"}, {"input": "2 2 1", "output": "NO\n \n\nThe sum of even numbers, no matter how many, is never odd.\n\n* * *"}, {"input": "1 100 97", "output": "YES\n \n\nYou can select 97, since you may select multiples of 1, that is, all integers.\n\n* * *"}, {"input": "40 98 58", "output": "YES\n \n\n* * *"}, {"input": "77 42 36", "output": "NO"}] |
Print `YES` or `NO`.
* * * | s531346022 | Accepted | p03730 | Input is given from Standard Input in the following format:
A B C | # ABC 060
# 基本
import math
def getInt():
return int(input())
def getIntList():
return [int(x) for x in input().split()]
def getIntFromRows(n):
return [int(input()) for i in range(n)]
def getIntMat(n):
mat = []
for i in range(n):
mat.append(getIntList())
return mat
def zeros(n):
return [0 for i in range(n)]
def zeros2(n, m):
return [[0 for i in range(m)] for j in range(n)]
N1097 = 10**9 + 7
debug = True
def db(x):
if debug:
print(x)
debug = False
a, b, c = getIntList()
rm = a % b
rslt = "NO"
for i in range(b + 1):
if a % b == c:
rslt = "YES"
break
a += rm
db(a)
print(rslt)
| Statement
We ask you to select some number of positive integers, and calculate the sum
of them.
It is allowed to select as many integers as you like, and as large integers as
you wish. You have to follow these, however: each selected integer needs to be
a multiple of A, and you need to select at least one integer.
Your objective is to make the sum congruent to C modulo B. Determine whether
this is possible.
If the objective is achievable, print `YES`. Otherwise, print `NO`. | [{"input": "7 5 1", "output": "YES\n \n\nFor example, if you select 7 and 14, the sum 21 is congruent to 1 modulo 5.\n\n* * *"}, {"input": "2 2 1", "output": "NO\n \n\nThe sum of even numbers, no matter how many, is never odd.\n\n* * *"}, {"input": "1 100 97", "output": "YES\n \n\nYou can select 97, since you may select multiples of 1, that is, all integers.\n\n* * *"}, {"input": "40 98 58", "output": "YES\n \n\n* * *"}, {"input": "77 42 36", "output": "NO"}] |
Print `YES` or `NO`.
* * * | s352529598 | Runtime Error | p03730 | Input is given from Standard Input in the following format:
A B C | # -*- coding: utf-8 -*-
A,B,C = map(int, input().split())
ans = "NO"
for i in range(B+1)):
res = A * i % B
if res == C:
ans = "YES"
break
print(ans) | Statement
We ask you to select some number of positive integers, and calculate the sum
of them.
It is allowed to select as many integers as you like, and as large integers as
you wish. You have to follow these, however: each selected integer needs to be
a multiple of A, and you need to select at least one integer.
Your objective is to make the sum congruent to C modulo B. Determine whether
this is possible.
If the objective is achievable, print `YES`. Otherwise, print `NO`. | [{"input": "7 5 1", "output": "YES\n \n\nFor example, if you select 7 and 14, the sum 21 is congruent to 1 modulo 5.\n\n* * *"}, {"input": "2 2 1", "output": "NO\n \n\nThe sum of even numbers, no matter how many, is never odd.\n\n* * *"}, {"input": "1 100 97", "output": "YES\n \n\nYou can select 97, since you may select multiples of 1, that is, all integers.\n\n* * *"}, {"input": "40 98 58", "output": "YES\n \n\n* * *"}, {"input": "77 42 36", "output": "NO"}] |
Print `YES` or `NO`.
* * * | s333836712 | Runtime Error | p03730 | Input is given from Standard Input in the following format:
A B C | # -*- coding: utf-8 -*-
A, B, C = map(int, input().split())
for i in range(1, B + 1)
if (A * i) % B == C:
print('YES')
exit()
print('NO') | Statement
We ask you to select some number of positive integers, and calculate the sum
of them.
It is allowed to select as many integers as you like, and as large integers as
you wish. You have to follow these, however: each selected integer needs to be
a multiple of A, and you need to select at least one integer.
Your objective is to make the sum congruent to C modulo B. Determine whether
this is possible.
If the objective is achievable, print `YES`. Otherwise, print `NO`. | [{"input": "7 5 1", "output": "YES\n \n\nFor example, if you select 7 and 14, the sum 21 is congruent to 1 modulo 5.\n\n* * *"}, {"input": "2 2 1", "output": "NO\n \n\nThe sum of even numbers, no matter how many, is never odd.\n\n* * *"}, {"input": "1 100 97", "output": "YES\n \n\nYou can select 97, since you may select multiples of 1, that is, all integers.\n\n* * *"}, {"input": "40 98 58", "output": "YES\n \n\n* * *"}, {"input": "77 42 36", "output": "NO"}] |
Print `YES` or `NO`.
* * * | s560143812 | Runtime Error | p03730 | Input is given from Standard Input in the following format:
A B C | ,b,c=map(int,input().split())
s={}
while True:
if a%b==c:
print("YES")
break
elif (a%b) in s:
print("NO")
break
else:
s.add((a%b))
a+=a | Statement
We ask you to select some number of positive integers, and calculate the sum
of them.
It is allowed to select as many integers as you like, and as large integers as
you wish. You have to follow these, however: each selected integer needs to be
a multiple of A, and you need to select at least one integer.
Your objective is to make the sum congruent to C modulo B. Determine whether
this is possible.
If the objective is achievable, print `YES`. Otherwise, print `NO`. | [{"input": "7 5 1", "output": "YES\n \n\nFor example, if you select 7 and 14, the sum 21 is congruent to 1 modulo 5.\n\n* * *"}, {"input": "2 2 1", "output": "NO\n \n\nThe sum of even numbers, no matter how many, is never odd.\n\n* * *"}, {"input": "1 100 97", "output": "YES\n \n\nYou can select 97, since you may select multiples of 1, that is, all integers.\n\n* * *"}, {"input": "40 98 58", "output": "YES\n \n\n* * *"}, {"input": "77 42 36", "output": "NO"}] |
Print `YES` or `NO`.
* * * | s726297060 | Runtime Error | p03730 | Input is given from Standard Input in the following format:
A B C | a,b,c=map(int,input().split())
for i in range(0:B):
if (i*a)%b==c:
print('YES')
break
print('NO') | Statement
We ask you to select some number of positive integers, and calculate the sum
of them.
It is allowed to select as many integers as you like, and as large integers as
you wish. You have to follow these, however: each selected integer needs to be
a multiple of A, and you need to select at least one integer.
Your objective is to make the sum congruent to C modulo B. Determine whether
this is possible.
If the objective is achievable, print `YES`. Otherwise, print `NO`. | [{"input": "7 5 1", "output": "YES\n \n\nFor example, if you select 7 and 14, the sum 21 is congruent to 1 modulo 5.\n\n* * *"}, {"input": "2 2 1", "output": "NO\n \n\nThe sum of even numbers, no matter how many, is never odd.\n\n* * *"}, {"input": "1 100 97", "output": "YES\n \n\nYou can select 97, since you may select multiples of 1, that is, all integers.\n\n* * *"}, {"input": "40 98 58", "output": "YES\n \n\n* * *"}, {"input": "77 42 36", "output": "NO"}] |
Print `YES` or `NO`.
* * * | s052361596 | Accepted | p03730 | Input is given from Standard Input in the following format:
A B C | import sys
## io ##
def IS():
return sys.stdin.readline().rstrip()
def II():
return int(IS())
def MII():
return list(map(int, IS().split()))
def MIIZ():
return list(map(lambda x: x - 1, MII()))
## dp ##
def DD2(d1, d2, init=0):
return [[init] * d2 for _ in range(d1)]
def DD3(d1, d2, d3, init=0):
return [DD2(d2, d3, init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str:
return format(x, "b") # rev => int(res, 2)
def to_oct(x: int) -> str:
return format(x, "o") # rev => int(res, 8)
def to_hex(x: int) -> str:
return format(x, "x") # rev => int(res, 16)
MOD = 10**9 + 7
def divc(x, y) -> int:
return -(-x // y)
def divf(x, y) -> int:
return x // y
def gcd(x, y):
while y:
x, y = y, x % y
return x
def lcm(x, y):
return x * y // gcd(x, y)
def enumerate_divs(n):
"""Return a tuple list of divisor of n"""
return [(i, n // i) for i in range(1, int(n**0.5) + 1) if n % i == 0]
def get_primes(MAX_NUM=10**3):
"""Return a list of prime numbers n or less"""
is_prime = [True] * (MAX_NUM + 1)
is_prime[0] = is_prime[1] = False
for i in range(2, int(MAX_NUM**0.5) + 1):
if not is_prime[i]:
continue
for j in range(i * 2, MAX_NUM + 1, i):
is_prime[j] = False
return [i for i in range(MAX_NUM + 1) if is_prime[i]]
## libs ##
from itertools import (
accumulate as acc,
combinations as combi,
product,
combinations_with_replacement as combi_dup,
)
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
# ======================================================#
def main():
a, b, c = MII()
r = a % b
ri = r
if r == 0:
if r == c:
print("YES")
return None
else:
print("NO")
return None
while r < 10**5:
if r % b == c:
print("YES")
return None
r += ri
print("NO")
if __name__ == "__main__":
main()
| Statement
We ask you to select some number of positive integers, and calculate the sum
of them.
It is allowed to select as many integers as you like, and as large integers as
you wish. You have to follow these, however: each selected integer needs to be
a multiple of A, and you need to select at least one integer.
Your objective is to make the sum congruent to C modulo B. Determine whether
this is possible.
If the objective is achievable, print `YES`. Otherwise, print `NO`. | [{"input": "7 5 1", "output": "YES\n \n\nFor example, if you select 7 and 14, the sum 21 is congruent to 1 modulo 5.\n\n* * *"}, {"input": "2 2 1", "output": "NO\n \n\nThe sum of even numbers, no matter how many, is never odd.\n\n* * *"}, {"input": "1 100 97", "output": "YES\n \n\nYou can select 97, since you may select multiples of 1, that is, all integers.\n\n* * *"}, {"input": "40 98 58", "output": "YES\n \n\n* * *"}, {"input": "77 42 36", "output": "NO"}] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.