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 the string obtained by concatenating all the characters in the odd- numbered positions. * * *
s652024095
Accepted
p03610
The input is given from Standard Input in the following format: s
from collections import defaultdict, Counter from itertools import product, groupby, count, permutations, combinations from math import pi, sqrt from collections import deque from bisect import bisect, bisect_left, bisect_right from string import ascii_lowercase from functools import lru_cache import sys sys.setrecursionlimit(10000) INF = float("inf") YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no" dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0] dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1] def inside(y, x, H, W): return 0 <= y < H and 0 <= x < W def ceil(a, b): return (a + b - 1) // b def main(): s = input() print("".join(s[i] for i in range(0, len(s), 2))) if __name__ == "__main__": main()
Statement You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
[{"input": "atcoder", "output": "acdr\n \n\nExtract the first character `a`, the third character `c`, the fifth character\n`d` and the seventh character `r` to obtain `acdr`.\n\n* * *"}, {"input": "aaaa", "output": "aa\n \n\n* * *"}, {"input": "z", "output": "z\n \n\n* * *"}, {"input": "fukuokayamaguchi", "output": "fkoaaauh"}]
Print the string obtained by concatenating all the characters in the odd- numbered positions. * * *
s479112435
Wrong Answer
p03610
The input is given from Standard Input in the following format: s
input()[0::2]
Statement You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
[{"input": "atcoder", "output": "acdr\n \n\nExtract the first character `a`, the third character `c`, the fifth character\n`d` and the seventh character `r` to obtain `acdr`.\n\n* * *"}, {"input": "aaaa", "output": "aa\n \n\n* * *"}, {"input": "z", "output": "z\n \n\n* * *"}, {"input": "fukuokayamaguchi", "output": "fkoaaauh"}]
Print the string obtained by concatenating all the characters in the odd- numbered positions. * * *
s578206553
Accepted
p03610
The input is given from Standard Input in the following format: s
print("".join(list(input())[0::2]))
Statement You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
[{"input": "atcoder", "output": "acdr\n \n\nExtract the first character `a`, the third character `c`, the fifth character\n`d` and the seventh character `r` to obtain `acdr`.\n\n* * *"}, {"input": "aaaa", "output": "aa\n \n\n* * *"}, {"input": "z", "output": "z\n \n\n* * *"}, {"input": "fukuokayamaguchi", "output": "fkoaaauh"}]
Print the string obtained by concatenating all the characters in the odd- numbered positions. * * *
s425792031
Wrong Answer
p03610
The input is given from Standard Input in the following format: s
print("".join(list(input())[1::2]))
Statement You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
[{"input": "atcoder", "output": "acdr\n \n\nExtract the first character `a`, the third character `c`, the fifth character\n`d` and the seventh character `r` to obtain `acdr`.\n\n* * *"}, {"input": "aaaa", "output": "aa\n \n\n* * *"}, {"input": "z", "output": "z\n \n\n* * *"}, {"input": "fukuokayamaguchi", "output": "fkoaaauh"}]
Print the string obtained by concatenating all the characters in the odd- numbered positions. * * *
s256934757
Accepted
p03610
The input is given from Standard Input in the following format: s
a = input() b = len(a) num = [] for x in range(0, b, 2): num.append(x) for i in num: print(a[i], end="")
Statement You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
[{"input": "atcoder", "output": "acdr\n \n\nExtract the first character `a`, the third character `c`, the fifth character\n`d` and the seventh character `r` to obtain `acdr`.\n\n* * *"}, {"input": "aaaa", "output": "aa\n \n\n* * *"}, {"input": "z", "output": "z\n \n\n* * *"}, {"input": "fukuokayamaguchi", "output": "fkoaaauh"}]
Print the string obtained by concatenating all the characters in the odd- numbered positions. * * *
s022709387
Runtime Error
p03610
The input is given from Standard Input in the following format: s
n = int(input()) a = [int(i) for i in input().split()] a.sort() count = 0 ans = [] for i in range(n): for j in range(n - 1): if j >= i and a[j] - a[i] <= 2: # print(i,j) count += 1 else: ans.append(count) count = 0 if n == 1: print(1) else: print(max(ans))
Statement You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
[{"input": "atcoder", "output": "acdr\n \n\nExtract the first character `a`, the third character `c`, the fifth character\n`d` and the seventh character `r` to obtain `acdr`.\n\n* * *"}, {"input": "aaaa", "output": "aa\n \n\n* * *"}, {"input": "z", "output": "z\n \n\n* * *"}, {"input": "fukuokayamaguchi", "output": "fkoaaauh"}]
Print the string obtained by concatenating all the characters in the odd- numbered positions. * * *
s155903370
Wrong Answer
p03610
The input is given from Standard Input in the following format: s
a = list(input()) if len(a) == 1: print("".join(a)) else: for i in a: if a.index(i) % 2 == 0: print(i, end="")
Statement You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
[{"input": "atcoder", "output": "acdr\n \n\nExtract the first character `a`, the third character `c`, the fifth character\n`d` and the seventh character `r` to obtain `acdr`.\n\n* * *"}, {"input": "aaaa", "output": "aa\n \n\n* * *"}, {"input": "z", "output": "z\n \n\n* * *"}, {"input": "fukuokayamaguchi", "output": "fkoaaauh"}]
Print the string obtained by concatenating all the characters in the odd- numbered positions. * * *
s612429459
Accepted
p03610
The input is given from Standard Input in the following format: s
s = input() count = 1 for a in s: if not count % 2 == 0: print(a, end="") count = count + 1
Statement You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
[{"input": "atcoder", "output": "acdr\n \n\nExtract the first character `a`, the third character `c`, the fifth character\n`d` and the seventh character `r` to obtain `acdr`.\n\n* * *"}, {"input": "aaaa", "output": "aa\n \n\n* * *"}, {"input": "z", "output": "z\n \n\n* * *"}, {"input": "fukuokayamaguchi", "output": "fkoaaauh"}]
Print the string obtained by concatenating all the characters in the odd- numbered positions. * * *
s946960670
Wrong Answer
p03610
The input is given from Standard Input in the following format: s
string = input() answer = [character for i, character in enumerate(string) if i % 2 == 1] for character in answer: print(character, end="", sep="")
Statement You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
[{"input": "atcoder", "output": "acdr\n \n\nExtract the first character `a`, the third character `c`, the fifth character\n`d` and the seventh character `r` to obtain `acdr`.\n\n* * *"}, {"input": "aaaa", "output": "aa\n \n\n* * *"}, {"input": "z", "output": "z\n \n\n* * *"}, {"input": "fukuokayamaguchi", "output": "fkoaaauh"}]
Print the string obtained by concatenating all the characters in the odd- numbered positions. * * *
s242659350
Runtime Error
p03610
The input is given from Standard Input in the following format: s
s = input() print(s.[::2])
Statement You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
[{"input": "atcoder", "output": "acdr\n \n\nExtract the first character `a`, the third character `c`, the fifth character\n`d` and the seventh character `r` to obtain `acdr`.\n\n* * *"}, {"input": "aaaa", "output": "aa\n \n\n* * *"}, {"input": "z", "output": "z\n \n\n* * *"}, {"input": "fukuokayamaguchi", "output": "fkoaaauh"}]
Print the string obtained by concatenating all the characters in the odd- numbered positions. * * *
s162180855
Runtime Error
p03610
The input is given from Standard Input in the following format: s
print(str(input(N))[::2])
Statement You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
[{"input": "atcoder", "output": "acdr\n \n\nExtract the first character `a`, the third character `c`, the fifth character\n`d` and the seventh character `r` to obtain `acdr`.\n\n* * *"}, {"input": "aaaa", "output": "aa\n \n\n* * *"}, {"input": "z", "output": "z\n \n\n* * *"}, {"input": "fukuokayamaguchi", "output": "fkoaaauh"}]
Print the string obtained by concatenating all the characters in the odd- numbered positions. * * *
s198825508
Runtime Error
p03610
The input is given from Standard Input in the following format: s
s = input() print(s[::2]
Statement You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
[{"input": "atcoder", "output": "acdr\n \n\nExtract the first character `a`, the third character `c`, the fifth character\n`d` and the seventh character `r` to obtain `acdr`.\n\n* * *"}, {"input": "aaaa", "output": "aa\n \n\n* * *"}, {"input": "z", "output": "z\n \n\n* * *"}, {"input": "fukuokayamaguchi", "output": "fkoaaauh"}]
Print the string obtained by concatenating all the characters in the odd- numbered positions. * * *
s279296748
Runtime Error
p03610
The input is given from Standard Input in the following format: s
L = index() print(L[::2])
Statement You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
[{"input": "atcoder", "output": "acdr\n \n\nExtract the first character `a`, the third character `c`, the fifth character\n`d` and the seventh character `r` to obtain `acdr`.\n\n* * *"}, {"input": "aaaa", "output": "aa\n \n\n* * *"}, {"input": "z", "output": "z\n \n\n* * *"}, {"input": "fukuokayamaguchi", "output": "fkoaaauh"}]
Print the string obtained by concatenating all the characters in the odd- numbered positions. * * *
s072782159
Runtime Error
p03610
The input is given from Standard Input in the following format: s
atcoder
Statement You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
[{"input": "atcoder", "output": "acdr\n \n\nExtract the first character `a`, the third character `c`, the fifth character\n`d` and the seventh character `r` to obtain `acdr`.\n\n* * *"}, {"input": "aaaa", "output": "aa\n \n\n* * *"}, {"input": "z", "output": "z\n \n\n* * *"}, {"input": "fukuokayamaguchi", "output": "fkoaaauh"}]
Print the string obtained by concatenating all the characters in the odd- numbered positions. * * *
s237217735
Runtime Error
p03610
The input is given from Standard Input in the following format: s
print(input[::2])
Statement You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
[{"input": "atcoder", "output": "acdr\n \n\nExtract the first character `a`, the third character `c`, the fifth character\n`d` and the seventh character `r` to obtain `acdr`.\n\n* * *"}, {"input": "aaaa", "output": "aa\n \n\n* * *"}, {"input": "z", "output": "z\n \n\n* * *"}, {"input": "fukuokayamaguchi", "output": "fkoaaauh"}]
Print the string obtained by concatenating all the characters in the odd- numbered positions. * * *
s571554239
Runtime Error
p03610
The input is given from Standard Input in the following format: s
s=list(input()) s2="" for i in range(len(s)): if i%==0: s2+=s[i] print(s2)
Statement You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
[{"input": "atcoder", "output": "acdr\n \n\nExtract the first character `a`, the third character `c`, the fifth character\n`d` and the seventh character `r` to obtain `acdr`.\n\n* * *"}, {"input": "aaaa", "output": "aa\n \n\n* * *"}, {"input": "z", "output": "z\n \n\n* * *"}, {"input": "fukuokayamaguchi", "output": "fkoaaauh"}]
Print the string obtained by concatenating all the characters in the odd- numbered positions. * * *
s676803046
Runtime Error
p03610
The input is given from Standard Input in the following format: s
s=list(input()) s2='' for i in range(len(s)): if i%==0: s2+=s[i] print(s2)
Statement You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
[{"input": "atcoder", "output": "acdr\n \n\nExtract the first character `a`, the third character `c`, the fifth character\n`d` and the seventh character `r` to obtain `acdr`.\n\n* * *"}, {"input": "aaaa", "output": "aa\n \n\n* * *"}, {"input": "z", "output": "z\n \n\n* * *"}, {"input": "fukuokayamaguchi", "output": "fkoaaauh"}]
Print the string obtained by concatenating all the characters in the odd- numbered positions. * * *
s464028560
Runtime Error
p03610
The input is given from Standard Input in the following format: s
S = list(input()) print(S) for v in S[0::2] print(v)
Statement You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
[{"input": "atcoder", "output": "acdr\n \n\nExtract the first character `a`, the third character `c`, the fifth character\n`d` and the seventh character `r` to obtain `acdr`.\n\n* * *"}, {"input": "aaaa", "output": "aa\n \n\n* * *"}, {"input": "z", "output": "z\n \n\n* * *"}, {"input": "fukuokayamaguchi", "output": "fkoaaauh"}]
Print the string obtained by concatenating all the characters in the odd- numbered positions. * * *
s764084830
Runtime Error
p03610
The input is given from Standard Input in the following format: s
s = input() print("".join([s[i] for i in range(0, len(s), 2)))
Statement You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
[{"input": "atcoder", "output": "acdr\n \n\nExtract the first character `a`, the third character `c`, the fifth character\n`d` and the seventh character `r` to obtain `acdr`.\n\n* * *"}, {"input": "aaaa", "output": "aa\n \n\n* * *"}, {"input": "z", "output": "z\n \n\n* * *"}, {"input": "fukuokayamaguchi", "output": "fkoaaauh"}]
Print the string obtained by concatenating all the characters in the odd- numbered positions. * * *
s749566040
Runtime Error
p03610
The input is given from Standard Input in the following format: s
s=str(input()) x=list(s) if i in len(x):
Statement You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
[{"input": "atcoder", "output": "acdr\n \n\nExtract the first character `a`, the third character `c`, the fifth character\n`d` and the seventh character `r` to obtain `acdr`.\n\n* * *"}, {"input": "aaaa", "output": "aa\n \n\n* * *"}, {"input": "z", "output": "z\n \n\n* * *"}, {"input": "fukuokayamaguchi", "output": "fkoaaauh"}]
Print the string obtained by concatenating all the characters in the odd- numbered positions. * * *
s176825401
Runtime Error
p03610
The input is given from Standard Input in the following format: s
s = input() ans = "" for i in range(0,len(s),2) ans += s[i] print(ans)
Statement You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
[{"input": "atcoder", "output": "acdr\n \n\nExtract the first character `a`, the third character `c`, the fifth character\n`d` and the seventh character `r` to obtain `acdr`.\n\n* * *"}, {"input": "aaaa", "output": "aa\n \n\n* * *"}, {"input": "z", "output": "z\n \n\n* * *"}, {"input": "fukuokayamaguchi", "output": "fkoaaauh"}]
Print the string obtained by concatenating all the characters in the odd- numbered positions. * * *
s599031536
Runtime Error
p03610
The input is given from Standard Input in the following format: s
s = str(input()) print(0:len(s):2)
Statement You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
[{"input": "atcoder", "output": "acdr\n \n\nExtract the first character `a`, the third character `c`, the fifth character\n`d` and the seventh character `r` to obtain `acdr`.\n\n* * *"}, {"input": "aaaa", "output": "aa\n \n\n* * *"}, {"input": "z", "output": "z\n \n\n* * *"}, {"input": "fukuokayamaguchi", "output": "fkoaaauh"}]
Print the string obtained by concatenating all the characters in the odd- numbered positions. * * *
s945130136
Runtime Error
p03610
The input is given from Standard Input in the following format: s
letters = list(input().split()) new_letters = [] for i, item in enumerate(letters, 1) if i % 2 != 0 new_letters.append(item) print(''.join(new_letters))
Statement You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
[{"input": "atcoder", "output": "acdr\n \n\nExtract the first character `a`, the third character `c`, the fifth character\n`d` and the seventh character `r` to obtain `acdr`.\n\n* * *"}, {"input": "aaaa", "output": "aa\n \n\n* * *"}, {"input": "z", "output": "z\n \n\n* * *"}, {"input": "fukuokayamaguchi", "output": "fkoaaauh"}]
Print the string obtained by concatenating all the characters in the odd- numbered positions. * * *
s813982105
Runtime Error
p03610
The input is given from Standard Input in the following format: s
s = input() oddstring = s[0] a = (len(s) + 1) // 2 for i in renge(a-1)}: oddstring += s[2*i+2] print(oddstring)
Statement You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
[{"input": "atcoder", "output": "acdr\n \n\nExtract the first character `a`, the third character `c`, the fifth character\n`d` and the seventh character `r` to obtain `acdr`.\n\n* * *"}, {"input": "aaaa", "output": "aa\n \n\n* * *"}, {"input": "z", "output": "z\n \n\n* * *"}, {"input": "fukuokayamaguchi", "output": "fkoaaauh"}]
Print the string obtained by concatenating all the characters in the odd- numbered positions. * * *
s302722084
Runtime Error
p03610
The input is given from Standard Input in the following format: s
import math # input s = input() ans = '' for i in range(math.ceil(len(s) // 2): ans = ans + s[2 * i] print(ans)
Statement You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
[{"input": "atcoder", "output": "acdr\n \n\nExtract the first character `a`, the third character `c`, the fifth character\n`d` and the seventh character `r` to obtain `acdr`.\n\n* * *"}, {"input": "aaaa", "output": "aa\n \n\n* * *"}, {"input": "z", "output": "z\n \n\n* * *"}, {"input": "fukuokayamaguchi", "output": "fkoaaauh"}]
Print the string obtained by concatenating all the characters in the odd- numbered positions. * * *
s984590805
Runtime Error
p03610
The input is given from Standard Input in the following format: s
s = input() cnt = 0 strings = "" for i in s: if cnt % 2 == 0: strings.= strings + i print(strings)
Statement You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
[{"input": "atcoder", "output": "acdr\n \n\nExtract the first character `a`, the third character `c`, the fifth character\n`d` and the seventh character `r` to obtain `acdr`.\n\n* * *"}, {"input": "aaaa", "output": "aa\n \n\n* * *"}, {"input": "z", "output": "z\n \n\n* * *"}, {"input": "fukuokayamaguchi", "output": "fkoaaauh"}]
Print n lines. In the i-th line, print the maximum amount of snuuk that Kenkoooo has when he reaches City t if he goes on a trip from City s to City t after i-1 years. * * *
s313170125
Runtime Error
p03305
Input is given from Standard Input in the following format: n m s t u_1 v_1 a_1 b_1 : u_m v_m a_m b_m
# import sys # fin = sys.stdin.readline from collections import defaultdict from heapq import heappop, heappush def initialize(adj, s): MAX_NUM = float('inf') parent = {s: None} d = {vertex: MAX_NUM for vertex in adj.keys()} d[s] = 0 return d, parent # Dijkstra can work using a minheap which does not have decrease_key. # and also we do not have to implement Vertex class. # Instead, we can use (distance, vertex). # in this case, the time it takes is O(ElgE). # E is at most O(V^2), thus O(ElgE) = O(ElgV). def dijkstra_simple(adj, w, s): d, parent = initialize(adj, s) priority_queue = [] heappush(priority_queue, (d[s], s)) while priority_queue: distance, source = heappop(priority_queue) for neighbor in adj[source]: new_distance = distance + w[(source, neighbor)] if new_distance < d[neighbor]: d[neighbor] = new_distance parent[neighbor] = source heappush(priority_queue, (new_distance, neighbor)) return d n, m, s, t = map(int, input().split()) adj = defaultdict(list) yen_weights = dict() snuuk_weights = dict() for _ in range(m): u, v, a, b = map(int, input().split()) for v1, v2 in [(u, v), (v, u)]: adj[v1].append(v2) yen_weights[(v1, v2)] = a snuuk_weights[(v1, v2)] = b d_yen = dijkstra_simple(adj, yen_weights, s) d_snuuk = dijkstra_simple(adj, snuuk_weights, t) min_cost = float('inf') min_cost_after_each_year_reversed = [] for vertex in range(n, 0, -1): min_cost = min(min_cost, d_yen[vertex] + d_snuuk[vertex]) min_cost_after_each_year_reversed.append(min_cost) initial_money = 10**15 print(*(initial_money - cost for cost in reversed(min_cost_after_each_year_reversed)), sep='\n') in reversed(min_cost_after_each_year_reversed)), sep='\n')
Statement Kenkoooo is planning a trip in Republic of Snuke. In this country, there are n cities and m trains running. The cities are numbered 1 through n, and the i-th train connects City u_i and v_i bidirectionally. Any city can be reached from any city by changing trains. Two currencies are used in the country: yen and snuuk. Any train fare can be paid by both yen and snuuk. The fare of the i-th train is a_i yen if paid in yen, and b_i snuuk if paid in snuuk. In a city with a money exchange office, you can change 1 yen into 1 snuuk. However, when you do a money exchange, you have to change all your yen into snuuk. That is, if Kenkoooo does a money exchange when he has X yen, he will then have X snuuk. Currently, there is a money exchange office in every city, but the office in City i will shut down in i years and can never be used in and after that year. Kenkoooo is planning to depart City s with 10^{15} yen in his pocket and head for City t, and change his yen into snuuk in some city while traveling. It is acceptable to do the exchange in City s or City t. Kenkoooo would like to have as much snuuk as possible when he reaches City t by making the optimal choices for the route to travel and the city to do the exchange. For each i=0,...,n-1, find the maximum amount of snuuk that Kenkoooo has when he reaches City t if he goes on a trip from City s to City t after i years. You can assume that the trip finishes within the year.
[{"input": "4 3 2 3\n 1 4 1 100\n 1 2 1 10\n 1 3 20 1", "output": "999999999999998\n 999999999999989\n 999999999999979\n 999999999999897\n \n\nAfter 0 years, it is optimal to do the exchange in City 1. \nAfter 1 years, it is optimal to do the exchange in City 2. \nNote that City 1 can still be visited even after the exchange office is\nclosed. Also note that, if it was allowed to keep 1 yen when do the exchange\nin City 2 and change the remaining yen into snuuk, we could reach City 3 with\n999999999999998 snuuk, but this is NOT allowed. \nAfter 2 years, it is optimal to do the exchange in City 3. \nAfter 3 years, it is optimal to do the exchange in City 4. Note that the same\ntrain can be used multiple times.\n\n* * *"}, {"input": "8 12 3 8\n 2 8 685087149 857180777\n 6 7 298270585 209942236\n 2 4 346080035 234079976\n 2 5 131857300 22507157\n 4 8 30723332 173476334\n 2 6 480845267 448565596\n 1 4 181424400 548830121\n 4 5 57429995 195056405\n 7 8 160277628 479932440\n 1 6 475692952 203530153\n 3 5 336869679 160714712\n 2 7 389775999 199123879", "output": "999999574976994\n 999999574976994\n 999999574976994\n 999999574976994\n 999999574976994\n 999999574976994\n 999999574976994\n 999999574976994"}]
Print n lines. In the i-th line, print the maximum amount of snuuk that Kenkoooo has when he reaches City t if he goes on a trip from City s to City t after i-1 years. * * *
s650113543
Runtime Error
p03305
Input is given from Standard Input in the following format: n m s t u_1 v_1 a_1 b_1 : u_m v_m a_m b_m
inp = list(map(int, input().split())) n = inp[0] # the num of node m = inp[1] # the num of edge s = inp[2] - 1 # start t = inp[3] - 1 # stop u = [] # edge (smaller) v = [] # edge (larger) a = [] # fare (yen) b = [] # fare (snuke) for i in range(m): inp = list(map(int, input().split())) u.append(inp[0] - 1) v.append(inp[1] - 1) a.append(inp[2]) b.append(inp[3]) uu = [[] for i in range(n)] for i in range(m): uu[u[i]].append([v[i], a[i], b[i]]) uu[v[i]].append([u[i], a[i], b[i]]) # Dijkstra's Algorithm # fare: 1 => yen, 2 => snuke def cheaper(start, stop, fare): if (start == stop): return 0 flag = [0 for i in range(n)] distance = [-1 for i in range(n)] flag[start] = 1 distance[start] = 0 base = start changeList = set([]) for i in range(n - 1): # update distance for j in len(uu[base]): befo = distance[uu[base][j][0]] afte = distance[base] + uu[base][j][fare] if (afte < befo or befo == -1): distance[uu[base][j][0]] = afte changeList.add(uu[base][j][0]]) # update base base = list(changeList)[0] for j in changeList: if (distance[j] < distance[base]): base = j changeList.remove(base) # update flag (using updated base) flag[base] = 1 # check break if (base == stop): break return distance[base] totalFare = [] for ex in range(n): # ex: exchange totalFare.append(cheaper(s, ex, a) + cheaper(ex, t, b)) for i in range(n): money = 10 ** 15 print(money - min(totalFare)) del totalFare[0]
Statement Kenkoooo is planning a trip in Republic of Snuke. In this country, there are n cities and m trains running. The cities are numbered 1 through n, and the i-th train connects City u_i and v_i bidirectionally. Any city can be reached from any city by changing trains. Two currencies are used in the country: yen and snuuk. Any train fare can be paid by both yen and snuuk. The fare of the i-th train is a_i yen if paid in yen, and b_i snuuk if paid in snuuk. In a city with a money exchange office, you can change 1 yen into 1 snuuk. However, when you do a money exchange, you have to change all your yen into snuuk. That is, if Kenkoooo does a money exchange when he has X yen, he will then have X snuuk. Currently, there is a money exchange office in every city, but the office in City i will shut down in i years and can never be used in and after that year. Kenkoooo is planning to depart City s with 10^{15} yen in his pocket and head for City t, and change his yen into snuuk in some city while traveling. It is acceptable to do the exchange in City s or City t. Kenkoooo would like to have as much snuuk as possible when he reaches City t by making the optimal choices for the route to travel and the city to do the exchange. For each i=0,...,n-1, find the maximum amount of snuuk that Kenkoooo has when he reaches City t if he goes on a trip from City s to City t after i years. You can assume that the trip finishes within the year.
[{"input": "4 3 2 3\n 1 4 1 100\n 1 2 1 10\n 1 3 20 1", "output": "999999999999998\n 999999999999989\n 999999999999979\n 999999999999897\n \n\nAfter 0 years, it is optimal to do the exchange in City 1. \nAfter 1 years, it is optimal to do the exchange in City 2. \nNote that City 1 can still be visited even after the exchange office is\nclosed. Also note that, if it was allowed to keep 1 yen when do the exchange\nin City 2 and change the remaining yen into snuuk, we could reach City 3 with\n999999999999998 snuuk, but this is NOT allowed. \nAfter 2 years, it is optimal to do the exchange in City 3. \nAfter 3 years, it is optimal to do the exchange in City 4. Note that the same\ntrain can be used multiple times.\n\n* * *"}, {"input": "8 12 3 8\n 2 8 685087149 857180777\n 6 7 298270585 209942236\n 2 4 346080035 234079976\n 2 5 131857300 22507157\n 4 8 30723332 173476334\n 2 6 480845267 448565596\n 1 4 181424400 548830121\n 4 5 57429995 195056405\n 7 8 160277628 479932440\n 1 6 475692952 203530153\n 3 5 336869679 160714712\n 2 7 389775999 199123879", "output": "999999574976994\n 999999574976994\n 999999574976994\n 999999574976994\n 999999574976994\n 999999574976994\n 999999574976994\n 999999574976994"}]
Print n lines. In the i-th line, print the maximum amount of snuuk that Kenkoooo has when he reaches City t if he goes on a trip from City s to City t after i-1 years. * * *
s963557078
Runtime Error
p03305
Input is given from Standard Input in the following format: n m s t u_1 v_1 a_1 b_1 : u_m v_m a_m b_m
import heapq n, m, s, t = map(int, input().split()) INF = 10**20 data = [] for _ in range(m): data.append(list(map(int, input().split()))) check = [False] * (n+1) graph = [[] for i in range(n+1)] for i in range(m): graph[data[i][0]].append([data[i][1], data[i][2], data[i][3]]) graph[data[i][1]].append([data[i][0], data[i][2], data[i][3]]) city_yen_cost = [INF] * (n+1) city_yen_cost[s] = 0 queue = [] #[cost, vertex] heapq.heappush(queue, [0, s]) count = 0 while count != n: now = heapq.heappop(queue) if check[now[1]]: continue else: count += 1 check[now[1]] = True for path in graph[now[1]]: if not check[path[0]]: if city_yen_cost[now[1]]+path[1] < city_yen_cost[path[0]]: city_yen_cost[path[0]] = city_yen_cost[now[1]]+path[1] heapq.heappush(queue, [city_yen_cost[now[1]]+path[1], path[0]]) check = [False] * (n+1) city_snuke_cost = [INF] * (n+1) city_snuke_cost[t] = 0 queue = [] heapq.heappush(queue, [0, t]) count = 0 while count != n: now = heapq.heappop(queue) if check[now[1]]: continue else: count += 1 check[now[1]] = True for path in graph[now[1]]: if not check[path[0]]: if city_snuke_cost[now[1]]+path[2] < city_snuke_cost[path[0]] city_snuke_cost[path[0]] = city_snuke_cost[now[1]]+path[2] heapq.heappush(queue, [city_snuke_cost[now[1]]+path[2], path[0]]) for i in range(n+1): city_yen_cost[i] += city_snuke_cost[i] for i in range(n): city_yen_cost[-i-2] = min(city_yen_cost[-i-2], city_yen_cost[-i-1]) for i in range(n): print(10**15-city_yen_cost[i+1])
Statement Kenkoooo is planning a trip in Republic of Snuke. In this country, there are n cities and m trains running. The cities are numbered 1 through n, and the i-th train connects City u_i and v_i bidirectionally. Any city can be reached from any city by changing trains. Two currencies are used in the country: yen and snuuk. Any train fare can be paid by both yen and snuuk. The fare of the i-th train is a_i yen if paid in yen, and b_i snuuk if paid in snuuk. In a city with a money exchange office, you can change 1 yen into 1 snuuk. However, when you do a money exchange, you have to change all your yen into snuuk. That is, if Kenkoooo does a money exchange when he has X yen, he will then have X snuuk. Currently, there is a money exchange office in every city, but the office in City i will shut down in i years and can never be used in and after that year. Kenkoooo is planning to depart City s with 10^{15} yen in his pocket and head for City t, and change his yen into snuuk in some city while traveling. It is acceptable to do the exchange in City s or City t. Kenkoooo would like to have as much snuuk as possible when he reaches City t by making the optimal choices for the route to travel and the city to do the exchange. For each i=0,...,n-1, find the maximum amount of snuuk that Kenkoooo has when he reaches City t if he goes on a trip from City s to City t after i years. You can assume that the trip finishes within the year.
[{"input": "4 3 2 3\n 1 4 1 100\n 1 2 1 10\n 1 3 20 1", "output": "999999999999998\n 999999999999989\n 999999999999979\n 999999999999897\n \n\nAfter 0 years, it is optimal to do the exchange in City 1. \nAfter 1 years, it is optimal to do the exchange in City 2. \nNote that City 1 can still be visited even after the exchange office is\nclosed. Also note that, if it was allowed to keep 1 yen when do the exchange\nin City 2 and change the remaining yen into snuuk, we could reach City 3 with\n999999999999998 snuuk, but this is NOT allowed. \nAfter 2 years, it is optimal to do the exchange in City 3. \nAfter 3 years, it is optimal to do the exchange in City 4. Note that the same\ntrain can be used multiple times.\n\n* * *"}, {"input": "8 12 3 8\n 2 8 685087149 857180777\n 6 7 298270585 209942236\n 2 4 346080035 234079976\n 2 5 131857300 22507157\n 4 8 30723332 173476334\n 2 6 480845267 448565596\n 1 4 181424400 548830121\n 4 5 57429995 195056405\n 7 8 160277628 479932440\n 1 6 475692952 203530153\n 3 5 336869679 160714712\n 2 7 389775999 199123879", "output": "999999574976994\n 999999574976994\n 999999574976994\n 999999574976994\n 999999574976994\n 999999574976994\n 999999574976994\n 999999574976994"}]
Print n lines. In the i-th line, print the maximum amount of snuuk that Kenkoooo has when he reaches City t if he goes on a trip from City s to City t after i-1 years. * * *
s314337251
Runtime Error
p03305
Input is given from Standard Input in the following format: n m s t u_1 v_1 a_1 b_1 : u_m v_m a_m b_m
import sys input = sys.stdin.buffer.readline import heapq N,M,S,T = map(int,input().split()) adj=[set()]*N for _ in range(M): a,b,c,d = map(int,input().split()) adj[a-1].add((b-1,c,d)) adj[b-1].add((a-1,c,d)) D_S=[float("inf")]*N D_T=[float("inf")]*N D_S[S-1]=0 D_T[T-1]=0 Q=[] heapq.heappush(Q,(0,S-1)) while Q: dist_to_node,node = heapq.heappop(Q) if D_S[node]< dist_to_node: continue for nex in adj[node]: (next_node,yen,_) = nex if dist_to_node+yen>=D_S[next_node]: continue else: D_S[next_node] = dist_to_node+yen heapq.heappush(Q,(D_S[next_node],next_node)) Q=[] heapq.heappush(Q,(0,T-1)) while Q: dist_to_node,node = heapq.heappop(Q) if D_T[node]< dist_to_node: continue for nex in adj[node]: (next_node,_,yen) = nex if dist_to_node+yen>=D_T[next_node]: continue else: D_T[next_node] = dist_to_node+yen heapq.heappush(Q,(D_T[next_node],next_node)) tmp_min=float("inf") ans=[] gor i in reversed(range(N)): tmp_min = min(tmp_min,D_S[i]+D_T[i]) ans.append(tmp_min) for a in reversed(ans): print(10**15-a)
Statement Kenkoooo is planning a trip in Republic of Snuke. In this country, there are n cities and m trains running. The cities are numbered 1 through n, and the i-th train connects City u_i and v_i bidirectionally. Any city can be reached from any city by changing trains. Two currencies are used in the country: yen and snuuk. Any train fare can be paid by both yen and snuuk. The fare of the i-th train is a_i yen if paid in yen, and b_i snuuk if paid in snuuk. In a city with a money exchange office, you can change 1 yen into 1 snuuk. However, when you do a money exchange, you have to change all your yen into snuuk. That is, if Kenkoooo does a money exchange when he has X yen, he will then have X snuuk. Currently, there is a money exchange office in every city, but the office in City i will shut down in i years and can never be used in and after that year. Kenkoooo is planning to depart City s with 10^{15} yen in his pocket and head for City t, and change his yen into snuuk in some city while traveling. It is acceptable to do the exchange in City s or City t. Kenkoooo would like to have as much snuuk as possible when he reaches City t by making the optimal choices for the route to travel and the city to do the exchange. For each i=0,...,n-1, find the maximum amount of snuuk that Kenkoooo has when he reaches City t if he goes on a trip from City s to City t after i years. You can assume that the trip finishes within the year.
[{"input": "4 3 2 3\n 1 4 1 100\n 1 2 1 10\n 1 3 20 1", "output": "999999999999998\n 999999999999989\n 999999999999979\n 999999999999897\n \n\nAfter 0 years, it is optimal to do the exchange in City 1. \nAfter 1 years, it is optimal to do the exchange in City 2. \nNote that City 1 can still be visited even after the exchange office is\nclosed. Also note that, if it was allowed to keep 1 yen when do the exchange\nin City 2 and change the remaining yen into snuuk, we could reach City 3 with\n999999999999998 snuuk, but this is NOT allowed. \nAfter 2 years, it is optimal to do the exchange in City 3. \nAfter 3 years, it is optimal to do the exchange in City 4. Note that the same\ntrain can be used multiple times.\n\n* * *"}, {"input": "8 12 3 8\n 2 8 685087149 857180777\n 6 7 298270585 209942236\n 2 4 346080035 234079976\n 2 5 131857300 22507157\n 4 8 30723332 173476334\n 2 6 480845267 448565596\n 1 4 181424400 548830121\n 4 5 57429995 195056405\n 7 8 160277628 479932440\n 1 6 475692952 203530153\n 3 5 336869679 160714712\n 2 7 389775999 199123879", "output": "999999574976994\n 999999574976994\n 999999574976994\n 999999574976994\n 999999574976994\n 999999574976994\n 999999574976994\n 999999574976994"}]
Print n lines. In the i-th line, print the maximum amount of snuuk that Kenkoooo has when he reaches City t if he goes on a trip from City s to City t after i-1 years. * * *
s075005292
Runtime Error
p03305
Input is given from Standard Input in the following format: n m s t u_1 v_1 a_1 b_1 : u_m v_m a_m b_m
from scipy.sparse.csgraph import dijkstra from scipy.sparse import csr_matrix N, M, S, T, *UVAB = map(int, open(0).read().split()) A, B, R, C = [], [], [], [] for u, v, a, b in zip(*[iter(UVAB)] * 4): A.append(a) B.append(b) R.append(u) C.append(v) A = dijkstra(csr_matrix((A, (R, C)), (N + 1, N + 1)), False, S, min_only=True) B = dijkstra(csr_matrix((B, (R, C)), (N + 1, N + 1)), False, T, min_only=True) C = (A + B).astype(int) init = 10**15 ans = [] cur = float("inf") for c in reversed(C[1:]): cur = min(cur, c) ans.append(init - cur) for a in reversed(ans): print(a)
Statement Kenkoooo is planning a trip in Republic of Snuke. In this country, there are n cities and m trains running. The cities are numbered 1 through n, and the i-th train connects City u_i and v_i bidirectionally. Any city can be reached from any city by changing trains. Two currencies are used in the country: yen and snuuk. Any train fare can be paid by both yen and snuuk. The fare of the i-th train is a_i yen if paid in yen, and b_i snuuk if paid in snuuk. In a city with a money exchange office, you can change 1 yen into 1 snuuk. However, when you do a money exchange, you have to change all your yen into snuuk. That is, if Kenkoooo does a money exchange when he has X yen, he will then have X snuuk. Currently, there is a money exchange office in every city, but the office in City i will shut down in i years and can never be used in and after that year. Kenkoooo is planning to depart City s with 10^{15} yen in his pocket and head for City t, and change his yen into snuuk in some city while traveling. It is acceptable to do the exchange in City s or City t. Kenkoooo would like to have as much snuuk as possible when he reaches City t by making the optimal choices for the route to travel and the city to do the exchange. For each i=0,...,n-1, find the maximum amount of snuuk that Kenkoooo has when he reaches City t if he goes on a trip from City s to City t after i years. You can assume that the trip finishes within the year.
[{"input": "4 3 2 3\n 1 4 1 100\n 1 2 1 10\n 1 3 20 1", "output": "999999999999998\n 999999999999989\n 999999999999979\n 999999999999897\n \n\nAfter 0 years, it is optimal to do the exchange in City 1. \nAfter 1 years, it is optimal to do the exchange in City 2. \nNote that City 1 can still be visited even after the exchange office is\nclosed. Also note that, if it was allowed to keep 1 yen when do the exchange\nin City 2 and change the remaining yen into snuuk, we could reach City 3 with\n999999999999998 snuuk, but this is NOT allowed. \nAfter 2 years, it is optimal to do the exchange in City 3. \nAfter 3 years, it is optimal to do the exchange in City 4. Note that the same\ntrain can be used multiple times.\n\n* * *"}, {"input": "8 12 3 8\n 2 8 685087149 857180777\n 6 7 298270585 209942236\n 2 4 346080035 234079976\n 2 5 131857300 22507157\n 4 8 30723332 173476334\n 2 6 480845267 448565596\n 1 4 181424400 548830121\n 4 5 57429995 195056405\n 7 8 160277628 479932440\n 1 6 475692952 203530153\n 3 5 336869679 160714712\n 2 7 389775999 199123879", "output": "999999574976994\n 999999574976994\n 999999574976994\n 999999574976994\n 999999574976994\n 999999574976994\n 999999574976994\n 999999574976994"}]
Print n lines. In the i-th line, print the maximum amount of snuuk that Kenkoooo has when he reaches City t if he goes on a trip from City s to City t after i-1 years. * * *
s288022708
Runtime Error
p03305
Input is given from Standard Input in the following format: n m s t u_1 v_1 a_1 b_1 : u_m v_m a_m b_m
n, m, d = map(int, input().split()) if d == 0: print((m - 1) / n) else: print((m - 1) * 2 * (n - d) / n**2)
Statement Kenkoooo is planning a trip in Republic of Snuke. In this country, there are n cities and m trains running. The cities are numbered 1 through n, and the i-th train connects City u_i and v_i bidirectionally. Any city can be reached from any city by changing trains. Two currencies are used in the country: yen and snuuk. Any train fare can be paid by both yen and snuuk. The fare of the i-th train is a_i yen if paid in yen, and b_i snuuk if paid in snuuk. In a city with a money exchange office, you can change 1 yen into 1 snuuk. However, when you do a money exchange, you have to change all your yen into snuuk. That is, if Kenkoooo does a money exchange when he has X yen, he will then have X snuuk. Currently, there is a money exchange office in every city, but the office in City i will shut down in i years and can never be used in and after that year. Kenkoooo is planning to depart City s with 10^{15} yen in his pocket and head for City t, and change his yen into snuuk in some city while traveling. It is acceptable to do the exchange in City s or City t. Kenkoooo would like to have as much snuuk as possible when he reaches City t by making the optimal choices for the route to travel and the city to do the exchange. For each i=0,...,n-1, find the maximum amount of snuuk that Kenkoooo has when he reaches City t if he goes on a trip from City s to City t after i years. You can assume that the trip finishes within the year.
[{"input": "4 3 2 3\n 1 4 1 100\n 1 2 1 10\n 1 3 20 1", "output": "999999999999998\n 999999999999989\n 999999999999979\n 999999999999897\n \n\nAfter 0 years, it is optimal to do the exchange in City 1. \nAfter 1 years, it is optimal to do the exchange in City 2. \nNote that City 1 can still be visited even after the exchange office is\nclosed. Also note that, if it was allowed to keep 1 yen when do the exchange\nin City 2 and change the remaining yen into snuuk, we could reach City 3 with\n999999999999998 snuuk, but this is NOT allowed. \nAfter 2 years, it is optimal to do the exchange in City 3. \nAfter 3 years, it is optimal to do the exchange in City 4. Note that the same\ntrain can be used multiple times.\n\n* * *"}, {"input": "8 12 3 8\n 2 8 685087149 857180777\n 6 7 298270585 209942236\n 2 4 346080035 234079976\n 2 5 131857300 22507157\n 4 8 30723332 173476334\n 2 6 480845267 448565596\n 1 4 181424400 548830121\n 4 5 57429995 195056405\n 7 8 160277628 479932440\n 1 6 475692952 203530153\n 3 5 336869679 160714712\n 2 7 389775999 199123879", "output": "999999574976994\n 999999574976994\n 999999574976994\n 999999574976994\n 999999574976994\n 999999574976994\n 999999574976994\n 999999574976994"}]
Print n lines. In the i-th line, print the maximum amount of snuuk that Kenkoooo has when he reaches City t if he goes on a trip from City s to City t after i-1 years. * * *
s117615831
Runtime Error
p03305
Input is given from Standard Input in the following format: n m s t u_1 v_1 a_1 b_1 : u_m v_m a_m b_m
from heapq import * INF = 10**15 def djikstra(G,s,d): #d = [0]*V que = [] d[s] = 0 visited = [False] * V heappush(que,(0,s)) while(len(que)!=0): c,v = heappop(que) if visited[v]: continue visited[v] = True for i in range(len(G[v])): e = G[v][i] if visited[e[0]]: continue if d[e[0]] > d[v] + e[1]: d[e[0]] = d[v] + e[1] heappush(que,(d[e[0]],e[0])) n,m,s,t = map(int,input().split()) V = n Ga = [[] for i in range(n)] Gb = [[] for i in range(n)] for i in range(m): u,v,a,b = map(int,input().split()) Ga[u-1].append((v-1,a)) Ga[v-1].append((u-1,a)) Gb[u-1].append((v-1,b)) Gb[v-1].append((u-1,b)) S = [INF]*V T = [INF]*V djikstra(Ga,s-1,S) djikstra(Gb,t-1,T) M = [0]*n for i in range(n): M[i] = INF-S[i]-T[i] ans = [0]*n ans[n-1] = M[n-1] for i in range(n-2,-1,-1): ans[i] = max(ans[i+1],M[i]) for i in range(n): print(ans[i])
Statement Kenkoooo is planning a trip in Republic of Snuke. In this country, there are n cities and m trains running. The cities are numbered 1 through n, and the i-th train connects City u_i and v_i bidirectionally. Any city can be reached from any city by changing trains. Two currencies are used in the country: yen and snuuk. Any train fare can be paid by both yen and snuuk. The fare of the i-th train is a_i yen if paid in yen, and b_i snuuk if paid in snuuk. In a city with a money exchange office, you can change 1 yen into 1 snuuk. However, when you do a money exchange, you have to change all your yen into snuuk. That is, if Kenkoooo does a money exchange when he has X yen, he will then have X snuuk. Currently, there is a money exchange office in every city, but the office in City i will shut down in i years and can never be used in and after that year. Kenkoooo is planning to depart City s with 10^{15} yen in his pocket and head for City t, and change his yen into snuuk in some city while traveling. It is acceptable to do the exchange in City s or City t. Kenkoooo would like to have as much snuuk as possible when he reaches City t by making the optimal choices for the route to travel and the city to do the exchange. For each i=0,...,n-1, find the maximum amount of snuuk that Kenkoooo has when he reaches City t if he goes on a trip from City s to City t after i years. You can assume that the trip finishes within the year.
[{"input": "4 3 2 3\n 1 4 1 100\n 1 2 1 10\n 1 3 20 1", "output": "999999999999998\n 999999999999989\n 999999999999979\n 999999999999897\n \n\nAfter 0 years, it is optimal to do the exchange in City 1. \nAfter 1 years, it is optimal to do the exchange in City 2. \nNote that City 1 can still be visited even after the exchange office is\nclosed. Also note that, if it was allowed to keep 1 yen when do the exchange\nin City 2 and change the remaining yen into snuuk, we could reach City 3 with\n999999999999998 snuuk, but this is NOT allowed. \nAfter 2 years, it is optimal to do the exchange in City 3. \nAfter 3 years, it is optimal to do the exchange in City 4. Note that the same\ntrain can be used multiple times.\n\n* * *"}, {"input": "8 12 3 8\n 2 8 685087149 857180777\n 6 7 298270585 209942236\n 2 4 346080035 234079976\n 2 5 131857300 22507157\n 4 8 30723332 173476334\n 2 6 480845267 448565596\n 1 4 181424400 548830121\n 4 5 57429995 195056405\n 7 8 160277628 479932440\n 1 6 475692952 203530153\n 3 5 336869679 160714712\n 2 7 389775999 199123879", "output": "999999574976994\n 999999574976994\n 999999574976994\n 999999574976994\n 999999574976994\n 999999574976994\n 999999574976994\n 999999574976994"}]
Print n lines. In the i-th line, print the maximum amount of snuuk that Kenkoooo has when he reaches City t if he goes on a trip from City s to City t after i-1 years. * * *
s707598691
Runtime Error
p03305
Input is given from Standard Input in the following format: n m s t u_1 v_1 a_1 b_1 : u_m v_m a_m b_m
import sys sys.setrecursionlimit(4100000) import math import logging logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) from collections import defaultdict # d = defaultdict(list) import numpy as np from scipy.sparse import csr_matrix from scipy.sparse.csgraph import dijkstra def resolve(): # S = [x for x in sys.stdin.readline().split()][0] # 文字列 一つ # N = [int(x) for x in sys.stdin.readline().split()][0] # int 一つ n, m, s, t = [int(x) for x in sys.stdin.readline().split()] # 複数int # h_list = [int(x) for x in sys.stdin.readline().split()] # 複数int # grid = [list(sys.stdin.readline().split()[0]) for _ in range(N)] # 文字列grid # v_list = [int(sys.stdin.readline().split()[0]) for _ in range(N)] grid = [ [int(x) for x in sys.stdin.readline().split()] for _ in range(m) ] # int grid yen_neighbour_mat = np.zeros((n, n)) snuuke_neighbour_mat = np.zeros((n, n)) for u, v, yen, snuuke in grid: u = u - 1 v = v - 1 yen_neighbour_mat[u, v] = yen_neighbour_mat[v, u] = yen snuuke_neighbour_mat[u, v] = snuuke_neighbour_mat[v, u] = snuuke yen_csr = csr_matrix(yen_neighbour_mat) sn_csr = csr_matrix(snuuke_neighbour_mat) min_dist_list = [] result_list = [] for i_year in reversed(range(n)): min_dist_list.append( dijkstra(yen_csr, directed=False, indices=i_year)[s - 1] + dijkstra(sn_csr, directed=False, indices=i_year)[t - 1] ) result_list.append(min(min_dist_list)) for r in reversed(result_list): print(int(10**15) - int(r)) if __name__ == "__main__": resolve() # AtCoder Unit Test で自動生成できる, 最後のunittest.main は消す # python -m unittest template/template.py で実行できる # pypy3 -m unittest template/template.py で実行できる import sys from io import StringIO import unittest class TestClass(unittest.TestCase): def assertIO(self, input, output): stdout, stdin = sys.stdout, sys.stdin sys.stdout, sys.stdin = StringIO(), StringIO(input) resolve() sys.stdout.seek(0) out = sys.stdout.read()[:-1] sys.stdout, sys.stdin = stdout, stdin self.assertEqual(out, output) def test_入力例_1(self): input = """4 3 2 3 1 4 1 100 1 2 1 10 1 3 20 1""" output = """999999999999998 999999999999989 999999999999979 999999999999897""" self.assertIO(input, output) def test_入力例_2(self): input = """8 12 3 8 2 8 685087149 857180777 6 7 298270585 209942236 2 4 346080035 234079976 2 5 131857300 22507157 4 8 30723332 173476334 2 6 480845267 448565596 1 4 181424400 548830121 4 5 57429995 195056405 7 8 160277628 479932440 1 6 475692952 203530153 3 5 336869679 160714712 2 7 389775999 199123879""" output = """999999574976994 999999574976994 999999574976994 999999574976994 999999574976994 999999574976994 999999574976994 999999574976994""" self.assertIO(input, output)
Statement Kenkoooo is planning a trip in Republic of Snuke. In this country, there are n cities and m trains running. The cities are numbered 1 through n, and the i-th train connects City u_i and v_i bidirectionally. Any city can be reached from any city by changing trains. Two currencies are used in the country: yen and snuuk. Any train fare can be paid by both yen and snuuk. The fare of the i-th train is a_i yen if paid in yen, and b_i snuuk if paid in snuuk. In a city with a money exchange office, you can change 1 yen into 1 snuuk. However, when you do a money exchange, you have to change all your yen into snuuk. That is, if Kenkoooo does a money exchange when he has X yen, he will then have X snuuk. Currently, there is a money exchange office in every city, but the office in City i will shut down in i years and can never be used in and after that year. Kenkoooo is planning to depart City s with 10^{15} yen in his pocket and head for City t, and change his yen into snuuk in some city while traveling. It is acceptable to do the exchange in City s or City t. Kenkoooo would like to have as much snuuk as possible when he reaches City t by making the optimal choices for the route to travel and the city to do the exchange. For each i=0,...,n-1, find the maximum amount of snuuk that Kenkoooo has when he reaches City t if he goes on a trip from City s to City t after i years. You can assume that the trip finishes within the year.
[{"input": "4 3 2 3\n 1 4 1 100\n 1 2 1 10\n 1 3 20 1", "output": "999999999999998\n 999999999999989\n 999999999999979\n 999999999999897\n \n\nAfter 0 years, it is optimal to do the exchange in City 1. \nAfter 1 years, it is optimal to do the exchange in City 2. \nNote that City 1 can still be visited even after the exchange office is\nclosed. Also note that, if it was allowed to keep 1 yen when do the exchange\nin City 2 and change the remaining yen into snuuk, we could reach City 3 with\n999999999999998 snuuk, but this is NOT allowed. \nAfter 2 years, it is optimal to do the exchange in City 3. \nAfter 3 years, it is optimal to do the exchange in City 4. Note that the same\ntrain can be used multiple times.\n\n* * *"}, {"input": "8 12 3 8\n 2 8 685087149 857180777\n 6 7 298270585 209942236\n 2 4 346080035 234079976\n 2 5 131857300 22507157\n 4 8 30723332 173476334\n 2 6 480845267 448565596\n 1 4 181424400 548830121\n 4 5 57429995 195056405\n 7 8 160277628 479932440\n 1 6 475692952 203530153\n 3 5 336869679 160714712\n 2 7 389775999 199123879", "output": "999999574976994\n 999999574976994\n 999999574976994\n 999999574976994\n 999999574976994\n 999999574976994\n 999999574976994\n 999999574976994"}]
Print n lines. In the i-th line, print the maximum amount of snuuk that Kenkoooo has when he reaches City t if he goes on a trip from City s to City t after i-1 years. * * *
s461692879
Runtime Error
p03305
Input is given from Standard Input in the following format: n m s t u_1 v_1 a_1 b_1 : u_m v_m a_m b_m
import sys import math import collections import itertools import array import inspect # Set max recursion limit sys.setrecursionlimit(10000) # Debug output def chkprint(*args): names = {id(v): k for k, v in inspect.currentframe().f_back.f_locals.items()} print(", ".join(names.get(id(arg), "???") + " = " + repr(arg) for arg in args)) # Binary converter def to_bin(x): return bin(x)[2:] # -------------------------------------------- dp = None def main(): n_station, n_train, src_station, dst_station = [int(_) for _ in input().split()] connect = [] for _ in range(n_station + 1): connect.append([]) trains = {} for _ in range(n_train): u, v, a, b = [int(_) for _ in input().split()] trains[str(u) + str(v)] = {"yen": a, "snk": b} connect[u].append(v) connect[v].append(u) costs_by_exchange_station = [10**20] stat_and_cost_arr = [(src_station, 0)] costs_yen = {src_station: 0} while True: new_stat_and_cost_arr = [] for stat_and_cost in stat_and_cost_arr: new_stat_and_cost_arr = [] current_station, current_cost = stat_and_cost[0], stat_and_cost[1] for next_station in connect[current_station]: u, v = min(current_station, next_station), max( current_station, next_station ) if ( next_station not in costs_yen or current_cost + trains[str(u) + str(v)]["yen"] < costs_yen[next_station] ): new_stat_and_cost_arr.append( (next_station, current_cost + trains[str(u) + str(v)]["yen"]) ) costs_yen[next_station] = ( current_cost + trains[str(u) + str(v)]["yen"] ) if len(new_stat_and_cost_arr) == 0: break else: stat_and_cost_arr = new_stat_and_cost_arr for exchange_station in range(1, n_station + 1): stat_and_cost_arr = [(exchange_station, costs_yen[exchange_station])] costs_snk = {exchange_station: costs_yen[exchange_station]} while True: new_stat_and_cost_arr = [] for stat_and_cost in stat_and_cost_arr: new_stat_and_cost_arr = [] current_station, current_cost = stat_and_cost[0], stat_and_cost[1] for next_station in connect[current_station]: u, v = min(current_station, next_station), max( current_station, next_station ) if ( next_station not in costs_snk or current_cost + trains[str(u) + str(v)]["snk"] < costs_snk[next_station] ): new_stat_and_cost_arr.append( ( next_station, current_cost + trains[str(u) + str(v)]["snk"], ) ) costs_snk[next_station] = ( current_cost + trains[str(u) + str(v)]["snk"] ) if len(new_stat_and_cost_arr) == 0: break else: stat_and_cost_arr = new_stat_and_cost_arr costs_by_exchange_station.append(costs_snk[dst_station]) for year in range(n_station): print(10**15 - min(costs_by_exchange_station[year + 1 :])) main()
Statement Kenkoooo is planning a trip in Republic of Snuke. In this country, there are n cities and m trains running. The cities are numbered 1 through n, and the i-th train connects City u_i and v_i bidirectionally. Any city can be reached from any city by changing trains. Two currencies are used in the country: yen and snuuk. Any train fare can be paid by both yen and snuuk. The fare of the i-th train is a_i yen if paid in yen, and b_i snuuk if paid in snuuk. In a city with a money exchange office, you can change 1 yen into 1 snuuk. However, when you do a money exchange, you have to change all your yen into snuuk. That is, if Kenkoooo does a money exchange when he has X yen, he will then have X snuuk. Currently, there is a money exchange office in every city, but the office in City i will shut down in i years and can never be used in and after that year. Kenkoooo is planning to depart City s with 10^{15} yen in his pocket and head for City t, and change his yen into snuuk in some city while traveling. It is acceptable to do the exchange in City s or City t. Kenkoooo would like to have as much snuuk as possible when he reaches City t by making the optimal choices for the route to travel and the city to do the exchange. For each i=0,...,n-1, find the maximum amount of snuuk that Kenkoooo has when he reaches City t if he goes on a trip from City s to City t after i years. You can assume that the trip finishes within the year.
[{"input": "4 3 2 3\n 1 4 1 100\n 1 2 1 10\n 1 3 20 1", "output": "999999999999998\n 999999999999989\n 999999999999979\n 999999999999897\n \n\nAfter 0 years, it is optimal to do the exchange in City 1. \nAfter 1 years, it is optimal to do the exchange in City 2. \nNote that City 1 can still be visited even after the exchange office is\nclosed. Also note that, if it was allowed to keep 1 yen when do the exchange\nin City 2 and change the remaining yen into snuuk, we could reach City 3 with\n999999999999998 snuuk, but this is NOT allowed. \nAfter 2 years, it is optimal to do the exchange in City 3. \nAfter 3 years, it is optimal to do the exchange in City 4. Note that the same\ntrain can be used multiple times.\n\n* * *"}, {"input": "8 12 3 8\n 2 8 685087149 857180777\n 6 7 298270585 209942236\n 2 4 346080035 234079976\n 2 5 131857300 22507157\n 4 8 30723332 173476334\n 2 6 480845267 448565596\n 1 4 181424400 548830121\n 4 5 57429995 195056405\n 7 8 160277628 479932440\n 1 6 475692952 203530153\n 3 5 336869679 160714712\n 2 7 389775999 199123879", "output": "999999574976994\n 999999574976994\n 999999574976994\n 999999574976994\n 999999574976994\n 999999574976994\n 999999574976994\n 999999574976994"}]
Print n lines. In the i-th line, print the maximum amount of snuuk that Kenkoooo has when he reaches City t if he goes on a trip from City s to City t after i-1 years. * * *
s894275817
Accepted
p03305
Input is given from Standard Input in the following format: n m s t u_1 v_1 a_1 b_1 : u_m v_m a_m b_m
# -*- coding: utf-8 -*- import sys from heapq import heappop, heappush from itertools import accumulate def dijkstra(n, edges, start, *, adj_matrix=False, default_value=float("inf")): inf = float("inf") costs = [inf] * n costs[start] = 0 pq, rem = [(0, start)], n - 1 while pq and rem: tmp_cost, tmp_node = heappop(pq) if costs[tmp_node] < tmp_cost: continue rem -= 1 nxt_edges = ( ( (node, cost) for node, cost in enumerate(edges[tmp_node]) if cost != default_value ) if adj_matrix else edges[tmp_node] ) for nxt_node, nxt_cost in nxt_edges: new_cost = tmp_cost + nxt_cost if costs[nxt_node] > new_cost: costs[nxt_node] = new_cost heappush(pq, (new_cost, nxt_node)) return costs # n, m, s, t = map(int, input().split()) # trains = [list(map(int, l.strip().split())) for l in sys.stdin.readlines()] # yen_edges = [[float('inf') if __ != _ else 0 for __ in range(n)] # for _ in range(n)] # snuke_edges = [[float('inf') if __ != _ else 0 for __ in range(n)] # for _ in range(n)] # for i, j, yen, snuke in trains: # yen_edges[i - 1][j - 1] = yen # yen_edges[j - 1][i - 1] = yen # snuke_edges[i - 1][j - 1] = snuke # snuke_edges[j - 1][i - 1] = snuke # yen_cost = dijkstra(n, yen_edges, s - 1, adj_matrix=True) # snuke_cost = dijkstra(n, snuke_edges, t - 1, adj_matrix=True) # costs = [yen + snuke for yen, snuke in zip(yen_cost, snuke_cost)] n, m, s, t = map(int, input().split()) yen_edges = [[] for _ in range(n)] snuke_edges = [[] for _ in range(n)] for l in sys.stdin.readlines(): u, v, yen, snuke = map(int, l.strip().split()) # for _ in range(m): # u, v, yen, snuke = map(int, input().split()) yen_edges[u - 1].append((v - 1, yen)) yen_edges[v - 1].append((u - 1, yen)) snuke_edges[u - 1].append((v - 1, snuke)) snuke_edges[v - 1].append((u - 1, snuke)) yen_costs = dijkstra(n, yen_edges, s - 1) snuke_costs = dijkstra(n, snuke_edges, t - 1) final_costs = list( accumulate([yen + snuke for yen, snuke in zip(yen_costs, snuke_costs)][::-1], min) )[::-1] asset = 10**15 for final_cost in final_costs: print(asset - final_cost)
Statement Kenkoooo is planning a trip in Republic of Snuke. In this country, there are n cities and m trains running. The cities are numbered 1 through n, and the i-th train connects City u_i and v_i bidirectionally. Any city can be reached from any city by changing trains. Two currencies are used in the country: yen and snuuk. Any train fare can be paid by both yen and snuuk. The fare of the i-th train is a_i yen if paid in yen, and b_i snuuk if paid in snuuk. In a city with a money exchange office, you can change 1 yen into 1 snuuk. However, when you do a money exchange, you have to change all your yen into snuuk. That is, if Kenkoooo does a money exchange when he has X yen, he will then have X snuuk. Currently, there is a money exchange office in every city, but the office in City i will shut down in i years and can never be used in and after that year. Kenkoooo is planning to depart City s with 10^{15} yen in his pocket and head for City t, and change his yen into snuuk in some city while traveling. It is acceptable to do the exchange in City s or City t. Kenkoooo would like to have as much snuuk as possible when he reaches City t by making the optimal choices for the route to travel and the city to do the exchange. For each i=0,...,n-1, find the maximum amount of snuuk that Kenkoooo has when he reaches City t if he goes on a trip from City s to City t after i years. You can assume that the trip finishes within the year.
[{"input": "4 3 2 3\n 1 4 1 100\n 1 2 1 10\n 1 3 20 1", "output": "999999999999998\n 999999999999989\n 999999999999979\n 999999999999897\n \n\nAfter 0 years, it is optimal to do the exchange in City 1. \nAfter 1 years, it is optimal to do the exchange in City 2. \nNote that City 1 can still be visited even after the exchange office is\nclosed. Also note that, if it was allowed to keep 1 yen when do the exchange\nin City 2 and change the remaining yen into snuuk, we could reach City 3 with\n999999999999998 snuuk, but this is NOT allowed. \nAfter 2 years, it is optimal to do the exchange in City 3. \nAfter 3 years, it is optimal to do the exchange in City 4. Note that the same\ntrain can be used multiple times.\n\n* * *"}, {"input": "8 12 3 8\n 2 8 685087149 857180777\n 6 7 298270585 209942236\n 2 4 346080035 234079976\n 2 5 131857300 22507157\n 4 8 30723332 173476334\n 2 6 480845267 448565596\n 1 4 181424400 548830121\n 4 5 57429995 195056405\n 7 8 160277628 479932440\n 1 6 475692952 203530153\n 3 5 336869679 160714712\n 2 7 389775999 199123879", "output": "999999574976994\n 999999574976994\n 999999574976994\n 999999574976994\n 999999574976994\n 999999574976994\n 999999574976994\n 999999574976994"}]
Print n lines. In the i-th line, print the maximum amount of snuuk that Kenkoooo has when he reaches City t if he goes on a trip from City s to City t after i-1 years. * * *
s352896138
Accepted
p03305
Input is given from Standard Input in the following format: n m s t u_1 v_1 a_1 b_1 : u_m v_m a_m b_m
#!/usr/bin python3 # -*- coding: utf-8 -*- # 有向グラフで優先度付きキューで探索 from heapq import heapify, heappop, heappush, heappushpop INF = float("inf") def dijkstra(s, n, g): seen = [False] * n cost = [INF] * n cost[s] = 0 # スタートはコスト0 next_q = [(0, s)] heapify(next_q) while len(next_q) > 0: c, i = heappop(next_q) if cost[i] < c: continue for nedge, ncost in g[i]: nc = cost[i] + ncost if cost[nedge] > nc: cost[nedge] = nc heappush(next_q, (nc, nedge)) return cost def main(): N, M, S, T = map(int, input().split()) graph_F = [[] for _ in range(N)] graph_R = [[] for _ in range(N)] # リストの作成 for i in range(M): a, b, c, d = map(int, input().split()) a -= 1 b -= 1 graph_F[a].append((b, c)) graph_F[b].append((a, c)) graph_R[a].append((b, d)) graph_R[b].append((a, d)) F = dijkstra(S - 1, N, graph_F) R = dijkstra(T - 1, N, graph_R) ret = [i + j for (i, j) in zip(F, R)] X = 10**15 for r in range(N - 2, -1, -1): ret[r] = min(ret[r + 1], ret[r]) for r in ret: print(X - r) if __name__ == "__main__": main()
Statement Kenkoooo is planning a trip in Republic of Snuke. In this country, there are n cities and m trains running. The cities are numbered 1 through n, and the i-th train connects City u_i and v_i bidirectionally. Any city can be reached from any city by changing trains. Two currencies are used in the country: yen and snuuk. Any train fare can be paid by both yen and snuuk. The fare of the i-th train is a_i yen if paid in yen, and b_i snuuk if paid in snuuk. In a city with a money exchange office, you can change 1 yen into 1 snuuk. However, when you do a money exchange, you have to change all your yen into snuuk. That is, if Kenkoooo does a money exchange when he has X yen, he will then have X snuuk. Currently, there is a money exchange office in every city, but the office in City i will shut down in i years and can never be used in and after that year. Kenkoooo is planning to depart City s with 10^{15} yen in his pocket and head for City t, and change his yen into snuuk in some city while traveling. It is acceptable to do the exchange in City s or City t. Kenkoooo would like to have as much snuuk as possible when he reaches City t by making the optimal choices for the route to travel and the city to do the exchange. For each i=0,...,n-1, find the maximum amount of snuuk that Kenkoooo has when he reaches City t if he goes on a trip from City s to City t after i years. You can assume that the trip finishes within the year.
[{"input": "4 3 2 3\n 1 4 1 100\n 1 2 1 10\n 1 3 20 1", "output": "999999999999998\n 999999999999989\n 999999999999979\n 999999999999897\n \n\nAfter 0 years, it is optimal to do the exchange in City 1. \nAfter 1 years, it is optimal to do the exchange in City 2. \nNote that City 1 can still be visited even after the exchange office is\nclosed. Also note that, if it was allowed to keep 1 yen when do the exchange\nin City 2 and change the remaining yen into snuuk, we could reach City 3 with\n999999999999998 snuuk, but this is NOT allowed. \nAfter 2 years, it is optimal to do the exchange in City 3. \nAfter 3 years, it is optimal to do the exchange in City 4. Note that the same\ntrain can be used multiple times.\n\n* * *"}, {"input": "8 12 3 8\n 2 8 685087149 857180777\n 6 7 298270585 209942236\n 2 4 346080035 234079976\n 2 5 131857300 22507157\n 4 8 30723332 173476334\n 2 6 480845267 448565596\n 1 4 181424400 548830121\n 4 5 57429995 195056405\n 7 8 160277628 479932440\n 1 6 475692952 203530153\n 3 5 336869679 160714712\n 2 7 389775999 199123879", "output": "999999574976994\n 999999574976994\n 999999574976994\n 999999574976994\n 999999574976994\n 999999574976994\n 999999574976994\n 999999574976994"}]
Print the number of days before the next Sunday. * * *
s974072022
Runtime Error
p02847
Input is given from Standard Input in the following format: S
N = int(input()) S = input() As = "" for i in range(len(S)): As += chr(((ord(S[i]) - 65) + N) % 26 + 65) print(As)
Statement Given is a string S representing the day of the week today. S is `SUN`, `MON`, `TUE`, `WED`, `THU`, `FRI`, or `SAT`, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively. After how many days is the next Sunday (tomorrow or later)?
[{"input": "SAT", "output": "1\n \n\nIt is Saturday today, and tomorrow will be Sunday.\n\n* * *"}, {"input": "SUN", "output": "7\n \n\nIt is Sunday today, and seven days later, it will be Sunday again."}]
Print the number of days before the next Sunday. * * *
s043917071
Accepted
p02847
Input is given from Standard Input in the following format: S
D = {"SUN": 7, "MON": 6, "TUE": 5, "WED": 4, "THU": 3, "FRI": 2, "SAT": 1} print(D[input().strip()])
Statement Given is a string S representing the day of the week today. S is `SUN`, `MON`, `TUE`, `WED`, `THU`, `FRI`, or `SAT`, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively. After how many days is the next Sunday (tomorrow or later)?
[{"input": "SAT", "output": "1\n \n\nIt is Saturday today, and tomorrow will be Sunday.\n\n* * *"}, {"input": "SUN", "output": "7\n \n\nIt is Sunday today, and seven days later, it will be Sunday again."}]
Print the number of days before the next Sunday. * * *
s910321583
Wrong Answer
p02847
Input is given from Standard Input in the following format: S
if input() == "SUN": print(7)
Statement Given is a string S representing the day of the week today. S is `SUN`, `MON`, `TUE`, `WED`, `THU`, `FRI`, or `SAT`, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively. After how many days is the next Sunday (tomorrow or later)?
[{"input": "SAT", "output": "1\n \n\nIt is Saturday today, and tomorrow will be Sunday.\n\n* * *"}, {"input": "SUN", "output": "7\n \n\nIt is Sunday today, and seven days later, it will be Sunday again."}]
Print the number of days before the next Sunday. * * *
s100094522
Wrong Answer
p02847
Input is given from Standard Input in the following format: S
l = ("SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT") print(8 - l.index(input()))
Statement Given is a string S representing the day of the week today. S is `SUN`, `MON`, `TUE`, `WED`, `THU`, `FRI`, or `SAT`, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively. After how many days is the next Sunday (tomorrow or later)?
[{"input": "SAT", "output": "1\n \n\nIt is Saturday today, and tomorrow will be Sunday.\n\n* * *"}, {"input": "SUN", "output": "7\n \n\nIt is Sunday today, and seven days later, it will be Sunday again."}]
Print the number of days before the next Sunday. * * *
s308935833
Runtime Error
p02847
Input is given from Standard Input in the following format: S
A, B, X = map(int, input().split()) low = 0 high = 10**10 for i in range(10**9): if high - low == 1: if A * high + B * len(str(high)) <= X: print(high) break else: print(low) break if (high - low) % 2 == 0: N = (high - low) // 2 + low tmp = A * N + B * len(str(N)) if tmp < X: low = N elif tmp > X: high = N elif tmp == X: print(N) break else: N = (high - low) / 2 + low floor = int(N) ceil = floor + 1 tmp_floor = A * floor + B * len(str(floor)) tmp_ceil = A * ceil + B * len(str(ceil)) if tmp_floor < tmp_ceil < X: low = ceil elif X < tmp_floor < tmp_ceil: high = floor elif tmp_floor < X < tmp_ceil: low = floor high = ceil elif X == tmp_floor: print(N) break elif X == tmp_ceil: print(N) break
Statement Given is a string S representing the day of the week today. S is `SUN`, `MON`, `TUE`, `WED`, `THU`, `FRI`, or `SAT`, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively. After how many days is the next Sunday (tomorrow or later)?
[{"input": "SAT", "output": "1\n \n\nIt is Saturday today, and tomorrow will be Sunday.\n\n* * *"}, {"input": "SUN", "output": "7\n \n\nIt is Sunday today, and seven days later, it will be Sunday again."}]
Print the number of days before the next Sunday. * * *
s155865056
Accepted
p02847
Input is given from Standard Input in the following format: S
l = [["SUN", 7], ["MON", 6], ["TUE", 5], ["WED", 4], ["THU", 3], ["FRI", 2], ["SAT", 1]] s = str(input()) for i in range(7): if s == l[i][0]: print(l[i][1])
Statement Given is a string S representing the day of the week today. S is `SUN`, `MON`, `TUE`, `WED`, `THU`, `FRI`, or `SAT`, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively. After how many days is the next Sunday (tomorrow or later)?
[{"input": "SAT", "output": "1\n \n\nIt is Saturday today, and tomorrow will be Sunday.\n\n* * *"}, {"input": "SUN", "output": "7\n \n\nIt is Sunday today, and seven days later, it will be Sunday again."}]
Print the number of days before the next Sunday. * * *
s831935951
Accepted
p02847
Input is given from Standard Input in the following format: S
print("SAFRTHWETUMOSU".find(input()[:2]) // 2 + 1)
Statement Given is a string S representing the day of the week today. S is `SUN`, `MON`, `TUE`, `WED`, `THU`, `FRI`, or `SAT`, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively. After how many days is the next Sunday (tomorrow or later)?
[{"input": "SAT", "output": "1\n \n\nIt is Saturday today, and tomorrow will be Sunday.\n\n* * *"}, {"input": "SUN", "output": "7\n \n\nIt is Sunday today, and seven days later, it will be Sunday again."}]
Print the number of days before the next Sunday. * * *
s853362255
Accepted
p02847
Input is given from Standard Input in the following format: S
# 146_A day = ["SU", "MO", "TU", "WE", "TH", "FR", "SA"] s = input()[:2] print(7 - day.index(s))
Statement Given is a string S representing the day of the week today. S is `SUN`, `MON`, `TUE`, `WED`, `THU`, `FRI`, or `SAT`, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively. After how many days is the next Sunday (tomorrow or later)?
[{"input": "SAT", "output": "1\n \n\nIt is Saturday today, and tomorrow will be Sunday.\n\n* * *"}, {"input": "SUN", "output": "7\n \n\nIt is Sunday today, and seven days later, it will be Sunday again."}]
Print the number of days before the next Sunday. * * *
s399958121
Accepted
p02847
Input is given from Standard Input in the following format: S
S = input().rstrip() print(7 - ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"].index(S))
Statement Given is a string S representing the day of the week today. S is `SUN`, `MON`, `TUE`, `WED`, `THU`, `FRI`, or `SAT`, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively. After how many days is the next Sunday (tomorrow or later)?
[{"input": "SAT", "output": "1\n \n\nIt is Saturday today, and tomorrow will be Sunday.\n\n* * *"}, {"input": "SUN", "output": "7\n \n\nIt is Sunday today, and seven days later, it will be Sunday again."}]
Print the number of days before the next Sunday. * * *
s406954937
Wrong Answer
p02847
Input is given from Standard Input in the following format: S
t = "SUN,MON,TUE,WED,THU,FRI,SAT" s = t.split(",") print((7 - s.index(input())) % 7)
Statement Given is a string S representing the day of the week today. S is `SUN`, `MON`, `TUE`, `WED`, `THU`, `FRI`, or `SAT`, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively. After how many days is the next Sunday (tomorrow or later)?
[{"input": "SAT", "output": "1\n \n\nIt is Saturday today, and tomorrow will be Sunday.\n\n* * *"}, {"input": "SUN", "output": "7\n \n\nIt is Sunday today, and seven days later, it will be Sunday again."}]
Print the number of days before the next Sunday. * * *
s779813860
Wrong Answer
p02847
Input is given from Standard Input in the following format: S
S = input() print( { "SUN": 7, "MON": 6, "TUE": 5, "WED": 4, "THU": 3, "FRI": 2, "SAT": 1, } )
Statement Given is a string S representing the day of the week today. S is `SUN`, `MON`, `TUE`, `WED`, `THU`, `FRI`, or `SAT`, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively. After how many days is the next Sunday (tomorrow or later)?
[{"input": "SAT", "output": "1\n \n\nIt is Saturday today, and tomorrow will be Sunday.\n\n* * *"}, {"input": "SUN", "output": "7\n \n\nIt is Sunday today, and seven days later, it will be Sunday again."}]
Print the number of days before the next Sunday. * * *
s431454026
Runtime Error
p02847
Input is given from Standard Input in the following format: S
def main(): A, B, X = list(map(int, input().split())) if A >= X or B >= X: N = 0 else: for d in range(len(str(X)), 0, -1): if d * B < X: break if d > 0: d = min(X // A, pow(10, d)) for N in range(d, 0, -1): if afford(A, B, N, X): break else: N = 0 else: N = 0 print(N if N < 1e9 else int(1e9)) def afford(a, b, n, x): c = a * n if c >= x: return False y = c + b * len(str(n)) return y <= x if __name__ == "__main__": main()
Statement Given is a string S representing the day of the week today. S is `SUN`, `MON`, `TUE`, `WED`, `THU`, `FRI`, or `SAT`, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively. After how many days is the next Sunday (tomorrow or later)?
[{"input": "SAT", "output": "1\n \n\nIt is Saturday today, and tomorrow will be Sunday.\n\n* * *"}, {"input": "SUN", "output": "7\n \n\nIt is Sunday today, and seven days later, it will be Sunday again."}]
Print the number of days before the next Sunday. * * *
s418311183
Runtime Error
p02847
Input is given from Standard Input in the following format: S
a, b, x = [int(i) for i in input().split()] for i in range(1, 10): n = (x - b * i) / float(a) if n < 0: if i == 9: print(0) continue if len(str(int(n))) == i: print(int(n) + 1) break elif i == 9: print(10**9)
Statement Given is a string S representing the day of the week today. S is `SUN`, `MON`, `TUE`, `WED`, `THU`, `FRI`, or `SAT`, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively. After how many days is the next Sunday (tomorrow or later)?
[{"input": "SAT", "output": "1\n \n\nIt is Saturday today, and tomorrow will be Sunday.\n\n* * *"}, {"input": "SUN", "output": "7\n \n\nIt is Sunday today, and seven days later, it will be Sunday again."}]
Print the number of days before the next Sunday. * * *
s513971244
Runtime Error
p02847
Input is given from Standard Input in the following format: S
A, B, X = map(int, input().split()) # 整数Nにたいして値段PはP=A*N + B*d(N), P<Xとなる最大のNを求める.ただしN<10**9以下となる # d(N)に対して探索してみる ketasu = 20 while True: if ketasu == 0: # なんにもかえない場合 n = 0 break Bdn = ketasu * B min_num = 1 * 10 ** (ketasu - 1) min_P = min_num * A + Bdn if min_P > X: ketasu -= 1 continue else: # Xで買える桁数 n = (X - Bdn) // A if n == 10**ketasu: # 10**ketasu n -= 1 break if n > 10**9: print(10**9) else: print(n)
Statement Given is a string S representing the day of the week today. S is `SUN`, `MON`, `TUE`, `WED`, `THU`, `FRI`, or `SAT`, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively. After how many days is the next Sunday (tomorrow or later)?
[{"input": "SAT", "output": "1\n \n\nIt is Saturday today, and tomorrow will be Sunday.\n\n* * *"}, {"input": "SUN", "output": "7\n \n\nIt is Sunday today, and seven days later, it will be Sunday again."}]
Print the number of days before the next Sunday. * * *
s522359845
Runtime Error
p02847
Input is given from Standard Input in the following format: S
N = int(input()) W = [] G = [[] for i in range(N + 1)] for i in range(N - 1): a, b = map(int, input().split()) W.append((a, b)) G[a].append(b) G[b].append(a) K = 0 for i in range(1, N + 1): n = len(G[i]) K = max(K, n) print(K) C = [[i for i in range(1, K + 1)] for j in range(N + 1)] import copy w = copy.deepcopy(W) d = [[0 for i in range(N + 1)] for j in range(N + 1)] w.sort() for i in range(N - 1): a, b = W[i] print(d[a][b])
Statement Given is a string S representing the day of the week today. S is `SUN`, `MON`, `TUE`, `WED`, `THU`, `FRI`, or `SAT`, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively. After how many days is the next Sunday (tomorrow or later)?
[{"input": "SAT", "output": "1\n \n\nIt is Saturday today, and tomorrow will be Sunday.\n\n* * *"}, {"input": "SUN", "output": "7\n \n\nIt is Sunday today, and seven days later, it will be Sunday again."}]
Print the number of days before the next Sunday. * * *
s139763587
Runtime Error
p02847
Input is given from Standard Input in the following format: S
n = int(input()) s = [{0} for i in range(n)] ans = [0] * n a = 0 b = 0 sp = {i for i in range(n)} for i in range(1, n): a, b = list(map(int, input().split())) ans[i] = min(sp - (s[a - 1] | s[b - 1])) s[a - 1].add(ans[i]) s[b - 1].add(ans[i]) print(max(ans)) for i in range(1, n): print(ans[i])
Statement Given is a string S representing the day of the week today. S is `SUN`, `MON`, `TUE`, `WED`, `THU`, `FRI`, or `SAT`, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively. After how many days is the next Sunday (tomorrow or later)?
[{"input": "SAT", "output": "1\n \n\nIt is Saturday today, and tomorrow will be Sunday.\n\n* * *"}, {"input": "SUN", "output": "7\n \n\nIt is Sunday today, and seven days later, it will be Sunday again."}]
Print the number of days before the next Sunday. * * *
s260108618
Runtime Error
p02847
Input is given from Standard Input in the following format: S
N = int(input()) Mat = [[] for _ in range(N)] for i in range(N - 1): a, b = list(map(int, input().split(" "))) a, b = a - 1, b - 1 Mat[a].append([i, b]) Mat[b].append([i, a]) colL = [1 for i in range(N - 1)] colorSave = [] M = 0 for i in range(N): if M < len(Mat[i]): M = len(Mat[i]) print(M) def bfs(now, bef, nowC, befC, first): colL = [1 for i in range(N - 1)] if first == 0: colL[nowC] = 0 for nex in Mat[now]: if nex[1] != bef: nexC = colL.index(1) colL[nexC] = 0 colorSave.append([nex[0], nexC]) bfs(nex[1], now, nexC, nowC, 0) return bfs(0, -1, 0, -1, 1) new = sorted(colorSave, key=lambda x: x[0]) for n in new: print(n[1] + 1)
Statement Given is a string S representing the day of the week today. S is `SUN`, `MON`, `TUE`, `WED`, `THU`, `FRI`, or `SAT`, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively. After how many days is the next Sunday (tomorrow or later)?
[{"input": "SAT", "output": "1\n \n\nIt is Saturday today, and tomorrow will be Sunday.\n\n* * *"}, {"input": "SUN", "output": "7\n \n\nIt is Sunday today, and seven days later, it will be Sunday again."}]
Print the number of days before the next Sunday. * * *
s200935008
Wrong Answer
p02847
Input is given from Standard Input in the following format: S
x = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"] y = x.index(input()) print(min(abs(6 - y), abs(y)))
Statement Given is a string S representing the day of the week today. S is `SUN`, `MON`, `TUE`, `WED`, `THU`, `FRI`, or `SAT`, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively. After how many days is the next Sunday (tomorrow or later)?
[{"input": "SAT", "output": "1\n \n\nIt is Saturday today, and tomorrow will be Sunday.\n\n* * *"}, {"input": "SUN", "output": "7\n \n\nIt is Sunday today, and seven days later, it will be Sunday again."}]
Print the number of days before the next Sunday. * * *
s433413356
Wrong Answer
p02847
Input is given from Standard Input in the following format: S
def Holiday(s): days = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"] return -(days.index(s) - 7) if days.index(s) >= 3 else days.index(s)
Statement Given is a string S representing the day of the week today. S is `SUN`, `MON`, `TUE`, `WED`, `THU`, `FRI`, or `SAT`, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively. After how many days is the next Sunday (tomorrow or later)?
[{"input": "SAT", "output": "1\n \n\nIt is Saturday today, and tomorrow will be Sunday.\n\n* * *"}, {"input": "SUN", "output": "7\n \n\nIt is Sunday today, and seven days later, it will be Sunday again."}]
Print the number of days before the next Sunday. * * *
s952038894
Wrong Answer
p02847
Input is given from Standard Input in the following format: S
dw = input() dw_dictionary = {"SUN": 7, "MON": 6, "TUE": 5, "WED": 4, "THU": 3, "FRI": 2, "SAT": 1} dw_dictionary.get(dw)
Statement Given is a string S representing the day of the week today. S is `SUN`, `MON`, `TUE`, `WED`, `THU`, `FRI`, or `SAT`, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively. After how many days is the next Sunday (tomorrow or later)?
[{"input": "SAT", "output": "1\n \n\nIt is Saturday today, and tomorrow will be Sunday.\n\n* * *"}, {"input": "SUN", "output": "7\n \n\nIt is Sunday today, and seven days later, it will be Sunday again."}]
Print the number of days before the next Sunday. * * *
s636754171
Accepted
p02847
Input is given from Standard Input in the following format: S
print(dict(SUN=7, MON=6, TUE=5, WED=4, THU=3, FRI=2, SAT=1)[input()])
Statement Given is a string S representing the day of the week today. S is `SUN`, `MON`, `TUE`, `WED`, `THU`, `FRI`, or `SAT`, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively. After how many days is the next Sunday (tomorrow or later)?
[{"input": "SAT", "output": "1\n \n\nIt is Saturday today, and tomorrow will be Sunday.\n\n* * *"}, {"input": "SUN", "output": "7\n \n\nIt is Sunday today, and seven days later, it will be Sunday again."}]
Print the number of days before the next Sunday. * * *
s170714070
Accepted
p02847
Input is given from Standard Input in the following format: S
print("SATFRITHUWEDTUEMONSUN".find(input()) // 3 + 1)
Statement Given is a string S representing the day of the week today. S is `SUN`, `MON`, `TUE`, `WED`, `THU`, `FRI`, or `SAT`, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively. After how many days is the next Sunday (tomorrow or later)?
[{"input": "SAT", "output": "1\n \n\nIt is Saturday today, and tomorrow will be Sunday.\n\n* * *"}, {"input": "SUN", "output": "7\n \n\nIt is Sunday today, and seven days later, it will be Sunday again."}]
Print the number of days before the next Sunday. * * *
s830247623
Accepted
p02847
Input is given from Standard Input in the following format: S
D = "SUN MON TUE WED THU FRI SAT".split() print(7 - D.index(input()))
Statement Given is a string S representing the day of the week today. S is `SUN`, `MON`, `TUE`, `WED`, `THU`, `FRI`, or `SAT`, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively. After how many days is the next Sunday (tomorrow or later)?
[{"input": "SAT", "output": "1\n \n\nIt is Saturday today, and tomorrow will be Sunday.\n\n* * *"}, {"input": "SUN", "output": "7\n \n\nIt is Sunday today, and seven days later, it will be Sunday again."}]
Print the number of days before the next Sunday. * * *
s311041002
Accepted
p02847
Input is given from Standard Input in the following format: S
print(sum(map(ord, input() + "\n")) ** 698 % 6329 % 8)
Statement Given is a string S representing the day of the week today. S is `SUN`, `MON`, `TUE`, `WED`, `THU`, `FRI`, or `SAT`, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively. After how many days is the next Sunday (tomorrow or later)?
[{"input": "SAT", "output": "1\n \n\nIt is Saturday today, and tomorrow will be Sunday.\n\n* * *"}, {"input": "SUN", "output": "7\n \n\nIt is Sunday today, and seven days later, it will be Sunday again."}]
Print the number of days before the next Sunday. * * *
s888380198
Wrong Answer
p02847
Input is given from Standard Input in the following format: S
print(sum(map(ord, input())) ** 698 % 6329 % 8)
Statement Given is a string S representing the day of the week today. S is `SUN`, `MON`, `TUE`, `WED`, `THU`, `FRI`, or `SAT`, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively. After how many days is the next Sunday (tomorrow or later)?
[{"input": "SAT", "output": "1\n \n\nIt is Saturday today, and tomorrow will be Sunday.\n\n* * *"}, {"input": "SUN", "output": "7\n \n\nIt is Sunday today, and seven days later, it will be Sunday again."}]
Print the number of days before the next Sunday. * * *
s826651393
Runtime Error
p02847
Input is given from Standard Input in the following format: S
Week = ["SAT", "FRI", "THU", "WED", "TUE", "MON", "SAN"] Day = input() print(Week.index(Day) + 1)
Statement Given is a string S representing the day of the week today. S is `SUN`, `MON`, `TUE`, `WED`, `THU`, `FRI`, or `SAT`, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively. After how many days is the next Sunday (tomorrow or later)?
[{"input": "SAT", "output": "1\n \n\nIt is Saturday today, and tomorrow will be Sunday.\n\n* * *"}, {"input": "SUN", "output": "7\n \n\nIt is Sunday today, and seven days later, it will be Sunday again."}]
Print the number of days before the next Sunday. * * *
s209020672
Runtime Error
p02847
Input is given from Standard Input in the following format: S
l = ["SUN", "MUN", "TUE", "WED", "THU", "FRI", "SAT"] print(len(l) - l.index(input()))
Statement Given is a string S representing the day of the week today. S is `SUN`, `MON`, `TUE`, `WED`, `THU`, `FRI`, or `SAT`, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively. After how many days is the next Sunday (tomorrow or later)?
[{"input": "SAT", "output": "1\n \n\nIt is Saturday today, and tomorrow will be Sunday.\n\n* * *"}, {"input": "SUN", "output": "7\n \n\nIt is Sunday today, and seven days later, it will be Sunday again."}]
Print the number of days before the next Sunday. * * *
s033663009
Runtime Error
p02847
Input is given from Standard Input in the following format: S
Cal = {"SUN": 7, "MON": 6, "TUE": 5, "WED": 4, "THU": 3, "FRI": 2, "SUT": 1} print(Cal[input()])
Statement Given is a string S representing the day of the week today. S is `SUN`, `MON`, `TUE`, `WED`, `THU`, `FRI`, or `SAT`, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively. After how many days is the next Sunday (tomorrow or later)?
[{"input": "SAT", "output": "1\n \n\nIt is Saturday today, and tomorrow will be Sunday.\n\n* * *"}, {"input": "SUN", "output": "7\n \n\nIt is Sunday today, and seven days later, it will be Sunday again."}]
Print the number of days before the next Sunday. * * *
s270400674
Runtime Error
p02847
Input is given from Standard Input in the following format: S
day = ["SUN", "MON", "TUE", "WED", "THU", "FRY", "SAT"] print(7 - day.index(input()))
Statement Given is a string S representing the day of the week today. S is `SUN`, `MON`, `TUE`, `WED`, `THU`, `FRI`, or `SAT`, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively. After how many days is the next Sunday (tomorrow or later)?
[{"input": "SAT", "output": "1\n \n\nIt is Saturday today, and tomorrow will be Sunday.\n\n* * *"}, {"input": "SUN", "output": "7\n \n\nIt is Sunday today, and seven days later, it will be Sunday again."}]
Print the number of days before the next Sunday. * * *
s532162839
Runtime Error
p02847
Input is given from Standard Input in the following format: S
n = int(input()) s = "" for m in input(): s += chr((ord(m) + n - ord("A")) % 26 + ord("A")) print(s)
Statement Given is a string S representing the day of the week today. S is `SUN`, `MON`, `TUE`, `WED`, `THU`, `FRI`, or `SAT`, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively. After how many days is the next Sunday (tomorrow or later)?
[{"input": "SAT", "output": "1\n \n\nIt is Saturday today, and tomorrow will be Sunday.\n\n* * *"}, {"input": "SUN", "output": "7\n \n\nIt is Sunday today, and seven days later, it will be Sunday again."}]
Print the number of days before the next Sunday. * * *
s427765736
Wrong Answer
p02847
Input is given from Standard Input in the following format: S
print(["SAT", "MON", "TUE", "WED", "THU", "FRI", "SUN"].index(input()) + 1)
Statement Given is a string S representing the day of the week today. S is `SUN`, `MON`, `TUE`, `WED`, `THU`, `FRI`, or `SAT`, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively. After how many days is the next Sunday (tomorrow or later)?
[{"input": "SAT", "output": "1\n \n\nIt is Saturday today, and tomorrow will be Sunday.\n\n* * *"}, {"input": "SUN", "output": "7\n \n\nIt is Sunday today, and seven days later, it will be Sunday again."}]
Print the number of days before the next Sunday. * * *
s731441052
Runtime Error
p02847
Input is given from Standard Input in the following format: S
N = int(input()) S = input() string = list(S) alphabet = [ "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", ] # Generate empty output output = "" for i in range(len(S)): # Get the index of an alphabet in the list ind1 = alphabet.index(string[i]) # Divide N by 26 and get the remainder ind2 = (int(ind1) + N) % 26 # Update the letter and keep adding it to the list output += alphabet[ind2] print(output)
Statement Given is a string S representing the day of the week today. S is `SUN`, `MON`, `TUE`, `WED`, `THU`, `FRI`, or `SAT`, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively. After how many days is the next Sunday (tomorrow or later)?
[{"input": "SAT", "output": "1\n \n\nIt is Saturday today, and tomorrow will be Sunday.\n\n* * *"}, {"input": "SUN", "output": "7\n \n\nIt is Sunday today, and seven days later, it will be Sunday again."}]
Print the maximum number of tasty cookies that Takahashi can eat. * * *
s789157842
Runtime Error
p03186
Input is given from Standard Input in the following format: A B C
abc = input().split(" ") a = int(abc[0]) b = int(abc[1]) c = int(abc[2]) def eat(a, b, c, a_flg, b_flg, c_flg, cnt=0): # print(str(a) + " " + str(b) + " " + str(c)) if c_flg: if c - 1 < 0: return eat(a, b, c, a_flg=a_flg, b_flg=b_flg, c_flg=False, cnt=cnt) else: return eat(a, b, c - 1, a_flg=a_flg, b_flg=b_flg, c_flg=False, cnt=cnt + 1) elif b_flg: if b - 1 < 0: return eat(a, b, c, a_flg=a_flg, b_flg=False, c_flg=c_flg, cnt=cnt) else: return eat(a, b - 1, c, a_flg=a_flg, b_flg=b_flg, c_flg=True, cnt=cnt + 1) elif a_flg: if a - 1 < 0: return eat(a, b, c, a_flg=False, b_flg=b_flg, c_flg=c_flg, cnt=cnt) else: return eat(a - 1, b, c, a_flg=a_flg, b_flg=b_flg, c_flg=True, cnt=cnt) else: return cnt print(eat(a, b, c, a_flg=True, b_flg=True, c_flg=True, cnt=0))
Statement Takahashi has A untasty cookies containing antidotes, B tasty cookies containing antidotes and C tasty cookies containing poison. Eating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomachache results in a death. As he wants to live, he cannot eat one in such a situation. Eating a cookie containing antidotes while having a stomachache cures it, and there is no other way to cure stomachaches. Find the maximum number of tasty cookies that Takahashi can eat.
[{"input": "3 1 4", "output": "5\n \n\nWe can eat all tasty cookies, in the following order:\n\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n * A tasty cookie containing antidotes\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n\n* * *"}, {"input": "5 2 9", "output": "10\n \n\n* * *"}, {"input": "8 8 1", "output": "9"}]
Print the maximum number of tasty cookies that Takahashi can eat. * * *
s351881603
Runtime Error
p03186
Input is given from Standard Input in the following format: A B C
# -*- coding: utf-8 -*- ############# # Libraries # ############# import sys input = sys.stdin.readline import math # from math import gcd import bisect from collections import defaultdict from collections import deque from collections import Counter from functools import lru_cache ############# # Constants # ############# MOD = 10**9 + 7 INF = float("inf") ############# # Functions # ############# ######INPUT###### def I(): return int(input().strip()) def S(): return input().strip() def IL(): return list(map(int, input().split())) def SL(): return list(map(str, input().split())) def ILs(n): return list(int(input()) for _ in range(n)) def SLs(n): return list(input().strip() for _ in range(n)) def ILL(n): return [list(map(int, input().split())) for _ in range(n)] def SLL(n): return [list(map(str, input().split())) for _ in range(n)] ######OUTPUT###### def P(arg): print(arg) return def Y(): print("Yes") return def N(): print("No") return def E(): exit() def PE(arg): print(arg) exit() def YE(): print("Yes") exit() def NE(): print("No") exit() #####Shorten##### def DD(arg): return defaultdict(arg) #####Inverse##### def inv(n): return pow(n, MOD - 2, MOD) ######Combination###### kaijo_memo = [] def kaijo(n): if len(kaijo_memo) > n: return kaijo_memo[n] if len(kaijo_memo) == 0: kaijo_memo.append(1) while len(kaijo_memo) <= n: kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD) return kaijo_memo[n] gyaku_kaijo_memo = [] def gyaku_kaijo(n): if len(gyaku_kaijo_memo) > n: return gyaku_kaijo_memo[n] if len(gyaku_kaijo_memo) == 0: gyaku_kaijo_memo.append(1) while len(gyaku_kaijo_memo) <= n: gyaku_kaijo_memo.append( gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo), MOD - 2, MOD) % MOD ) return gyaku_kaijo_memo[n] def nCr(n, r): if n == r: return 1 if n < r or r < 0: return 0 ret = 1 ret = ret * kaijo(n) % MOD ret = ret * gyaku_kaijo(r) % MOD ret = ret * gyaku_kaijo(n - r) % MOD return ret ######Factorization###### def factorization(n): arr = [] temp = n for i in range(2, int(-(-(n**0.5) // 1)) + 1): if temp % i == 0: cnt = 0 while temp % i == 0: cnt += 1 temp //= i arr.append([i, cnt]) if temp != 1: arr.append([temp, 1]) if arr == []: arr.append([n, 1]) return arr #####MakeDivisors###### def make_divisors(n): divisors = [] for i in range(1, int(n**0.5) + 1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n // i) return divisors #####MakePrimes###### def make_primes(N): max = int(math.sqrt(N)) seachList = [i for i in range(2, N + 1)] primeNum = [] while seachList[0] <= max: primeNum.append(seachList[0]) tmp = seachList[0] seachList = [i for i in seachList if i % tmp != 0] primeNum.extend(seachList) return primeNum #####GCD##### def gcd(a, b): while b: a, b = b, a % b return a #####LCM##### def lcm(a, b): return a * b // gcd(a, b) #####BitCount##### def count_bit(n): count = 0 while n: n &= n - 1 count += 1 return count #####ChangeBase##### def base_10_to_n(X, n): if X // n: return base_10_to_n(X // n, n) + [X % n] return [X % n] def base_n_to_10(X, n): return sum(int(str(X)[-i - 1]) * n**i for i in range(len(str(X)))) #####IntLog##### def int_log(n, a): count = 0 while n >= a: n //= a count += 1 return count ############# # Main Code # ############# A, B, C = IL() print(B + min(C, min(A + B - 1)))
Statement Takahashi has A untasty cookies containing antidotes, B tasty cookies containing antidotes and C tasty cookies containing poison. Eating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomachache results in a death. As he wants to live, he cannot eat one in such a situation. Eating a cookie containing antidotes while having a stomachache cures it, and there is no other way to cure stomachaches. Find the maximum number of tasty cookies that Takahashi can eat.
[{"input": "3 1 4", "output": "5\n \n\nWe can eat all tasty cookies, in the following order:\n\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n * A tasty cookie containing antidotes\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n\n* * *"}, {"input": "5 2 9", "output": "10\n \n\n* * *"}, {"input": "8 8 1", "output": "9"}]
Print the maximum number of tasty cookies that Takahashi can eat. * * *
s325962775
Runtime Error
p03186
Input is given from Standard Input in the following format: A B C
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef pair<double,int> pdi; typedef pair<double,double> pdd; typedef pair<double,ll> pdl; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<pii> vii; typedef vector<pll> vll; typedef vector<vl> vvl; typedef vector<vi> vvi; typedef vector<bool> vb; typedef vector<vb> vvb; typedef vector<double> vd; typedef vector<vd> vvd; typedef vector<pdd> vdd; typedef vector<pdi> vdi; typedef vector<pdl> vdl; typedef vector<string> vs; #define fi first #define se second const ll INFLL=LLONG_MAX; const int INF=INT_MAX; const ll MAXLL=0x3f3f3f3f3f3f3f3f; const int MAX=0x3f3f3f3f; const ll MOD=1000000007; const ll mod=998244353; #define eb emplace_back #define emp emplace #define mp(a,b) make_pair(a,b) template<class T> using min_heap=priority_queue<T,vector<T>,greater<T> >; template<class T> void sort(vector<T>& v){ sort(v.begin(),v.end()); } template <class T, class U> void sort(vector<T>& v,U func){ sort(v.begin(),v.end(),func); } template<class T> void rsort(vector<T>& v){ sort(v.rbegin(),v.rend()); } template <class T> int lb_index(vector<T>& v,T k){ return lower_bound(v.begin(),v.end(),k)-v.begin(); } template <class T> int ub_index(vector<T>& v,T k){ return upper_bound(v.begin(),v.end(),k)-v.begin(); } template<class T> bool is_sorted(vector<T>& v){ return is_sorted(v.begin(),v.end()); } template<class T> bool sorted(vector<T>& v){ return is_sorted(v); } void precompute(){ return; } void solve(){ ll a,b,c; cin>>a>>b>>c; cout<<min(c,a+b+1)+b; return; } int main(){ ios::sync_with_stdio(0); int numberofsubtestcases=1; // cin>>numberofsubtestcases; precompute(); for(int looping=1;looping<=numberofsubtestcases;looping++){ // cout<<"Case #"<<looping<<": "; solve(); } return 0; }
Statement Takahashi has A untasty cookies containing antidotes, B tasty cookies containing antidotes and C tasty cookies containing poison. Eating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomachache results in a death. As he wants to live, he cannot eat one in such a situation. Eating a cookie containing antidotes while having a stomachache cures it, and there is no other way to cure stomachaches. Find the maximum number of tasty cookies that Takahashi can eat.
[{"input": "3 1 4", "output": "5\n \n\nWe can eat all tasty cookies, in the following order:\n\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n * A tasty cookie containing antidotes\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n\n* * *"}, {"input": "5 2 9", "output": "10\n \n\n* * *"}, {"input": "8 8 1", "output": "9"}]
Print the maximum number of tasty cookies that Takahashi can eat. * * *
s955685312
Runtime Error
p03186
Input is given from Standard Input in the following format: A B C
a, b, c = list(map(int, input().split())) if a + b >= c - 1: print(b+c) else: print(a+2b+1)
Statement Takahashi has A untasty cookies containing antidotes, B tasty cookies containing antidotes and C tasty cookies containing poison. Eating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomachache results in a death. As he wants to live, he cannot eat one in such a situation. Eating a cookie containing antidotes while having a stomachache cures it, and there is no other way to cure stomachaches. Find the maximum number of tasty cookies that Takahashi can eat.
[{"input": "3 1 4", "output": "5\n \n\nWe can eat all tasty cookies, in the following order:\n\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n * A tasty cookie containing antidotes\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n\n* * *"}, {"input": "5 2 9", "output": "10\n \n\n* * *"}, {"input": "8 8 1", "output": "9"}]
Print the maximum number of tasty cookies that Takahashi can eat. * * *
s681662694
Runtime Error
p03186
Input is given from Standard Input in the following format: A B C
A, B, C = [int(_) for _ in input().split()] if(A+B<C-1){ print(B+C) else{ print(A+2*B+1)
Statement Takahashi has A untasty cookies containing antidotes, B tasty cookies containing antidotes and C tasty cookies containing poison. Eating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomachache results in a death. As he wants to live, he cannot eat one in such a situation. Eating a cookie containing antidotes while having a stomachache cures it, and there is no other way to cure stomachaches. Find the maximum number of tasty cookies that Takahashi can eat.
[{"input": "3 1 4", "output": "5\n \n\nWe can eat all tasty cookies, in the following order:\n\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n * A tasty cookie containing antidotes\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n\n* * *"}, {"input": "5 2 9", "output": "10\n \n\n* * *"}, {"input": "8 8 1", "output": "9"}]
Print the maximum number of tasty cookies that Takahashi can eat. * * *
s534949464
Runtime Error
p03186
Input is given from Standard Input in the following format: A B C
a,b,c=map(int,input().split()) if a + b >= c: print(b+c) else: print(a+2b)
Statement Takahashi has A untasty cookies containing antidotes, B tasty cookies containing antidotes and C tasty cookies containing poison. Eating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomachache results in a death. As he wants to live, he cannot eat one in such a situation. Eating a cookie containing antidotes while having a stomachache cures it, and there is no other way to cure stomachaches. Find the maximum number of tasty cookies that Takahashi can eat.
[{"input": "3 1 4", "output": "5\n \n\nWe can eat all tasty cookies, in the following order:\n\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n * A tasty cookie containing antidotes\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n\n* * *"}, {"input": "5 2 9", "output": "10\n \n\n* * *"}, {"input": "8 8 1", "output": "9"}]
Print the maximum number of tasty cookies that Takahashi can eat. * * *
s108115681
Runtime Error
p03186
Input is given from Standard Input in the following format: A B C
A = int(input()) B = int(input()) C = int(input()) j = 0 for i in range(C): j = j + 1
Statement Takahashi has A untasty cookies containing antidotes, B tasty cookies containing antidotes and C tasty cookies containing poison. Eating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomachache results in a death. As he wants to live, he cannot eat one in such a situation. Eating a cookie containing antidotes while having a stomachache cures it, and there is no other way to cure stomachaches. Find the maximum number of tasty cookies that Takahashi can eat.
[{"input": "3 1 4", "output": "5\n \n\nWe can eat all tasty cookies, in the following order:\n\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n * A tasty cookie containing antidotes\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n\n* * *"}, {"input": "5 2 9", "output": "10\n \n\n* * *"}, {"input": "8 8 1", "output": "9"}]
Print the maximum number of tasty cookies that Takahashi can eat. * * *
s948681548
Wrong Answer
p03186
Input is given from Standard Input in the following format: A B C
a, b, c = (int(i) for i in input().split())
Statement Takahashi has A untasty cookies containing antidotes, B tasty cookies containing antidotes and C tasty cookies containing poison. Eating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomachache results in a death. As he wants to live, he cannot eat one in such a situation. Eating a cookie containing antidotes while having a stomachache cures it, and there is no other way to cure stomachaches. Find the maximum number of tasty cookies that Takahashi can eat.
[{"input": "3 1 4", "output": "5\n \n\nWe can eat all tasty cookies, in the following order:\n\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n * A tasty cookie containing antidotes\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n\n* * *"}, {"input": "5 2 9", "output": "10\n \n\n* * *"}, {"input": "8 8 1", "output": "9"}]
Print the maximum number of tasty cookies that Takahashi can eat. * * *
s598737106
Runtime Error
p03186
Input is given from Standard Input in the following format: A B C
a,b,c=map(int,input().split()) d=b+c if a*2=<d: print(a*2) else: print(d)
Statement Takahashi has A untasty cookies containing antidotes, B tasty cookies containing antidotes and C tasty cookies containing poison. Eating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomachache results in a death. As he wants to live, he cannot eat one in such a situation. Eating a cookie containing antidotes while having a stomachache cures it, and there is no other way to cure stomachaches. Find the maximum number of tasty cookies that Takahashi can eat.
[{"input": "3 1 4", "output": "5\n \n\nWe can eat all tasty cookies, in the following order:\n\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n * A tasty cookie containing antidotes\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n\n* * *"}, {"input": "5 2 9", "output": "10\n \n\n* * *"}, {"input": "8 8 1", "output": "9"}]
Print the maximum number of tasty cookies that Takahashi can eat. * * *
s744235512
Runtime Error
p03186
Input is given from Standard Input in the following format: A B C
a.b.c=(int(i) for i in input().split()) if b+1>c: print(b+c) else: if a+1>c-b: print(2*b+c) else: print(2b+a+1)
Statement Takahashi has A untasty cookies containing antidotes, B tasty cookies containing antidotes and C tasty cookies containing poison. Eating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomachache results in a death. As he wants to live, he cannot eat one in such a situation. Eating a cookie containing antidotes while having a stomachache cures it, and there is no other way to cure stomachaches. Find the maximum number of tasty cookies that Takahashi can eat.
[{"input": "3 1 4", "output": "5\n \n\nWe can eat all tasty cookies, in the following order:\n\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n * A tasty cookie containing antidotes\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n\n* * *"}, {"input": "5 2 9", "output": "10\n \n\n* * *"}, {"input": "8 8 1", "output": "9"}]
Print the maximum number of tasty cookies that Takahashi can eat. * * *
s409775278
Runtime Error
p03186
Input is given from Standard Input in the following format: A B C
a, b, c = map(int, input().split()) if a+b >= c: c = c + 1 else a + b < c: c = c + 1 print(c)
Statement Takahashi has A untasty cookies containing antidotes, B tasty cookies containing antidotes and C tasty cookies containing poison. Eating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomachache results in a death. As he wants to live, he cannot eat one in such a situation. Eating a cookie containing antidotes while having a stomachache cures it, and there is no other way to cure stomachaches. Find the maximum number of tasty cookies that Takahashi can eat.
[{"input": "3 1 4", "output": "5\n \n\nWe can eat all tasty cookies, in the following order:\n\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n * A tasty cookie containing antidotes\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n\n* * *"}, {"input": "5 2 9", "output": "10\n \n\n* * *"}, {"input": "8 8 1", "output": "9"}]
Print the maximum number of tasty cookies that Takahashi can eat. * * *
s747786710
Runtime Error
p03186
Input is given from Standard Input in the following format: A B C
a,b,c=(int(i) for i in input().split()) if b+1>=c: print(b+c) else: if a+1>c-b: print(2*b+c) else: print(2b+a+1)
Statement Takahashi has A untasty cookies containing antidotes, B tasty cookies containing antidotes and C tasty cookies containing poison. Eating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomachache results in a death. As he wants to live, he cannot eat one in such a situation. Eating a cookie containing antidotes while having a stomachache cures it, and there is no other way to cure stomachaches. Find the maximum number of tasty cookies that Takahashi can eat.
[{"input": "3 1 4", "output": "5\n \n\nWe can eat all tasty cookies, in the following order:\n\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n * A tasty cookie containing antidotes\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n\n* * *"}, {"input": "5 2 9", "output": "10\n \n\n* * *"}, {"input": "8 8 1", "output": "9"}]
Print the maximum number of tasty cookies that Takahashi can eat. * * *
s583616954
Runtime Error
p03186
Input is given from Standard Input in the following format: A B C
a,b,c=map(int,input().split()) if a + b >= c + 1: print(b+c) elif a==b==c==0: print(0) elif a+b=c: print(b+c) else: print(a+2*b+1)
Statement Takahashi has A untasty cookies containing antidotes, B tasty cookies containing antidotes and C tasty cookies containing poison. Eating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomachache results in a death. As he wants to live, he cannot eat one in such a situation. Eating a cookie containing antidotes while having a stomachache cures it, and there is no other way to cure stomachaches. Find the maximum number of tasty cookies that Takahashi can eat.
[{"input": "3 1 4", "output": "5\n \n\nWe can eat all tasty cookies, in the following order:\n\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n * A tasty cookie containing antidotes\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n\n* * *"}, {"input": "5 2 9", "output": "10\n \n\n* * *"}, {"input": "8 8 1", "output": "9"}]
Print the maximum number of tasty cookies that Takahashi can eat. * * *
s724437405
Runtime Error
p03186
Input is given from Standard Input in the following format: A B C
A,B,C=map(int,input().split()) if B>=C: ans=B+C else C>B: ans+=2*B if A>C: ans+=C else: ans+=A print(ans)
Statement Takahashi has A untasty cookies containing antidotes, B tasty cookies containing antidotes and C tasty cookies containing poison. Eating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomachache results in a death. As he wants to live, he cannot eat one in such a situation. Eating a cookie containing antidotes while having a stomachache cures it, and there is no other way to cure stomachaches. Find the maximum number of tasty cookies that Takahashi can eat.
[{"input": "3 1 4", "output": "5\n \n\nWe can eat all tasty cookies, in the following order:\n\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n * A tasty cookie containing antidotes\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n\n* * *"}, {"input": "5 2 9", "output": "10\n \n\n* * *"}, {"input": "8 8 1", "output": "9"}]
Print the maximum number of tasty cookies that Takahashi can eat. * * *
s924245683
Runtime Error
p03186
Input is given from Standard Input in the following format: A B C
L,N=(int(i) for i in input().split()) X = [] for i in range(0,N): a = int(input()) X.append(a) import math if X[math.ceil(N/2)]<L/2: result=L-X[N-1] for i in range (0,math.ceil(N/2)): for j in range (N-1,math.ceil(N/2)-1,-1): result+=abs(X[j]-X[i]) else: result=X[0] for i in range (0,math.ceil(N/2)): for j in range (N-1,math.ceil(N/2)-1,-1): result+=abs(X[i]-X[j]) print(result)
Statement Takahashi has A untasty cookies containing antidotes, B tasty cookies containing antidotes and C tasty cookies containing poison. Eating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomachache results in a death. As he wants to live, he cannot eat one in such a situation. Eating a cookie containing antidotes while having a stomachache cures it, and there is no other way to cure stomachaches. Find the maximum number of tasty cookies that Takahashi can eat.
[{"input": "3 1 4", "output": "5\n \n\nWe can eat all tasty cookies, in the following order:\n\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n * A tasty cookie containing antidotes\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n\n* * *"}, {"input": "5 2 9", "output": "10\n \n\n* * *"}, {"input": "8 8 1", "output": "9"}]
Print the maximum number of tasty cookies that Takahashi can eat. * * *
s730614357
Runtime Error
p03186
Input is given from Standard Input in the following format: A B C
#include <iostream> #include <algorithm> #include <vector> #include <set> #include <iomanip> #include <queue> #include <map> #define debug(x) std::cerr << #x << " = " << (x) << std::endl using namespace std; typedef long long LL; const int MAXN = 1e5 + 17; const int MOD = 1e9 + 17; int main(int argc, char const *argv[]) { #ifdef noob freopen("Input.txt", "r", stdin); freopen("Output.txt", "w", stdout); #endif int a,b,c,ans = 0; cin>>a>>b>>c; int mn = min(b,c); ans += 2*mn; c -= mn; ans += min(a,c); cout<<ans<<endl; return 0; }
Statement Takahashi has A untasty cookies containing antidotes, B tasty cookies containing antidotes and C tasty cookies containing poison. Eating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomachache results in a death. As he wants to live, he cannot eat one in such a situation. Eating a cookie containing antidotes while having a stomachache cures it, and there is no other way to cure stomachaches. Find the maximum number of tasty cookies that Takahashi can eat.
[{"input": "3 1 4", "output": "5\n \n\nWe can eat all tasty cookies, in the following order:\n\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n * A tasty cookie containing antidotes\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n\n* * *"}, {"input": "5 2 9", "output": "10\n \n\n* * *"}, {"input": "8 8 1", "output": "9"}]
Print the maximum number of tasty cookies that Takahashi can eat. * * *
s785383142
Runtime Error
p03186
Input is given from Standard Input in the following format: A B C
abc = input().split(" ") a = int(abc[0]) b = int(abc[1]) c = int(abc[2]) a_flg = True b_flg = True c_flg = True cnt = 0 if b >= c: cnt += b + c #b -= c #c = 0 #c_flg = False elif b < c: cnt += 2 * b c -= b if a < c: cnt += a + 1 else: cnt += c + 1 #b = 0 #b_flg = False print(cnt) """
Statement Takahashi has A untasty cookies containing antidotes, B tasty cookies containing antidotes and C tasty cookies containing poison. Eating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomachache results in a death. As he wants to live, he cannot eat one in such a situation. Eating a cookie containing antidotes while having a stomachache cures it, and there is no other way to cure stomachaches. Find the maximum number of tasty cookies that Takahashi can eat.
[{"input": "3 1 4", "output": "5\n \n\nWe can eat all tasty cookies, in the following order:\n\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n * A tasty cookie containing antidotes\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n\n* * *"}, {"input": "5 2 9", "output": "10\n \n\n* * *"}, {"input": "8 8 1", "output": "9"}]
Print the maximum number of tasty cookies that Takahashi can eat. * * *
s061538191
Runtime Error
p03186
Input is given from Standard Input in the following format: A B C
a = list(map(int,input().split())) if a[0] + a[1] >= a[2]: print(a[1] + a[2]) elif a[0] + a[1] < a[2]: f = a[2] - a[1] print(a[1] + f + 1)
Statement Takahashi has A untasty cookies containing antidotes, B tasty cookies containing antidotes and C tasty cookies containing poison. Eating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomachache results in a death. As he wants to live, he cannot eat one in such a situation. Eating a cookie containing antidotes while having a stomachache cures it, and there is no other way to cure stomachaches. Find the maximum number of tasty cookies that Takahashi can eat.
[{"input": "3 1 4", "output": "5\n \n\nWe can eat all tasty cookies, in the following order:\n\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n * A tasty cookie containing antidotes\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n\n* * *"}, {"input": "5 2 9", "output": "10\n \n\n* * *"}, {"input": "8 8 1", "output": "9"}]
Print the maximum number of tasty cookies that Takahashi can eat. * * *
s822439866
Runtime Error
p03186
Input is given from Standard Input in the following format: A B C
A, B, C = (int(n) for n in input().split()) count = 0 if C - B < 0: count = C + B elif C - B =>0: if C - B - A =<0: count = C + B elif C - B - A >0: count = A + 2*B + 1 print(count)
Statement Takahashi has A untasty cookies containing antidotes, B tasty cookies containing antidotes and C tasty cookies containing poison. Eating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomachache results in a death. As he wants to live, he cannot eat one in such a situation. Eating a cookie containing antidotes while having a stomachache cures it, and there is no other way to cure stomachaches. Find the maximum number of tasty cookies that Takahashi can eat.
[{"input": "3 1 4", "output": "5\n \n\nWe can eat all tasty cookies, in the following order:\n\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n * A tasty cookie containing antidotes\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n\n* * *"}, {"input": "5 2 9", "output": "10\n \n\n* * *"}, {"input": "8 8 1", "output": "9"}]
Print the maximum number of tasty cookies that Takahashi can eat. * * *
s473271929
Wrong Answer
p03186
Input is given from Standard Input in the following format: A B C
abc = list(map(int, input().split())) if abc[2] >= abc[1] and abc[1] >= abc[0]: print(2 * abc[1] + min(abc[0], abc[2] - abc[1])) elif abc[2] >= abc[0] and abc[0] >= abc[1]: print(2 * abc[1] + min(abc[0], abc[2] - abc[1])) elif abc[1] >= abc[0] and abc[0] >= abc[2]: print(abc[1] + abc[2]) elif abc[1] >= abc[2] and abc[2] >= abc[0]: print(abc[1] + abc[2]) elif abc[0] >= abc[1] and abc[1] >= abc[2]: print(abc[1] + abc[2]) elif abc[0] >= abc[2] and abc[2] >= abc[1]: print(abc[1] + abc[2])
Statement Takahashi has A untasty cookies containing antidotes, B tasty cookies containing antidotes and C tasty cookies containing poison. Eating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomachache results in a death. As he wants to live, he cannot eat one in such a situation. Eating a cookie containing antidotes while having a stomachache cures it, and there is no other way to cure stomachaches. Find the maximum number of tasty cookies that Takahashi can eat.
[{"input": "3 1 4", "output": "5\n \n\nWe can eat all tasty cookies, in the following order:\n\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n * A tasty cookie containing antidotes\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n\n* * *"}, {"input": "5 2 9", "output": "10\n \n\n* * *"}, {"input": "8 8 1", "output": "9"}]
Print the maximum number of tasty cookies that Takahashi can eat. * * *
s207309595
Runtime Error
p03186
Input is given from Standard Input in the following format: A B C
N = input() a_list = list(map(int, input().split())) b_list = list(map(int, input().split())) if all([a >= b for a, b in zip(a_list, b_list)]): # すべての準備度が必要度を上回っている場合 print(0) else: # 準備度が足りていない試験がある場合 if sum(a_list) < sum(b_list): # そもそも準備度の総量が足りない場合 print(-1) else: # 準備度を移動すれば受かる場合 # 一番数の大きいところから足りていないところに割り振る戦略 # a_listをcopy c_list = [a for a in a_list] # 準備度の余裕をリストに格納 diff_list = [c - b for c, b in zip(c_list, b_list)] # 一度減算し始めたら対象が0になるまで続ける selected_biggest_idx = diff_list.index(max(diff_list)) while not all([c >= b for c, b in zip(c_list, b_list)]): if diff_list[selected_biggest_idx] == 0: selected_biggest_idx = diff_list.index(max(diff_list)) min_idx = diff_list.index(min(diff_list)) # 最大と最小で移し替えを行う if diff_list[selected_biggest_idx] < abs(diff_list[min_idx]): # 足りていない値のほうが大きい場合 c_list[selected_biggest_idx] -= diff_list[selected_biggest_idx] c_list[min_idx] += diff_list[selected_biggest_idx] else: # 足りていない値のほうが小さい場合 c_list[selected_biggest_idx] -= abs(diff_list[min_idx]) c_list[min_idx] += abs(diff_list[min_idx]) # diff_listを更新 diff_list = [c - b for c, b in zip(c_list, b_list)] result_count = len([1 for a, c in zip(a_list, c_list) if a != c]) print(result_count)
Statement Takahashi has A untasty cookies containing antidotes, B tasty cookies containing antidotes and C tasty cookies containing poison. Eating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomachache results in a death. As he wants to live, he cannot eat one in such a situation. Eating a cookie containing antidotes while having a stomachache cures it, and there is no other way to cure stomachaches. Find the maximum number of tasty cookies that Takahashi can eat.
[{"input": "3 1 4", "output": "5\n \n\nWe can eat all tasty cookies, in the following order:\n\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n * A tasty cookie containing antidotes\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n\n* * *"}, {"input": "5 2 9", "output": "10\n \n\n* * *"}, {"input": "8 8 1", "output": "9"}]
Print the maximum number of tasty cookies that Takahashi can eat. * * *
s242354358
Runtime Error
p03186
Input is given from Standard Input in the following format: A B C
abc = input().split(" ") a = int(abc[0]) b = int(abc[1]) c = int(abc[2]) a_flg = True b_flg = True c_flg = True cnt = 0 if b >= c: cnt += b + c #b -= c #c = 0 #c_flg = False elif b < c: cnt += 2 * b c -= b if a < c: cnt += a else: cnt += c + 1 #b = 0 #b_flg = False print(cnt) """
Statement Takahashi has A untasty cookies containing antidotes, B tasty cookies containing antidotes and C tasty cookies containing poison. Eating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomachache results in a death. As he wants to live, he cannot eat one in such a situation. Eating a cookie containing antidotes while having a stomachache cures it, and there is no other way to cure stomachaches. Find the maximum number of tasty cookies that Takahashi can eat.
[{"input": "3 1 4", "output": "5\n \n\nWe can eat all tasty cookies, in the following order:\n\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n * A tasty cookie containing antidotes\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n\n* * *"}, {"input": "5 2 9", "output": "10\n \n\n* * *"}, {"input": "8 8 1", "output": "9"}]
Print the maximum number of tasty cookies that Takahashi can eat. * * *
s708191200
Runtime Error
p03186
Input is given from Standard Input in the following format: A B C
a = list(map(int,input().split())) if a[0] + a[1] >= a[2]: print(a[1] + a[2]) elif a[0] + a[1] < a[2]: f = a[2] - a[1] print(a[1] + f + 1)
Statement Takahashi has A untasty cookies containing antidotes, B tasty cookies containing antidotes and C tasty cookies containing poison. Eating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomachache results in a death. As he wants to live, he cannot eat one in such a situation. Eating a cookie containing antidotes while having a stomachache cures it, and there is no other way to cure stomachaches. Find the maximum number of tasty cookies that Takahashi can eat.
[{"input": "3 1 4", "output": "5\n \n\nWe can eat all tasty cookies, in the following order:\n\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n * A tasty cookie containing antidotes\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n\n* * *"}, {"input": "5 2 9", "output": "10\n \n\n* * *"}, {"input": "8 8 1", "output": "9"}]
Print the maximum number of tasty cookies that Takahashi can eat. * * *
s479222024
Runtime Error
p03186
Input is given from Standard Input in the following format: A B C
j
Statement Takahashi has A untasty cookies containing antidotes, B tasty cookies containing antidotes and C tasty cookies containing poison. Eating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomachache results in a death. As he wants to live, he cannot eat one in such a situation. Eating a cookie containing antidotes while having a stomachache cures it, and there is no other way to cure stomachaches. Find the maximum number of tasty cookies that Takahashi can eat.
[{"input": "3 1 4", "output": "5\n \n\nWe can eat all tasty cookies, in the following order:\n\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n * A tasty cookie containing antidotes\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n\n* * *"}, {"input": "5 2 9", "output": "10\n \n\n* * *"}, {"input": "8 8 1", "output": "9"}]
Print the maximum number of tasty cookies that Takahashi can eat. * * *
s341306101
Wrong Answer
p03186
Input is given from Standard Input in the following format: A B C
def cookie(a, b, c): if (a + b) > c: return c + b else: return a + 2 * b
Statement Takahashi has A untasty cookies containing antidotes, B tasty cookies containing antidotes and C tasty cookies containing poison. Eating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomachache results in a death. As he wants to live, he cannot eat one in such a situation. Eating a cookie containing antidotes while having a stomachache cures it, and there is no other way to cure stomachaches. Find the maximum number of tasty cookies that Takahashi can eat.
[{"input": "3 1 4", "output": "5\n \n\nWe can eat all tasty cookies, in the following order:\n\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n * A tasty cookie containing antidotes\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n\n* * *"}, {"input": "5 2 9", "output": "10\n \n\n* * *"}, {"input": "8 8 1", "output": "9"}]
Print the maximum number of tasty cookies that Takahashi can eat. * * *
s855982019
Runtime Error
p03186
Input is given from Standard Input in the following format: A B C
A, B, C = map(int, input().split()) if A + B >= C - 1: print("{}".format(B+C) else: print("{}".format(A+2*B+1))
Statement Takahashi has A untasty cookies containing antidotes, B tasty cookies containing antidotes and C tasty cookies containing poison. Eating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomachache results in a death. As he wants to live, he cannot eat one in such a situation. Eating a cookie containing antidotes while having a stomachache cures it, and there is no other way to cure stomachaches. Find the maximum number of tasty cookies that Takahashi can eat.
[{"input": "3 1 4", "output": "5\n \n\nWe can eat all tasty cookies, in the following order:\n\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n * A tasty cookie containing antidotes\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n\n* * *"}, {"input": "5 2 9", "output": "10\n \n\n* * *"}, {"input": "8 8 1", "output": "9"}]
Print the maximum number of tasty cookies that Takahashi can eat. * * *
s543061032
Runtime Error
p03186
Input is given from Standard Input in the following format: A B C
a, b, c = map(int, input().split()) if a+b+1 > c: count = b+c else count = b+(a+b+1) print(count)
Statement Takahashi has A untasty cookies containing antidotes, B tasty cookies containing antidotes and C tasty cookies containing poison. Eating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomachache results in a death. As he wants to live, he cannot eat one in such a situation. Eating a cookie containing antidotes while having a stomachache cures it, and there is no other way to cure stomachaches. Find the maximum number of tasty cookies that Takahashi can eat.
[{"input": "3 1 4", "output": "5\n \n\nWe can eat all tasty cookies, in the following order:\n\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n * A tasty cookie containing antidotes\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n\n* * *"}, {"input": "5 2 9", "output": "10\n \n\n* * *"}, {"input": "8 8 1", "output": "9"}]
Print the maximum number of tasty cookies that Takahashi can eat. * * *
s032753145
Runtime Error
p03186
Input is given from Standard Input in the following format: A B C
a=[int(x) for x in input().split()] if(a[0]+a[1]>a[2]): print(a[1]+a[2]) elif: print(a[1]+a[2]-abs(a[0]+a[1]-a[2]))
Statement Takahashi has A untasty cookies containing antidotes, B tasty cookies containing antidotes and C tasty cookies containing poison. Eating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomachache results in a death. As he wants to live, he cannot eat one in such a situation. Eating a cookie containing antidotes while having a stomachache cures it, and there is no other way to cure stomachaches. Find the maximum number of tasty cookies that Takahashi can eat.
[{"input": "3 1 4", "output": "5\n \n\nWe can eat all tasty cookies, in the following order:\n\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n * A tasty cookie containing antidotes\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n\n* * *"}, {"input": "5 2 9", "output": "10\n \n\n* * *"}, {"input": "8 8 1", "output": "9"}]
Print the maximum number of tasty cookies that Takahashi can eat. * * *
s264647125
Runtime Error
p03186
Input is given from Standard Input in the following format: A B C
i=input() is=i.split(" ") a=int(is[0]) b=int(is[1]) c=int(is[2]) if(a+b>c-1){ print(c+b) else{ print(b+(a+b+1))
Statement Takahashi has A untasty cookies containing antidotes, B tasty cookies containing antidotes and C tasty cookies containing poison. Eating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomachache results in a death. As he wants to live, he cannot eat one in such a situation. Eating a cookie containing antidotes while having a stomachache cures it, and there is no other way to cure stomachaches. Find the maximum number of tasty cookies that Takahashi can eat.
[{"input": "3 1 4", "output": "5\n \n\nWe can eat all tasty cookies, in the following order:\n\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n * A tasty cookie containing antidotes\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n\n* * *"}, {"input": "5 2 9", "output": "10\n \n\n* * *"}, {"input": "8 8 1", "output": "9"}]
Print the maximum number of tasty cookies that Takahashi can eat. * * *
s990567375
Runtime Error
p03186
Input is given from Standard Input in the following format: A B C
A,B,C=map(int,input().split()) if B>=C: ans=B+C else C>B: ans=2*B if A>C: ans+=C else: ans+=A print(ans)
Statement Takahashi has A untasty cookies containing antidotes, B tasty cookies containing antidotes and C tasty cookies containing poison. Eating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomachache results in a death. As he wants to live, he cannot eat one in such a situation. Eating a cookie containing antidotes while having a stomachache cures it, and there is no other way to cure stomachaches. Find the maximum number of tasty cookies that Takahashi can eat.
[{"input": "3 1 4", "output": "5\n \n\nWe can eat all tasty cookies, in the following order:\n\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n * A tasty cookie containing antidotes\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n\n* * *"}, {"input": "5 2 9", "output": "10\n \n\n* * *"}, {"input": "8 8 1", "output": "9"}]
Print the maximum number of tasty cookies that Takahashi can eat. * * *
s007351084
Accepted
p03186
Input is given from Standard Input in the following format: A B C
c = input() d = c.split() d = [int(i) for i in d] p = d[0] q = d[1] r = d[2] count = 0 if p + q < r: count += p + q + q + 1 elif p + q >= r: count += r + q print(count)
Statement Takahashi has A untasty cookies containing antidotes, B tasty cookies containing antidotes and C tasty cookies containing poison. Eating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomachache results in a death. As he wants to live, he cannot eat one in such a situation. Eating a cookie containing antidotes while having a stomachache cures it, and there is no other way to cure stomachaches. Find the maximum number of tasty cookies that Takahashi can eat.
[{"input": "3 1 4", "output": "5\n \n\nWe can eat all tasty cookies, in the following order:\n\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n * A tasty cookie containing antidotes\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n\n* * *"}, {"input": "5 2 9", "output": "10\n \n\n* * *"}, {"input": "8 8 1", "output": "9"}]