eolymp
bolt
Попробуйте наш новый интерфейс для отправки задач
Задачи

Burned Calendar

Burned Calendar

A year calendar is printed using the monospace font according to the following rules: \begin{enumerate} \item All spaces on the printed calendar are represented by the dot character (\textbf{ASCII 46}). \item Every month occupies a rectangle of \textbf{17} by \textbf{8} characters, with the name of the month written in all capital letters starting from the \textbf{2}^nd character of the first line. \item All days of the months are printed in \textbf{4}, \textbf{5}, or \textbf{6} columns \textbf{2} characters wide and \textbf{7} characters high, with one space between the columns. The first day of the week is Monday. \begin{itemize} \item a. Months of the year are arranged in the three rows separated by horizontal and vertical lines of spaces. Each row contains four months. The calendar margins are of \textbf{1} space from all sides. Therefore, the whole calendar has size of \textbf{73} by \textbf{28} characters. \end{itemize} \end{enumerate} Note that January \textbf{1^st}, \textbf{1900} was Monday. Also note that a leap year number is divisible by \textbf{4} and not divisible by \textbf{100}, or divisible by \textbf{400}. For example, a part of the printed calendar from October to December \textbf{2002} may look like this: \includegraphics{https://static.e-olymp.com/content/ad/ad3bd219e158ca89d4b25d61adc94d32fbd9570c.jpg} A calendar was printed and then burned, with only a small rectangular piece left. Your program must determine to which of years from \textbf{1900} to \textbf{2100} this piece could belong. \InputFile The first line of the input file contains integer numbers \textbf{N} and \textbf{M} (\textbf{2} ≤ \textbf{N}, \textbf{M} ≤ \textbf{10}), separated by spaces --- the size of the piece. The following M lines contain N characters each --- the piece of calendar. \OutputFile Output file must contain an ordered list of year numbers, one year per line. If given piece could not belong to any calendar, output must contain a single integer \textbf{0} (zero).
Лимит времени 1 секунда
Лимит использования памяти 64 MiB
Входные данные #1
2 2
..
..
Выходные данные #1
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099

...
Источник ACM ICPC 2002/2003 Quarterfinal (Far-Eastern Subregion) Vladivostok, November 2, 2002.