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 `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s753128901
Accepted
p03109
Input is given from Standard Input in the following format: S
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys # {{{ import os import time import re from pydoc import help import string import math from operator import itemgetter from collections import Counter from collections import deque from collections import defaultdict as dd import fractions from heapq import heappop, heappush, heapify import array from bisect import bisect_left, bisect_right, insort_left, insort_right from copy import deepcopy as dcopy import itertools # }}} # pre-defined{{{ sys.setrecursionlimit(10**7) INF = 10**20 GOSA = 1.0 / 10**10 MOD = 10**9 + 7 ALPHABETS = [ chr(i) for i in range(ord("a"), ord("z") + 1) ] # can also use string module def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()] def LF(): return [float(x) for x in sys.stdin.readline().split()] def LS(): return sys.stdin.readline().split() def I(): return int(sys.stdin.readline()) def F(): return float(sys.stdin.readline()) def DP(N, M, first): return [[first] * M for n in range(N)] def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)] from inspect import currentframe def dump(*args): names = {id(v): k for k, v in currentframe().f_back.f_locals.items()} print( ", ".join(names.get(id(arg), "???") + " => " + repr(arg) for arg in args), file=sys.stderr, ) # }}} def local_input(): # {{{ from pcm.utils import set_stdin import sys from pathlib import Path parentdir = Path(os.path.dirname(__file__)).parent inputfile = parentdir.joinpath("test/sample-1.in") if len(sys.argv) == 1: set_stdin(inputfile) # }}} def solve(): s = input() yyyy = int(s[:4]) mm = int(s[5:7]) # print(yyyy, mm) if yyyy >= 2019 and mm >= 5: print("TBD") else: print("Heisei") return 0 if __name__ == "__main__": # {{{ try: local_input() except: pass solve() # vim: set foldmethod=marker:}}}
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s863757834
Accepted
p03109
Input is given from Standard Input in the following format: S
from collections import defaultdict, deque, Counter from heapq import heappush, heappop, heapify from itertools import ( permutations, accumulate, combinations, combinations_with_replacement, ) from math import sqrt, ceil, floor, factorial from bisect import bisect_left, bisect_right, insort_left, insort_right from copy import deepcopy from operator import itemgetter from functools import reduce from fractions import gcd import sys def input(): return sys.stdin.readline().rstrip() def I(): return int(input()) def Is(): return map(int, input().split()) def LI(): return list(map(int, input().split())) def TI(): return tuple(map(int, input().split())) def IR(n): return [I() for _ in range(n)] def LIR(n): return [LI() for _ in range(n)] def TIR(n): return [TI() for _ in range(n)] def S(): return input() def Ss(): return input().split() def LS(): return list(input()) def SR(n): return [S() for _ in range(n)] def SsR(n): return [Ss() for _ in range(n)] def LSR(n): return [LS() for _ in range(n)] sys.setrecursionlimit(10**6) MOD = 10**9 + 7 INF = float("inf") # ----------------------------------------------------------- # s = S() y = int(s[:4]) m = int(s[5:7]) d = int(s[8:]) if y < 2019 or (y == 2019 and m < 5): print("Heisei") else: print("TBD")
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s940093941
Runtime Error
p03109
Input is given from Standard Input in the following format: S
s = str(input()) year = "" month = "" day = "" for i in range(4): y = s[i] year += y for i in range(5, 7): m = s[i] month += m for i in range(9, 11): d = s[i] day += d year = int(year) month = int(month) day = int(day) if year < 2019: answer = "Heisei" elif year == 2019 and month <= 4: answer = "Heisei" else: answer = "TBD" print(answer)
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s684849493
Runtime Error
p03109
Input is given from Standard Input in the following format: S
import numpy as np def check(x, al, bl): rcost = np.inf for a in al: tmp_c = abs(a - x) for b in bl: t = abs(b - a) rcost = min(rcost, tmp_c + t, abs(b - x) + t) print(int(rcost)) n = [int(each) for each in input().split()] a, b, q = n[0], n[1], n[2] sl = np.zeros(a) tl = np.zeros(b) xl = np.zeros(q) for i in range(a): sl[i] = int(input()) for i in range(b): tl[i] = int(input()) for i in range(q): xl[i] = int(input()) result = [] for x in xl: check(x, sl, tl)
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s339859438
Accepted
p03109
Input is given from Standard Input in the following format: S
print("Heisei" if int(input().split("/")[1]) < 5 else "TBD")
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s628439625
Wrong Answer
p03109
Input is given from Standard Input in the following format: S
L = list(map(int, input().split("/"))) print("Heisesi" if L[1] >= 5 else "TBD")
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s804379534
Runtime Error
p03109
Input is given from Standard Input in the following format: S
s = input() y = int(s[0:4]) m = int(s[5:7]) d = int(s[8:10]) if y > 2019: print("TBD") elif y=2019 and m>4: print("TBD") else: print("Heisei")
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s805813676
Runtime Error
p03109
Input is given from Standard Input in the following format: S
y,m,d=map(int,input().split(/)) if y<=2018 : print(Heisei) else: if m<=4 : print(Heisei) else: print(TBD)
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s324432410
Runtime Error
p03109
Input is given from Standard Input in the following format: S
a=int(input()) b=0 for i in range(a): c=input().split() if c[1]=='BTC': b+=(float)c[0]*380000.0 else: b+=(int)c[0] print(b)
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s830617683
Runtime Error
p03109
Input is given from Standard Input in the following format: S
import datetime S = input() if datetime.datetime.strptime(S, "%Y/%m/%d") <= datetime.datetime(2019, 4, 30, 0 ,0 ,0): print('Heisei') else: print('TBD'
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s294155846
Runtime Error
p03109
Input is given from Standard Input in the following format: S
ret = 0 psn = int ( input () ) for i in range (psn) : m,t = input ( ) m = float ( m ) if t = "BTC" : m = 380000 * m ret += m print ( ret )
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s123231005
Runtime Error
p03109
Input is given from Standard Input in the following format: S
year, month, day = map(int, input().split("/")) if year<2019: print("Heisei") elif year == 2019 && month<5: print(Heisei) else: print("TBD")
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s405030794
Accepted
p03109
Input is given from Standard Input in the following format: S
S = list(str(input())) print("Heisei" if int(S[5]) == 0 and int(S[6]) < 5 else "TBD")
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s960266350
Accepted
p03109
Input is given from Standard Input in the following format: S
nancy = "TBD" if int(input().split("/")[1]) > 4 else "Heisei" print(nancy)
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s824265331
Accepted
p03109
Input is given from Standard Input in the following format: S
print(["Heisei", "TBD"][input()[5:7] > "04"])
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s311137303
Accepted
p03109
Input is given from Standard Input in the following format: S
print("Heisei" if input() < "2019/05/01" else "TBD")
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s445474888
Accepted
p03109
Input is given from Standard Input in the following format: S
print("TBD" if int(input()[5:7]) >= 5 else "Heisei")
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s757171715
Accepted
p03109
Input is given from Standard Input in the following format: S
print("TBD" if int(input().replace("/", "")) > 20190430 else "Heisei")
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s147222871
Runtime Error
p03109
Input is given from Standard Input in the following format: S
a,b,c=map(int,input()split("/")) print("Heisei" if b*10+c<=70 else "TBD")
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s364803167
Runtime Error
p03109
Input is given from Standard Input in the following format: S
s = input print("TBD") if int(s[5:7]) =>5 else print("Heisei")
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s412308069
Runtime Error
p03109
Input is given from Standard Input in the following format: S
S = input() 2 print('Heisei' if S <= '2019/04/30' else 'TBD')
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s553178748
Runtime Error
p03109
Input is given from Standard Input in the following format: S
s = sorted(input()) t = sorted(input())[::-1] print("Yes" if s < t else "No")
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s190039259
Runtime Error
p03109
Input is given from Standard Input in the following format: S
s = input() if s[5::6] <= 04 and s[8::9] <= 30: print("Heisei") else: print("TBD")
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s446792546
Runtime Error
p03109
Input is given from Standard Input in the following format: S
print("Heisei" if input()<="2019/04/30" and"TBD")
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s385897875
Wrong Answer
p03109
Input is given from Standard Input in the following format: S
n = input() print("Heisei" if n <= "2019/4/30" else "TBD")
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s335245289
Runtime Error
p03109
Input is given from Standard Input in the following format: S
n=input() if int(n[5]+n[6]) >=5: print('TBD'): else: print('Heisei')
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s752147156
Runtime Error
p03109
Input is given from Standard Input in the following format: S
s = input() print("Heisei") if s[5:7] =< 4 else print("TBD")
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s275529835
Wrong Answer
p03109
Input is given from Standard Input in the following format: S
print("Heisei" if int(input().replace("/", "")) <= 2019430 else "TBD")
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s478415634
Runtime Error
p03109
Input is given from Standard Input in the following format: S
S = map(int, input().replace("/", "")) print("Heisei" if S <= S else "TBD")
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s328932395
Runtime Error
p03109
Input is given from Standard Input in the following format: S
s=input()s=input() if int(s[1])>4: print('TBD') elif int(s[0])==1: print('TBD') else: print('Heisei')
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s878111030
Runtime Error
p03109
Input is given from Standard Input in the following format: S
S=input() S_l=S.split('/') if int(S_l[1]>4: print('TBD') else: print('Heisei')
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s502275210
Runtime Error
p03109
Input is given from Standard Input in the following format: S
S=int(input("yyyy/mm/dd")) if S<="2019/04/30": print("Heisei") else: print("TBD")
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s873974241
Runtime Error
p03109
Input is given from Standard Input in the following format: S
y, m, d =list(map(int, input().split('/'))) if y<2019: print('Heisei') elif m=<4: print('Heisei') else: print('TBD')
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s467906380
Runtime Error
p03109
Input is given from Standard Input in the following format: S
y=0 for _ in range(int(input())): x,u=input().split() y+=int(x) if u=="JPY" else float(x)*380000 print(y
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s348394999
Runtime Error
p03109
Input is given from Standard Input in the following format: S
S = map(int,input().split("/")) if S<=20190430: print("Heisei") elif: print("TBD")
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s219554679
Runtime Error
p03109
Input is given from Standard Input in the following format: S
a, b, c=map(int, input().split(/)) if a>=2020: print("TBD") elif a==2019 and b>=5: print("TBD") else: print("Heisei")
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s389897890
Wrong Answer
p03109
Input is given from Standard Input in the following format: S
S = [int(i) for i in input().split("/")] print("Heisei" if S[1] >= 4 and S[2] >= 30 else "TBD")
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s459448132
Runtime Error
p03109
Input is given from Standard Input in the following format: S
s=list(map(int,input().split("/"))) if (s[0]=2019 and s[1]<=4) or (s[0]<2019): print("Heisei") else: print("TBD")
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s130921440
Runtime Error
p03109
Input is given from Standard Input in the following format: S
import numpy as np s = str(input()) y, m, d = s.split("/") y, m, d = int(y), int(m), int(d) if y < 2019: print("Heisei") elif y==2019 and m<4: print("Heisei") elif y==2019 and m=4 and d < 30: print("Heisei") else: print("TBD")
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s472955633
Runtime Error
p03109
Input is given from Standard Input in the following format: S
# -*- coding: utf-8 -*- date = input().split('/') if(int(date[0]) >= 2020): print('TBD') elif(int(date[0]) == 2019 && int(date[1]) >=5): print('TBD') else: print('Heisei')
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s181816482
Runtime Error
p03109
Input is given from Standard Input in the following format: S
//include //------------------------------------------ #include <bits/stdc++.h> using namespace std; //typedef //------------------------------------------ typedef long long LL; typedef vector<LL> VL; typedef vector<VL> VVL; typedef vector<string> VS; typedef pair<LL, LL> PLL; //container util //------------------------------------------ #define ALL(a) (a).begin(),(a).end() #define RALL(a) (a).rbegin(), (a).rend() #define PB push_back #define MP make_pair #define SZ(a) int((a).size()) #define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i) #define EXIST(s,e) ((s).find(e)!=(s).end()) #define SORT(c) sort((c).begin(),(c).end()) //constant //-------------------------------------------- const double EPS = 1e-10; const double PI = acos(-1.0); const int MOD = 1000000007; //debug #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; //main code int main(int argc, char const* argv[]) { string s; cin >> s; if (s[5] == '0' and s[6] <= '4') { cout << "Heisei" << endl; } else { cout << "TBD" << endl; } return 0; }
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s482823512
Runtime Error
p03109
Input is given from Standard Input in the following format: S
N = int(input()) total = 0.0 for i in range(N): money, tani = map(input().split()) money = float(input()) if tani = "JPY": total += money else: total += money * 380000.0 print("%.11f"%(total))
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s777674222
Runtime Error
p03109
Input is given from Standard Input in the following format: S
N = int(input()) total = 0.0 rate = 380000.0 for i in range(N): money, tani = input().split() money = float(input()) if tani = "JPY": total += money else: total += money*rate print("%.11f"%(total))
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s743479069
Runtime Error
p03109
Input is given from Standard Input in the following format: S
yy,mm,dd =map(int,input().split('/')) x = 0 if(yy<=2019): if(mm<=4): if(dd<=30): x = 1 if(x == 1): print('Heisei') else: print('TBD')
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s253177443
Runtime Error
p03109
Input is given from Standard Input in the following format: S
import datetime t = datetime.datetime.strptime(input(), "%Y/%m/%d") if t < (year=2019, month=5, day=1): print("Heisei") else: print("TBD")
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s435630680
Runtime Error
p03109
Input is given from Standard Input in the following format: S
S = input().split("/") if int(S[5]) < 5 and s[4] == 0 : print('Heisei') else : print('TBD')
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s798440286
Runtime Error
p03109
Input is given from Standard Input in the following format: S
a, b, q = map(int, input().split()) sno = [-10e6] + [int(input()) for _ in range(a)] + [10e6] tno = [-10e6] + [int(input()) for _ in range(b)] + [10e6] dis = [int(input()) for _ in range q] for i in range(q): sl = 0 sr = 0 tl = 0 tr = 0 for j in range(a+2): if sno[j] >= dis[i]: sl = dis[i] - sno[j-1] sr = sno[j] - dis[i] break else: pass for k in range(b+2): if tno[k] >= dis[i]: tl = dis[i] - tno[k-1] tr = tno[k] - dis[i] break else: pass lds = max(sl, tl) rds = max(sr, tr) ans = min(lds, rds) print(ans)
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s860320849
Runtime Error
p03109
Input is given from Standard Input in the following format: S
import bisect import itertools a, b, q = map(int, input().split()) ss, tt = [], [] for _ in range(a): ss.append(int(input())) for _ in range(b): tt.append(int(input())) for _ in range(q): x = int(input()) md = pow(10, 15) xs, xt = bisect.bisect_left(ss, x), bisect.bisect_left(tt, x) ls, rs, lt, rt = ( ss[max(0, xs - 1)], ss[min(a - 1, xs)], tt[max(0, xt - 1)], tt[min(b - 1, xt)], ) for s, t in itertools.product([ls, rs], [lt, rt]): if s > t: if t > x: md = s - x if s - x < md else md elif s > x: if md > 2 * (s - x) + x - t: md = 2 * (s - x) + x - t if md > 2 * (x - t) + s - x: md = 2 * (x - t) + s - x else: md = x - t if x - t < md else md else: # t > s if s > x: md = t - x if t - x < md else md elif t > x: if md > 2 * (x - s) + t - x: md = 2 * (x - s) + t - x if md > 2 * (t - x) + x - s: md = 2 * (t - x) + x - s else: md = x - s if x - s < md else md print(md)
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s909251583
Runtime Error
p03109
Input is given from Standard Input in the following format: S
N = int(input()) XU = list(input().split() for i in range(int(input()))) print(sum([float(x) * {"JPY": 1, "BTC": 380000}[u] for x, u in XU]))
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s871490095
Runtime Error
p03109
Input is given from Standard Input in the following format: S
#coding:utf-8 a = list(map(int,input().split("/"))) if a[0]=2019 and a[1]>=4: print("TBD") elif a[0]<2019: print("TBD") else: print("Heisei")
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s228792325
Runtime Error
p03109
Input is given from Standard Input in the following format: S
s=input() if int(s[:4])<2019: print("Heisei") exit() if int(s[:4])=2019 and int(s[5])<=4: print("Heisei") exit() print("TBD")
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s268757653
Accepted
p03109
Input is given from Standard Input in the following format: S
print("Heisei" if int(input().replace("/", "")) <= 20190430 else "TBD")
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s133354638
Accepted
p03109
Input is given from Standard Input in the following format: S
d = int(input().replace("/", "")) print("Heisei" if 20190430 - d >= 0 else "TBD")
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s554206720
Wrong Answer
p03109
Input is given from Standard Input in the following format: S
print("2019/04/30" if input() <= "2019/04/30" else "TBD")
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s425509328
Runtime Error
p03109
Input is given from Standard Input in the following format: S
S = input() if S[5:7] >= "04": print("TBD") else print("Heisei")
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s298378078
Wrong Answer
p03109
Input is given from Standard Input in the following format: S
print("Heisei" if input() <= "2019/04/30" else "TDB")
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s904945472
Wrong Answer
p03109
Input is given from Standard Input in the following format: S
Y, M, _ = map(int, input().split("/")) print("TBD") if 5 <= M else print("heisei")
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s256291065
Runtime Error
p03109
Input is given from Standard Input in the following format: S
s=input() if s<='2019/4/30': print("Heisei") else: print("TBD")
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s110611122
Runtime Error
p03109
Input is given from Standard Input in the following format: S
a
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s302568928
Accepted
p03109
Input is given from Standard Input in the following format: S
s = input().split("/") date = "" for i in s: date += i print("Heisei") if int(date) <= 20190430 else print("TBD")
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s194292204
Runtime Error
p03109
Input is given from Standard Input in the following format: S
y,m,d = map(int,input().split(/)) if y<2019 or (y==2019 and m <= 4): print("Heisei") else: print("TBD")
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s863963502
Runtime Error
p03109
Input is given from Standard Input in the following format: S
y = 0 for _ in range(int(input())): x, u = input().split() y += int(x) if u == "JPY" else float(x) * 380000 print(y)
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s786746518
Runtime Error
p03109
Input is given from Standard Input in the following format: S
N = int(input()) total = 0.0 for i in range(N): money, tani = input().split() money = float(money) if tani = "JPY": total += money else: total += money * 380000.0 print("%f"%(total))
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s235385246
Runtime Error
p03109
Input is given from Standard Input in the following format: S
#coding:utf-8 import sys BAMB_NUM = 0 BAMB_A = 0 BAMB_B = 0 BAMB_C = 0 BAMB_LIST = [] def calcMP(idx, lenA, lenB, lenC): # when classified all bamboos if (idx == BAMB_NUM): # exists a zero length bamboo if (lenA <= 0 or lenB <= 0 or lenC <= 0): return sys.maxsize return abs(lenA - BAMB_A) + abs(lenB - BAMB_B) + abs(lenc - BAMB_C) # don't use idx-th bamboo mp = calcMP(idx+1, lenA, lenB, lenC) # use idx-th bamboo mp = min(mp, calcMP(idx + 1, lenA + BAMB_LIST[idx], lenB, lenC) + (BAMB_A > 0 ? 10 : 0)) mp = min(mp, calcMP(idx + 1, lenA, lenB + BAMB_LIST[idx], lenC) + (BAMB_B > 0 ? 10 : 0)) mp = min(mp, calcMP(idx + 1, lenA, lenB, lenC + BAMB_LIST[idx]) + (BAMB_C > 0 ? 10 : 0)) return mp if __name__ == "__main__": """ http://drken1215.hatenablog.com/entry/2019/02/24/224100 """ # requested bamboo lengths bamb_num, bambA, bambB, bambC = map(lambda x: int(x), input().split()) # available bamboo lengths bamb_list = [] for bamb in range(bamb_num): bamb_list.append(int(input())) mp = calcMP(0, 0, 0, 0) print(mp)
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
Print `Heisei` if the date represented by S is not later than April 30, 2019, and print `TBD` otherwise. * * *
s780036220
Runtime Error
p03109
Input is given from Standard Input in the following format: S
# N A B C # l1 # l2 # ... (N, A, B, C) = (int(input().split()[i]) for i in range(4)) L = [] for i in range(N): l = int(input()) L.append(l) # N = 5 # A = 100 # B = 90 # C = 80 # L = [98, 40, 30, 21, 80] def recur_function(a, b, c, n): if n == N: return abs(a - A) + abs(b - B) + abs(c - C) if min(a, b, c) > 0 else 10**9 ret0 = ( recur_function(a + L[n], b, c, n + 1) + 10 if a > 0 else recur_function(a + L[n], b, c, n + 1) ) ret1 = ( recur_function(a, b + L[n], c, n + 1) + 10 if b > 0 else recur_function(a, b + L[n], c, n + 1) ) ret2 = ( recur_function(a, b, c + L[n], n + 1) + 10 if c > 0 else recur_function(a, b, c + L[n], n + 1) ) ret3 = recur_function(a, b, c, n + 1) return min(ret0, ret1, ret2, ret3) print(recur_function(0, 0, 0, 0))
Statement You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.
[{"input": "2019/04/30", "output": "Heisei\n \n\n* * *"}, {"input": "2019/11/01", "output": "TBD"}]
In the first line, print the maximized flow by reversing some roads. In the second line, print the number R of the reversed roads. In each of the following R lines, print the ID number (1-based) of a reversed road. You may not print the same ID number more than once. If there are multiple answers which would give us the same flow capacity, you can print any of them.
s852477899
Wrong Answer
p01421
The first line of a data set contains two integers N (2 \leq N \leq 300) and M (0 \leq M \leq {\rm min} (1\,000,\ N(N-1)/2)). N is the number of crossings in the city and M is the number of roads. The following M lines describe one-way roads in the city. The i-th line (1-based) contains two integers X_i and Y_i (1 \leq X_i, Y_i \leq N, X_i \neq Y_i). X_i is the ID number (1-based) of the starting point of the i-th road and Y_i is that of the terminal point. The last line contains two integers S and T (1 \leq S, T \leq N, S \neq T, 1-based). The capacity of each road is 1. You can assume that i \neq j implies either X_i \neq X_j or Y_i \neq Y_j, and either X_i \neq Y_j or X_j \neq Y_i.
# AOJ 2304 Reverse Roads # Python3 2018.7.21 bal4u # ******************************************* # Dinic's Max Flow Algorithm # ******************************************* INF = 0x7FFFFFFF class Donic: def __init__(self, V): self.V = V self.level = [0] * V self.iter = [0] * V self.edge = [[] for i in range(V)] def add_edge(self, frm, to, cap): f, t = len(self.edge[frm]), len(self.edge[to]) self.edge[frm].append([to, cap, t]) self.edge[to].append([frm, cap, f]) def bfs(self, s): self.level = [-1] * self.V self.level[s] = 0 Q = [] Q.append(s) while Q: v = Q.pop() for to, cap, rev in self.edge[v]: if cap > 0 and self.level[to] < 0: self.level[to] = self.level[v] + 1 Q.append(to) def dfs(self, v, t, f): if v == t: return f k = self.iter[v] while k < len(self.edge[v]): to, cap, rev = self.edge[v][k] if cap > 0 and self.level[v] < self.level[to]: d = self.dfs(to, t, f if f <= cap else cap) if d > 0: self.edge[v][k][1] -= d self.edge[to][rev][1] += d return d self.iter[v] += 1 k += 1 return 0 def maxFlow(self, s, t): flow = 0 while True: self.bfs(s) if self.level[t] < 0: break self.iter = [0] * self.V while True: f = self.dfs(s, t, INF) if f <= 0: break flow += f return flow N, M = map(int, input().split()) dir = [[0 for j in range(N)] for i in range(N)] id = [[0 for j in range(N)] for i in range(N)] d = Donic(N) for i in range(M): x, y = map(int, input().split()) x, y = x - 1, y - 1 dir[y][x] = 1 id[y][x] = i + 1 d.add_edge(x, y, 1) S, T = map(int, input().split()) print(d.maxFlow(S - 1, T - 1)) ans = [] for i in range(N): for to, cap, rev in d.edge[i]: if cap < 1 and dir[i][to]: ans.append(id[i][to]) ans.sort() print(len(ans)) print(*ans, sep="\n")
Reverse Roads ICP city has an express company whose trucks run from the crossing S to the crossing T. The president of the company is feeling upset because all the roads in the city are one-way, and are severely congested. So, he planned to improve the maximum flow (edge disjoint paths) from the crossing S to the crossing T by reversing the traffic direction on some of the roads. Your task is writing a program to calculate the maximized flow from S to T by reversing some roads, and the list of the reversed roads.
[{"input": "2 1\n 2 1\n 2 1", "output": "1\n 0"}, {"input": "2 1\n 1 2\n 2 1", "output": "1\n 1\n 1"}, {"input": "3 3\n 3 2\n 1 2\n 3 1\n 1 3", "output": "2\n 2\n 1\n 3"}]
Print the number of ways to paint the string that satisfy the condition. * * *
s637730669
Accepted
p03298
Input is given from Standard Input in the following format: N S
import sys import socket if socket.gethostname() in ["N551J", "F551C"]: sys.stdin = open("c1.in") def read_int_list(): return list(map(int, input().split())) def read_int(): return int(input()) def read_str_list(): return input().split() def read_str(): return input() def solve(): n = read_int() s = read_str() # 同じ文字が連続する場合、redとblueに振り分ける順番が変わってもそのあとの判定に影響を与えないので、計算結果をcasheに格納して同一計算を省略する cache = {} # 1文字ずつredとblueに振り分けながら再帰的に関数読み出しを繰り返し、条件を満たしながらredとblue双方の長さが2nになったものの数を数える # 探索数は基本的に2のn乗でスケールするが、条件に当てはまらないような塗分けは排除しながら進んでいく(再帰読み出しを行わず戻り値0を返す) def rec(red, blue): # 一度探索したことのある文字列は即答する if (red, blue) in cache: return cache[(red, blue)] nr = len(red) nb = len(blue) # redとblueのどちらかが長さnを超えていたら関数は0を返す if nr > n or nb > n: res = 0 cache[(red, blue)] = res return res # 長さの合計がちょうど2nなら(上記と合わせると、両方の長さがnずつならば関数は1を返す) if nr + nb == 2 * n: res = 1 cache[(red, blue)] = res return res c = s[nr + nb] res = 0 # 文字列sの一番左の文字から始め、1文字ずつredの左側もしくはblueの右側に格納していく # nr+nbがn未満の場合無条件で再帰的関数読み出しを行う # nr+nbがnを超えた場合、新しく追加する文字cがこれまでのred, blueと整合性が取れている場合のみに再帰的関数読み出しを行う if nr + nb < n or (nr < n and c == blue[nr - n]): res += rec(red + c, blue) if nr + nb < n or (nb < n and c == red[n - 1 - nb]): res += rec(red, c + blue) cache[(red, blue)] = res return res res2 = rec("", "") return res2 def main(): res = solve() print(res) if __name__ == "__main__": main()
Statement You are given a string S of length 2N consisting of lowercase English letters. There are 2^{2N} ways to color each character in S red or blue. Among these ways, how many satisfy the following condition? * The string obtained by reading the characters painted red **from left to right** is equal to the string obtained by reading the characters painted blue **from right to left**.
[{"input": "4\n cabaacba", "output": "4\n \n\nThere are four ways to paint the string, as follows:\n\n * cabaacba\n * cabaacba\n * cabaacba\n * cabaacba\n\n* * *"}, {"input": "11\n mippiisssisssiipsspiim", "output": "504\n \n\n* * *"}, {"input": "4\n abcdefgh", "output": "0\n \n\n* * *"}, {"input": "18\n aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "output": "9075135300\n \n\nThe answer may not be representable as a 32-bit integer."}]
Print the number of ways to paint the string that satisfy the condition. * * *
s223836370
Runtime Error
p03298
Input is given from Standard Input in the following format: N S
N = int(input()) S = input() S_l = S[:N] S_r = S[N:][::-1] dict_l = {} dict_r = {} ans = 0 for num in range(2**N): tmpl_1 = "" tmpl_2 = "" tmpr_1 = "" tmpr_2 = "" for n in range(N): if num >> (N - 1 - n) & 1: tmpl_1 += S_l[n] tmpr_1 += S_r[n] else: tmpl_2 += S_l[n] tmpr_2 += S_r[n] dict_l[[tmpl_1, tmpl_2]] = dict_l.get([tmpl_1, tmpl_2], 0) + 1 dict_r[[tmpr_1, tmpr_2]] = dict_r.get([tmpr_1, tmpr_2], 0) + 1 for k, v in dict_l.items(): ans += v * dict_r.get(k, 0) print(ans)
Statement You are given a string S of length 2N consisting of lowercase English letters. There are 2^{2N} ways to color each character in S red or blue. Among these ways, how many satisfy the following condition? * The string obtained by reading the characters painted red **from left to right** is equal to the string obtained by reading the characters painted blue **from right to left**.
[{"input": "4\n cabaacba", "output": "4\n \n\nThere are four ways to paint the string, as follows:\n\n * cabaacba\n * cabaacba\n * cabaacba\n * cabaacba\n\n* * *"}, {"input": "11\n mippiisssisssiipsspiim", "output": "504\n \n\n* * *"}, {"input": "4\n abcdefgh", "output": "0\n \n\n* * *"}, {"input": "18\n aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "output": "9075135300\n \n\nThe answer may not be representable as a 32-bit integer."}]
Print the number of ways to paint the string that satisfy the condition. * * *
s876091523
Runtime Error
p03298
Input is given from Standard Input in the following format: N S
18 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Statement You are given a string S of length 2N consisting of lowercase English letters. There are 2^{2N} ways to color each character in S red or blue. Among these ways, how many satisfy the following condition? * The string obtained by reading the characters painted red **from left to right** is equal to the string obtained by reading the characters painted blue **from right to left**.
[{"input": "4\n cabaacba", "output": "4\n \n\nThere are four ways to paint the string, as follows:\n\n * cabaacba\n * cabaacba\n * cabaacba\n * cabaacba\n\n* * *"}, {"input": "11\n mippiisssisssiipsspiim", "output": "504\n \n\n* * *"}, {"input": "4\n abcdefgh", "output": "0\n \n\n* * *"}, {"input": "18\n aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "output": "9075135300\n \n\nThe answer may not be representable as a 32-bit integer."}]
Print the number of ways to paint the string that satisfy the condition. * * *
s062390068
Runtime Error
p03298
Input is given from Standard Input in the following format: N S
#include <map> #include <set> #include <list> #include <cmath> #include <queue> #include <stack> #include <cstdio> #include <string> #include <vector> #include <complex> #include <cstdlib> #include <cstring> #include <numeric> #include <sstream> #include <iostream> #include <algorithm> #include <functional> #define mp make_pair #define pb push_back #define all(x) (x).begin(),(x).end() #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<bool> vb; typedef vector<int> vi; typedef vector<vb> vvb; typedef vector<vi> vvi; typedef pair<int,int> pii; const int INF=1<<29; const double EPS=1e-9; const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1}; int dp[50][50]; ll comb(ll n, ll r) { if (dp[n][r]) return dp[n][r]; if (n == r) return dp[n][r] = 1; if (r == 0) return dp[n][r] = n; return dp[n][r] = comb(n - 1, r - 1) + comb(n - 1, r); } int main() { int N; cin >> N; string S; cin >> S; string s1 = S.substr(0, N); string s2 = S.substr(N); map<pair<string,string>, ll> cnt; for(int i = 0; i < 1 << N; i++) { string red = ""; string blue = ""; for(int j = 0; j < N; j++) { if (i >> j & 1) { red += s2[j]; } else { blue += s2[j]; } } string red_rev = red, blue_rev = blue; reverse(red_rev.begin(), red_rev.end()); reverse(blue_rev.begin(), blue_rev.end()); cnt[mp(red_rev, blue_rev)]++; } ll ans = 0; for (int i = 0; i < 1 << N; i++) { string red = ""; string blue = ""; for(int j = 0; j < N; j++) { if (i >> j & 1) { red += s1[j]; } else { blue += s1[j]; } } ans += cnt[mp(red, blue)]; } cout << ans << endl; return 0; }
Statement You are given a string S of length 2N consisting of lowercase English letters. There are 2^{2N} ways to color each character in S red or blue. Among these ways, how many satisfy the following condition? * The string obtained by reading the characters painted red **from left to right** is equal to the string obtained by reading the characters painted blue **from right to left**.
[{"input": "4\n cabaacba", "output": "4\n \n\nThere are four ways to paint the string, as follows:\n\n * cabaacba\n * cabaacba\n * cabaacba\n * cabaacba\n\n* * *"}, {"input": "11\n mippiisssisssiipsspiim", "output": "504\n \n\n* * *"}, {"input": "4\n abcdefgh", "output": "0\n \n\n* * *"}, {"input": "18\n aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "output": "9075135300\n \n\nThe answer may not be representable as a 32-bit integer."}]
Print the number of ways to paint the string that satisfy the condition. * * *
s241022154
Accepted
p03298
Input is given from Standard Input in the following format: N S
import sys, bisect, string, math, time, functools, random, fractions from heapq import heappush, heappop, heapify from collections import deque, defaultdict, Counter from itertools import permutations, combinations, groupby rep = range R = range def Golf(): n, *t = map(int, open(0).read().split()) def I(): return int(input()) def S_(): return input() def IS(): return input().split() def LS(): return [i for i in input().split()] def MI(): return map(int, input().split()) def LI(): return [int(i) for i in input().split()] def LI_(): return [int(i) - 1 for i in input().split()] def NI(n): return [int(input()) for i in range(n)] def NI_(n): return [int(input()) - 1 for i in range(n)] def NLI(n): return [[int(i) for i in input().split()] for i in range(n)] def NLI_(n): return [[int(i) - 1 for i in input().split()] for i in range(n)] def StoLI(): return [ord(i) - 97 for i in input()] def ItoS(n): return chr(n + 97) def LtoS(ls): return "".join([chr(i + 97) for i in ls]) def RA(): return map(int, open(0).read().split()) def RLI(n=8, a=1, b=10): return [random.randint(a, b) for i in range(n)] def RI(a=1, b=10): return random.randint(a, b) def Rtest(T): case, err = 0, 0 for i in range(T): inp = INP() a1, ls = naive(*inp) a2 = solve(*inp) if a1 != a2: print((a1, a2), inp) err += 1 case += 1 print("Tested", case, "case with", err, "errors") def GI(V, E, ls=None, Directed=False, index=1): org_inp = [] g = [[] for i in range(V)] FromStdin = True if ls == None else False for i in range(E): if FromStdin: inp = LI() org_inp.append(inp) else: inp = ls[i] if len(inp) == 2: a, b = inp c = 1 else: a, b, c = inp if index == 1: a -= 1 b -= 1 aa = (a, c) bb = (b, c) g[a].append(bb) if not Directed: g[b].append(aa) return g, org_inp def GGI( h, w, search=None, replacement_of_found=".", mp_def={"#": 1, ".": 0}, boundary=1 ): # h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0},boundary=1) # sample usage mp = [boundary] * (w + 2) found = {} for i in R(h): s = input() for char in search: if char in s: found[char] = (i + 1) * (w + 2) + s.index(char) + 1 mp_def[char] = mp_def[replacement_of_found] mp += [boundary] + [mp_def[j] for j in s] + [boundary] mp += [boundary] * (w + 2) return h + 2, w + 2, mp, found def TI(n): return GI(n, n - 1) def accum(ls): rt = [0] for i in ls: rt += [rt[-1] + i] return rt def bit_combination(n, base=2): rt = [] for tb in R(base**n): s = [tb // (base**bt) % base for bt in R(n)] rt += [s] return rt def gcd(x, y): if y == 0: return x if x % y == 0: return y while x % y != 0: x, y = y, x % y return y def YN(x): print(["NO", "YES"][x]) def Yn(x): print(["No", "Yes"][x]) def show(*inp, end="\n"): if show_flg: print(*inp, end=end) mo = 10**9 + 7 # mo=998244353 inf = float("inf") FourNb = [(-1, 0), (1, 0), (0, 1), (0, -1)] EightNb = [(-1, 0), (1, 0), (0, 1), (0, -1), (1, 1), (-1, -1), (1, -1), (-1, 1)] compas = dict(zip("WENS", FourNb)) cursol = dict(zip("LRUD", FourNb)) l_alp = string.ascii_lowercase # sys.setrecursionlimit(10**9) read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline input = lambda: sys.stdin.readline().rstrip() show_flg = False show_flg = True ans = 0 n = I() s = input() a = s[:n] b = s[n:][::-1] def coloring(x): N = 1 << n dc = defaultdict(int) for i in range(N): r = "" b = "" for j in range(n): if i >> j & 1: r += x[j] else: b += x[j] dc[r + "-" + b] += 1 return dc fd = coloring(a) ld = coloring(b) for i, j in fd.items(): ans += ld[i] * j print(ans)
Statement You are given a string S of length 2N consisting of lowercase English letters. There are 2^{2N} ways to color each character in S red or blue. Among these ways, how many satisfy the following condition? * The string obtained by reading the characters painted red **from left to right** is equal to the string obtained by reading the characters painted blue **from right to left**.
[{"input": "4\n cabaacba", "output": "4\n \n\nThere are four ways to paint the string, as follows:\n\n * cabaacba\n * cabaacba\n * cabaacba\n * cabaacba\n\n* * *"}, {"input": "11\n mippiisssisssiipsspiim", "output": "504\n \n\n* * *"}, {"input": "4\n abcdefgh", "output": "0\n \n\n* * *"}, {"input": "18\n aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "output": "9075135300\n \n\nThe answer may not be representable as a 32-bit integer."}]
Print the number of ways to paint the string that satisfy the condition. * * *
s789383022
Accepted
p03298
Input is given from Standard Input in the following format: N S
n = int(input()) s = input() s1 = s[:n] s2 = s[n:][::-1] dic1 = {} dic2 = {} for i in range(2**n): r1 = "" r2 = "" b1 = "" b2 = "" flag = format(i, "b") l = len(flag) if l != n: flag = "0" * (n - l) + flag for j in range(n): if flag[j] == "0": r1 += s1[j] r2 += s2[j] else: b1 += s1[j] b2 += s2[j] if (r1, b1) not in dic1: dic1[(r1, b1)] = 1 else: dic1[(r1, b1)] += 1 if (r2, b2) not in dic2: dic2[(r2, b2)] = 1 else: dic2[(r2, b2)] += 1 ans = 0 for i in dic1.keys(): if i in dic2: ans += dic1[i] * dic2[i] print(ans)
Statement You are given a string S of length 2N consisting of lowercase English letters. There are 2^{2N} ways to color each character in S red or blue. Among these ways, how many satisfy the following condition? * The string obtained by reading the characters painted red **from left to right** is equal to the string obtained by reading the characters painted blue **from right to left**.
[{"input": "4\n cabaacba", "output": "4\n \n\nThere are four ways to paint the string, as follows:\n\n * cabaacba\n * cabaacba\n * cabaacba\n * cabaacba\n\n* * *"}, {"input": "11\n mippiisssisssiipsspiim", "output": "504\n \n\n* * *"}, {"input": "4\n abcdefgh", "output": "0\n \n\n* * *"}, {"input": "18\n aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "output": "9075135300\n \n\nThe answer may not be representable as a 32-bit integer."}]
Print the number of ways to paint the string that satisfy the condition. * * *
s812874752
Wrong Answer
p03298
Input is given from Standard Input in the following format: N S
N = int(input()) S = list(input()) def find(A, B, lst): q = (B, A) l, r = 0, len(lst) while r - l > 1: nxt = (l + r) // 2 print(l, r, nxt, lst[nxt], q) if lst[nxt] < q: l = nxt else: r = nxt print(lst[l], q) if lst[l] >= q: return l else: return r MAX = 2**N ans = 0 first = [S[i] for i in range(N)] last = [S[i] for i in range(N, 2 * N)] search = [] lasts = [[] for i in range(N + 1)] for i in range(MAX): paint = [False for i in range(N)] n = i c = 0 while n > 0: paint[c] = n % 2 == 1 c += 1 n = n // 2 A = "".join([first[i] for i in range(N) if paint[i]]) B = "".join([first[N - i] for i in range(1, N + 1) if not paint[N - i]]) search.append((A, B)) cnt = sum([1 if p else 0 for p in paint]) A = "".join([last[i] for i in range(N) if paint[i]]) B = "".join([last[N - i] for i in range(1, N + 1) if not paint[N - i]]) lasts[cnt].append((A, B)) for i in range(N): lasts[i].sort() for A, B in search: len_B = len(B) if len_B > 0 and len_B < N: a = list(A) a[len(a) - 1] = chr(ord(a[len(a) - 1]) + 1) A2 = "".join(a) i1 = find(A, B, lasts[len_B]) i2 = find(A2, B, lasts[len_B]) print(B, A, A2, lasts[len_B], i2, i1) ans += i2 - i1 elif (B, A) == lasts[len_B][0]: ans += 1 print(ans)
Statement You are given a string S of length 2N consisting of lowercase English letters. There are 2^{2N} ways to color each character in S red or blue. Among these ways, how many satisfy the following condition? * The string obtained by reading the characters painted red **from left to right** is equal to the string obtained by reading the characters painted blue **from right to left**.
[{"input": "4\n cabaacba", "output": "4\n \n\nThere are four ways to paint the string, as follows:\n\n * cabaacba\n * cabaacba\n * cabaacba\n * cabaacba\n\n* * *"}, {"input": "11\n mippiisssisssiipsspiim", "output": "504\n \n\n* * *"}, {"input": "4\n abcdefgh", "output": "0\n \n\n* * *"}, {"input": "18\n aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "output": "9075135300\n \n\nThe answer may not be representable as a 32-bit integer."}]
Print the total area of the rectangles, modulo 10^9+7. * * *
s347255809
Wrong Answer
p03762
Input is given from Standard Input in the following format: n m x_1 x_2 ... x_n y_1 y_2 ... y_m
import sys import math import fractions import bisect import queue import heapq import collections import itertools sys.setrecursionlimit(4100000) MOD = int(1e9 + 7) PI = 3.14159265358979323846264338327950288 INF = 1e18 """ 1行のint===================================== N, K = map(int, input().split()) N, M = map(int, input().split()) A, B = map(int, input().split()) H, W = map(int, input().split()) L, R = map(int, input().split()) 1行のstring================================= S, T = input().split() 1行の整数配列================================ P = list(map(int,input().split())) A = list(map(int,input().split())) B = list(map(int,input().split())) C = list(map(int,input().split())) D = list(map(int,input().split())) L = list(map(int,input().split())) R = list(map(int,input().split())) T = list(map(int,input().split())) 改行あり整数================================== X = [] Y = [] for i in range(N): x1,y1=[int(i) for i in input().split()] X.append(x1) Y.append(y1) A = [] for i in range(N): a=int(input()) A.append(a) Pair = [] for i in range(N): x1,y1=[int(i) for i in input().split()] Pair.append((x1, y1)) 2次元整数配列===================================== A = [] for i in range(N): tmp = list(map(int,input().split())) A.append(tmp) N行M列の初期化==================================== dp = [[VAL] * RETU for i in range(GYO)] """ N, M = map(int, input().split()) X = list(map(int, input().split())) Y = list(map(int, input().split())) DX = [X[i + 1] - X[i] for i in range(N - 1)] DY = [Y[i + 1] - Y[i] for i in range(M - 1)] N -= 1 M -= 1 countX = [(i + 1) * (N - i) for i in range(N)] countY = [(i + 1) * (N - i) for i in range(M)] local = 0 for i in range(M): local += countY[i] * DY[i] local *= DX[0] * countX[0] ans = local % MOD for i in range(1, N): local = local * countX[i] * DX[i] / countX[i - 1] / DX[i - 1] ans += local ans = int(ans) ans %= MOD print(int(ans))
Statement On a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis. Among the lines parallel to the x axis, the i-th from the bottom is represented by y = y_i. Similarly, among the lines parallel to the y axis, the i-th from the left is represented by x = x_i. For every rectangle that is formed by these lines, find its area, and print the total area modulo 10^9+7. That is, for every quadruple (i,j,k,l) satisfying 1\leq i < j\leq n and 1\leq k < l\leq m, find the area of the rectangle formed by the lines x=x_i, x=x_j, y=y_k and y=y_l, and print the sum of these areas modulo 10^9+7.
[{"input": "3 3\n 1 3 4\n 1 3 6", "output": "60\n \n\nThe following figure illustrates this input:\n\n![sample1-1](https://atcoder.jp/img/arc071/aec4d5cc2e5c73dbee455be237a649a5.png)\n\nThe total area of the nine rectangles A, B, ..., I shown in the following\nfigure, is 60.\n\n![sample1-2](https://atcoder.jp/img/arc071/f0771c0f7e68af2b00e7513186f585ff.png)\n\n* * *"}, {"input": "6 5\n -790013317 -192321079 95834122 418379342 586260100 802780784\n -253230108 193944314 363756450 712662868 735867677", "output": "835067060"}]
Print the total area of the rectangles, modulo 10^9+7. * * *
s854459020
Accepted
p03762
Input is given from Standard Input in the following format: n m x_1 x_2 ... x_n y_1 y_2 ... y_m
def getN(): return int(input()) def getNM(): return map(int, input().split()) def getList(): return list(map(int, input().split())) def getArray(intn): return [int(input()) for i in range(intn)] def input(): return sys.stdin.readline().rstrip() def rand_N(ran1, ran2): return random.randint(ran1, ran2) def rand_List(ran1, ran2, rantime): return [random.randint(ran1, ran2) for i in range(rantime)] def rand_ints_nodup(ran1, ran2, rantime): ns = [] while len(ns) < rantime: n = random.randint(ran1, ran2) if not n in ns: ns.append(n) return sorted(ns) def rand_query(ran1, ran2, rantime): r_query = [] while len(r_query) < rantime: n_q = rand_ints_nodup(ran1, ran2, 2) if not n_q in r_query: r_query.append(n_q) return sorted(r_query) from collections import defaultdict, deque, Counter from sys import exit from decimal import * import heapq from math import sqrt, pi from fractions import gcd import random import string import copy from itertools import combinations, permutations, product from operator import mul, itemgetter from functools import reduce from bisect import bisect_left, bisect_right import sys sys.setrecursionlimit(1000000000) mod = 10**9 + 7 ############# # Main Code # ############# N, M = getNM() X = getList() Y = getList() X.sort(reverse=True) Y.sort(reverse=True) XP, YP = 0, 0 for i in range(N): XP += (N - 1 - i * 2) * X[i] XP %= mod for i in range(M): YP += (M - 1 - i * 2) * Y[i] YP %= mod print((XP * YP) % mod)
Statement On a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis. Among the lines parallel to the x axis, the i-th from the bottom is represented by y = y_i. Similarly, among the lines parallel to the y axis, the i-th from the left is represented by x = x_i. For every rectangle that is formed by these lines, find its area, and print the total area modulo 10^9+7. That is, for every quadruple (i,j,k,l) satisfying 1\leq i < j\leq n and 1\leq k < l\leq m, find the area of the rectangle formed by the lines x=x_i, x=x_j, y=y_k and y=y_l, and print the sum of these areas modulo 10^9+7.
[{"input": "3 3\n 1 3 4\n 1 3 6", "output": "60\n \n\nThe following figure illustrates this input:\n\n![sample1-1](https://atcoder.jp/img/arc071/aec4d5cc2e5c73dbee455be237a649a5.png)\n\nThe total area of the nine rectangles A, B, ..., I shown in the following\nfigure, is 60.\n\n![sample1-2](https://atcoder.jp/img/arc071/f0771c0f7e68af2b00e7513186f585ff.png)\n\n* * *"}, {"input": "6 5\n -790013317 -192321079 95834122 418379342 586260100 802780784\n -253230108 193944314 363756450 712662868 735867677", "output": "835067060"}]
Print the total area of the rectangles, modulo 10^9+7. * * *
s133418917
Accepted
p03762
Input is given from Standard Input in the following format: n m x_1 x_2 ... x_n y_1 y_2 ... y_m
a, b = map(int, input().split()) x = list(map(int, input().split())) y = list(map(int, input().split())) s = 0 k = 0 for i, t in enumerate(reversed(x)): s += (a - i - 1) * t s -= i * t for i, t in enumerate(reversed(y)): k += (b - i - 1) * t k -= i * t print((s * k) % (10**9 + 7))
Statement On a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis. Among the lines parallel to the x axis, the i-th from the bottom is represented by y = y_i. Similarly, among the lines parallel to the y axis, the i-th from the left is represented by x = x_i. For every rectangle that is formed by these lines, find its area, and print the total area modulo 10^9+7. That is, for every quadruple (i,j,k,l) satisfying 1\leq i < j\leq n and 1\leq k < l\leq m, find the area of the rectangle formed by the lines x=x_i, x=x_j, y=y_k and y=y_l, and print the sum of these areas modulo 10^9+7.
[{"input": "3 3\n 1 3 4\n 1 3 6", "output": "60\n \n\nThe following figure illustrates this input:\n\n![sample1-1](https://atcoder.jp/img/arc071/aec4d5cc2e5c73dbee455be237a649a5.png)\n\nThe total area of the nine rectangles A, B, ..., I shown in the following\nfigure, is 60.\n\n![sample1-2](https://atcoder.jp/img/arc071/f0771c0f7e68af2b00e7513186f585ff.png)\n\n* * *"}, {"input": "6 5\n -790013317 -192321079 95834122 418379342 586260100 802780784\n -253230108 193944314 363756450 712662868 735867677", "output": "835067060"}]
Print the total area of the rectangles, modulo 10^9+7. * * *
s745432822
Accepted
p03762
Input is given from Standard Input in the following format: n m x_1 x_2 ... x_n y_1 y_2 ... y_m
import sys # sys.stdin = open('d1.in') def read_int_list(): return list(map(int, input().split())) def read_str_list(): return input().split() def read_int(): return int(input()) def read_str(): return input() n, m = read_int_list() x = read_int_list() y = read_int_list() def compute_sum(q, a): return sum([(2 * p - q - 1) * a[p - 1] for p in range(1, q + 1)]) M = 10**9 + 7 s = compute_sum(n, x) t = compute_sum(m, y) res = s * t % M print(res)
Statement On a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis. Among the lines parallel to the x axis, the i-th from the bottom is represented by y = y_i. Similarly, among the lines parallel to the y axis, the i-th from the left is represented by x = x_i. For every rectangle that is formed by these lines, find its area, and print the total area modulo 10^9+7. That is, for every quadruple (i,j,k,l) satisfying 1\leq i < j\leq n and 1\leq k < l\leq m, find the area of the rectangle formed by the lines x=x_i, x=x_j, y=y_k and y=y_l, and print the sum of these areas modulo 10^9+7.
[{"input": "3 3\n 1 3 4\n 1 3 6", "output": "60\n \n\nThe following figure illustrates this input:\n\n![sample1-1](https://atcoder.jp/img/arc071/aec4d5cc2e5c73dbee455be237a649a5.png)\n\nThe total area of the nine rectangles A, B, ..., I shown in the following\nfigure, is 60.\n\n![sample1-2](https://atcoder.jp/img/arc071/f0771c0f7e68af2b00e7513186f585ff.png)\n\n* * *"}, {"input": "6 5\n -790013317 -192321079 95834122 418379342 586260100 802780784\n -253230108 193944314 363756450 712662868 735867677", "output": "835067060"}]
Print the total area of the rectangles, modulo 10^9+7. * * *
s611919767
Runtime Error
p03762
Input is given from Standard Input in the following format: n m x_1 x_2 ... x_n y_1 y_2 ... y_m
n, m = map(int, input().split(" ")); xs = list(map(int, input().split(" "))); ys = list(map(int, input().split(" "))); modula=1000000007 sumx=0; sumy=0; answer=0; for i in range(0, n-1): for j in range(i+1, n): for k in range(0, m-1): for l in range(k+1, m): answer = (((xs[j]-xs[i])%modula) * (ys[l]-ys[k])%modula)) % modula print(answer);
Statement On a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis. Among the lines parallel to the x axis, the i-th from the bottom is represented by y = y_i. Similarly, among the lines parallel to the y axis, the i-th from the left is represented by x = x_i. For every rectangle that is formed by these lines, find its area, and print the total area modulo 10^9+7. That is, for every quadruple (i,j,k,l) satisfying 1\leq i < j\leq n and 1\leq k < l\leq m, find the area of the rectangle formed by the lines x=x_i, x=x_j, y=y_k and y=y_l, and print the sum of these areas modulo 10^9+7.
[{"input": "3 3\n 1 3 4\n 1 3 6", "output": "60\n \n\nThe following figure illustrates this input:\n\n![sample1-1](https://atcoder.jp/img/arc071/aec4d5cc2e5c73dbee455be237a649a5.png)\n\nThe total area of the nine rectangles A, B, ..., I shown in the following\nfigure, is 60.\n\n![sample1-2](https://atcoder.jp/img/arc071/f0771c0f7e68af2b00e7513186f585ff.png)\n\n* * *"}, {"input": "6 5\n -790013317 -192321079 95834122 418379342 586260100 802780784\n -253230108 193944314 363756450 712662868 735867677", "output": "835067060"}]
Print the total area of the rectangles, modulo 10^9+7. * * *
s512149192
Runtime Error
p03762
Input is given from Standard Input in the following format: n m x_1 x_2 ... x_n y_1 y_2 ... y_m
n, m = map(int, input().split(" ")); xs = list(map(int, input().split(" "))); ys = list(map(int, input().split(" "))); modula=1000000007 sumx=0; sumy=0; answer=0; for i in range(0, n-1): for j in range(i+1, n): for i in range(0, m-1): for j in range(i+1, m): answer = (((xs[j]-xs[i])%modula) * (ys[j]-ys[i])%modula)) % modula print(answer);
Statement On a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis. Among the lines parallel to the x axis, the i-th from the bottom is represented by y = y_i. Similarly, among the lines parallel to the y axis, the i-th from the left is represented by x = x_i. For every rectangle that is formed by these lines, find its area, and print the total area modulo 10^9+7. That is, for every quadruple (i,j,k,l) satisfying 1\leq i < j\leq n and 1\leq k < l\leq m, find the area of the rectangle formed by the lines x=x_i, x=x_j, y=y_k and y=y_l, and print the sum of these areas modulo 10^9+7.
[{"input": "3 3\n 1 3 4\n 1 3 6", "output": "60\n \n\nThe following figure illustrates this input:\n\n![sample1-1](https://atcoder.jp/img/arc071/aec4d5cc2e5c73dbee455be237a649a5.png)\n\nThe total area of the nine rectangles A, B, ..., I shown in the following\nfigure, is 60.\n\n![sample1-2](https://atcoder.jp/img/arc071/f0771c0f7e68af2b00e7513186f585ff.png)\n\n* * *"}, {"input": "6 5\n -790013317 -192321079 95834122 418379342 586260100 802780784\n -253230108 193944314 363756450 712662868 735867677", "output": "835067060"}]
Print the total area of the rectangles, modulo 10^9+7. * * *
s684452904
Accepted
p03762
Input is given from Standard Input in the following format: n m x_1 x_2 ... x_n y_1 y_2 ... y_m
m, n = map(int, input().split()) X = list(map(int, input().split())) Y = list(map(int, input().split())) MOD = 1000000007 sum_x = 0 sum_y = 0 for k in range(m): sum_x += (2 * k + 1 - m) * X[k] sum_x %= MOD for l in range(n): sum_y += (2 * l + 1 - n) * Y[l] sum_y %= MOD Answer = (sum_x * sum_y) % MOD print(Answer)
Statement On a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis. Among the lines parallel to the x axis, the i-th from the bottom is represented by y = y_i. Similarly, among the lines parallel to the y axis, the i-th from the left is represented by x = x_i. For every rectangle that is formed by these lines, find its area, and print the total area modulo 10^9+7. That is, for every quadruple (i,j,k,l) satisfying 1\leq i < j\leq n and 1\leq k < l\leq m, find the area of the rectangle formed by the lines x=x_i, x=x_j, y=y_k and y=y_l, and print the sum of these areas modulo 10^9+7.
[{"input": "3 3\n 1 3 4\n 1 3 6", "output": "60\n \n\nThe following figure illustrates this input:\n\n![sample1-1](https://atcoder.jp/img/arc071/aec4d5cc2e5c73dbee455be237a649a5.png)\n\nThe total area of the nine rectangles A, B, ..., I shown in the following\nfigure, is 60.\n\n![sample1-2](https://atcoder.jp/img/arc071/f0771c0f7e68af2b00e7513186f585ff.png)\n\n* * *"}, {"input": "6 5\n -790013317 -192321079 95834122 418379342 586260100 802780784\n -253230108 193944314 363756450 712662868 735867677", "output": "835067060"}]
Print the total area of the rectangles, modulo 10^9+7. * * *
s887379185
Accepted
p03762
Input is given from Standard Input in the following format: n m x_1 x_2 ... x_n y_1 y_2 ... y_m
I = lambda: list(map(int, input().split())) I() F = lambda x: sum(j * (len(x) - 1 - 2 * i) for i, j in enumerate(x)) print(F(I()) * F(I()) % (10**9 + 7))
Statement On a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis. Among the lines parallel to the x axis, the i-th from the bottom is represented by y = y_i. Similarly, among the lines parallel to the y axis, the i-th from the left is represented by x = x_i. For every rectangle that is formed by these lines, find its area, and print the total area modulo 10^9+7. That is, for every quadruple (i,j,k,l) satisfying 1\leq i < j\leq n and 1\leq k < l\leq m, find the area of the rectangle formed by the lines x=x_i, x=x_j, y=y_k and y=y_l, and print the sum of these areas modulo 10^9+7.
[{"input": "3 3\n 1 3 4\n 1 3 6", "output": "60\n \n\nThe following figure illustrates this input:\n\n![sample1-1](https://atcoder.jp/img/arc071/aec4d5cc2e5c73dbee455be237a649a5.png)\n\nThe total area of the nine rectangles A, B, ..., I shown in the following\nfigure, is 60.\n\n![sample1-2](https://atcoder.jp/img/arc071/f0771c0f7e68af2b00e7513186f585ff.png)\n\n* * *"}, {"input": "6 5\n -790013317 -192321079 95834122 418379342 586260100 802780784\n -253230108 193944314 363756450 712662868 735867677", "output": "835067060"}]
Print the total area of the rectangles, modulo 10^9+7. * * *
s553694769
Wrong Answer
p03762
Input is given from Standard Input in the following format: n m x_1 x_2 ... x_n y_1 y_2 ... y_m
o = input() e = input() for i in range(min(len(o), len(e))): print("%s%s" % (o[i], e[i]), end="") if len(o) > len(e): print(o[-1])
Statement On a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis. Among the lines parallel to the x axis, the i-th from the bottom is represented by y = y_i. Similarly, among the lines parallel to the y axis, the i-th from the left is represented by x = x_i. For every rectangle that is formed by these lines, find its area, and print the total area modulo 10^9+7. That is, for every quadruple (i,j,k,l) satisfying 1\leq i < j\leq n and 1\leq k < l\leq m, find the area of the rectangle formed by the lines x=x_i, x=x_j, y=y_k and y=y_l, and print the sum of these areas modulo 10^9+7.
[{"input": "3 3\n 1 3 4\n 1 3 6", "output": "60\n \n\nThe following figure illustrates this input:\n\n![sample1-1](https://atcoder.jp/img/arc071/aec4d5cc2e5c73dbee455be237a649a5.png)\n\nThe total area of the nine rectangles A, B, ..., I shown in the following\nfigure, is 60.\n\n![sample1-2](https://atcoder.jp/img/arc071/f0771c0f7e68af2b00e7513186f585ff.png)\n\n* * *"}, {"input": "6 5\n -790013317 -192321079 95834122 418379342 586260100 802780784\n -253230108 193944314 363756450 712662868 735867677", "output": "835067060"}]
Print the total area of the rectangles, modulo 10^9+7. * * *
s895414213
Runtime Error
p03762
Input is given from Standard Input in the following format: n m x_1 x_2 ... x_n y_1 y_2 ... y_m
n = int(input()) - 1 a = sorted(list(input())) while n: c = input() a = [i for i in a if i in c] n -= 1 print("".join(a))
Statement On a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis. Among the lines parallel to the x axis, the i-th from the bottom is represented by y = y_i. Similarly, among the lines parallel to the y axis, the i-th from the left is represented by x = x_i. For every rectangle that is formed by these lines, find its area, and print the total area modulo 10^9+7. That is, for every quadruple (i,j,k,l) satisfying 1\leq i < j\leq n and 1\leq k < l\leq m, find the area of the rectangle formed by the lines x=x_i, x=x_j, y=y_k and y=y_l, and print the sum of these areas modulo 10^9+7.
[{"input": "3 3\n 1 3 4\n 1 3 6", "output": "60\n \n\nThe following figure illustrates this input:\n\n![sample1-1](https://atcoder.jp/img/arc071/aec4d5cc2e5c73dbee455be237a649a5.png)\n\nThe total area of the nine rectangles A, B, ..., I shown in the following\nfigure, is 60.\n\n![sample1-2](https://atcoder.jp/img/arc071/f0771c0f7e68af2b00e7513186f585ff.png)\n\n* * *"}, {"input": "6 5\n -790013317 -192321079 95834122 418379342 586260100 802780784\n -253230108 193944314 363756450 712662868 735867677", "output": "835067060"}]
Print the total area of the rectangles, modulo 10^9+7. * * *
s687512139
Runtime Error
p03762
Input is given from Standard Input in the following format: n m x_1 x_2 ... x_n y_1 y_2 ... y_m
num = input().split().int() print(num)
Statement On a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis. Among the lines parallel to the x axis, the i-th from the bottom is represented by y = y_i. Similarly, among the lines parallel to the y axis, the i-th from the left is represented by x = x_i. For every rectangle that is formed by these lines, find its area, and print the total area modulo 10^9+7. That is, for every quadruple (i,j,k,l) satisfying 1\leq i < j\leq n and 1\leq k < l\leq m, find the area of the rectangle formed by the lines x=x_i, x=x_j, y=y_k and y=y_l, and print the sum of these areas modulo 10^9+7.
[{"input": "3 3\n 1 3 4\n 1 3 6", "output": "60\n \n\nThe following figure illustrates this input:\n\n![sample1-1](https://atcoder.jp/img/arc071/aec4d5cc2e5c73dbee455be237a649a5.png)\n\nThe total area of the nine rectangles A, B, ..., I shown in the following\nfigure, is 60.\n\n![sample1-2](https://atcoder.jp/img/arc071/f0771c0f7e68af2b00e7513186f585ff.png)\n\n* * *"}, {"input": "6 5\n -790013317 -192321079 95834122 418379342 586260100 802780784\n -253230108 193944314 363756450 712662868 735867677", "output": "835067060"}]
Print the total area of the rectangles, modulo 10^9+7. * * *
s140765335
Runtime Error
p03762
Input is given from Standard Input in the following format: n m x_1 x_2 ... x_n y_1 y_2 ... y_m
in1 = list(input().split()) nx = in[0] ny = in[y] x = list(input().split()) y = list(input().split()) lx = sum([ x[i]*(2*i - x - 1) for i in range(nx) ]) ly = sum([ y[i]*(2*i - x - 1) for i in range(ny) ]) print(lx*ly%(10**9 + 7))
Statement On a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis. Among the lines parallel to the x axis, the i-th from the bottom is represented by y = y_i. Similarly, among the lines parallel to the y axis, the i-th from the left is represented by x = x_i. For every rectangle that is formed by these lines, find its area, and print the total area modulo 10^9+7. That is, for every quadruple (i,j,k,l) satisfying 1\leq i < j\leq n and 1\leq k < l\leq m, find the area of the rectangle formed by the lines x=x_i, x=x_j, y=y_k and y=y_l, and print the sum of these areas modulo 10^9+7.
[{"input": "3 3\n 1 3 4\n 1 3 6", "output": "60\n \n\nThe following figure illustrates this input:\n\n![sample1-1](https://atcoder.jp/img/arc071/aec4d5cc2e5c73dbee455be237a649a5.png)\n\nThe total area of the nine rectangles A, B, ..., I shown in the following\nfigure, is 60.\n\n![sample1-2](https://atcoder.jp/img/arc071/f0771c0f7e68af2b00e7513186f585ff.png)\n\n* * *"}, {"input": "6 5\n -790013317 -192321079 95834122 418379342 586260100 802780784\n -253230108 193944314 363756450 712662868 735867677", "output": "835067060"}]
Print the total area of the rectangles, modulo 10^9+7. * * *
s761501614
Accepted
p03762
Input is given from Standard Input in the following format: n m x_1 x_2 ... x_n y_1 y_2 ... y_m
# -*- coding: utf-8 -*- import sys from itertools import accumulate def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)] def ceil(x, y=1): return int(-(-x // y)) def INT(): return int(input()) def MAP(): return map(int, input().split()) def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)] def Yes(): print("Yes") def No(): print("No") def YES(): print("YES") def NO(): print("NO") sys.setrecursionlimit(10**9) INF = 10**18 MOD = 10**9 + 7 N, M = MAP() A = LIST() B = LIST() # データの持ち方を座標から区間長にして累積和 A2 = [] for i in range(N - 1): A2.append(A[i + 1] - A[i]) B2 = [] for i in range(M - 1): B2.append(B[i + 1] - B[i]) A2 = [0] + list(accumulate(A2)) B2 = [0] + list(accumulate(B2)) # 縦横独立に、累積和の全区間総和を取る lsm = rsm = 0 for i in range(N): lsm += A2[i] * (N - i - 1) rsm += A2[i] * i lsm %= MOD rsm %= MOD h = rsm - lsm lsm = rsm = 0 for i in range(M): lsm += B2[i] * (M - i - 1) rsm += B2[i] * i lsm %= MOD rsm %= MOD w = rsm - lsm ans = h * w % MOD print(ans)
Statement On a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis. Among the lines parallel to the x axis, the i-th from the bottom is represented by y = y_i. Similarly, among the lines parallel to the y axis, the i-th from the left is represented by x = x_i. For every rectangle that is formed by these lines, find its area, and print the total area modulo 10^9+7. That is, for every quadruple (i,j,k,l) satisfying 1\leq i < j\leq n and 1\leq k < l\leq m, find the area of the rectangle formed by the lines x=x_i, x=x_j, y=y_k and y=y_l, and print the sum of these areas modulo 10^9+7.
[{"input": "3 3\n 1 3 4\n 1 3 6", "output": "60\n \n\nThe following figure illustrates this input:\n\n![sample1-1](https://atcoder.jp/img/arc071/aec4d5cc2e5c73dbee455be237a649a5.png)\n\nThe total area of the nine rectangles A, B, ..., I shown in the following\nfigure, is 60.\n\n![sample1-2](https://atcoder.jp/img/arc071/f0771c0f7e68af2b00e7513186f585ff.png)\n\n* * *"}, {"input": "6 5\n -790013317 -192321079 95834122 418379342 586260100 802780784\n -253230108 193944314 363756450 712662868 735867677", "output": "835067060"}]
Print the total area of the rectangles, modulo 10^9+7. * * *
s375434213
Wrong Answer
p03762
Input is given from Standard Input in the following format: n m x_1 x_2 ... x_n y_1 y_2 ... y_m
# -*- coding: utf-8 -*- def list_n(): return [int(e) for e in input().split()] def list_s(): return [s for e in input().split()] def main(xs, ys): answer = 0 max_x = max(xs) max_y = max(ys) min_x = min(xs) min_y = min(ys) def one_fold(xs, x=False): if len(xs) == 2: if x: return [max_x - min_x] else: return [max_y - min_y] else: return [xs[i] - xs[i - 1] for i in range(1, len(xs))] xxs = one_fold(xs) yys = one_fold(ys) while True: if len(xxs) == 1 and len(yys) == 1: break for x in xxs: for y in yys: answer += x * y if len(xxs) > len(yys): xxs = one_fold(xxs, x=True) else: yys = one_fold(yys) answer += max_x * max_y return answer % (pow(10, 9) + 7) # print( # main( # [1, 3, 4], # [1, 3, 6] # ) # ) if __name__ == "__main__": n, m = list_n() xs = list_n() ys = list_n() print(main(xs, ys))
Statement On a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis. Among the lines parallel to the x axis, the i-th from the bottom is represented by y = y_i. Similarly, among the lines parallel to the y axis, the i-th from the left is represented by x = x_i. For every rectangle that is formed by these lines, find its area, and print the total area modulo 10^9+7. That is, for every quadruple (i,j,k,l) satisfying 1\leq i < j\leq n and 1\leq k < l\leq m, find the area of the rectangle formed by the lines x=x_i, x=x_j, y=y_k and y=y_l, and print the sum of these areas modulo 10^9+7.
[{"input": "3 3\n 1 3 4\n 1 3 6", "output": "60\n \n\nThe following figure illustrates this input:\n\n![sample1-1](https://atcoder.jp/img/arc071/aec4d5cc2e5c73dbee455be237a649a5.png)\n\nThe total area of the nine rectangles A, B, ..., I shown in the following\nfigure, is 60.\n\n![sample1-2](https://atcoder.jp/img/arc071/f0771c0f7e68af2b00e7513186f585ff.png)\n\n* * *"}, {"input": "6 5\n -790013317 -192321079 95834122 418379342 586260100 802780784\n -253230108 193944314 363756450 712662868 735867677", "output": "835067060"}]
Print the total area of the rectangles, modulo 10^9+7. * * *
s583553059
Accepted
p03762
Input is given from Standard Input in the following format: n m x_1 x_2 ... x_n y_1 y_2 ... y_m
class Mint: MOD = 1000000007 # Must be a prime CACHE_FACTORIALS = [1, 1] def __init__(self, v): if self.__isally(v): self.v = v.v % self.MOD else: self.v = v % self.MOD @property def inv(self): return Mint(self.__minv(self.v)) @classmethod def factorial(cls, v): for i in range(len(cls.CACHE_FACTORIALS), int(v) + 1): cls.CACHE_FACTORIALS.append(cls.CACHE_FACTORIALS[-1] * i % cls.MOD) return Mint(cls.CACHE_FACTORIALS[int(v)]) @classmethod def perm(cls, n, r): if n < r or r < 0: return 0 return cls.factorial(n) // cls.factorial(n - r) @classmethod def comb(cls, n, r): if n < r or r < 0: return 0 return cls.perm(n, r) // cls.factorial(r) @classmethod def __isally(cls, v) -> bool: return isinstance(v, cls) @classmethod def __minv(cls, v) -> int: return pow(v, cls.MOD - 2, cls.MOD) @classmethod def __mpow(cls, v, w) -> int: return pow(v, w, cls.MOD) def __str__(self): return str(self.v) __repr__ = __str__ def __int__(self): return self.v def __eq__(self, w): return self.v == w.v if self.__isally(w) else self.v == w def __add__(self, w): return Mint(self.v + w.v) if self.__isally(w) else Mint(self.v + w) __radd__ = __add__ def __sub__(self, w): return Mint(self.v - w.v) if self.__isally(w) else Mint(self.v - w) def __rsub__(self, u): return Mint(u.v - self.v) if self.__isally(u) else Mint(u - self.v) def __mul__(self, w): return Mint(self.v * w.v) if self.__isally(w) else Mint(self.v * w) __rmul__ = __mul__ def __floordiv__(self, w): return ( Mint(self.v * self.__minv(w.v)) if self.__isally(w) else Mint(self.v * self.__minv(w)) ) def __rfloordiv__(self, u): return ( Mint(u.v * self.__minv(self.v)) if self.__isally(u) else Mint(u * self.__minv(self.v)) ) def __pow__(self, w): return ( Mint(self.__mpow(self.v, w.v)) if self.__isally(w) else Mint(self.__mpow(self.v, w)) ) def __rpow__(self, u): return ( Mint(self.__mpow(u.v, self.v)) if self.__isally(u) else Mint(self.__mpow(u, self.v)) ) n, m = map(int, input().split()) x = [int(s) for s in input().split()] y = [int(s) for s in input().split()] dx = [x[i + 1] - x[i] for i in range(n - 1)] dy = [y[i + 1] - y[i] for i in range(m - 1)] dp = [Mint(0)] * n for i, d in enumerate(dx): dp[i + 1] = dp[i] + (i + 1) * d sx = sum(dp) dp = [Mint(0)] * m for i, d in enumerate(dy): dp[i + 1] = dp[i] + (i + 1) * d sy = sum(dp) print(sx * sy)
Statement On a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis. Among the lines parallel to the x axis, the i-th from the bottom is represented by y = y_i. Similarly, among the lines parallel to the y axis, the i-th from the left is represented by x = x_i. For every rectangle that is formed by these lines, find its area, and print the total area modulo 10^9+7. That is, for every quadruple (i,j,k,l) satisfying 1\leq i < j\leq n and 1\leq k < l\leq m, find the area of the rectangle formed by the lines x=x_i, x=x_j, y=y_k and y=y_l, and print the sum of these areas modulo 10^9+7.
[{"input": "3 3\n 1 3 4\n 1 3 6", "output": "60\n \n\nThe following figure illustrates this input:\n\n![sample1-1](https://atcoder.jp/img/arc071/aec4d5cc2e5c73dbee455be237a649a5.png)\n\nThe total area of the nine rectangles A, B, ..., I shown in the following\nfigure, is 60.\n\n![sample1-2](https://atcoder.jp/img/arc071/f0771c0f7e68af2b00e7513186f585ff.png)\n\n* * *"}, {"input": "6 5\n -790013317 -192321079 95834122 418379342 586260100 802780784\n -253230108 193944314 363756450 712662868 735867677", "output": "835067060"}]
Print the total area of the rectangles, modulo 10^9+7. * * *
s614631188
Accepted
p03762
Input is given from Standard Input in the following format: n m x_1 x_2 ... x_n y_1 y_2 ... y_m
#!/usr/bin/env python3 import sys # import time # import math # import numpy as np # import scipy.sparse.csgraph as cs # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall # import random # random, uniform, randint, randrange, shuffle, sample # import string # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits # import re # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s) # from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]). # from collections import deque # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate() # from collections import defaultdict # subclass of dict. defaultdict(facroty) # from collections import Counter # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter) # from datetime import date, datetime # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj # from datetime.datetime import strptime # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj # from datetime import timedelta # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available. # from copy import copy, deepcopy # use deepcopy to copy multi-dimentional matrix without reference # from functools import reduce # reduce(f, iter[, init]) # from functools import lru_cache # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed) # from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn). # from heapq import nlargest, nsmallest # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn). # from itertools import count, cycle, repeat # count(start[,step]), cycle(iter), repeat(elm[,n]) # from itertools import groupby # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])] # from itertools import starmap # starmap(pow, [[2,5], [3,2]]) returns [32, 9] # from itertools import product, permutations # product(iter, repeat=n), permutations(iter[,r]) # from itertools import combinations, combinations_with_replacement # from itertools import accumulate # accumulate(iter[, f]) # from operator import itemgetter # itemgetter(1), itemgetter('key') # from fractions import gcd # for Python 3.4 (previous contest @AtCoder) def main(): mod = 1000000007 # 10^9+7 inf = float("inf") # sys.float_info.max = 1.79...e+308 # inf = 2 ** 64 - 1 # (for fast JIT compile in PyPy) 1.84...e+19 sys.setrecursionlimit(10**6) # 1000 -> 1000000 def input(): return sys.stdin.readline().rstrip() def ii(): return int(input()) def mi(): return map(int, input().split()) def mi_0(): return map(lambda x: int(x) - 1, input().split()) def lmi(): return list(map(int, input().split())) def lmi_0(): return list(map(lambda x: int(x) - 1, input().split())) def li(): return list(input()) n, m = mi() X = lmi() Y = lmi() tmp = 0 for j in range(m - 1): tmp = (tmp + (j + 1) * (m - j - 1) * (Y[j + 1] - Y[j])) % mod ans = 0 for i in range(n - 1): ans = (ans + (i + 1) * (n - i - 1) * (X[i + 1] - X[i]) * tmp) % mod print(ans) if __name__ == "__main__": main()
Statement On a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis. Among the lines parallel to the x axis, the i-th from the bottom is represented by y = y_i. Similarly, among the lines parallel to the y axis, the i-th from the left is represented by x = x_i. For every rectangle that is formed by these lines, find its area, and print the total area modulo 10^9+7. That is, for every quadruple (i,j,k,l) satisfying 1\leq i < j\leq n and 1\leq k < l\leq m, find the area of the rectangle formed by the lines x=x_i, x=x_j, y=y_k and y=y_l, and print the sum of these areas modulo 10^9+7.
[{"input": "3 3\n 1 3 4\n 1 3 6", "output": "60\n \n\nThe following figure illustrates this input:\n\n![sample1-1](https://atcoder.jp/img/arc071/aec4d5cc2e5c73dbee455be237a649a5.png)\n\nThe total area of the nine rectangles A, B, ..., I shown in the following\nfigure, is 60.\n\n![sample1-2](https://atcoder.jp/img/arc071/f0771c0f7e68af2b00e7513186f585ff.png)\n\n* * *"}, {"input": "6 5\n -790013317 -192321079 95834122 418379342 586260100 802780784\n -253230108 193944314 363756450 712662868 735867677", "output": "835067060"}]
Print the total area of the rectangles, modulo 10^9+7. * * *
s761663212
Wrong Answer
p03762
Input is given from Standard Input in the following format: n m x_1 x_2 ... x_n y_1 y_2 ... y_m
# #    ⋀_⋀ #    (・ω・) # ./ U ∽ U\ # │* 合 *│ # │* 格 *│ # │* 祈 *│ # │* 願 *│ # │*   *│ #  ̄ # import sys sys.setrecursionlimit(10**6) input = sys.stdin.readline from math import floor, ceil, sqrt, factorial, hypot, log # log2ないyp from heapq import heappop, heappush, heappushpop from collections import Counter, defaultdict, deque from itertools import ( accumulate, permutations, combinations, product, combinations_with_replacement, ) from bisect import bisect_left, bisect_right from copy import deepcopy inf = float("inf") mod = 10**9 + 7 def pprint(*A): for a in A: print(*a, sep="\n") def INT_(n): return int(n) - 1 def MI(): return map(int, input().split()) def MF(): return map(float, input().split()) def MI_(): return map(INT_, input().split()) def LI(): return list(MI()) def LI_(): return [int(x) - 1 for x in input().split()] def LF(): return list(MF()) def LIN(n: int): return [I() for _ in range(n)] def LLIN(n: int): return [LI() for _ in range(n)] def LLIN_(n: int): return [LI_() for _ in range(n)] def LLI(): return [list(map(int, l.split())) for l in input()] def I(): return int(input()) def F(): return float(input()) def ST(): return input().replace("\n", "") # mint class ModInt: def __init__(self, x): self.x = x % mod def __str__(self): return str(self.x) __repr__ = __str__ def __add__(self, other): if isinstance(other, ModInt): return ModInt(self.x + other.x) else: return ModInt(self.x + other) __radd__ = __add__ def __sub__(self, other): if isinstance(other, ModInt): return ModInt(self.x - other.x) else: return ModInt(self.x - other) def __rsub__(self, other): if isinstance(other, ModInt): return ModInt(other.x - self.x) else: return ModInt(other - self.x) def __mul__(self, other): if isinstance(other, ModInt): return ModInt(self.x * other.x) else: return ModInt(self.x * other) __rmul__ = __mul__ def __truediv__(self, other): if isinstance(other, ModInt): return ModInt(self.x * pow(other.x, mod - 2, mod)) else: return ModInt(self.x * pow(other, mod - 2, mod)) def __rtruediv(self, other): if isinstance(other, self): return ModInt(other * pow(self.x, mod - 2, mod)) else: return ModInt(other.x * pow(self.x, mod - 2, mod)) def __pow__(self, other): if isinstance(other, ModInt): return ModInt(pow(self.x, other.x, mod)) else: return ModInt(pow(self.x, other, mod)) def __rpow__(self, other): if isinstance(other, ModInt): return ModInt(pow(other.x, self.x, mod)) else: return ModInt(pow(other, self.x, mod)) def main(): N, M = MI() X = LI() Y = LI() ans = ModInt(0) for i, x in enumerate(X[:-1]): for j, y in enumerate(Y[:-1]): s = (X[i + 1] - x) * (Y[j + 1] - y) print(s, (i + 1) * (N - (i + 1)) * (j + 1) * (M - (j + 1)) * s) ans += (i + 1) * (N - (i + 1)) * (j + 1) * (M - (j + 1)) * s print(ans) if __name__ == "__main__": main()
Statement On a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis. Among the lines parallel to the x axis, the i-th from the bottom is represented by y = y_i. Similarly, among the lines parallel to the y axis, the i-th from the left is represented by x = x_i. For every rectangle that is formed by these lines, find its area, and print the total area modulo 10^9+7. That is, for every quadruple (i,j,k,l) satisfying 1\leq i < j\leq n and 1\leq k < l\leq m, find the area of the rectangle formed by the lines x=x_i, x=x_j, y=y_k and y=y_l, and print the sum of these areas modulo 10^9+7.
[{"input": "3 3\n 1 3 4\n 1 3 6", "output": "60\n \n\nThe following figure illustrates this input:\n\n![sample1-1](https://atcoder.jp/img/arc071/aec4d5cc2e5c73dbee455be237a649a5.png)\n\nThe total area of the nine rectangles A, B, ..., I shown in the following\nfigure, is 60.\n\n![sample1-2](https://atcoder.jp/img/arc071/f0771c0f7e68af2b00e7513186f585ff.png)\n\n* * *"}, {"input": "6 5\n -790013317 -192321079 95834122 418379342 586260100 802780784\n -253230108 193944314 363756450 712662868 735867677", "output": "835067060"}]
Print the total area of the rectangles, modulo 10^9+7. * * *
s022040746
Wrong Answer
p03762
Input is given from Standard Input in the following format: n m x_1 x_2 ... x_n y_1 y_2 ... y_m
n, m = map(int, input().split()) x = sorted(list(map(int, input().split()))) y = sorted(list(map(int, input().split()))) total = 0 for l in range(len(y) - 1): for k in range(len(x) - 1): for i in range(1, len(x)): for j in range(1, len(y)): total += ((x[i] - x[k]) * (y[j] - y[l])) % 1000000007 total %= 1000000007 print(total % 1000000007)
Statement On a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis. Among the lines parallel to the x axis, the i-th from the bottom is represented by y = y_i. Similarly, among the lines parallel to the y axis, the i-th from the left is represented by x = x_i. For every rectangle that is formed by these lines, find its area, and print the total area modulo 10^9+7. That is, for every quadruple (i,j,k,l) satisfying 1\leq i < j\leq n and 1\leq k < l\leq m, find the area of the rectangle formed by the lines x=x_i, x=x_j, y=y_k and y=y_l, and print the sum of these areas modulo 10^9+7.
[{"input": "3 3\n 1 3 4\n 1 3 6", "output": "60\n \n\nThe following figure illustrates this input:\n\n![sample1-1](https://atcoder.jp/img/arc071/aec4d5cc2e5c73dbee455be237a649a5.png)\n\nThe total area of the nine rectangles A, B, ..., I shown in the following\nfigure, is 60.\n\n![sample1-2](https://atcoder.jp/img/arc071/f0771c0f7e68af2b00e7513186f585ff.png)\n\n* * *"}, {"input": "6 5\n -790013317 -192321079 95834122 418379342 586260100 802780784\n -253230108 193944314 363756450 712662868 735867677", "output": "835067060"}]
Print the number of the ways to paint tiles, modulo 998244353. * * *
s316188063
Accepted
p03332
Input is given from Standard Input in the following format: N A B K
# -*- coding: utf-8 -*- import bisect import heapq import math import random import sys from collections import Counter, defaultdict from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinations, combinations_with_replacement, product sys.setrecursionlimit(10000) MOD = 998244353 def mul_mod(a, b): return (a % MOD) * (b % MOD) % MOD def add_mod(a, b): return (a + b) % MOD def sub_mod(a, b): return (a - b) % MOD def read_int(): return int(input()) def read_int_n(): return list(map(int, input().split())) def read_float(): return float(input()) def read_float_n(): return list(map(float, input().split())) def read_str(): return input() def read_str_n(): return list(map(str, input().split())) def error_print(*args): print(*args, file=sys.stderr) def mt(f): import time def wrap(*args, **kwargs): s = time.time() ret = f(*args, **kwargs) e = time.time() error_print(e - s, "sec") return ret return wrap def prepare(n): f = 1 for m in range(1, n + 1): f *= m f %= MOD fn = f inv = pow(f, MOD - 2, MOD) invs = [1] * (n + 1) invs[n] = inv for m in range(n, 1, -1): inv *= m inv %= MOD invs[m - 1] = inv return fn, invs @mt def slv(N, A, B, K): ans = 0 FN, invs = prepare(N) for i in range(K // A + 1): if (K - i * A) % B == 0 and i <= N and (K - i * A) // B <= N: j = (K - i * A) // B error_print(i, j) ans = add_mod( ans, mul_mod( FN * invs[i] * invs[N - i] % MOD, FN * invs[j] * invs[N - j] % MOD ), ) return ans def main(): N, A, B, K = read_int_n() print(slv(N, A, B, K)) if __name__ == "__main__": main()
Statement Takahashi has a tower which is divided into N layers. Initially, all the layers are uncolored. Takahashi is going to paint some of the layers in red, green or blue to make a beautiful tower. He defines the _beauty of the tower_ as follows: * The beauty of the tower is the sum of the scores of the N layers, where the score of a layer is A if the layer is painted red, A+B if the layer is painted green, B if the layer is painted blue, and 0 if the layer is uncolored. Here, A and B are positive integer constants given beforehand. Also note that a layer may not be painted in two or more colors. Takahashi is planning to paint the tower so that the beauty of the tower becomes exactly K. How many such ways are there to paint the tower? Find the count modulo 998244353. Two ways to paint the tower are considered different when there exists a layer that is painted in different colors, or a layer that is painted in some color in one of the ways and not in the other.
[{"input": "4 1 2 5", "output": "40\n \n\nIn this case, a red layer worth 1 points, a green layer worth 3 points and the\nblue layer worth 2 points. The beauty of the tower is 5 when we have one of\nthe following sets of painted layers:\n\n * 1 green, 1 blue\n * 1 red, 2 blues\n * 2 reds, 1 green\n * 3 reds, 1 blue\n\nThe total number of the ways to produce them is 40.\n\n* * *"}, {"input": "2 5 6 0", "output": "1\n \n\nThe beauty of the tower is 0 only when all the layers are uncolored. Thus, the\nanswer is 1.\n\n* * *"}, {"input": "90081 33447 90629 6391049189", "output": "577742975"}]
Print the number of the ways to paint tiles, modulo 998244353. * * *
s523018227
Accepted
p03332
Input is given from Standard Input in the following format: N A B K
# -*- coding: utf-8 -*- import sys def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)] def ceil(x, y=1): return int(-(-x // y)) def INT(): return int(input()) def MAP(): return map(int, input().split()) def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)] def Yes(): print("Yes") def No(): print("No") def YES(): print("YES") def NO(): print("NO") sys.setrecursionlimit(10**9) INF = 10**18 MOD = 998244353 class ModTools: """階乗たくさん使う時用のテーブル準備""" def __init__(self, MAX, MOD): """MAX:階乗に使う数値の最大以上まで作る""" MAX += 1 self.MAX = MAX self.MOD = MOD # 階乗テーブル factorial = [1] * MAX factorial[0] = factorial[1] = 1 for i in range(2, MAX): factorial[i] = factorial[i - 1] * i % MOD # 階乗の逆元テーブル inverse = [1] * MAX # powに第三引数入れると冪乗のmod付計算を高速にやってくれる inverse[MAX - 1] = pow(factorial[MAX - 1], MOD - 2, MOD) for i in range(MAX - 2, 0, -1): # 最後から戻っていくこのループならMAX回powするより処理が速い inverse[i] = inverse[i + 1] * (i + 1) % MOD self.fact = factorial self.inv = inverse def nCr(self, n, r): """組み合わせの数 (必要な階乗と逆元のテーブルを事前に作っておく)""" if n < r: return 0 # 10C7 = 10C3 r = min(r, n - r) # 分子の計算 numerator = self.fact[n] # 分母の計算 denominator = self.inv[r] * self.inv[n - r] % self.MOD return numerator * denominator % self.MOD N, A, B, K = MAP() ans = 0 mt = ModTools(N, MOD) for x in range(N + 1): # 式変形:A * x + B * y = K → y = (K - A * x) / B y = (K - A * x) / B if y < 0 or not y.is_integer(): continue y = int(y) ans += mt.nCr(N, x) * mt.nCr(N, y) ans %= MOD print(ans)
Statement Takahashi has a tower which is divided into N layers. Initially, all the layers are uncolored. Takahashi is going to paint some of the layers in red, green or blue to make a beautiful tower. He defines the _beauty of the tower_ as follows: * The beauty of the tower is the sum of the scores of the N layers, where the score of a layer is A if the layer is painted red, A+B if the layer is painted green, B if the layer is painted blue, and 0 if the layer is uncolored. Here, A and B are positive integer constants given beforehand. Also note that a layer may not be painted in two or more colors. Takahashi is planning to paint the tower so that the beauty of the tower becomes exactly K. How many such ways are there to paint the tower? Find the count modulo 998244353. Two ways to paint the tower are considered different when there exists a layer that is painted in different colors, or a layer that is painted in some color in one of the ways and not in the other.
[{"input": "4 1 2 5", "output": "40\n \n\nIn this case, a red layer worth 1 points, a green layer worth 3 points and the\nblue layer worth 2 points. The beauty of the tower is 5 when we have one of\nthe following sets of painted layers:\n\n * 1 green, 1 blue\n * 1 red, 2 blues\n * 2 reds, 1 green\n * 3 reds, 1 blue\n\nThe total number of the ways to produce them is 40.\n\n* * *"}, {"input": "2 5 6 0", "output": "1\n \n\nThe beauty of the tower is 0 only when all the layers are uncolored. Thus, the\nanswer is 1.\n\n* * *"}, {"input": "90081 33447 90629 6391049189", "output": "577742975"}]
Print the number of the ways to paint tiles, modulo 998244353. * * *
s042608762
Accepted
p03332
Input is given from Standard Input in the following format: N A B K
###================================================== ### import # import bisect # from collections import Counter, deque, defaultdict # from copy import deepcopy # from functools import reduce, lru_cache # from heapq import heappush, heappop # import itertools # import math # import string import sys ### stdin def input(): return sys.stdin.readline() def iIn(): return int(input()) def iInM(): return map(int, input().split()) def iInM1(): return map(int1, input().split()) def iInLH(): return list(map(int, input().split())) def iInLH1(): return list(map(int1, input().split())) def iInLV(n): return [iIn() for _ in range(n)] def iInLV1(n): return [iIn() - 1 for _ in range(n)] def iInLD(n): return [iInLH() for _ in range(n)] def iInLD1(n): return [iInLH1() for _ in range(n)] def sInLH(): return list(input().split()) def sInLV(n): return [input().rstrip("\n") for _ in range(n)] def sInLD(n): return [sInLH() for _ in range(n)] ### stdout def OutH(lst): print(*lst) def OutV(lst): print(*lst, sep="\n") ### setting sys.setrecursionlimit(10**6) ### utils int1 = lambda x: int(x) - 1 ### constants INF = int(1e9) MOD = 1000000007 dx = (-1, 0, 1, 0) dy = (0, -1, 0, 1) ###--------------------------------------------------- ## factorial library ## ## begin library factorial here ## usage: fac = Factorial() ## usage: nCr = fac.comb(n, r) ## usage: nPr = fac.perm(n, r) class Factorial: def __init__(self, N): self.fact = [0] * (N + 1) self.fact_inv = [0] * (N + 1) self.calc_factorial(N) self.calc_inv_factorial(N) def calc_factorial(self, N): self.fact[0] = 1 for i in range(N): self.fact[i + 1] = self.fact[i] * (i + 1) % MOD def calc_inv_factorial(self, N): self.fact_inv[N] = pow(self.fact[N], MOD - 2, MOD) for i in range(N, 0, -1): self.fact_inv[i - 1] = self.fact_inv[i] * i % MOD def comb(self, n, r): if n < 0 or r < 0 or n < r: return 0 res = self.fact[n] res = res * self.fact_inv[r] % MOD res = res * self.fact_inv[n - r] % MOD return res def perm(self, n, r): if n < 0 or r < 0 or n < r: return 0 res = self.fact[n] res = res * self.fact_inv[r] % MOD return res MOD = 998244353 N, A, B, K = iInM() fac = Factorial(300000) ans = 0 for a in range(N + 1): if (K - A * a) % B == 0: b = (K - A * a) // B ans = (ans + fac.comb(N, a) * fac.comb(N, b)) % MOD else: continue print(ans)
Statement Takahashi has a tower which is divided into N layers. Initially, all the layers are uncolored. Takahashi is going to paint some of the layers in red, green or blue to make a beautiful tower. He defines the _beauty of the tower_ as follows: * The beauty of the tower is the sum of the scores of the N layers, where the score of a layer is A if the layer is painted red, A+B if the layer is painted green, B if the layer is painted blue, and 0 if the layer is uncolored. Here, A and B are positive integer constants given beforehand. Also note that a layer may not be painted in two or more colors. Takahashi is planning to paint the tower so that the beauty of the tower becomes exactly K. How many such ways are there to paint the tower? Find the count modulo 998244353. Two ways to paint the tower are considered different when there exists a layer that is painted in different colors, or a layer that is painted in some color in one of the ways and not in the other.
[{"input": "4 1 2 5", "output": "40\n \n\nIn this case, a red layer worth 1 points, a green layer worth 3 points and the\nblue layer worth 2 points. The beauty of the tower is 5 when we have one of\nthe following sets of painted layers:\n\n * 1 green, 1 blue\n * 1 red, 2 blues\n * 2 reds, 1 green\n * 3 reds, 1 blue\n\nThe total number of the ways to produce them is 40.\n\n* * *"}, {"input": "2 5 6 0", "output": "1\n \n\nThe beauty of the tower is 0 only when all the layers are uncolored. Thus, the\nanswer is 1.\n\n* * *"}, {"input": "90081 33447 90629 6391049189", "output": "577742975"}]
Print the number of the ways to paint tiles, modulo 998244353. * * *
s720036677
Runtime Error
p03332
Input is given from Standard Input in the following format: N A B K
Q = 998244353 def modpower(a,b,Q):#a^b mod Q if b == 0: return 1 if b%2 == 0: d = modpower(a,b//2,Q) return d*d%Q if b%2 == 1: return (a*modpower(a,b-1,Q))%Q def factorials(n,Q):#n以下の階乗のリストと階乗の逆元のmodQでのリスト F = [1]*(n+1) R = [1]*(n+1) for i in range(n): F[i+1] = F[i]*(i+1)%Q R[i+1] = R[i]*modpower(i+1,Q-2,Q) return F, R N, A, B, K = map( int, input().split()) ans = 0 F, R = factorials(N,Q) for i in range( min(K//A, N)+1): if (K-A*i)%B == 0: j = (K-A*i)//B ans = (ans + F[N]*R[j]*%QR[N-j]%Q*F[N]*R[i]%Q*R[N-i]%Q)%Q print(ans)
Statement Takahashi has a tower which is divided into N layers. Initially, all the layers are uncolored. Takahashi is going to paint some of the layers in red, green or blue to make a beautiful tower. He defines the _beauty of the tower_ as follows: * The beauty of the tower is the sum of the scores of the N layers, where the score of a layer is A if the layer is painted red, A+B if the layer is painted green, B if the layer is painted blue, and 0 if the layer is uncolored. Here, A and B are positive integer constants given beforehand. Also note that a layer may not be painted in two or more colors. Takahashi is planning to paint the tower so that the beauty of the tower becomes exactly K. How many such ways are there to paint the tower? Find the count modulo 998244353. Two ways to paint the tower are considered different when there exists a layer that is painted in different colors, or a layer that is painted in some color in one of the ways and not in the other.
[{"input": "4 1 2 5", "output": "40\n \n\nIn this case, a red layer worth 1 points, a green layer worth 3 points and the\nblue layer worth 2 points. The beauty of the tower is 5 when we have one of\nthe following sets of painted layers:\n\n * 1 green, 1 blue\n * 1 red, 2 blues\n * 2 reds, 1 green\n * 3 reds, 1 blue\n\nThe total number of the ways to produce them is 40.\n\n* * *"}, {"input": "2 5 6 0", "output": "1\n \n\nThe beauty of the tower is 0 only when all the layers are uncolored. Thus, the\nanswer is 1.\n\n* * *"}, {"input": "90081 33447 90629 6391049189", "output": "577742975"}]
Print the number of the ways to paint tiles, modulo 998244353. * * *
s499395575
Runtime Error
p03332
Input is given from Standard Input in the following format: N A B K
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll MOD = 998244353; ll ncr[300005]; ll fact[300005]; ll inv[300005]; ll ex(ll a, ll b) { if (b == 0) return 1; ll r = ex(a, b>>1); r *= r; r %= MOD; if (b&1) r = (r*a)%MOD; return r; } int main() { ll n, a, b, k, ans = 0; cin >> n >> a >> b >> k; fact[0] = 1; inv[0] = 1; for (ll i = 1;i <= n;i++) { fact[i] = fact[i-1]*i; fact[i] %= MOD; inv[i] = ex(fact[i], MOD-2); } for (ll i = 0;i <= n;i++) { ncr[i] = fact[n]*inv[i]; ncr[i] %= MOD; ncr[i] *= inv[n-i]; ncr[i] %= MOD; } for (ll i = 0;i <= n;i++) { ll rem = k-i*a; if (rem >= 0 && rem%b == 0) { ans += ncr[i]*ncr[rem/b]; ans %= MOD; } } cout << ans << endl; return 0; }
Statement Takahashi has a tower which is divided into N layers. Initially, all the layers are uncolored. Takahashi is going to paint some of the layers in red, green or blue to make a beautiful tower. He defines the _beauty of the tower_ as follows: * The beauty of the tower is the sum of the scores of the N layers, where the score of a layer is A if the layer is painted red, A+B if the layer is painted green, B if the layer is painted blue, and 0 if the layer is uncolored. Here, A and B are positive integer constants given beforehand. Also note that a layer may not be painted in two or more colors. Takahashi is planning to paint the tower so that the beauty of the tower becomes exactly K. How many such ways are there to paint the tower? Find the count modulo 998244353. Two ways to paint the tower are considered different when there exists a layer that is painted in different colors, or a layer that is painted in some color in one of the ways and not in the other.
[{"input": "4 1 2 5", "output": "40\n \n\nIn this case, a red layer worth 1 points, a green layer worth 3 points and the\nblue layer worth 2 points. The beauty of the tower is 5 when we have one of\nthe following sets of painted layers:\n\n * 1 green, 1 blue\n * 1 red, 2 blues\n * 2 reds, 1 green\n * 3 reds, 1 blue\n\nThe total number of the ways to produce them is 40.\n\n* * *"}, {"input": "2 5 6 0", "output": "1\n \n\nThe beauty of the tower is 0 only when all the layers are uncolored. Thus, the\nanswer is 1.\n\n* * *"}, {"input": "90081 33447 90629 6391049189", "output": "577742975"}]
Print the number of the ways to paint tiles, modulo 998244353. * * *
s342241887
Runtime Error
p03332
Input is given from Standard Input in the following format: N A B K
Q = 998244353 def modpower(a,b,Q):#a^b mod Q if b == 0: return 1 if b%2 == 0: d = modpower(a,b//2,Q) return d*d%Q if b%2 == 1: return (a*modpower(a,b-1,Q))%Q def factorials(n,Q):#n以下の階乗のリストと階乗の逆元のmodQでのリスト F = [1]*(n+1) R = [1]*(n+1) for i in range(n): F[i+1] = F[i]*(i+1)%Q R[i+1] = R[i]*modpower(i+1,Q-2,Q) return F, R N, A, B, K = map( int, input().split()) ans = 0 F, R = factorials(N,Q) for i in range( min(K//A, N)+1): if (K-A*i)%B == 0: print(i) j = (K-A*i)//B print(F[N]*R[j]%Q*R[N-j]%Q*F[N]*R[i]%Q*R[N-i]%Q) ans = (ans + F[N]*R[j]*%QR[N-j]%Q*F[N]*R[i]%Q*R[N-i]%Q)%Q print(ans)
Statement Takahashi has a tower which is divided into N layers. Initially, all the layers are uncolored. Takahashi is going to paint some of the layers in red, green or blue to make a beautiful tower. He defines the _beauty of the tower_ as follows: * The beauty of the tower is the sum of the scores of the N layers, where the score of a layer is A if the layer is painted red, A+B if the layer is painted green, B if the layer is painted blue, and 0 if the layer is uncolored. Here, A and B are positive integer constants given beforehand. Also note that a layer may not be painted in two or more colors. Takahashi is planning to paint the tower so that the beauty of the tower becomes exactly K. How many such ways are there to paint the tower? Find the count modulo 998244353. Two ways to paint the tower are considered different when there exists a layer that is painted in different colors, or a layer that is painted in some color in one of the ways and not in the other.
[{"input": "4 1 2 5", "output": "40\n \n\nIn this case, a red layer worth 1 points, a green layer worth 3 points and the\nblue layer worth 2 points. The beauty of the tower is 5 when we have one of\nthe following sets of painted layers:\n\n * 1 green, 1 blue\n * 1 red, 2 blues\n * 2 reds, 1 green\n * 3 reds, 1 blue\n\nThe total number of the ways to produce them is 40.\n\n* * *"}, {"input": "2 5 6 0", "output": "1\n \n\nThe beauty of the tower is 0 only when all the layers are uncolored. Thus, the\nanswer is 1.\n\n* * *"}, {"input": "90081 33447 90629 6391049189", "output": "577742975"}]
Print the number of the ways to paint tiles, modulo 998244353. * * *
s727985488
Runtime Error
p03332
Input is given from Standard Input in the following format: N A B K
import numpy as np import math n,a,b,k = input('input>>').split(' ') va = np.array([1,0,0]) vb = np.array([0,1,0]) vc = np.array([0,0,1]) v0 = np.array([0,0,0]) def sum_c(sums,pointer,way_vec): if sums == k: way_vec.append(pointer) return way_vec if sums > k: return way_vec sums = sums + c pointer = pointer + vc sum_c(sums,pointer,way_vec) def sum_b(sums,pointer,way_vec): if sums == k: way_vec.append(pointer) return way_vec if sums > k: return way_vec sums = sums + b pointer = pointer + vb sum_b(sums,pointer,way_vec) sum_c(sums,pointer,way_vec) def sum_a(sums,pointer,way_vec): if sums == k: way_vec.append(pointer) return way_vec if sums > k: return way_vec sums = sums + a pointer = pointer + va sum_a(sums,pointer,way_vec) sum_b(sums,pointer,way_vec) sum_c(sums,pointer,way_vec) if a > b: a,b = b,a if a%2==0 && b%2==0 && k%2==1: return 0 else if k<a: return 0 wey_vec = [] else if a <= k < b: way_vec = sum_a(0,v0,way_vec) elseif b <= k < c: way_vec = sum_a(0,v0,way_vec) way_vec = sum_b(0,v0,way_vec) else if k > c: way_vec = sum_a(0,v0,way_vec) way_vec = sum_b(0,v0,way_vec) way_vec = sum_c(0,v0,way_vec) else : return 0 def comb1(n,r): if n==0 or r==0:return 1 return comb1(n,r-1)*(n-r+1)/r ans = 0 for i in range(len(way_vec)): t= way_vec[i] ans = ans + comb1(n,t[0]) * comb1(n-t[0],t[1]) * comb2(n-t[0]-t[1],t[2]) ans = ans % 998244353 return ans
Statement Takahashi has a tower which is divided into N layers. Initially, all the layers are uncolored. Takahashi is going to paint some of the layers in red, green or blue to make a beautiful tower. He defines the _beauty of the tower_ as follows: * The beauty of the tower is the sum of the scores of the N layers, where the score of a layer is A if the layer is painted red, A+B if the layer is painted green, B if the layer is painted blue, and 0 if the layer is uncolored. Here, A and B are positive integer constants given beforehand. Also note that a layer may not be painted in two or more colors. Takahashi is planning to paint the tower so that the beauty of the tower becomes exactly K. How many such ways are there to paint the tower? Find the count modulo 998244353. Two ways to paint the tower are considered different when there exists a layer that is painted in different colors, or a layer that is painted in some color in one of the ways and not in the other.
[{"input": "4 1 2 5", "output": "40\n \n\nIn this case, a red layer worth 1 points, a green layer worth 3 points and the\nblue layer worth 2 points. The beauty of the tower is 5 when we have one of\nthe following sets of painted layers:\n\n * 1 green, 1 blue\n * 1 red, 2 blues\n * 2 reds, 1 green\n * 3 reds, 1 blue\n\nThe total number of the ways to produce them is 40.\n\n* * *"}, {"input": "2 5 6 0", "output": "1\n \n\nThe beauty of the tower is 0 only when all the layers are uncolored. Thus, the\nanswer is 1.\n\n* * *"}, {"input": "90081 33447 90629 6391049189", "output": "577742975"}]
Print the number of the ways to paint tiles, modulo 998244353. * * *
s762324320
Runtime Error
p03332
Input is given from Standard Input in the following format: N A B K
N, A, B, K = map(int, input().split()) thisMap = {} def search(N, K): global A, B plus = 0 if N == 1: if K == 0 or K == A or K == B or K == A + B: return 1 else: return 0 plus += search(N - 1, K) if K - A >= 0: if str(N - 1) + "-" + str(K - A) in thisMap.keys(): plus += thisMap[str(N - 1) + "-" + str(K - A)] else: plus += search(N - 1, K - A) if K - B >= 0: if str(N - 1) + "-" + str(K - B) in thisMap.keys(): plus += thisMap[str(N - 1) + "-" + str(K - B)] else: plus += search(N - 1, K - B) if K - A - B >= 0: if str(N - 1) + "-" + str(K - A - B) in thisMap.keys(): plus += thisMap[str(N - 1) + "-" + str(K - A - B)] else: plus += search(N - 1, K - A - B) return plus # map = [[0 for _ in range(N)] for _ in range(K+1)] # for i in range(N): # map[0][i] = 1 # # for i in range(1,K+1): # if i == A or i == B or i == A+B: # map[i][0] = 1 # print("HI") # for i in range(1,K+1): # for j in range(1,N): # plus = 0 # plus += map[i][j-1] # if i - A >= 0: # plus += map[i-A][j-1] # if i - (A+B) >= 0: # plus += map[i-A-B][j-1] # if i - B >= 0: # plus += map[i-B][j-1] # map[i][j] = plus # for i in range(1,6 * (10 ** 2)): # if N > i * 500: # search(i * 500, K) print(search(N, K))
Statement Takahashi has a tower which is divided into N layers. Initially, all the layers are uncolored. Takahashi is going to paint some of the layers in red, green or blue to make a beautiful tower. He defines the _beauty of the tower_ as follows: * The beauty of the tower is the sum of the scores of the N layers, where the score of a layer is A if the layer is painted red, A+B if the layer is painted green, B if the layer is painted blue, and 0 if the layer is uncolored. Here, A and B are positive integer constants given beforehand. Also note that a layer may not be painted in two or more colors. Takahashi is planning to paint the tower so that the beauty of the tower becomes exactly K. How many such ways are there to paint the tower? Find the count modulo 998244353. Two ways to paint the tower are considered different when there exists a layer that is painted in different colors, or a layer that is painted in some color in one of the ways and not in the other.
[{"input": "4 1 2 5", "output": "40\n \n\nIn this case, a red layer worth 1 points, a green layer worth 3 points and the\nblue layer worth 2 points. The beauty of the tower is 5 when we have one of\nthe following sets of painted layers:\n\n * 1 green, 1 blue\n * 1 red, 2 blues\n * 2 reds, 1 green\n * 3 reds, 1 blue\n\nThe total number of the ways to produce them is 40.\n\n* * *"}, {"input": "2 5 6 0", "output": "1\n \n\nThe beauty of the tower is 0 only when all the layers are uncolored. Thus, the\nanswer is 1.\n\n* * *"}, {"input": "90081 33447 90629 6391049189", "output": "577742975"}]
Print the number of the ways to paint tiles, modulo 998244353. * * *
s939411893
Accepted
p03332
Input is given from Standard Input in the following format: N A B K
mod = 998244353 def extgcd(a, b, c): x, y, u, v, k, l = 1, 0, 0, 1, a, b while l != 0: x, y, u, v = u, v, x - u * (k // l), y - (k // l) k, l = l, k % l if c == 1: return x elif c == 2: return y elif c == 3: return k def inved(x): return extgcd(x, mod, 1) fact = [1 for i in range(300001)] invf = [1 for i in range(300001)] for i in range(300000): fact[i + 1] = (fact[i] * (i + 1)) % mod invf[300000] = inved(fact[300000]) for i in range(300000, 0, -1): invf[i - 1] = (invf[i] * i) % mod # --------------------------------------------------# N, A, B, K = map(int, input().split()) g = extgcd(A, B, 3) uppern = (fact[N] * fact[N]) % mod S = 0 if K % g != 0: S = 0 else: left = max(-((B * N - K) // A), 0) right = min(K // A, N) for i in range(left, right + 1): if (K - A * i) % B == 0: l = (K - A * i) // B prod = (invf[i] * invf[N - i]) % mod prod *= (invf[l] * invf[N - l]) % mod prod %= mod prod *= uppern prod %= mod S += prod S %= mod print(S)
Statement Takahashi has a tower which is divided into N layers. Initially, all the layers are uncolored. Takahashi is going to paint some of the layers in red, green or blue to make a beautiful tower. He defines the _beauty of the tower_ as follows: * The beauty of the tower is the sum of the scores of the N layers, where the score of a layer is A if the layer is painted red, A+B if the layer is painted green, B if the layer is painted blue, and 0 if the layer is uncolored. Here, A and B are positive integer constants given beforehand. Also note that a layer may not be painted in two or more colors. Takahashi is planning to paint the tower so that the beauty of the tower becomes exactly K. How many such ways are there to paint the tower? Find the count modulo 998244353. Two ways to paint the tower are considered different when there exists a layer that is painted in different colors, or a layer that is painted in some color in one of the ways and not in the other.
[{"input": "4 1 2 5", "output": "40\n \n\nIn this case, a red layer worth 1 points, a green layer worth 3 points and the\nblue layer worth 2 points. The beauty of the tower is 5 when we have one of\nthe following sets of painted layers:\n\n * 1 green, 1 blue\n * 1 red, 2 blues\n * 2 reds, 1 green\n * 3 reds, 1 blue\n\nThe total number of the ways to produce them is 40.\n\n* * *"}, {"input": "2 5 6 0", "output": "1\n \n\nThe beauty of the tower is 0 only when all the layers are uncolored. Thus, the\nanswer is 1.\n\n* * *"}, {"input": "90081 33447 90629 6391049189", "output": "577742975"}]