problem_id
stringlengths 3
7
| contestId
stringclasses 660
values | problem_index
stringclasses 27
values | programmingLanguage
stringclasses 3
values | testset
stringclasses 5
values | incorrect_passedTestCount
float64 0
146
| incorrect_timeConsumedMillis
float64 15
4.26k
| incorrect_memoryConsumedBytes
float64 0
271M
| incorrect_submission_id
stringlengths 7
9
| incorrect_source
stringlengths 10
27.7k
| correct_passedTestCount
float64 2
360
| correct_timeConsumedMillis
int64 30
8.06k
| correct_memoryConsumedBytes
int64 0
475M
| correct_submission_id
stringlengths 7
9
| correct_source
stringlengths 28
21.2k
| contest_name
stringclasses 664
values | contest_type
stringclasses 3
values | contest_start_year
int64 2.01k
2.02k
| time_limit
float64 0.5
15
| memory_limit
float64 64
1.02k
| title
stringlengths 2
54
| description
stringlengths 35
3.16k
| input_format
stringlengths 67
1.76k
| output_format
stringlengths 18
1.06k
⌀ | interaction_format
null | note
stringclasses 840
values | examples
stringlengths 34
1.16k
| rating
int64 800
3.4k
⌀ | tags
stringclasses 533
values | testset_size
int64 2
360
| official_tests
stringlengths 44
19.7M
| official_tests_complete
bool 1
class | input_mode
stringclasses 1
value | generated_checker
stringclasses 231
values | executable
bool 1
class |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
113/A
|
113
|
A
|
Python 3
|
TESTS
| 136 | 92 | 102,400 |
212181856
|
a=input().split()
i=0
n=len(a)
while i<n and (len(a[i])>=4 and a[i][len(a[i])-4:]=="lios"):
i+=1
i1=i
while i<n and (len(a[i])>=3 and a[i][len(a[i])-3:]=="etr"):
i+=1
if i-i1!=1 and i!=0 and n>1:
print("NO")
exit()
while i<n and (len(a[i])>=6 and a[i][len(a[i])-6:]=="initis"):
i+=1
#print(i)
if i==0:
i=0
n=len(a)
while i < n and (len(a[i])>=5 and a[i][len(a[i])-5:]=="liala"):
i += 1
i1 = i
while i < n and (len(a[i])>=4 and a[i][len(a[i])-4:]=="etra"):
i += 1
if i - i1 != 1 and n>1:
print("NO")
exit()
while i < n and (len(a[i])>=6 and a[i][len(a[i])-6:]=="inites"):
i += 1
if len(a) != i:
print("NO")
else:
print("YES")
elif i==n:
print("YES")
else:
print("NO")
| 360 | 78 | 307,200 |
4075975
|
s=input().split()
if(len(s)==1):
if(s[0].endswith("lios") or s[0].endswith("etr") or s[0].endswith("liala") or s[0].endswith("etra") or s[0].endswith("inites") or s[0].endswith("initis")):
print("YES")
else:
print("NO")
elif(s[0].endswith("lios") or s[0].endswith("etr")):
n=len(s)
i=0
while(i<n and s[i].endswith("lios")):
i+=1
if(i==n):
print("NO")
elif(s[i].endswith("etr")):
i+=1
while(i<n and s[i].endswith("initis")):
i+=1
if(i==n):
print("YES")
else:
print("NO")
else:
print("NO")
elif(s[0].endswith("liala") or s[0].endswith("etra")):
n=len(s)
i=0
while(i<n and s[i].endswith("liala")):
i+=1
if(i==n):
print("NO")
elif(s[i].endswith("etra")):
i+=1
while(i<n and s[i].endswith("inites")):
i+=1
if(i==n):
print("YES")
else:
print("NO")
else:
print("NO")
else:
print("NO")
|
Codeforces Beta Round 86 (Div. 1 Only)
|
CF
| 2,011 | 5 | 256 |
Grammar Lessons
|
Petya got interested in grammar on his third year in school. He invented his own language called Petya's. Petya wanted to create a maximally simple language that would be enough to chat with friends, that's why all the language's grammar can be described with the following set of rules:
- There are three parts of speech: the adjective, the noun, the verb. Each word in his language is an adjective, noun or verb.
- There are two genders: masculine and feminine. Each word in his language has gender either masculine or feminine.
- Masculine adjectives end with -lios, and feminine adjectives end with -liala.
- Masculine nouns end with -etr, and feminime nouns end with -etra.
- Masculine verbs end with -initis, and feminime verbs end with -inites.
- Thus, each word in the Petya's language has one of the six endings, given above. There are no other endings in Petya's language.
- It is accepted that the whole word consists of an ending. That is, words "lios", "liala", "etr" and so on belong to the Petya's language.
- There aren't any punctuation marks, grammatical tenses, singular/plural forms or other language complications.
- A sentence is either exactly one valid language word or exactly one statement.
Statement is any sequence of the Petya's language, that satisfy both conditions:
- Words in statement follow in the following order (from the left to the right): zero or more adjectives followed by exactly one noun followed by zero or more verbs.
- All words in the statement should have the same gender.
After Petya's friend Vasya wrote instant messenger (an instant messaging program) that supported the Petya's language, Petya wanted to add spelling and grammar checking to the program. As Vasya was in the country and Petya didn't feel like waiting, he asked you to help him with this problem. Your task is to define by a given sequence of words, whether it is true that the given text represents exactly one sentence in Petya's language.
|
The first line contains one or more words consisting of lowercase Latin letters. The overall number of characters (including letters and spaces) does not exceed 105.
It is guaranteed that any two consecutive words are separated by exactly one space and the input data do not contain any other spaces. It is possible that given words do not belong to the Petya's language.
|
If some word of the given text does not belong to the Petya's language or if the text contains more that one sentence, print "NO" (without the quotes). Otherwise, print "YES" (without the quotes).
| null | null |
[{"input": "petr", "output": "YES"}, {"input": "etis atis animatis etis atis amatis", "output": "NO"}, {"input": "nataliala kataliala vetra feinites", "output": "YES"}]
| 1,600 |
["implementation", "strings"]
| 360 |
[{"input": "petr\r\n", "output": "YES\r\n"}, {"input": "etis atis animatis etis atis amatis\r\n", "output": "NO\r\n"}, {"input": "nataliala kataliala vetra feinites\r\n", "output": "YES\r\n"}, {"input": "qweasbvflios\r\n", "output": "YES\r\n"}, {"input": "lios lios petr initis qwe\r\n", "output": "NO\r\n"}, {"input": "lios initis\r\n", "output": "NO\r\n"}, {"input": "petr initis lios\r\n", "output": "NO\r\n"}, {"input": "petra petra petra\r\n", "output": "NO\r\n"}, {"input": "in\r\n", "output": "NO\r\n"}, {"input": "liala petra initis\r\n", "output": "NO\r\n"}, {"input": "liala petra inites\r\n", "output": "YES\r\n"}, {"input": "liala initis\r\n", "output": "NO\r\n"}, {"input": "liala petra petr inites\r\n", "output": "NO\r\n"}, {"input": "liala petr inites\r\n", "output": "NO\r\n"}, {"input": "llilitos\r\n", "output": "NO\r\n"}, {"input": "i i i i i i i i i i i i i i i a a a a a a v v v v v v v v v v v\r\n", "output": "NO\r\n"}, {"input": "hqaagnslliola vdumwjqalkyzbybwcaomxyffbkufaarhoebrqlpgshbmvjbwchfolyniuqkrysdhakzzrbiznhatifkbrqruswzhkewvgarmqtuadmsiquueumnpftiulfdpvzqfdgcfscczfsqivcdbuqvtyujirjwohskuabufdkehctkkguvetra oxnpizgojsrtinites\r\n", "output": "NO\r\n"}, {"input": "etretra linites\r\n", "output": "YES\r\n"}, {"input": "petretra petr\r\n", "output": "NO\r\n"}, {"input": "lialalios petraveryfunnypetr\r\n", "output": "YES\r\n"}, {"input": "petropetrapetr petra\r\n", "output": "NO\r\n"}, {"input": "lios petrnonono\r\n", "output": "NO\r\n"}, {"input": "lios petr initisandinitisandliala petrainitis\r\n", "output": "NO\r\n"}, {"input": "petro\r\n", "output": "NO\r\n"}, {"input": "petr initesinitis\r\n", "output": "YES\r\n"}, {"input": "lios initis\r\n", "output": "NO\r\n"}, {"input": "liala initespetra\r\n", "output": "YES\r\n"}, {"input": "lios petrapetr\r\n", "output": "YES\r\n"}, {"input": "initis petr\r\n", "output": "NO\r\n"}, {"input": "lioslialapetrpetrainitisinitesliosliala initesinitislioslialapetrpetrainitisinitetra\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixpetr\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixpetra\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixinitis\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixinites\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixliala\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixlios\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixlialas\r\n", "output": "NO\r\n"}, {"input": "veryfunnyprefixliala veryfunnyprefixpetretra\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixlios veryfunnyprefixinitisetr\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixlios aabbinitis\r\n", "output": "NO\r\n"}, {"input": "veryfunnyprefixlios inites\r\n", "output": "NO\r\n"}, {"input": "lios petr initis\r\n", "output": "YES\r\n"}, {"input": "liala etra inites\r\n", "output": "YES\r\n"}, {"input": "lios\r\n", "output": "YES\r\n"}, {"input": "liala\r\n", "output": "YES\r\n"}, {"input": "initis\r\n", "output": "YES\r\n"}, {"input": "inites\r\n", "output": "YES\r\n"}, {"input": "tes\r\n", "output": "NO\r\n"}, {"input": "tr\r\n", "output": "NO\r\n"}, {"input": "a\r\n", "output": "NO\r\n"}, {"input": "lios lios\r\n", "output": "NO\r\n"}, {"input": "lios\r\n", "output": "YES\r\n"}, {"input": "liala\r\n", "output": "YES\r\n"}, {"input": "petr\r\n", "output": "YES\r\n"}, {"input": "petra\r\n", "output": "YES\r\n"}, {"input": "pinitis\r\n", "output": "YES\r\n"}, {"input": "pinites\r\n", "output": "YES\r\n"}, {"input": "plios pliala\r\n", "output": "NO\r\n"}, {"input": "plios petr\r\n", "output": "YES\r\n"}, {"input": "plios petra\r\n", "output": "NO\r\n"}, {"input": "plios plios\r\n", "output": "NO\r\n"}, {"input": "plios initis\r\n", "output": "NO\r\n"}, {"input": "plios pinites\r\n", "output": "NO\r\n"}, {"input": "pliala plios\r\n", "output": "NO\r\n"}, {"input": "pliala ppliala\r\n", "output": "NO\r\n"}, {"input": "pliala petr\r\n", "output": "NO\r\n"}, {"input": "pliala petra\r\n", "output": "YES\r\n"}, {"input": "pliala pinitis\r\n", "output": "NO\r\n"}, {"input": "pliala pinites\r\n", "output": "NO\r\n"}, {"input": "petr plios\r\n", "output": "NO\r\n"}, {"input": "petr pliala\r\n", "output": "NO\r\n"}, {"input": "petr petr\r\n", "output": "NO\r\n"}, {"input": "petr petra\r\n", "output": "NO\r\n"}, {"input": "petr pinitis\r\n", "output": "YES\r\n"}, {"input": "petr pinites\r\n", "output": "NO\r\n"}, {"input": "petra lios\r\n", "output": "NO\r\n"}, {"input": "petra liala\r\n", "output": "NO\r\n"}, {"input": "petra petr\r\n", "output": "NO\r\n"}, {"input": "petra petra\r\n", "output": "NO\r\n"}, {"input": "petra initis\r\n", "output": "NO\r\n"}, {"input": "petra inites\r\n", "output": "YES\r\n"}, {"input": "initis lios\r\n", "output": "NO\r\n"}, {"input": "initis liala\r\n", "output": "NO\r\n"}, {"input": "initis petr\r\n", "output": "NO\r\n"}, {"input": "initis petra\r\n", "output": "NO\r\n"}, {"input": "initis initis\r\n", "output": "NO\r\n"}, {"input": "initis inites\r\n", "output": "NO\r\n"}, {"input": "inites lios\r\n", "output": "NO\r\n"}, {"input": "inites liala\r\n", "output": "NO\r\n"}, {"input": "inites petr\r\n", "output": "NO\r\n"}, {"input": "inites petra\r\n", "output": "NO\r\n"}, {"input": "inites initis\r\n", "output": "NO\r\n"}, {"input": "inites inites\r\n", "output": "NO\r\n"}, {"input": "lios lios lios\r\n", "output": "NO\r\n"}, {"input": "lios lios liala\r\n", "output": "NO\r\n"}, {"input": "lios lios etr\r\n", "output": "YES\r\n"}, {"input": "lios lios etra\r\n", "output": "NO\r\n"}, {"input": "lios lios initis\r\n", "output": "NO\r\n"}, {"input": "lios lios inites\r\n", "output": "NO\r\n"}, {"input": "lios liala lios\r\n", "output": "NO\r\n"}, {"input": "lios liala liala\r\n", "output": "NO\r\n"}, {"input": "lios liala etr\r\n", "output": "NO\r\n"}, {"input": "lios liala etra\r\n", "output": "NO\r\n"}, {"input": "lios liala initis\r\n", "output": "NO\r\n"}, {"input": "lios liala inites\r\n", "output": "NO\r\n"}, {"input": "lios etr lios\r\n", "output": "NO\r\n"}, {"input": "lios etr liala\r\n", "output": "NO\r\n"}, {"input": "lios etr etr\r\n", "output": "NO\r\n"}, {"input": "lios etr etra\r\n", "output": "NO\r\n"}, {"input": "lios etr initis\r\n", "output": "YES\r\n"}, {"input": "lios etr inites\r\n", "output": "NO\r\n"}, {"input": "lios etra lios\r\n", "output": "NO\r\n"}, {"input": "lios etra liala\r\n", "output": "NO\r\n"}, {"input": "lios etra etr\r\n", "output": "NO\r\n"}, {"input": "lios etra etra\r\n", "output": "NO\r\n"}, {"input": "lios etra initis\r\n", "output": "NO\r\n"}, {"input": "lios etra inites\r\n", "output": "NO\r\n"}, {"input": "lios initis lios\r\n", "output": "NO\r\n"}, {"input": "lios initis liala\r\n", "output": "NO\r\n"}, {"input": "lios initis etr\r\n", "output": "NO\r\n"}, {"input": "lios initis etra\r\n", "output": "NO\r\n"}, {"input": "lios initis initis\r\n", "output": "NO\r\n"}, {"input": "lios initis inites\r\n", "output": "NO\r\n"}, {"input": "lios inites lios\r\n", "output": "NO\r\n"}, {"input": "lios inites liala\r\n", "output": "NO\r\n"}, {"input": "lios inites etr\r\n", "output": "NO\r\n"}, {"input": "lios inites etra\r\n", "output": "NO\r\n"}, {"input": "lios inites initis\r\n", "output": "NO\r\n"}, {"input": "lios inites inites\r\n", "output": "NO\r\n"}, {"input": "liala lios lios\r\n", "output": "NO\r\n"}, {"input": "liala lios liala\r\n", "output": "NO\r\n"}, {"input": "liala lios etr\r\n", "output": "NO\r\n"}, {"input": "liala lios etra\r\n", "output": "NO\r\n"}, {"input": "liala lios initis\r\n", "output": "NO\r\n"}, {"input": "liala lios inites\r\n", "output": "NO\r\n"}, {"input": "liala liala lios\r\n", "output": "NO\r\n"}, {"input": "liala liala liala\r\n", "output": "NO\r\n"}, {"input": "liala liala etr\r\n", "output": "NO\r\n"}, {"input": "liala liala etra\r\n", "output": "YES\r\n"}, {"input": "liala liala initis\r\n", "output": "NO\r\n"}, {"input": "liala liala inites\r\n", "output": "NO\r\n"}, {"input": "liala etr lios\r\n", "output": "NO\r\n"}, {"input": "liala etr liala\r\n", "output": "NO\r\n"}, {"input": "liala etr etr\r\n", "output": "NO\r\n"}, {"input": "liala etr etra\r\n", "output": "NO\r\n"}, {"input": "liala etr initis\r\n", "output": "NO\r\n"}, {"input": "liala etr inites\r\n", "output": "NO\r\n"}, {"input": "liala etra lios\r\n", "output": "NO\r\n"}, {"input": "liala etra liala\r\n", "output": "NO\r\n"}, {"input": "liala etra etr\r\n", "output": "NO\r\n"}, {"input": "liala etra etra\r\n", "output": "NO\r\n"}, {"input": "liala etra initis\r\n", "output": "NO\r\n"}, {"input": "liala etra inites\r\n", "output": "YES\r\n"}, {"input": "liala initis lios\r\n", "output": "NO\r\n"}, {"input": "liala initis liala\r\n", "output": "NO\r\n"}, {"input": "liala initis etr\r\n", "output": "NO\r\n"}, {"input": "liala initis etra\r\n", "output": "NO\r\n"}, {"input": "liala initis initis\r\n", "output": "NO\r\n"}, {"input": "liala initis inites\r\n", "output": "NO\r\n"}, {"input": "liala inites lios\r\n", "output": "NO\r\n"}, {"input": "liala inites liala\r\n", "output": "NO\r\n"}, {"input": "liala inites etr\r\n", "output": "NO\r\n"}, {"input": "liala inites etra\r\n", "output": "NO\r\n"}, {"input": "liala inites initis\r\n", "output": "NO\r\n"}, {"input": "liala inites inites\r\n", "output": "NO\r\n"}, {"input": "etr lios lios\r\n", "output": "NO\r\n"}, {"input": "etr lios liala\r\n", "output": "NO\r\n"}, {"input": "etr lios etr\r\n", "output": "NO\r\n"}, {"input": "etr lios etra\r\n", "output": "NO\r\n"}, {"input": "etr lios initis\r\n", "output": "NO\r\n"}, {"input": "etr lios inites\r\n", "output": "NO\r\n"}, {"input": "etr liala lios\r\n", "output": "NO\r\n"}, {"input": "etr liala liala\r\n", "output": "NO\r\n"}, {"input": "etr liala etr\r\n", "output": "NO\r\n"}, {"input": "etr liala etra\r\n", "output": "NO\r\n"}, {"input": "etr liala initis\r\n", "output": "NO\r\n"}, {"input": "etr liala inites\r\n", "output": "NO\r\n"}, {"input": "etr etr lios\r\n", "output": "NO\r\n"}, {"input": "etr etr liala\r\n", "output": "NO\r\n"}, {"input": "etr etr etr\r\n", "output": "NO\r\n"}, {"input": "etr etr etra\r\n", "output": "NO\r\n"}, {"input": "etr etr initis\r\n", "output": "NO\r\n"}, {"input": "etr etr inites\r\n", "output": "NO\r\n"}, {"input": "etr etra lios\r\n", "output": "NO\r\n"}, {"input": "etr etra liala\r\n", "output": "NO\r\n"}, {"input": "etr etra etr\r\n", "output": "NO\r\n"}, {"input": "etr etra etra\r\n", "output": "NO\r\n"}, {"input": "etr etra initis\r\n", "output": "NO\r\n"}, {"input": "etr etra inites\r\n", "output": "NO\r\n"}, {"input": "etr initis lios\r\n", "output": "NO\r\n"}, {"input": "etr initis liala\r\n", "output": "NO\r\n"}, {"input": "etr initis etr\r\n", "output": "NO\r\n"}, {"input": "etr initis etra\r\n", "output": "NO\r\n"}, {"input": "etr initis initis\r\n", "output": "YES\r\n"}, {"input": "etr initis inites\r\n", "output": "NO\r\n"}, {"input": "etr inites lios\r\n", "output": "NO\r\n"}, {"input": "etr inites liala\r\n", "output": "NO\r\n"}, {"input": "etr inites etr\r\n", "output": "NO\r\n"}, {"input": "etr inites etra\r\n", "output": "NO\r\n"}, {"input": "etr inites initis\r\n", "output": "NO\r\n"}, {"input": "etr inites inites\r\n", "output": "NO\r\n"}, {"input": "etra lios lios\r\n", "output": "NO\r\n"}, {"input": "etra lios liala\r\n", "output": "NO\r\n"}, {"input": "etra lios etr\r\n", "output": "NO\r\n"}, {"input": "etra lios etra\r\n", "output": "NO\r\n"}, {"input": "etra lios initis\r\n", "output": "NO\r\n"}, {"input": "etra lios inites\r\n", "output": "NO\r\n"}, {"input": "etra liala lios\r\n", "output": "NO\r\n"}, {"input": "etra liala liala\r\n", "output": "NO\r\n"}, {"input": "etra liala etr\r\n", "output": "NO\r\n"}, {"input": "etra liala etra\r\n", "output": "NO\r\n"}, {"input": "etra liala initis\r\n", "output": "NO\r\n"}, {"input": "etra liala inites\r\n", "output": "NO\r\n"}, {"input": "etra etr lios\r\n", "output": "NO\r\n"}, {"input": "etra etr liala\r\n", "output": "NO\r\n"}, {"input": "etra etr etr\r\n", "output": "NO\r\n"}, {"input": "etra etr etra\r\n", "output": "NO\r\n"}, {"input": "etra etr initis\r\n", "output": "NO\r\n"}, {"input": "etra etr inites\r\n", "output": "NO\r\n"}, {"input": "etra etra lios\r\n", "output": "NO\r\n"}, {"input": "etra etra liala\r\n", "output": "NO\r\n"}, {"input": "etra etra etr\r\n", "output": "NO\r\n"}, {"input": "etra etra etra\r\n", "output": "NO\r\n"}, {"input": "etra etra initis\r\n", "output": "NO\r\n"}, {"input": "etra etra inites\r\n", "output": "NO\r\n"}, {"input": "etra initis lios\r\n", "output": "NO\r\n"}, {"input": "etra initis liala\r\n", "output": "NO\r\n"}, {"input": "etra initis etr\r\n", "output": "NO\r\n"}, {"input": "etra initis etra\r\n", "output": "NO\r\n"}, {"input": "etra initis initis\r\n", "output": "NO\r\n"}, {"input": "etra initis inites\r\n", "output": "NO\r\n"}, {"input": "etra inites lios\r\n", "output": "NO\r\n"}, {"input": "etra inites liala\r\n", "output": "NO\r\n"}, {"input": "etra inites etr\r\n", "output": "NO\r\n"}, {"input": "etra inites etra\r\n", "output": "NO\r\n"}, {"input": "etra inites initis\r\n", "output": "NO\r\n"}, {"input": "etra inites inites\r\n", "output": "YES\r\n"}, {"input": "initis lios lios\r\n", "output": "NO\r\n"}, {"input": "initis lios liala\r\n", "output": "NO\r\n"}, {"input": "initis lios etr\r\n", "output": "NO\r\n"}, {"input": "initis lios etra\r\n", "output": "NO\r\n"}, {"input": "initis lios initis\r\n", "output": "NO\r\n"}, {"input": "initis lios inites\r\n", "output": "NO\r\n"}, {"input": "initis liala lios\r\n", "output": "NO\r\n"}, {"input": "initis liala liala\r\n", "output": "NO\r\n"}, {"input": "initis liala etr\r\n", "output": "NO\r\n"}, {"input": "initis liala etra\r\n", "output": "NO\r\n"}, {"input": "initis liala initis\r\n", "output": "NO\r\n"}, {"input": "initis liala inites\r\n", "output": "NO\r\n"}, {"input": "initis etr lios\r\n", "output": "NO\r\n"}, {"input": "initis etr liala\r\n", "output": "NO\r\n"}, {"input": "initis etr etr\r\n", "output": "NO\r\n"}, {"input": "initis etr etra\r\n", "output": "NO\r\n"}, {"input": "initis etr initis\r\n", "output": "NO\r\n"}, {"input": "initis etr inites\r\n", "output": "NO\r\n"}, {"input": "initis etra lios\r\n", "output": "NO\r\n"}, {"input": "initis etra liala\r\n", "output": "NO\r\n"}, {"input": "initis etra etr\r\n", "output": "NO\r\n"}, {"input": "initis etra etra\r\n", "output": "NO\r\n"}, {"input": "initis etra initis\r\n", "output": "NO\r\n"}, {"input": "initis etra inites\r\n", "output": "NO\r\n"}, {"input": "initis initis lios\r\n", "output": "NO\r\n"}, {"input": "initis initis liala\r\n", "output": "NO\r\n"}, {"input": "initis initis etr\r\n", "output": "NO\r\n"}, {"input": "initis initis etra\r\n", "output": "NO\r\n"}, {"input": "initis initis initis\r\n", "output": "NO\r\n"}, {"input": "initis initis inites\r\n", "output": "NO\r\n"}, {"input": "initis inites lios\r\n", "output": "NO\r\n"}, {"input": "initis inites liala\r\n", "output": "NO\r\n"}, {"input": "initis inites etr\r\n", "output": "NO\r\n"}, {"input": "initis inites etra\r\n", "output": "NO\r\n"}, {"input": "initis inites initis\r\n", "output": "NO\r\n"}, {"input": "initis inites inites\r\n", "output": "NO\r\n"}, {"input": "inites lios lios\r\n", "output": "NO\r\n"}, {"input": "inites lios liala\r\n", "output": "NO\r\n"}, {"input": "inites lios etr\r\n", "output": "NO\r\n"}, {"input": "inites lios etra\r\n", "output": "NO\r\n"}, {"input": "inites lios initis\r\n", "output": "NO\r\n"}, {"input": "inites lios inites\r\n", "output": "NO\r\n"}, {"input": "inites liala lios\r\n", "output": "NO\r\n"}, {"input": "inites liala liala\r\n", "output": "NO\r\n"}, {"input": "inites liala etr\r\n", "output": "NO\r\n"}, {"input": "inites liala etra\r\n", "output": "NO\r\n"}, {"input": "inites liala initis\r\n", "output": "NO\r\n"}, {"input": "inites liala inites\r\n", "output": "NO\r\n"}, {"input": "inites etr lios\r\n", "output": "NO\r\n"}, {"input": "inites etr liala\r\n", "output": "NO\r\n"}, {"input": "inites etr etr\r\n", "output": "NO\r\n"}, {"input": "inites etr etra\r\n", "output": "NO\r\n"}, {"input": "inites etr initis\r\n", "output": "NO\r\n"}, {"input": "inites etr inites\r\n", "output": "NO\r\n"}, {"input": "inites etra lios\r\n", "output": "NO\r\n"}, {"input": "inites etra liala\r\n", "output": "NO\r\n"}, {"input": "inites etra etr\r\n", "output": "NO\r\n"}, {"input": "inites etra etra\r\n", "output": "NO\r\n"}, {"input": "inites etra initis\r\n", "output": "NO\r\n"}, {"input": "inites etra inites\r\n", "output": "NO\r\n"}, {"input": "inites initis lios\r\n", "output": "NO\r\n"}, {"input": "inites initis liala\r\n", "output": "NO\r\n"}, {"input": "inites initis etr\r\n", "output": "NO\r\n"}, {"input": "inites initis etra\r\n", "output": "NO\r\n"}, {"input": "inites initis initis\r\n", "output": "NO\r\n"}, {"input": "inites initis inites\r\n", "output": "NO\r\n"}, {"input": "inites inites lios\r\n", "output": "NO\r\n"}, {"input": "inites inites liala\r\n", "output": "NO\r\n"}, {"input": "inites inites etr\r\n", "output": "NO\r\n"}, {"input": "inites inites etra\r\n", "output": "NO\r\n"}, {"input": "inites inites initis\r\n", "output": "NO\r\n"}, {"input": "inites inites inites\r\n", "output": "NO\r\n"}]
| false |
stdio
| null | true |
113/A
|
113
|
A
|
Python 3
|
TESTS
| 65 | 92 | 102,400 |
151378536
|
def isPetyaLanguage():
read = input().split()
if len(read) == 1:
if read[0].endswith('lios') or read[0].endswith('lialia') or read[0].endswith('etr') or read[0].endswith('etra') or read[0].endswith('initis') or read[0].endswith('inites'):
print('YES')
return
else:
print('NO')
return
else:
if read[0].endswith('lios') or read[0].endswith('etr') or read[0].endswith('initis'):
for i in range(1,len(read)):
if (read[i].endswith('lios') or read[i].endswith('etr') or read[i].endswith('initis')) == False:
print('NO')
return
elif read[0].endswith('liala') or read[0].endswith('etra') or read[0].endswith('inites'):
for i in range(1,len(read)):
if (read[i].endswith('liala') or read[i].endswith('etra') or read[i].endswith('inites')) == False:
print('NO')
return
else:
print('NO')
return
index = -1
for i in range(len(read)):
if read[i].endswith('etr') or read[i].endswith('etra'):
index = i
if index == -1:
print('NO')
return
for i in range(0,index):
if (read[i].endswith('lios') or read[i].endswith('liala')) == False:
print('NO')
return
if index == len(read)-1:
print('YES')
return
for i in range(index+1,len(read)):
if (read[i].endswith('initis') or read[i].endswith('inites')) == False:
print('NO')
return
print('YES')
return
isPetyaLanguage()
| 360 | 92 | 102,400 |
151322401
|
def isPetyaLanguage():
words = input().split()
if len(words) == 1:
if words[0].endswith("etr") or words[0].endswith("etra") or words[0].endswith("lios") or words[0].endswith("liala") or words[0].endswith("initis") or words[0].endswith("inites"):
print("YES")
return
else:
print("NO")
return
for i in range(len(words)):
if words[i].endswith("etr"):
noun = i
gender = "masculine"
break
elif words[i].endswith("etra"):
noun = i
gender = "feminine"
break
else:
print("NO")
return
if gender == "masculine":
if noun > 0:
for i in range(noun):
if not words[i].endswith("lios"):
print("NO")
return
if noun < len(words) - 1:
for i in range(noun + 1, len(words)):
if not words[i].endswith("initis"):
print("NO")
return
elif gender == "feminine":
if noun > 0:
for i in range(noun):
if not words[i].endswith("liala"):
print("NO")
return
if noun < len(words) - 1:
for i in range(noun + 1, len(words)):
if not words[i].endswith("inites"):
print("NO")
return
print("YES")
return
isPetyaLanguage()
|
Codeforces Beta Round 86 (Div. 1 Only)
|
CF
| 2,011 | 5 | 256 |
Grammar Lessons
|
Petya got interested in grammar on his third year in school. He invented his own language called Petya's. Petya wanted to create a maximally simple language that would be enough to chat with friends, that's why all the language's grammar can be described with the following set of rules:
- There are three parts of speech: the adjective, the noun, the verb. Each word in his language is an adjective, noun or verb.
- There are two genders: masculine and feminine. Each word in his language has gender either masculine or feminine.
- Masculine adjectives end with -lios, and feminine adjectives end with -liala.
- Masculine nouns end with -etr, and feminime nouns end with -etra.
- Masculine verbs end with -initis, and feminime verbs end with -inites.
- Thus, each word in the Petya's language has one of the six endings, given above. There are no other endings in Petya's language.
- It is accepted that the whole word consists of an ending. That is, words "lios", "liala", "etr" and so on belong to the Petya's language.
- There aren't any punctuation marks, grammatical tenses, singular/plural forms or other language complications.
- A sentence is either exactly one valid language word or exactly one statement.
Statement is any sequence of the Petya's language, that satisfy both conditions:
- Words in statement follow in the following order (from the left to the right): zero or more adjectives followed by exactly one noun followed by zero or more verbs.
- All words in the statement should have the same gender.
After Petya's friend Vasya wrote instant messenger (an instant messaging program) that supported the Petya's language, Petya wanted to add spelling and grammar checking to the program. As Vasya was in the country and Petya didn't feel like waiting, he asked you to help him with this problem. Your task is to define by a given sequence of words, whether it is true that the given text represents exactly one sentence in Petya's language.
|
The first line contains one or more words consisting of lowercase Latin letters. The overall number of characters (including letters and spaces) does not exceed 105.
It is guaranteed that any two consecutive words are separated by exactly one space and the input data do not contain any other spaces. It is possible that given words do not belong to the Petya's language.
|
If some word of the given text does not belong to the Petya's language or if the text contains more that one sentence, print "NO" (without the quotes). Otherwise, print "YES" (without the quotes).
| null | null |
[{"input": "petr", "output": "YES"}, {"input": "etis atis animatis etis atis amatis", "output": "NO"}, {"input": "nataliala kataliala vetra feinites", "output": "YES"}]
| 1,600 |
["implementation", "strings"]
| 360 |
[{"input": "petr\r\n", "output": "YES\r\n"}, {"input": "etis atis animatis etis atis amatis\r\n", "output": "NO\r\n"}, {"input": "nataliala kataliala vetra feinites\r\n", "output": "YES\r\n"}, {"input": "qweasbvflios\r\n", "output": "YES\r\n"}, {"input": "lios lios petr initis qwe\r\n", "output": "NO\r\n"}, {"input": "lios initis\r\n", "output": "NO\r\n"}, {"input": "petr initis lios\r\n", "output": "NO\r\n"}, {"input": "petra petra petra\r\n", "output": "NO\r\n"}, {"input": "in\r\n", "output": "NO\r\n"}, {"input": "liala petra initis\r\n", "output": "NO\r\n"}, {"input": "liala petra inites\r\n", "output": "YES\r\n"}, {"input": "liala initis\r\n", "output": "NO\r\n"}, {"input": "liala petra petr inites\r\n", "output": "NO\r\n"}, {"input": "liala petr inites\r\n", "output": "NO\r\n"}, {"input": "llilitos\r\n", "output": "NO\r\n"}, {"input": "i i i i i i i i i i i i i i i a a a a a a v v v v v v v v v v v\r\n", "output": "NO\r\n"}, {"input": "hqaagnslliola vdumwjqalkyzbybwcaomxyffbkufaarhoebrqlpgshbmvjbwchfolyniuqkrysdhakzzrbiznhatifkbrqruswzhkewvgarmqtuadmsiquueumnpftiulfdpvzqfdgcfscczfsqivcdbuqvtyujirjwohskuabufdkehctkkguvetra oxnpizgojsrtinites\r\n", "output": "NO\r\n"}, {"input": "etretra linites\r\n", "output": "YES\r\n"}, {"input": "petretra petr\r\n", "output": "NO\r\n"}, {"input": "lialalios petraveryfunnypetr\r\n", "output": "YES\r\n"}, {"input": "petropetrapetr petra\r\n", "output": "NO\r\n"}, {"input": "lios petrnonono\r\n", "output": "NO\r\n"}, {"input": "lios petr initisandinitisandliala petrainitis\r\n", "output": "NO\r\n"}, {"input": "petro\r\n", "output": "NO\r\n"}, {"input": "petr initesinitis\r\n", "output": "YES\r\n"}, {"input": "lios initis\r\n", "output": "NO\r\n"}, {"input": "liala initespetra\r\n", "output": "YES\r\n"}, {"input": "lios petrapetr\r\n", "output": "YES\r\n"}, {"input": "initis petr\r\n", "output": "NO\r\n"}, {"input": "lioslialapetrpetrainitisinitesliosliala initesinitislioslialapetrpetrainitisinitetra\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixpetr\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixpetra\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixinitis\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixinites\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixliala\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixlios\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixlialas\r\n", "output": "NO\r\n"}, {"input": "veryfunnyprefixliala veryfunnyprefixpetretra\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixlios veryfunnyprefixinitisetr\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixlios aabbinitis\r\n", "output": "NO\r\n"}, {"input": "veryfunnyprefixlios inites\r\n", "output": "NO\r\n"}, {"input": "lios petr initis\r\n", "output": "YES\r\n"}, {"input": "liala etra inites\r\n", "output": "YES\r\n"}, {"input": "lios\r\n", "output": "YES\r\n"}, {"input": "liala\r\n", "output": "YES\r\n"}, {"input": "initis\r\n", "output": "YES\r\n"}, {"input": "inites\r\n", "output": "YES\r\n"}, {"input": "tes\r\n", "output": "NO\r\n"}, {"input": "tr\r\n", "output": "NO\r\n"}, {"input": "a\r\n", "output": "NO\r\n"}, {"input": "lios lios\r\n", "output": "NO\r\n"}, {"input": "lios\r\n", "output": "YES\r\n"}, {"input": "liala\r\n", "output": "YES\r\n"}, {"input": "petr\r\n", "output": "YES\r\n"}, {"input": "petra\r\n", "output": "YES\r\n"}, {"input": "pinitis\r\n", "output": "YES\r\n"}, {"input": "pinites\r\n", "output": "YES\r\n"}, {"input": "plios pliala\r\n", "output": "NO\r\n"}, {"input": "plios petr\r\n", "output": "YES\r\n"}, {"input": "plios petra\r\n", "output": "NO\r\n"}, {"input": "plios plios\r\n", "output": "NO\r\n"}, {"input": "plios initis\r\n", "output": "NO\r\n"}, {"input": "plios pinites\r\n", "output": "NO\r\n"}, {"input": "pliala plios\r\n", "output": "NO\r\n"}, {"input": "pliala ppliala\r\n", "output": "NO\r\n"}, {"input": "pliala petr\r\n", "output": "NO\r\n"}, {"input": "pliala petra\r\n", "output": "YES\r\n"}, {"input": "pliala pinitis\r\n", "output": "NO\r\n"}, {"input": "pliala pinites\r\n", "output": "NO\r\n"}, {"input": "petr plios\r\n", "output": "NO\r\n"}, {"input": "petr pliala\r\n", "output": "NO\r\n"}, {"input": "petr petr\r\n", "output": "NO\r\n"}, {"input": "petr petra\r\n", "output": "NO\r\n"}, {"input": "petr pinitis\r\n", "output": "YES\r\n"}, {"input": "petr pinites\r\n", "output": "NO\r\n"}, {"input": "petra lios\r\n", "output": "NO\r\n"}, {"input": "petra liala\r\n", "output": "NO\r\n"}, {"input": "petra petr\r\n", "output": "NO\r\n"}, {"input": "petra petra\r\n", "output": "NO\r\n"}, {"input": "petra initis\r\n", "output": "NO\r\n"}, {"input": "petra inites\r\n", "output": "YES\r\n"}, {"input": "initis lios\r\n", "output": "NO\r\n"}, {"input": "initis liala\r\n", "output": "NO\r\n"}, {"input": "initis petr\r\n", "output": "NO\r\n"}, {"input": "initis petra\r\n", "output": "NO\r\n"}, {"input": "initis initis\r\n", "output": "NO\r\n"}, {"input": "initis inites\r\n", "output": "NO\r\n"}, {"input": "inites lios\r\n", "output": "NO\r\n"}, {"input": "inites liala\r\n", "output": "NO\r\n"}, {"input": "inites petr\r\n", "output": "NO\r\n"}, {"input": "inites petra\r\n", "output": "NO\r\n"}, {"input": "inites initis\r\n", "output": "NO\r\n"}, {"input": "inites inites\r\n", "output": "NO\r\n"}, {"input": "lios lios lios\r\n", "output": "NO\r\n"}, {"input": "lios lios liala\r\n", "output": "NO\r\n"}, {"input": "lios lios etr\r\n", "output": "YES\r\n"}, {"input": "lios lios etra\r\n", "output": "NO\r\n"}, {"input": "lios lios initis\r\n", "output": "NO\r\n"}, {"input": "lios lios inites\r\n", "output": "NO\r\n"}, {"input": "lios liala lios\r\n", "output": "NO\r\n"}, {"input": "lios liala liala\r\n", "output": "NO\r\n"}, {"input": "lios liala etr\r\n", "output": "NO\r\n"}, {"input": "lios liala etra\r\n", "output": "NO\r\n"}, {"input": "lios liala initis\r\n", "output": "NO\r\n"}, {"input": "lios liala inites\r\n", "output": "NO\r\n"}, {"input": "lios etr lios\r\n", "output": "NO\r\n"}, {"input": "lios etr liala\r\n", "output": "NO\r\n"}, {"input": "lios etr etr\r\n", "output": "NO\r\n"}, {"input": "lios etr etra\r\n", "output": "NO\r\n"}, {"input": "lios etr initis\r\n", "output": "YES\r\n"}, {"input": "lios etr inites\r\n", "output": "NO\r\n"}, {"input": "lios etra lios\r\n", "output": "NO\r\n"}, {"input": "lios etra liala\r\n", "output": "NO\r\n"}, {"input": "lios etra etr\r\n", "output": "NO\r\n"}, {"input": "lios etra etra\r\n", "output": "NO\r\n"}, {"input": "lios etra initis\r\n", "output": "NO\r\n"}, {"input": "lios etra inites\r\n", "output": "NO\r\n"}, {"input": "lios initis lios\r\n", "output": "NO\r\n"}, {"input": "lios initis liala\r\n", "output": "NO\r\n"}, {"input": "lios initis etr\r\n", "output": "NO\r\n"}, {"input": "lios initis etra\r\n", "output": "NO\r\n"}, {"input": "lios initis initis\r\n", "output": "NO\r\n"}, {"input": "lios initis inites\r\n", "output": "NO\r\n"}, {"input": "lios inites lios\r\n", "output": "NO\r\n"}, {"input": "lios inites liala\r\n", "output": "NO\r\n"}, {"input": "lios inites etr\r\n", "output": "NO\r\n"}, {"input": "lios inites etra\r\n", "output": "NO\r\n"}, {"input": "lios inites initis\r\n", "output": "NO\r\n"}, {"input": "lios inites inites\r\n", "output": "NO\r\n"}, {"input": "liala lios lios\r\n", "output": "NO\r\n"}, {"input": "liala lios liala\r\n", "output": "NO\r\n"}, {"input": "liala lios etr\r\n", "output": "NO\r\n"}, {"input": "liala lios etra\r\n", "output": "NO\r\n"}, {"input": "liala lios initis\r\n", "output": "NO\r\n"}, {"input": "liala lios inites\r\n", "output": "NO\r\n"}, {"input": "liala liala lios\r\n", "output": "NO\r\n"}, {"input": "liala liala liala\r\n", "output": "NO\r\n"}, {"input": "liala liala etr\r\n", "output": "NO\r\n"}, {"input": "liala liala etra\r\n", "output": "YES\r\n"}, {"input": "liala liala initis\r\n", "output": "NO\r\n"}, {"input": "liala liala inites\r\n", "output": "NO\r\n"}, {"input": "liala etr lios\r\n", "output": "NO\r\n"}, {"input": "liala etr liala\r\n", "output": "NO\r\n"}, {"input": "liala etr etr\r\n", "output": "NO\r\n"}, {"input": "liala etr etra\r\n", "output": "NO\r\n"}, {"input": "liala etr initis\r\n", "output": "NO\r\n"}, {"input": "liala etr inites\r\n", "output": "NO\r\n"}, {"input": "liala etra lios\r\n", "output": "NO\r\n"}, {"input": "liala etra liala\r\n", "output": "NO\r\n"}, {"input": "liala etra etr\r\n", "output": "NO\r\n"}, {"input": "liala etra etra\r\n", "output": "NO\r\n"}, {"input": "liala etra initis\r\n", "output": "NO\r\n"}, {"input": "liala etra inites\r\n", "output": "YES\r\n"}, {"input": "liala initis lios\r\n", "output": "NO\r\n"}, {"input": "liala initis liala\r\n", "output": "NO\r\n"}, {"input": "liala initis etr\r\n", "output": "NO\r\n"}, {"input": "liala initis etra\r\n", "output": "NO\r\n"}, {"input": "liala initis initis\r\n", "output": "NO\r\n"}, {"input": "liala initis inites\r\n", "output": "NO\r\n"}, {"input": "liala inites lios\r\n", "output": "NO\r\n"}, {"input": "liala inites liala\r\n", "output": "NO\r\n"}, {"input": "liala inites etr\r\n", "output": "NO\r\n"}, {"input": "liala inites etra\r\n", "output": "NO\r\n"}, {"input": "liala inites initis\r\n", "output": "NO\r\n"}, {"input": "liala inites inites\r\n", "output": "NO\r\n"}, {"input": "etr lios lios\r\n", "output": "NO\r\n"}, {"input": "etr lios liala\r\n", "output": "NO\r\n"}, {"input": "etr lios etr\r\n", "output": "NO\r\n"}, {"input": "etr lios etra\r\n", "output": "NO\r\n"}, {"input": "etr lios initis\r\n", "output": "NO\r\n"}, {"input": "etr lios inites\r\n", "output": "NO\r\n"}, {"input": "etr liala lios\r\n", "output": "NO\r\n"}, {"input": "etr liala liala\r\n", "output": "NO\r\n"}, {"input": "etr liala etr\r\n", "output": "NO\r\n"}, {"input": "etr liala etra\r\n", "output": "NO\r\n"}, {"input": "etr liala initis\r\n", "output": "NO\r\n"}, {"input": "etr liala inites\r\n", "output": "NO\r\n"}, {"input": "etr etr lios\r\n", "output": "NO\r\n"}, {"input": "etr etr liala\r\n", "output": "NO\r\n"}, {"input": "etr etr etr\r\n", "output": "NO\r\n"}, {"input": "etr etr etra\r\n", "output": "NO\r\n"}, {"input": "etr etr initis\r\n", "output": "NO\r\n"}, {"input": "etr etr inites\r\n", "output": "NO\r\n"}, {"input": "etr etra lios\r\n", "output": "NO\r\n"}, {"input": "etr etra liala\r\n", "output": "NO\r\n"}, {"input": "etr etra etr\r\n", "output": "NO\r\n"}, {"input": "etr etra etra\r\n", "output": "NO\r\n"}, {"input": "etr etra initis\r\n", "output": "NO\r\n"}, {"input": "etr etra inites\r\n", "output": "NO\r\n"}, {"input": "etr initis lios\r\n", "output": "NO\r\n"}, {"input": "etr initis liala\r\n", "output": "NO\r\n"}, {"input": "etr initis etr\r\n", "output": "NO\r\n"}, {"input": "etr initis etra\r\n", "output": "NO\r\n"}, {"input": "etr initis initis\r\n", "output": "YES\r\n"}, {"input": "etr initis inites\r\n", "output": "NO\r\n"}, {"input": "etr inites lios\r\n", "output": "NO\r\n"}, {"input": "etr inites liala\r\n", "output": "NO\r\n"}, {"input": "etr inites etr\r\n", "output": "NO\r\n"}, {"input": "etr inites etra\r\n", "output": "NO\r\n"}, {"input": "etr inites initis\r\n", "output": "NO\r\n"}, {"input": "etr inites inites\r\n", "output": "NO\r\n"}, {"input": "etra lios lios\r\n", "output": "NO\r\n"}, {"input": "etra lios liala\r\n", "output": "NO\r\n"}, {"input": "etra lios etr\r\n", "output": "NO\r\n"}, {"input": "etra lios etra\r\n", "output": "NO\r\n"}, {"input": "etra lios initis\r\n", "output": "NO\r\n"}, {"input": "etra lios inites\r\n", "output": "NO\r\n"}, {"input": "etra liala lios\r\n", "output": "NO\r\n"}, {"input": "etra liala liala\r\n", "output": "NO\r\n"}, {"input": "etra liala etr\r\n", "output": "NO\r\n"}, {"input": "etra liala etra\r\n", "output": "NO\r\n"}, {"input": "etra liala initis\r\n", "output": "NO\r\n"}, {"input": "etra liala inites\r\n", "output": "NO\r\n"}, {"input": "etra etr lios\r\n", "output": "NO\r\n"}, {"input": "etra etr liala\r\n", "output": "NO\r\n"}, {"input": "etra etr etr\r\n", "output": "NO\r\n"}, {"input": "etra etr etra\r\n", "output": "NO\r\n"}, {"input": "etra etr initis\r\n", "output": "NO\r\n"}, {"input": "etra etr inites\r\n", "output": "NO\r\n"}, {"input": "etra etra lios\r\n", "output": "NO\r\n"}, {"input": "etra etra liala\r\n", "output": "NO\r\n"}, {"input": "etra etra etr\r\n", "output": "NO\r\n"}, {"input": "etra etra etra\r\n", "output": "NO\r\n"}, {"input": "etra etra initis\r\n", "output": "NO\r\n"}, {"input": "etra etra inites\r\n", "output": "NO\r\n"}, {"input": "etra initis lios\r\n", "output": "NO\r\n"}, {"input": "etra initis liala\r\n", "output": "NO\r\n"}, {"input": "etra initis etr\r\n", "output": "NO\r\n"}, {"input": "etra initis etra\r\n", "output": "NO\r\n"}, {"input": "etra initis initis\r\n", "output": "NO\r\n"}, {"input": "etra initis inites\r\n", "output": "NO\r\n"}, {"input": "etra inites lios\r\n", "output": "NO\r\n"}, {"input": "etra inites liala\r\n", "output": "NO\r\n"}, {"input": "etra inites etr\r\n", "output": "NO\r\n"}, {"input": "etra inites etra\r\n", "output": "NO\r\n"}, {"input": "etra inites initis\r\n", "output": "NO\r\n"}, {"input": "etra inites inites\r\n", "output": "YES\r\n"}, {"input": "initis lios lios\r\n", "output": "NO\r\n"}, {"input": "initis lios liala\r\n", "output": "NO\r\n"}, {"input": "initis lios etr\r\n", "output": "NO\r\n"}, {"input": "initis lios etra\r\n", "output": "NO\r\n"}, {"input": "initis lios initis\r\n", "output": "NO\r\n"}, {"input": "initis lios inites\r\n", "output": "NO\r\n"}, {"input": "initis liala lios\r\n", "output": "NO\r\n"}, {"input": "initis liala liala\r\n", "output": "NO\r\n"}, {"input": "initis liala etr\r\n", "output": "NO\r\n"}, {"input": "initis liala etra\r\n", "output": "NO\r\n"}, {"input": "initis liala initis\r\n", "output": "NO\r\n"}, {"input": "initis liala inites\r\n", "output": "NO\r\n"}, {"input": "initis etr lios\r\n", "output": "NO\r\n"}, {"input": "initis etr liala\r\n", "output": "NO\r\n"}, {"input": "initis etr etr\r\n", "output": "NO\r\n"}, {"input": "initis etr etra\r\n", "output": "NO\r\n"}, {"input": "initis etr initis\r\n", "output": "NO\r\n"}, {"input": "initis etr inites\r\n", "output": "NO\r\n"}, {"input": "initis etra lios\r\n", "output": "NO\r\n"}, {"input": "initis etra liala\r\n", "output": "NO\r\n"}, {"input": "initis etra etr\r\n", "output": "NO\r\n"}, {"input": "initis etra etra\r\n", "output": "NO\r\n"}, {"input": "initis etra initis\r\n", "output": "NO\r\n"}, {"input": "initis etra inites\r\n", "output": "NO\r\n"}, {"input": "initis initis lios\r\n", "output": "NO\r\n"}, {"input": "initis initis liala\r\n", "output": "NO\r\n"}, {"input": "initis initis etr\r\n", "output": "NO\r\n"}, {"input": "initis initis etra\r\n", "output": "NO\r\n"}, {"input": "initis initis initis\r\n", "output": "NO\r\n"}, {"input": "initis initis inites\r\n", "output": "NO\r\n"}, {"input": "initis inites lios\r\n", "output": "NO\r\n"}, {"input": "initis inites liala\r\n", "output": "NO\r\n"}, {"input": "initis inites etr\r\n", "output": "NO\r\n"}, {"input": "initis inites etra\r\n", "output": "NO\r\n"}, {"input": "initis inites initis\r\n", "output": "NO\r\n"}, {"input": "initis inites inites\r\n", "output": "NO\r\n"}, {"input": "inites lios lios\r\n", "output": "NO\r\n"}, {"input": "inites lios liala\r\n", "output": "NO\r\n"}, {"input": "inites lios etr\r\n", "output": "NO\r\n"}, {"input": "inites lios etra\r\n", "output": "NO\r\n"}, {"input": "inites lios initis\r\n", "output": "NO\r\n"}, {"input": "inites lios inites\r\n", "output": "NO\r\n"}, {"input": "inites liala lios\r\n", "output": "NO\r\n"}, {"input": "inites liala liala\r\n", "output": "NO\r\n"}, {"input": "inites liala etr\r\n", "output": "NO\r\n"}, {"input": "inites liala etra\r\n", "output": "NO\r\n"}, {"input": "inites liala initis\r\n", "output": "NO\r\n"}, {"input": "inites liala inites\r\n", "output": "NO\r\n"}, {"input": "inites etr lios\r\n", "output": "NO\r\n"}, {"input": "inites etr liala\r\n", "output": "NO\r\n"}, {"input": "inites etr etr\r\n", "output": "NO\r\n"}, {"input": "inites etr etra\r\n", "output": "NO\r\n"}, {"input": "inites etr initis\r\n", "output": "NO\r\n"}, {"input": "inites etr inites\r\n", "output": "NO\r\n"}, {"input": "inites etra lios\r\n", "output": "NO\r\n"}, {"input": "inites etra liala\r\n", "output": "NO\r\n"}, {"input": "inites etra etr\r\n", "output": "NO\r\n"}, {"input": "inites etra etra\r\n", "output": "NO\r\n"}, {"input": "inites etra initis\r\n", "output": "NO\r\n"}, {"input": "inites etra inites\r\n", "output": "NO\r\n"}, {"input": "inites initis lios\r\n", "output": "NO\r\n"}, {"input": "inites initis liala\r\n", "output": "NO\r\n"}, {"input": "inites initis etr\r\n", "output": "NO\r\n"}, {"input": "inites initis etra\r\n", "output": "NO\r\n"}, {"input": "inites initis initis\r\n", "output": "NO\r\n"}, {"input": "inites initis inites\r\n", "output": "NO\r\n"}, {"input": "inites inites lios\r\n", "output": "NO\r\n"}, {"input": "inites inites liala\r\n", "output": "NO\r\n"}, {"input": "inites inites etr\r\n", "output": "NO\r\n"}, {"input": "inites inites etra\r\n", "output": "NO\r\n"}, {"input": "inites inites initis\r\n", "output": "NO\r\n"}, {"input": "inites inites inites\r\n", "output": "NO\r\n"}]
| false |
stdio
| null | true |
113/A
|
113
|
A
|
PyPy 3-64
|
TESTS
| 146 | 156 | 716,800 |
171980063
|
from collections import defaultdict as dc
words=input().split()
ends=['lios','liala','etr','etra','initis','inites']
adjm,adjf,verbm,verbf,nounm,nounf,=set(),set(),set(),set(),set(),set()
for s in words:
n=len(s)
for i in ends:
idx=len(s)-len(i)
if idx<0:continue
j,flag=0,0
while idx<len(s) and j<len(i):
if s[idx]!=i[j]:flag=1; break
idx+=1; j+=1
if flag:continue
if i=='lios':adjm.add(s)
elif i=='liala':adjf.add(s)
elif i=='etr':nounm.add(s)
elif i=='etra':nounf.add(s)
elif i=='initis':verbm.add(s)
elif i=='inites':verbf.add(s)
break
if len(adjm)+len(adjf)+len(verbm)+len(verbf)+len(nounm)+len(nounf)!=len(words):print("NO"); quit()
if(len(adjm)+len(adjf)+len(verbm)+len(verbf)+len(nounm)+len(nounf))==1:print("YES"); quit()
if (len(adjm) or len(verbm) or len(nounm)):
if (len(adjf) or len(verbf) or len(nounf)):print("NO"); quit()
if len(nounm)!=1:print("NO"); quit()
ad,no,vb=0,0,0
for i in range(len(words)):
if words[i] in adjm:
if no or vb:print("NO"); quit()
else:ad=1
elif words[i] in nounm:
if vb:print("NO"); quit()
else:no=1
else:
if no==0:print("NO"); quit()
else:vb=1
print("YES"); quit()
if (len(adjf) or len(verbf) or len(nounf)):
if (len(adjm) or len(verbm) or len(nounm)):print("NO"); quit()
if len(nounf)!=1:print("NO"); quit()
ad,no,vb=0,0,0
for i in range(len(words)):
if words[i] in adjf:
if no or vb:print("NO"); quit()
else:ad=1
elif words[i] in nounf:
if vb:print("NO"); quit()
else:no=1
else:
if no==0:print("NO"); quit()
else:vb=1
print("YES")
| 360 | 92 | 102,400 |
214687216
|
from sys import stdin, stdout
x = stdin.readline().replace("\n","")
lst = x.split(' ')
genderLst = []
typeLst = []
valid = 1
for x in lst:
if x.endswith("lios") or x.endswith("etr") or x.endswith("initis"):
genderLst.append(1)
elif x.endswith("liala") or x.endswith("etra") or x.endswith("inites"):
genderLst.append(0)
else:
valid = 0
if valid == 0:
print("NO")
exit()
for x in lst:
if(x.endswith("lios") or x.endswith("liala")):
typeLst.append(1)
if(x.endswith("etr") or x.endswith("etra")):
typeLst.append(2)
if(x.endswith("initis") or x.endswith("inites")):
typeLst.append(3)
if genderLst[0] == 1 and 0 in genderLst:
valid = 0
if genderLst[0] == 0 and 1 in genderLst:
valid = 0
if(len(typeLst) != 1):
if typeLst.count(2) != 1:
valid = 0
i = 0
while i < len(typeLst) and typeLst[i] == 1:
i += 1
while i < len(typeLst) and typeLst[i] == 2:
i += 1
while i < len(typeLst) and typeLst[i] == 3:
i += 1
if i != len(typeLst):
valid = 0
if(valid):
print ("YES")
else:
print("NO")
|
Codeforces Beta Round 86 (Div. 1 Only)
|
CF
| 2,011 | 5 | 256 |
Grammar Lessons
|
Petya got interested in grammar on his third year in school. He invented his own language called Petya's. Petya wanted to create a maximally simple language that would be enough to chat with friends, that's why all the language's grammar can be described with the following set of rules:
- There are three parts of speech: the adjective, the noun, the verb. Each word in his language is an adjective, noun or verb.
- There are two genders: masculine and feminine. Each word in his language has gender either masculine or feminine.
- Masculine adjectives end with -lios, and feminine adjectives end with -liala.
- Masculine nouns end with -etr, and feminime nouns end with -etra.
- Masculine verbs end with -initis, and feminime verbs end with -inites.
- Thus, each word in the Petya's language has one of the six endings, given above. There are no other endings in Petya's language.
- It is accepted that the whole word consists of an ending. That is, words "lios", "liala", "etr" and so on belong to the Petya's language.
- There aren't any punctuation marks, grammatical tenses, singular/plural forms or other language complications.
- A sentence is either exactly one valid language word or exactly one statement.
Statement is any sequence of the Petya's language, that satisfy both conditions:
- Words in statement follow in the following order (from the left to the right): zero or more adjectives followed by exactly one noun followed by zero or more verbs.
- All words in the statement should have the same gender.
After Petya's friend Vasya wrote instant messenger (an instant messaging program) that supported the Petya's language, Petya wanted to add spelling and grammar checking to the program. As Vasya was in the country and Petya didn't feel like waiting, he asked you to help him with this problem. Your task is to define by a given sequence of words, whether it is true that the given text represents exactly one sentence in Petya's language.
|
The first line contains one or more words consisting of lowercase Latin letters. The overall number of characters (including letters and spaces) does not exceed 105.
It is guaranteed that any two consecutive words are separated by exactly one space and the input data do not contain any other spaces. It is possible that given words do not belong to the Petya's language.
|
If some word of the given text does not belong to the Petya's language or if the text contains more that one sentence, print "NO" (without the quotes). Otherwise, print "YES" (without the quotes).
| null | null |
[{"input": "petr", "output": "YES"}, {"input": "etis atis animatis etis atis amatis", "output": "NO"}, {"input": "nataliala kataliala vetra feinites", "output": "YES"}]
| 1,600 |
["implementation", "strings"]
| 360 |
[{"input": "petr\r\n", "output": "YES\r\n"}, {"input": "etis atis animatis etis atis amatis\r\n", "output": "NO\r\n"}, {"input": "nataliala kataliala vetra feinites\r\n", "output": "YES\r\n"}, {"input": "qweasbvflios\r\n", "output": "YES\r\n"}, {"input": "lios lios petr initis qwe\r\n", "output": "NO\r\n"}, {"input": "lios initis\r\n", "output": "NO\r\n"}, {"input": "petr initis lios\r\n", "output": "NO\r\n"}, {"input": "petra petra petra\r\n", "output": "NO\r\n"}, {"input": "in\r\n", "output": "NO\r\n"}, {"input": "liala petra initis\r\n", "output": "NO\r\n"}, {"input": "liala petra inites\r\n", "output": "YES\r\n"}, {"input": "liala initis\r\n", "output": "NO\r\n"}, {"input": "liala petra petr inites\r\n", "output": "NO\r\n"}, {"input": "liala petr inites\r\n", "output": "NO\r\n"}, {"input": "llilitos\r\n", "output": "NO\r\n"}, {"input": "i i i i i i i i i i i i i i i a a a a a a v v v v v v v v v v v\r\n", "output": "NO\r\n"}, {"input": "hqaagnslliola vdumwjqalkyzbybwcaomxyffbkufaarhoebrqlpgshbmvjbwchfolyniuqkrysdhakzzrbiznhatifkbrqruswzhkewvgarmqtuadmsiquueumnpftiulfdpvzqfdgcfscczfsqivcdbuqvtyujirjwohskuabufdkehctkkguvetra oxnpizgojsrtinites\r\n", "output": "NO\r\n"}, {"input": "etretra linites\r\n", "output": "YES\r\n"}, {"input": "petretra petr\r\n", "output": "NO\r\n"}, {"input": "lialalios petraveryfunnypetr\r\n", "output": "YES\r\n"}, {"input": "petropetrapetr petra\r\n", "output": "NO\r\n"}, {"input": "lios petrnonono\r\n", "output": "NO\r\n"}, {"input": "lios petr initisandinitisandliala petrainitis\r\n", "output": "NO\r\n"}, {"input": "petro\r\n", "output": "NO\r\n"}, {"input": "petr initesinitis\r\n", "output": "YES\r\n"}, {"input": "lios initis\r\n", "output": "NO\r\n"}, {"input": "liala initespetra\r\n", "output": "YES\r\n"}, {"input": "lios petrapetr\r\n", "output": "YES\r\n"}, {"input": "initis petr\r\n", "output": "NO\r\n"}, {"input": "lioslialapetrpetrainitisinitesliosliala initesinitislioslialapetrpetrainitisinitetra\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixpetr\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixpetra\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixinitis\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixinites\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixliala\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixlios\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixlialas\r\n", "output": "NO\r\n"}, {"input": "veryfunnyprefixliala veryfunnyprefixpetretra\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixlios veryfunnyprefixinitisetr\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixlios aabbinitis\r\n", "output": "NO\r\n"}, {"input": "veryfunnyprefixlios inites\r\n", "output": "NO\r\n"}, {"input": "lios petr initis\r\n", "output": "YES\r\n"}, {"input": "liala etra inites\r\n", "output": "YES\r\n"}, {"input": "lios\r\n", "output": "YES\r\n"}, {"input": "liala\r\n", "output": "YES\r\n"}, {"input": "initis\r\n", "output": "YES\r\n"}, {"input": "inites\r\n", "output": "YES\r\n"}, {"input": "tes\r\n", "output": "NO\r\n"}, {"input": "tr\r\n", "output": "NO\r\n"}, {"input": "a\r\n", "output": "NO\r\n"}, {"input": "lios lios\r\n", "output": "NO\r\n"}, {"input": "lios\r\n", "output": "YES\r\n"}, {"input": "liala\r\n", "output": "YES\r\n"}, {"input": "petr\r\n", "output": "YES\r\n"}, {"input": "petra\r\n", "output": "YES\r\n"}, {"input": "pinitis\r\n", "output": "YES\r\n"}, {"input": "pinites\r\n", "output": "YES\r\n"}, {"input": "plios pliala\r\n", "output": "NO\r\n"}, {"input": "plios petr\r\n", "output": "YES\r\n"}, {"input": "plios petra\r\n", "output": "NO\r\n"}, {"input": "plios plios\r\n", "output": "NO\r\n"}, {"input": "plios initis\r\n", "output": "NO\r\n"}, {"input": "plios pinites\r\n", "output": "NO\r\n"}, {"input": "pliala plios\r\n", "output": "NO\r\n"}, {"input": "pliala ppliala\r\n", "output": "NO\r\n"}, {"input": "pliala petr\r\n", "output": "NO\r\n"}, {"input": "pliala petra\r\n", "output": "YES\r\n"}, {"input": "pliala pinitis\r\n", "output": "NO\r\n"}, {"input": "pliala pinites\r\n", "output": "NO\r\n"}, {"input": "petr plios\r\n", "output": "NO\r\n"}, {"input": "petr pliala\r\n", "output": "NO\r\n"}, {"input": "petr petr\r\n", "output": "NO\r\n"}, {"input": "petr petra\r\n", "output": "NO\r\n"}, {"input": "petr pinitis\r\n", "output": "YES\r\n"}, {"input": "petr pinites\r\n", "output": "NO\r\n"}, {"input": "petra lios\r\n", "output": "NO\r\n"}, {"input": "petra liala\r\n", "output": "NO\r\n"}, {"input": "petra petr\r\n", "output": "NO\r\n"}, {"input": "petra petra\r\n", "output": "NO\r\n"}, {"input": "petra initis\r\n", "output": "NO\r\n"}, {"input": "petra inites\r\n", "output": "YES\r\n"}, {"input": "initis lios\r\n", "output": "NO\r\n"}, {"input": "initis liala\r\n", "output": "NO\r\n"}, {"input": "initis petr\r\n", "output": "NO\r\n"}, {"input": "initis petra\r\n", "output": "NO\r\n"}, {"input": "initis initis\r\n", "output": "NO\r\n"}, {"input": "initis inites\r\n", "output": "NO\r\n"}, {"input": "inites lios\r\n", "output": "NO\r\n"}, {"input": "inites liala\r\n", "output": "NO\r\n"}, {"input": "inites petr\r\n", "output": "NO\r\n"}, {"input": "inites petra\r\n", "output": "NO\r\n"}, {"input": "inites initis\r\n", "output": "NO\r\n"}, {"input": "inites inites\r\n", "output": "NO\r\n"}, {"input": "lios lios lios\r\n", "output": "NO\r\n"}, {"input": "lios lios liala\r\n", "output": "NO\r\n"}, {"input": "lios lios etr\r\n", "output": "YES\r\n"}, {"input": "lios lios etra\r\n", "output": "NO\r\n"}, {"input": "lios lios initis\r\n", "output": "NO\r\n"}, {"input": "lios lios inites\r\n", "output": "NO\r\n"}, {"input": "lios liala lios\r\n", "output": "NO\r\n"}, {"input": "lios liala liala\r\n", "output": "NO\r\n"}, {"input": "lios liala etr\r\n", "output": "NO\r\n"}, {"input": "lios liala etra\r\n", "output": "NO\r\n"}, {"input": "lios liala initis\r\n", "output": "NO\r\n"}, {"input": "lios liala inites\r\n", "output": "NO\r\n"}, {"input": "lios etr lios\r\n", "output": "NO\r\n"}, {"input": "lios etr liala\r\n", "output": "NO\r\n"}, {"input": "lios etr etr\r\n", "output": "NO\r\n"}, {"input": "lios etr etra\r\n", "output": "NO\r\n"}, {"input": "lios etr initis\r\n", "output": "YES\r\n"}, {"input": "lios etr inites\r\n", "output": "NO\r\n"}, {"input": "lios etra lios\r\n", "output": "NO\r\n"}, {"input": "lios etra liala\r\n", "output": "NO\r\n"}, {"input": "lios etra etr\r\n", "output": "NO\r\n"}, {"input": "lios etra etra\r\n", "output": "NO\r\n"}, {"input": "lios etra initis\r\n", "output": "NO\r\n"}, {"input": "lios etra inites\r\n", "output": "NO\r\n"}, {"input": "lios initis lios\r\n", "output": "NO\r\n"}, {"input": "lios initis liala\r\n", "output": "NO\r\n"}, {"input": "lios initis etr\r\n", "output": "NO\r\n"}, {"input": "lios initis etra\r\n", "output": "NO\r\n"}, {"input": "lios initis initis\r\n", "output": "NO\r\n"}, {"input": "lios initis inites\r\n", "output": "NO\r\n"}, {"input": "lios inites lios\r\n", "output": "NO\r\n"}, {"input": "lios inites liala\r\n", "output": "NO\r\n"}, {"input": "lios inites etr\r\n", "output": "NO\r\n"}, {"input": "lios inites etra\r\n", "output": "NO\r\n"}, {"input": "lios inites initis\r\n", "output": "NO\r\n"}, {"input": "lios inites inites\r\n", "output": "NO\r\n"}, {"input": "liala lios lios\r\n", "output": "NO\r\n"}, {"input": "liala lios liala\r\n", "output": "NO\r\n"}, {"input": "liala lios etr\r\n", "output": "NO\r\n"}, {"input": "liala lios etra\r\n", "output": "NO\r\n"}, {"input": "liala lios initis\r\n", "output": "NO\r\n"}, {"input": "liala lios inites\r\n", "output": "NO\r\n"}, {"input": "liala liala lios\r\n", "output": "NO\r\n"}, {"input": "liala liala liala\r\n", "output": "NO\r\n"}, {"input": "liala liala etr\r\n", "output": "NO\r\n"}, {"input": "liala liala etra\r\n", "output": "YES\r\n"}, {"input": "liala liala initis\r\n", "output": "NO\r\n"}, {"input": "liala liala inites\r\n", "output": "NO\r\n"}, {"input": "liala etr lios\r\n", "output": "NO\r\n"}, {"input": "liala etr liala\r\n", "output": "NO\r\n"}, {"input": "liala etr etr\r\n", "output": "NO\r\n"}, {"input": "liala etr etra\r\n", "output": "NO\r\n"}, {"input": "liala etr initis\r\n", "output": "NO\r\n"}, {"input": "liala etr inites\r\n", "output": "NO\r\n"}, {"input": "liala etra lios\r\n", "output": "NO\r\n"}, {"input": "liala etra liala\r\n", "output": "NO\r\n"}, {"input": "liala etra etr\r\n", "output": "NO\r\n"}, {"input": "liala etra etra\r\n", "output": "NO\r\n"}, {"input": "liala etra initis\r\n", "output": "NO\r\n"}, {"input": "liala etra inites\r\n", "output": "YES\r\n"}, {"input": "liala initis lios\r\n", "output": "NO\r\n"}, {"input": "liala initis liala\r\n", "output": "NO\r\n"}, {"input": "liala initis etr\r\n", "output": "NO\r\n"}, {"input": "liala initis etra\r\n", "output": "NO\r\n"}, {"input": "liala initis initis\r\n", "output": "NO\r\n"}, {"input": "liala initis inites\r\n", "output": "NO\r\n"}, {"input": "liala inites lios\r\n", "output": "NO\r\n"}, {"input": "liala inites liala\r\n", "output": "NO\r\n"}, {"input": "liala inites etr\r\n", "output": "NO\r\n"}, {"input": "liala inites etra\r\n", "output": "NO\r\n"}, {"input": "liala inites initis\r\n", "output": "NO\r\n"}, {"input": "liala inites inites\r\n", "output": "NO\r\n"}, {"input": "etr lios lios\r\n", "output": "NO\r\n"}, {"input": "etr lios liala\r\n", "output": "NO\r\n"}, {"input": "etr lios etr\r\n", "output": "NO\r\n"}, {"input": "etr lios etra\r\n", "output": "NO\r\n"}, {"input": "etr lios initis\r\n", "output": "NO\r\n"}, {"input": "etr lios inites\r\n", "output": "NO\r\n"}, {"input": "etr liala lios\r\n", "output": "NO\r\n"}, {"input": "etr liala liala\r\n", "output": "NO\r\n"}, {"input": "etr liala etr\r\n", "output": "NO\r\n"}, {"input": "etr liala etra\r\n", "output": "NO\r\n"}, {"input": "etr liala initis\r\n", "output": "NO\r\n"}, {"input": "etr liala inites\r\n", "output": "NO\r\n"}, {"input": "etr etr lios\r\n", "output": "NO\r\n"}, {"input": "etr etr liala\r\n", "output": "NO\r\n"}, {"input": "etr etr etr\r\n", "output": "NO\r\n"}, {"input": "etr etr etra\r\n", "output": "NO\r\n"}, {"input": "etr etr initis\r\n", "output": "NO\r\n"}, {"input": "etr etr inites\r\n", "output": "NO\r\n"}, {"input": "etr etra lios\r\n", "output": "NO\r\n"}, {"input": "etr etra liala\r\n", "output": "NO\r\n"}, {"input": "etr etra etr\r\n", "output": "NO\r\n"}, {"input": "etr etra etra\r\n", "output": "NO\r\n"}, {"input": "etr etra initis\r\n", "output": "NO\r\n"}, {"input": "etr etra inites\r\n", "output": "NO\r\n"}, {"input": "etr initis lios\r\n", "output": "NO\r\n"}, {"input": "etr initis liala\r\n", "output": "NO\r\n"}, {"input": "etr initis etr\r\n", "output": "NO\r\n"}, {"input": "etr initis etra\r\n", "output": "NO\r\n"}, {"input": "etr initis initis\r\n", "output": "YES\r\n"}, {"input": "etr initis inites\r\n", "output": "NO\r\n"}, {"input": "etr inites lios\r\n", "output": "NO\r\n"}, {"input": "etr inites liala\r\n", "output": "NO\r\n"}, {"input": "etr inites etr\r\n", "output": "NO\r\n"}, {"input": "etr inites etra\r\n", "output": "NO\r\n"}, {"input": "etr inites initis\r\n", "output": "NO\r\n"}, {"input": "etr inites inites\r\n", "output": "NO\r\n"}, {"input": "etra lios lios\r\n", "output": "NO\r\n"}, {"input": "etra lios liala\r\n", "output": "NO\r\n"}, {"input": "etra lios etr\r\n", "output": "NO\r\n"}, {"input": "etra lios etra\r\n", "output": "NO\r\n"}, {"input": "etra lios initis\r\n", "output": "NO\r\n"}, {"input": "etra lios inites\r\n", "output": "NO\r\n"}, {"input": "etra liala lios\r\n", "output": "NO\r\n"}, {"input": "etra liala liala\r\n", "output": "NO\r\n"}, {"input": "etra liala etr\r\n", "output": "NO\r\n"}, {"input": "etra liala etra\r\n", "output": "NO\r\n"}, {"input": "etra liala initis\r\n", "output": "NO\r\n"}, {"input": "etra liala inites\r\n", "output": "NO\r\n"}, {"input": "etra etr lios\r\n", "output": "NO\r\n"}, {"input": "etra etr liala\r\n", "output": "NO\r\n"}, {"input": "etra etr etr\r\n", "output": "NO\r\n"}, {"input": "etra etr etra\r\n", "output": "NO\r\n"}, {"input": "etra etr initis\r\n", "output": "NO\r\n"}, {"input": "etra etr inites\r\n", "output": "NO\r\n"}, {"input": "etra etra lios\r\n", "output": "NO\r\n"}, {"input": "etra etra liala\r\n", "output": "NO\r\n"}, {"input": "etra etra etr\r\n", "output": "NO\r\n"}, {"input": "etra etra etra\r\n", "output": "NO\r\n"}, {"input": "etra etra initis\r\n", "output": "NO\r\n"}, {"input": "etra etra inites\r\n", "output": "NO\r\n"}, {"input": "etra initis lios\r\n", "output": "NO\r\n"}, {"input": "etra initis liala\r\n", "output": "NO\r\n"}, {"input": "etra initis etr\r\n", "output": "NO\r\n"}, {"input": "etra initis etra\r\n", "output": "NO\r\n"}, {"input": "etra initis initis\r\n", "output": "NO\r\n"}, {"input": "etra initis inites\r\n", "output": "NO\r\n"}, {"input": "etra inites lios\r\n", "output": "NO\r\n"}, {"input": "etra inites liala\r\n", "output": "NO\r\n"}, {"input": "etra inites etr\r\n", "output": "NO\r\n"}, {"input": "etra inites etra\r\n", "output": "NO\r\n"}, {"input": "etra inites initis\r\n", "output": "NO\r\n"}, {"input": "etra inites inites\r\n", "output": "YES\r\n"}, {"input": "initis lios lios\r\n", "output": "NO\r\n"}, {"input": "initis lios liala\r\n", "output": "NO\r\n"}, {"input": "initis lios etr\r\n", "output": "NO\r\n"}, {"input": "initis lios etra\r\n", "output": "NO\r\n"}, {"input": "initis lios initis\r\n", "output": "NO\r\n"}, {"input": "initis lios inites\r\n", "output": "NO\r\n"}, {"input": "initis liala lios\r\n", "output": "NO\r\n"}, {"input": "initis liala liala\r\n", "output": "NO\r\n"}, {"input": "initis liala etr\r\n", "output": "NO\r\n"}, {"input": "initis liala etra\r\n", "output": "NO\r\n"}, {"input": "initis liala initis\r\n", "output": "NO\r\n"}, {"input": "initis liala inites\r\n", "output": "NO\r\n"}, {"input": "initis etr lios\r\n", "output": "NO\r\n"}, {"input": "initis etr liala\r\n", "output": "NO\r\n"}, {"input": "initis etr etr\r\n", "output": "NO\r\n"}, {"input": "initis etr etra\r\n", "output": "NO\r\n"}, {"input": "initis etr initis\r\n", "output": "NO\r\n"}, {"input": "initis etr inites\r\n", "output": "NO\r\n"}, {"input": "initis etra lios\r\n", "output": "NO\r\n"}, {"input": "initis etra liala\r\n", "output": "NO\r\n"}, {"input": "initis etra etr\r\n", "output": "NO\r\n"}, {"input": "initis etra etra\r\n", "output": "NO\r\n"}, {"input": "initis etra initis\r\n", "output": "NO\r\n"}, {"input": "initis etra inites\r\n", "output": "NO\r\n"}, {"input": "initis initis lios\r\n", "output": "NO\r\n"}, {"input": "initis initis liala\r\n", "output": "NO\r\n"}, {"input": "initis initis etr\r\n", "output": "NO\r\n"}, {"input": "initis initis etra\r\n", "output": "NO\r\n"}, {"input": "initis initis initis\r\n", "output": "NO\r\n"}, {"input": "initis initis inites\r\n", "output": "NO\r\n"}, {"input": "initis inites lios\r\n", "output": "NO\r\n"}, {"input": "initis inites liala\r\n", "output": "NO\r\n"}, {"input": "initis inites etr\r\n", "output": "NO\r\n"}, {"input": "initis inites etra\r\n", "output": "NO\r\n"}, {"input": "initis inites initis\r\n", "output": "NO\r\n"}, {"input": "initis inites inites\r\n", "output": "NO\r\n"}, {"input": "inites lios lios\r\n", "output": "NO\r\n"}, {"input": "inites lios liala\r\n", "output": "NO\r\n"}, {"input": "inites lios etr\r\n", "output": "NO\r\n"}, {"input": "inites lios etra\r\n", "output": "NO\r\n"}, {"input": "inites lios initis\r\n", "output": "NO\r\n"}, {"input": "inites lios inites\r\n", "output": "NO\r\n"}, {"input": "inites liala lios\r\n", "output": "NO\r\n"}, {"input": "inites liala liala\r\n", "output": "NO\r\n"}, {"input": "inites liala etr\r\n", "output": "NO\r\n"}, {"input": "inites liala etra\r\n", "output": "NO\r\n"}, {"input": "inites liala initis\r\n", "output": "NO\r\n"}, {"input": "inites liala inites\r\n", "output": "NO\r\n"}, {"input": "inites etr lios\r\n", "output": "NO\r\n"}, {"input": "inites etr liala\r\n", "output": "NO\r\n"}, {"input": "inites etr etr\r\n", "output": "NO\r\n"}, {"input": "inites etr etra\r\n", "output": "NO\r\n"}, {"input": "inites etr initis\r\n", "output": "NO\r\n"}, {"input": "inites etr inites\r\n", "output": "NO\r\n"}, {"input": "inites etra lios\r\n", "output": "NO\r\n"}, {"input": "inites etra liala\r\n", "output": "NO\r\n"}, {"input": "inites etra etr\r\n", "output": "NO\r\n"}, {"input": "inites etra etra\r\n", "output": "NO\r\n"}, {"input": "inites etra initis\r\n", "output": "NO\r\n"}, {"input": "inites etra inites\r\n", "output": "NO\r\n"}, {"input": "inites initis lios\r\n", "output": "NO\r\n"}, {"input": "inites initis liala\r\n", "output": "NO\r\n"}, {"input": "inites initis etr\r\n", "output": "NO\r\n"}, {"input": "inites initis etra\r\n", "output": "NO\r\n"}, {"input": "inites initis initis\r\n", "output": "NO\r\n"}, {"input": "inites initis inites\r\n", "output": "NO\r\n"}, {"input": "inites inites lios\r\n", "output": "NO\r\n"}, {"input": "inites inites liala\r\n", "output": "NO\r\n"}, {"input": "inites inites etr\r\n", "output": "NO\r\n"}, {"input": "inites inites etra\r\n", "output": "NO\r\n"}, {"input": "inites inites initis\r\n", "output": "NO\r\n"}, {"input": "inites inites inites\r\n", "output": "NO\r\n"}]
| false |
stdio
| null | true |
113/A
|
113
|
A
|
PyPy 3-64
|
TESTS
| 101 | 124 | 204,800 |
212179196
|
def get_type(slovo):
slovo = slovo[::-1]
slovo += '#######'
if slovo[:4] == 'soil':
return [0, 0]
if slovo[:5] == 'alail':
return [0, 1]
if slovo[:3] == 'rte':
return [1, 0]
if slovo[:4] == 'arte':
return [1, 1]
if slovo[:6] == 'sitini':
return [2, 0]
if slovo[:6] == 'setini':
return [2, 1]
else:
return [-1, -1]
s = input().split()
rod = -1
type = 0
if len(s) == 1:
if get_type(s[0])[0] != -1:
print('YES')
else:
print('NO')
else:
for slovo in s:
w = get_type(slovo)
if w[0] == -1:
print('NO')
exit(0)
if rod == -1:
rod = w[1]
if w[0] == 1:
if type == 2 or w[1] != rod:
print('NO')
exit(0)
else:
type = 2
elif w[0] == 0:
if type == 2 or w[1] != rod:
print('NO')
exit(0)
elif w[0] == 2:
if type != 2 or w[1]!=rod:
print('NO')
exit(0)
print('YES')
| 360 | 92 | 102,400 |
227284427
|
# LUOGU_RID: 128399015
a = input().split()
c = 5 #设置一个变量,记录当前的状态
for b in a:
if c == 5:
if len(a) == 1:
if b[-4:] == 'lios' or b[-5:] == 'liala' or b[-3:] == 'etr' or b[-4:] == 'etra' or b[-6:] == 'initis' or b[-6:] == 'inites': #输入只有一个任意合法单词时也特判为合法
c = 0
elif b[-4:] == 'lios':
c = 1
elif b[-5:] == 'liala':
c = 2
elif b[-3:] == 'etr':
c = 3
elif b[-4:] == 'etra':
c = 4
else:
break
elif c == 1:
if b[-4:] == 'lios':
continue
elif b[-3:] == 'etr':
c = 3
else:
c = 5
break
elif c == 2:
if b[-5:] == 'liala':
continue
elif b[-4:] == 'etra':
c = 4
else:
c = 5
break
elif c == 3:
if b[-6:] == 'initis':
c = 6
else:
c = 5
break
elif c == 4:
if b[-6:] == 'inites':
c = 7
else:
c = 5
break
elif c == 6:
if b[-6:] == 'initis':
continue
else:
c = 5
break
else:
if b[-6:] == 'inites':
continue
else:
c = 5
break
if c in (1,2,5):
print('NO')
else:
print('YES')
|
Codeforces Beta Round 86 (Div. 1 Only)
|
CF
| 2,011 | 5 | 256 |
Grammar Lessons
|
Petya got interested in grammar on his third year in school. He invented his own language called Petya's. Petya wanted to create a maximally simple language that would be enough to chat with friends, that's why all the language's grammar can be described with the following set of rules:
- There are three parts of speech: the adjective, the noun, the verb. Each word in his language is an adjective, noun or verb.
- There are two genders: masculine and feminine. Each word in his language has gender either masculine or feminine.
- Masculine adjectives end with -lios, and feminine adjectives end with -liala.
- Masculine nouns end with -etr, and feminime nouns end with -etra.
- Masculine verbs end with -initis, and feminime verbs end with -inites.
- Thus, each word in the Petya's language has one of the six endings, given above. There are no other endings in Petya's language.
- It is accepted that the whole word consists of an ending. That is, words "lios", "liala", "etr" and so on belong to the Petya's language.
- There aren't any punctuation marks, grammatical tenses, singular/plural forms or other language complications.
- A sentence is either exactly one valid language word or exactly one statement.
Statement is any sequence of the Petya's language, that satisfy both conditions:
- Words in statement follow in the following order (from the left to the right): zero or more adjectives followed by exactly one noun followed by zero or more verbs.
- All words in the statement should have the same gender.
After Petya's friend Vasya wrote instant messenger (an instant messaging program) that supported the Petya's language, Petya wanted to add spelling and grammar checking to the program. As Vasya was in the country and Petya didn't feel like waiting, he asked you to help him with this problem. Your task is to define by a given sequence of words, whether it is true that the given text represents exactly one sentence in Petya's language.
|
The first line contains one or more words consisting of lowercase Latin letters. The overall number of characters (including letters and spaces) does not exceed 105.
It is guaranteed that any two consecutive words are separated by exactly one space and the input data do not contain any other spaces. It is possible that given words do not belong to the Petya's language.
|
If some word of the given text does not belong to the Petya's language or if the text contains more that one sentence, print "NO" (without the quotes). Otherwise, print "YES" (without the quotes).
| null | null |
[{"input": "petr", "output": "YES"}, {"input": "etis atis animatis etis atis amatis", "output": "NO"}, {"input": "nataliala kataliala vetra feinites", "output": "YES"}]
| 1,600 |
["implementation", "strings"]
| 360 |
[{"input": "petr\r\n", "output": "YES\r\n"}, {"input": "etis atis animatis etis atis amatis\r\n", "output": "NO\r\n"}, {"input": "nataliala kataliala vetra feinites\r\n", "output": "YES\r\n"}, {"input": "qweasbvflios\r\n", "output": "YES\r\n"}, {"input": "lios lios petr initis qwe\r\n", "output": "NO\r\n"}, {"input": "lios initis\r\n", "output": "NO\r\n"}, {"input": "petr initis lios\r\n", "output": "NO\r\n"}, {"input": "petra petra petra\r\n", "output": "NO\r\n"}, {"input": "in\r\n", "output": "NO\r\n"}, {"input": "liala petra initis\r\n", "output": "NO\r\n"}, {"input": "liala petra inites\r\n", "output": "YES\r\n"}, {"input": "liala initis\r\n", "output": "NO\r\n"}, {"input": "liala petra petr inites\r\n", "output": "NO\r\n"}, {"input": "liala petr inites\r\n", "output": "NO\r\n"}, {"input": "llilitos\r\n", "output": "NO\r\n"}, {"input": "i i i i i i i i i i i i i i i a a a a a a v v v v v v v v v v v\r\n", "output": "NO\r\n"}, {"input": "hqaagnslliola vdumwjqalkyzbybwcaomxyffbkufaarhoebrqlpgshbmvjbwchfolyniuqkrysdhakzzrbiznhatifkbrqruswzhkewvgarmqtuadmsiquueumnpftiulfdpvzqfdgcfscczfsqivcdbuqvtyujirjwohskuabufdkehctkkguvetra oxnpizgojsrtinites\r\n", "output": "NO\r\n"}, {"input": "etretra linites\r\n", "output": "YES\r\n"}, {"input": "petretra petr\r\n", "output": "NO\r\n"}, {"input": "lialalios petraveryfunnypetr\r\n", "output": "YES\r\n"}, {"input": "petropetrapetr petra\r\n", "output": "NO\r\n"}, {"input": "lios petrnonono\r\n", "output": "NO\r\n"}, {"input": "lios petr initisandinitisandliala petrainitis\r\n", "output": "NO\r\n"}, {"input": "petro\r\n", "output": "NO\r\n"}, {"input": "petr initesinitis\r\n", "output": "YES\r\n"}, {"input": "lios initis\r\n", "output": "NO\r\n"}, {"input": "liala initespetra\r\n", "output": "YES\r\n"}, {"input": "lios petrapetr\r\n", "output": "YES\r\n"}, {"input": "initis petr\r\n", "output": "NO\r\n"}, {"input": "lioslialapetrpetrainitisinitesliosliala initesinitislioslialapetrpetrainitisinitetra\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixpetr\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixpetra\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixinitis\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixinites\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixliala\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixlios\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixlialas\r\n", "output": "NO\r\n"}, {"input": "veryfunnyprefixliala veryfunnyprefixpetretra\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixlios veryfunnyprefixinitisetr\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixlios aabbinitis\r\n", "output": "NO\r\n"}, {"input": "veryfunnyprefixlios inites\r\n", "output": "NO\r\n"}, {"input": "lios petr initis\r\n", "output": "YES\r\n"}, {"input": "liala etra inites\r\n", "output": "YES\r\n"}, {"input": "lios\r\n", "output": "YES\r\n"}, {"input": "liala\r\n", "output": "YES\r\n"}, {"input": "initis\r\n", "output": "YES\r\n"}, {"input": "inites\r\n", "output": "YES\r\n"}, {"input": "tes\r\n", "output": "NO\r\n"}, {"input": "tr\r\n", "output": "NO\r\n"}, {"input": "a\r\n", "output": "NO\r\n"}, {"input": "lios lios\r\n", "output": "NO\r\n"}, {"input": "lios\r\n", "output": "YES\r\n"}, {"input": "liala\r\n", "output": "YES\r\n"}, {"input": "petr\r\n", "output": "YES\r\n"}, {"input": "petra\r\n", "output": "YES\r\n"}, {"input": "pinitis\r\n", "output": "YES\r\n"}, {"input": "pinites\r\n", "output": "YES\r\n"}, {"input": "plios pliala\r\n", "output": "NO\r\n"}, {"input": "plios petr\r\n", "output": "YES\r\n"}, {"input": "plios petra\r\n", "output": "NO\r\n"}, {"input": "plios plios\r\n", "output": "NO\r\n"}, {"input": "plios initis\r\n", "output": "NO\r\n"}, {"input": "plios pinites\r\n", "output": "NO\r\n"}, {"input": "pliala plios\r\n", "output": "NO\r\n"}, {"input": "pliala ppliala\r\n", "output": "NO\r\n"}, {"input": "pliala petr\r\n", "output": "NO\r\n"}, {"input": "pliala petra\r\n", "output": "YES\r\n"}, {"input": "pliala pinitis\r\n", "output": "NO\r\n"}, {"input": "pliala pinites\r\n", "output": "NO\r\n"}, {"input": "petr plios\r\n", "output": "NO\r\n"}, {"input": "petr pliala\r\n", "output": "NO\r\n"}, {"input": "petr petr\r\n", "output": "NO\r\n"}, {"input": "petr petra\r\n", "output": "NO\r\n"}, {"input": "petr pinitis\r\n", "output": "YES\r\n"}, {"input": "petr pinites\r\n", "output": "NO\r\n"}, {"input": "petra lios\r\n", "output": "NO\r\n"}, {"input": "petra liala\r\n", "output": "NO\r\n"}, {"input": "petra petr\r\n", "output": "NO\r\n"}, {"input": "petra petra\r\n", "output": "NO\r\n"}, {"input": "petra initis\r\n", "output": "NO\r\n"}, {"input": "petra inites\r\n", "output": "YES\r\n"}, {"input": "initis lios\r\n", "output": "NO\r\n"}, {"input": "initis liala\r\n", "output": "NO\r\n"}, {"input": "initis petr\r\n", "output": "NO\r\n"}, {"input": "initis petra\r\n", "output": "NO\r\n"}, {"input": "initis initis\r\n", "output": "NO\r\n"}, {"input": "initis inites\r\n", "output": "NO\r\n"}, {"input": "inites lios\r\n", "output": "NO\r\n"}, {"input": "inites liala\r\n", "output": "NO\r\n"}, {"input": "inites petr\r\n", "output": "NO\r\n"}, {"input": "inites petra\r\n", "output": "NO\r\n"}, {"input": "inites initis\r\n", "output": "NO\r\n"}, {"input": "inites inites\r\n", "output": "NO\r\n"}, {"input": "lios lios lios\r\n", "output": "NO\r\n"}, {"input": "lios lios liala\r\n", "output": "NO\r\n"}, {"input": "lios lios etr\r\n", "output": "YES\r\n"}, {"input": "lios lios etra\r\n", "output": "NO\r\n"}, {"input": "lios lios initis\r\n", "output": "NO\r\n"}, {"input": "lios lios inites\r\n", "output": "NO\r\n"}, {"input": "lios liala lios\r\n", "output": "NO\r\n"}, {"input": "lios liala liala\r\n", "output": "NO\r\n"}, {"input": "lios liala etr\r\n", "output": "NO\r\n"}, {"input": "lios liala etra\r\n", "output": "NO\r\n"}, {"input": "lios liala initis\r\n", "output": "NO\r\n"}, {"input": "lios liala inites\r\n", "output": "NO\r\n"}, {"input": "lios etr lios\r\n", "output": "NO\r\n"}, {"input": "lios etr liala\r\n", "output": "NO\r\n"}, {"input": "lios etr etr\r\n", "output": "NO\r\n"}, {"input": "lios etr etra\r\n", "output": "NO\r\n"}, {"input": "lios etr initis\r\n", "output": "YES\r\n"}, {"input": "lios etr inites\r\n", "output": "NO\r\n"}, {"input": "lios etra lios\r\n", "output": "NO\r\n"}, {"input": "lios etra liala\r\n", "output": "NO\r\n"}, {"input": "lios etra etr\r\n", "output": "NO\r\n"}, {"input": "lios etra etra\r\n", "output": "NO\r\n"}, {"input": "lios etra initis\r\n", "output": "NO\r\n"}, {"input": "lios etra inites\r\n", "output": "NO\r\n"}, {"input": "lios initis lios\r\n", "output": "NO\r\n"}, {"input": "lios initis liala\r\n", "output": "NO\r\n"}, {"input": "lios initis etr\r\n", "output": "NO\r\n"}, {"input": "lios initis etra\r\n", "output": "NO\r\n"}, {"input": "lios initis initis\r\n", "output": "NO\r\n"}, {"input": "lios initis inites\r\n", "output": "NO\r\n"}, {"input": "lios inites lios\r\n", "output": "NO\r\n"}, {"input": "lios inites liala\r\n", "output": "NO\r\n"}, {"input": "lios inites etr\r\n", "output": "NO\r\n"}, {"input": "lios inites etra\r\n", "output": "NO\r\n"}, {"input": "lios inites initis\r\n", "output": "NO\r\n"}, {"input": "lios inites inites\r\n", "output": "NO\r\n"}, {"input": "liala lios lios\r\n", "output": "NO\r\n"}, {"input": "liala lios liala\r\n", "output": "NO\r\n"}, {"input": "liala lios etr\r\n", "output": "NO\r\n"}, {"input": "liala lios etra\r\n", "output": "NO\r\n"}, {"input": "liala lios initis\r\n", "output": "NO\r\n"}, {"input": "liala lios inites\r\n", "output": "NO\r\n"}, {"input": "liala liala lios\r\n", "output": "NO\r\n"}, {"input": "liala liala liala\r\n", "output": "NO\r\n"}, {"input": "liala liala etr\r\n", "output": "NO\r\n"}, {"input": "liala liala etra\r\n", "output": "YES\r\n"}, {"input": "liala liala initis\r\n", "output": "NO\r\n"}, {"input": "liala liala inites\r\n", "output": "NO\r\n"}, {"input": "liala etr lios\r\n", "output": "NO\r\n"}, {"input": "liala etr liala\r\n", "output": "NO\r\n"}, {"input": "liala etr etr\r\n", "output": "NO\r\n"}, {"input": "liala etr etra\r\n", "output": "NO\r\n"}, {"input": "liala etr initis\r\n", "output": "NO\r\n"}, {"input": "liala etr inites\r\n", "output": "NO\r\n"}, {"input": "liala etra lios\r\n", "output": "NO\r\n"}, {"input": "liala etra liala\r\n", "output": "NO\r\n"}, {"input": "liala etra etr\r\n", "output": "NO\r\n"}, {"input": "liala etra etra\r\n", "output": "NO\r\n"}, {"input": "liala etra initis\r\n", "output": "NO\r\n"}, {"input": "liala etra inites\r\n", "output": "YES\r\n"}, {"input": "liala initis lios\r\n", "output": "NO\r\n"}, {"input": "liala initis liala\r\n", "output": "NO\r\n"}, {"input": "liala initis etr\r\n", "output": "NO\r\n"}, {"input": "liala initis etra\r\n", "output": "NO\r\n"}, {"input": "liala initis initis\r\n", "output": "NO\r\n"}, {"input": "liala initis inites\r\n", "output": "NO\r\n"}, {"input": "liala inites lios\r\n", "output": "NO\r\n"}, {"input": "liala inites liala\r\n", "output": "NO\r\n"}, {"input": "liala inites etr\r\n", "output": "NO\r\n"}, {"input": "liala inites etra\r\n", "output": "NO\r\n"}, {"input": "liala inites initis\r\n", "output": "NO\r\n"}, {"input": "liala inites inites\r\n", "output": "NO\r\n"}, {"input": "etr lios lios\r\n", "output": "NO\r\n"}, {"input": "etr lios liala\r\n", "output": "NO\r\n"}, {"input": "etr lios etr\r\n", "output": "NO\r\n"}, {"input": "etr lios etra\r\n", "output": "NO\r\n"}, {"input": "etr lios initis\r\n", "output": "NO\r\n"}, {"input": "etr lios inites\r\n", "output": "NO\r\n"}, {"input": "etr liala lios\r\n", "output": "NO\r\n"}, {"input": "etr liala liala\r\n", "output": "NO\r\n"}, {"input": "etr liala etr\r\n", "output": "NO\r\n"}, {"input": "etr liala etra\r\n", "output": "NO\r\n"}, {"input": "etr liala initis\r\n", "output": "NO\r\n"}, {"input": "etr liala inites\r\n", "output": "NO\r\n"}, {"input": "etr etr lios\r\n", "output": "NO\r\n"}, {"input": "etr etr liala\r\n", "output": "NO\r\n"}, {"input": "etr etr etr\r\n", "output": "NO\r\n"}, {"input": "etr etr etra\r\n", "output": "NO\r\n"}, {"input": "etr etr initis\r\n", "output": "NO\r\n"}, {"input": "etr etr inites\r\n", "output": "NO\r\n"}, {"input": "etr etra lios\r\n", "output": "NO\r\n"}, {"input": "etr etra liala\r\n", "output": "NO\r\n"}, {"input": "etr etra etr\r\n", "output": "NO\r\n"}, {"input": "etr etra etra\r\n", "output": "NO\r\n"}, {"input": "etr etra initis\r\n", "output": "NO\r\n"}, {"input": "etr etra inites\r\n", "output": "NO\r\n"}, {"input": "etr initis lios\r\n", "output": "NO\r\n"}, {"input": "etr initis liala\r\n", "output": "NO\r\n"}, {"input": "etr initis etr\r\n", "output": "NO\r\n"}, {"input": "etr initis etra\r\n", "output": "NO\r\n"}, {"input": "etr initis initis\r\n", "output": "YES\r\n"}, {"input": "etr initis inites\r\n", "output": "NO\r\n"}, {"input": "etr inites lios\r\n", "output": "NO\r\n"}, {"input": "etr inites liala\r\n", "output": "NO\r\n"}, {"input": "etr inites etr\r\n", "output": "NO\r\n"}, {"input": "etr inites etra\r\n", "output": "NO\r\n"}, {"input": "etr inites initis\r\n", "output": "NO\r\n"}, {"input": "etr inites inites\r\n", "output": "NO\r\n"}, {"input": "etra lios lios\r\n", "output": "NO\r\n"}, {"input": "etra lios liala\r\n", "output": "NO\r\n"}, {"input": "etra lios etr\r\n", "output": "NO\r\n"}, {"input": "etra lios etra\r\n", "output": "NO\r\n"}, {"input": "etra lios initis\r\n", "output": "NO\r\n"}, {"input": "etra lios inites\r\n", "output": "NO\r\n"}, {"input": "etra liala lios\r\n", "output": "NO\r\n"}, {"input": "etra liala liala\r\n", "output": "NO\r\n"}, {"input": "etra liala etr\r\n", "output": "NO\r\n"}, {"input": "etra liala etra\r\n", "output": "NO\r\n"}, {"input": "etra liala initis\r\n", "output": "NO\r\n"}, {"input": "etra liala inites\r\n", "output": "NO\r\n"}, {"input": "etra etr lios\r\n", "output": "NO\r\n"}, {"input": "etra etr liala\r\n", "output": "NO\r\n"}, {"input": "etra etr etr\r\n", "output": "NO\r\n"}, {"input": "etra etr etra\r\n", "output": "NO\r\n"}, {"input": "etra etr initis\r\n", "output": "NO\r\n"}, {"input": "etra etr inites\r\n", "output": "NO\r\n"}, {"input": "etra etra lios\r\n", "output": "NO\r\n"}, {"input": "etra etra liala\r\n", "output": "NO\r\n"}, {"input": "etra etra etr\r\n", "output": "NO\r\n"}, {"input": "etra etra etra\r\n", "output": "NO\r\n"}, {"input": "etra etra initis\r\n", "output": "NO\r\n"}, {"input": "etra etra inites\r\n", "output": "NO\r\n"}, {"input": "etra initis lios\r\n", "output": "NO\r\n"}, {"input": "etra initis liala\r\n", "output": "NO\r\n"}, {"input": "etra initis etr\r\n", "output": "NO\r\n"}, {"input": "etra initis etra\r\n", "output": "NO\r\n"}, {"input": "etra initis initis\r\n", "output": "NO\r\n"}, {"input": "etra initis inites\r\n", "output": "NO\r\n"}, {"input": "etra inites lios\r\n", "output": "NO\r\n"}, {"input": "etra inites liala\r\n", "output": "NO\r\n"}, {"input": "etra inites etr\r\n", "output": "NO\r\n"}, {"input": "etra inites etra\r\n", "output": "NO\r\n"}, {"input": "etra inites initis\r\n", "output": "NO\r\n"}, {"input": "etra inites inites\r\n", "output": "YES\r\n"}, {"input": "initis lios lios\r\n", "output": "NO\r\n"}, {"input": "initis lios liala\r\n", "output": "NO\r\n"}, {"input": "initis lios etr\r\n", "output": "NO\r\n"}, {"input": "initis lios etra\r\n", "output": "NO\r\n"}, {"input": "initis lios initis\r\n", "output": "NO\r\n"}, {"input": "initis lios inites\r\n", "output": "NO\r\n"}, {"input": "initis liala lios\r\n", "output": "NO\r\n"}, {"input": "initis liala liala\r\n", "output": "NO\r\n"}, {"input": "initis liala etr\r\n", "output": "NO\r\n"}, {"input": "initis liala etra\r\n", "output": "NO\r\n"}, {"input": "initis liala initis\r\n", "output": "NO\r\n"}, {"input": "initis liala inites\r\n", "output": "NO\r\n"}, {"input": "initis etr lios\r\n", "output": "NO\r\n"}, {"input": "initis etr liala\r\n", "output": "NO\r\n"}, {"input": "initis etr etr\r\n", "output": "NO\r\n"}, {"input": "initis etr etra\r\n", "output": "NO\r\n"}, {"input": "initis etr initis\r\n", "output": "NO\r\n"}, {"input": "initis etr inites\r\n", "output": "NO\r\n"}, {"input": "initis etra lios\r\n", "output": "NO\r\n"}, {"input": "initis etra liala\r\n", "output": "NO\r\n"}, {"input": "initis etra etr\r\n", "output": "NO\r\n"}, {"input": "initis etra etra\r\n", "output": "NO\r\n"}, {"input": "initis etra initis\r\n", "output": "NO\r\n"}, {"input": "initis etra inites\r\n", "output": "NO\r\n"}, {"input": "initis initis lios\r\n", "output": "NO\r\n"}, {"input": "initis initis liala\r\n", "output": "NO\r\n"}, {"input": "initis initis etr\r\n", "output": "NO\r\n"}, {"input": "initis initis etra\r\n", "output": "NO\r\n"}, {"input": "initis initis initis\r\n", "output": "NO\r\n"}, {"input": "initis initis inites\r\n", "output": "NO\r\n"}, {"input": "initis inites lios\r\n", "output": "NO\r\n"}, {"input": "initis inites liala\r\n", "output": "NO\r\n"}, {"input": "initis inites etr\r\n", "output": "NO\r\n"}, {"input": "initis inites etra\r\n", "output": "NO\r\n"}, {"input": "initis inites initis\r\n", "output": "NO\r\n"}, {"input": "initis inites inites\r\n", "output": "NO\r\n"}, {"input": "inites lios lios\r\n", "output": "NO\r\n"}, {"input": "inites lios liala\r\n", "output": "NO\r\n"}, {"input": "inites lios etr\r\n", "output": "NO\r\n"}, {"input": "inites lios etra\r\n", "output": "NO\r\n"}, {"input": "inites lios initis\r\n", "output": "NO\r\n"}, {"input": "inites lios inites\r\n", "output": "NO\r\n"}, {"input": "inites liala lios\r\n", "output": "NO\r\n"}, {"input": "inites liala liala\r\n", "output": "NO\r\n"}, {"input": "inites liala etr\r\n", "output": "NO\r\n"}, {"input": "inites liala etra\r\n", "output": "NO\r\n"}, {"input": "inites liala initis\r\n", "output": "NO\r\n"}, {"input": "inites liala inites\r\n", "output": "NO\r\n"}, {"input": "inites etr lios\r\n", "output": "NO\r\n"}, {"input": "inites etr liala\r\n", "output": "NO\r\n"}, {"input": "inites etr etr\r\n", "output": "NO\r\n"}, {"input": "inites etr etra\r\n", "output": "NO\r\n"}, {"input": "inites etr initis\r\n", "output": "NO\r\n"}, {"input": "inites etr inites\r\n", "output": "NO\r\n"}, {"input": "inites etra lios\r\n", "output": "NO\r\n"}, {"input": "inites etra liala\r\n", "output": "NO\r\n"}, {"input": "inites etra etr\r\n", "output": "NO\r\n"}, {"input": "inites etra etra\r\n", "output": "NO\r\n"}, {"input": "inites etra initis\r\n", "output": "NO\r\n"}, {"input": "inites etra inites\r\n", "output": "NO\r\n"}, {"input": "inites initis lios\r\n", "output": "NO\r\n"}, {"input": "inites initis liala\r\n", "output": "NO\r\n"}, {"input": "inites initis etr\r\n", "output": "NO\r\n"}, {"input": "inites initis etra\r\n", "output": "NO\r\n"}, {"input": "inites initis initis\r\n", "output": "NO\r\n"}, {"input": "inites initis inites\r\n", "output": "NO\r\n"}, {"input": "inites inites lios\r\n", "output": "NO\r\n"}, {"input": "inites inites liala\r\n", "output": "NO\r\n"}, {"input": "inites inites etr\r\n", "output": "NO\r\n"}, {"input": "inites inites etra\r\n", "output": "NO\r\n"}, {"input": "inites inites initis\r\n", "output": "NO\r\n"}, {"input": "inites inites inites\r\n", "output": "NO\r\n"}]
| false |
stdio
| null | true |
113/A
|
113
|
A
|
PyPy 3-64
|
TESTS
| 7 | 124 | 614,400 |
171980252
|
from collections import defaultdict as dc
words=input().split()
ends=['lios','liala','etr','etra','initis','inites']
adjm,adjf,verbm,verbf,nounm,nounf,=set(),set(),set(),set(),set(),set()
frq=dc(lambda:0)
for s in words:
n=len(s)
for i in ends:
idx=len(s)-len(i)
if idx<0:continue
j,flag=0,0
while idx<len(s) and j<len(i):
if s[idx]!=i[j]:flag=1; break
idx+=1; j+=1
if flag:continue
if i=='lios':adjm.add(s);
elif i=='liala':adjf.add(s)
elif i=='etr':nounm.add(s)
elif i=='etra':nounf.add(s)
elif i=='initis':verbm.add(s)
elif i=='inites':verbf.add(s)
frq[s]+=1
break
ctr=0
for i in frq:ctr+=frq[i]
if ctr!=len(words):print("NO"); quit()
if ctr==1:print("YES"); quit()
if (len(adjm) or len(verbm) or len(nounm)):
if (len(adjf) or len(verbf) or len(nounf)):print("NO"); quit()
if len(nounm)!=1:print("NO"); quit()
ad,no,vb=0,0,0
for i in range(len(words)):
if words[i] in adjm:
if no or vb:print("NO"); quit()
else:ad=1
elif words[i] in nounm:
if vb:print("NO"); quit()
else:no=1
else:
if no==0:print("NO"); quit()
else:vb=1
print("YES"); quit()
if (len(adjf) or len(verbf) or len(nounf)):
if (len(adjm) or len(verbm) or len(nounm)):print("NO"); quit()
if len(nounf)!=1:print("NO"); quit()
ad,no,vb=0,0,0
for i in range(len(words)):
if words[i] in adjf:
if no or vb:print("NO"); quit()
else:ad=1
elif words[i] in nounf:
if vb:print("NO"); quit()
else:no=1
else:
if no==0:print("NO"); quit()
else:vb=1
print("YES")
| 360 | 122 | 4,710,400 |
157359820
|
n = input().split()
w = 0
x=y=z=0
r=s=t=0
while w<len(n):
if n[w][-4:]=="lios" or n[w][-5:]=="liala":
if n[w][-4:]=="lios":
x+=1
w+=1
else:
r+=1
w+=1
else:
break
while w<len(n):
if n[w][-3:]=="etr" or n[w][-4:]=="etra":
if n[w][-3:]=="etr":
y+=1
w+=1
else:
s+=1
w+=1
else:
break
while w<len(n):
if n[w][-6:]=="initis" or n[w][-6:]=="inites":
if n[w][-6:]=="initis":
z+=1
w+=1
else:
t+=1
w+=1
else:
break
if len(n)==1 and (x==1 or y==1 or z==1 ):
print("YES")
elif len(n)==1 and (r==1 or s==1 or t==1):
print("YES")
elif y==1 and x+y+z==len(n) and s==0:
print("YES")
elif y==0 and r+s+t==len(n) and s==1:
print("YES")
else:
print("NO")
|
Codeforces Beta Round 86 (Div. 1 Only)
|
CF
| 2,011 | 5 | 256 |
Grammar Lessons
|
Petya got interested in grammar on his third year in school. He invented his own language called Petya's. Petya wanted to create a maximally simple language that would be enough to chat with friends, that's why all the language's grammar can be described with the following set of rules:
- There are three parts of speech: the adjective, the noun, the verb. Each word in his language is an adjective, noun or verb.
- There are two genders: masculine and feminine. Each word in his language has gender either masculine or feminine.
- Masculine adjectives end with -lios, and feminine adjectives end with -liala.
- Masculine nouns end with -etr, and feminime nouns end with -etra.
- Masculine verbs end with -initis, and feminime verbs end with -inites.
- Thus, each word in the Petya's language has one of the six endings, given above. There are no other endings in Petya's language.
- It is accepted that the whole word consists of an ending. That is, words "lios", "liala", "etr" and so on belong to the Petya's language.
- There aren't any punctuation marks, grammatical tenses, singular/plural forms or other language complications.
- A sentence is either exactly one valid language word or exactly one statement.
Statement is any sequence of the Petya's language, that satisfy both conditions:
- Words in statement follow in the following order (from the left to the right): zero or more adjectives followed by exactly one noun followed by zero or more verbs.
- All words in the statement should have the same gender.
After Petya's friend Vasya wrote instant messenger (an instant messaging program) that supported the Petya's language, Petya wanted to add spelling and grammar checking to the program. As Vasya was in the country and Petya didn't feel like waiting, he asked you to help him with this problem. Your task is to define by a given sequence of words, whether it is true that the given text represents exactly one sentence in Petya's language.
|
The first line contains one or more words consisting of lowercase Latin letters. The overall number of characters (including letters and spaces) does not exceed 105.
It is guaranteed that any two consecutive words are separated by exactly one space and the input data do not contain any other spaces. It is possible that given words do not belong to the Petya's language.
|
If some word of the given text does not belong to the Petya's language or if the text contains more that one sentence, print "NO" (without the quotes). Otherwise, print "YES" (without the quotes).
| null | null |
[{"input": "petr", "output": "YES"}, {"input": "etis atis animatis etis atis amatis", "output": "NO"}, {"input": "nataliala kataliala vetra feinites", "output": "YES"}]
| 1,600 |
["implementation", "strings"]
| 360 |
[{"input": "petr\r\n", "output": "YES\r\n"}, {"input": "etis atis animatis etis atis amatis\r\n", "output": "NO\r\n"}, {"input": "nataliala kataliala vetra feinites\r\n", "output": "YES\r\n"}, {"input": "qweasbvflios\r\n", "output": "YES\r\n"}, {"input": "lios lios petr initis qwe\r\n", "output": "NO\r\n"}, {"input": "lios initis\r\n", "output": "NO\r\n"}, {"input": "petr initis lios\r\n", "output": "NO\r\n"}, {"input": "petra petra petra\r\n", "output": "NO\r\n"}, {"input": "in\r\n", "output": "NO\r\n"}, {"input": "liala petra initis\r\n", "output": "NO\r\n"}, {"input": "liala petra inites\r\n", "output": "YES\r\n"}, {"input": "liala initis\r\n", "output": "NO\r\n"}, {"input": "liala petra petr inites\r\n", "output": "NO\r\n"}, {"input": "liala petr inites\r\n", "output": "NO\r\n"}, {"input": "llilitos\r\n", "output": "NO\r\n"}, {"input": "i i i i i i i i i i i i i i i a a a a a a v v v v v v v v v v v\r\n", "output": "NO\r\n"}, {"input": "hqaagnslliola vdumwjqalkyzbybwcaomxyffbkufaarhoebrqlpgshbmvjbwchfolyniuqkrysdhakzzrbiznhatifkbrqruswzhkewvgarmqtuadmsiquueumnpftiulfdpvzqfdgcfscczfsqivcdbuqvtyujirjwohskuabufdkehctkkguvetra oxnpizgojsrtinites\r\n", "output": "NO\r\n"}, {"input": "etretra linites\r\n", "output": "YES\r\n"}, {"input": "petretra petr\r\n", "output": "NO\r\n"}, {"input": "lialalios petraveryfunnypetr\r\n", "output": "YES\r\n"}, {"input": "petropetrapetr petra\r\n", "output": "NO\r\n"}, {"input": "lios petrnonono\r\n", "output": "NO\r\n"}, {"input": "lios petr initisandinitisandliala petrainitis\r\n", "output": "NO\r\n"}, {"input": "petro\r\n", "output": "NO\r\n"}, {"input": "petr initesinitis\r\n", "output": "YES\r\n"}, {"input": "lios initis\r\n", "output": "NO\r\n"}, {"input": "liala initespetra\r\n", "output": "YES\r\n"}, {"input": "lios petrapetr\r\n", "output": "YES\r\n"}, {"input": "initis petr\r\n", "output": "NO\r\n"}, {"input": "lioslialapetrpetrainitisinitesliosliala initesinitislioslialapetrpetrainitisinitetra\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixpetr\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixpetra\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixinitis\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixinites\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixliala\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixlios\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixlialas\r\n", "output": "NO\r\n"}, {"input": "veryfunnyprefixliala veryfunnyprefixpetretra\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixlios veryfunnyprefixinitisetr\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixlios aabbinitis\r\n", "output": "NO\r\n"}, {"input": "veryfunnyprefixlios inites\r\n", "output": "NO\r\n"}, {"input": "lios petr initis\r\n", "output": "YES\r\n"}, {"input": "liala etra inites\r\n", "output": "YES\r\n"}, {"input": "lios\r\n", "output": "YES\r\n"}, {"input": "liala\r\n", "output": "YES\r\n"}, {"input": "initis\r\n", "output": "YES\r\n"}, {"input": "inites\r\n", "output": "YES\r\n"}, {"input": "tes\r\n", "output": "NO\r\n"}, {"input": "tr\r\n", "output": "NO\r\n"}, {"input": "a\r\n", "output": "NO\r\n"}, {"input": "lios lios\r\n", "output": "NO\r\n"}, {"input": "lios\r\n", "output": "YES\r\n"}, {"input": "liala\r\n", "output": "YES\r\n"}, {"input": "petr\r\n", "output": "YES\r\n"}, {"input": "petra\r\n", "output": "YES\r\n"}, {"input": "pinitis\r\n", "output": "YES\r\n"}, {"input": "pinites\r\n", "output": "YES\r\n"}, {"input": "plios pliala\r\n", "output": "NO\r\n"}, {"input": "plios petr\r\n", "output": "YES\r\n"}, {"input": "plios petra\r\n", "output": "NO\r\n"}, {"input": "plios plios\r\n", "output": "NO\r\n"}, {"input": "plios initis\r\n", "output": "NO\r\n"}, {"input": "plios pinites\r\n", "output": "NO\r\n"}, {"input": "pliala plios\r\n", "output": "NO\r\n"}, {"input": "pliala ppliala\r\n", "output": "NO\r\n"}, {"input": "pliala petr\r\n", "output": "NO\r\n"}, {"input": "pliala petra\r\n", "output": "YES\r\n"}, {"input": "pliala pinitis\r\n", "output": "NO\r\n"}, {"input": "pliala pinites\r\n", "output": "NO\r\n"}, {"input": "petr plios\r\n", "output": "NO\r\n"}, {"input": "petr pliala\r\n", "output": "NO\r\n"}, {"input": "petr petr\r\n", "output": "NO\r\n"}, {"input": "petr petra\r\n", "output": "NO\r\n"}, {"input": "petr pinitis\r\n", "output": "YES\r\n"}, {"input": "petr pinites\r\n", "output": "NO\r\n"}, {"input": "petra lios\r\n", "output": "NO\r\n"}, {"input": "petra liala\r\n", "output": "NO\r\n"}, {"input": "petra petr\r\n", "output": "NO\r\n"}, {"input": "petra petra\r\n", "output": "NO\r\n"}, {"input": "petra initis\r\n", "output": "NO\r\n"}, {"input": "petra inites\r\n", "output": "YES\r\n"}, {"input": "initis lios\r\n", "output": "NO\r\n"}, {"input": "initis liala\r\n", "output": "NO\r\n"}, {"input": "initis petr\r\n", "output": "NO\r\n"}, {"input": "initis petra\r\n", "output": "NO\r\n"}, {"input": "initis initis\r\n", "output": "NO\r\n"}, {"input": "initis inites\r\n", "output": "NO\r\n"}, {"input": "inites lios\r\n", "output": "NO\r\n"}, {"input": "inites liala\r\n", "output": "NO\r\n"}, {"input": "inites petr\r\n", "output": "NO\r\n"}, {"input": "inites petra\r\n", "output": "NO\r\n"}, {"input": "inites initis\r\n", "output": "NO\r\n"}, {"input": "inites inites\r\n", "output": "NO\r\n"}, {"input": "lios lios lios\r\n", "output": "NO\r\n"}, {"input": "lios lios liala\r\n", "output": "NO\r\n"}, {"input": "lios lios etr\r\n", "output": "YES\r\n"}, {"input": "lios lios etra\r\n", "output": "NO\r\n"}, {"input": "lios lios initis\r\n", "output": "NO\r\n"}, {"input": "lios lios inites\r\n", "output": "NO\r\n"}, {"input": "lios liala lios\r\n", "output": "NO\r\n"}, {"input": "lios liala liala\r\n", "output": "NO\r\n"}, {"input": "lios liala etr\r\n", "output": "NO\r\n"}, {"input": "lios liala etra\r\n", "output": "NO\r\n"}, {"input": "lios liala initis\r\n", "output": "NO\r\n"}, {"input": "lios liala inites\r\n", "output": "NO\r\n"}, {"input": "lios etr lios\r\n", "output": "NO\r\n"}, {"input": "lios etr liala\r\n", "output": "NO\r\n"}, {"input": "lios etr etr\r\n", "output": "NO\r\n"}, {"input": "lios etr etra\r\n", "output": "NO\r\n"}, {"input": "lios etr initis\r\n", "output": "YES\r\n"}, {"input": "lios etr inites\r\n", "output": "NO\r\n"}, {"input": "lios etra lios\r\n", "output": "NO\r\n"}, {"input": "lios etra liala\r\n", "output": "NO\r\n"}, {"input": "lios etra etr\r\n", "output": "NO\r\n"}, {"input": "lios etra etra\r\n", "output": "NO\r\n"}, {"input": "lios etra initis\r\n", "output": "NO\r\n"}, {"input": "lios etra inites\r\n", "output": "NO\r\n"}, {"input": "lios initis lios\r\n", "output": "NO\r\n"}, {"input": "lios initis liala\r\n", "output": "NO\r\n"}, {"input": "lios initis etr\r\n", "output": "NO\r\n"}, {"input": "lios initis etra\r\n", "output": "NO\r\n"}, {"input": "lios initis initis\r\n", "output": "NO\r\n"}, {"input": "lios initis inites\r\n", "output": "NO\r\n"}, {"input": "lios inites lios\r\n", "output": "NO\r\n"}, {"input": "lios inites liala\r\n", "output": "NO\r\n"}, {"input": "lios inites etr\r\n", "output": "NO\r\n"}, {"input": "lios inites etra\r\n", "output": "NO\r\n"}, {"input": "lios inites initis\r\n", "output": "NO\r\n"}, {"input": "lios inites inites\r\n", "output": "NO\r\n"}, {"input": "liala lios lios\r\n", "output": "NO\r\n"}, {"input": "liala lios liala\r\n", "output": "NO\r\n"}, {"input": "liala lios etr\r\n", "output": "NO\r\n"}, {"input": "liala lios etra\r\n", "output": "NO\r\n"}, {"input": "liala lios initis\r\n", "output": "NO\r\n"}, {"input": "liala lios inites\r\n", "output": "NO\r\n"}, {"input": "liala liala lios\r\n", "output": "NO\r\n"}, {"input": "liala liala liala\r\n", "output": "NO\r\n"}, {"input": "liala liala etr\r\n", "output": "NO\r\n"}, {"input": "liala liala etra\r\n", "output": "YES\r\n"}, {"input": "liala liala initis\r\n", "output": "NO\r\n"}, {"input": "liala liala inites\r\n", "output": "NO\r\n"}, {"input": "liala etr lios\r\n", "output": "NO\r\n"}, {"input": "liala etr liala\r\n", "output": "NO\r\n"}, {"input": "liala etr etr\r\n", "output": "NO\r\n"}, {"input": "liala etr etra\r\n", "output": "NO\r\n"}, {"input": "liala etr initis\r\n", "output": "NO\r\n"}, {"input": "liala etr inites\r\n", "output": "NO\r\n"}, {"input": "liala etra lios\r\n", "output": "NO\r\n"}, {"input": "liala etra liala\r\n", "output": "NO\r\n"}, {"input": "liala etra etr\r\n", "output": "NO\r\n"}, {"input": "liala etra etra\r\n", "output": "NO\r\n"}, {"input": "liala etra initis\r\n", "output": "NO\r\n"}, {"input": "liala etra inites\r\n", "output": "YES\r\n"}, {"input": "liala initis lios\r\n", "output": "NO\r\n"}, {"input": "liala initis liala\r\n", "output": "NO\r\n"}, {"input": "liala initis etr\r\n", "output": "NO\r\n"}, {"input": "liala initis etra\r\n", "output": "NO\r\n"}, {"input": "liala initis initis\r\n", "output": "NO\r\n"}, {"input": "liala initis inites\r\n", "output": "NO\r\n"}, {"input": "liala inites lios\r\n", "output": "NO\r\n"}, {"input": "liala inites liala\r\n", "output": "NO\r\n"}, {"input": "liala inites etr\r\n", "output": "NO\r\n"}, {"input": "liala inites etra\r\n", "output": "NO\r\n"}, {"input": "liala inites initis\r\n", "output": "NO\r\n"}, {"input": "liala inites inites\r\n", "output": "NO\r\n"}, {"input": "etr lios lios\r\n", "output": "NO\r\n"}, {"input": "etr lios liala\r\n", "output": "NO\r\n"}, {"input": "etr lios etr\r\n", "output": "NO\r\n"}, {"input": "etr lios etra\r\n", "output": "NO\r\n"}, {"input": "etr lios initis\r\n", "output": "NO\r\n"}, {"input": "etr lios inites\r\n", "output": "NO\r\n"}, {"input": "etr liala lios\r\n", "output": "NO\r\n"}, {"input": "etr liala liala\r\n", "output": "NO\r\n"}, {"input": "etr liala etr\r\n", "output": "NO\r\n"}, {"input": "etr liala etra\r\n", "output": "NO\r\n"}, {"input": "etr liala initis\r\n", "output": "NO\r\n"}, {"input": "etr liala inites\r\n", "output": "NO\r\n"}, {"input": "etr etr lios\r\n", "output": "NO\r\n"}, {"input": "etr etr liala\r\n", "output": "NO\r\n"}, {"input": "etr etr etr\r\n", "output": "NO\r\n"}, {"input": "etr etr etra\r\n", "output": "NO\r\n"}, {"input": "etr etr initis\r\n", "output": "NO\r\n"}, {"input": "etr etr inites\r\n", "output": "NO\r\n"}, {"input": "etr etra lios\r\n", "output": "NO\r\n"}, {"input": "etr etra liala\r\n", "output": "NO\r\n"}, {"input": "etr etra etr\r\n", "output": "NO\r\n"}, {"input": "etr etra etra\r\n", "output": "NO\r\n"}, {"input": "etr etra initis\r\n", "output": "NO\r\n"}, {"input": "etr etra inites\r\n", "output": "NO\r\n"}, {"input": "etr initis lios\r\n", "output": "NO\r\n"}, {"input": "etr initis liala\r\n", "output": "NO\r\n"}, {"input": "etr initis etr\r\n", "output": "NO\r\n"}, {"input": "etr initis etra\r\n", "output": "NO\r\n"}, {"input": "etr initis initis\r\n", "output": "YES\r\n"}, {"input": "etr initis inites\r\n", "output": "NO\r\n"}, {"input": "etr inites lios\r\n", "output": "NO\r\n"}, {"input": "etr inites liala\r\n", "output": "NO\r\n"}, {"input": "etr inites etr\r\n", "output": "NO\r\n"}, {"input": "etr inites etra\r\n", "output": "NO\r\n"}, {"input": "etr inites initis\r\n", "output": "NO\r\n"}, {"input": "etr inites inites\r\n", "output": "NO\r\n"}, {"input": "etra lios lios\r\n", "output": "NO\r\n"}, {"input": "etra lios liala\r\n", "output": "NO\r\n"}, {"input": "etra lios etr\r\n", "output": "NO\r\n"}, {"input": "etra lios etra\r\n", "output": "NO\r\n"}, {"input": "etra lios initis\r\n", "output": "NO\r\n"}, {"input": "etra lios inites\r\n", "output": "NO\r\n"}, {"input": "etra liala lios\r\n", "output": "NO\r\n"}, {"input": "etra liala liala\r\n", "output": "NO\r\n"}, {"input": "etra liala etr\r\n", "output": "NO\r\n"}, {"input": "etra liala etra\r\n", "output": "NO\r\n"}, {"input": "etra liala initis\r\n", "output": "NO\r\n"}, {"input": "etra liala inites\r\n", "output": "NO\r\n"}, {"input": "etra etr lios\r\n", "output": "NO\r\n"}, {"input": "etra etr liala\r\n", "output": "NO\r\n"}, {"input": "etra etr etr\r\n", "output": "NO\r\n"}, {"input": "etra etr etra\r\n", "output": "NO\r\n"}, {"input": "etra etr initis\r\n", "output": "NO\r\n"}, {"input": "etra etr inites\r\n", "output": "NO\r\n"}, {"input": "etra etra lios\r\n", "output": "NO\r\n"}, {"input": "etra etra liala\r\n", "output": "NO\r\n"}, {"input": "etra etra etr\r\n", "output": "NO\r\n"}, {"input": "etra etra etra\r\n", "output": "NO\r\n"}, {"input": "etra etra initis\r\n", "output": "NO\r\n"}, {"input": "etra etra inites\r\n", "output": "NO\r\n"}, {"input": "etra initis lios\r\n", "output": "NO\r\n"}, {"input": "etra initis liala\r\n", "output": "NO\r\n"}, {"input": "etra initis etr\r\n", "output": "NO\r\n"}, {"input": "etra initis etra\r\n", "output": "NO\r\n"}, {"input": "etra initis initis\r\n", "output": "NO\r\n"}, {"input": "etra initis inites\r\n", "output": "NO\r\n"}, {"input": "etra inites lios\r\n", "output": "NO\r\n"}, {"input": "etra inites liala\r\n", "output": "NO\r\n"}, {"input": "etra inites etr\r\n", "output": "NO\r\n"}, {"input": "etra inites etra\r\n", "output": "NO\r\n"}, {"input": "etra inites initis\r\n", "output": "NO\r\n"}, {"input": "etra inites inites\r\n", "output": "YES\r\n"}, {"input": "initis lios lios\r\n", "output": "NO\r\n"}, {"input": "initis lios liala\r\n", "output": "NO\r\n"}, {"input": "initis lios etr\r\n", "output": "NO\r\n"}, {"input": "initis lios etra\r\n", "output": "NO\r\n"}, {"input": "initis lios initis\r\n", "output": "NO\r\n"}, {"input": "initis lios inites\r\n", "output": "NO\r\n"}, {"input": "initis liala lios\r\n", "output": "NO\r\n"}, {"input": "initis liala liala\r\n", "output": "NO\r\n"}, {"input": "initis liala etr\r\n", "output": "NO\r\n"}, {"input": "initis liala etra\r\n", "output": "NO\r\n"}, {"input": "initis liala initis\r\n", "output": "NO\r\n"}, {"input": "initis liala inites\r\n", "output": "NO\r\n"}, {"input": "initis etr lios\r\n", "output": "NO\r\n"}, {"input": "initis etr liala\r\n", "output": "NO\r\n"}, {"input": "initis etr etr\r\n", "output": "NO\r\n"}, {"input": "initis etr etra\r\n", "output": "NO\r\n"}, {"input": "initis etr initis\r\n", "output": "NO\r\n"}, {"input": "initis etr inites\r\n", "output": "NO\r\n"}, {"input": "initis etra lios\r\n", "output": "NO\r\n"}, {"input": "initis etra liala\r\n", "output": "NO\r\n"}, {"input": "initis etra etr\r\n", "output": "NO\r\n"}, {"input": "initis etra etra\r\n", "output": "NO\r\n"}, {"input": "initis etra initis\r\n", "output": "NO\r\n"}, {"input": "initis etra inites\r\n", "output": "NO\r\n"}, {"input": "initis initis lios\r\n", "output": "NO\r\n"}, {"input": "initis initis liala\r\n", "output": "NO\r\n"}, {"input": "initis initis etr\r\n", "output": "NO\r\n"}, {"input": "initis initis etra\r\n", "output": "NO\r\n"}, {"input": "initis initis initis\r\n", "output": "NO\r\n"}, {"input": "initis initis inites\r\n", "output": "NO\r\n"}, {"input": "initis inites lios\r\n", "output": "NO\r\n"}, {"input": "initis inites liala\r\n", "output": "NO\r\n"}, {"input": "initis inites etr\r\n", "output": "NO\r\n"}, {"input": "initis inites etra\r\n", "output": "NO\r\n"}, {"input": "initis inites initis\r\n", "output": "NO\r\n"}, {"input": "initis inites inites\r\n", "output": "NO\r\n"}, {"input": "inites lios lios\r\n", "output": "NO\r\n"}, {"input": "inites lios liala\r\n", "output": "NO\r\n"}, {"input": "inites lios etr\r\n", "output": "NO\r\n"}, {"input": "inites lios etra\r\n", "output": "NO\r\n"}, {"input": "inites lios initis\r\n", "output": "NO\r\n"}, {"input": "inites lios inites\r\n", "output": "NO\r\n"}, {"input": "inites liala lios\r\n", "output": "NO\r\n"}, {"input": "inites liala liala\r\n", "output": "NO\r\n"}, {"input": "inites liala etr\r\n", "output": "NO\r\n"}, {"input": "inites liala etra\r\n", "output": "NO\r\n"}, {"input": "inites liala initis\r\n", "output": "NO\r\n"}, {"input": "inites liala inites\r\n", "output": "NO\r\n"}, {"input": "inites etr lios\r\n", "output": "NO\r\n"}, {"input": "inites etr liala\r\n", "output": "NO\r\n"}, {"input": "inites etr etr\r\n", "output": "NO\r\n"}, {"input": "inites etr etra\r\n", "output": "NO\r\n"}, {"input": "inites etr initis\r\n", "output": "NO\r\n"}, {"input": "inites etr inites\r\n", "output": "NO\r\n"}, {"input": "inites etra lios\r\n", "output": "NO\r\n"}, {"input": "inites etra liala\r\n", "output": "NO\r\n"}, {"input": "inites etra etr\r\n", "output": "NO\r\n"}, {"input": "inites etra etra\r\n", "output": "NO\r\n"}, {"input": "inites etra initis\r\n", "output": "NO\r\n"}, {"input": "inites etra inites\r\n", "output": "NO\r\n"}, {"input": "inites initis lios\r\n", "output": "NO\r\n"}, {"input": "inites initis liala\r\n", "output": "NO\r\n"}, {"input": "inites initis etr\r\n", "output": "NO\r\n"}, {"input": "inites initis etra\r\n", "output": "NO\r\n"}, {"input": "inites initis initis\r\n", "output": "NO\r\n"}, {"input": "inites initis inites\r\n", "output": "NO\r\n"}, {"input": "inites inites lios\r\n", "output": "NO\r\n"}, {"input": "inites inites liala\r\n", "output": "NO\r\n"}, {"input": "inites inites etr\r\n", "output": "NO\r\n"}, {"input": "inites inites etra\r\n", "output": "NO\r\n"}, {"input": "inites inites initis\r\n", "output": "NO\r\n"}, {"input": "inites inites inites\r\n", "output": "NO\r\n"}]
| false |
stdio
| null | true |
113/A
|
113
|
A
|
PyPy 3
|
TESTS
| 7 | 184 | 0 |
11937161
|
def pos(w):
if len(w) < 3:
return False
if w == 'etr' or w[-3:] == 'etr':
return 'MN'
if len(w) == 3:
return False
if w == 'lios' or w[-4:] == 'lios':
return 'MA'
if w == 'etra' or w[-4:] == 'etra':
return 'FN'
if len(w) == 4:
return False
if w == 'liala' or w[-5:] == 'liala':
return 'FA'
if len(w) == 5:
return False
if w == 'initis' or w[-6:] == 'initis':
return 'MV'
if w == 'inites' or w[-6:] == 'inites':
return 'FV'
return False
x = input().split(' ')
if len(x) == 1:
if not pos(x[0]):
print("NO")
quit()
else:
print("YES")
quit()
t = []
u = []
a = 0
n = 0
v = 0
for i in x:
e = pos(i)
if not e:
print("NO")
quit()
t.append(e[0])
if t[-1] != t[0]:
print("NO")
quit()
u.append(e[1])
if e[1] == 'A':
a += 1
if e[1] == 'N':
n += 1
if e[1] == 'V':
v +=1
if u == ['A'] * a + ['N'] * n + ['V'] * v and n >= 1:
print("YES")
quit()
print("NO")
| 360 | 124 | 102,400 |
151380136
|
'''
def isPetyaLanguage():
read = input().split(' ')
if len(read) == 1:
if read[0].endswith('lios') or read[0].endswith('lialia') or read[0].endswith('etr') or read[0].endswith('etra') or read[0].endswith('initis') or read[0].endswith('inites'):
print('YES')
return
else:
print('NO')
return
else:
if read[0].endswith('lios') or read[0].endswith('etr') or read[0].endswith('initis'):
for i in range(1,len(read)):
if (read[i].endswith('lios') or read[i].endswith('etr') or read[i].endswith('initis')) == False:
print('NO')
return
elif read[0].endswith('liala') or read[0].endswith('etra') or read[0].endswith('inites'):
for i in range(1,len(read)):
if (read[i].endswith('liala') or read[i].endswith('etra') or read[i].endswith('inites')) == False:
print('NO')
return
else:
print('NO')
return
index = -1
for i in range(len(read)):
if read[i].endswith('etr') or read[i].endswith('etra'):
index = i
if index == -1:
print('NO')
return
for i in range(0,index):
if (read[i].endswith('lios') or read[i].endswith('liala')) == False:
print('NO')
return
if index == len(read)-1:
print('YES')
return
for i in range(index+1,len(read)):
if (read[i].endswith('initis') or read[i].endswith('inites')) == False:
print('NO')
return
print('YES')
return
isPetyaLanguage()
'''
def getType(word):
if word.endswith("lios"): return 1
elif word.endswith("liala"): return -1
elif word.endswith("etr"): return 2
elif word.endswith("etra"): return -2
elif word.endswith("initis"):return 3
elif word.endswith("inites"): return -3
else: return 0
def gendercheck(words):
for i in range(len(words)-1):
if words[i]*words[i+1] <= 0:
return 0
return 1
def isPetyaLanguage():
words = input().strip().split()
words = [getType(x) for x in words]
if len(words) == 1:
if words[0] == 0:
print('NO')
return
else:
print('YES')
return
else:
if gendercheck(words) == 0:
print('NO')
return
else:
words = [abs(x) for x in words]
index = -1
for i in range(len(words)):
if words[i] == 2:
index = i
if index == -1:
print('NO')
return
for i in range(index):
if words[i] != 1:
print('NO')
return
if index == len(words)-1:
print('YES')
return
for i in range(index+1,len(words)):
if words[i] != 3:
print('NO')
return
print('YES')
return
return
isPetyaLanguage()
|
Codeforces Beta Round 86 (Div. 1 Only)
|
CF
| 2,011 | 5 | 256 |
Grammar Lessons
|
Petya got interested in grammar on his third year in school. He invented his own language called Petya's. Petya wanted to create a maximally simple language that would be enough to chat with friends, that's why all the language's grammar can be described with the following set of rules:
- There are three parts of speech: the adjective, the noun, the verb. Each word in his language is an adjective, noun or verb.
- There are two genders: masculine and feminine. Each word in his language has gender either masculine or feminine.
- Masculine adjectives end with -lios, and feminine adjectives end with -liala.
- Masculine nouns end with -etr, and feminime nouns end with -etra.
- Masculine verbs end with -initis, and feminime verbs end with -inites.
- Thus, each word in the Petya's language has one of the six endings, given above. There are no other endings in Petya's language.
- It is accepted that the whole word consists of an ending. That is, words "lios", "liala", "etr" and so on belong to the Petya's language.
- There aren't any punctuation marks, grammatical tenses, singular/plural forms or other language complications.
- A sentence is either exactly one valid language word or exactly one statement.
Statement is any sequence of the Petya's language, that satisfy both conditions:
- Words in statement follow in the following order (from the left to the right): zero or more adjectives followed by exactly one noun followed by zero or more verbs.
- All words in the statement should have the same gender.
After Petya's friend Vasya wrote instant messenger (an instant messaging program) that supported the Petya's language, Petya wanted to add spelling and grammar checking to the program. As Vasya was in the country and Petya didn't feel like waiting, he asked you to help him with this problem. Your task is to define by a given sequence of words, whether it is true that the given text represents exactly one sentence in Petya's language.
|
The first line contains one or more words consisting of lowercase Latin letters. The overall number of characters (including letters and spaces) does not exceed 105.
It is guaranteed that any two consecutive words are separated by exactly one space and the input data do not contain any other spaces. It is possible that given words do not belong to the Petya's language.
|
If some word of the given text does not belong to the Petya's language or if the text contains more that one sentence, print "NO" (without the quotes). Otherwise, print "YES" (without the quotes).
| null | null |
[{"input": "petr", "output": "YES"}, {"input": "etis atis animatis etis atis amatis", "output": "NO"}, {"input": "nataliala kataliala vetra feinites", "output": "YES"}]
| 1,600 |
["implementation", "strings"]
| 360 |
[{"input": "petr\r\n", "output": "YES\r\n"}, {"input": "etis atis animatis etis atis amatis\r\n", "output": "NO\r\n"}, {"input": "nataliala kataliala vetra feinites\r\n", "output": "YES\r\n"}, {"input": "qweasbvflios\r\n", "output": "YES\r\n"}, {"input": "lios lios petr initis qwe\r\n", "output": "NO\r\n"}, {"input": "lios initis\r\n", "output": "NO\r\n"}, {"input": "petr initis lios\r\n", "output": "NO\r\n"}, {"input": "petra petra petra\r\n", "output": "NO\r\n"}, {"input": "in\r\n", "output": "NO\r\n"}, {"input": "liala petra initis\r\n", "output": "NO\r\n"}, {"input": "liala petra inites\r\n", "output": "YES\r\n"}, {"input": "liala initis\r\n", "output": "NO\r\n"}, {"input": "liala petra petr inites\r\n", "output": "NO\r\n"}, {"input": "liala petr inites\r\n", "output": "NO\r\n"}, {"input": "llilitos\r\n", "output": "NO\r\n"}, {"input": "i i i i i i i i i i i i i i i a a a a a a v v v v v v v v v v v\r\n", "output": "NO\r\n"}, {"input": "hqaagnslliola vdumwjqalkyzbybwcaomxyffbkufaarhoebrqlpgshbmvjbwchfolyniuqkrysdhakzzrbiznhatifkbrqruswzhkewvgarmqtuadmsiquueumnpftiulfdpvzqfdgcfscczfsqivcdbuqvtyujirjwohskuabufdkehctkkguvetra oxnpizgojsrtinites\r\n", "output": "NO\r\n"}, {"input": "etretra linites\r\n", "output": "YES\r\n"}, {"input": "petretra petr\r\n", "output": "NO\r\n"}, {"input": "lialalios petraveryfunnypetr\r\n", "output": "YES\r\n"}, {"input": "petropetrapetr petra\r\n", "output": "NO\r\n"}, {"input": "lios petrnonono\r\n", "output": "NO\r\n"}, {"input": "lios petr initisandinitisandliala petrainitis\r\n", "output": "NO\r\n"}, {"input": "petro\r\n", "output": "NO\r\n"}, {"input": "petr initesinitis\r\n", "output": "YES\r\n"}, {"input": "lios initis\r\n", "output": "NO\r\n"}, {"input": "liala initespetra\r\n", "output": "YES\r\n"}, {"input": "lios petrapetr\r\n", "output": "YES\r\n"}, {"input": "initis petr\r\n", "output": "NO\r\n"}, {"input": "lioslialapetrpetrainitisinitesliosliala initesinitislioslialapetrpetrainitisinitetra\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixpetr\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixpetra\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixinitis\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixinites\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixliala\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixlios\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixlialas\r\n", "output": "NO\r\n"}, {"input": "veryfunnyprefixliala veryfunnyprefixpetretra\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixlios veryfunnyprefixinitisetr\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixlios aabbinitis\r\n", "output": "NO\r\n"}, {"input": "veryfunnyprefixlios inites\r\n", "output": "NO\r\n"}, {"input": "lios petr initis\r\n", "output": "YES\r\n"}, {"input": "liala etra inites\r\n", "output": "YES\r\n"}, {"input": "lios\r\n", "output": "YES\r\n"}, {"input": "liala\r\n", "output": "YES\r\n"}, {"input": "initis\r\n", "output": "YES\r\n"}, {"input": "inites\r\n", "output": "YES\r\n"}, {"input": "tes\r\n", "output": "NO\r\n"}, {"input": "tr\r\n", "output": "NO\r\n"}, {"input": "a\r\n", "output": "NO\r\n"}, {"input": "lios lios\r\n", "output": "NO\r\n"}, {"input": "lios\r\n", "output": "YES\r\n"}, {"input": "liala\r\n", "output": "YES\r\n"}, {"input": "petr\r\n", "output": "YES\r\n"}, {"input": "petra\r\n", "output": "YES\r\n"}, {"input": "pinitis\r\n", "output": "YES\r\n"}, {"input": "pinites\r\n", "output": "YES\r\n"}, {"input": "plios pliala\r\n", "output": "NO\r\n"}, {"input": "plios petr\r\n", "output": "YES\r\n"}, {"input": "plios petra\r\n", "output": "NO\r\n"}, {"input": "plios plios\r\n", "output": "NO\r\n"}, {"input": "plios initis\r\n", "output": "NO\r\n"}, {"input": "plios pinites\r\n", "output": "NO\r\n"}, {"input": "pliala plios\r\n", "output": "NO\r\n"}, {"input": "pliala ppliala\r\n", "output": "NO\r\n"}, {"input": "pliala petr\r\n", "output": "NO\r\n"}, {"input": "pliala petra\r\n", "output": "YES\r\n"}, {"input": "pliala pinitis\r\n", "output": "NO\r\n"}, {"input": "pliala pinites\r\n", "output": "NO\r\n"}, {"input": "petr plios\r\n", "output": "NO\r\n"}, {"input": "petr pliala\r\n", "output": "NO\r\n"}, {"input": "petr petr\r\n", "output": "NO\r\n"}, {"input": "petr petra\r\n", "output": "NO\r\n"}, {"input": "petr pinitis\r\n", "output": "YES\r\n"}, {"input": "petr pinites\r\n", "output": "NO\r\n"}, {"input": "petra lios\r\n", "output": "NO\r\n"}, {"input": "petra liala\r\n", "output": "NO\r\n"}, {"input": "petra petr\r\n", "output": "NO\r\n"}, {"input": "petra petra\r\n", "output": "NO\r\n"}, {"input": "petra initis\r\n", "output": "NO\r\n"}, {"input": "petra inites\r\n", "output": "YES\r\n"}, {"input": "initis lios\r\n", "output": "NO\r\n"}, {"input": "initis liala\r\n", "output": "NO\r\n"}, {"input": "initis petr\r\n", "output": "NO\r\n"}, {"input": "initis petra\r\n", "output": "NO\r\n"}, {"input": "initis initis\r\n", "output": "NO\r\n"}, {"input": "initis inites\r\n", "output": "NO\r\n"}, {"input": "inites lios\r\n", "output": "NO\r\n"}, {"input": "inites liala\r\n", "output": "NO\r\n"}, {"input": "inites petr\r\n", "output": "NO\r\n"}, {"input": "inites petra\r\n", "output": "NO\r\n"}, {"input": "inites initis\r\n", "output": "NO\r\n"}, {"input": "inites inites\r\n", "output": "NO\r\n"}, {"input": "lios lios lios\r\n", "output": "NO\r\n"}, {"input": "lios lios liala\r\n", "output": "NO\r\n"}, {"input": "lios lios etr\r\n", "output": "YES\r\n"}, {"input": "lios lios etra\r\n", "output": "NO\r\n"}, {"input": "lios lios initis\r\n", "output": "NO\r\n"}, {"input": "lios lios inites\r\n", "output": "NO\r\n"}, {"input": "lios liala lios\r\n", "output": "NO\r\n"}, {"input": "lios liala liala\r\n", "output": "NO\r\n"}, {"input": "lios liala etr\r\n", "output": "NO\r\n"}, {"input": "lios liala etra\r\n", "output": "NO\r\n"}, {"input": "lios liala initis\r\n", "output": "NO\r\n"}, {"input": "lios liala inites\r\n", "output": "NO\r\n"}, {"input": "lios etr lios\r\n", "output": "NO\r\n"}, {"input": "lios etr liala\r\n", "output": "NO\r\n"}, {"input": "lios etr etr\r\n", "output": "NO\r\n"}, {"input": "lios etr etra\r\n", "output": "NO\r\n"}, {"input": "lios etr initis\r\n", "output": "YES\r\n"}, {"input": "lios etr inites\r\n", "output": "NO\r\n"}, {"input": "lios etra lios\r\n", "output": "NO\r\n"}, {"input": "lios etra liala\r\n", "output": "NO\r\n"}, {"input": "lios etra etr\r\n", "output": "NO\r\n"}, {"input": "lios etra etra\r\n", "output": "NO\r\n"}, {"input": "lios etra initis\r\n", "output": "NO\r\n"}, {"input": "lios etra inites\r\n", "output": "NO\r\n"}, {"input": "lios initis lios\r\n", "output": "NO\r\n"}, {"input": "lios initis liala\r\n", "output": "NO\r\n"}, {"input": "lios initis etr\r\n", "output": "NO\r\n"}, {"input": "lios initis etra\r\n", "output": "NO\r\n"}, {"input": "lios initis initis\r\n", "output": "NO\r\n"}, {"input": "lios initis inites\r\n", "output": "NO\r\n"}, {"input": "lios inites lios\r\n", "output": "NO\r\n"}, {"input": "lios inites liala\r\n", "output": "NO\r\n"}, {"input": "lios inites etr\r\n", "output": "NO\r\n"}, {"input": "lios inites etra\r\n", "output": "NO\r\n"}, {"input": "lios inites initis\r\n", "output": "NO\r\n"}, {"input": "lios inites inites\r\n", "output": "NO\r\n"}, {"input": "liala lios lios\r\n", "output": "NO\r\n"}, {"input": "liala lios liala\r\n", "output": "NO\r\n"}, {"input": "liala lios etr\r\n", "output": "NO\r\n"}, {"input": "liala lios etra\r\n", "output": "NO\r\n"}, {"input": "liala lios initis\r\n", "output": "NO\r\n"}, {"input": "liala lios inites\r\n", "output": "NO\r\n"}, {"input": "liala liala lios\r\n", "output": "NO\r\n"}, {"input": "liala liala liala\r\n", "output": "NO\r\n"}, {"input": "liala liala etr\r\n", "output": "NO\r\n"}, {"input": "liala liala etra\r\n", "output": "YES\r\n"}, {"input": "liala liala initis\r\n", "output": "NO\r\n"}, {"input": "liala liala inites\r\n", "output": "NO\r\n"}, {"input": "liala etr lios\r\n", "output": "NO\r\n"}, {"input": "liala etr liala\r\n", "output": "NO\r\n"}, {"input": "liala etr etr\r\n", "output": "NO\r\n"}, {"input": "liala etr etra\r\n", "output": "NO\r\n"}, {"input": "liala etr initis\r\n", "output": "NO\r\n"}, {"input": "liala etr inites\r\n", "output": "NO\r\n"}, {"input": "liala etra lios\r\n", "output": "NO\r\n"}, {"input": "liala etra liala\r\n", "output": "NO\r\n"}, {"input": "liala etra etr\r\n", "output": "NO\r\n"}, {"input": "liala etra etra\r\n", "output": "NO\r\n"}, {"input": "liala etra initis\r\n", "output": "NO\r\n"}, {"input": "liala etra inites\r\n", "output": "YES\r\n"}, {"input": "liala initis lios\r\n", "output": "NO\r\n"}, {"input": "liala initis liala\r\n", "output": "NO\r\n"}, {"input": "liala initis etr\r\n", "output": "NO\r\n"}, {"input": "liala initis etra\r\n", "output": "NO\r\n"}, {"input": "liala initis initis\r\n", "output": "NO\r\n"}, {"input": "liala initis inites\r\n", "output": "NO\r\n"}, {"input": "liala inites lios\r\n", "output": "NO\r\n"}, {"input": "liala inites liala\r\n", "output": "NO\r\n"}, {"input": "liala inites etr\r\n", "output": "NO\r\n"}, {"input": "liala inites etra\r\n", "output": "NO\r\n"}, {"input": "liala inites initis\r\n", "output": "NO\r\n"}, {"input": "liala inites inites\r\n", "output": "NO\r\n"}, {"input": "etr lios lios\r\n", "output": "NO\r\n"}, {"input": "etr lios liala\r\n", "output": "NO\r\n"}, {"input": "etr lios etr\r\n", "output": "NO\r\n"}, {"input": "etr lios etra\r\n", "output": "NO\r\n"}, {"input": "etr lios initis\r\n", "output": "NO\r\n"}, {"input": "etr lios inites\r\n", "output": "NO\r\n"}, {"input": "etr liala lios\r\n", "output": "NO\r\n"}, {"input": "etr liala liala\r\n", "output": "NO\r\n"}, {"input": "etr liala etr\r\n", "output": "NO\r\n"}, {"input": "etr liala etra\r\n", "output": "NO\r\n"}, {"input": "etr liala initis\r\n", "output": "NO\r\n"}, {"input": "etr liala inites\r\n", "output": "NO\r\n"}, {"input": "etr etr lios\r\n", "output": "NO\r\n"}, {"input": "etr etr liala\r\n", "output": "NO\r\n"}, {"input": "etr etr etr\r\n", "output": "NO\r\n"}, {"input": "etr etr etra\r\n", "output": "NO\r\n"}, {"input": "etr etr initis\r\n", "output": "NO\r\n"}, {"input": "etr etr inites\r\n", "output": "NO\r\n"}, {"input": "etr etra lios\r\n", "output": "NO\r\n"}, {"input": "etr etra liala\r\n", "output": "NO\r\n"}, {"input": "etr etra etr\r\n", "output": "NO\r\n"}, {"input": "etr etra etra\r\n", "output": "NO\r\n"}, {"input": "etr etra initis\r\n", "output": "NO\r\n"}, {"input": "etr etra inites\r\n", "output": "NO\r\n"}, {"input": "etr initis lios\r\n", "output": "NO\r\n"}, {"input": "etr initis liala\r\n", "output": "NO\r\n"}, {"input": "etr initis etr\r\n", "output": "NO\r\n"}, {"input": "etr initis etra\r\n", "output": "NO\r\n"}, {"input": "etr initis initis\r\n", "output": "YES\r\n"}, {"input": "etr initis inites\r\n", "output": "NO\r\n"}, {"input": "etr inites lios\r\n", "output": "NO\r\n"}, {"input": "etr inites liala\r\n", "output": "NO\r\n"}, {"input": "etr inites etr\r\n", "output": "NO\r\n"}, {"input": "etr inites etra\r\n", "output": "NO\r\n"}, {"input": "etr inites initis\r\n", "output": "NO\r\n"}, {"input": "etr inites inites\r\n", "output": "NO\r\n"}, {"input": "etra lios lios\r\n", "output": "NO\r\n"}, {"input": "etra lios liala\r\n", "output": "NO\r\n"}, {"input": "etra lios etr\r\n", "output": "NO\r\n"}, {"input": "etra lios etra\r\n", "output": "NO\r\n"}, {"input": "etra lios initis\r\n", "output": "NO\r\n"}, {"input": "etra lios inites\r\n", "output": "NO\r\n"}, {"input": "etra liala lios\r\n", "output": "NO\r\n"}, {"input": "etra liala liala\r\n", "output": "NO\r\n"}, {"input": "etra liala etr\r\n", "output": "NO\r\n"}, {"input": "etra liala etra\r\n", "output": "NO\r\n"}, {"input": "etra liala initis\r\n", "output": "NO\r\n"}, {"input": "etra liala inites\r\n", "output": "NO\r\n"}, {"input": "etra etr lios\r\n", "output": "NO\r\n"}, {"input": "etra etr liala\r\n", "output": "NO\r\n"}, {"input": "etra etr etr\r\n", "output": "NO\r\n"}, {"input": "etra etr etra\r\n", "output": "NO\r\n"}, {"input": "etra etr initis\r\n", "output": "NO\r\n"}, {"input": "etra etr inites\r\n", "output": "NO\r\n"}, {"input": "etra etra lios\r\n", "output": "NO\r\n"}, {"input": "etra etra liala\r\n", "output": "NO\r\n"}, {"input": "etra etra etr\r\n", "output": "NO\r\n"}, {"input": "etra etra etra\r\n", "output": "NO\r\n"}, {"input": "etra etra initis\r\n", "output": "NO\r\n"}, {"input": "etra etra inites\r\n", "output": "NO\r\n"}, {"input": "etra initis lios\r\n", "output": "NO\r\n"}, {"input": "etra initis liala\r\n", "output": "NO\r\n"}, {"input": "etra initis etr\r\n", "output": "NO\r\n"}, {"input": "etra initis etra\r\n", "output": "NO\r\n"}, {"input": "etra initis initis\r\n", "output": "NO\r\n"}, {"input": "etra initis inites\r\n", "output": "NO\r\n"}, {"input": "etra inites lios\r\n", "output": "NO\r\n"}, {"input": "etra inites liala\r\n", "output": "NO\r\n"}, {"input": "etra inites etr\r\n", "output": "NO\r\n"}, {"input": "etra inites etra\r\n", "output": "NO\r\n"}, {"input": "etra inites initis\r\n", "output": "NO\r\n"}, {"input": "etra inites inites\r\n", "output": "YES\r\n"}, {"input": "initis lios lios\r\n", "output": "NO\r\n"}, {"input": "initis lios liala\r\n", "output": "NO\r\n"}, {"input": "initis lios etr\r\n", "output": "NO\r\n"}, {"input": "initis lios etra\r\n", "output": "NO\r\n"}, {"input": "initis lios initis\r\n", "output": "NO\r\n"}, {"input": "initis lios inites\r\n", "output": "NO\r\n"}, {"input": "initis liala lios\r\n", "output": "NO\r\n"}, {"input": "initis liala liala\r\n", "output": "NO\r\n"}, {"input": "initis liala etr\r\n", "output": "NO\r\n"}, {"input": "initis liala etra\r\n", "output": "NO\r\n"}, {"input": "initis liala initis\r\n", "output": "NO\r\n"}, {"input": "initis liala inites\r\n", "output": "NO\r\n"}, {"input": "initis etr lios\r\n", "output": "NO\r\n"}, {"input": "initis etr liala\r\n", "output": "NO\r\n"}, {"input": "initis etr etr\r\n", "output": "NO\r\n"}, {"input": "initis etr etra\r\n", "output": "NO\r\n"}, {"input": "initis etr initis\r\n", "output": "NO\r\n"}, {"input": "initis etr inites\r\n", "output": "NO\r\n"}, {"input": "initis etra lios\r\n", "output": "NO\r\n"}, {"input": "initis etra liala\r\n", "output": "NO\r\n"}, {"input": "initis etra etr\r\n", "output": "NO\r\n"}, {"input": "initis etra etra\r\n", "output": "NO\r\n"}, {"input": "initis etra initis\r\n", "output": "NO\r\n"}, {"input": "initis etra inites\r\n", "output": "NO\r\n"}, {"input": "initis initis lios\r\n", "output": "NO\r\n"}, {"input": "initis initis liala\r\n", "output": "NO\r\n"}, {"input": "initis initis etr\r\n", "output": "NO\r\n"}, {"input": "initis initis etra\r\n", "output": "NO\r\n"}, {"input": "initis initis initis\r\n", "output": "NO\r\n"}, {"input": "initis initis inites\r\n", "output": "NO\r\n"}, {"input": "initis inites lios\r\n", "output": "NO\r\n"}, {"input": "initis inites liala\r\n", "output": "NO\r\n"}, {"input": "initis inites etr\r\n", "output": "NO\r\n"}, {"input": "initis inites etra\r\n", "output": "NO\r\n"}, {"input": "initis inites initis\r\n", "output": "NO\r\n"}, {"input": "initis inites inites\r\n", "output": "NO\r\n"}, {"input": "inites lios lios\r\n", "output": "NO\r\n"}, {"input": "inites lios liala\r\n", "output": "NO\r\n"}, {"input": "inites lios etr\r\n", "output": "NO\r\n"}, {"input": "inites lios etra\r\n", "output": "NO\r\n"}, {"input": "inites lios initis\r\n", "output": "NO\r\n"}, {"input": "inites lios inites\r\n", "output": "NO\r\n"}, {"input": "inites liala lios\r\n", "output": "NO\r\n"}, {"input": "inites liala liala\r\n", "output": "NO\r\n"}, {"input": "inites liala etr\r\n", "output": "NO\r\n"}, {"input": "inites liala etra\r\n", "output": "NO\r\n"}, {"input": "inites liala initis\r\n", "output": "NO\r\n"}, {"input": "inites liala inites\r\n", "output": "NO\r\n"}, {"input": "inites etr lios\r\n", "output": "NO\r\n"}, {"input": "inites etr liala\r\n", "output": "NO\r\n"}, {"input": "inites etr etr\r\n", "output": "NO\r\n"}, {"input": "inites etr etra\r\n", "output": "NO\r\n"}, {"input": "inites etr initis\r\n", "output": "NO\r\n"}, {"input": "inites etr inites\r\n", "output": "NO\r\n"}, {"input": "inites etra lios\r\n", "output": "NO\r\n"}, {"input": "inites etra liala\r\n", "output": "NO\r\n"}, {"input": "inites etra etr\r\n", "output": "NO\r\n"}, {"input": "inites etra etra\r\n", "output": "NO\r\n"}, {"input": "inites etra initis\r\n", "output": "NO\r\n"}, {"input": "inites etra inites\r\n", "output": "NO\r\n"}, {"input": "inites initis lios\r\n", "output": "NO\r\n"}, {"input": "inites initis liala\r\n", "output": "NO\r\n"}, {"input": "inites initis etr\r\n", "output": "NO\r\n"}, {"input": "inites initis etra\r\n", "output": "NO\r\n"}, {"input": "inites initis initis\r\n", "output": "NO\r\n"}, {"input": "inites initis inites\r\n", "output": "NO\r\n"}, {"input": "inites inites lios\r\n", "output": "NO\r\n"}, {"input": "inites inites liala\r\n", "output": "NO\r\n"}, {"input": "inites inites etr\r\n", "output": "NO\r\n"}, {"input": "inites inites etra\r\n", "output": "NO\r\n"}, {"input": "inites inites initis\r\n", "output": "NO\r\n"}, {"input": "inites inites inites\r\n", "output": "NO\r\n"}]
| false |
stdio
| null | true |
113/A
|
113
|
A
|
Python 3
|
TESTS
| 7 | 186 | 307,200 |
91305797
|
s=list(map(str,input().split(' ')))
g=[['lios','liala'],['etr','etra'],['initis','inites']]
if len(s)==1:
n=len(s[0])
if s[0][n-len(g[0][0]):]==g[0][0] or s[0][n-len(g[0][1]):]==g[0][1] or s[0][n-len(g[1][0]):]==g[1][0] or s[0][n-len(g[1][1]):]==g[1][1] or s[0][n-len(g[2][0]):]==g[2][0] or s[0][n-len(g[2][1]):]==g[2][1]:
print('YES')
else:
print('NO')
else:
j=0
f=1
c=None
i=0
nc=0
while i<len(s):
if i==0:
n=len(s[i])
if s[i][n-len(g[j][0]):]==g[j][0] or s[i][n-len(g[j][1]):]==g[j][1]:
if s[i][n-len(g[j][0]):]==g[j][0]:
c=0
elif s[i][n-len(g[j][1]):]==g[j][1]==g[j][1]:
c=1
if j==1:
nc=nc+1
i=i+1
else:
j=j+1
else:
n=len(s[i])
if s[i][n-len(g[j][c]):]==g[j][c]:
if j==1:
nc=nc+1
i=i+1
else:
j=j+1
if j==3:
f=0
break
if f and nc>0:
print('YES')
else:
print('NO')
| 360 | 124 | 204,800 |
208405599
|
class Context:
def __init__(self, words):
self.words = words
self.index = 0
def get_token(self):
return self.words[self.index]
def next(self):
self.index += 1
def end(self):
return self.index == len(self.words)
def dump(self):
return self.index
def restore(self, dump):
self.index = dump
class Parser:
def parse(self, ctx) -> bool:
raise NotImplementedError
class WordParser(Parser):
END = None
def parse(self, ctx):
if ctx.end():
return False
token = ctx.get_token()
if token.endswith(self.END):
ctx.next()
return True
return False
class AdjectiveMale(WordParser):
END = "lios"
class AdjectiveFemale(WordParser):
END = "liala"
class NounMale(WordParser):
END = "etr"
class NounFemale(WordParser):
END = "etra"
class VerbMale(WordParser):
END = "initis"
class VerbFemale(WordParser):
END = "inites"
class AnyWordParser(Parser):
def __init__(self, parsers):
self.parsers = parsers
def parse(self, ctx) -> bool:
for parser in self.parsers:
dump = ctx.dump()
if parser.parse(ctx):
return True
ctx.restore(dump)
return False
class SequenceParser(Parser):
def __init__(self, parser):
self.parser = parser
def parse(self, ctx) -> bool:
status = False
while not ctx.end() and self.parser.parse(ctx):
status = True
return status
class PhraseParser(Parser):
def __init__(self, parsers_sequence):
self.parsers_sequence = parsers_sequence
def parse(self, ctx) -> bool:
dump = ctx.dump()
for parser in self.parsers_sequence:
if not parser.parse(ctx):
ctx.restore(dump)
return False
return True
class OptionalParser(Parser):
def __init__(self, parser):
self.parser = parser
def parse(self, ctx) -> bool:
dump = ctx.dump()
if not self.parser.parse(ctx):
ctx.restore(dump)
return True
class MalePhraseParser(PhraseParser):
def __init__(self):
adjective_parser = AdjectiveMale()
adjectives_parser = SequenceParser(adjective_parser)
optional_adjectives_parser = OptionalParser(adjectives_parser)
noun_parser = NounMale()
verb_parser = VerbMale()
verbs_parser = SequenceParser(verb_parser)
optional_verbs_parser = OptionalParser(verbs_parser)
parsers_pipeline = (optional_adjectives_parser, noun_parser, optional_verbs_parser)
super().__init__(parsers_pipeline)
class FemalePhraseParser(PhraseParser):
def __init__(self):
adjective_parser = AdjectiveFemale()
adjectives_parser = SequenceParser(adjective_parser)
optional_adjectives_parser = OptionalParser(adjectives_parser)
noun_parser = NounFemale()
verb_parser = VerbFemale()
verbs_parser = SequenceParser(verb_parser)
optional_verbs_parser = OptionalParser(verbs_parser)
parsers_pipeline = (optional_adjectives_parser, noun_parser, optional_verbs_parser)
super().__init__(parsers_pipeline)
class SentenceParser(Parser):
def __init__(self):
self.male_phrase_parser = MalePhraseParser()
self.female_phrase_parser = FemalePhraseParser()
self.any_word_parser = AnyWordParser((
AdjectiveMale(), AdjectiveFemale(),
NounMale(), NounFemale(),
VerbMale(), VerbFemale()
))
def parse(self, ctx) -> bool:
dump = ctx.dump()
if not self.male_phrase_parser.parse(ctx):
ctx.restore(dump)
else:
return True
if not self.female_phrase_parser.parse(ctx):
ctx.restore(dump)
else:
return True
if not self.any_word_parser.parse(ctx):
ctx.restore(dump)
return False
return True
def main():
data = input().split()
ctx = Context(data)
parser = SentenceParser()
status = parser.parse(ctx)
if status and ctx.end():
print("YES")
else:
print("NO")
main()
|
Codeforces Beta Round 86 (Div. 1 Only)
|
CF
| 2,011 | 5 | 256 |
Grammar Lessons
|
Petya got interested in grammar on his third year in school. He invented his own language called Petya's. Petya wanted to create a maximally simple language that would be enough to chat with friends, that's why all the language's grammar can be described with the following set of rules:
- There are three parts of speech: the adjective, the noun, the verb. Each word in his language is an adjective, noun or verb.
- There are two genders: masculine and feminine. Each word in his language has gender either masculine or feminine.
- Masculine adjectives end with -lios, and feminine adjectives end with -liala.
- Masculine nouns end with -etr, and feminime nouns end with -etra.
- Masculine verbs end with -initis, and feminime verbs end with -inites.
- Thus, each word in the Petya's language has one of the six endings, given above. There are no other endings in Petya's language.
- It is accepted that the whole word consists of an ending. That is, words "lios", "liala", "etr" and so on belong to the Petya's language.
- There aren't any punctuation marks, grammatical tenses, singular/plural forms or other language complications.
- A sentence is either exactly one valid language word or exactly one statement.
Statement is any sequence of the Petya's language, that satisfy both conditions:
- Words in statement follow in the following order (from the left to the right): zero or more adjectives followed by exactly one noun followed by zero or more verbs.
- All words in the statement should have the same gender.
After Petya's friend Vasya wrote instant messenger (an instant messaging program) that supported the Petya's language, Petya wanted to add spelling and grammar checking to the program. As Vasya was in the country and Petya didn't feel like waiting, he asked you to help him with this problem. Your task is to define by a given sequence of words, whether it is true that the given text represents exactly one sentence in Petya's language.
|
The first line contains one or more words consisting of lowercase Latin letters. The overall number of characters (including letters and spaces) does not exceed 105.
It is guaranteed that any two consecutive words are separated by exactly one space and the input data do not contain any other spaces. It is possible that given words do not belong to the Petya's language.
|
If some word of the given text does not belong to the Petya's language or if the text contains more that one sentence, print "NO" (without the quotes). Otherwise, print "YES" (without the quotes).
| null | null |
[{"input": "petr", "output": "YES"}, {"input": "etis atis animatis etis atis amatis", "output": "NO"}, {"input": "nataliala kataliala vetra feinites", "output": "YES"}]
| 1,600 |
["implementation", "strings"]
| 360 |
[{"input": "petr\r\n", "output": "YES\r\n"}, {"input": "etis atis animatis etis atis amatis\r\n", "output": "NO\r\n"}, {"input": "nataliala kataliala vetra feinites\r\n", "output": "YES\r\n"}, {"input": "qweasbvflios\r\n", "output": "YES\r\n"}, {"input": "lios lios petr initis qwe\r\n", "output": "NO\r\n"}, {"input": "lios initis\r\n", "output": "NO\r\n"}, {"input": "petr initis lios\r\n", "output": "NO\r\n"}, {"input": "petra petra petra\r\n", "output": "NO\r\n"}, {"input": "in\r\n", "output": "NO\r\n"}, {"input": "liala petra initis\r\n", "output": "NO\r\n"}, {"input": "liala petra inites\r\n", "output": "YES\r\n"}, {"input": "liala initis\r\n", "output": "NO\r\n"}, {"input": "liala petra petr inites\r\n", "output": "NO\r\n"}, {"input": "liala petr inites\r\n", "output": "NO\r\n"}, {"input": "llilitos\r\n", "output": "NO\r\n"}, {"input": "i i i i i i i i i i i i i i i a a a a a a v v v v v v v v v v v\r\n", "output": "NO\r\n"}, {"input": "hqaagnslliola vdumwjqalkyzbybwcaomxyffbkufaarhoebrqlpgshbmvjbwchfolyniuqkrysdhakzzrbiznhatifkbrqruswzhkewvgarmqtuadmsiquueumnpftiulfdpvzqfdgcfscczfsqivcdbuqvtyujirjwohskuabufdkehctkkguvetra oxnpizgojsrtinites\r\n", "output": "NO\r\n"}, {"input": "etretra linites\r\n", "output": "YES\r\n"}, {"input": "petretra petr\r\n", "output": "NO\r\n"}, {"input": "lialalios petraveryfunnypetr\r\n", "output": "YES\r\n"}, {"input": "petropetrapetr petra\r\n", "output": "NO\r\n"}, {"input": "lios petrnonono\r\n", "output": "NO\r\n"}, {"input": "lios petr initisandinitisandliala petrainitis\r\n", "output": "NO\r\n"}, {"input": "petro\r\n", "output": "NO\r\n"}, {"input": "petr initesinitis\r\n", "output": "YES\r\n"}, {"input": "lios initis\r\n", "output": "NO\r\n"}, {"input": "liala initespetra\r\n", "output": "YES\r\n"}, {"input": "lios petrapetr\r\n", "output": "YES\r\n"}, {"input": "initis petr\r\n", "output": "NO\r\n"}, {"input": "lioslialapetrpetrainitisinitesliosliala initesinitislioslialapetrpetrainitisinitetra\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixpetr\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixpetra\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixinitis\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixinites\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixliala\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixlios\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixlialas\r\n", "output": "NO\r\n"}, {"input": "veryfunnyprefixliala veryfunnyprefixpetretra\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixlios veryfunnyprefixinitisetr\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixlios aabbinitis\r\n", "output": "NO\r\n"}, {"input": "veryfunnyprefixlios inites\r\n", "output": "NO\r\n"}, {"input": "lios petr initis\r\n", "output": "YES\r\n"}, {"input": "liala etra inites\r\n", "output": "YES\r\n"}, {"input": "lios\r\n", "output": "YES\r\n"}, {"input": "liala\r\n", "output": "YES\r\n"}, {"input": "initis\r\n", "output": "YES\r\n"}, {"input": "inites\r\n", "output": "YES\r\n"}, {"input": "tes\r\n", "output": "NO\r\n"}, {"input": "tr\r\n", "output": "NO\r\n"}, {"input": "a\r\n", "output": "NO\r\n"}, {"input": "lios lios\r\n", "output": "NO\r\n"}, {"input": "lios\r\n", "output": "YES\r\n"}, {"input": "liala\r\n", "output": "YES\r\n"}, {"input": "petr\r\n", "output": "YES\r\n"}, {"input": "petra\r\n", "output": "YES\r\n"}, {"input": "pinitis\r\n", "output": "YES\r\n"}, {"input": "pinites\r\n", "output": "YES\r\n"}, {"input": "plios pliala\r\n", "output": "NO\r\n"}, {"input": "plios petr\r\n", "output": "YES\r\n"}, {"input": "plios petra\r\n", "output": "NO\r\n"}, {"input": "plios plios\r\n", "output": "NO\r\n"}, {"input": "plios initis\r\n", "output": "NO\r\n"}, {"input": "plios pinites\r\n", "output": "NO\r\n"}, {"input": "pliala plios\r\n", "output": "NO\r\n"}, {"input": "pliala ppliala\r\n", "output": "NO\r\n"}, {"input": "pliala petr\r\n", "output": "NO\r\n"}, {"input": "pliala petra\r\n", "output": "YES\r\n"}, {"input": "pliala pinitis\r\n", "output": "NO\r\n"}, {"input": "pliala pinites\r\n", "output": "NO\r\n"}, {"input": "petr plios\r\n", "output": "NO\r\n"}, {"input": "petr pliala\r\n", "output": "NO\r\n"}, {"input": "petr petr\r\n", "output": "NO\r\n"}, {"input": "petr petra\r\n", "output": "NO\r\n"}, {"input": "petr pinitis\r\n", "output": "YES\r\n"}, {"input": "petr pinites\r\n", "output": "NO\r\n"}, {"input": "petra lios\r\n", "output": "NO\r\n"}, {"input": "petra liala\r\n", "output": "NO\r\n"}, {"input": "petra petr\r\n", "output": "NO\r\n"}, {"input": "petra petra\r\n", "output": "NO\r\n"}, {"input": "petra initis\r\n", "output": "NO\r\n"}, {"input": "petra inites\r\n", "output": "YES\r\n"}, {"input": "initis lios\r\n", "output": "NO\r\n"}, {"input": "initis liala\r\n", "output": "NO\r\n"}, {"input": "initis petr\r\n", "output": "NO\r\n"}, {"input": "initis petra\r\n", "output": "NO\r\n"}, {"input": "initis initis\r\n", "output": "NO\r\n"}, {"input": "initis inites\r\n", "output": "NO\r\n"}, {"input": "inites lios\r\n", "output": "NO\r\n"}, {"input": "inites liala\r\n", "output": "NO\r\n"}, {"input": "inites petr\r\n", "output": "NO\r\n"}, {"input": "inites petra\r\n", "output": "NO\r\n"}, {"input": "inites initis\r\n", "output": "NO\r\n"}, {"input": "inites inites\r\n", "output": "NO\r\n"}, {"input": "lios lios lios\r\n", "output": "NO\r\n"}, {"input": "lios lios liala\r\n", "output": "NO\r\n"}, {"input": "lios lios etr\r\n", "output": "YES\r\n"}, {"input": "lios lios etra\r\n", "output": "NO\r\n"}, {"input": "lios lios initis\r\n", "output": "NO\r\n"}, {"input": "lios lios inites\r\n", "output": "NO\r\n"}, {"input": "lios liala lios\r\n", "output": "NO\r\n"}, {"input": "lios liala liala\r\n", "output": "NO\r\n"}, {"input": "lios liala etr\r\n", "output": "NO\r\n"}, {"input": "lios liala etra\r\n", "output": "NO\r\n"}, {"input": "lios liala initis\r\n", "output": "NO\r\n"}, {"input": "lios liala inites\r\n", "output": "NO\r\n"}, {"input": "lios etr lios\r\n", "output": "NO\r\n"}, {"input": "lios etr liala\r\n", "output": "NO\r\n"}, {"input": "lios etr etr\r\n", "output": "NO\r\n"}, {"input": "lios etr etra\r\n", "output": "NO\r\n"}, {"input": "lios etr initis\r\n", "output": "YES\r\n"}, {"input": "lios etr inites\r\n", "output": "NO\r\n"}, {"input": "lios etra lios\r\n", "output": "NO\r\n"}, {"input": "lios etra liala\r\n", "output": "NO\r\n"}, {"input": "lios etra etr\r\n", "output": "NO\r\n"}, {"input": "lios etra etra\r\n", "output": "NO\r\n"}, {"input": "lios etra initis\r\n", "output": "NO\r\n"}, {"input": "lios etra inites\r\n", "output": "NO\r\n"}, {"input": "lios initis lios\r\n", "output": "NO\r\n"}, {"input": "lios initis liala\r\n", "output": "NO\r\n"}, {"input": "lios initis etr\r\n", "output": "NO\r\n"}, {"input": "lios initis etra\r\n", "output": "NO\r\n"}, {"input": "lios initis initis\r\n", "output": "NO\r\n"}, {"input": "lios initis inites\r\n", "output": "NO\r\n"}, {"input": "lios inites lios\r\n", "output": "NO\r\n"}, {"input": "lios inites liala\r\n", "output": "NO\r\n"}, {"input": "lios inites etr\r\n", "output": "NO\r\n"}, {"input": "lios inites etra\r\n", "output": "NO\r\n"}, {"input": "lios inites initis\r\n", "output": "NO\r\n"}, {"input": "lios inites inites\r\n", "output": "NO\r\n"}, {"input": "liala lios lios\r\n", "output": "NO\r\n"}, {"input": "liala lios liala\r\n", "output": "NO\r\n"}, {"input": "liala lios etr\r\n", "output": "NO\r\n"}, {"input": "liala lios etra\r\n", "output": "NO\r\n"}, {"input": "liala lios initis\r\n", "output": "NO\r\n"}, {"input": "liala lios inites\r\n", "output": "NO\r\n"}, {"input": "liala liala lios\r\n", "output": "NO\r\n"}, {"input": "liala liala liala\r\n", "output": "NO\r\n"}, {"input": "liala liala etr\r\n", "output": "NO\r\n"}, {"input": "liala liala etra\r\n", "output": "YES\r\n"}, {"input": "liala liala initis\r\n", "output": "NO\r\n"}, {"input": "liala liala inites\r\n", "output": "NO\r\n"}, {"input": "liala etr lios\r\n", "output": "NO\r\n"}, {"input": "liala etr liala\r\n", "output": "NO\r\n"}, {"input": "liala etr etr\r\n", "output": "NO\r\n"}, {"input": "liala etr etra\r\n", "output": "NO\r\n"}, {"input": "liala etr initis\r\n", "output": "NO\r\n"}, {"input": "liala etr inites\r\n", "output": "NO\r\n"}, {"input": "liala etra lios\r\n", "output": "NO\r\n"}, {"input": "liala etra liala\r\n", "output": "NO\r\n"}, {"input": "liala etra etr\r\n", "output": "NO\r\n"}, {"input": "liala etra etra\r\n", "output": "NO\r\n"}, {"input": "liala etra initis\r\n", "output": "NO\r\n"}, {"input": "liala etra inites\r\n", "output": "YES\r\n"}, {"input": "liala initis lios\r\n", "output": "NO\r\n"}, {"input": "liala initis liala\r\n", "output": "NO\r\n"}, {"input": "liala initis etr\r\n", "output": "NO\r\n"}, {"input": "liala initis etra\r\n", "output": "NO\r\n"}, {"input": "liala initis initis\r\n", "output": "NO\r\n"}, {"input": "liala initis inites\r\n", "output": "NO\r\n"}, {"input": "liala inites lios\r\n", "output": "NO\r\n"}, {"input": "liala inites liala\r\n", "output": "NO\r\n"}, {"input": "liala inites etr\r\n", "output": "NO\r\n"}, {"input": "liala inites etra\r\n", "output": "NO\r\n"}, {"input": "liala inites initis\r\n", "output": "NO\r\n"}, {"input": "liala inites inites\r\n", "output": "NO\r\n"}, {"input": "etr lios lios\r\n", "output": "NO\r\n"}, {"input": "etr lios liala\r\n", "output": "NO\r\n"}, {"input": "etr lios etr\r\n", "output": "NO\r\n"}, {"input": "etr lios etra\r\n", "output": "NO\r\n"}, {"input": "etr lios initis\r\n", "output": "NO\r\n"}, {"input": "etr lios inites\r\n", "output": "NO\r\n"}, {"input": "etr liala lios\r\n", "output": "NO\r\n"}, {"input": "etr liala liala\r\n", "output": "NO\r\n"}, {"input": "etr liala etr\r\n", "output": "NO\r\n"}, {"input": "etr liala etra\r\n", "output": "NO\r\n"}, {"input": "etr liala initis\r\n", "output": "NO\r\n"}, {"input": "etr liala inites\r\n", "output": "NO\r\n"}, {"input": "etr etr lios\r\n", "output": "NO\r\n"}, {"input": "etr etr liala\r\n", "output": "NO\r\n"}, {"input": "etr etr etr\r\n", "output": "NO\r\n"}, {"input": "etr etr etra\r\n", "output": "NO\r\n"}, {"input": "etr etr initis\r\n", "output": "NO\r\n"}, {"input": "etr etr inites\r\n", "output": "NO\r\n"}, {"input": "etr etra lios\r\n", "output": "NO\r\n"}, {"input": "etr etra liala\r\n", "output": "NO\r\n"}, {"input": "etr etra etr\r\n", "output": "NO\r\n"}, {"input": "etr etra etra\r\n", "output": "NO\r\n"}, {"input": "etr etra initis\r\n", "output": "NO\r\n"}, {"input": "etr etra inites\r\n", "output": "NO\r\n"}, {"input": "etr initis lios\r\n", "output": "NO\r\n"}, {"input": "etr initis liala\r\n", "output": "NO\r\n"}, {"input": "etr initis etr\r\n", "output": "NO\r\n"}, {"input": "etr initis etra\r\n", "output": "NO\r\n"}, {"input": "etr initis initis\r\n", "output": "YES\r\n"}, {"input": "etr initis inites\r\n", "output": "NO\r\n"}, {"input": "etr inites lios\r\n", "output": "NO\r\n"}, {"input": "etr inites liala\r\n", "output": "NO\r\n"}, {"input": "etr inites etr\r\n", "output": "NO\r\n"}, {"input": "etr inites etra\r\n", "output": "NO\r\n"}, {"input": "etr inites initis\r\n", "output": "NO\r\n"}, {"input": "etr inites inites\r\n", "output": "NO\r\n"}, {"input": "etra lios lios\r\n", "output": "NO\r\n"}, {"input": "etra lios liala\r\n", "output": "NO\r\n"}, {"input": "etra lios etr\r\n", "output": "NO\r\n"}, {"input": "etra lios etra\r\n", "output": "NO\r\n"}, {"input": "etra lios initis\r\n", "output": "NO\r\n"}, {"input": "etra lios inites\r\n", "output": "NO\r\n"}, {"input": "etra liala lios\r\n", "output": "NO\r\n"}, {"input": "etra liala liala\r\n", "output": "NO\r\n"}, {"input": "etra liala etr\r\n", "output": "NO\r\n"}, {"input": "etra liala etra\r\n", "output": "NO\r\n"}, {"input": "etra liala initis\r\n", "output": "NO\r\n"}, {"input": "etra liala inites\r\n", "output": "NO\r\n"}, {"input": "etra etr lios\r\n", "output": "NO\r\n"}, {"input": "etra etr liala\r\n", "output": "NO\r\n"}, {"input": "etra etr etr\r\n", "output": "NO\r\n"}, {"input": "etra etr etra\r\n", "output": "NO\r\n"}, {"input": "etra etr initis\r\n", "output": "NO\r\n"}, {"input": "etra etr inites\r\n", "output": "NO\r\n"}, {"input": "etra etra lios\r\n", "output": "NO\r\n"}, {"input": "etra etra liala\r\n", "output": "NO\r\n"}, {"input": "etra etra etr\r\n", "output": "NO\r\n"}, {"input": "etra etra etra\r\n", "output": "NO\r\n"}, {"input": "etra etra initis\r\n", "output": "NO\r\n"}, {"input": "etra etra inites\r\n", "output": "NO\r\n"}, {"input": "etra initis lios\r\n", "output": "NO\r\n"}, {"input": "etra initis liala\r\n", "output": "NO\r\n"}, {"input": "etra initis etr\r\n", "output": "NO\r\n"}, {"input": "etra initis etra\r\n", "output": "NO\r\n"}, {"input": "etra initis initis\r\n", "output": "NO\r\n"}, {"input": "etra initis inites\r\n", "output": "NO\r\n"}, {"input": "etra inites lios\r\n", "output": "NO\r\n"}, {"input": "etra inites liala\r\n", "output": "NO\r\n"}, {"input": "etra inites etr\r\n", "output": "NO\r\n"}, {"input": "etra inites etra\r\n", "output": "NO\r\n"}, {"input": "etra inites initis\r\n", "output": "NO\r\n"}, {"input": "etra inites inites\r\n", "output": "YES\r\n"}, {"input": "initis lios lios\r\n", "output": "NO\r\n"}, {"input": "initis lios liala\r\n", "output": "NO\r\n"}, {"input": "initis lios etr\r\n", "output": "NO\r\n"}, {"input": "initis lios etra\r\n", "output": "NO\r\n"}, {"input": "initis lios initis\r\n", "output": "NO\r\n"}, {"input": "initis lios inites\r\n", "output": "NO\r\n"}, {"input": "initis liala lios\r\n", "output": "NO\r\n"}, {"input": "initis liala liala\r\n", "output": "NO\r\n"}, {"input": "initis liala etr\r\n", "output": "NO\r\n"}, {"input": "initis liala etra\r\n", "output": "NO\r\n"}, {"input": "initis liala initis\r\n", "output": "NO\r\n"}, {"input": "initis liala inites\r\n", "output": "NO\r\n"}, {"input": "initis etr lios\r\n", "output": "NO\r\n"}, {"input": "initis etr liala\r\n", "output": "NO\r\n"}, {"input": "initis etr etr\r\n", "output": "NO\r\n"}, {"input": "initis etr etra\r\n", "output": "NO\r\n"}, {"input": "initis etr initis\r\n", "output": "NO\r\n"}, {"input": "initis etr inites\r\n", "output": "NO\r\n"}, {"input": "initis etra lios\r\n", "output": "NO\r\n"}, {"input": "initis etra liala\r\n", "output": "NO\r\n"}, {"input": "initis etra etr\r\n", "output": "NO\r\n"}, {"input": "initis etra etra\r\n", "output": "NO\r\n"}, {"input": "initis etra initis\r\n", "output": "NO\r\n"}, {"input": "initis etra inites\r\n", "output": "NO\r\n"}, {"input": "initis initis lios\r\n", "output": "NO\r\n"}, {"input": "initis initis liala\r\n", "output": "NO\r\n"}, {"input": "initis initis etr\r\n", "output": "NO\r\n"}, {"input": "initis initis etra\r\n", "output": "NO\r\n"}, {"input": "initis initis initis\r\n", "output": "NO\r\n"}, {"input": "initis initis inites\r\n", "output": "NO\r\n"}, {"input": "initis inites lios\r\n", "output": "NO\r\n"}, {"input": "initis inites liala\r\n", "output": "NO\r\n"}, {"input": "initis inites etr\r\n", "output": "NO\r\n"}, {"input": "initis inites etra\r\n", "output": "NO\r\n"}, {"input": "initis inites initis\r\n", "output": "NO\r\n"}, {"input": "initis inites inites\r\n", "output": "NO\r\n"}, {"input": "inites lios lios\r\n", "output": "NO\r\n"}, {"input": "inites lios liala\r\n", "output": "NO\r\n"}, {"input": "inites lios etr\r\n", "output": "NO\r\n"}, {"input": "inites lios etra\r\n", "output": "NO\r\n"}, {"input": "inites lios initis\r\n", "output": "NO\r\n"}, {"input": "inites lios inites\r\n", "output": "NO\r\n"}, {"input": "inites liala lios\r\n", "output": "NO\r\n"}, {"input": "inites liala liala\r\n", "output": "NO\r\n"}, {"input": "inites liala etr\r\n", "output": "NO\r\n"}, {"input": "inites liala etra\r\n", "output": "NO\r\n"}, {"input": "inites liala initis\r\n", "output": "NO\r\n"}, {"input": "inites liala inites\r\n", "output": "NO\r\n"}, {"input": "inites etr lios\r\n", "output": "NO\r\n"}, {"input": "inites etr liala\r\n", "output": "NO\r\n"}, {"input": "inites etr etr\r\n", "output": "NO\r\n"}, {"input": "inites etr etra\r\n", "output": "NO\r\n"}, {"input": "inites etr initis\r\n", "output": "NO\r\n"}, {"input": "inites etr inites\r\n", "output": "NO\r\n"}, {"input": "inites etra lios\r\n", "output": "NO\r\n"}, {"input": "inites etra liala\r\n", "output": "NO\r\n"}, {"input": "inites etra etr\r\n", "output": "NO\r\n"}, {"input": "inites etra etra\r\n", "output": "NO\r\n"}, {"input": "inites etra initis\r\n", "output": "NO\r\n"}, {"input": "inites etra inites\r\n", "output": "NO\r\n"}, {"input": "inites initis lios\r\n", "output": "NO\r\n"}, {"input": "inites initis liala\r\n", "output": "NO\r\n"}, {"input": "inites initis etr\r\n", "output": "NO\r\n"}, {"input": "inites initis etra\r\n", "output": "NO\r\n"}, {"input": "inites initis initis\r\n", "output": "NO\r\n"}, {"input": "inites initis inites\r\n", "output": "NO\r\n"}, {"input": "inites inites lios\r\n", "output": "NO\r\n"}, {"input": "inites inites liala\r\n", "output": "NO\r\n"}, {"input": "inites inites etr\r\n", "output": "NO\r\n"}, {"input": "inites inites etra\r\n", "output": "NO\r\n"}, {"input": "inites inites initis\r\n", "output": "NO\r\n"}, {"input": "inites inites inites\r\n", "output": "NO\r\n"}]
| false |
stdio
| null | true |
113/A
|
113
|
A
|
Python 3
|
TESTS
| 66 | 156 | 204,800 |
22654372
|
ms = input().split()
al = [['lios','etr','initis'],['liala','etra','inites']]
s = ms[0]
i=0;
ans = True;
if s.endswith(al[0][0]) or s.endswith(al[0][1]):
fs = 0;
elif s.endswith(al[1][0]) or s.endswith(al[1][1]):
fs = 1;
else:
ans=False;
if ans==True:
for s in ms:
if i==0:
if s.endswith(al[fs][0]) or s.endswith(al[fs][1]):
if s.endswith(al[fs][1]):
i=1;
else:
ans=False;
break;
elif i==1 and s.endswith(al[fs][2]):
continue;
else:
ans=False;
break;
print(['NO','YES'][ans]);
| 360 | 124 | 614,400 |
162396833
|
import re;t=input();p=[r'([^ ]*lios )*([^ ]*etr)( [^ ]*initis)*',r'([^ ]*liala )*([^ ]*etra)( [^ ]*inites)*',r'[^ ]*(li(os|ala)|etra?|init[ie]s)'];print(['NO','YES'][any(re.fullmatch(q,t)for q in p)])
|
Codeforces Beta Round 86 (Div. 1 Only)
|
CF
| 2,011 | 5 | 256 |
Grammar Lessons
|
Petya got interested in grammar on his third year in school. He invented his own language called Petya's. Petya wanted to create a maximally simple language that would be enough to chat with friends, that's why all the language's grammar can be described with the following set of rules:
- There are three parts of speech: the adjective, the noun, the verb. Each word in his language is an adjective, noun or verb.
- There are two genders: masculine and feminine. Each word in his language has gender either masculine or feminine.
- Masculine adjectives end with -lios, and feminine adjectives end with -liala.
- Masculine nouns end with -etr, and feminime nouns end with -etra.
- Masculine verbs end with -initis, and feminime verbs end with -inites.
- Thus, each word in the Petya's language has one of the six endings, given above. There are no other endings in Petya's language.
- It is accepted that the whole word consists of an ending. That is, words "lios", "liala", "etr" and so on belong to the Petya's language.
- There aren't any punctuation marks, grammatical tenses, singular/plural forms or other language complications.
- A sentence is either exactly one valid language word or exactly one statement.
Statement is any sequence of the Petya's language, that satisfy both conditions:
- Words in statement follow in the following order (from the left to the right): zero or more adjectives followed by exactly one noun followed by zero or more verbs.
- All words in the statement should have the same gender.
After Petya's friend Vasya wrote instant messenger (an instant messaging program) that supported the Petya's language, Petya wanted to add spelling and grammar checking to the program. As Vasya was in the country and Petya didn't feel like waiting, he asked you to help him with this problem. Your task is to define by a given sequence of words, whether it is true that the given text represents exactly one sentence in Petya's language.
|
The first line contains one or more words consisting of lowercase Latin letters. The overall number of characters (including letters and spaces) does not exceed 105.
It is guaranteed that any two consecutive words are separated by exactly one space and the input data do not contain any other spaces. It is possible that given words do not belong to the Petya's language.
|
If some word of the given text does not belong to the Petya's language or if the text contains more that one sentence, print "NO" (without the quotes). Otherwise, print "YES" (without the quotes).
| null | null |
[{"input": "petr", "output": "YES"}, {"input": "etis atis animatis etis atis amatis", "output": "NO"}, {"input": "nataliala kataliala vetra feinites", "output": "YES"}]
| 1,600 |
["implementation", "strings"]
| 360 |
[{"input": "petr\r\n", "output": "YES\r\n"}, {"input": "etis atis animatis etis atis amatis\r\n", "output": "NO\r\n"}, {"input": "nataliala kataliala vetra feinites\r\n", "output": "YES\r\n"}, {"input": "qweasbvflios\r\n", "output": "YES\r\n"}, {"input": "lios lios petr initis qwe\r\n", "output": "NO\r\n"}, {"input": "lios initis\r\n", "output": "NO\r\n"}, {"input": "petr initis lios\r\n", "output": "NO\r\n"}, {"input": "petra petra petra\r\n", "output": "NO\r\n"}, {"input": "in\r\n", "output": "NO\r\n"}, {"input": "liala petra initis\r\n", "output": "NO\r\n"}, {"input": "liala petra inites\r\n", "output": "YES\r\n"}, {"input": "liala initis\r\n", "output": "NO\r\n"}, {"input": "liala petra petr inites\r\n", "output": "NO\r\n"}, {"input": "liala petr inites\r\n", "output": "NO\r\n"}, {"input": "llilitos\r\n", "output": "NO\r\n"}, {"input": "i i i i i i i i i i i i i i i a a a a a a v v v v v v v v v v v\r\n", "output": "NO\r\n"}, {"input": "hqaagnslliola vdumwjqalkyzbybwcaomxyffbkufaarhoebrqlpgshbmvjbwchfolyniuqkrysdhakzzrbiznhatifkbrqruswzhkewvgarmqtuadmsiquueumnpftiulfdpvzqfdgcfscczfsqivcdbuqvtyujirjwohskuabufdkehctkkguvetra oxnpizgojsrtinites\r\n", "output": "NO\r\n"}, {"input": "etretra linites\r\n", "output": "YES\r\n"}, {"input": "petretra petr\r\n", "output": "NO\r\n"}, {"input": "lialalios petraveryfunnypetr\r\n", "output": "YES\r\n"}, {"input": "petropetrapetr petra\r\n", "output": "NO\r\n"}, {"input": "lios petrnonono\r\n", "output": "NO\r\n"}, {"input": "lios petr initisandinitisandliala petrainitis\r\n", "output": "NO\r\n"}, {"input": "petro\r\n", "output": "NO\r\n"}, {"input": "petr initesinitis\r\n", "output": "YES\r\n"}, {"input": "lios initis\r\n", "output": "NO\r\n"}, {"input": "liala initespetra\r\n", "output": "YES\r\n"}, {"input": "lios petrapetr\r\n", "output": "YES\r\n"}, {"input": "initis petr\r\n", "output": "NO\r\n"}, {"input": "lioslialapetrpetrainitisinitesliosliala initesinitislioslialapetrpetrainitisinitetra\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixpetr\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixpetra\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixinitis\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixinites\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixliala\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixlios\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixlialas\r\n", "output": "NO\r\n"}, {"input": "veryfunnyprefixliala veryfunnyprefixpetretra\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixlios veryfunnyprefixinitisetr\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixlios aabbinitis\r\n", "output": "NO\r\n"}, {"input": "veryfunnyprefixlios inites\r\n", "output": "NO\r\n"}, {"input": "lios petr initis\r\n", "output": "YES\r\n"}, {"input": "liala etra inites\r\n", "output": "YES\r\n"}, {"input": "lios\r\n", "output": "YES\r\n"}, {"input": "liala\r\n", "output": "YES\r\n"}, {"input": "initis\r\n", "output": "YES\r\n"}, {"input": "inites\r\n", "output": "YES\r\n"}, {"input": "tes\r\n", "output": "NO\r\n"}, {"input": "tr\r\n", "output": "NO\r\n"}, {"input": "a\r\n", "output": "NO\r\n"}, {"input": "lios lios\r\n", "output": "NO\r\n"}, {"input": "lios\r\n", "output": "YES\r\n"}, {"input": "liala\r\n", "output": "YES\r\n"}, {"input": "petr\r\n", "output": "YES\r\n"}, {"input": "petra\r\n", "output": "YES\r\n"}, {"input": "pinitis\r\n", "output": "YES\r\n"}, {"input": "pinites\r\n", "output": "YES\r\n"}, {"input": "plios pliala\r\n", "output": "NO\r\n"}, {"input": "plios petr\r\n", "output": "YES\r\n"}, {"input": "plios petra\r\n", "output": "NO\r\n"}, {"input": "plios plios\r\n", "output": "NO\r\n"}, {"input": "plios initis\r\n", "output": "NO\r\n"}, {"input": "plios pinites\r\n", "output": "NO\r\n"}, {"input": "pliala plios\r\n", "output": "NO\r\n"}, {"input": "pliala ppliala\r\n", "output": "NO\r\n"}, {"input": "pliala petr\r\n", "output": "NO\r\n"}, {"input": "pliala petra\r\n", "output": "YES\r\n"}, {"input": "pliala pinitis\r\n", "output": "NO\r\n"}, {"input": "pliala pinites\r\n", "output": "NO\r\n"}, {"input": "petr plios\r\n", "output": "NO\r\n"}, {"input": "petr pliala\r\n", "output": "NO\r\n"}, {"input": "petr petr\r\n", "output": "NO\r\n"}, {"input": "petr petra\r\n", "output": "NO\r\n"}, {"input": "petr pinitis\r\n", "output": "YES\r\n"}, {"input": "petr pinites\r\n", "output": "NO\r\n"}, {"input": "petra lios\r\n", "output": "NO\r\n"}, {"input": "petra liala\r\n", "output": "NO\r\n"}, {"input": "petra petr\r\n", "output": "NO\r\n"}, {"input": "petra petra\r\n", "output": "NO\r\n"}, {"input": "petra initis\r\n", "output": "NO\r\n"}, {"input": "petra inites\r\n", "output": "YES\r\n"}, {"input": "initis lios\r\n", "output": "NO\r\n"}, {"input": "initis liala\r\n", "output": "NO\r\n"}, {"input": "initis petr\r\n", "output": "NO\r\n"}, {"input": "initis petra\r\n", "output": "NO\r\n"}, {"input": "initis initis\r\n", "output": "NO\r\n"}, {"input": "initis inites\r\n", "output": "NO\r\n"}, {"input": "inites lios\r\n", "output": "NO\r\n"}, {"input": "inites liala\r\n", "output": "NO\r\n"}, {"input": "inites petr\r\n", "output": "NO\r\n"}, {"input": "inites petra\r\n", "output": "NO\r\n"}, {"input": "inites initis\r\n", "output": "NO\r\n"}, {"input": "inites inites\r\n", "output": "NO\r\n"}, {"input": "lios lios lios\r\n", "output": "NO\r\n"}, {"input": "lios lios liala\r\n", "output": "NO\r\n"}, {"input": "lios lios etr\r\n", "output": "YES\r\n"}, {"input": "lios lios etra\r\n", "output": "NO\r\n"}, {"input": "lios lios initis\r\n", "output": "NO\r\n"}, {"input": "lios lios inites\r\n", "output": "NO\r\n"}, {"input": "lios liala lios\r\n", "output": "NO\r\n"}, {"input": "lios liala liala\r\n", "output": "NO\r\n"}, {"input": "lios liala etr\r\n", "output": "NO\r\n"}, {"input": "lios liala etra\r\n", "output": "NO\r\n"}, {"input": "lios liala initis\r\n", "output": "NO\r\n"}, {"input": "lios liala inites\r\n", "output": "NO\r\n"}, {"input": "lios etr lios\r\n", "output": "NO\r\n"}, {"input": "lios etr liala\r\n", "output": "NO\r\n"}, {"input": "lios etr etr\r\n", "output": "NO\r\n"}, {"input": "lios etr etra\r\n", "output": "NO\r\n"}, {"input": "lios etr initis\r\n", "output": "YES\r\n"}, {"input": "lios etr inites\r\n", "output": "NO\r\n"}, {"input": "lios etra lios\r\n", "output": "NO\r\n"}, {"input": "lios etra liala\r\n", "output": "NO\r\n"}, {"input": "lios etra etr\r\n", "output": "NO\r\n"}, {"input": "lios etra etra\r\n", "output": "NO\r\n"}, {"input": "lios etra initis\r\n", "output": "NO\r\n"}, {"input": "lios etra inites\r\n", "output": "NO\r\n"}, {"input": "lios initis lios\r\n", "output": "NO\r\n"}, {"input": "lios initis liala\r\n", "output": "NO\r\n"}, {"input": "lios initis etr\r\n", "output": "NO\r\n"}, {"input": "lios initis etra\r\n", "output": "NO\r\n"}, {"input": "lios initis initis\r\n", "output": "NO\r\n"}, {"input": "lios initis inites\r\n", "output": "NO\r\n"}, {"input": "lios inites lios\r\n", "output": "NO\r\n"}, {"input": "lios inites liala\r\n", "output": "NO\r\n"}, {"input": "lios inites etr\r\n", "output": "NO\r\n"}, {"input": "lios inites etra\r\n", "output": "NO\r\n"}, {"input": "lios inites initis\r\n", "output": "NO\r\n"}, {"input": "lios inites inites\r\n", "output": "NO\r\n"}, {"input": "liala lios lios\r\n", "output": "NO\r\n"}, {"input": "liala lios liala\r\n", "output": "NO\r\n"}, {"input": "liala lios etr\r\n", "output": "NO\r\n"}, {"input": "liala lios etra\r\n", "output": "NO\r\n"}, {"input": "liala lios initis\r\n", "output": "NO\r\n"}, {"input": "liala lios inites\r\n", "output": "NO\r\n"}, {"input": "liala liala lios\r\n", "output": "NO\r\n"}, {"input": "liala liala liala\r\n", "output": "NO\r\n"}, {"input": "liala liala etr\r\n", "output": "NO\r\n"}, {"input": "liala liala etra\r\n", "output": "YES\r\n"}, {"input": "liala liala initis\r\n", "output": "NO\r\n"}, {"input": "liala liala inites\r\n", "output": "NO\r\n"}, {"input": "liala etr lios\r\n", "output": "NO\r\n"}, {"input": "liala etr liala\r\n", "output": "NO\r\n"}, {"input": "liala etr etr\r\n", "output": "NO\r\n"}, {"input": "liala etr etra\r\n", "output": "NO\r\n"}, {"input": "liala etr initis\r\n", "output": "NO\r\n"}, {"input": "liala etr inites\r\n", "output": "NO\r\n"}, {"input": "liala etra lios\r\n", "output": "NO\r\n"}, {"input": "liala etra liala\r\n", "output": "NO\r\n"}, {"input": "liala etra etr\r\n", "output": "NO\r\n"}, {"input": "liala etra etra\r\n", "output": "NO\r\n"}, {"input": "liala etra initis\r\n", "output": "NO\r\n"}, {"input": "liala etra inites\r\n", "output": "YES\r\n"}, {"input": "liala initis lios\r\n", "output": "NO\r\n"}, {"input": "liala initis liala\r\n", "output": "NO\r\n"}, {"input": "liala initis etr\r\n", "output": "NO\r\n"}, {"input": "liala initis etra\r\n", "output": "NO\r\n"}, {"input": "liala initis initis\r\n", "output": "NO\r\n"}, {"input": "liala initis inites\r\n", "output": "NO\r\n"}, {"input": "liala inites lios\r\n", "output": "NO\r\n"}, {"input": "liala inites liala\r\n", "output": "NO\r\n"}, {"input": "liala inites etr\r\n", "output": "NO\r\n"}, {"input": "liala inites etra\r\n", "output": "NO\r\n"}, {"input": "liala inites initis\r\n", "output": "NO\r\n"}, {"input": "liala inites inites\r\n", "output": "NO\r\n"}, {"input": "etr lios lios\r\n", "output": "NO\r\n"}, {"input": "etr lios liala\r\n", "output": "NO\r\n"}, {"input": "etr lios etr\r\n", "output": "NO\r\n"}, {"input": "etr lios etra\r\n", "output": "NO\r\n"}, {"input": "etr lios initis\r\n", "output": "NO\r\n"}, {"input": "etr lios inites\r\n", "output": "NO\r\n"}, {"input": "etr liala lios\r\n", "output": "NO\r\n"}, {"input": "etr liala liala\r\n", "output": "NO\r\n"}, {"input": "etr liala etr\r\n", "output": "NO\r\n"}, {"input": "etr liala etra\r\n", "output": "NO\r\n"}, {"input": "etr liala initis\r\n", "output": "NO\r\n"}, {"input": "etr liala inites\r\n", "output": "NO\r\n"}, {"input": "etr etr lios\r\n", "output": "NO\r\n"}, {"input": "etr etr liala\r\n", "output": "NO\r\n"}, {"input": "etr etr etr\r\n", "output": "NO\r\n"}, {"input": "etr etr etra\r\n", "output": "NO\r\n"}, {"input": "etr etr initis\r\n", "output": "NO\r\n"}, {"input": "etr etr inites\r\n", "output": "NO\r\n"}, {"input": "etr etra lios\r\n", "output": "NO\r\n"}, {"input": "etr etra liala\r\n", "output": "NO\r\n"}, {"input": "etr etra etr\r\n", "output": "NO\r\n"}, {"input": "etr etra etra\r\n", "output": "NO\r\n"}, {"input": "etr etra initis\r\n", "output": "NO\r\n"}, {"input": "etr etra inites\r\n", "output": "NO\r\n"}, {"input": "etr initis lios\r\n", "output": "NO\r\n"}, {"input": "etr initis liala\r\n", "output": "NO\r\n"}, {"input": "etr initis etr\r\n", "output": "NO\r\n"}, {"input": "etr initis etra\r\n", "output": "NO\r\n"}, {"input": "etr initis initis\r\n", "output": "YES\r\n"}, {"input": "etr initis inites\r\n", "output": "NO\r\n"}, {"input": "etr inites lios\r\n", "output": "NO\r\n"}, {"input": "etr inites liala\r\n", "output": "NO\r\n"}, {"input": "etr inites etr\r\n", "output": "NO\r\n"}, {"input": "etr inites etra\r\n", "output": "NO\r\n"}, {"input": "etr inites initis\r\n", "output": "NO\r\n"}, {"input": "etr inites inites\r\n", "output": "NO\r\n"}, {"input": "etra lios lios\r\n", "output": "NO\r\n"}, {"input": "etra lios liala\r\n", "output": "NO\r\n"}, {"input": "etra lios etr\r\n", "output": "NO\r\n"}, {"input": "etra lios etra\r\n", "output": "NO\r\n"}, {"input": "etra lios initis\r\n", "output": "NO\r\n"}, {"input": "etra lios inites\r\n", "output": "NO\r\n"}, {"input": "etra liala lios\r\n", "output": "NO\r\n"}, {"input": "etra liala liala\r\n", "output": "NO\r\n"}, {"input": "etra liala etr\r\n", "output": "NO\r\n"}, {"input": "etra liala etra\r\n", "output": "NO\r\n"}, {"input": "etra liala initis\r\n", "output": "NO\r\n"}, {"input": "etra liala inites\r\n", "output": "NO\r\n"}, {"input": "etra etr lios\r\n", "output": "NO\r\n"}, {"input": "etra etr liala\r\n", "output": "NO\r\n"}, {"input": "etra etr etr\r\n", "output": "NO\r\n"}, {"input": "etra etr etra\r\n", "output": "NO\r\n"}, {"input": "etra etr initis\r\n", "output": "NO\r\n"}, {"input": "etra etr inites\r\n", "output": "NO\r\n"}, {"input": "etra etra lios\r\n", "output": "NO\r\n"}, {"input": "etra etra liala\r\n", "output": "NO\r\n"}, {"input": "etra etra etr\r\n", "output": "NO\r\n"}, {"input": "etra etra etra\r\n", "output": "NO\r\n"}, {"input": "etra etra initis\r\n", "output": "NO\r\n"}, {"input": "etra etra inites\r\n", "output": "NO\r\n"}, {"input": "etra initis lios\r\n", "output": "NO\r\n"}, {"input": "etra initis liala\r\n", "output": "NO\r\n"}, {"input": "etra initis etr\r\n", "output": "NO\r\n"}, {"input": "etra initis etra\r\n", "output": "NO\r\n"}, {"input": "etra initis initis\r\n", "output": "NO\r\n"}, {"input": "etra initis inites\r\n", "output": "NO\r\n"}, {"input": "etra inites lios\r\n", "output": "NO\r\n"}, {"input": "etra inites liala\r\n", "output": "NO\r\n"}, {"input": "etra inites etr\r\n", "output": "NO\r\n"}, {"input": "etra inites etra\r\n", "output": "NO\r\n"}, {"input": "etra inites initis\r\n", "output": "NO\r\n"}, {"input": "etra inites inites\r\n", "output": "YES\r\n"}, {"input": "initis lios lios\r\n", "output": "NO\r\n"}, {"input": "initis lios liala\r\n", "output": "NO\r\n"}, {"input": "initis lios etr\r\n", "output": "NO\r\n"}, {"input": "initis lios etra\r\n", "output": "NO\r\n"}, {"input": "initis lios initis\r\n", "output": "NO\r\n"}, {"input": "initis lios inites\r\n", "output": "NO\r\n"}, {"input": "initis liala lios\r\n", "output": "NO\r\n"}, {"input": "initis liala liala\r\n", "output": "NO\r\n"}, {"input": "initis liala etr\r\n", "output": "NO\r\n"}, {"input": "initis liala etra\r\n", "output": "NO\r\n"}, {"input": "initis liala initis\r\n", "output": "NO\r\n"}, {"input": "initis liala inites\r\n", "output": "NO\r\n"}, {"input": "initis etr lios\r\n", "output": "NO\r\n"}, {"input": "initis etr liala\r\n", "output": "NO\r\n"}, {"input": "initis etr etr\r\n", "output": "NO\r\n"}, {"input": "initis etr etra\r\n", "output": "NO\r\n"}, {"input": "initis etr initis\r\n", "output": "NO\r\n"}, {"input": "initis etr inites\r\n", "output": "NO\r\n"}, {"input": "initis etra lios\r\n", "output": "NO\r\n"}, {"input": "initis etra liala\r\n", "output": "NO\r\n"}, {"input": "initis etra etr\r\n", "output": "NO\r\n"}, {"input": "initis etra etra\r\n", "output": "NO\r\n"}, {"input": "initis etra initis\r\n", "output": "NO\r\n"}, {"input": "initis etra inites\r\n", "output": "NO\r\n"}, {"input": "initis initis lios\r\n", "output": "NO\r\n"}, {"input": "initis initis liala\r\n", "output": "NO\r\n"}, {"input": "initis initis etr\r\n", "output": "NO\r\n"}, {"input": "initis initis etra\r\n", "output": "NO\r\n"}, {"input": "initis initis initis\r\n", "output": "NO\r\n"}, {"input": "initis initis inites\r\n", "output": "NO\r\n"}, {"input": "initis inites lios\r\n", "output": "NO\r\n"}, {"input": "initis inites liala\r\n", "output": "NO\r\n"}, {"input": "initis inites etr\r\n", "output": "NO\r\n"}, {"input": "initis inites etra\r\n", "output": "NO\r\n"}, {"input": "initis inites initis\r\n", "output": "NO\r\n"}, {"input": "initis inites inites\r\n", "output": "NO\r\n"}, {"input": "inites lios lios\r\n", "output": "NO\r\n"}, {"input": "inites lios liala\r\n", "output": "NO\r\n"}, {"input": "inites lios etr\r\n", "output": "NO\r\n"}, {"input": "inites lios etra\r\n", "output": "NO\r\n"}, {"input": "inites lios initis\r\n", "output": "NO\r\n"}, {"input": "inites lios inites\r\n", "output": "NO\r\n"}, {"input": "inites liala lios\r\n", "output": "NO\r\n"}, {"input": "inites liala liala\r\n", "output": "NO\r\n"}, {"input": "inites liala etr\r\n", "output": "NO\r\n"}, {"input": "inites liala etra\r\n", "output": "NO\r\n"}, {"input": "inites liala initis\r\n", "output": "NO\r\n"}, {"input": "inites liala inites\r\n", "output": "NO\r\n"}, {"input": "inites etr lios\r\n", "output": "NO\r\n"}, {"input": "inites etr liala\r\n", "output": "NO\r\n"}, {"input": "inites etr etr\r\n", "output": "NO\r\n"}, {"input": "inites etr etra\r\n", "output": "NO\r\n"}, {"input": "inites etr initis\r\n", "output": "NO\r\n"}, {"input": "inites etr inites\r\n", "output": "NO\r\n"}, {"input": "inites etra lios\r\n", "output": "NO\r\n"}, {"input": "inites etra liala\r\n", "output": "NO\r\n"}, {"input": "inites etra etr\r\n", "output": "NO\r\n"}, {"input": "inites etra etra\r\n", "output": "NO\r\n"}, {"input": "inites etra initis\r\n", "output": "NO\r\n"}, {"input": "inites etra inites\r\n", "output": "NO\r\n"}, {"input": "inites initis lios\r\n", "output": "NO\r\n"}, {"input": "inites initis liala\r\n", "output": "NO\r\n"}, {"input": "inites initis etr\r\n", "output": "NO\r\n"}, {"input": "inites initis etra\r\n", "output": "NO\r\n"}, {"input": "inites initis initis\r\n", "output": "NO\r\n"}, {"input": "inites initis inites\r\n", "output": "NO\r\n"}, {"input": "inites inites lios\r\n", "output": "NO\r\n"}, {"input": "inites inites liala\r\n", "output": "NO\r\n"}, {"input": "inites inites etr\r\n", "output": "NO\r\n"}, {"input": "inites inites etra\r\n", "output": "NO\r\n"}, {"input": "inites inites initis\r\n", "output": "NO\r\n"}, {"input": "inites inites inites\r\n", "output": "NO\r\n"}]
| false |
stdio
| null | true |
113/A
|
113
|
A
|
Python 3
|
TESTS
| 66 | 216 | 8,396,800 |
127696390
|
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect, insort
from time import perf_counter
from fractions import Fraction
import copy
from copy import deepcopy
import time
starttime = time.time()
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def L(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]
try:
# sys.setrecursionlimit(int(pow(10,6)))
sys.stdin = open("input.txt", "r")
sys.stdout = open("../output.txt", "w")
except:
pass
def pmat(A):
for ele in A: print(*ele,end="\n")
# from sys import stdin
# input = stdin.buffer.readline
# I = lambda : list(map(int,input().split()))
# import sys
# input=sys.stdin.readline
s=input().split()
x=[]
y=[]
enc=0
gender=-1
for i in range(len(s)):
if s[i].endswith("etr"):
if enc:
print("NO")
exit()
if gender==0:
print("NO")
exit()
gender=1
enc=1
continue
elif s[i].endswith("etra"):
if enc:
print("NO")
exit()
if gender==1:
print("NO")
exit()
gender=0
enc=1
continue
if enc:
if (s[i].endswith("initis") and gender==0) or (s[i].endswith("inites") and gender==1) or (not s[i].endswith("initis") and not s[i].endswith("inites")):
print("NO")
exit()
y.append(s[i])
else:
x.append(s[i])
if x[-1].endswith("lios"):
if gender==-1:
gender=1
elif gender!=1:
print("NO")
exit()
elif x[-1].endswith("liala"):
if gender==-1:
gender=0
elif gender!=0:
print("NO")
exit()
else:
print("NO")
exit()
print("YES")
| 360 | 154 | 204,800 |
15182995
|
s, n, m, f = input().split(), False, False, False
def cc(w, me, fe):
global m, f
if w.endswith(me):
m = True
return True
elif w.endswith(fe):
f = True
return True
else:
return False
def ad(w): return cc(w, 'lios', 'liala')
def nn(w): return cc(w, 'etr', 'etra')
def vb(w): return cc(w, 'initis', 'inites')
for w in s:
if not n:
if ad(w) or vb(w) and len(s) == 1:
pass
elif nn(w):
n = True
else:
print('NO')
exit()
elif not vb(w):
print('NO')
exit()
print('YES' if len(s) == 1 or (n and (m ^ f)) else 'NO')
|
Codeforces Beta Round 86 (Div. 1 Only)
|
CF
| 2,011 | 5 | 256 |
Grammar Lessons
|
Petya got interested in grammar on his third year in school. He invented his own language called Petya's. Petya wanted to create a maximally simple language that would be enough to chat with friends, that's why all the language's grammar can be described with the following set of rules:
- There are three parts of speech: the adjective, the noun, the verb. Each word in his language is an adjective, noun or verb.
- There are two genders: masculine and feminine. Each word in his language has gender either masculine or feminine.
- Masculine adjectives end with -lios, and feminine adjectives end with -liala.
- Masculine nouns end with -etr, and feminime nouns end with -etra.
- Masculine verbs end with -initis, and feminime verbs end with -inites.
- Thus, each word in the Petya's language has one of the six endings, given above. There are no other endings in Petya's language.
- It is accepted that the whole word consists of an ending. That is, words "lios", "liala", "etr" and so on belong to the Petya's language.
- There aren't any punctuation marks, grammatical tenses, singular/plural forms or other language complications.
- A sentence is either exactly one valid language word or exactly one statement.
Statement is any sequence of the Petya's language, that satisfy both conditions:
- Words in statement follow in the following order (from the left to the right): zero or more adjectives followed by exactly one noun followed by zero or more verbs.
- All words in the statement should have the same gender.
After Petya's friend Vasya wrote instant messenger (an instant messaging program) that supported the Petya's language, Petya wanted to add spelling and grammar checking to the program. As Vasya was in the country and Petya didn't feel like waiting, he asked you to help him with this problem. Your task is to define by a given sequence of words, whether it is true that the given text represents exactly one sentence in Petya's language.
|
The first line contains one or more words consisting of lowercase Latin letters. The overall number of characters (including letters and spaces) does not exceed 105.
It is guaranteed that any two consecutive words are separated by exactly one space and the input data do not contain any other spaces. It is possible that given words do not belong to the Petya's language.
|
If some word of the given text does not belong to the Petya's language or if the text contains more that one sentence, print "NO" (without the quotes). Otherwise, print "YES" (without the quotes).
| null | null |
[{"input": "petr", "output": "YES"}, {"input": "etis atis animatis etis atis amatis", "output": "NO"}, {"input": "nataliala kataliala vetra feinites", "output": "YES"}]
| 1,600 |
["implementation", "strings"]
| 360 |
[{"input": "petr\r\n", "output": "YES\r\n"}, {"input": "etis atis animatis etis atis amatis\r\n", "output": "NO\r\n"}, {"input": "nataliala kataliala vetra feinites\r\n", "output": "YES\r\n"}, {"input": "qweasbvflios\r\n", "output": "YES\r\n"}, {"input": "lios lios petr initis qwe\r\n", "output": "NO\r\n"}, {"input": "lios initis\r\n", "output": "NO\r\n"}, {"input": "petr initis lios\r\n", "output": "NO\r\n"}, {"input": "petra petra petra\r\n", "output": "NO\r\n"}, {"input": "in\r\n", "output": "NO\r\n"}, {"input": "liala petra initis\r\n", "output": "NO\r\n"}, {"input": "liala petra inites\r\n", "output": "YES\r\n"}, {"input": "liala initis\r\n", "output": "NO\r\n"}, {"input": "liala petra petr inites\r\n", "output": "NO\r\n"}, {"input": "liala petr inites\r\n", "output": "NO\r\n"}, {"input": "llilitos\r\n", "output": "NO\r\n"}, {"input": "i i i i i i i i i i i i i i i a a a a a a v v v v v v v v v v v\r\n", "output": "NO\r\n"}, {"input": "hqaagnslliola vdumwjqalkyzbybwcaomxyffbkufaarhoebrqlpgshbmvjbwchfolyniuqkrysdhakzzrbiznhatifkbrqruswzhkewvgarmqtuadmsiquueumnpftiulfdpvzqfdgcfscczfsqivcdbuqvtyujirjwohskuabufdkehctkkguvetra oxnpizgojsrtinites\r\n", "output": "NO\r\n"}, {"input": "etretra linites\r\n", "output": "YES\r\n"}, {"input": "petretra petr\r\n", "output": "NO\r\n"}, {"input": "lialalios petraveryfunnypetr\r\n", "output": "YES\r\n"}, {"input": "petropetrapetr petra\r\n", "output": "NO\r\n"}, {"input": "lios petrnonono\r\n", "output": "NO\r\n"}, {"input": "lios petr initisandinitisandliala petrainitis\r\n", "output": "NO\r\n"}, {"input": "petro\r\n", "output": "NO\r\n"}, {"input": "petr initesinitis\r\n", "output": "YES\r\n"}, {"input": "lios initis\r\n", "output": "NO\r\n"}, {"input": "liala initespetra\r\n", "output": "YES\r\n"}, {"input": "lios petrapetr\r\n", "output": "YES\r\n"}, {"input": "initis petr\r\n", "output": "NO\r\n"}, {"input": "lioslialapetrpetrainitisinitesliosliala initesinitislioslialapetrpetrainitisinitetra\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixpetr\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixpetra\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixinitis\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixinites\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixliala\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixlios\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixlialas\r\n", "output": "NO\r\n"}, {"input": "veryfunnyprefixliala veryfunnyprefixpetretra\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixlios veryfunnyprefixinitisetr\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixlios aabbinitis\r\n", "output": "NO\r\n"}, {"input": "veryfunnyprefixlios inites\r\n", "output": "NO\r\n"}, {"input": "lios petr initis\r\n", "output": "YES\r\n"}, {"input": "liala etra inites\r\n", "output": "YES\r\n"}, {"input": "lios\r\n", "output": "YES\r\n"}, {"input": "liala\r\n", "output": "YES\r\n"}, {"input": "initis\r\n", "output": "YES\r\n"}, {"input": "inites\r\n", "output": "YES\r\n"}, {"input": "tes\r\n", "output": "NO\r\n"}, {"input": "tr\r\n", "output": "NO\r\n"}, {"input": "a\r\n", "output": "NO\r\n"}, {"input": "lios lios\r\n", "output": "NO\r\n"}, {"input": "lios\r\n", "output": "YES\r\n"}, {"input": "liala\r\n", "output": "YES\r\n"}, {"input": "petr\r\n", "output": "YES\r\n"}, {"input": "petra\r\n", "output": "YES\r\n"}, {"input": "pinitis\r\n", "output": "YES\r\n"}, {"input": "pinites\r\n", "output": "YES\r\n"}, {"input": "plios pliala\r\n", "output": "NO\r\n"}, {"input": "plios petr\r\n", "output": "YES\r\n"}, {"input": "plios petra\r\n", "output": "NO\r\n"}, {"input": "plios plios\r\n", "output": "NO\r\n"}, {"input": "plios initis\r\n", "output": "NO\r\n"}, {"input": "plios pinites\r\n", "output": "NO\r\n"}, {"input": "pliala plios\r\n", "output": "NO\r\n"}, {"input": "pliala ppliala\r\n", "output": "NO\r\n"}, {"input": "pliala petr\r\n", "output": "NO\r\n"}, {"input": "pliala petra\r\n", "output": "YES\r\n"}, {"input": "pliala pinitis\r\n", "output": "NO\r\n"}, {"input": "pliala pinites\r\n", "output": "NO\r\n"}, {"input": "petr plios\r\n", "output": "NO\r\n"}, {"input": "petr pliala\r\n", "output": "NO\r\n"}, {"input": "petr petr\r\n", "output": "NO\r\n"}, {"input": "petr petra\r\n", "output": "NO\r\n"}, {"input": "petr pinitis\r\n", "output": "YES\r\n"}, {"input": "petr pinites\r\n", "output": "NO\r\n"}, {"input": "petra lios\r\n", "output": "NO\r\n"}, {"input": "petra liala\r\n", "output": "NO\r\n"}, {"input": "petra petr\r\n", "output": "NO\r\n"}, {"input": "petra petra\r\n", "output": "NO\r\n"}, {"input": "petra initis\r\n", "output": "NO\r\n"}, {"input": "petra inites\r\n", "output": "YES\r\n"}, {"input": "initis lios\r\n", "output": "NO\r\n"}, {"input": "initis liala\r\n", "output": "NO\r\n"}, {"input": "initis petr\r\n", "output": "NO\r\n"}, {"input": "initis petra\r\n", "output": "NO\r\n"}, {"input": "initis initis\r\n", "output": "NO\r\n"}, {"input": "initis inites\r\n", "output": "NO\r\n"}, {"input": "inites lios\r\n", "output": "NO\r\n"}, {"input": "inites liala\r\n", "output": "NO\r\n"}, {"input": "inites petr\r\n", "output": "NO\r\n"}, {"input": "inites petra\r\n", "output": "NO\r\n"}, {"input": "inites initis\r\n", "output": "NO\r\n"}, {"input": "inites inites\r\n", "output": "NO\r\n"}, {"input": "lios lios lios\r\n", "output": "NO\r\n"}, {"input": "lios lios liala\r\n", "output": "NO\r\n"}, {"input": "lios lios etr\r\n", "output": "YES\r\n"}, {"input": "lios lios etra\r\n", "output": "NO\r\n"}, {"input": "lios lios initis\r\n", "output": "NO\r\n"}, {"input": "lios lios inites\r\n", "output": "NO\r\n"}, {"input": "lios liala lios\r\n", "output": "NO\r\n"}, {"input": "lios liala liala\r\n", "output": "NO\r\n"}, {"input": "lios liala etr\r\n", "output": "NO\r\n"}, {"input": "lios liala etra\r\n", "output": "NO\r\n"}, {"input": "lios liala initis\r\n", "output": "NO\r\n"}, {"input": "lios liala inites\r\n", "output": "NO\r\n"}, {"input": "lios etr lios\r\n", "output": "NO\r\n"}, {"input": "lios etr liala\r\n", "output": "NO\r\n"}, {"input": "lios etr etr\r\n", "output": "NO\r\n"}, {"input": "lios etr etra\r\n", "output": "NO\r\n"}, {"input": "lios etr initis\r\n", "output": "YES\r\n"}, {"input": "lios etr inites\r\n", "output": "NO\r\n"}, {"input": "lios etra lios\r\n", "output": "NO\r\n"}, {"input": "lios etra liala\r\n", "output": "NO\r\n"}, {"input": "lios etra etr\r\n", "output": "NO\r\n"}, {"input": "lios etra etra\r\n", "output": "NO\r\n"}, {"input": "lios etra initis\r\n", "output": "NO\r\n"}, {"input": "lios etra inites\r\n", "output": "NO\r\n"}, {"input": "lios initis lios\r\n", "output": "NO\r\n"}, {"input": "lios initis liala\r\n", "output": "NO\r\n"}, {"input": "lios initis etr\r\n", "output": "NO\r\n"}, {"input": "lios initis etra\r\n", "output": "NO\r\n"}, {"input": "lios initis initis\r\n", "output": "NO\r\n"}, {"input": "lios initis inites\r\n", "output": "NO\r\n"}, {"input": "lios inites lios\r\n", "output": "NO\r\n"}, {"input": "lios inites liala\r\n", "output": "NO\r\n"}, {"input": "lios inites etr\r\n", "output": "NO\r\n"}, {"input": "lios inites etra\r\n", "output": "NO\r\n"}, {"input": "lios inites initis\r\n", "output": "NO\r\n"}, {"input": "lios inites inites\r\n", "output": "NO\r\n"}, {"input": "liala lios lios\r\n", "output": "NO\r\n"}, {"input": "liala lios liala\r\n", "output": "NO\r\n"}, {"input": "liala lios etr\r\n", "output": "NO\r\n"}, {"input": "liala lios etra\r\n", "output": "NO\r\n"}, {"input": "liala lios initis\r\n", "output": "NO\r\n"}, {"input": "liala lios inites\r\n", "output": "NO\r\n"}, {"input": "liala liala lios\r\n", "output": "NO\r\n"}, {"input": "liala liala liala\r\n", "output": "NO\r\n"}, {"input": "liala liala etr\r\n", "output": "NO\r\n"}, {"input": "liala liala etra\r\n", "output": "YES\r\n"}, {"input": "liala liala initis\r\n", "output": "NO\r\n"}, {"input": "liala liala inites\r\n", "output": "NO\r\n"}, {"input": "liala etr lios\r\n", "output": "NO\r\n"}, {"input": "liala etr liala\r\n", "output": "NO\r\n"}, {"input": "liala etr etr\r\n", "output": "NO\r\n"}, {"input": "liala etr etra\r\n", "output": "NO\r\n"}, {"input": "liala etr initis\r\n", "output": "NO\r\n"}, {"input": "liala etr inites\r\n", "output": "NO\r\n"}, {"input": "liala etra lios\r\n", "output": "NO\r\n"}, {"input": "liala etra liala\r\n", "output": "NO\r\n"}, {"input": "liala etra etr\r\n", "output": "NO\r\n"}, {"input": "liala etra etra\r\n", "output": "NO\r\n"}, {"input": "liala etra initis\r\n", "output": "NO\r\n"}, {"input": "liala etra inites\r\n", "output": "YES\r\n"}, {"input": "liala initis lios\r\n", "output": "NO\r\n"}, {"input": "liala initis liala\r\n", "output": "NO\r\n"}, {"input": "liala initis etr\r\n", "output": "NO\r\n"}, {"input": "liala initis etra\r\n", "output": "NO\r\n"}, {"input": "liala initis initis\r\n", "output": "NO\r\n"}, {"input": "liala initis inites\r\n", "output": "NO\r\n"}, {"input": "liala inites lios\r\n", "output": "NO\r\n"}, {"input": "liala inites liala\r\n", "output": "NO\r\n"}, {"input": "liala inites etr\r\n", "output": "NO\r\n"}, {"input": "liala inites etra\r\n", "output": "NO\r\n"}, {"input": "liala inites initis\r\n", "output": "NO\r\n"}, {"input": "liala inites inites\r\n", "output": "NO\r\n"}, {"input": "etr lios lios\r\n", "output": "NO\r\n"}, {"input": "etr lios liala\r\n", "output": "NO\r\n"}, {"input": "etr lios etr\r\n", "output": "NO\r\n"}, {"input": "etr lios etra\r\n", "output": "NO\r\n"}, {"input": "etr lios initis\r\n", "output": "NO\r\n"}, {"input": "etr lios inites\r\n", "output": "NO\r\n"}, {"input": "etr liala lios\r\n", "output": "NO\r\n"}, {"input": "etr liala liala\r\n", "output": "NO\r\n"}, {"input": "etr liala etr\r\n", "output": "NO\r\n"}, {"input": "etr liala etra\r\n", "output": "NO\r\n"}, {"input": "etr liala initis\r\n", "output": "NO\r\n"}, {"input": "etr liala inites\r\n", "output": "NO\r\n"}, {"input": "etr etr lios\r\n", "output": "NO\r\n"}, {"input": "etr etr liala\r\n", "output": "NO\r\n"}, {"input": "etr etr etr\r\n", "output": "NO\r\n"}, {"input": "etr etr etra\r\n", "output": "NO\r\n"}, {"input": "etr etr initis\r\n", "output": "NO\r\n"}, {"input": "etr etr inites\r\n", "output": "NO\r\n"}, {"input": "etr etra lios\r\n", "output": "NO\r\n"}, {"input": "etr etra liala\r\n", "output": "NO\r\n"}, {"input": "etr etra etr\r\n", "output": "NO\r\n"}, {"input": "etr etra etra\r\n", "output": "NO\r\n"}, {"input": "etr etra initis\r\n", "output": "NO\r\n"}, {"input": "etr etra inites\r\n", "output": "NO\r\n"}, {"input": "etr initis lios\r\n", "output": "NO\r\n"}, {"input": "etr initis liala\r\n", "output": "NO\r\n"}, {"input": "etr initis etr\r\n", "output": "NO\r\n"}, {"input": "etr initis etra\r\n", "output": "NO\r\n"}, {"input": "etr initis initis\r\n", "output": "YES\r\n"}, {"input": "etr initis inites\r\n", "output": "NO\r\n"}, {"input": "etr inites lios\r\n", "output": "NO\r\n"}, {"input": "etr inites liala\r\n", "output": "NO\r\n"}, {"input": "etr inites etr\r\n", "output": "NO\r\n"}, {"input": "etr inites etra\r\n", "output": "NO\r\n"}, {"input": "etr inites initis\r\n", "output": "NO\r\n"}, {"input": "etr inites inites\r\n", "output": "NO\r\n"}, {"input": "etra lios lios\r\n", "output": "NO\r\n"}, {"input": "etra lios liala\r\n", "output": "NO\r\n"}, {"input": "etra lios etr\r\n", "output": "NO\r\n"}, {"input": "etra lios etra\r\n", "output": "NO\r\n"}, {"input": "etra lios initis\r\n", "output": "NO\r\n"}, {"input": "etra lios inites\r\n", "output": "NO\r\n"}, {"input": "etra liala lios\r\n", "output": "NO\r\n"}, {"input": "etra liala liala\r\n", "output": "NO\r\n"}, {"input": "etra liala etr\r\n", "output": "NO\r\n"}, {"input": "etra liala etra\r\n", "output": "NO\r\n"}, {"input": "etra liala initis\r\n", "output": "NO\r\n"}, {"input": "etra liala inites\r\n", "output": "NO\r\n"}, {"input": "etra etr lios\r\n", "output": "NO\r\n"}, {"input": "etra etr liala\r\n", "output": "NO\r\n"}, {"input": "etra etr etr\r\n", "output": "NO\r\n"}, {"input": "etra etr etra\r\n", "output": "NO\r\n"}, {"input": "etra etr initis\r\n", "output": "NO\r\n"}, {"input": "etra etr inites\r\n", "output": "NO\r\n"}, {"input": "etra etra lios\r\n", "output": "NO\r\n"}, {"input": "etra etra liala\r\n", "output": "NO\r\n"}, {"input": "etra etra etr\r\n", "output": "NO\r\n"}, {"input": "etra etra etra\r\n", "output": "NO\r\n"}, {"input": "etra etra initis\r\n", "output": "NO\r\n"}, {"input": "etra etra inites\r\n", "output": "NO\r\n"}, {"input": "etra initis lios\r\n", "output": "NO\r\n"}, {"input": "etra initis liala\r\n", "output": "NO\r\n"}, {"input": "etra initis etr\r\n", "output": "NO\r\n"}, {"input": "etra initis etra\r\n", "output": "NO\r\n"}, {"input": "etra initis initis\r\n", "output": "NO\r\n"}, {"input": "etra initis inites\r\n", "output": "NO\r\n"}, {"input": "etra inites lios\r\n", "output": "NO\r\n"}, {"input": "etra inites liala\r\n", "output": "NO\r\n"}, {"input": "etra inites etr\r\n", "output": "NO\r\n"}, {"input": "etra inites etra\r\n", "output": "NO\r\n"}, {"input": "etra inites initis\r\n", "output": "NO\r\n"}, {"input": "etra inites inites\r\n", "output": "YES\r\n"}, {"input": "initis lios lios\r\n", "output": "NO\r\n"}, {"input": "initis lios liala\r\n", "output": "NO\r\n"}, {"input": "initis lios etr\r\n", "output": "NO\r\n"}, {"input": "initis lios etra\r\n", "output": "NO\r\n"}, {"input": "initis lios initis\r\n", "output": "NO\r\n"}, {"input": "initis lios inites\r\n", "output": "NO\r\n"}, {"input": "initis liala lios\r\n", "output": "NO\r\n"}, {"input": "initis liala liala\r\n", "output": "NO\r\n"}, {"input": "initis liala etr\r\n", "output": "NO\r\n"}, {"input": "initis liala etra\r\n", "output": "NO\r\n"}, {"input": "initis liala initis\r\n", "output": "NO\r\n"}, {"input": "initis liala inites\r\n", "output": "NO\r\n"}, {"input": "initis etr lios\r\n", "output": "NO\r\n"}, {"input": "initis etr liala\r\n", "output": "NO\r\n"}, {"input": "initis etr etr\r\n", "output": "NO\r\n"}, {"input": "initis etr etra\r\n", "output": "NO\r\n"}, {"input": "initis etr initis\r\n", "output": "NO\r\n"}, {"input": "initis etr inites\r\n", "output": "NO\r\n"}, {"input": "initis etra lios\r\n", "output": "NO\r\n"}, {"input": "initis etra liala\r\n", "output": "NO\r\n"}, {"input": "initis etra etr\r\n", "output": "NO\r\n"}, {"input": "initis etra etra\r\n", "output": "NO\r\n"}, {"input": "initis etra initis\r\n", "output": "NO\r\n"}, {"input": "initis etra inites\r\n", "output": "NO\r\n"}, {"input": "initis initis lios\r\n", "output": "NO\r\n"}, {"input": "initis initis liala\r\n", "output": "NO\r\n"}, {"input": "initis initis etr\r\n", "output": "NO\r\n"}, {"input": "initis initis etra\r\n", "output": "NO\r\n"}, {"input": "initis initis initis\r\n", "output": "NO\r\n"}, {"input": "initis initis inites\r\n", "output": "NO\r\n"}, {"input": "initis inites lios\r\n", "output": "NO\r\n"}, {"input": "initis inites liala\r\n", "output": "NO\r\n"}, {"input": "initis inites etr\r\n", "output": "NO\r\n"}, {"input": "initis inites etra\r\n", "output": "NO\r\n"}, {"input": "initis inites initis\r\n", "output": "NO\r\n"}, {"input": "initis inites inites\r\n", "output": "NO\r\n"}, {"input": "inites lios lios\r\n", "output": "NO\r\n"}, {"input": "inites lios liala\r\n", "output": "NO\r\n"}, {"input": "inites lios etr\r\n", "output": "NO\r\n"}, {"input": "inites lios etra\r\n", "output": "NO\r\n"}, {"input": "inites lios initis\r\n", "output": "NO\r\n"}, {"input": "inites lios inites\r\n", "output": "NO\r\n"}, {"input": "inites liala lios\r\n", "output": "NO\r\n"}, {"input": "inites liala liala\r\n", "output": "NO\r\n"}, {"input": "inites liala etr\r\n", "output": "NO\r\n"}, {"input": "inites liala etra\r\n", "output": "NO\r\n"}, {"input": "inites liala initis\r\n", "output": "NO\r\n"}, {"input": "inites liala inites\r\n", "output": "NO\r\n"}, {"input": "inites etr lios\r\n", "output": "NO\r\n"}, {"input": "inites etr liala\r\n", "output": "NO\r\n"}, {"input": "inites etr etr\r\n", "output": "NO\r\n"}, {"input": "inites etr etra\r\n", "output": "NO\r\n"}, {"input": "inites etr initis\r\n", "output": "NO\r\n"}, {"input": "inites etr inites\r\n", "output": "NO\r\n"}, {"input": "inites etra lios\r\n", "output": "NO\r\n"}, {"input": "inites etra liala\r\n", "output": "NO\r\n"}, {"input": "inites etra etr\r\n", "output": "NO\r\n"}, {"input": "inites etra etra\r\n", "output": "NO\r\n"}, {"input": "inites etra initis\r\n", "output": "NO\r\n"}, {"input": "inites etra inites\r\n", "output": "NO\r\n"}, {"input": "inites initis lios\r\n", "output": "NO\r\n"}, {"input": "inites initis liala\r\n", "output": "NO\r\n"}, {"input": "inites initis etr\r\n", "output": "NO\r\n"}, {"input": "inites initis etra\r\n", "output": "NO\r\n"}, {"input": "inites initis initis\r\n", "output": "NO\r\n"}, {"input": "inites initis inites\r\n", "output": "NO\r\n"}, {"input": "inites inites lios\r\n", "output": "NO\r\n"}, {"input": "inites inites liala\r\n", "output": "NO\r\n"}, {"input": "inites inites etr\r\n", "output": "NO\r\n"}, {"input": "inites inites etra\r\n", "output": "NO\r\n"}, {"input": "inites inites initis\r\n", "output": "NO\r\n"}, {"input": "inites inites inites\r\n", "output": "NO\r\n"}]
| false |
stdio
| null | true |
113/A
|
113
|
A
|
Python 3
|
TESTS
| 66 | 218 | 614,400 |
99499790
|
lista = input().split()
passadj = False
passsub = False
gender = -1
can = True
# verificando os generos das palavras
for i in range(0,len(lista)):
if (len(lista[i]) >= 3 and lista[i][len(lista[i])-3::] == "etr") or (len(lista[i]) >= 4 and lista[i][len(lista[i])-4::] == "lios") or (len(lista[i]) >= 6 and lista[i][len(lista[i])-6::] == "initis"):
if gender == -1:
gender = 1
elif gender == 2:
can = False
else:
if gender == -1:
gender = 2
elif gender == 1:
can = False
# print(can)
# verificando os blocos
for i in range(0, len(lista)):
if (len(lista[i]) >= 4 and lista[i][len(lista[i])-4::] == "lios") or (len(lista[i]) >= 5 and lista[i][len(lista[i])-5::] == "liala"):
if(passadj == True):
can = False
elif (len(lista[i]) >= 3 and lista[i][len(lista[i])-3::] == "etr") or (len(lista[i]) >= 4 and lista[i][len(lista[i])-4::] == "etra"):
passadj = True
if passsub == True:
can = False
else:
passsub = True
elif (len(lista[i]) >= 6 and lista[i][len(lista[i])-6::] == "initis") or (len(lista[i]) >= 6 and lista[i][len(lista[i])-6::] == "inites"):
if passadj == False or passsub == False:
can = False
else:
can = False
# print(can)
if can:
print("YES\n")
else:
print("NO\n")
| 360 | 216 | 716,800 |
15383496
|
#!/usr/bin/python3
import re
al = re.compile(r'^1*23*$')
def getType(word):
if word.endswith("lios"): return 1
elif word.endswith("liala"): return -1
elif word.endswith("etr"): return 2
elif word.endswith("etra"): return -2
elif word.endswith("initis"):return 3
elif word.endswith("inites"): return -3
else: return 0
words = input().strip().split()
words = [getType(x) for x in words]
if len(words) == 1:
if words[0] != 0:print("YES")
else:print("NO")
else:
p = words[0]
for x in words:
if p*x <= 0:
print("NO")
exit()
words = [str(abs(x)) for x in words]
words = "".join(words)
#print(words)
if al.match(words):print("YES")
else:print("NO")
|
Codeforces Beta Round 86 (Div. 1 Only)
|
CF
| 2,011 | 5 | 256 |
Grammar Lessons
|
Petya got interested in grammar on his third year in school. He invented his own language called Petya's. Petya wanted to create a maximally simple language that would be enough to chat with friends, that's why all the language's grammar can be described with the following set of rules:
- There are three parts of speech: the adjective, the noun, the verb. Each word in his language is an adjective, noun or verb.
- There are two genders: masculine and feminine. Each word in his language has gender either masculine or feminine.
- Masculine adjectives end with -lios, and feminine adjectives end with -liala.
- Masculine nouns end with -etr, and feminime nouns end with -etra.
- Masculine verbs end with -initis, and feminime verbs end with -inites.
- Thus, each word in the Petya's language has one of the six endings, given above. There are no other endings in Petya's language.
- It is accepted that the whole word consists of an ending. That is, words "lios", "liala", "etr" and so on belong to the Petya's language.
- There aren't any punctuation marks, grammatical tenses, singular/plural forms or other language complications.
- A sentence is either exactly one valid language word or exactly one statement.
Statement is any sequence of the Petya's language, that satisfy both conditions:
- Words in statement follow in the following order (from the left to the right): zero or more adjectives followed by exactly one noun followed by zero or more verbs.
- All words in the statement should have the same gender.
After Petya's friend Vasya wrote instant messenger (an instant messaging program) that supported the Petya's language, Petya wanted to add spelling and grammar checking to the program. As Vasya was in the country and Petya didn't feel like waiting, he asked you to help him with this problem. Your task is to define by a given sequence of words, whether it is true that the given text represents exactly one sentence in Petya's language.
|
The first line contains one or more words consisting of lowercase Latin letters. The overall number of characters (including letters and spaces) does not exceed 105.
It is guaranteed that any two consecutive words are separated by exactly one space and the input data do not contain any other spaces. It is possible that given words do not belong to the Petya's language.
|
If some word of the given text does not belong to the Petya's language or if the text contains more that one sentence, print "NO" (without the quotes). Otherwise, print "YES" (without the quotes).
| null | null |
[{"input": "petr", "output": "YES"}, {"input": "etis atis animatis etis atis amatis", "output": "NO"}, {"input": "nataliala kataliala vetra feinites", "output": "YES"}]
| 1,600 |
["implementation", "strings"]
| 360 |
[{"input": "petr\r\n", "output": "YES\r\n"}, {"input": "etis atis animatis etis atis amatis\r\n", "output": "NO\r\n"}, {"input": "nataliala kataliala vetra feinites\r\n", "output": "YES\r\n"}, {"input": "qweasbvflios\r\n", "output": "YES\r\n"}, {"input": "lios lios petr initis qwe\r\n", "output": "NO\r\n"}, {"input": "lios initis\r\n", "output": "NO\r\n"}, {"input": "petr initis lios\r\n", "output": "NO\r\n"}, {"input": "petra petra petra\r\n", "output": "NO\r\n"}, {"input": "in\r\n", "output": "NO\r\n"}, {"input": "liala petra initis\r\n", "output": "NO\r\n"}, {"input": "liala petra inites\r\n", "output": "YES\r\n"}, {"input": "liala initis\r\n", "output": "NO\r\n"}, {"input": "liala petra petr inites\r\n", "output": "NO\r\n"}, {"input": "liala petr inites\r\n", "output": "NO\r\n"}, {"input": "llilitos\r\n", "output": "NO\r\n"}, {"input": "i i i i i i i i i i i i i i i a a a a a a v v v v v v v v v v v\r\n", "output": "NO\r\n"}, {"input": "hqaagnslliola vdumwjqalkyzbybwcaomxyffbkufaarhoebrqlpgshbmvjbwchfolyniuqkrysdhakzzrbiznhatifkbrqruswzhkewvgarmqtuadmsiquueumnpftiulfdpvzqfdgcfscczfsqivcdbuqvtyujirjwohskuabufdkehctkkguvetra oxnpizgojsrtinites\r\n", "output": "NO\r\n"}, {"input": "etretra linites\r\n", "output": "YES\r\n"}, {"input": "petretra petr\r\n", "output": "NO\r\n"}, {"input": "lialalios petraveryfunnypetr\r\n", "output": "YES\r\n"}, {"input": "petropetrapetr petra\r\n", "output": "NO\r\n"}, {"input": "lios petrnonono\r\n", "output": "NO\r\n"}, {"input": "lios petr initisandinitisandliala petrainitis\r\n", "output": "NO\r\n"}, {"input": "petro\r\n", "output": "NO\r\n"}, {"input": "petr initesinitis\r\n", "output": "YES\r\n"}, {"input": "lios initis\r\n", "output": "NO\r\n"}, {"input": "liala initespetra\r\n", "output": "YES\r\n"}, {"input": "lios petrapetr\r\n", "output": "YES\r\n"}, {"input": "initis petr\r\n", "output": "NO\r\n"}, {"input": "lioslialapetrpetrainitisinitesliosliala initesinitislioslialapetrpetrainitisinitetra\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixpetr\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixpetra\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixinitis\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixinites\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixliala\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixlios\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixlialas\r\n", "output": "NO\r\n"}, {"input": "veryfunnyprefixliala veryfunnyprefixpetretra\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixlios veryfunnyprefixinitisetr\r\n", "output": "YES\r\n"}, {"input": "veryfunnyprefixlios aabbinitis\r\n", "output": "NO\r\n"}, {"input": "veryfunnyprefixlios inites\r\n", "output": "NO\r\n"}, {"input": "lios petr initis\r\n", "output": "YES\r\n"}, {"input": "liala etra inites\r\n", "output": "YES\r\n"}, {"input": "lios\r\n", "output": "YES\r\n"}, {"input": "liala\r\n", "output": "YES\r\n"}, {"input": "initis\r\n", "output": "YES\r\n"}, {"input": "inites\r\n", "output": "YES\r\n"}, {"input": "tes\r\n", "output": "NO\r\n"}, {"input": "tr\r\n", "output": "NO\r\n"}, {"input": "a\r\n", "output": "NO\r\n"}, {"input": "lios lios\r\n", "output": "NO\r\n"}, {"input": "lios\r\n", "output": "YES\r\n"}, {"input": "liala\r\n", "output": "YES\r\n"}, {"input": "petr\r\n", "output": "YES\r\n"}, {"input": "petra\r\n", "output": "YES\r\n"}, {"input": "pinitis\r\n", "output": "YES\r\n"}, {"input": "pinites\r\n", "output": "YES\r\n"}, {"input": "plios pliala\r\n", "output": "NO\r\n"}, {"input": "plios petr\r\n", "output": "YES\r\n"}, {"input": "plios petra\r\n", "output": "NO\r\n"}, {"input": "plios plios\r\n", "output": "NO\r\n"}, {"input": "plios initis\r\n", "output": "NO\r\n"}, {"input": "plios pinites\r\n", "output": "NO\r\n"}, {"input": "pliala plios\r\n", "output": "NO\r\n"}, {"input": "pliala ppliala\r\n", "output": "NO\r\n"}, {"input": "pliala petr\r\n", "output": "NO\r\n"}, {"input": "pliala petra\r\n", "output": "YES\r\n"}, {"input": "pliala pinitis\r\n", "output": "NO\r\n"}, {"input": "pliala pinites\r\n", "output": "NO\r\n"}, {"input": "petr plios\r\n", "output": "NO\r\n"}, {"input": "petr pliala\r\n", "output": "NO\r\n"}, {"input": "petr petr\r\n", "output": "NO\r\n"}, {"input": "petr petra\r\n", "output": "NO\r\n"}, {"input": "petr pinitis\r\n", "output": "YES\r\n"}, {"input": "petr pinites\r\n", "output": "NO\r\n"}, {"input": "petra lios\r\n", "output": "NO\r\n"}, {"input": "petra liala\r\n", "output": "NO\r\n"}, {"input": "petra petr\r\n", "output": "NO\r\n"}, {"input": "petra petra\r\n", "output": "NO\r\n"}, {"input": "petra initis\r\n", "output": "NO\r\n"}, {"input": "petra inites\r\n", "output": "YES\r\n"}, {"input": "initis lios\r\n", "output": "NO\r\n"}, {"input": "initis liala\r\n", "output": "NO\r\n"}, {"input": "initis petr\r\n", "output": "NO\r\n"}, {"input": "initis petra\r\n", "output": "NO\r\n"}, {"input": "initis initis\r\n", "output": "NO\r\n"}, {"input": "initis inites\r\n", "output": "NO\r\n"}, {"input": "inites lios\r\n", "output": "NO\r\n"}, {"input": "inites liala\r\n", "output": "NO\r\n"}, {"input": "inites petr\r\n", "output": "NO\r\n"}, {"input": "inites petra\r\n", "output": "NO\r\n"}, {"input": "inites initis\r\n", "output": "NO\r\n"}, {"input": "inites inites\r\n", "output": "NO\r\n"}, {"input": "lios lios lios\r\n", "output": "NO\r\n"}, {"input": "lios lios liala\r\n", "output": "NO\r\n"}, {"input": "lios lios etr\r\n", "output": "YES\r\n"}, {"input": "lios lios etra\r\n", "output": "NO\r\n"}, {"input": "lios lios initis\r\n", "output": "NO\r\n"}, {"input": "lios lios inites\r\n", "output": "NO\r\n"}, {"input": "lios liala lios\r\n", "output": "NO\r\n"}, {"input": "lios liala liala\r\n", "output": "NO\r\n"}, {"input": "lios liala etr\r\n", "output": "NO\r\n"}, {"input": "lios liala etra\r\n", "output": "NO\r\n"}, {"input": "lios liala initis\r\n", "output": "NO\r\n"}, {"input": "lios liala inites\r\n", "output": "NO\r\n"}, {"input": "lios etr lios\r\n", "output": "NO\r\n"}, {"input": "lios etr liala\r\n", "output": "NO\r\n"}, {"input": "lios etr etr\r\n", "output": "NO\r\n"}, {"input": "lios etr etra\r\n", "output": "NO\r\n"}, {"input": "lios etr initis\r\n", "output": "YES\r\n"}, {"input": "lios etr inites\r\n", "output": "NO\r\n"}, {"input": "lios etra lios\r\n", "output": "NO\r\n"}, {"input": "lios etra liala\r\n", "output": "NO\r\n"}, {"input": "lios etra etr\r\n", "output": "NO\r\n"}, {"input": "lios etra etra\r\n", "output": "NO\r\n"}, {"input": "lios etra initis\r\n", "output": "NO\r\n"}, {"input": "lios etra inites\r\n", "output": "NO\r\n"}, {"input": "lios initis lios\r\n", "output": "NO\r\n"}, {"input": "lios initis liala\r\n", "output": "NO\r\n"}, {"input": "lios initis etr\r\n", "output": "NO\r\n"}, {"input": "lios initis etra\r\n", "output": "NO\r\n"}, {"input": "lios initis initis\r\n", "output": "NO\r\n"}, {"input": "lios initis inites\r\n", "output": "NO\r\n"}, {"input": "lios inites lios\r\n", "output": "NO\r\n"}, {"input": "lios inites liala\r\n", "output": "NO\r\n"}, {"input": "lios inites etr\r\n", "output": "NO\r\n"}, {"input": "lios inites etra\r\n", "output": "NO\r\n"}, {"input": "lios inites initis\r\n", "output": "NO\r\n"}, {"input": "lios inites inites\r\n", "output": "NO\r\n"}, {"input": "liala lios lios\r\n", "output": "NO\r\n"}, {"input": "liala lios liala\r\n", "output": "NO\r\n"}, {"input": "liala lios etr\r\n", "output": "NO\r\n"}, {"input": "liala lios etra\r\n", "output": "NO\r\n"}, {"input": "liala lios initis\r\n", "output": "NO\r\n"}, {"input": "liala lios inites\r\n", "output": "NO\r\n"}, {"input": "liala liala lios\r\n", "output": "NO\r\n"}, {"input": "liala liala liala\r\n", "output": "NO\r\n"}, {"input": "liala liala etr\r\n", "output": "NO\r\n"}, {"input": "liala liala etra\r\n", "output": "YES\r\n"}, {"input": "liala liala initis\r\n", "output": "NO\r\n"}, {"input": "liala liala inites\r\n", "output": "NO\r\n"}, {"input": "liala etr lios\r\n", "output": "NO\r\n"}, {"input": "liala etr liala\r\n", "output": "NO\r\n"}, {"input": "liala etr etr\r\n", "output": "NO\r\n"}, {"input": "liala etr etra\r\n", "output": "NO\r\n"}, {"input": "liala etr initis\r\n", "output": "NO\r\n"}, {"input": "liala etr inites\r\n", "output": "NO\r\n"}, {"input": "liala etra lios\r\n", "output": "NO\r\n"}, {"input": "liala etra liala\r\n", "output": "NO\r\n"}, {"input": "liala etra etr\r\n", "output": "NO\r\n"}, {"input": "liala etra etra\r\n", "output": "NO\r\n"}, {"input": "liala etra initis\r\n", "output": "NO\r\n"}, {"input": "liala etra inites\r\n", "output": "YES\r\n"}, {"input": "liala initis lios\r\n", "output": "NO\r\n"}, {"input": "liala initis liala\r\n", "output": "NO\r\n"}, {"input": "liala initis etr\r\n", "output": "NO\r\n"}, {"input": "liala initis etra\r\n", "output": "NO\r\n"}, {"input": "liala initis initis\r\n", "output": "NO\r\n"}, {"input": "liala initis inites\r\n", "output": "NO\r\n"}, {"input": "liala inites lios\r\n", "output": "NO\r\n"}, {"input": "liala inites liala\r\n", "output": "NO\r\n"}, {"input": "liala inites etr\r\n", "output": "NO\r\n"}, {"input": "liala inites etra\r\n", "output": "NO\r\n"}, {"input": "liala inites initis\r\n", "output": "NO\r\n"}, {"input": "liala inites inites\r\n", "output": "NO\r\n"}, {"input": "etr lios lios\r\n", "output": "NO\r\n"}, {"input": "etr lios liala\r\n", "output": "NO\r\n"}, {"input": "etr lios etr\r\n", "output": "NO\r\n"}, {"input": "etr lios etra\r\n", "output": "NO\r\n"}, {"input": "etr lios initis\r\n", "output": "NO\r\n"}, {"input": "etr lios inites\r\n", "output": "NO\r\n"}, {"input": "etr liala lios\r\n", "output": "NO\r\n"}, {"input": "etr liala liala\r\n", "output": "NO\r\n"}, {"input": "etr liala etr\r\n", "output": "NO\r\n"}, {"input": "etr liala etra\r\n", "output": "NO\r\n"}, {"input": "etr liala initis\r\n", "output": "NO\r\n"}, {"input": "etr liala inites\r\n", "output": "NO\r\n"}, {"input": "etr etr lios\r\n", "output": "NO\r\n"}, {"input": "etr etr liala\r\n", "output": "NO\r\n"}, {"input": "etr etr etr\r\n", "output": "NO\r\n"}, {"input": "etr etr etra\r\n", "output": "NO\r\n"}, {"input": "etr etr initis\r\n", "output": "NO\r\n"}, {"input": "etr etr inites\r\n", "output": "NO\r\n"}, {"input": "etr etra lios\r\n", "output": "NO\r\n"}, {"input": "etr etra liala\r\n", "output": "NO\r\n"}, {"input": "etr etra etr\r\n", "output": "NO\r\n"}, {"input": "etr etra etra\r\n", "output": "NO\r\n"}, {"input": "etr etra initis\r\n", "output": "NO\r\n"}, {"input": "etr etra inites\r\n", "output": "NO\r\n"}, {"input": "etr initis lios\r\n", "output": "NO\r\n"}, {"input": "etr initis liala\r\n", "output": "NO\r\n"}, {"input": "etr initis etr\r\n", "output": "NO\r\n"}, {"input": "etr initis etra\r\n", "output": "NO\r\n"}, {"input": "etr initis initis\r\n", "output": "YES\r\n"}, {"input": "etr initis inites\r\n", "output": "NO\r\n"}, {"input": "etr inites lios\r\n", "output": "NO\r\n"}, {"input": "etr inites liala\r\n", "output": "NO\r\n"}, {"input": "etr inites etr\r\n", "output": "NO\r\n"}, {"input": "etr inites etra\r\n", "output": "NO\r\n"}, {"input": "etr inites initis\r\n", "output": "NO\r\n"}, {"input": "etr inites inites\r\n", "output": "NO\r\n"}, {"input": "etra lios lios\r\n", "output": "NO\r\n"}, {"input": "etra lios liala\r\n", "output": "NO\r\n"}, {"input": "etra lios etr\r\n", "output": "NO\r\n"}, {"input": "etra lios etra\r\n", "output": "NO\r\n"}, {"input": "etra lios initis\r\n", "output": "NO\r\n"}, {"input": "etra lios inites\r\n", "output": "NO\r\n"}, {"input": "etra liala lios\r\n", "output": "NO\r\n"}, {"input": "etra liala liala\r\n", "output": "NO\r\n"}, {"input": "etra liala etr\r\n", "output": "NO\r\n"}, {"input": "etra liala etra\r\n", "output": "NO\r\n"}, {"input": "etra liala initis\r\n", "output": "NO\r\n"}, {"input": "etra liala inites\r\n", "output": "NO\r\n"}, {"input": "etra etr lios\r\n", "output": "NO\r\n"}, {"input": "etra etr liala\r\n", "output": "NO\r\n"}, {"input": "etra etr etr\r\n", "output": "NO\r\n"}, {"input": "etra etr etra\r\n", "output": "NO\r\n"}, {"input": "etra etr initis\r\n", "output": "NO\r\n"}, {"input": "etra etr inites\r\n", "output": "NO\r\n"}, {"input": "etra etra lios\r\n", "output": "NO\r\n"}, {"input": "etra etra liala\r\n", "output": "NO\r\n"}, {"input": "etra etra etr\r\n", "output": "NO\r\n"}, {"input": "etra etra etra\r\n", "output": "NO\r\n"}, {"input": "etra etra initis\r\n", "output": "NO\r\n"}, {"input": "etra etra inites\r\n", "output": "NO\r\n"}, {"input": "etra initis lios\r\n", "output": "NO\r\n"}, {"input": "etra initis liala\r\n", "output": "NO\r\n"}, {"input": "etra initis etr\r\n", "output": "NO\r\n"}, {"input": "etra initis etra\r\n", "output": "NO\r\n"}, {"input": "etra initis initis\r\n", "output": "NO\r\n"}, {"input": "etra initis inites\r\n", "output": "NO\r\n"}, {"input": "etra inites lios\r\n", "output": "NO\r\n"}, {"input": "etra inites liala\r\n", "output": "NO\r\n"}, {"input": "etra inites etr\r\n", "output": "NO\r\n"}, {"input": "etra inites etra\r\n", "output": "NO\r\n"}, {"input": "etra inites initis\r\n", "output": "NO\r\n"}, {"input": "etra inites inites\r\n", "output": "YES\r\n"}, {"input": "initis lios lios\r\n", "output": "NO\r\n"}, {"input": "initis lios liala\r\n", "output": "NO\r\n"}, {"input": "initis lios etr\r\n", "output": "NO\r\n"}, {"input": "initis lios etra\r\n", "output": "NO\r\n"}, {"input": "initis lios initis\r\n", "output": "NO\r\n"}, {"input": "initis lios inites\r\n", "output": "NO\r\n"}, {"input": "initis liala lios\r\n", "output": "NO\r\n"}, {"input": "initis liala liala\r\n", "output": "NO\r\n"}, {"input": "initis liala etr\r\n", "output": "NO\r\n"}, {"input": "initis liala etra\r\n", "output": "NO\r\n"}, {"input": "initis liala initis\r\n", "output": "NO\r\n"}, {"input": "initis liala inites\r\n", "output": "NO\r\n"}, {"input": "initis etr lios\r\n", "output": "NO\r\n"}, {"input": "initis etr liala\r\n", "output": "NO\r\n"}, {"input": "initis etr etr\r\n", "output": "NO\r\n"}, {"input": "initis etr etra\r\n", "output": "NO\r\n"}, {"input": "initis etr initis\r\n", "output": "NO\r\n"}, {"input": "initis etr inites\r\n", "output": "NO\r\n"}, {"input": "initis etra lios\r\n", "output": "NO\r\n"}, {"input": "initis etra liala\r\n", "output": "NO\r\n"}, {"input": "initis etra etr\r\n", "output": "NO\r\n"}, {"input": "initis etra etra\r\n", "output": "NO\r\n"}, {"input": "initis etra initis\r\n", "output": "NO\r\n"}, {"input": "initis etra inites\r\n", "output": "NO\r\n"}, {"input": "initis initis lios\r\n", "output": "NO\r\n"}, {"input": "initis initis liala\r\n", "output": "NO\r\n"}, {"input": "initis initis etr\r\n", "output": "NO\r\n"}, {"input": "initis initis etra\r\n", "output": "NO\r\n"}, {"input": "initis initis initis\r\n", "output": "NO\r\n"}, {"input": "initis initis inites\r\n", "output": "NO\r\n"}, {"input": "initis inites lios\r\n", "output": "NO\r\n"}, {"input": "initis inites liala\r\n", "output": "NO\r\n"}, {"input": "initis inites etr\r\n", "output": "NO\r\n"}, {"input": "initis inites etra\r\n", "output": "NO\r\n"}, {"input": "initis inites initis\r\n", "output": "NO\r\n"}, {"input": "initis inites inites\r\n", "output": "NO\r\n"}, {"input": "inites lios lios\r\n", "output": "NO\r\n"}, {"input": "inites lios liala\r\n", "output": "NO\r\n"}, {"input": "inites lios etr\r\n", "output": "NO\r\n"}, {"input": "inites lios etra\r\n", "output": "NO\r\n"}, {"input": "inites lios initis\r\n", "output": "NO\r\n"}, {"input": "inites lios inites\r\n", "output": "NO\r\n"}, {"input": "inites liala lios\r\n", "output": "NO\r\n"}, {"input": "inites liala liala\r\n", "output": "NO\r\n"}, {"input": "inites liala etr\r\n", "output": "NO\r\n"}, {"input": "inites liala etra\r\n", "output": "NO\r\n"}, {"input": "inites liala initis\r\n", "output": "NO\r\n"}, {"input": "inites liala inites\r\n", "output": "NO\r\n"}, {"input": "inites etr lios\r\n", "output": "NO\r\n"}, {"input": "inites etr liala\r\n", "output": "NO\r\n"}, {"input": "inites etr etr\r\n", "output": "NO\r\n"}, {"input": "inites etr etra\r\n", "output": "NO\r\n"}, {"input": "inites etr initis\r\n", "output": "NO\r\n"}, {"input": "inites etr inites\r\n", "output": "NO\r\n"}, {"input": "inites etra lios\r\n", "output": "NO\r\n"}, {"input": "inites etra liala\r\n", "output": "NO\r\n"}, {"input": "inites etra etr\r\n", "output": "NO\r\n"}, {"input": "inites etra etra\r\n", "output": "NO\r\n"}, {"input": "inites etra initis\r\n", "output": "NO\r\n"}, {"input": "inites etra inites\r\n", "output": "NO\r\n"}, {"input": "inites initis lios\r\n", "output": "NO\r\n"}, {"input": "inites initis liala\r\n", "output": "NO\r\n"}, {"input": "inites initis etr\r\n", "output": "NO\r\n"}, {"input": "inites initis etra\r\n", "output": "NO\r\n"}, {"input": "inites initis initis\r\n", "output": "NO\r\n"}, {"input": "inites initis inites\r\n", "output": "NO\r\n"}, {"input": "inites inites lios\r\n", "output": "NO\r\n"}, {"input": "inites inites liala\r\n", "output": "NO\r\n"}, {"input": "inites inites etr\r\n", "output": "NO\r\n"}, {"input": "inites inites etra\r\n", "output": "NO\r\n"}, {"input": "inites inites initis\r\n", "output": "NO\r\n"}, {"input": "inites inites inites\r\n", "output": "NO\r\n"}]
| false |
stdio
| null | true |
818/C
|
818
|
C
|
Python 3
|
TESTS
| 16 | 763 | 26,828,800 |
28155256
|
from sys import stdin, stdout
k = int(stdin.readline())
n, m = map(int, stdin.readline().split())
left, right, down, up = [], [], [], []
challengers = []
for i in range(k):
x1, y1, x2, y2 = map(int, stdin.readline().split())
if x1 == x2:
if y1 < y2:
challengers.append((x1, y1, x2, y2, i))
else:
challengers.append((x2, y2, x1, y1, i))
else:
if x1 < x2:
challengers.append((x1, y1, x2, y2, i))
else:
challengers.append((x2, y2, x1, y1, i))
left.append(challengers[-1])
right.append(challengers[-1])
up.append(challengers[-1])
down.append(challengers[-1])
left.sort(key = lambda x: (x[0], x[2]))
down.sort(key = lambda x: (x[1], x[3]))
challengers = [[], [], [], []]
cntl, cntr, cntd, cntu = map(int, stdin.readline().split())
if cntl:
for i in range(cntl, -1, -1):
if (left[i][0], left[i][2]) == (left[cntl][0], left[cntl][2]):
challengers[0].append(left[i][-1])
else:
break
for i in range(cntl + 1, k):
if (left[i][0], left[i][2]) == (left[cntl][0], left[cntl][2]):
challengers[0].append(left[i][-1])
else:
break
else:
for i in range(k):
if (left[i][0], left[i][2]) == (left[0][0], left[0][2]):
challengers[0].append(left[i][-1])
else:
break
if cntr:
for i in range(k - 1 - cntr, k):
if (left[i][0], left[i][2]) == (left[k - 1 - cntr][0], left[k - 1 - cntr][2]):
challengers[1].append(left[i][-1])
else:
break
for i in range(k - 2 - cntr, -1, -1):
if (left[i][0], left[i][2]) == (left[k - 1 - cntr][0], left[k - 1 - cntr][2]):
challengers[1].append(left[i][-1])
else:
break
else:
for i in range(k - 1, -1, -1):
if (left[i][0], left[i][2]) == (left[k - 1][0], left[k - 1][2]):
challengers[1].append(left[i][-1])
else:
break
#!!!!!!!!!!!
if cntd:
for i in range(cntd, -1, -1):
if (down[i][1], down[i][3]) == (down[cntd][1], down[cntd][3]):
challengers[2].append(down[i][-1])
else:
break
for i in range(cntd + 1, k):
if (down[i][1], down[i][3]) == (down[cntd][1], down[cntd][3]):
challengers[2].append(down[i][-1])
else:
break
else:
for i in range(k):
if (down[i][1], down[i][3]) == (down[0][1], down[0][3]):
challengers[2].append(down[i][-1])
else:
break
if cntu:
for i in range(k - 1 - cntu, k):
if (down[i][1], down[i][3]) == (down[k - 1 - cntu][1], down[k - 1 - cntu][3]):
challengers[3].append(down[i][-1])
else:
break
for i in range(k - 2 - cntu, -1, -1):
if (down[i][1], down[i][3]) == (down[k - 1 - cntu][1], down[k - 1 - cntu][3]):
challengers[3].append(down[i][-1])
else:
break
else:
for i in range(k - 1, -1, -1):
if (down[i][1], down[i][3]) == (down[k - 1][1], down[k - 1][3]):
challengers[3].append(down[i][-1])
else:
break
ans = set(challengers[0]) & set(challengers[1]) & set(challengers[2]) & set(challengers[3])
if not len(ans):
stdout.write('-1')
else:
stdout.write(str(list(ans)[0] + 1))
| 212 | 482 | 40,140,800 |
170725525
|
import sys
import io, os
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
d = int(input())
n, m = map(int, input().split())
L = []
R = []
T = []
B = []
XY = []
for i in range(d):
x1, y1, x2, y2 = map(int, input().split())
L.append((min(x1, x2)))
R.append(-max(x1, x2))
T.append(min(y1, y2))
B.append(-max(y1, y2))
XY.append((x1, y1, x2, y2))
cntl, cntr, cntt, cntb = map(int, input().split())
cnt = [cntl, cntr, cntt, cntb]
L.sort()
R.sort()
T.sort()
B.sort()
import bisect
for i in range(d):
x1, y1, x2, y2 = XY[i]
if x1 != x2:
l = bisect.bisect_left(L, max(x1, x2))-1
else:
l = bisect.bisect_left(L, max(x1, x2))
if x1 != x2:
r = bisect.bisect_left(R, -min(x1, x2))-1
else:
r = bisect.bisect_left(R, -min(x1, x2))
if y1 != y2:
t = bisect.bisect_left(T, max(y1, y2))-1
else:
t = bisect.bisect_left(T, max(y1, y2))
if y1 != y2:
b = bisect.bisect_left(B, -min(y1, y2))-1
else:
b = bisect.bisect_left(B, -min(y1, y2))
if cnt == [l, r, t, b]:
print(i+1)
exit()
print(-1)
|
Educational Codeforces Round 24
|
ICPC
| 2,017 | 1 | 256 |
Sofa Thief
|
Yet another round on DecoForces is coming! Grandpa Maks wanted to participate in it but someone has stolen his precious sofa! And how can one perform well with such a major loss?
Fortunately, the thief had left a note for Grandpa Maks. This note got Maks to the sofa storehouse. Still he had no idea which sofa belongs to him as they all looked the same!
The storehouse is represented as matrix n × m. Every sofa takes two neighbouring by some side cells. No cell is covered by more than one sofa. There can be empty cells.
Sofa A is standing to the left of sofa B if there exist two such cells a and b that xa < xb, a is covered by A and b is covered by B. Sofa A is standing to the top of sofa B if there exist two such cells a and b that ya < yb, a is covered by A and b is covered by B. Right and bottom conditions are declared the same way.
Note that in all conditions A ≠ B. Also some sofa A can be both to the top of another sofa B and to the bottom of it. The same is for left and right conditions.
The note also stated that there are cntl sofas to the left of Grandpa Maks's sofa, cntr — to the right, cntt — to the top and cntb — to the bottom.
Grandpa Maks asks you to help him to identify his sofa. It is guaranteed that there is no more than one sofa of given conditions.
Output the number of Grandpa Maks's sofa. If there is no such sofa that all the conditions are met for it then output -1.
|
The first line contains one integer number d (1 ≤ d ≤ 105) — the number of sofas in the storehouse.
The second line contains two integer numbers n, m (1 ≤ n, m ≤ 105) — the size of the storehouse.
Next d lines contains four integer numbers x1, y1, x2, y2 (1 ≤ x1, x2 ≤ n, 1 ≤ y1, y2 ≤ m) — coordinates of the i-th sofa. It is guaranteed that cells (x1, y1) and (x2, y2) have common side, (x1, y1) ≠ (x2, y2) and no cell is covered by more than one sofa.
The last line contains four integer numbers cntl, cntr, cntt, cntb (0 ≤ cntl, cntr, cntt, cntb ≤ d - 1).
|
Print the number of the sofa for which all the conditions are met. Sofas are numbered 1 through d as given in input. If there is no such sofa then print -1.
| null |
Let's consider the second example.
- The first sofa has 0 to its left, 2 sofas to its right ((1, 1) is to the left of both (5, 5) and (5, 4)), 0 to its top and 2 to its bottom (both 2nd and 3rd sofas are below).
- The second sofa has cntl = 2, cntr = 1, cntt = 2 and cntb = 0.
- The third sofa has cntl = 2, cntr = 1, cntt = 1 and cntb = 1.
So the second one corresponds to the given conditions.
In the third example
- The first sofa has cntl = 1, cntr = 1, cntt = 0 and cntb = 1.
- The second sofa has cntl = 1, cntr = 1, cntt = 1 and cntb = 0.
And there is no sofa with the set (1, 0, 0, 0) so the answer is -1.
|
[{"input": "2\n3 2\n3 1 3 2\n1 2 2 2\n1 0 0 1", "output": "1"}, {"input": "3\n10 10\n1 2 1 1\n5 5 6 5\n6 4 5 4\n2 1 2 0", "output": "2"}, {"input": "2\n2 2\n2 1 1 1\n1 2 2 2\n1 0 0 0", "output": "-1"}]
| 2,000 |
["brute force", "implementation"]
| 212 |
[{"input": "2\r\n3 2\r\n3 1 3 2\r\n1 2 2 2\r\n1 0 0 1\r\n", "output": "1\r\n"}, {"input": "3\r\n10 10\r\n1 2 1 1\r\n5 5 6 5\r\n6 4 5 4\r\n2 1 2 0\r\n", "output": "2\r\n"}, {"input": "2\r\n2 2\r\n2 1 1 1\r\n1 2 2 2\r\n1 0 0 0\r\n", "output": "-1\r\n"}, {"input": "1\r\n1 2\r\n1 1 1 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n2 1\r\n2 1 1 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n1000 1000\r\n63 902 63 901\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "6\r\n10 10\r\n3 6 3 7\r\n4 9 5 9\r\n5 4 5 3\r\n7 1 8 1\r\n9 10 8 10\r\n7 7 7 8\r\n0 5 2 3\r\n", "output": "1\r\n"}, {"input": "2\r\n4 4\r\n3 1 3 2\r\n2 2 2 1\r\n0 0 0 0\r\n", "output": "-1\r\n"}, {"input": "2\r\n2 2\r\n1 1 1 2\r\n2 1 2 2\r\n0 1 1 1\r\n", "output": "1\r\n"}, {"input": "2\r\n2 2\r\n1 1 1 2\r\n2 1 2 2\r\n1 0 1 1\r\n", "output": "2\r\n"}, {"input": "2\r\n2 2\r\n1 1 1 2\r\n2 1 2 2\r\n0 1 1 0\r\n", "output": "-1\r\n"}, {"input": "1\r\n1 2\r\n1 2 1 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n1 3\r\n1 2 1 3\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n1 4\r\n1 2 1 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n1 5\r\n1 4 1 3\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n1 6\r\n1 6 1 5\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n1 7\r\n1 6 1 7\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n2 1\r\n2 1 1 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n2 2\r\n2 2 2 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n2 3\r\n1 2 1 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n2 4\r\n2 3 2 4\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n2 5\r\n2 4 1 4\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n2 6\r\n2 1 1 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n2 7\r\n2 7 2 6\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n3 1\r\n2 1 3 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n3 2\r\n1 1 2 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n3 3\r\n3 2 3 3\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n3 4\r\n2 1 2 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n3 5\r\n2 2 2 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n3 6\r\n1 4 2 4\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n3 7\r\n2 2 1 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n4 1\r\n1 1 2 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n4 2\r\n1 1 1 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n4 3\r\n4 3 4 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n4 4\r\n3 2 3 3\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n4 5\r\n1 2 2 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n4 6\r\n4 3 4 4\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n4 7\r\n3 6 4 6\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n5 1\r\n2 1 1 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n5 2\r\n5 1 4 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n5 3\r\n4 2 3 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n5 4\r\n2 4 3 4\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n5 5\r\n4 1 3 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n5 6\r\n3 3 3 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n5 7\r\n1 6 1 7\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n6 1\r\n6 1 5 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n6 2\r\n4 2 5 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n6 3\r\n1 2 1 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n6 4\r\n2 2 3 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n6 5\r\n6 1 6 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n6 6\r\n4 1 3 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n6 7\r\n6 7 6 6\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n7 1\r\n6 1 7 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n7 2\r\n4 2 4 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n7 3\r\n7 1 7 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n7 4\r\n3 3 3 4\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n7 5\r\n6 4 7 4\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n7 6\r\n2 2 2 3\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n7 7\r\n1 3 2 3\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n1 4\r\n1 4 1 3\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "2\r\n1 5\r\n1 5 1 4\r\n1 1 1 2\r\n0 0 1 0\r\n", "output": "1\r\n"}, {"input": "1\r\n1 6\r\n1 2 1 3\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "2\r\n1 7\r\n1 7 1 6\r\n1 4 1 5\r\n0 0 1 0\r\n", "output": "1\r\n"}, {"input": "1\r\n2 2\r\n2 1 2 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "2\r\n2 3\r\n2 3 1 3\r\n1 2 2 2\r\n0 0 0 1\r\n", "output": "-1\r\n"}, {"input": "2\r\n2 4\r\n2 2 2 1\r\n2 4 1 4\r\n0 1 1 0\r\n", "output": "2\r\n"}, {"input": "2\r\n2 5\r\n2 2 2 1\r\n1 3 1 4\r\n1 0 0 1\r\n", "output": "1\r\n"}, {"input": "2\r\n2 6\r\n1 2 1 1\r\n2 1 2 2\r\n1 0 1 1\r\n", "output": "2\r\n"}, {"input": "2\r\n2 7\r\n2 4 2 5\r\n2 7 1 7\r\n0 0 1 0\r\n", "output": "-1\r\n"}, {"input": "2\r\n3 2\r\n1 2 2 2\r\n1 1 2 1\r\n0 0 1 0\r\n", "output": "-1\r\n"}, {"input": "2\r\n3 3\r\n2 1 1 1\r\n1 2 2 2\r\n0 0 0 1\r\n", "output": "-1\r\n"}, {"input": "1\r\n3 4\r\n1 3 1 4\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "2\r\n3 5\r\n1 2 1 1\r\n3 1 2 1\r\n0 1 0 0\r\n", "output": "-1\r\n"}, {"input": "2\r\n3 6\r\n3 2 3 1\r\n3 6 2 6\r\n0 0 0 1\r\n", "output": "-1\r\n"}, {"input": "2\r\n3 7\r\n3 6 3 5\r\n2 4 2 3\r\n0 1 0 1\r\n", "output": "2\r\n"}, {"input": "2\r\n4 1\r\n3 1 4 1\r\n1 1 2 1\r\n0 1 0 0\r\n", "output": "2\r\n"}, {"input": "1\r\n4 2\r\n4 1 3 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "2\r\n4 3\r\n3 1 2 1\r\n1 2 1 1\r\n1 0 0 1\r\n", "output": "1\r\n"}, {"input": "1\r\n4 4\r\n4 1 3 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "2\r\n4 5\r\n3 1 4 1\r\n4 2 4 3\r\n0 1 0 1\r\n", "output": "1\r\n"}, {"input": "2\r\n4 6\r\n2 3 2 4\r\n2 6 2 5\r\n0 0 0 1\r\n", "output": "1\r\n"}, {"input": "2\r\n4 7\r\n1 7 2 7\r\n4 1 3 1\r\n1 0 0 1\r\n", "output": "2\r\n"}, {"input": "2\r\n5 1\r\n2 1 1 1\r\n5 1 4 1\r\n1 0 0 0\r\n", "output": "2\r\n"}, {"input": "2\r\n5 2\r\n1 1 1 2\r\n2 2 3 2\r\n1 0 1 0\r\n", "output": "2\r\n"}, {"input": "2\r\n5 3\r\n1 1 1 2\r\n5 2 5 3\r\n0 1 0 1\r\n", "output": "1\r\n"}, {"input": "2\r\n5 4\r\n4 4 4 3\r\n4 2 5 2\r\n0 0 0 1\r\n", "output": "-1\r\n"}, {"input": "2\r\n5 5\r\n3 4 3 5\r\n4 1 3 1\r\n1 0 0 1\r\n", "output": "2\r\n"}, {"input": "2\r\n5 6\r\n2 4 3 4\r\n5 2 5 1\r\n0 1 1 0\r\n", "output": "1\r\n"}, {"input": "2\r\n5 7\r\n2 7 1 7\r\n2 4 3 4\r\n0 0 0 1\r\n", "output": "-1\r\n"}, {"input": "1\r\n6 1\r\n3 1 4 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n6 2\r\n5 1 6 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "2\r\n6 3\r\n2 2 2 1\r\n3 2 3 1\r\n0 1 0 0\r\n", "output": "-1\r\n"}, {"input": "2\r\n6 4\r\n6 4 5 4\r\n4 3 4 2\r\n1 0 1 0\r\n", "output": "1\r\n"}, {"input": "2\r\n6 5\r\n2 4 2 3\r\n5 4 4 4\r\n1 0 0 0\r\n", "output": "-1\r\n"}, {"input": "2\r\n6 6\r\n6 6 5 6\r\n1 3 1 2\r\n1 0 1 0\r\n", "output": "1\r\n"}, {"input": "2\r\n6 7\r\n1 3 1 4\r\n5 2 5 1\r\n0 1 1 0\r\n", "output": "1\r\n"}, {"input": "1\r\n7 1\r\n6 1 7 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "2\r\n7 2\r\n5 2 4 2\r\n2 1 2 2\r\n0 1 0 1\r\n", "output": "2\r\n"}, {"input": "2\r\n7 3\r\n7 2 6 2\r\n1 2 2 2\r\n0 1 0 0\r\n", "output": "2\r\n"}, {"input": "2\r\n7 4\r\n6 1 6 2\r\n2 3 1 3\r\n1 0 0 1\r\n", "output": "1\r\n"}, {"input": "2\r\n7 5\r\n2 3 1 3\r\n4 3 3 3\r\n1 0 0 0\r\n", "output": "2\r\n"}, {"input": "2\r\n7 6\r\n5 1 6 1\r\n2 5 3 5\r\n0 1 1 0\r\n", "output": "2\r\n"}, {"input": "2\r\n7 7\r\n2 3 2 4\r\n5 4 5 5\r\n0 1 0 1\r\n", "output": "1\r\n"}, {"input": "1\r\n1 6\r\n1 4 1 5\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n1 7\r\n1 1 1 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n2 3\r\n1 1 2 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "3\r\n2 4\r\n1 3 1 4\r\n2 4 2 3\r\n2 2 1 2\r\n0 0 0 2\r\n", "output": "-1\r\n"}, {"input": "3\r\n2 5\r\n2 5 1 5\r\n2 3 2 2\r\n1 1 2 1\r\n0 0 1 1\r\n", "output": "-1\r\n"}, {"input": "1\r\n2 6\r\n1 3 1 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "3\r\n2 7\r\n2 6 2 7\r\n1 4 1 5\r\n2 2 2 3\r\n1 0 0 2\r\n", "output": "3\r\n"}, {"input": "1\r\n3 2\r\n3 2 2 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n3 3\r\n2 3 3 3\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "2\r\n3 4\r\n3 1 3 2\r\n3 4 2 4\r\n0 1 1 0\r\n", "output": "2\r\n"}, {"input": "3\r\n3 5\r\n3 4 3 5\r\n3 2 3 1\r\n1 3 2 3\r\n1 0 0 2\r\n", "output": "2\r\n"}, {"input": "2\r\n3 6\r\n1 1 2 1\r\n1 3 2 3\r\n0 0 1 0\r\n", "output": "-1\r\n"}, {"input": "1\r\n3 7\r\n2 1 3 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "3\r\n4 2\r\n1 2 2 2\r\n3 1 4 1\r\n3 2 4 2\r\n0 2 1 0\r\n", "output": "1\r\n"}, {"input": "2\r\n4 3\r\n4 3 3 3\r\n2 2 2 1\r\n1 0 1 0\r\n", "output": "1\r\n"}, {"input": "3\r\n4 4\r\n2 3 2 4\r\n4 4 4 3\r\n2 2 1 2\r\n0 2 0 2\r\n", "output": "3\r\n"}, {"input": "3\r\n4 5\r\n2 4 1 4\r\n1 3 1 2\r\n2 1 1 1\r\n2 1 2 0\r\n", "output": "1\r\n"}, {"input": "2\r\n4 6\r\n3 3 4 3\r\n4 6 3 6\r\n0 0 1 0\r\n", "output": "-1\r\n"}, {"input": "3\r\n4 7\r\n2 7 3 7\r\n4 4 4 5\r\n3 4 3 3\r\n2 0 0 1\r\n", "output": "-1\r\n"}, {"input": "1\r\n5 2\r\n1 1 1 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "3\r\n5 3\r\n1 2 1 3\r\n5 2 5 3\r\n1 1 2 1\r\n1 1 0 2\r\n", "output": "3\r\n"}, {"input": "3\r\n5 4\r\n4 1 4 2\r\n1 1 1 2\r\n5 1 5 2\r\n0 2 2 2\r\n", "output": "2\r\n"}, {"input": "2\r\n5 5\r\n3 3 4 3\r\n5 2 4 2\r\n0 0 0 1\r\n", "output": "-1\r\n"}, {"input": "3\r\n5 6\r\n5 2 4 2\r\n1 1 1 2\r\n5 1 4 1\r\n2 1 2 0\r\n", "output": "1\r\n"}, {"input": "3\r\n5 7\r\n5 4 4 4\r\n1 2 1 1\r\n2 5 2 4\r\n0 2 0 2\r\n", "output": "2\r\n"}, {"input": "2\r\n6 1\r\n3 1 2 1\r\n4 1 5 1\r\n1 0 0 0\r\n", "output": "2\r\n"}, {"input": "3\r\n6 2\r\n5 2 5 1\r\n6 1 6 2\r\n3 2 2 2\r\n2 0 0 0\r\n", "output": "-1\r\n"}, {"input": "3\r\n6 3\r\n2 1 2 2\r\n6 2 6 1\r\n1 2 1 1\r\n1 1 0 0\r\n", "output": "-1\r\n"}, {"input": "3\r\n6 4\r\n1 2 2 2\r\n3 1 3 2\r\n2 3 2 4\r\n0 2 0 1\r\n", "output": "-1\r\n"}, {"input": "3\r\n6 5\r\n2 2 2 1\r\n5 4 6 4\r\n4 4 4 3\r\n2 0 1 0\r\n", "output": "-1\r\n"}, {"input": "3\r\n6 6\r\n4 4 4 5\r\n2 3 1 3\r\n3 4 3 3\r\n0 2 0 1\r\n", "output": "-1\r\n"}, {"input": "3\r\n6 7\r\n3 4 3 5\r\n5 4 6 4\r\n4 5 4 4\r\n1 1 1 0\r\n", "output": "-1\r\n"}, {"input": "3\r\n7 1\r\n4 1 5 1\r\n3 1 2 1\r\n6 1 7 1\r\n2 0 0 0\r\n", "output": "3\r\n"}, {"input": "3\r\n7 2\r\n7 1 7 2\r\n5 1 4 1\r\n3 1 3 2\r\n0 2 2 1\r\n", "output": "3\r\n"}, {"input": "3\r\n7 3\r\n2 3 3 3\r\n5 1 6 1\r\n7 2 7 1\r\n0 2 2 0\r\n", "output": "1\r\n"}, {"input": "3\r\n7 4\r\n5 4 6 4\r\n6 1 6 2\r\n5 1 4 1\r\n0 2 0 1\r\n", "output": "-1\r\n"}, {"input": "3\r\n7 5\r\n2 2 2 3\r\n7 1 7 2\r\n1 4 1 3\r\n2 0 0 2\r\n", "output": "2\r\n"}, {"input": "3\r\n7 6\r\n2 6 2 5\r\n2 2 1 2\r\n4 4 3 4\r\n0 1 0 2\r\n", "output": "-1\r\n"}, {"input": "1\r\n7 7\r\n5 4 6 4\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n2 4\r\n1 1 1 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "3\r\n2 5\r\n2 4 2 5\r\n2 1 1 1\r\n2 2 1 2\r\n0 1 1 1\r\n", "output": "-1\r\n"}, {"input": "3\r\n2 6\r\n1 3 1 2\r\n2 2 2 1\r\n2 5 2 6\r\n1 0 0 1\r\n", "output": "-1\r\n"}, {"input": "1\r\n2 7\r\n2 1 1 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "4\r\n3 3\r\n3 1 2 1\r\n3 3 2 3\r\n1 3 1 2\r\n3 2 2 2\r\n0 3 2 1\r\n", "output": "3\r\n"}, {"input": "4\r\n3 4\r\n2 4 3 4\r\n3 3 3 2\r\n1 2 2 2\r\n3 1 2 1\r\n0 3 1 1\r\n", "output": "-1\r\n"}, {"input": "4\r\n3 5\r\n2 3 1 3\r\n1 5 1 4\r\n2 5 2 4\r\n2 2 1 2\r\n1 0 3 1\r\n", "output": "-1\r\n"}, {"input": "2\r\n3 6\r\n1 5 1 6\r\n3 5 3 4\r\n1 0 0 1\r\n", "output": "2\r\n"}, {"input": "4\r\n3 7\r\n1 2 1 1\r\n3 3 3 4\r\n2 1 3 1\r\n2 6 3 6\r\n1 1 3 0\r\n", "output": "-1\r\n"}, {"input": "3\r\n4 2\r\n2 2 3 2\r\n1 1 1 2\r\n4 2 4 1\r\n2 0 0 0\r\n", "output": "-1\r\n"}, {"input": "2\r\n4 3\r\n1 2 1 1\r\n3 1 3 2\r\n0 1 0 0\r\n", "output": "-1\r\n"}, {"input": "2\r\n4 4\r\n3 1 4 1\r\n3 4 4 4\r\n0 0 1 0\r\n", "output": "-1\r\n"}, {"input": "2\r\n4 5\r\n3 1 3 2\r\n2 1 2 2\r\n1 0 0 0\r\n", "output": "-1\r\n"}, {"input": "4\r\n4 6\r\n1 5 2 5\r\n3 4 3 5\r\n1 1 1 2\r\n4 1 4 2\r\n2 1 2 0\r\n", "output": "-1\r\n"}, {"input": "3\r\n4 7\r\n4 2 4 3\r\n1 4 1 3\r\n1 2 1 1\r\n0 1 0 2\r\n", "output": "3\r\n"}, {"input": "3\r\n5 2\r\n1 1 2 1\r\n3 1 4 1\r\n3 2 2 2\r\n1 1 2 0\r\n", "output": "3\r\n"}, {"input": "1\r\n5 3\r\n2 1 1 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "2\r\n5 4\r\n1 2 1 3\r\n5 4 5 3\r\n1 0 0 0\r\n", "output": "-1\r\n"}, {"input": "4\r\n5 5\r\n5 1 4 1\r\n3 3 3 4\r\n1 3 2 3\r\n2 1 2 2\r\n0 2 0 2\r\n", "output": "-1\r\n"}, {"input": "3\r\n5 6\r\n4 6 4 5\r\n1 5 1 6\r\n5 5 5 4\r\n0 2 1 0\r\n", "output": "-1\r\n"}, {"input": "3\r\n5 7\r\n1 5 1 4\r\n2 5 3 5\r\n4 4 3 4\r\n2 0 0 1\r\n", "output": "-1\r\n"}, {"input": "2\r\n6 2\r\n1 1 2 1\r\n6 1 5 1\r\n0 1 0 0\r\n", "output": "1\r\n"}, {"input": "2\r\n6 3\r\n3 3 4 3\r\n5 3 6 3\r\n1 0 0 0\r\n", "output": "2\r\n"}, {"input": "4\r\n6 4\r\n3 2 3 1\r\n4 1 5 1\r\n6 1 6 2\r\n2 2 1 2\r\n2 1 0 3\r\n", "output": "2\r\n"}, {"input": "3\r\n6 5\r\n5 4 5 3\r\n1 3 1 2\r\n2 1 1 1\r\n1 1 0 2\r\n", "output": "3\r\n"}, {"input": "3\r\n6 6\r\n1 2 2 2\r\n1 5 1 6\r\n6 6 6 5\r\n0 1 1 0\r\n", "output": "-1\r\n"}, {"input": "4\r\n6 7\r\n5 4 5 5\r\n4 4 3 4\r\n2 1 1 1\r\n6 3 6 2\r\n1 2 2 0\r\n", "output": "-1\r\n"}, {"input": "3\r\n7 2\r\n5 1 6 1\r\n2 2 3 2\r\n2 1 1 1\r\n2 0 0 1\r\n", "output": "1\r\n"}, {"input": "4\r\n7 3\r\n6 1 7 1\r\n3 1 4 1\r\n6 2 5 2\r\n2 1 1 1\r\n2 1 3 0\r\n", "output": "3\r\n"}, {"input": "4\r\n7 4\r\n4 2 3 2\r\n5 2 5 3\r\n3 4 2 4\r\n6 2 6 1\r\n3 0 0 3\r\n", "output": "4\r\n"}, {"input": "1\r\n7 5\r\n6 5 7 5\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "3\r\n7 6\r\n2 6 1 6\r\n2 4 2 5\r\n3 2 2 2\r\n1 0 0 2\r\n", "output": "-1\r\n"}, {"input": "4\r\n7 7\r\n4 6 5 6\r\n7 4 7 5\r\n7 1 7 2\r\n2 6 2 5\r\n1 2 2 0\r\n", "output": "-1\r\n"}, {"input": "4\r\n2 5\r\n1 3 2 3\r\n1 5 1 4\r\n1 2 2 2\r\n1 1 2 1\r\n0 0 3 0\r\n", "output": "-1\r\n"}, {"input": "2\r\n2 6\r\n2 1 2 2\r\n1 2 1 1\r\n1 0 0 0\r\n", "output": "-1\r\n"}, {"input": "4\r\n2 7\r\n1 2 2 2\r\n2 6 2 5\r\n2 3 1 3\r\n1 5 1 4\r\n0 3 2 1\r\n", "output": "4\r\n"}, {"input": "3\r\n3 4\r\n2 2 3 2\r\n1 2 1 3\r\n3 1 2 1\r\n1 0 0 2\r\n", "output": "-1\r\n"}, {"input": "4\r\n3 5\r\n3 1 3 2\r\n2 3 2 2\r\n2 5 1 5\r\n3 4 3 3\r\n2 0 2 1\r\n", "output": "4\r\n"}, {"input": "4\r\n3 6\r\n3 1 2 1\r\n1 2 2 2\r\n2 3 3 3\r\n1 5 1 4\r\n0 2 3 0\r\n", "output": "-1\r\n"}, {"input": "3\r\n3 7\r\n3 2 2 2\r\n3 5 2 5\r\n3 7 2 7\r\n0 0 1 1\r\n", "output": "-1\r\n"}, {"input": "4\r\n4 3\r\n3 2 3 3\r\n4 2 4 1\r\n1 2 1 3\r\n3 1 2 1\r\n0 3 1 0\r\n", "output": "-1\r\n"}, {"input": "4\r\n4 4\r\n2 4 1 4\r\n1 2 1 3\r\n4 3 4 4\r\n3 3 3 2\r\n0 2 0 2\r\n", "output": "-1\r\n"}, {"input": "3\r\n4 5\r\n4 5 3 5\r\n4 2 3 2\r\n2 1 3 1\r\n0 1 0 2\r\n", "output": "-1\r\n"}, {"input": "5\r\n4 6\r\n4 3 3 3\r\n4 2 4 1\r\n3 6 2 6\r\n2 4 2 3\r\n1 1 1 2\r\n1 2 2 1\r\n", "output": "-1\r\n"}, {"input": "2\r\n4 7\r\n2 6 2 7\r\n2 5 2 4\r\n0 0 1 0\r\n", "output": "1\r\n"}, {"input": "1\r\n5 2\r\n2 2 2 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n5 3\r\n4 2 3 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "2\r\n5 4\r\n3 1 2 1\r\n3 4 3 3\r\n0 0 1 0\r\n", "output": "-1\r\n"}, {"input": "1\r\n5 5\r\n3 4 2 4\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "4\r\n5 6\r\n5 3 5 2\r\n4 5 3 5\r\n1 2 1 3\r\n1 1 2 1\r\n3 0 1 1\r\n", "output": "-1\r\n"}, {"input": "5\r\n5 7\r\n5 5 5 6\r\n2 4 2 5\r\n2 3 1 3\r\n4 7 3 7\r\n4 1 5 1\r\n0 3 2 2\r\n", "output": "-1\r\n"}, {"input": "2\r\n6 2\r\n5 2 5 1\r\n4 2 4 1\r\n1 0 1 1\r\n", "output": "1\r\n"}, {"input": "3\r\n6 3\r\n2 2 2 3\r\n3 3 4 3\r\n4 2 4 1\r\n1 1 1 0\r\n", "output": "-1\r\n"}, {"input": "4\r\n6 4\r\n2 3 1 3\r\n4 4 3 4\r\n5 4 6 4\r\n1 4 2 4\r\n0 2 1 0\r\n", "output": "-1\r\n"}, {"input": "5\r\n6 5\r\n1 5 1 4\r\n4 2 4 3\r\n2 2 1 2\r\n2 3 1 3\r\n3 2 3 3\r\n0 2 0 3\r\n", "output": "-1\r\n"}, {"input": "4\r\n6 6\r\n4 3 4 2\r\n2 3 2 4\r\n4 4 5 4\r\n5 2 5 3\r\n0 3 2 0\r\n", "output": "-1\r\n"}, {"input": "5\r\n6 7\r\n1 6 1 5\r\n3 6 2 6\r\n5 1 4 1\r\n2 5 3 5\r\n5 3 5 2\r\n3 0 0 4\r\n", "output": "-1\r\n"}, {"input": "2\r\n7 2\r\n3 1 4 1\r\n7 1 7 2\r\n0 1 0 1\r\n", "output": "1\r\n"}, {"input": "2\r\n7 3\r\n6 3 7 3\r\n4 1 3 1\r\n0 1 0 1\r\n", "output": "2\r\n"}, {"input": "5\r\n7 4\r\n3 1 2 1\r\n5 2 5 1\r\n4 2 3 2\r\n7 3 6 3\r\n4 3 5 3\r\n1 2 2 2\r\n", "output": "-1\r\n"}, {"input": "5\r\n7 5\r\n5 3 5 2\r\n3 5 2 5\r\n1 3 1 4\r\n3 3 3 4\r\n4 1 3 1\r\n1 2 4 0\r\n", "output": "-1\r\n"}, {"input": "5\r\n7 6\r\n5 5 5 4\r\n6 1 7 1\r\n5 2 5 1\r\n1 1 2 1\r\n4 6 3 6\r\n1 3 4 0\r\n", "output": "5\r\n"}, {"input": "3\r\n7 7\r\n2 6 1 6\r\n7 2 6 2\r\n3 1 3 2\r\n2 0 1 1\r\n", "output": "2\r\n"}]
| false |
stdio
| null | true |
818/C
|
818
|
C
|
PyPy 3
|
TESTS
| 8 | 841 | 33,689,600 |
142736287
|
import sys
input = sys.stdin.readline
d = int(input())
n, m = map(int, input().split())
xl = [[] for _ in range(n + 2)]
xr = [[] for _ in range(n + 2)]
yt = [[] for _ in range(m + 2)]
yb = [[] for _ in range(m + 2)]
for i in range(1, d + 1):
x1, y1, x2, y2 = map(int, input().split())
if x1 > x2:
x1, x2 = x2, x1
if y1 > y2:
y1, y2 = y2, y1
xl[x1].append(i)
xr[x2].append(i)
yt[y1].append(i)
yb[y2].append(i)
cnt = [[0] * 4 for _ in range(d + 1)]
c = [0] * (n + 2)
for i in range(1, n + 1):
c[i] = c[i - 1] + len(xl[i])
ci = c[i]
for j in xl[i]:
cnt[j][0] = ci - 1
c = [0] * (n + 2)
for i in range(n, 0, -1):
c[i] = c[i + 1] + len(xr[i])
ci = c[i]
for j in xr[i]:
cnt[j][1] = ci - 1
c = [0] * (m + 2)
for i in range(1, m + 1):
c[i] = c[i - 1] + len(yt[i])
ci = c[i]
for j in yt[i]:
cnt[j][2] = ci - 1
c = [0] * (m + 2)
for i in range(m, 0, -1):
c[i] = c[i + 1] + len(yb[i])
ci = c[i]
for j in yb[i]:
cnt[j][3] = ci - 1
cnt0 = list(map(int, input().split()))
ans = -1
for i in range(1, d + 1):
cnti = cnt[i]
ok = 1
for u, v in zip(cnt0, cnti):
if u ^ v:
ok = 0
break
if ok:
ans = i
break
print(ans)
| 212 | 498 | 17,305,600 |
93759517
|
import sys
try:
fin=open('in')
except:
fin=sys.stdin
input=fin.readline
d = int(input())
n, m = map(int, input().split())
x1, y1, x2, y2 = [], [], [], []
T=[]
for _ in range(d):
u, v, w, x = map(int, input().split())
if u>w:u,w=w,u
if v>x:v,x=x,v
x1.append(u)
y1.append(v)
x2.append(-w)#the other direction pog?
y2.append(-x)
T.append([u,v,w,x])
x1.sort()
x2.sort()
y1.sort()
y2.sort()
req=list(map(int,input().split())) # x1,x2,y1,y2
import bisect
for i in range(len(T)):
# binary search
u,v,w,x=T[i]
if req[0]==bisect.bisect_left(x1,w)-(u!=w):
if req[1]==bisect.bisect_left(x2,-u)-(u!=w):
if req[2]==bisect.bisect_left(y1,x)-(v!=x):
if req[3]==bisect.bisect_left(y2,-v)-(v!=x):
print(i+1)
break
else:
print(-1)
|
Educational Codeforces Round 24
|
ICPC
| 2,017 | 1 | 256 |
Sofa Thief
|
Yet another round on DecoForces is coming! Grandpa Maks wanted to participate in it but someone has stolen his precious sofa! And how can one perform well with such a major loss?
Fortunately, the thief had left a note for Grandpa Maks. This note got Maks to the sofa storehouse. Still he had no idea which sofa belongs to him as they all looked the same!
The storehouse is represented as matrix n × m. Every sofa takes two neighbouring by some side cells. No cell is covered by more than one sofa. There can be empty cells.
Sofa A is standing to the left of sofa B if there exist two such cells a and b that xa < xb, a is covered by A and b is covered by B. Sofa A is standing to the top of sofa B if there exist two such cells a and b that ya < yb, a is covered by A and b is covered by B. Right and bottom conditions are declared the same way.
Note that in all conditions A ≠ B. Also some sofa A can be both to the top of another sofa B and to the bottom of it. The same is for left and right conditions.
The note also stated that there are cntl sofas to the left of Grandpa Maks's sofa, cntr — to the right, cntt — to the top and cntb — to the bottom.
Grandpa Maks asks you to help him to identify his sofa. It is guaranteed that there is no more than one sofa of given conditions.
Output the number of Grandpa Maks's sofa. If there is no such sofa that all the conditions are met for it then output -1.
|
The first line contains one integer number d (1 ≤ d ≤ 105) — the number of sofas in the storehouse.
The second line contains two integer numbers n, m (1 ≤ n, m ≤ 105) — the size of the storehouse.
Next d lines contains four integer numbers x1, y1, x2, y2 (1 ≤ x1, x2 ≤ n, 1 ≤ y1, y2 ≤ m) — coordinates of the i-th sofa. It is guaranteed that cells (x1, y1) and (x2, y2) have common side, (x1, y1) ≠ (x2, y2) and no cell is covered by more than one sofa.
The last line contains four integer numbers cntl, cntr, cntt, cntb (0 ≤ cntl, cntr, cntt, cntb ≤ d - 1).
|
Print the number of the sofa for which all the conditions are met. Sofas are numbered 1 through d as given in input. If there is no such sofa then print -1.
| null |
Let's consider the second example.
- The first sofa has 0 to its left, 2 sofas to its right ((1, 1) is to the left of both (5, 5) and (5, 4)), 0 to its top and 2 to its bottom (both 2nd and 3rd sofas are below).
- The second sofa has cntl = 2, cntr = 1, cntt = 2 and cntb = 0.
- The third sofa has cntl = 2, cntr = 1, cntt = 1 and cntb = 1.
So the second one corresponds to the given conditions.
In the third example
- The first sofa has cntl = 1, cntr = 1, cntt = 0 and cntb = 1.
- The second sofa has cntl = 1, cntr = 1, cntt = 1 and cntb = 0.
And there is no sofa with the set (1, 0, 0, 0) so the answer is -1.
|
[{"input": "2\n3 2\n3 1 3 2\n1 2 2 2\n1 0 0 1", "output": "1"}, {"input": "3\n10 10\n1 2 1 1\n5 5 6 5\n6 4 5 4\n2 1 2 0", "output": "2"}, {"input": "2\n2 2\n2 1 1 1\n1 2 2 2\n1 0 0 0", "output": "-1"}]
| 2,000 |
["brute force", "implementation"]
| 212 |
[{"input": "2\r\n3 2\r\n3 1 3 2\r\n1 2 2 2\r\n1 0 0 1\r\n", "output": "1\r\n"}, {"input": "3\r\n10 10\r\n1 2 1 1\r\n5 5 6 5\r\n6 4 5 4\r\n2 1 2 0\r\n", "output": "2\r\n"}, {"input": "2\r\n2 2\r\n2 1 1 1\r\n1 2 2 2\r\n1 0 0 0\r\n", "output": "-1\r\n"}, {"input": "1\r\n1 2\r\n1 1 1 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n2 1\r\n2 1 1 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n1000 1000\r\n63 902 63 901\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "6\r\n10 10\r\n3 6 3 7\r\n4 9 5 9\r\n5 4 5 3\r\n7 1 8 1\r\n9 10 8 10\r\n7 7 7 8\r\n0 5 2 3\r\n", "output": "1\r\n"}, {"input": "2\r\n4 4\r\n3 1 3 2\r\n2 2 2 1\r\n0 0 0 0\r\n", "output": "-1\r\n"}, {"input": "2\r\n2 2\r\n1 1 1 2\r\n2 1 2 2\r\n0 1 1 1\r\n", "output": "1\r\n"}, {"input": "2\r\n2 2\r\n1 1 1 2\r\n2 1 2 2\r\n1 0 1 1\r\n", "output": "2\r\n"}, {"input": "2\r\n2 2\r\n1 1 1 2\r\n2 1 2 2\r\n0 1 1 0\r\n", "output": "-1\r\n"}, {"input": "1\r\n1 2\r\n1 2 1 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n1 3\r\n1 2 1 3\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n1 4\r\n1 2 1 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n1 5\r\n1 4 1 3\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n1 6\r\n1 6 1 5\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n1 7\r\n1 6 1 7\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n2 1\r\n2 1 1 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n2 2\r\n2 2 2 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n2 3\r\n1 2 1 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n2 4\r\n2 3 2 4\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n2 5\r\n2 4 1 4\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n2 6\r\n2 1 1 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n2 7\r\n2 7 2 6\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n3 1\r\n2 1 3 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n3 2\r\n1 1 2 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n3 3\r\n3 2 3 3\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n3 4\r\n2 1 2 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n3 5\r\n2 2 2 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n3 6\r\n1 4 2 4\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n3 7\r\n2 2 1 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n4 1\r\n1 1 2 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n4 2\r\n1 1 1 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n4 3\r\n4 3 4 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n4 4\r\n3 2 3 3\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n4 5\r\n1 2 2 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n4 6\r\n4 3 4 4\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n4 7\r\n3 6 4 6\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n5 1\r\n2 1 1 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n5 2\r\n5 1 4 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n5 3\r\n4 2 3 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n5 4\r\n2 4 3 4\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n5 5\r\n4 1 3 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n5 6\r\n3 3 3 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n5 7\r\n1 6 1 7\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n6 1\r\n6 1 5 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n6 2\r\n4 2 5 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n6 3\r\n1 2 1 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n6 4\r\n2 2 3 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n6 5\r\n6 1 6 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n6 6\r\n4 1 3 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n6 7\r\n6 7 6 6\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n7 1\r\n6 1 7 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n7 2\r\n4 2 4 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n7 3\r\n7 1 7 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n7 4\r\n3 3 3 4\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n7 5\r\n6 4 7 4\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n7 6\r\n2 2 2 3\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n7 7\r\n1 3 2 3\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n1 4\r\n1 4 1 3\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "2\r\n1 5\r\n1 5 1 4\r\n1 1 1 2\r\n0 0 1 0\r\n", "output": "1\r\n"}, {"input": "1\r\n1 6\r\n1 2 1 3\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "2\r\n1 7\r\n1 7 1 6\r\n1 4 1 5\r\n0 0 1 0\r\n", "output": "1\r\n"}, {"input": "1\r\n2 2\r\n2 1 2 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "2\r\n2 3\r\n2 3 1 3\r\n1 2 2 2\r\n0 0 0 1\r\n", "output": "-1\r\n"}, {"input": "2\r\n2 4\r\n2 2 2 1\r\n2 4 1 4\r\n0 1 1 0\r\n", "output": "2\r\n"}, {"input": "2\r\n2 5\r\n2 2 2 1\r\n1 3 1 4\r\n1 0 0 1\r\n", "output": "1\r\n"}, {"input": "2\r\n2 6\r\n1 2 1 1\r\n2 1 2 2\r\n1 0 1 1\r\n", "output": "2\r\n"}, {"input": "2\r\n2 7\r\n2 4 2 5\r\n2 7 1 7\r\n0 0 1 0\r\n", "output": "-1\r\n"}, {"input": "2\r\n3 2\r\n1 2 2 2\r\n1 1 2 1\r\n0 0 1 0\r\n", "output": "-1\r\n"}, {"input": "2\r\n3 3\r\n2 1 1 1\r\n1 2 2 2\r\n0 0 0 1\r\n", "output": "-1\r\n"}, {"input": "1\r\n3 4\r\n1 3 1 4\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "2\r\n3 5\r\n1 2 1 1\r\n3 1 2 1\r\n0 1 0 0\r\n", "output": "-1\r\n"}, {"input": "2\r\n3 6\r\n3 2 3 1\r\n3 6 2 6\r\n0 0 0 1\r\n", "output": "-1\r\n"}, {"input": "2\r\n3 7\r\n3 6 3 5\r\n2 4 2 3\r\n0 1 0 1\r\n", "output": "2\r\n"}, {"input": "2\r\n4 1\r\n3 1 4 1\r\n1 1 2 1\r\n0 1 0 0\r\n", "output": "2\r\n"}, {"input": "1\r\n4 2\r\n4 1 3 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "2\r\n4 3\r\n3 1 2 1\r\n1 2 1 1\r\n1 0 0 1\r\n", "output": "1\r\n"}, {"input": "1\r\n4 4\r\n4 1 3 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "2\r\n4 5\r\n3 1 4 1\r\n4 2 4 3\r\n0 1 0 1\r\n", "output": "1\r\n"}, {"input": "2\r\n4 6\r\n2 3 2 4\r\n2 6 2 5\r\n0 0 0 1\r\n", "output": "1\r\n"}, {"input": "2\r\n4 7\r\n1 7 2 7\r\n4 1 3 1\r\n1 0 0 1\r\n", "output": "2\r\n"}, {"input": "2\r\n5 1\r\n2 1 1 1\r\n5 1 4 1\r\n1 0 0 0\r\n", "output": "2\r\n"}, {"input": "2\r\n5 2\r\n1 1 1 2\r\n2 2 3 2\r\n1 0 1 0\r\n", "output": "2\r\n"}, {"input": "2\r\n5 3\r\n1 1 1 2\r\n5 2 5 3\r\n0 1 0 1\r\n", "output": "1\r\n"}, {"input": "2\r\n5 4\r\n4 4 4 3\r\n4 2 5 2\r\n0 0 0 1\r\n", "output": "-1\r\n"}, {"input": "2\r\n5 5\r\n3 4 3 5\r\n4 1 3 1\r\n1 0 0 1\r\n", "output": "2\r\n"}, {"input": "2\r\n5 6\r\n2 4 3 4\r\n5 2 5 1\r\n0 1 1 0\r\n", "output": "1\r\n"}, {"input": "2\r\n5 7\r\n2 7 1 7\r\n2 4 3 4\r\n0 0 0 1\r\n", "output": "-1\r\n"}, {"input": "1\r\n6 1\r\n3 1 4 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n6 2\r\n5 1 6 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "2\r\n6 3\r\n2 2 2 1\r\n3 2 3 1\r\n0 1 0 0\r\n", "output": "-1\r\n"}, {"input": "2\r\n6 4\r\n6 4 5 4\r\n4 3 4 2\r\n1 0 1 0\r\n", "output": "1\r\n"}, {"input": "2\r\n6 5\r\n2 4 2 3\r\n5 4 4 4\r\n1 0 0 0\r\n", "output": "-1\r\n"}, {"input": "2\r\n6 6\r\n6 6 5 6\r\n1 3 1 2\r\n1 0 1 0\r\n", "output": "1\r\n"}, {"input": "2\r\n6 7\r\n1 3 1 4\r\n5 2 5 1\r\n0 1 1 0\r\n", "output": "1\r\n"}, {"input": "1\r\n7 1\r\n6 1 7 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "2\r\n7 2\r\n5 2 4 2\r\n2 1 2 2\r\n0 1 0 1\r\n", "output": "2\r\n"}, {"input": "2\r\n7 3\r\n7 2 6 2\r\n1 2 2 2\r\n0 1 0 0\r\n", "output": "2\r\n"}, {"input": "2\r\n7 4\r\n6 1 6 2\r\n2 3 1 3\r\n1 0 0 1\r\n", "output": "1\r\n"}, {"input": "2\r\n7 5\r\n2 3 1 3\r\n4 3 3 3\r\n1 0 0 0\r\n", "output": "2\r\n"}, {"input": "2\r\n7 6\r\n5 1 6 1\r\n2 5 3 5\r\n0 1 1 0\r\n", "output": "2\r\n"}, {"input": "2\r\n7 7\r\n2 3 2 4\r\n5 4 5 5\r\n0 1 0 1\r\n", "output": "1\r\n"}, {"input": "1\r\n1 6\r\n1 4 1 5\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n1 7\r\n1 1 1 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n2 3\r\n1 1 2 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "3\r\n2 4\r\n1 3 1 4\r\n2 4 2 3\r\n2 2 1 2\r\n0 0 0 2\r\n", "output": "-1\r\n"}, {"input": "3\r\n2 5\r\n2 5 1 5\r\n2 3 2 2\r\n1 1 2 1\r\n0 0 1 1\r\n", "output": "-1\r\n"}, {"input": "1\r\n2 6\r\n1 3 1 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "3\r\n2 7\r\n2 6 2 7\r\n1 4 1 5\r\n2 2 2 3\r\n1 0 0 2\r\n", "output": "3\r\n"}, {"input": "1\r\n3 2\r\n3 2 2 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n3 3\r\n2 3 3 3\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "2\r\n3 4\r\n3 1 3 2\r\n3 4 2 4\r\n0 1 1 0\r\n", "output": "2\r\n"}, {"input": "3\r\n3 5\r\n3 4 3 5\r\n3 2 3 1\r\n1 3 2 3\r\n1 0 0 2\r\n", "output": "2\r\n"}, {"input": "2\r\n3 6\r\n1 1 2 1\r\n1 3 2 3\r\n0 0 1 0\r\n", "output": "-1\r\n"}, {"input": "1\r\n3 7\r\n2 1 3 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "3\r\n4 2\r\n1 2 2 2\r\n3 1 4 1\r\n3 2 4 2\r\n0 2 1 0\r\n", "output": "1\r\n"}, {"input": "2\r\n4 3\r\n4 3 3 3\r\n2 2 2 1\r\n1 0 1 0\r\n", "output": "1\r\n"}, {"input": "3\r\n4 4\r\n2 3 2 4\r\n4 4 4 3\r\n2 2 1 2\r\n0 2 0 2\r\n", "output": "3\r\n"}, {"input": "3\r\n4 5\r\n2 4 1 4\r\n1 3 1 2\r\n2 1 1 1\r\n2 1 2 0\r\n", "output": "1\r\n"}, {"input": "2\r\n4 6\r\n3 3 4 3\r\n4 6 3 6\r\n0 0 1 0\r\n", "output": "-1\r\n"}, {"input": "3\r\n4 7\r\n2 7 3 7\r\n4 4 4 5\r\n3 4 3 3\r\n2 0 0 1\r\n", "output": "-1\r\n"}, {"input": "1\r\n5 2\r\n1 1 1 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "3\r\n5 3\r\n1 2 1 3\r\n5 2 5 3\r\n1 1 2 1\r\n1 1 0 2\r\n", "output": "3\r\n"}, {"input": "3\r\n5 4\r\n4 1 4 2\r\n1 1 1 2\r\n5 1 5 2\r\n0 2 2 2\r\n", "output": "2\r\n"}, {"input": "2\r\n5 5\r\n3 3 4 3\r\n5 2 4 2\r\n0 0 0 1\r\n", "output": "-1\r\n"}, {"input": "3\r\n5 6\r\n5 2 4 2\r\n1 1 1 2\r\n5 1 4 1\r\n2 1 2 0\r\n", "output": "1\r\n"}, {"input": "3\r\n5 7\r\n5 4 4 4\r\n1 2 1 1\r\n2 5 2 4\r\n0 2 0 2\r\n", "output": "2\r\n"}, {"input": "2\r\n6 1\r\n3 1 2 1\r\n4 1 5 1\r\n1 0 0 0\r\n", "output": "2\r\n"}, {"input": "3\r\n6 2\r\n5 2 5 1\r\n6 1 6 2\r\n3 2 2 2\r\n2 0 0 0\r\n", "output": "-1\r\n"}, {"input": "3\r\n6 3\r\n2 1 2 2\r\n6 2 6 1\r\n1 2 1 1\r\n1 1 0 0\r\n", "output": "-1\r\n"}, {"input": "3\r\n6 4\r\n1 2 2 2\r\n3 1 3 2\r\n2 3 2 4\r\n0 2 0 1\r\n", "output": "-1\r\n"}, {"input": "3\r\n6 5\r\n2 2 2 1\r\n5 4 6 4\r\n4 4 4 3\r\n2 0 1 0\r\n", "output": "-1\r\n"}, {"input": "3\r\n6 6\r\n4 4 4 5\r\n2 3 1 3\r\n3 4 3 3\r\n0 2 0 1\r\n", "output": "-1\r\n"}, {"input": "3\r\n6 7\r\n3 4 3 5\r\n5 4 6 4\r\n4 5 4 4\r\n1 1 1 0\r\n", "output": "-1\r\n"}, {"input": "3\r\n7 1\r\n4 1 5 1\r\n3 1 2 1\r\n6 1 7 1\r\n2 0 0 0\r\n", "output": "3\r\n"}, {"input": "3\r\n7 2\r\n7 1 7 2\r\n5 1 4 1\r\n3 1 3 2\r\n0 2 2 1\r\n", "output": "3\r\n"}, {"input": "3\r\n7 3\r\n2 3 3 3\r\n5 1 6 1\r\n7 2 7 1\r\n0 2 2 0\r\n", "output": "1\r\n"}, {"input": "3\r\n7 4\r\n5 4 6 4\r\n6 1 6 2\r\n5 1 4 1\r\n0 2 0 1\r\n", "output": "-1\r\n"}, {"input": "3\r\n7 5\r\n2 2 2 3\r\n7 1 7 2\r\n1 4 1 3\r\n2 0 0 2\r\n", "output": "2\r\n"}, {"input": "3\r\n7 6\r\n2 6 2 5\r\n2 2 1 2\r\n4 4 3 4\r\n0 1 0 2\r\n", "output": "-1\r\n"}, {"input": "1\r\n7 7\r\n5 4 6 4\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n2 4\r\n1 1 1 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "3\r\n2 5\r\n2 4 2 5\r\n2 1 1 1\r\n2 2 1 2\r\n0 1 1 1\r\n", "output": "-1\r\n"}, {"input": "3\r\n2 6\r\n1 3 1 2\r\n2 2 2 1\r\n2 5 2 6\r\n1 0 0 1\r\n", "output": "-1\r\n"}, {"input": "1\r\n2 7\r\n2 1 1 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "4\r\n3 3\r\n3 1 2 1\r\n3 3 2 3\r\n1 3 1 2\r\n3 2 2 2\r\n0 3 2 1\r\n", "output": "3\r\n"}, {"input": "4\r\n3 4\r\n2 4 3 4\r\n3 3 3 2\r\n1 2 2 2\r\n3 1 2 1\r\n0 3 1 1\r\n", "output": "-1\r\n"}, {"input": "4\r\n3 5\r\n2 3 1 3\r\n1 5 1 4\r\n2 5 2 4\r\n2 2 1 2\r\n1 0 3 1\r\n", "output": "-1\r\n"}, {"input": "2\r\n3 6\r\n1 5 1 6\r\n3 5 3 4\r\n1 0 0 1\r\n", "output": "2\r\n"}, {"input": "4\r\n3 7\r\n1 2 1 1\r\n3 3 3 4\r\n2 1 3 1\r\n2 6 3 6\r\n1 1 3 0\r\n", "output": "-1\r\n"}, {"input": "3\r\n4 2\r\n2 2 3 2\r\n1 1 1 2\r\n4 2 4 1\r\n2 0 0 0\r\n", "output": "-1\r\n"}, {"input": "2\r\n4 3\r\n1 2 1 1\r\n3 1 3 2\r\n0 1 0 0\r\n", "output": "-1\r\n"}, {"input": "2\r\n4 4\r\n3 1 4 1\r\n3 4 4 4\r\n0 0 1 0\r\n", "output": "-1\r\n"}, {"input": "2\r\n4 5\r\n3 1 3 2\r\n2 1 2 2\r\n1 0 0 0\r\n", "output": "-1\r\n"}, {"input": "4\r\n4 6\r\n1 5 2 5\r\n3 4 3 5\r\n1 1 1 2\r\n4 1 4 2\r\n2 1 2 0\r\n", "output": "-1\r\n"}, {"input": "3\r\n4 7\r\n4 2 4 3\r\n1 4 1 3\r\n1 2 1 1\r\n0 1 0 2\r\n", "output": "3\r\n"}, {"input": "3\r\n5 2\r\n1 1 2 1\r\n3 1 4 1\r\n3 2 2 2\r\n1 1 2 0\r\n", "output": "3\r\n"}, {"input": "1\r\n5 3\r\n2 1 1 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "2\r\n5 4\r\n1 2 1 3\r\n5 4 5 3\r\n1 0 0 0\r\n", "output": "-1\r\n"}, {"input": "4\r\n5 5\r\n5 1 4 1\r\n3 3 3 4\r\n1 3 2 3\r\n2 1 2 2\r\n0 2 0 2\r\n", "output": "-1\r\n"}, {"input": "3\r\n5 6\r\n4 6 4 5\r\n1 5 1 6\r\n5 5 5 4\r\n0 2 1 0\r\n", "output": "-1\r\n"}, {"input": "3\r\n5 7\r\n1 5 1 4\r\n2 5 3 5\r\n4 4 3 4\r\n2 0 0 1\r\n", "output": "-1\r\n"}, {"input": "2\r\n6 2\r\n1 1 2 1\r\n6 1 5 1\r\n0 1 0 0\r\n", "output": "1\r\n"}, {"input": "2\r\n6 3\r\n3 3 4 3\r\n5 3 6 3\r\n1 0 0 0\r\n", "output": "2\r\n"}, {"input": "4\r\n6 4\r\n3 2 3 1\r\n4 1 5 1\r\n6 1 6 2\r\n2 2 1 2\r\n2 1 0 3\r\n", "output": "2\r\n"}, {"input": "3\r\n6 5\r\n5 4 5 3\r\n1 3 1 2\r\n2 1 1 1\r\n1 1 0 2\r\n", "output": "3\r\n"}, {"input": "3\r\n6 6\r\n1 2 2 2\r\n1 5 1 6\r\n6 6 6 5\r\n0 1 1 0\r\n", "output": "-1\r\n"}, {"input": "4\r\n6 7\r\n5 4 5 5\r\n4 4 3 4\r\n2 1 1 1\r\n6 3 6 2\r\n1 2 2 0\r\n", "output": "-1\r\n"}, {"input": "3\r\n7 2\r\n5 1 6 1\r\n2 2 3 2\r\n2 1 1 1\r\n2 0 0 1\r\n", "output": "1\r\n"}, {"input": "4\r\n7 3\r\n6 1 7 1\r\n3 1 4 1\r\n6 2 5 2\r\n2 1 1 1\r\n2 1 3 0\r\n", "output": "3\r\n"}, {"input": "4\r\n7 4\r\n4 2 3 2\r\n5 2 5 3\r\n3 4 2 4\r\n6 2 6 1\r\n3 0 0 3\r\n", "output": "4\r\n"}, {"input": "1\r\n7 5\r\n6 5 7 5\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "3\r\n7 6\r\n2 6 1 6\r\n2 4 2 5\r\n3 2 2 2\r\n1 0 0 2\r\n", "output": "-1\r\n"}, {"input": "4\r\n7 7\r\n4 6 5 6\r\n7 4 7 5\r\n7 1 7 2\r\n2 6 2 5\r\n1 2 2 0\r\n", "output": "-1\r\n"}, {"input": "4\r\n2 5\r\n1 3 2 3\r\n1 5 1 4\r\n1 2 2 2\r\n1 1 2 1\r\n0 0 3 0\r\n", "output": "-1\r\n"}, {"input": "2\r\n2 6\r\n2 1 2 2\r\n1 2 1 1\r\n1 0 0 0\r\n", "output": "-1\r\n"}, {"input": "4\r\n2 7\r\n1 2 2 2\r\n2 6 2 5\r\n2 3 1 3\r\n1 5 1 4\r\n0 3 2 1\r\n", "output": "4\r\n"}, {"input": "3\r\n3 4\r\n2 2 3 2\r\n1 2 1 3\r\n3 1 2 1\r\n1 0 0 2\r\n", "output": "-1\r\n"}, {"input": "4\r\n3 5\r\n3 1 3 2\r\n2 3 2 2\r\n2 5 1 5\r\n3 4 3 3\r\n2 0 2 1\r\n", "output": "4\r\n"}, {"input": "4\r\n3 6\r\n3 1 2 1\r\n1 2 2 2\r\n2 3 3 3\r\n1 5 1 4\r\n0 2 3 0\r\n", "output": "-1\r\n"}, {"input": "3\r\n3 7\r\n3 2 2 2\r\n3 5 2 5\r\n3 7 2 7\r\n0 0 1 1\r\n", "output": "-1\r\n"}, {"input": "4\r\n4 3\r\n3 2 3 3\r\n4 2 4 1\r\n1 2 1 3\r\n3 1 2 1\r\n0 3 1 0\r\n", "output": "-1\r\n"}, {"input": "4\r\n4 4\r\n2 4 1 4\r\n1 2 1 3\r\n4 3 4 4\r\n3 3 3 2\r\n0 2 0 2\r\n", "output": "-1\r\n"}, {"input": "3\r\n4 5\r\n4 5 3 5\r\n4 2 3 2\r\n2 1 3 1\r\n0 1 0 2\r\n", "output": "-1\r\n"}, {"input": "5\r\n4 6\r\n4 3 3 3\r\n4 2 4 1\r\n3 6 2 6\r\n2 4 2 3\r\n1 1 1 2\r\n1 2 2 1\r\n", "output": "-1\r\n"}, {"input": "2\r\n4 7\r\n2 6 2 7\r\n2 5 2 4\r\n0 0 1 0\r\n", "output": "1\r\n"}, {"input": "1\r\n5 2\r\n2 2 2 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n5 3\r\n4 2 3 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "2\r\n5 4\r\n3 1 2 1\r\n3 4 3 3\r\n0 0 1 0\r\n", "output": "-1\r\n"}, {"input": "1\r\n5 5\r\n3 4 2 4\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "4\r\n5 6\r\n5 3 5 2\r\n4 5 3 5\r\n1 2 1 3\r\n1 1 2 1\r\n3 0 1 1\r\n", "output": "-1\r\n"}, {"input": "5\r\n5 7\r\n5 5 5 6\r\n2 4 2 5\r\n2 3 1 3\r\n4 7 3 7\r\n4 1 5 1\r\n0 3 2 2\r\n", "output": "-1\r\n"}, {"input": "2\r\n6 2\r\n5 2 5 1\r\n4 2 4 1\r\n1 0 1 1\r\n", "output": "1\r\n"}, {"input": "3\r\n6 3\r\n2 2 2 3\r\n3 3 4 3\r\n4 2 4 1\r\n1 1 1 0\r\n", "output": "-1\r\n"}, {"input": "4\r\n6 4\r\n2 3 1 3\r\n4 4 3 4\r\n5 4 6 4\r\n1 4 2 4\r\n0 2 1 0\r\n", "output": "-1\r\n"}, {"input": "5\r\n6 5\r\n1 5 1 4\r\n4 2 4 3\r\n2 2 1 2\r\n2 3 1 3\r\n3 2 3 3\r\n0 2 0 3\r\n", "output": "-1\r\n"}, {"input": "4\r\n6 6\r\n4 3 4 2\r\n2 3 2 4\r\n4 4 5 4\r\n5 2 5 3\r\n0 3 2 0\r\n", "output": "-1\r\n"}, {"input": "5\r\n6 7\r\n1 6 1 5\r\n3 6 2 6\r\n5 1 4 1\r\n2 5 3 5\r\n5 3 5 2\r\n3 0 0 4\r\n", "output": "-1\r\n"}, {"input": "2\r\n7 2\r\n3 1 4 1\r\n7 1 7 2\r\n0 1 0 1\r\n", "output": "1\r\n"}, {"input": "2\r\n7 3\r\n6 3 7 3\r\n4 1 3 1\r\n0 1 0 1\r\n", "output": "2\r\n"}, {"input": "5\r\n7 4\r\n3 1 2 1\r\n5 2 5 1\r\n4 2 3 2\r\n7 3 6 3\r\n4 3 5 3\r\n1 2 2 2\r\n", "output": "-1\r\n"}, {"input": "5\r\n7 5\r\n5 3 5 2\r\n3 5 2 5\r\n1 3 1 4\r\n3 3 3 4\r\n4 1 3 1\r\n1 2 4 0\r\n", "output": "-1\r\n"}, {"input": "5\r\n7 6\r\n5 5 5 4\r\n6 1 7 1\r\n5 2 5 1\r\n1 1 2 1\r\n4 6 3 6\r\n1 3 4 0\r\n", "output": "5\r\n"}, {"input": "3\r\n7 7\r\n2 6 1 6\r\n7 2 6 2\r\n3 1 3 2\r\n2 0 1 1\r\n", "output": "2\r\n"}]
| false |
stdio
| null | true |
797/C
|
797
|
C
|
Python 3
|
TESTS
| 32 | 467 | 1,331,200 |
111796189
|
from collections import deque
s = input()
t = deque([])
u = ""
ind = [-1]*26
for i, ss in enumerate(s):
ind[ord(ss)-97] = i
for i,ss in enumerate(s):
now = ord(ss)-97
for j in range(0,now):
if ind[j] > i:
t.append(ss)
break
else:
while t:
now = t.pop()
if now <= ss:
u += now
else:
t.append(now)
break
u += ss
if t:
tmp = "".join(t)
u += tmp[::-1]
print(u)
| 189 | 93 | 14,336,000 |
196924702
|
from collections import Counter, deque
s = input()
n = len(s)
mn = ['z'] * (n + 1)
for i in range(n - 1, -1, -1):
mn[i] = min(mn[i + 1], s[i])
t, u = [], []
for i in range(n):
while t and t[-1] <= mn[i]:
u.append(t.pop())
if s[i] == mn[i]:
u.append(s[i])
else:
t.append(s[i])
while t:
u.append(t.pop())
print(''.join(u))
|
Educational Codeforces Round 19
|
ICPC
| 2,017 | 1 | 256 |
Minimal string
|
Petya recieved a gift of a string s with length up to 105 characters for his birthday. He took two more empty strings t and u and decided to play a game. This game has two possible moves:
- Extract the first character of s and append t with this character.
- Extract the last character of t and append u with this character.
Petya wants to get strings s and t empty and string u lexicographically minimal.
You should write a program that will help Petya win the game.
|
First line contains non-empty string s (1 ≤ |s| ≤ 105), consisting of lowercase English letters.
|
Print resulting string u.
| null | null |
[{"input": "cab", "output": "abc"}, {"input": "acdb", "output": "abdc"}]
| 1,700 |
["data structures", "greedy", "strings"]
| 189 |
[{"input": "cab\r\n", "output": "abc\r\n"}, {"input": "acdb\r\n", "output": "abdc\r\n"}, {"input": "a\r\n", "output": "a\r\n"}, {"input": "ab\r\n", "output": "ab\r\n"}, {"input": "ba\r\n", "output": "ab\r\n"}, {"input": "dijee\r\n", "output": "deeji\r\n"}, {"input": "bhrmc\r\n", "output": "bcmrh\r\n"}, {"input": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\r\n", "output": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\r\n"}, {"input": "bababaaababaabbbbbabbbbbbaaabbabaaaaabbbbbaaaabbbbabaabaabababbbabbabbabaaababbabbababaaaaabaaaabbba\r\n", "output": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\r\n"}, {"input": "bccbbcccbccbacacbaccaababcbaababaaaaabcaaabcaacbabcaababaabaccacacccbacbcacbbbaacaaccccabbbbacbcbbba\r\n", "output": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbcbcbbbbcccccbbbccbcbccccccbbbcbbccbcbbbbcbbccbccbccbcccbbccb\r\n"}, {"input": "eejahjfbbcdhbieiigaihidhageiechaadieecaaehcehjbddgcjgagdfgffdaaihbecebdjhjagghecdhbhdfbedhfhfafbjajg\r\n", "output": "aaaaaaaaaaaaagjjbffhfhdebfdhbhdcehggjhjdbecebhidffgfdggjcgddbjhecheceeidhceieghdihigiieibhdcbbfjhjee\r\n"}, {"input": "bnrdfnybkzepmluyrhofwnwvfmkdwolvyzrqhuhztvlwjldqmoyxzytpfmrgouymeupxrvpbesyxixnrfbxnqcwgmgjstknqtwrr\r\n", "output": "bbbbcggjknqrrwttsmwqnxfrnxixysepvrxpuemyuogrmfptyzxyomqdljwlvtzhuhqrzyvlowdkmfvwnwfohryulmpezkynfdrn\r\n"}, {"input": "bcaeaae\r\n", "output": "aaaecbe\r\n"}, {"input": "edcadcbcdd\r\n", "output": "abccdcddde\r\n"}, {"input": "a\r\n", "output": "a\r\n"}, {"input": "a\r\n", "output": "a\r\n"}, {"input": "a\r\n", "output": "a\r\n"}, {"input": "b\r\n", "output": "b\r\n"}, {"input": "b\r\n", "output": "b\r\n"}, {"input": "a\r\n", "output": "a\r\n"}, {"input": "c\r\n", "output": "c\r\n"}, {"input": "a\r\n", "output": "a\r\n"}, {"input": "b\r\n", "output": "b\r\n"}, {"input": "c\r\n", "output": "c\r\n"}, {"input": "b\r\n", "output": "b\r\n"}, {"input": "a\r\n", "output": "a\r\n"}, {"input": "e\r\n", "output": "e\r\n"}, {"input": "b\r\n", "output": "b\r\n"}, {"input": "b\r\n", "output": "b\r\n"}, {"input": "aa\r\n", "output": "aa\r\n"}, {"input": "aa\r\n", "output": "aa\r\n"}, {"input": "aa\r\n", "output": "aa\r\n"}, {"input": "aa\r\n", "output": "aa\r\n"}, {"input": "bb\r\n", "output": "bb\r\n"}, {"input": "bb\r\n", "output": "bb\r\n"}, {"input": "ba\r\n", "output": "ab\r\n"}, {"input": "ca\r\n", "output": "ac\r\n"}, {"input": "ab\r\n", "output": "ab\r\n"}, {"input": "cb\r\n", "output": "bc\r\n"}, {"input": "bb\r\n", "output": "bb\r\n"}, {"input": "aa\r\n", "output": "aa\r\n"}, {"input": "da\r\n", "output": "ad\r\n"}, {"input": "ab\r\n", "output": "ab\r\n"}, {"input": "cd\r\n", "output": "cd\r\n"}, {"input": "aaa\r\n", "output": "aaa\r\n"}, {"input": "aaa\r\n", "output": "aaa\r\n"}, {"input": "aaa\r\n", "output": "aaa\r\n"}, {"input": "aab\r\n", "output": "aab\r\n"}, {"input": "aaa\r\n", "output": "aaa\r\n"}, {"input": "baa\r\n", "output": "aab\r\n"}, {"input": "bab\r\n", "output": "abb\r\n"}, {"input": "baa\r\n", "output": "aab\r\n"}, {"input": "ccc\r\n", "output": "ccc\r\n"}, {"input": "ddd\r\n", "output": "ddd\r\n"}, {"input": "ccd\r\n", "output": "ccd\r\n"}, {"input": "bca\r\n", "output": "acb\r\n"}, {"input": "cde\r\n", "output": "cde\r\n"}, {"input": "ece\r\n", "output": "cee\r\n"}, {"input": "bdd\r\n", "output": "bdd\r\n"}, {"input": "aaaa\r\n", "output": "aaaa\r\n"}, {"input": "aaaa\r\n", "output": "aaaa\r\n"}, {"input": "aaaa\r\n", "output": "aaaa\r\n"}, {"input": "abaa\r\n", "output": "aaab\r\n"}, {"input": "abab\r\n", "output": "aabb\r\n"}, {"input": "bbbb\r\n", "output": "bbbb\r\n"}, {"input": "bbba\r\n", "output": "abbb\r\n"}, {"input": "caba\r\n", "output": "aabc\r\n"}, {"input": "ccbb\r\n", "output": "bbcc\r\n"}, {"input": "abac\r\n", "output": "aabc\r\n"}, {"input": "daba\r\n", "output": "aabd\r\n"}, {"input": "cdbb\r\n", "output": "bbdc\r\n"}, {"input": "bddd\r\n", "output": "bddd\r\n"}, {"input": "dacb\r\n", "output": "abcd\r\n"}, {"input": "abcc\r\n", "output": "abcc\r\n"}, {"input": "aaaaa\r\n", "output": "aaaaa\r\n"}, {"input": "aaaaa\r\n", "output": "aaaaa\r\n"}, {"input": "aaaaa\r\n", "output": "aaaaa\r\n"}, {"input": "baaab\r\n", "output": "aaabb\r\n"}, {"input": "aabbb\r\n", "output": "aabbb\r\n"}, {"input": "aabaa\r\n", "output": "aaaab\r\n"}, {"input": "abcba\r\n", "output": "aabcb\r\n"}, {"input": "bacbc\r\n", "output": "abbcc\r\n"}, {"input": "bacba\r\n", "output": "aabcb\r\n"}, {"input": "bdbda\r\n", "output": "adbdb\r\n"}, {"input": "accbb\r\n", "output": "abbcc\r\n"}, {"input": "dbccc\r\n", "output": "bcccd\r\n"}, {"input": "decca\r\n", "output": "acced\r\n"}, {"input": "dbbdd\r\n", "output": "bbddd\r\n"}, {"input": "accec\r\n", "output": "accce\r\n"}, {"input": "aaaaaa\r\n", "output": "aaaaaa\r\n"}, {"input": "aaaaaa\r\n", "output": "aaaaaa\r\n"}, {"input": "aaaaaa\r\n", "output": "aaaaaa\r\n"}, {"input": "bbbbab\r\n", "output": "abbbbb\r\n"}, {"input": "bbbbab\r\n", "output": "abbbbb\r\n"}, {"input": "aaaaba\r\n", "output": "aaaaab\r\n"}, {"input": "cbbbcc\r\n", "output": "bbbccc\r\n"}, {"input": "aaacac\r\n", "output": "aaaacc\r\n"}, {"input": "bacbbc\r\n", "output": "abbbcc\r\n"}, {"input": "cacacc\r\n", "output": "aacccc\r\n"}, {"input": "badbdc\r\n", "output": "abbcdd\r\n"}, {"input": "ddadad\r\n", "output": "aadddd\r\n"}, {"input": "ccdece\r\n", "output": "cccede\r\n"}, {"input": "eecade\r\n", "output": "acdeee\r\n"}, {"input": "eabdcb\r\n", "output": "abbcde\r\n"}, {"input": "aaaaaaa\r\n", "output": "aaaaaaa\r\n"}, {"input": "aaaaaaa\r\n", "output": "aaaaaaa\r\n"}, {"input": "aaaaaaa\r\n", "output": "aaaaaaa\r\n"}, {"input": "aaabbaa\r\n", "output": "aaaaabb\r\n"}, {"input": "baaabab\r\n", "output": "aaaabbb\r\n"}, {"input": "bbababa\r\n", "output": "aaabbbb\r\n"}, {"input": "bcccacc\r\n", "output": "acccbcc\r\n"}, {"input": "cbbcccc\r\n", "output": "bbccccc\r\n"}, {"input": "abacaaa\r\n", "output": "aaaaacb\r\n"}, {"input": "ccdbdac\r\n", "output": "acdbdcc\r\n"}, {"input": "bbacaba\r\n", "output": "aaabcbb\r\n"}, {"input": "abbaccc\r\n", "output": "aabbccc\r\n"}, {"input": "bdcbcab\r\n", "output": "abcbcdb\r\n"}, {"input": "dabcbce\r\n", "output": "abbccde\r\n"}, {"input": "abaaabe\r\n", "output": "aaaabbe\r\n"}, {"input": "aaaaaaaa\r\n", "output": "aaaaaaaa\r\n"}, {"input": "aaaaaaaa\r\n", "output": "aaaaaaaa\r\n"}, {"input": "aaaaaaaa\r\n", "output": "aaaaaaaa\r\n"}, {"input": "ababbbba\r\n", "output": "aaabbbbb\r\n"}, {"input": "aaaaaaba\r\n", "output": "aaaaaaab\r\n"}, {"input": "babbbaab\r\n", "output": "aaabbbbb\r\n"}, {"input": "bcaccaab\r\n", "output": "aaabcccb\r\n"}, {"input": "bbccaabc\r\n", "output": "aabccbbc\r\n"}, {"input": "cacaaaac\r\n", "output": "aaaaaccc\r\n"}, {"input": "daacbddc\r\n", "output": "aabccddd\r\n"}, {"input": "cdbdcdaa\r\n", "output": "aadcdbdc\r\n"}, {"input": "bccbdacd\r\n", "output": "acdbccbd\r\n"}, {"input": "abbeaade\r\n", "output": "aaadebbe\r\n"}, {"input": "ccabecba\r\n", "output": "aabcebcc\r\n"}, {"input": "ececaead\r\n", "output": "aadecece\r\n"}, {"input": "aaaaaaaaa\r\n", "output": "aaaaaaaaa\r\n"}, {"input": "aaaaaaaaa\r\n", "output": "aaaaaaaaa\r\n"}, {"input": "aaaaaaaaa\r\n", "output": "aaaaaaaaa\r\n"}, {"input": "aabaaabbb\r\n", "output": "aaaaabbbb\r\n"}, {"input": "abbbbbaab\r\n", "output": "aaabbbbbb\r\n"}, {"input": "bbbaababb\r\n", "output": "aaabbbbbb\r\n"}, {"input": "babcaaccb\r\n", "output": "aaabcccbb\r\n"}, {"input": "ccbcabaac\r\n", "output": "aaabcbccc\r\n"}, {"input": "caaaccccb\r\n", "output": "aaabccccc\r\n"}, {"input": "abbcdbddb\r\n", "output": "abbbbdddc\r\n"}, {"input": "dbcaacbbb\r\n", "output": "aabbbccbd\r\n"}, {"input": "cadcbddac\r\n", "output": "aacddbcdc\r\n"}, {"input": "ecebadadb\r\n", "output": "aabddbece\r\n"}, {"input": "bdbeeccdd\r\n", "output": "bbccddeed\r\n"}, {"input": "daaedecda\r\n", "output": "aaadceded\r\n"}, {"input": "aaaaaaaaaa\r\n", "output": "aaaaaaaaaa\r\n"}, {"input": "aaaaaaaaaa\r\n", "output": "aaaaaaaaaa\r\n"}, {"input": "aaaaaaaaaa\r\n", "output": "aaaaaaaaaa\r\n"}, {"input": "abaaaaabbb\r\n", "output": "aaaaaabbbb\r\n"}, {"input": "bbaaaabaaa\r\n", "output": "aaaaaaabbb\r\n"}, {"input": "bbabbaaaaa\r\n", "output": "aaaaaabbbb\r\n"}, {"input": "cbaabcaacc\r\n", "output": "aaaacbbccc\r\n"}, {"input": "aaaaccccab\r\n", "output": "aaaaabcccc\r\n"}, {"input": "bccaccaacc\r\n", "output": "aaaccccbcc\r\n"}, {"input": "dbdccdcacd\r\n", "output": "accdccdbdd\r\n"}, {"input": "caaddaaccb\r\n", "output": "aaaabccddc\r\n"}, {"input": "adbbabcbdc\r\n", "output": "aabbbbccdd\r\n"}, {"input": "cdeabdbbad\r\n", "output": "aabbdbdedc\r\n"}, {"input": "eeddcbeeec\r\n", "output": "bcceeeddee\r\n"}, {"input": "bbcebddeba\r\n", "output": "abeddbecbb\r\n"}]
| false |
stdio
| null | true |
691/B
|
691
|
B
|
Python 3
|
TESTS
| 11 | 46 | 0 |
172134941
|
s = input()
mu = ['A','H','I','M','O','o','T','U','V','v','W','w','X','x','Y']
slen = len(s)
flag = 1
for i in range(slen):
if s[i]==s[-i-1] and s[i] in mu:
pass
elif (s[i]=='b' and s[-i-1]=='d') or (s[i]=='d' and s[-i-1]=='b'):
pass
else:
flag = 0
if flag == 1:
print("TAK")
else:
print("NIE")
| 168 | 46 | 0 |
158963335
|
t = input()
k = len(t) // 2 + 1
p = zip(t[:k], t[-k:][::-1])
u, v = 'AHIMOoTUVvWwXxY', 'bd db pq qp'
s = all(a in u and a == b or a + b in v for a, b in p)
print(['NIE', 'TAK'][s])
|
Educational Codeforces Round 14
|
ICPC
| 2,016 | 1 | 256 |
s-palindrome
|
Let's call a string "s-palindrome" if it is symmetric about the middle of the string. For example, the string "oHo" is "s-palindrome", but the string "aa" is not. The string "aa" is not "s-palindrome", because the second half of it is not a mirror reflection of the first half.
English alphabet
You are given a string s. Check if the string is "s-palindrome".
|
The only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.
|
Print "TAK" if the string s is "s-palindrome" and "NIE" otherwise.
| null | null |
[{"input": "oXoxoXo", "output": "TAK"}, {"input": "bod", "output": "TAK"}, {"input": "ER", "output": "NIE"}]
| 1,600 |
["implementation", "strings"]
| 168 |
[{"input": "oXoxoXo\r\n", "output": "TAK\r\n"}, {"input": "bod\r\n", "output": "TAK\r\n"}, {"input": "ER\r\n", "output": "NIE\r\n"}, {"input": "o\r\n", "output": "TAK\r\n"}, {"input": "a\r\n", "output": "NIE\r\n"}, {"input": "opo\r\n", "output": "NIE\r\n"}, {"input": "HCMoxkgbNb\r\n", "output": "NIE\r\n"}, {"input": "vMhhXCMWDe\r\n", "output": "NIE\r\n"}, {"input": "iIcamjTRFH\r\n", "output": "NIE\r\n"}, {"input": "WvoWvvWovW\r\n", "output": "TAK\r\n"}, {"input": "WXxAdbAxXW\r\n", "output": "TAK\r\n"}, {"input": "vqMTUUTMpv\r\n", "output": "TAK\r\n"}, {"input": "iii\r\n", "output": "NIE\r\n"}, {"input": "AAWW\r\n", "output": "NIE\r\n"}, {"input": "ss\r\n", "output": "NIE\r\n"}, {"input": "i\r\n", "output": "NIE\r\n"}, {"input": "ii\r\n", "output": "NIE\r\n"}, {"input": "mm\r\n", "output": "NIE\r\n"}, {"input": "LJ\r\n", "output": "NIE\r\n"}, {"input": "m\r\n", "output": "NIE\r\n"}, {"input": "ioi\r\n", "output": "NIE\r\n"}, {"input": "OA\r\n", "output": "NIE\r\n"}, {"input": "aaaiaaa\r\n", "output": "NIE\r\n"}, {"input": "SS\r\n", "output": "NIE\r\n"}, {"input": "iiii\r\n", "output": "NIE\r\n"}, {"input": "ssops\r\n", "output": "NIE\r\n"}, {"input": "ssss\r\n", "output": "NIE\r\n"}, {"input": "ll\r\n", "output": "NIE\r\n"}, {"input": "s\r\n", "output": "NIE\r\n"}, {"input": "bb\r\n", "output": "NIE\r\n"}, {"input": "uu\r\n", "output": "NIE\r\n"}, {"input": "ZoZ\r\n", "output": "NIE\r\n"}, {"input": "mom\r\n", "output": "NIE\r\n"}, {"input": "uou\r\n", "output": "NIE\r\n"}, {"input": "u\r\n", "output": "NIE\r\n"}, {"input": "JL\r\n", "output": "NIE\r\n"}, {"input": "mOm\r\n", "output": "NIE\r\n"}, {"input": "llll\r\n", "output": "NIE\r\n"}, {"input": "ouo\r\n", "output": "NIE\r\n"}, {"input": "aa\r\n", "output": "NIE\r\n"}, {"input": "olo\r\n", "output": "NIE\r\n"}, {"input": "S\r\n", "output": "NIE\r\n"}, {"input": "lAl\r\n", "output": "NIE\r\n"}, {"input": "nnnn\r\n", "output": "NIE\r\n"}, {"input": "ZzZ\r\n", "output": "NIE\r\n"}, {"input": "bNd\r\n", "output": "NIE\r\n"}, {"input": "ZZ\r\n", "output": "NIE\r\n"}, {"input": "oNoNo\r\n", "output": "NIE\r\n"}, {"input": "l\r\n", "output": "NIE\r\n"}, {"input": "zz\r\n", "output": "NIE\r\n"}, {"input": "NON\r\n", "output": "NIE\r\n"}, {"input": "nn\r\n", "output": "NIE\r\n"}, {"input": "NoN\r\n", "output": "NIE\r\n"}, {"input": "sos\r\n", "output": "NIE\r\n"}, {"input": "lol\r\n", "output": "NIE\r\n"}, {"input": "mmm\r\n", "output": "NIE\r\n"}, {"input": "YAiAY\r\n", "output": "NIE\r\n"}, {"input": "ipIqi\r\n", "output": "NIE\r\n"}, {"input": "AAA\r\n", "output": "TAK\r\n"}, {"input": "uoOou\r\n", "output": "NIE\r\n"}, {"input": "SOS\r\n", "output": "NIE\r\n"}, {"input": "NN\r\n", "output": "NIE\r\n"}, {"input": "n\r\n", "output": "NIE\r\n"}, {"input": "h\r\n", "output": "NIE\r\n"}, {"input": "blld\r\n", "output": "NIE\r\n"}, {"input": "ipOqi\r\n", "output": "NIE\r\n"}, {"input": "pop\r\n", "output": "NIE\r\n"}, {"input": "BB\r\n", "output": "NIE\r\n"}, {"input": "OuO\r\n", "output": "NIE\r\n"}, {"input": "lxl\r\n", "output": "NIE\r\n"}, {"input": "Z\r\n", "output": "NIE\r\n"}, {"input": "vvivv\r\n", "output": "NIE\r\n"}, {"input": "nnnnnnnnnnnnn\r\n", "output": "NIE\r\n"}, {"input": "AA\r\n", "output": "TAK\r\n"}, {"input": "t\r\n", "output": "NIE\r\n"}, {"input": "z\r\n", "output": "NIE\r\n"}, {"input": "mmmAmmm\r\n", "output": "NIE\r\n"}, {"input": "qlililp\r\n", "output": "NIE\r\n"}, {"input": "mpOqm\r\n", "output": "NIE\r\n"}, {"input": "iiiiiiiiii\r\n", "output": "NIE\r\n"}, {"input": "BAAAB\r\n", "output": "NIE\r\n"}, {"input": "UA\r\n", "output": "NIE\r\n"}, {"input": "mmmmmmm\r\n", "output": "NIE\r\n"}, {"input": "NpOqN\r\n", "output": "NIE\r\n"}, {"input": "uOu\r\n", "output": "NIE\r\n"}, {"input": "uuu\r\n", "output": "NIE\r\n"}, {"input": "NAMAN\r\n", "output": "NIE\r\n"}, {"input": "lllll\r\n", "output": "NIE\r\n"}, {"input": "T\r\n", "output": "TAK\r\n"}, {"input": "mmmmmmmmmmmmmmmm\r\n", "output": "NIE\r\n"}, {"input": "AiiA\r\n", "output": "NIE\r\n"}, {"input": "iOi\r\n", "output": "NIE\r\n"}, {"input": "lll\r\n", "output": "NIE\r\n"}, {"input": "N\r\n", "output": "NIE\r\n"}, {"input": "viv\r\n", "output": "NIE\r\n"}, {"input": "oiio\r\n", "output": "NIE\r\n"}, {"input": "AiiiA\r\n", "output": "NIE\r\n"}, {"input": "NNNN\r\n", "output": "NIE\r\n"}, {"input": "ixi\r\n", "output": "NIE\r\n"}, {"input": "AuuA\r\n", "output": "NIE\r\n"}, {"input": "AAAANANAAAA\r\n", "output": "NIE\r\n"}, {"input": "mmmmm\r\n", "output": "NIE\r\n"}, {"input": "oYo\r\n", "output": "TAK\r\n"}, {"input": "dd\r\n", "output": "NIE\r\n"}, {"input": "A\r\n", "output": "TAK\r\n"}, {"input": "ioh\r\n", "output": "NIE\r\n"}, {"input": "mmmm\r\n", "output": "NIE\r\n"}, {"input": "uuuu\r\n", "output": "NIE\r\n"}, {"input": "puq\r\n", "output": "NIE\r\n"}, {"input": "rrrrrr\r\n", "output": "NIE\r\n"}, {"input": "c\r\n", "output": "NIE\r\n"}, {"input": "AbpA\r\n", "output": "NIE\r\n"}, {"input": "qAq\r\n", "output": "NIE\r\n"}, {"input": "tt\r\n", "output": "NIE\r\n"}, {"input": "mnmnm\r\n", "output": "NIE\r\n"}, {"input": "sss\r\n", "output": "NIE\r\n"}, {"input": "yy\r\n", "output": "NIE\r\n"}, {"input": "bob\r\n", "output": "NIE\r\n"}, {"input": "NAN\r\n", "output": "NIE\r\n"}, {"input": "mAm\r\n", "output": "NIE\r\n"}, {"input": "tAt\r\n", "output": "NIE\r\n"}, {"input": "yAy\r\n", "output": "NIE\r\n"}, {"input": "zAz\r\n", "output": "NIE\r\n"}, {"input": "aZ\r\n", "output": "NIE\r\n"}, {"input": "hh\r\n", "output": "NIE\r\n"}, {"input": "bbbb\r\n", "output": "NIE\r\n"}, {"input": "ZAZ\r\n", "output": "NIE\r\n"}, {"input": "Y\r\n", "output": "TAK\r\n"}, {"input": "AAMM\r\n", "output": "NIE\r\n"}, {"input": "lml\r\n", "output": "NIE\r\n"}, {"input": "AZA\r\n", "output": "NIE\r\n"}, {"input": "mXm\r\n", "output": "NIE\r\n"}, {"input": "bd\r\n", "output": "TAK\r\n"}, {"input": "H\r\n", "output": "TAK\r\n"}, {"input": "uvu\r\n", "output": "NIE\r\n"}, {"input": "dxxd\r\n", "output": "NIE\r\n"}, {"input": "dp\r\n", "output": "NIE\r\n"}, {"input": "vV\r\n", "output": "NIE\r\n"}, {"input": "vMo\r\n", "output": "NIE\r\n"}, {"input": "O\r\n", "output": "TAK\r\n"}, {"input": "vYv\r\n", "output": "TAK\r\n"}, {"input": "fv\r\n", "output": "NIE\r\n"}, {"input": "U\r\n", "output": "TAK\r\n"}, {"input": "iAi\r\n", "output": "NIE\r\n"}, {"input": "I\r\n", "output": "TAK\r\n"}, {"input": "VxrV\r\n", "output": "NIE\r\n"}, {"input": "POP\r\n", "output": "NIE\r\n"}, {"input": "bid\r\n", "output": "NIE\r\n"}, {"input": "bmd\r\n", "output": "NIE\r\n"}, {"input": "AiA\r\n", "output": "NIE\r\n"}, {"input": "mmmmmm\r\n", "output": "NIE\r\n"}, {"input": "XHX\r\n", "output": "TAK\r\n"}, {"input": "llllll\r\n", "output": "NIE\r\n"}, {"input": "aAa\r\n", "output": "NIE\r\n"}, {"input": "Db\r\n", "output": "NIE\r\n"}, {"input": "lOl\r\n", "output": "NIE\r\n"}, {"input": "bzd\r\n", "output": "NIE\r\n"}]
| false |
stdio
| null | true |
691/B
|
691
|
B
|
Python 3
|
TESTS
| 11 | 62 | 307,200 |
109822485
|
chars = {
'A': {'A'},
'b': {'d'},
'd': {'b'},
'H': {'H'},
'M':{'M'},
'O':{'O'},
'o':{'o'},
'T':{'T'},
'U':{'U'},
'V':{'V'},
'v':{'v'},
'W':{'W'},
'w':{'w'},
'X':{'X'},
'x': {'x'},
'Y':{'Y'},
}
s = input()
ans = True
for i in range(len(s)//2):
if s[i] not in chars.keys() or s[len(s) - i - 1] not in chars[s[i]]:
ans = False
break
if (len(s) % 2 != 0 and (s[len(s)//2] not in chars.keys()
or s[len(s)//2] == 'b' or s[len(s)//2] == 'd')):
ans = False
if ans:
print("TAK")
else:
print("NIE")
| 168 | 46 | 0 |
185154340
|
s=input()
p='AbdHIMOopqTUVvWwXxY'
p1='AdbHIMOoqpTUVvWwXxY'
j=1
n=len(s)
for i in range(n):
if s[i] not in p:
j=0
break
elif p1[p.index(s[i])]!=s[n-i-1]:
j=0
break
if j==1:
print('TAK')
else:
print('NIE')
|
Educational Codeforces Round 14
|
ICPC
| 2,016 | 1 | 256 |
s-palindrome
|
Let's call a string "s-palindrome" if it is symmetric about the middle of the string. For example, the string "oHo" is "s-palindrome", but the string "aa" is not. The string "aa" is not "s-palindrome", because the second half of it is not a mirror reflection of the first half.
English alphabet
You are given a string s. Check if the string is "s-palindrome".
|
The only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.
|
Print "TAK" if the string s is "s-palindrome" and "NIE" otherwise.
| null | null |
[{"input": "oXoxoXo", "output": "TAK"}, {"input": "bod", "output": "TAK"}, {"input": "ER", "output": "NIE"}]
| 1,600 |
["implementation", "strings"]
| 168 |
[{"input": "oXoxoXo\r\n", "output": "TAK\r\n"}, {"input": "bod\r\n", "output": "TAK\r\n"}, {"input": "ER\r\n", "output": "NIE\r\n"}, {"input": "o\r\n", "output": "TAK\r\n"}, {"input": "a\r\n", "output": "NIE\r\n"}, {"input": "opo\r\n", "output": "NIE\r\n"}, {"input": "HCMoxkgbNb\r\n", "output": "NIE\r\n"}, {"input": "vMhhXCMWDe\r\n", "output": "NIE\r\n"}, {"input": "iIcamjTRFH\r\n", "output": "NIE\r\n"}, {"input": "WvoWvvWovW\r\n", "output": "TAK\r\n"}, {"input": "WXxAdbAxXW\r\n", "output": "TAK\r\n"}, {"input": "vqMTUUTMpv\r\n", "output": "TAK\r\n"}, {"input": "iii\r\n", "output": "NIE\r\n"}, {"input": "AAWW\r\n", "output": "NIE\r\n"}, {"input": "ss\r\n", "output": "NIE\r\n"}, {"input": "i\r\n", "output": "NIE\r\n"}, {"input": "ii\r\n", "output": "NIE\r\n"}, {"input": "mm\r\n", "output": "NIE\r\n"}, {"input": "LJ\r\n", "output": "NIE\r\n"}, {"input": "m\r\n", "output": "NIE\r\n"}, {"input": "ioi\r\n", "output": "NIE\r\n"}, {"input": "OA\r\n", "output": "NIE\r\n"}, {"input": "aaaiaaa\r\n", "output": "NIE\r\n"}, {"input": "SS\r\n", "output": "NIE\r\n"}, {"input": "iiii\r\n", "output": "NIE\r\n"}, {"input": "ssops\r\n", "output": "NIE\r\n"}, {"input": "ssss\r\n", "output": "NIE\r\n"}, {"input": "ll\r\n", "output": "NIE\r\n"}, {"input": "s\r\n", "output": "NIE\r\n"}, {"input": "bb\r\n", "output": "NIE\r\n"}, {"input": "uu\r\n", "output": "NIE\r\n"}, {"input": "ZoZ\r\n", "output": "NIE\r\n"}, {"input": "mom\r\n", "output": "NIE\r\n"}, {"input": "uou\r\n", "output": "NIE\r\n"}, {"input": "u\r\n", "output": "NIE\r\n"}, {"input": "JL\r\n", "output": "NIE\r\n"}, {"input": "mOm\r\n", "output": "NIE\r\n"}, {"input": "llll\r\n", "output": "NIE\r\n"}, {"input": "ouo\r\n", "output": "NIE\r\n"}, {"input": "aa\r\n", "output": "NIE\r\n"}, {"input": "olo\r\n", "output": "NIE\r\n"}, {"input": "S\r\n", "output": "NIE\r\n"}, {"input": "lAl\r\n", "output": "NIE\r\n"}, {"input": "nnnn\r\n", "output": "NIE\r\n"}, {"input": "ZzZ\r\n", "output": "NIE\r\n"}, {"input": "bNd\r\n", "output": "NIE\r\n"}, {"input": "ZZ\r\n", "output": "NIE\r\n"}, {"input": "oNoNo\r\n", "output": "NIE\r\n"}, {"input": "l\r\n", "output": "NIE\r\n"}, {"input": "zz\r\n", "output": "NIE\r\n"}, {"input": "NON\r\n", "output": "NIE\r\n"}, {"input": "nn\r\n", "output": "NIE\r\n"}, {"input": "NoN\r\n", "output": "NIE\r\n"}, {"input": "sos\r\n", "output": "NIE\r\n"}, {"input": "lol\r\n", "output": "NIE\r\n"}, {"input": "mmm\r\n", "output": "NIE\r\n"}, {"input": "YAiAY\r\n", "output": "NIE\r\n"}, {"input": "ipIqi\r\n", "output": "NIE\r\n"}, {"input": "AAA\r\n", "output": "TAK\r\n"}, {"input": "uoOou\r\n", "output": "NIE\r\n"}, {"input": "SOS\r\n", "output": "NIE\r\n"}, {"input": "NN\r\n", "output": "NIE\r\n"}, {"input": "n\r\n", "output": "NIE\r\n"}, {"input": "h\r\n", "output": "NIE\r\n"}, {"input": "blld\r\n", "output": "NIE\r\n"}, {"input": "ipOqi\r\n", "output": "NIE\r\n"}, {"input": "pop\r\n", "output": "NIE\r\n"}, {"input": "BB\r\n", "output": "NIE\r\n"}, {"input": "OuO\r\n", "output": "NIE\r\n"}, {"input": "lxl\r\n", "output": "NIE\r\n"}, {"input": "Z\r\n", "output": "NIE\r\n"}, {"input": "vvivv\r\n", "output": "NIE\r\n"}, {"input": "nnnnnnnnnnnnn\r\n", "output": "NIE\r\n"}, {"input": "AA\r\n", "output": "TAK\r\n"}, {"input": "t\r\n", "output": "NIE\r\n"}, {"input": "z\r\n", "output": "NIE\r\n"}, {"input": "mmmAmmm\r\n", "output": "NIE\r\n"}, {"input": "qlililp\r\n", "output": "NIE\r\n"}, {"input": "mpOqm\r\n", "output": "NIE\r\n"}, {"input": "iiiiiiiiii\r\n", "output": "NIE\r\n"}, {"input": "BAAAB\r\n", "output": "NIE\r\n"}, {"input": "UA\r\n", "output": "NIE\r\n"}, {"input": "mmmmmmm\r\n", "output": "NIE\r\n"}, {"input": "NpOqN\r\n", "output": "NIE\r\n"}, {"input": "uOu\r\n", "output": "NIE\r\n"}, {"input": "uuu\r\n", "output": "NIE\r\n"}, {"input": "NAMAN\r\n", "output": "NIE\r\n"}, {"input": "lllll\r\n", "output": "NIE\r\n"}, {"input": "T\r\n", "output": "TAK\r\n"}, {"input": "mmmmmmmmmmmmmmmm\r\n", "output": "NIE\r\n"}, {"input": "AiiA\r\n", "output": "NIE\r\n"}, {"input": "iOi\r\n", "output": "NIE\r\n"}, {"input": "lll\r\n", "output": "NIE\r\n"}, {"input": "N\r\n", "output": "NIE\r\n"}, {"input": "viv\r\n", "output": "NIE\r\n"}, {"input": "oiio\r\n", "output": "NIE\r\n"}, {"input": "AiiiA\r\n", "output": "NIE\r\n"}, {"input": "NNNN\r\n", "output": "NIE\r\n"}, {"input": "ixi\r\n", "output": "NIE\r\n"}, {"input": "AuuA\r\n", "output": "NIE\r\n"}, {"input": "AAAANANAAAA\r\n", "output": "NIE\r\n"}, {"input": "mmmmm\r\n", "output": "NIE\r\n"}, {"input": "oYo\r\n", "output": "TAK\r\n"}, {"input": "dd\r\n", "output": "NIE\r\n"}, {"input": "A\r\n", "output": "TAK\r\n"}, {"input": "ioh\r\n", "output": "NIE\r\n"}, {"input": "mmmm\r\n", "output": "NIE\r\n"}, {"input": "uuuu\r\n", "output": "NIE\r\n"}, {"input": "puq\r\n", "output": "NIE\r\n"}, {"input": "rrrrrr\r\n", "output": "NIE\r\n"}, {"input": "c\r\n", "output": "NIE\r\n"}, {"input": "AbpA\r\n", "output": "NIE\r\n"}, {"input": "qAq\r\n", "output": "NIE\r\n"}, {"input": "tt\r\n", "output": "NIE\r\n"}, {"input": "mnmnm\r\n", "output": "NIE\r\n"}, {"input": "sss\r\n", "output": "NIE\r\n"}, {"input": "yy\r\n", "output": "NIE\r\n"}, {"input": "bob\r\n", "output": "NIE\r\n"}, {"input": "NAN\r\n", "output": "NIE\r\n"}, {"input": "mAm\r\n", "output": "NIE\r\n"}, {"input": "tAt\r\n", "output": "NIE\r\n"}, {"input": "yAy\r\n", "output": "NIE\r\n"}, {"input": "zAz\r\n", "output": "NIE\r\n"}, {"input": "aZ\r\n", "output": "NIE\r\n"}, {"input": "hh\r\n", "output": "NIE\r\n"}, {"input": "bbbb\r\n", "output": "NIE\r\n"}, {"input": "ZAZ\r\n", "output": "NIE\r\n"}, {"input": "Y\r\n", "output": "TAK\r\n"}, {"input": "AAMM\r\n", "output": "NIE\r\n"}, {"input": "lml\r\n", "output": "NIE\r\n"}, {"input": "AZA\r\n", "output": "NIE\r\n"}, {"input": "mXm\r\n", "output": "NIE\r\n"}, {"input": "bd\r\n", "output": "TAK\r\n"}, {"input": "H\r\n", "output": "TAK\r\n"}, {"input": "uvu\r\n", "output": "NIE\r\n"}, {"input": "dxxd\r\n", "output": "NIE\r\n"}, {"input": "dp\r\n", "output": "NIE\r\n"}, {"input": "vV\r\n", "output": "NIE\r\n"}, {"input": "vMo\r\n", "output": "NIE\r\n"}, {"input": "O\r\n", "output": "TAK\r\n"}, {"input": "vYv\r\n", "output": "TAK\r\n"}, {"input": "fv\r\n", "output": "NIE\r\n"}, {"input": "U\r\n", "output": "TAK\r\n"}, {"input": "iAi\r\n", "output": "NIE\r\n"}, {"input": "I\r\n", "output": "TAK\r\n"}, {"input": "VxrV\r\n", "output": "NIE\r\n"}, {"input": "POP\r\n", "output": "NIE\r\n"}, {"input": "bid\r\n", "output": "NIE\r\n"}, {"input": "bmd\r\n", "output": "NIE\r\n"}, {"input": "AiA\r\n", "output": "NIE\r\n"}, {"input": "mmmmmm\r\n", "output": "NIE\r\n"}, {"input": "XHX\r\n", "output": "TAK\r\n"}, {"input": "llllll\r\n", "output": "NIE\r\n"}, {"input": "aAa\r\n", "output": "NIE\r\n"}, {"input": "Db\r\n", "output": "NIE\r\n"}, {"input": "lOl\r\n", "output": "NIE\r\n"}, {"input": "bzd\r\n", "output": "NIE\r\n"}]
| false |
stdio
| null | true |
691/B
|
691
|
B
|
PyPy 3
|
TESTS
| 11 | 62 | 19,968,000 |
36211090
|
symmetric_letters = ['A', 'H', 'I', 'M', 'O', 'o', 'U', 'V',
'v', 'W', 'w', 'X', 'x', 'Y']
letter_trans = {
'b': 'd',
'd': 'b',
'p': 'q',
'q': 'p',
}
for letter in symmetric_letters:
letter_trans[letter] = letter
word = input()
if all([x in letter_trans for x in word]) and \
list(word) == [letter_trans[x] for x in word[::-1]]:
print("TAK")
else:
print("NIE")
| 168 | 62 | 0 |
19079997
|
d = "AHIMOoTUVvWwXxY"
s = input()
for i in range(len(s) // 2 + 1):
if not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in ["bd", "db", "pq", "qp"]):
print("NIE")
break
else:
print("TAK")
|
Educational Codeforces Round 14
|
ICPC
| 2,016 | 1 | 256 |
s-palindrome
|
Let's call a string "s-palindrome" if it is symmetric about the middle of the string. For example, the string "oHo" is "s-palindrome", but the string "aa" is not. The string "aa" is not "s-palindrome", because the second half of it is not a mirror reflection of the first half.
English alphabet
You are given a string s. Check if the string is "s-palindrome".
|
The only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.
|
Print "TAK" if the string s is "s-palindrome" and "NIE" otherwise.
| null | null |
[{"input": "oXoxoXo", "output": "TAK"}, {"input": "bod", "output": "TAK"}, {"input": "ER", "output": "NIE"}]
| 1,600 |
["implementation", "strings"]
| 168 |
[{"input": "oXoxoXo\r\n", "output": "TAK\r\n"}, {"input": "bod\r\n", "output": "TAK\r\n"}, {"input": "ER\r\n", "output": "NIE\r\n"}, {"input": "o\r\n", "output": "TAK\r\n"}, {"input": "a\r\n", "output": "NIE\r\n"}, {"input": "opo\r\n", "output": "NIE\r\n"}, {"input": "HCMoxkgbNb\r\n", "output": "NIE\r\n"}, {"input": "vMhhXCMWDe\r\n", "output": "NIE\r\n"}, {"input": "iIcamjTRFH\r\n", "output": "NIE\r\n"}, {"input": "WvoWvvWovW\r\n", "output": "TAK\r\n"}, {"input": "WXxAdbAxXW\r\n", "output": "TAK\r\n"}, {"input": "vqMTUUTMpv\r\n", "output": "TAK\r\n"}, {"input": "iii\r\n", "output": "NIE\r\n"}, {"input": "AAWW\r\n", "output": "NIE\r\n"}, {"input": "ss\r\n", "output": "NIE\r\n"}, {"input": "i\r\n", "output": "NIE\r\n"}, {"input": "ii\r\n", "output": "NIE\r\n"}, {"input": "mm\r\n", "output": "NIE\r\n"}, {"input": "LJ\r\n", "output": "NIE\r\n"}, {"input": "m\r\n", "output": "NIE\r\n"}, {"input": "ioi\r\n", "output": "NIE\r\n"}, {"input": "OA\r\n", "output": "NIE\r\n"}, {"input": "aaaiaaa\r\n", "output": "NIE\r\n"}, {"input": "SS\r\n", "output": "NIE\r\n"}, {"input": "iiii\r\n", "output": "NIE\r\n"}, {"input": "ssops\r\n", "output": "NIE\r\n"}, {"input": "ssss\r\n", "output": "NIE\r\n"}, {"input": "ll\r\n", "output": "NIE\r\n"}, {"input": "s\r\n", "output": "NIE\r\n"}, {"input": "bb\r\n", "output": "NIE\r\n"}, {"input": "uu\r\n", "output": "NIE\r\n"}, {"input": "ZoZ\r\n", "output": "NIE\r\n"}, {"input": "mom\r\n", "output": "NIE\r\n"}, {"input": "uou\r\n", "output": "NIE\r\n"}, {"input": "u\r\n", "output": "NIE\r\n"}, {"input": "JL\r\n", "output": "NIE\r\n"}, {"input": "mOm\r\n", "output": "NIE\r\n"}, {"input": "llll\r\n", "output": "NIE\r\n"}, {"input": "ouo\r\n", "output": "NIE\r\n"}, {"input": "aa\r\n", "output": "NIE\r\n"}, {"input": "olo\r\n", "output": "NIE\r\n"}, {"input": "S\r\n", "output": "NIE\r\n"}, {"input": "lAl\r\n", "output": "NIE\r\n"}, {"input": "nnnn\r\n", "output": "NIE\r\n"}, {"input": "ZzZ\r\n", "output": "NIE\r\n"}, {"input": "bNd\r\n", "output": "NIE\r\n"}, {"input": "ZZ\r\n", "output": "NIE\r\n"}, {"input": "oNoNo\r\n", "output": "NIE\r\n"}, {"input": "l\r\n", "output": "NIE\r\n"}, {"input": "zz\r\n", "output": "NIE\r\n"}, {"input": "NON\r\n", "output": "NIE\r\n"}, {"input": "nn\r\n", "output": "NIE\r\n"}, {"input": "NoN\r\n", "output": "NIE\r\n"}, {"input": "sos\r\n", "output": "NIE\r\n"}, {"input": "lol\r\n", "output": "NIE\r\n"}, {"input": "mmm\r\n", "output": "NIE\r\n"}, {"input": "YAiAY\r\n", "output": "NIE\r\n"}, {"input": "ipIqi\r\n", "output": "NIE\r\n"}, {"input": "AAA\r\n", "output": "TAK\r\n"}, {"input": "uoOou\r\n", "output": "NIE\r\n"}, {"input": "SOS\r\n", "output": "NIE\r\n"}, {"input": "NN\r\n", "output": "NIE\r\n"}, {"input": "n\r\n", "output": "NIE\r\n"}, {"input": "h\r\n", "output": "NIE\r\n"}, {"input": "blld\r\n", "output": "NIE\r\n"}, {"input": "ipOqi\r\n", "output": "NIE\r\n"}, {"input": "pop\r\n", "output": "NIE\r\n"}, {"input": "BB\r\n", "output": "NIE\r\n"}, {"input": "OuO\r\n", "output": "NIE\r\n"}, {"input": "lxl\r\n", "output": "NIE\r\n"}, {"input": "Z\r\n", "output": "NIE\r\n"}, {"input": "vvivv\r\n", "output": "NIE\r\n"}, {"input": "nnnnnnnnnnnnn\r\n", "output": "NIE\r\n"}, {"input": "AA\r\n", "output": "TAK\r\n"}, {"input": "t\r\n", "output": "NIE\r\n"}, {"input": "z\r\n", "output": "NIE\r\n"}, {"input": "mmmAmmm\r\n", "output": "NIE\r\n"}, {"input": "qlililp\r\n", "output": "NIE\r\n"}, {"input": "mpOqm\r\n", "output": "NIE\r\n"}, {"input": "iiiiiiiiii\r\n", "output": "NIE\r\n"}, {"input": "BAAAB\r\n", "output": "NIE\r\n"}, {"input": "UA\r\n", "output": "NIE\r\n"}, {"input": "mmmmmmm\r\n", "output": "NIE\r\n"}, {"input": "NpOqN\r\n", "output": "NIE\r\n"}, {"input": "uOu\r\n", "output": "NIE\r\n"}, {"input": "uuu\r\n", "output": "NIE\r\n"}, {"input": "NAMAN\r\n", "output": "NIE\r\n"}, {"input": "lllll\r\n", "output": "NIE\r\n"}, {"input": "T\r\n", "output": "TAK\r\n"}, {"input": "mmmmmmmmmmmmmmmm\r\n", "output": "NIE\r\n"}, {"input": "AiiA\r\n", "output": "NIE\r\n"}, {"input": "iOi\r\n", "output": "NIE\r\n"}, {"input": "lll\r\n", "output": "NIE\r\n"}, {"input": "N\r\n", "output": "NIE\r\n"}, {"input": "viv\r\n", "output": "NIE\r\n"}, {"input": "oiio\r\n", "output": "NIE\r\n"}, {"input": "AiiiA\r\n", "output": "NIE\r\n"}, {"input": "NNNN\r\n", "output": "NIE\r\n"}, {"input": "ixi\r\n", "output": "NIE\r\n"}, {"input": "AuuA\r\n", "output": "NIE\r\n"}, {"input": "AAAANANAAAA\r\n", "output": "NIE\r\n"}, {"input": "mmmmm\r\n", "output": "NIE\r\n"}, {"input": "oYo\r\n", "output": "TAK\r\n"}, {"input": "dd\r\n", "output": "NIE\r\n"}, {"input": "A\r\n", "output": "TAK\r\n"}, {"input": "ioh\r\n", "output": "NIE\r\n"}, {"input": "mmmm\r\n", "output": "NIE\r\n"}, {"input": "uuuu\r\n", "output": "NIE\r\n"}, {"input": "puq\r\n", "output": "NIE\r\n"}, {"input": "rrrrrr\r\n", "output": "NIE\r\n"}, {"input": "c\r\n", "output": "NIE\r\n"}, {"input": "AbpA\r\n", "output": "NIE\r\n"}, {"input": "qAq\r\n", "output": "NIE\r\n"}, {"input": "tt\r\n", "output": "NIE\r\n"}, {"input": "mnmnm\r\n", "output": "NIE\r\n"}, {"input": "sss\r\n", "output": "NIE\r\n"}, {"input": "yy\r\n", "output": "NIE\r\n"}, {"input": "bob\r\n", "output": "NIE\r\n"}, {"input": "NAN\r\n", "output": "NIE\r\n"}, {"input": "mAm\r\n", "output": "NIE\r\n"}, {"input": "tAt\r\n", "output": "NIE\r\n"}, {"input": "yAy\r\n", "output": "NIE\r\n"}, {"input": "zAz\r\n", "output": "NIE\r\n"}, {"input": "aZ\r\n", "output": "NIE\r\n"}, {"input": "hh\r\n", "output": "NIE\r\n"}, {"input": "bbbb\r\n", "output": "NIE\r\n"}, {"input": "ZAZ\r\n", "output": "NIE\r\n"}, {"input": "Y\r\n", "output": "TAK\r\n"}, {"input": "AAMM\r\n", "output": "NIE\r\n"}, {"input": "lml\r\n", "output": "NIE\r\n"}, {"input": "AZA\r\n", "output": "NIE\r\n"}, {"input": "mXm\r\n", "output": "NIE\r\n"}, {"input": "bd\r\n", "output": "TAK\r\n"}, {"input": "H\r\n", "output": "TAK\r\n"}, {"input": "uvu\r\n", "output": "NIE\r\n"}, {"input": "dxxd\r\n", "output": "NIE\r\n"}, {"input": "dp\r\n", "output": "NIE\r\n"}, {"input": "vV\r\n", "output": "NIE\r\n"}, {"input": "vMo\r\n", "output": "NIE\r\n"}, {"input": "O\r\n", "output": "TAK\r\n"}, {"input": "vYv\r\n", "output": "TAK\r\n"}, {"input": "fv\r\n", "output": "NIE\r\n"}, {"input": "U\r\n", "output": "TAK\r\n"}, {"input": "iAi\r\n", "output": "NIE\r\n"}, {"input": "I\r\n", "output": "TAK\r\n"}, {"input": "VxrV\r\n", "output": "NIE\r\n"}, {"input": "POP\r\n", "output": "NIE\r\n"}, {"input": "bid\r\n", "output": "NIE\r\n"}, {"input": "bmd\r\n", "output": "NIE\r\n"}, {"input": "AiA\r\n", "output": "NIE\r\n"}, {"input": "mmmmmm\r\n", "output": "NIE\r\n"}, {"input": "XHX\r\n", "output": "TAK\r\n"}, {"input": "llllll\r\n", "output": "NIE\r\n"}, {"input": "aAa\r\n", "output": "NIE\r\n"}, {"input": "Db\r\n", "output": "NIE\r\n"}, {"input": "lOl\r\n", "output": "NIE\r\n"}, {"input": "bzd\r\n", "output": "NIE\r\n"}]
| false |
stdio
| null | true |
691/B
|
691
|
B
|
Python 3
|
TESTS
| 11 | 46 | 0 |
171744136
|
a='AAHHMMTTUUVVWWXXYYOOMMbddboovvxxww'
a1=[]
for i in range(0,len(a),2):
a1.append(a[i]+a[i+1])
s=input()
t='AHMTUVWMXYOMoxvw'
x=True
if len(s)%2==1:
if s[len(s)//2] in t:
for i in range(len(s)//2):
if s[i]+s[len(s)-i-1] in a1:
x=True
else:
x=False
break
else:
x=False
elif x==True:
for i in range(len(s) // 2):
if s[i]+s[len(s)-i-1] in a1:
x = True
else:
x = False
break
if x==True:
print('TAK')
else:
print('NIE')
| 168 | 62 | 0 |
19080023
|
s = input()
p = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz'
for c in s:
if c in p:
print('NIE')
exit()
def trans(c):
d = {
'b': 'd',
'd': 'b',
'p': 'q',
'q': 'p',
}
if c in d:
return d[c]
return c
t = ''.join(map(trans, s[::-1]))
if t == s:
print('TAK')
else:
print('NIE')
|
Educational Codeforces Round 14
|
ICPC
| 2,016 | 1 | 256 |
s-palindrome
|
Let's call a string "s-palindrome" if it is symmetric about the middle of the string. For example, the string "oHo" is "s-palindrome", but the string "aa" is not. The string "aa" is not "s-palindrome", because the second half of it is not a mirror reflection of the first half.
English alphabet
You are given a string s. Check if the string is "s-palindrome".
|
The only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.
|
Print "TAK" if the string s is "s-palindrome" and "NIE" otherwise.
| null | null |
[{"input": "oXoxoXo", "output": "TAK"}, {"input": "bod", "output": "TAK"}, {"input": "ER", "output": "NIE"}]
| 1,600 |
["implementation", "strings"]
| 168 |
[{"input": "oXoxoXo\r\n", "output": "TAK\r\n"}, {"input": "bod\r\n", "output": "TAK\r\n"}, {"input": "ER\r\n", "output": "NIE\r\n"}, {"input": "o\r\n", "output": "TAK\r\n"}, {"input": "a\r\n", "output": "NIE\r\n"}, {"input": "opo\r\n", "output": "NIE\r\n"}, {"input": "HCMoxkgbNb\r\n", "output": "NIE\r\n"}, {"input": "vMhhXCMWDe\r\n", "output": "NIE\r\n"}, {"input": "iIcamjTRFH\r\n", "output": "NIE\r\n"}, {"input": "WvoWvvWovW\r\n", "output": "TAK\r\n"}, {"input": "WXxAdbAxXW\r\n", "output": "TAK\r\n"}, {"input": "vqMTUUTMpv\r\n", "output": "TAK\r\n"}, {"input": "iii\r\n", "output": "NIE\r\n"}, {"input": "AAWW\r\n", "output": "NIE\r\n"}, {"input": "ss\r\n", "output": "NIE\r\n"}, {"input": "i\r\n", "output": "NIE\r\n"}, {"input": "ii\r\n", "output": "NIE\r\n"}, {"input": "mm\r\n", "output": "NIE\r\n"}, {"input": "LJ\r\n", "output": "NIE\r\n"}, {"input": "m\r\n", "output": "NIE\r\n"}, {"input": "ioi\r\n", "output": "NIE\r\n"}, {"input": "OA\r\n", "output": "NIE\r\n"}, {"input": "aaaiaaa\r\n", "output": "NIE\r\n"}, {"input": "SS\r\n", "output": "NIE\r\n"}, {"input": "iiii\r\n", "output": "NIE\r\n"}, {"input": "ssops\r\n", "output": "NIE\r\n"}, {"input": "ssss\r\n", "output": "NIE\r\n"}, {"input": "ll\r\n", "output": "NIE\r\n"}, {"input": "s\r\n", "output": "NIE\r\n"}, {"input": "bb\r\n", "output": "NIE\r\n"}, {"input": "uu\r\n", "output": "NIE\r\n"}, {"input": "ZoZ\r\n", "output": "NIE\r\n"}, {"input": "mom\r\n", "output": "NIE\r\n"}, {"input": "uou\r\n", "output": "NIE\r\n"}, {"input": "u\r\n", "output": "NIE\r\n"}, {"input": "JL\r\n", "output": "NIE\r\n"}, {"input": "mOm\r\n", "output": "NIE\r\n"}, {"input": "llll\r\n", "output": "NIE\r\n"}, {"input": "ouo\r\n", "output": "NIE\r\n"}, {"input": "aa\r\n", "output": "NIE\r\n"}, {"input": "olo\r\n", "output": "NIE\r\n"}, {"input": "S\r\n", "output": "NIE\r\n"}, {"input": "lAl\r\n", "output": "NIE\r\n"}, {"input": "nnnn\r\n", "output": "NIE\r\n"}, {"input": "ZzZ\r\n", "output": "NIE\r\n"}, {"input": "bNd\r\n", "output": "NIE\r\n"}, {"input": "ZZ\r\n", "output": "NIE\r\n"}, {"input": "oNoNo\r\n", "output": "NIE\r\n"}, {"input": "l\r\n", "output": "NIE\r\n"}, {"input": "zz\r\n", "output": "NIE\r\n"}, {"input": "NON\r\n", "output": "NIE\r\n"}, {"input": "nn\r\n", "output": "NIE\r\n"}, {"input": "NoN\r\n", "output": "NIE\r\n"}, {"input": "sos\r\n", "output": "NIE\r\n"}, {"input": "lol\r\n", "output": "NIE\r\n"}, {"input": "mmm\r\n", "output": "NIE\r\n"}, {"input": "YAiAY\r\n", "output": "NIE\r\n"}, {"input": "ipIqi\r\n", "output": "NIE\r\n"}, {"input": "AAA\r\n", "output": "TAK\r\n"}, {"input": "uoOou\r\n", "output": "NIE\r\n"}, {"input": "SOS\r\n", "output": "NIE\r\n"}, {"input": "NN\r\n", "output": "NIE\r\n"}, {"input": "n\r\n", "output": "NIE\r\n"}, {"input": "h\r\n", "output": "NIE\r\n"}, {"input": "blld\r\n", "output": "NIE\r\n"}, {"input": "ipOqi\r\n", "output": "NIE\r\n"}, {"input": "pop\r\n", "output": "NIE\r\n"}, {"input": "BB\r\n", "output": "NIE\r\n"}, {"input": "OuO\r\n", "output": "NIE\r\n"}, {"input": "lxl\r\n", "output": "NIE\r\n"}, {"input": "Z\r\n", "output": "NIE\r\n"}, {"input": "vvivv\r\n", "output": "NIE\r\n"}, {"input": "nnnnnnnnnnnnn\r\n", "output": "NIE\r\n"}, {"input": "AA\r\n", "output": "TAK\r\n"}, {"input": "t\r\n", "output": "NIE\r\n"}, {"input": "z\r\n", "output": "NIE\r\n"}, {"input": "mmmAmmm\r\n", "output": "NIE\r\n"}, {"input": "qlililp\r\n", "output": "NIE\r\n"}, {"input": "mpOqm\r\n", "output": "NIE\r\n"}, {"input": "iiiiiiiiii\r\n", "output": "NIE\r\n"}, {"input": "BAAAB\r\n", "output": "NIE\r\n"}, {"input": "UA\r\n", "output": "NIE\r\n"}, {"input": "mmmmmmm\r\n", "output": "NIE\r\n"}, {"input": "NpOqN\r\n", "output": "NIE\r\n"}, {"input": "uOu\r\n", "output": "NIE\r\n"}, {"input": "uuu\r\n", "output": "NIE\r\n"}, {"input": "NAMAN\r\n", "output": "NIE\r\n"}, {"input": "lllll\r\n", "output": "NIE\r\n"}, {"input": "T\r\n", "output": "TAK\r\n"}, {"input": "mmmmmmmmmmmmmmmm\r\n", "output": "NIE\r\n"}, {"input": "AiiA\r\n", "output": "NIE\r\n"}, {"input": "iOi\r\n", "output": "NIE\r\n"}, {"input": "lll\r\n", "output": "NIE\r\n"}, {"input": "N\r\n", "output": "NIE\r\n"}, {"input": "viv\r\n", "output": "NIE\r\n"}, {"input": "oiio\r\n", "output": "NIE\r\n"}, {"input": "AiiiA\r\n", "output": "NIE\r\n"}, {"input": "NNNN\r\n", "output": "NIE\r\n"}, {"input": "ixi\r\n", "output": "NIE\r\n"}, {"input": "AuuA\r\n", "output": "NIE\r\n"}, {"input": "AAAANANAAAA\r\n", "output": "NIE\r\n"}, {"input": "mmmmm\r\n", "output": "NIE\r\n"}, {"input": "oYo\r\n", "output": "TAK\r\n"}, {"input": "dd\r\n", "output": "NIE\r\n"}, {"input": "A\r\n", "output": "TAK\r\n"}, {"input": "ioh\r\n", "output": "NIE\r\n"}, {"input": "mmmm\r\n", "output": "NIE\r\n"}, {"input": "uuuu\r\n", "output": "NIE\r\n"}, {"input": "puq\r\n", "output": "NIE\r\n"}, {"input": "rrrrrr\r\n", "output": "NIE\r\n"}, {"input": "c\r\n", "output": "NIE\r\n"}, {"input": "AbpA\r\n", "output": "NIE\r\n"}, {"input": "qAq\r\n", "output": "NIE\r\n"}, {"input": "tt\r\n", "output": "NIE\r\n"}, {"input": "mnmnm\r\n", "output": "NIE\r\n"}, {"input": "sss\r\n", "output": "NIE\r\n"}, {"input": "yy\r\n", "output": "NIE\r\n"}, {"input": "bob\r\n", "output": "NIE\r\n"}, {"input": "NAN\r\n", "output": "NIE\r\n"}, {"input": "mAm\r\n", "output": "NIE\r\n"}, {"input": "tAt\r\n", "output": "NIE\r\n"}, {"input": "yAy\r\n", "output": "NIE\r\n"}, {"input": "zAz\r\n", "output": "NIE\r\n"}, {"input": "aZ\r\n", "output": "NIE\r\n"}, {"input": "hh\r\n", "output": "NIE\r\n"}, {"input": "bbbb\r\n", "output": "NIE\r\n"}, {"input": "ZAZ\r\n", "output": "NIE\r\n"}, {"input": "Y\r\n", "output": "TAK\r\n"}, {"input": "AAMM\r\n", "output": "NIE\r\n"}, {"input": "lml\r\n", "output": "NIE\r\n"}, {"input": "AZA\r\n", "output": "NIE\r\n"}, {"input": "mXm\r\n", "output": "NIE\r\n"}, {"input": "bd\r\n", "output": "TAK\r\n"}, {"input": "H\r\n", "output": "TAK\r\n"}, {"input": "uvu\r\n", "output": "NIE\r\n"}, {"input": "dxxd\r\n", "output": "NIE\r\n"}, {"input": "dp\r\n", "output": "NIE\r\n"}, {"input": "vV\r\n", "output": "NIE\r\n"}, {"input": "vMo\r\n", "output": "NIE\r\n"}, {"input": "O\r\n", "output": "TAK\r\n"}, {"input": "vYv\r\n", "output": "TAK\r\n"}, {"input": "fv\r\n", "output": "NIE\r\n"}, {"input": "U\r\n", "output": "TAK\r\n"}, {"input": "iAi\r\n", "output": "NIE\r\n"}, {"input": "I\r\n", "output": "TAK\r\n"}, {"input": "VxrV\r\n", "output": "NIE\r\n"}, {"input": "POP\r\n", "output": "NIE\r\n"}, {"input": "bid\r\n", "output": "NIE\r\n"}, {"input": "bmd\r\n", "output": "NIE\r\n"}, {"input": "AiA\r\n", "output": "NIE\r\n"}, {"input": "mmmmmm\r\n", "output": "NIE\r\n"}, {"input": "XHX\r\n", "output": "TAK\r\n"}, {"input": "llllll\r\n", "output": "NIE\r\n"}, {"input": "aAa\r\n", "output": "NIE\r\n"}, {"input": "Db\r\n", "output": "NIE\r\n"}, {"input": "lOl\r\n", "output": "NIE\r\n"}, {"input": "bzd\r\n", "output": "NIE\r\n"}]
| false |
stdio
| null | true |
797/C
|
797
|
C
|
PyPy 3
|
TESTS
| 20 | 140 | 29,900,800 |
123806207
|
import sys
import heapq
def get_string(): return sys.stdin.readline().strip()
# Output for list
# sys.stdout.write(" ".join(map(str, final)) + "\n")
# Output for int or str
# sys.stdout.write(str(best) + "\n")
def solve(s):
length = len(s)
current = 97
final = []
start = 0
end = length - 1
extra = []
while start <= end and current <= 122:
ele = chr(current)
temp = end
flag = 0
# extra.reverse()
while extra:
if extra[-1] == ele:
final.append(ele)
extra.pop()
else:
break
# extra.reverse()
while temp >= start:
if s[temp] == ele:
flag = 1
break
else:
temp -= 1
if flag == 1:
for i in range(start, temp+1):
if s[i] == ele:
final.append(ele)
else:
extra.append(s[i])
start = temp + 1
end = length - 1
current += 1
extra.reverse()
final.extend(extra)
sys.stdout.write("".join(map(str, final)) + "\n")
return
s = get_string()
solve(s)
| 189 | 93 | 14,540,800 |
175279224
|
from collections import defaultdict
from collections import Counter
def parse():
return(int(input()))
def parse2():
return(list(map(int,input().split())))
def parsestr():
return input()
def solve():
s = parsestr()
n = len(s)
best = [0]*(n+1)
best[-1] = 'z'
for i in range(n-1,-1,-1):
best[i] = min(best[i+1], s[i])
ans = []
stack = []
cur = 0
while (stack or cur < n):
if stack and stack[-1] <= best[cur]:
ans.append(stack.pop())
else:
stack.append(s[cur])
cur += 1
print(''.join(ans))
if __name__ == '__main__':
solve()
|
Educational Codeforces Round 19
|
ICPC
| 2,017 | 1 | 256 |
Minimal string
|
Petya recieved a gift of a string s with length up to 105 characters for his birthday. He took two more empty strings t and u and decided to play a game. This game has two possible moves:
- Extract the first character of s and append t with this character.
- Extract the last character of t and append u with this character.
Petya wants to get strings s and t empty and string u lexicographically minimal.
You should write a program that will help Petya win the game.
|
First line contains non-empty string s (1 ≤ |s| ≤ 105), consisting of lowercase English letters.
|
Print resulting string u.
| null | null |
[{"input": "cab", "output": "abc"}, {"input": "acdb", "output": "abdc"}]
| 1,700 |
["data structures", "greedy", "strings"]
| 189 |
[{"input": "cab\r\n", "output": "abc\r\n"}, {"input": "acdb\r\n", "output": "abdc\r\n"}, {"input": "a\r\n", "output": "a\r\n"}, {"input": "ab\r\n", "output": "ab\r\n"}, {"input": "ba\r\n", "output": "ab\r\n"}, {"input": "dijee\r\n", "output": "deeji\r\n"}, {"input": "bhrmc\r\n", "output": "bcmrh\r\n"}, {"input": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\r\n", "output": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\r\n"}, {"input": "bababaaababaabbbbbabbbbbbaaabbabaaaaabbbbbaaaabbbbabaabaabababbbabbabbabaaababbabbababaaaaabaaaabbba\r\n", "output": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\r\n"}, {"input": "bccbbcccbccbacacbaccaababcbaababaaaaabcaaabcaacbabcaababaabaccacacccbacbcacbbbaacaaccccabbbbacbcbbba\r\n", "output": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbcbcbbbbcccccbbbccbcbccccccbbbcbbccbcbbbbcbbccbccbccbcccbbccb\r\n"}, {"input": "eejahjfbbcdhbieiigaihidhageiechaadieecaaehcehjbddgcjgagdfgffdaaihbecebdjhjagghecdhbhdfbedhfhfafbjajg\r\n", "output": "aaaaaaaaaaaaagjjbffhfhdebfdhbhdcehggjhjdbecebhidffgfdggjcgddbjhecheceeidhceieghdihigiieibhdcbbfjhjee\r\n"}, {"input": "bnrdfnybkzepmluyrhofwnwvfmkdwolvyzrqhuhztvlwjldqmoyxzytpfmrgouymeupxrvpbesyxixnrfbxnqcwgmgjstknqtwrr\r\n", "output": "bbbbcggjknqrrwttsmwqnxfrnxixysepvrxpuemyuogrmfptyzxyomqdljwlvtzhuhqrzyvlowdkmfvwnwfohryulmpezkynfdrn\r\n"}, {"input": "bcaeaae\r\n", "output": "aaaecbe\r\n"}, {"input": "edcadcbcdd\r\n", "output": "abccdcddde\r\n"}, {"input": "a\r\n", "output": "a\r\n"}, {"input": "a\r\n", "output": "a\r\n"}, {"input": "a\r\n", "output": "a\r\n"}, {"input": "b\r\n", "output": "b\r\n"}, {"input": "b\r\n", "output": "b\r\n"}, {"input": "a\r\n", "output": "a\r\n"}, {"input": "c\r\n", "output": "c\r\n"}, {"input": "a\r\n", "output": "a\r\n"}, {"input": "b\r\n", "output": "b\r\n"}, {"input": "c\r\n", "output": "c\r\n"}, {"input": "b\r\n", "output": "b\r\n"}, {"input": "a\r\n", "output": "a\r\n"}, {"input": "e\r\n", "output": "e\r\n"}, {"input": "b\r\n", "output": "b\r\n"}, {"input": "b\r\n", "output": "b\r\n"}, {"input": "aa\r\n", "output": "aa\r\n"}, {"input": "aa\r\n", "output": "aa\r\n"}, {"input": "aa\r\n", "output": "aa\r\n"}, {"input": "aa\r\n", "output": "aa\r\n"}, {"input": "bb\r\n", "output": "bb\r\n"}, {"input": "bb\r\n", "output": "bb\r\n"}, {"input": "ba\r\n", "output": "ab\r\n"}, {"input": "ca\r\n", "output": "ac\r\n"}, {"input": "ab\r\n", "output": "ab\r\n"}, {"input": "cb\r\n", "output": "bc\r\n"}, {"input": "bb\r\n", "output": "bb\r\n"}, {"input": "aa\r\n", "output": "aa\r\n"}, {"input": "da\r\n", "output": "ad\r\n"}, {"input": "ab\r\n", "output": "ab\r\n"}, {"input": "cd\r\n", "output": "cd\r\n"}, {"input": "aaa\r\n", "output": "aaa\r\n"}, {"input": "aaa\r\n", "output": "aaa\r\n"}, {"input": "aaa\r\n", "output": "aaa\r\n"}, {"input": "aab\r\n", "output": "aab\r\n"}, {"input": "aaa\r\n", "output": "aaa\r\n"}, {"input": "baa\r\n", "output": "aab\r\n"}, {"input": "bab\r\n", "output": "abb\r\n"}, {"input": "baa\r\n", "output": "aab\r\n"}, {"input": "ccc\r\n", "output": "ccc\r\n"}, {"input": "ddd\r\n", "output": "ddd\r\n"}, {"input": "ccd\r\n", "output": "ccd\r\n"}, {"input": "bca\r\n", "output": "acb\r\n"}, {"input": "cde\r\n", "output": "cde\r\n"}, {"input": "ece\r\n", "output": "cee\r\n"}, {"input": "bdd\r\n", "output": "bdd\r\n"}, {"input": "aaaa\r\n", "output": "aaaa\r\n"}, {"input": "aaaa\r\n", "output": "aaaa\r\n"}, {"input": "aaaa\r\n", "output": "aaaa\r\n"}, {"input": "abaa\r\n", "output": "aaab\r\n"}, {"input": "abab\r\n", "output": "aabb\r\n"}, {"input": "bbbb\r\n", "output": "bbbb\r\n"}, {"input": "bbba\r\n", "output": "abbb\r\n"}, {"input": "caba\r\n", "output": "aabc\r\n"}, {"input": "ccbb\r\n", "output": "bbcc\r\n"}, {"input": "abac\r\n", "output": "aabc\r\n"}, {"input": "daba\r\n", "output": "aabd\r\n"}, {"input": "cdbb\r\n", "output": "bbdc\r\n"}, {"input": "bddd\r\n", "output": "bddd\r\n"}, {"input": "dacb\r\n", "output": "abcd\r\n"}, {"input": "abcc\r\n", "output": "abcc\r\n"}, {"input": "aaaaa\r\n", "output": "aaaaa\r\n"}, {"input": "aaaaa\r\n", "output": "aaaaa\r\n"}, {"input": "aaaaa\r\n", "output": "aaaaa\r\n"}, {"input": "baaab\r\n", "output": "aaabb\r\n"}, {"input": "aabbb\r\n", "output": "aabbb\r\n"}, {"input": "aabaa\r\n", "output": "aaaab\r\n"}, {"input": "abcba\r\n", "output": "aabcb\r\n"}, {"input": "bacbc\r\n", "output": "abbcc\r\n"}, {"input": "bacba\r\n", "output": "aabcb\r\n"}, {"input": "bdbda\r\n", "output": "adbdb\r\n"}, {"input": "accbb\r\n", "output": "abbcc\r\n"}, {"input": "dbccc\r\n", "output": "bcccd\r\n"}, {"input": "decca\r\n", "output": "acced\r\n"}, {"input": "dbbdd\r\n", "output": "bbddd\r\n"}, {"input": "accec\r\n", "output": "accce\r\n"}, {"input": "aaaaaa\r\n", "output": "aaaaaa\r\n"}, {"input": "aaaaaa\r\n", "output": "aaaaaa\r\n"}, {"input": "aaaaaa\r\n", "output": "aaaaaa\r\n"}, {"input": "bbbbab\r\n", "output": "abbbbb\r\n"}, {"input": "bbbbab\r\n", "output": "abbbbb\r\n"}, {"input": "aaaaba\r\n", "output": "aaaaab\r\n"}, {"input": "cbbbcc\r\n", "output": "bbbccc\r\n"}, {"input": "aaacac\r\n", "output": "aaaacc\r\n"}, {"input": "bacbbc\r\n", "output": "abbbcc\r\n"}, {"input": "cacacc\r\n", "output": "aacccc\r\n"}, {"input": "badbdc\r\n", "output": "abbcdd\r\n"}, {"input": "ddadad\r\n", "output": "aadddd\r\n"}, {"input": "ccdece\r\n", "output": "cccede\r\n"}, {"input": "eecade\r\n", "output": "acdeee\r\n"}, {"input": "eabdcb\r\n", "output": "abbcde\r\n"}, {"input": "aaaaaaa\r\n", "output": "aaaaaaa\r\n"}, {"input": "aaaaaaa\r\n", "output": "aaaaaaa\r\n"}, {"input": "aaaaaaa\r\n", "output": "aaaaaaa\r\n"}, {"input": "aaabbaa\r\n", "output": "aaaaabb\r\n"}, {"input": "baaabab\r\n", "output": "aaaabbb\r\n"}, {"input": "bbababa\r\n", "output": "aaabbbb\r\n"}, {"input": "bcccacc\r\n", "output": "acccbcc\r\n"}, {"input": "cbbcccc\r\n", "output": "bbccccc\r\n"}, {"input": "abacaaa\r\n", "output": "aaaaacb\r\n"}, {"input": "ccdbdac\r\n", "output": "acdbdcc\r\n"}, {"input": "bbacaba\r\n", "output": "aaabcbb\r\n"}, {"input": "abbaccc\r\n", "output": "aabbccc\r\n"}, {"input": "bdcbcab\r\n", "output": "abcbcdb\r\n"}, {"input": "dabcbce\r\n", "output": "abbccde\r\n"}, {"input": "abaaabe\r\n", "output": "aaaabbe\r\n"}, {"input": "aaaaaaaa\r\n", "output": "aaaaaaaa\r\n"}, {"input": "aaaaaaaa\r\n", "output": "aaaaaaaa\r\n"}, {"input": "aaaaaaaa\r\n", "output": "aaaaaaaa\r\n"}, {"input": "ababbbba\r\n", "output": "aaabbbbb\r\n"}, {"input": "aaaaaaba\r\n", "output": "aaaaaaab\r\n"}, {"input": "babbbaab\r\n", "output": "aaabbbbb\r\n"}, {"input": "bcaccaab\r\n", "output": "aaabcccb\r\n"}, {"input": "bbccaabc\r\n", "output": "aabccbbc\r\n"}, {"input": "cacaaaac\r\n", "output": "aaaaaccc\r\n"}, {"input": "daacbddc\r\n", "output": "aabccddd\r\n"}, {"input": "cdbdcdaa\r\n", "output": "aadcdbdc\r\n"}, {"input": "bccbdacd\r\n", "output": "acdbccbd\r\n"}, {"input": "abbeaade\r\n", "output": "aaadebbe\r\n"}, {"input": "ccabecba\r\n", "output": "aabcebcc\r\n"}, {"input": "ececaead\r\n", "output": "aadecece\r\n"}, {"input": "aaaaaaaaa\r\n", "output": "aaaaaaaaa\r\n"}, {"input": "aaaaaaaaa\r\n", "output": "aaaaaaaaa\r\n"}, {"input": "aaaaaaaaa\r\n", "output": "aaaaaaaaa\r\n"}, {"input": "aabaaabbb\r\n", "output": "aaaaabbbb\r\n"}, {"input": "abbbbbaab\r\n", "output": "aaabbbbbb\r\n"}, {"input": "bbbaababb\r\n", "output": "aaabbbbbb\r\n"}, {"input": "babcaaccb\r\n", "output": "aaabcccbb\r\n"}, {"input": "ccbcabaac\r\n", "output": "aaabcbccc\r\n"}, {"input": "caaaccccb\r\n", "output": "aaabccccc\r\n"}, {"input": "abbcdbddb\r\n", "output": "abbbbdddc\r\n"}, {"input": "dbcaacbbb\r\n", "output": "aabbbccbd\r\n"}, {"input": "cadcbddac\r\n", "output": "aacddbcdc\r\n"}, {"input": "ecebadadb\r\n", "output": "aabddbece\r\n"}, {"input": "bdbeeccdd\r\n", "output": "bbccddeed\r\n"}, {"input": "daaedecda\r\n", "output": "aaadceded\r\n"}, {"input": "aaaaaaaaaa\r\n", "output": "aaaaaaaaaa\r\n"}, {"input": "aaaaaaaaaa\r\n", "output": "aaaaaaaaaa\r\n"}, {"input": "aaaaaaaaaa\r\n", "output": "aaaaaaaaaa\r\n"}, {"input": "abaaaaabbb\r\n", "output": "aaaaaabbbb\r\n"}, {"input": "bbaaaabaaa\r\n", "output": "aaaaaaabbb\r\n"}, {"input": "bbabbaaaaa\r\n", "output": "aaaaaabbbb\r\n"}, {"input": "cbaabcaacc\r\n", "output": "aaaacbbccc\r\n"}, {"input": "aaaaccccab\r\n", "output": "aaaaabcccc\r\n"}, {"input": "bccaccaacc\r\n", "output": "aaaccccbcc\r\n"}, {"input": "dbdccdcacd\r\n", "output": "accdccdbdd\r\n"}, {"input": "caaddaaccb\r\n", "output": "aaaabccddc\r\n"}, {"input": "adbbabcbdc\r\n", "output": "aabbbbccdd\r\n"}, {"input": "cdeabdbbad\r\n", "output": "aabbdbdedc\r\n"}, {"input": "eeddcbeeec\r\n", "output": "bcceeeddee\r\n"}, {"input": "bbcebddeba\r\n", "output": "abeddbecbb\r\n"}]
| false |
stdio
| null | true |
797/C
|
797
|
C
|
Python 3
|
TESTS
| 20 | 639 | 921,600 |
136697802
|
s = list(input())
#s = ['a']*100000
u = []
index = 0
while(len(s)!= 0):
for j in range(index, len(s)):
if(len(u) != 0 and s[j] == u[len(u)-1]):
index = j
break
if(s[j] < s[index]):
index = j
u.append(s.pop(index))
index = max(0, index-1)
print(''.join(u))
| 189 | 108 | 14,131,200 |
220321279
|
stack = input()
n = len(stack)
aux = [0] * n
aux[-1] = stack[-1]
for i in range(n - 2, -1, -1):
aux[i] = min(aux[i + 1], stack[i])
second_stack = []
result_stack = []
for i in range(n):
if not second_stack:
second_stack.append(stack[i])
else:
while second_stack:
if second_stack[-1] <= aux[i]:
result_stack.append(second_stack.pop())
else:
break
second_stack.append(stack[i])
while second_stack:
result_stack.append(second_stack.pop())
print(''.join(result_stack))
|
Educational Codeforces Round 19
|
ICPC
| 2,017 | 1 | 256 |
Minimal string
|
Petya recieved a gift of a string s with length up to 105 characters for his birthday. He took two more empty strings t and u and decided to play a game. This game has two possible moves:
- Extract the first character of s and append t with this character.
- Extract the last character of t and append u with this character.
Petya wants to get strings s and t empty and string u lexicographically minimal.
You should write a program that will help Petya win the game.
|
First line contains non-empty string s (1 ≤ |s| ≤ 105), consisting of lowercase English letters.
|
Print resulting string u.
| null | null |
[{"input": "cab", "output": "abc"}, {"input": "acdb", "output": "abdc"}]
| 1,700 |
["data structures", "greedy", "strings"]
| 189 |
[{"input": "cab\r\n", "output": "abc\r\n"}, {"input": "acdb\r\n", "output": "abdc\r\n"}, {"input": "a\r\n", "output": "a\r\n"}, {"input": "ab\r\n", "output": "ab\r\n"}, {"input": "ba\r\n", "output": "ab\r\n"}, {"input": "dijee\r\n", "output": "deeji\r\n"}, {"input": "bhrmc\r\n", "output": "bcmrh\r\n"}, {"input": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\r\n", "output": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\r\n"}, {"input": "bababaaababaabbbbbabbbbbbaaabbabaaaaabbbbbaaaabbbbabaabaabababbbabbabbabaaababbabbababaaaaabaaaabbba\r\n", "output": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\r\n"}, {"input": "bccbbcccbccbacacbaccaababcbaababaaaaabcaaabcaacbabcaababaabaccacacccbacbcacbbbaacaaccccabbbbacbcbbba\r\n", "output": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbcbcbbbbcccccbbbccbcbccccccbbbcbbccbcbbbbcbbccbccbccbcccbbccb\r\n"}, {"input": "eejahjfbbcdhbieiigaihidhageiechaadieecaaehcehjbddgcjgagdfgffdaaihbecebdjhjagghecdhbhdfbedhfhfafbjajg\r\n", "output": "aaaaaaaaaaaaagjjbffhfhdebfdhbhdcehggjhjdbecebhidffgfdggjcgddbjhecheceeidhceieghdihigiieibhdcbbfjhjee\r\n"}, {"input": "bnrdfnybkzepmluyrhofwnwvfmkdwolvyzrqhuhztvlwjldqmoyxzytpfmrgouymeupxrvpbesyxixnrfbxnqcwgmgjstknqtwrr\r\n", "output": "bbbbcggjknqrrwttsmwqnxfrnxixysepvrxpuemyuogrmfptyzxyomqdljwlvtzhuhqrzyvlowdkmfvwnwfohryulmpezkynfdrn\r\n"}, {"input": "bcaeaae\r\n", "output": "aaaecbe\r\n"}, {"input": "edcadcbcdd\r\n", "output": "abccdcddde\r\n"}, {"input": "a\r\n", "output": "a\r\n"}, {"input": "a\r\n", "output": "a\r\n"}, {"input": "a\r\n", "output": "a\r\n"}, {"input": "b\r\n", "output": "b\r\n"}, {"input": "b\r\n", "output": "b\r\n"}, {"input": "a\r\n", "output": "a\r\n"}, {"input": "c\r\n", "output": "c\r\n"}, {"input": "a\r\n", "output": "a\r\n"}, {"input": "b\r\n", "output": "b\r\n"}, {"input": "c\r\n", "output": "c\r\n"}, {"input": "b\r\n", "output": "b\r\n"}, {"input": "a\r\n", "output": "a\r\n"}, {"input": "e\r\n", "output": "e\r\n"}, {"input": "b\r\n", "output": "b\r\n"}, {"input": "b\r\n", "output": "b\r\n"}, {"input": "aa\r\n", "output": "aa\r\n"}, {"input": "aa\r\n", "output": "aa\r\n"}, {"input": "aa\r\n", "output": "aa\r\n"}, {"input": "aa\r\n", "output": "aa\r\n"}, {"input": "bb\r\n", "output": "bb\r\n"}, {"input": "bb\r\n", "output": "bb\r\n"}, {"input": "ba\r\n", "output": "ab\r\n"}, {"input": "ca\r\n", "output": "ac\r\n"}, {"input": "ab\r\n", "output": "ab\r\n"}, {"input": "cb\r\n", "output": "bc\r\n"}, {"input": "bb\r\n", "output": "bb\r\n"}, {"input": "aa\r\n", "output": "aa\r\n"}, {"input": "da\r\n", "output": "ad\r\n"}, {"input": "ab\r\n", "output": "ab\r\n"}, {"input": "cd\r\n", "output": "cd\r\n"}, {"input": "aaa\r\n", "output": "aaa\r\n"}, {"input": "aaa\r\n", "output": "aaa\r\n"}, {"input": "aaa\r\n", "output": "aaa\r\n"}, {"input": "aab\r\n", "output": "aab\r\n"}, {"input": "aaa\r\n", "output": "aaa\r\n"}, {"input": "baa\r\n", "output": "aab\r\n"}, {"input": "bab\r\n", "output": "abb\r\n"}, {"input": "baa\r\n", "output": "aab\r\n"}, {"input": "ccc\r\n", "output": "ccc\r\n"}, {"input": "ddd\r\n", "output": "ddd\r\n"}, {"input": "ccd\r\n", "output": "ccd\r\n"}, {"input": "bca\r\n", "output": "acb\r\n"}, {"input": "cde\r\n", "output": "cde\r\n"}, {"input": "ece\r\n", "output": "cee\r\n"}, {"input": "bdd\r\n", "output": "bdd\r\n"}, {"input": "aaaa\r\n", "output": "aaaa\r\n"}, {"input": "aaaa\r\n", "output": "aaaa\r\n"}, {"input": "aaaa\r\n", "output": "aaaa\r\n"}, {"input": "abaa\r\n", "output": "aaab\r\n"}, {"input": "abab\r\n", "output": "aabb\r\n"}, {"input": "bbbb\r\n", "output": "bbbb\r\n"}, {"input": "bbba\r\n", "output": "abbb\r\n"}, {"input": "caba\r\n", "output": "aabc\r\n"}, {"input": "ccbb\r\n", "output": "bbcc\r\n"}, {"input": "abac\r\n", "output": "aabc\r\n"}, {"input": "daba\r\n", "output": "aabd\r\n"}, {"input": "cdbb\r\n", "output": "bbdc\r\n"}, {"input": "bddd\r\n", "output": "bddd\r\n"}, {"input": "dacb\r\n", "output": "abcd\r\n"}, {"input": "abcc\r\n", "output": "abcc\r\n"}, {"input": "aaaaa\r\n", "output": "aaaaa\r\n"}, {"input": "aaaaa\r\n", "output": "aaaaa\r\n"}, {"input": "aaaaa\r\n", "output": "aaaaa\r\n"}, {"input": "baaab\r\n", "output": "aaabb\r\n"}, {"input": "aabbb\r\n", "output": "aabbb\r\n"}, {"input": "aabaa\r\n", "output": "aaaab\r\n"}, {"input": "abcba\r\n", "output": "aabcb\r\n"}, {"input": "bacbc\r\n", "output": "abbcc\r\n"}, {"input": "bacba\r\n", "output": "aabcb\r\n"}, {"input": "bdbda\r\n", "output": "adbdb\r\n"}, {"input": "accbb\r\n", "output": "abbcc\r\n"}, {"input": "dbccc\r\n", "output": "bcccd\r\n"}, {"input": "decca\r\n", "output": "acced\r\n"}, {"input": "dbbdd\r\n", "output": "bbddd\r\n"}, {"input": "accec\r\n", "output": "accce\r\n"}, {"input": "aaaaaa\r\n", "output": "aaaaaa\r\n"}, {"input": "aaaaaa\r\n", "output": "aaaaaa\r\n"}, {"input": "aaaaaa\r\n", "output": "aaaaaa\r\n"}, {"input": "bbbbab\r\n", "output": "abbbbb\r\n"}, {"input": "bbbbab\r\n", "output": "abbbbb\r\n"}, {"input": "aaaaba\r\n", "output": "aaaaab\r\n"}, {"input": "cbbbcc\r\n", "output": "bbbccc\r\n"}, {"input": "aaacac\r\n", "output": "aaaacc\r\n"}, {"input": "bacbbc\r\n", "output": "abbbcc\r\n"}, {"input": "cacacc\r\n", "output": "aacccc\r\n"}, {"input": "badbdc\r\n", "output": "abbcdd\r\n"}, {"input": "ddadad\r\n", "output": "aadddd\r\n"}, {"input": "ccdece\r\n", "output": "cccede\r\n"}, {"input": "eecade\r\n", "output": "acdeee\r\n"}, {"input": "eabdcb\r\n", "output": "abbcde\r\n"}, {"input": "aaaaaaa\r\n", "output": "aaaaaaa\r\n"}, {"input": "aaaaaaa\r\n", "output": "aaaaaaa\r\n"}, {"input": "aaaaaaa\r\n", "output": "aaaaaaa\r\n"}, {"input": "aaabbaa\r\n", "output": "aaaaabb\r\n"}, {"input": "baaabab\r\n", "output": "aaaabbb\r\n"}, {"input": "bbababa\r\n", "output": "aaabbbb\r\n"}, {"input": "bcccacc\r\n", "output": "acccbcc\r\n"}, {"input": "cbbcccc\r\n", "output": "bbccccc\r\n"}, {"input": "abacaaa\r\n", "output": "aaaaacb\r\n"}, {"input": "ccdbdac\r\n", "output": "acdbdcc\r\n"}, {"input": "bbacaba\r\n", "output": "aaabcbb\r\n"}, {"input": "abbaccc\r\n", "output": "aabbccc\r\n"}, {"input": "bdcbcab\r\n", "output": "abcbcdb\r\n"}, {"input": "dabcbce\r\n", "output": "abbccde\r\n"}, {"input": "abaaabe\r\n", "output": "aaaabbe\r\n"}, {"input": "aaaaaaaa\r\n", "output": "aaaaaaaa\r\n"}, {"input": "aaaaaaaa\r\n", "output": "aaaaaaaa\r\n"}, {"input": "aaaaaaaa\r\n", "output": "aaaaaaaa\r\n"}, {"input": "ababbbba\r\n", "output": "aaabbbbb\r\n"}, {"input": "aaaaaaba\r\n", "output": "aaaaaaab\r\n"}, {"input": "babbbaab\r\n", "output": "aaabbbbb\r\n"}, {"input": "bcaccaab\r\n", "output": "aaabcccb\r\n"}, {"input": "bbccaabc\r\n", "output": "aabccbbc\r\n"}, {"input": "cacaaaac\r\n", "output": "aaaaaccc\r\n"}, {"input": "daacbddc\r\n", "output": "aabccddd\r\n"}, {"input": "cdbdcdaa\r\n", "output": "aadcdbdc\r\n"}, {"input": "bccbdacd\r\n", "output": "acdbccbd\r\n"}, {"input": "abbeaade\r\n", "output": "aaadebbe\r\n"}, {"input": "ccabecba\r\n", "output": "aabcebcc\r\n"}, {"input": "ececaead\r\n", "output": "aadecece\r\n"}, {"input": "aaaaaaaaa\r\n", "output": "aaaaaaaaa\r\n"}, {"input": "aaaaaaaaa\r\n", "output": "aaaaaaaaa\r\n"}, {"input": "aaaaaaaaa\r\n", "output": "aaaaaaaaa\r\n"}, {"input": "aabaaabbb\r\n", "output": "aaaaabbbb\r\n"}, {"input": "abbbbbaab\r\n", "output": "aaabbbbbb\r\n"}, {"input": "bbbaababb\r\n", "output": "aaabbbbbb\r\n"}, {"input": "babcaaccb\r\n", "output": "aaabcccbb\r\n"}, {"input": "ccbcabaac\r\n", "output": "aaabcbccc\r\n"}, {"input": "caaaccccb\r\n", "output": "aaabccccc\r\n"}, {"input": "abbcdbddb\r\n", "output": "abbbbdddc\r\n"}, {"input": "dbcaacbbb\r\n", "output": "aabbbccbd\r\n"}, {"input": "cadcbddac\r\n", "output": "aacddbcdc\r\n"}, {"input": "ecebadadb\r\n", "output": "aabddbece\r\n"}, {"input": "bdbeeccdd\r\n", "output": "bbccddeed\r\n"}, {"input": "daaedecda\r\n", "output": "aaadceded\r\n"}, {"input": "aaaaaaaaaa\r\n", "output": "aaaaaaaaaa\r\n"}, {"input": "aaaaaaaaaa\r\n", "output": "aaaaaaaaaa\r\n"}, {"input": "aaaaaaaaaa\r\n", "output": "aaaaaaaaaa\r\n"}, {"input": "abaaaaabbb\r\n", "output": "aaaaaabbbb\r\n"}, {"input": "bbaaaabaaa\r\n", "output": "aaaaaaabbb\r\n"}, {"input": "bbabbaaaaa\r\n", "output": "aaaaaabbbb\r\n"}, {"input": "cbaabcaacc\r\n", "output": "aaaacbbccc\r\n"}, {"input": "aaaaccccab\r\n", "output": "aaaaabcccc\r\n"}, {"input": "bccaccaacc\r\n", "output": "aaaccccbcc\r\n"}, {"input": "dbdccdcacd\r\n", "output": "accdccdbdd\r\n"}, {"input": "caaddaaccb\r\n", "output": "aaaabccddc\r\n"}, {"input": "adbbabcbdc\r\n", "output": "aabbbbccdd\r\n"}, {"input": "cdeabdbbad\r\n", "output": "aabbdbdedc\r\n"}, {"input": "eeddcbeeec\r\n", "output": "bcceeeddee\r\n"}, {"input": "bbcebddeba\r\n", "output": "abeddbecbb\r\n"}]
| false |
stdio
| null | true |
691/B
|
691
|
B
|
Python 3
|
TESTS
| 24 | 62 | 4,505,600 |
134395076
|
s = input()
f = 1
if len(s) % 2 == 1:
k = len(s) // 2
if s[k] != 'H' and s[k] != 'A' and s[k] != 'I' and s[k] != 'M' and s[k] != 'O' and s[k] != 'o' \
and s[k] != 'T' and s[k] != 'V' and s[k] != 'v' and s[k] != 'W' and s[k] != 'w' \
and s[k] != 'X' and s[k] != 'x' and s[k] != 'Y' and s[k] != 'U':
print("NIE")
f = 0
if f:
ff = 1
for k in range(len(s)):
if s[k] != 'H' and s[k] != 'A' and s[k] != 'I' and s[k] != 'M' and s[k] != 'O' and s[k] != 'o' \
and s[k] != 'T' and s[k] != 'V' and s[k] != 'v' and s[k] != 'W' and s[k] != 'w' \
and s[k] != 'X' and s[k] != 'x' and s[k] != 'Y' and s[k] != 'U':
if ff == 1:
ff = 0
if s[k] == 'b' and s[len(s) - 1 - k] == 'd':
ff = 1
if s[k] == 'd' and s[len(s) - 1 - k] == 'b':
ff = 1
if s[k] == 'p' and s[len(s) - 1 - k] == 'q':
ff = 1
if s[k] == 'q' and s[len(s) - 1 - k] == 'p':
ff = 1
if ff:
print("TAK")
else:
print("NIE")
| 168 | 62 | 0 |
19080106
|
midsym = 'AHIMOoTUVvWwXxY'
sym = 'pqbd'
s = input()
if len(s) % 2 == 1:
t = len(s) // 2
if s[t] not in midsym:
print('NIE')
exit()
s = s[:t] + s[t+1:]
#print(s)
f = s[:int(len(s)/2)]
l = s[int(len(s)/2):]
l = l[::-1]
for k in range(len(f)):
if f[k] not in midsym and f[k] not in sym:
print('NIE')
exit()
if f[k] in midsym:
if l[k] != f[k]:
print('NIE')
exit()
if f[k] in sym:
if f[k] == 'p' and l[k] == 'q': continue
if f[k] == 'q' and l[k] == 'p': continue
if f[k] == 'b' and l[k] == 'd': continue
if f[k] == 'd' and l[k] == 'b': continue
print('NIE')
exit()
print('TAK')
|
Educational Codeforces Round 14
|
ICPC
| 2,016 | 1 | 256 |
s-palindrome
|
Let's call a string "s-palindrome" if it is symmetric about the middle of the string. For example, the string "oHo" is "s-palindrome", but the string "aa" is not. The string "aa" is not "s-palindrome", because the second half of it is not a mirror reflection of the first half.
English alphabet
You are given a string s. Check if the string is "s-palindrome".
|
The only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.
|
Print "TAK" if the string s is "s-palindrome" and "NIE" otherwise.
| null | null |
[{"input": "oXoxoXo", "output": "TAK"}, {"input": "bod", "output": "TAK"}, {"input": "ER", "output": "NIE"}]
| 1,600 |
["implementation", "strings"]
| 168 |
[{"input": "oXoxoXo\r\n", "output": "TAK\r\n"}, {"input": "bod\r\n", "output": "TAK\r\n"}, {"input": "ER\r\n", "output": "NIE\r\n"}, {"input": "o\r\n", "output": "TAK\r\n"}, {"input": "a\r\n", "output": "NIE\r\n"}, {"input": "opo\r\n", "output": "NIE\r\n"}, {"input": "HCMoxkgbNb\r\n", "output": "NIE\r\n"}, {"input": "vMhhXCMWDe\r\n", "output": "NIE\r\n"}, {"input": "iIcamjTRFH\r\n", "output": "NIE\r\n"}, {"input": "WvoWvvWovW\r\n", "output": "TAK\r\n"}, {"input": "WXxAdbAxXW\r\n", "output": "TAK\r\n"}, {"input": "vqMTUUTMpv\r\n", "output": "TAK\r\n"}, {"input": "iii\r\n", "output": "NIE\r\n"}, {"input": "AAWW\r\n", "output": "NIE\r\n"}, {"input": "ss\r\n", "output": "NIE\r\n"}, {"input": "i\r\n", "output": "NIE\r\n"}, {"input": "ii\r\n", "output": "NIE\r\n"}, {"input": "mm\r\n", "output": "NIE\r\n"}, {"input": "LJ\r\n", "output": "NIE\r\n"}, {"input": "m\r\n", "output": "NIE\r\n"}, {"input": "ioi\r\n", "output": "NIE\r\n"}, {"input": "OA\r\n", "output": "NIE\r\n"}, {"input": "aaaiaaa\r\n", "output": "NIE\r\n"}, {"input": "SS\r\n", "output": "NIE\r\n"}, {"input": "iiii\r\n", "output": "NIE\r\n"}, {"input": "ssops\r\n", "output": "NIE\r\n"}, {"input": "ssss\r\n", "output": "NIE\r\n"}, {"input": "ll\r\n", "output": "NIE\r\n"}, {"input": "s\r\n", "output": "NIE\r\n"}, {"input": "bb\r\n", "output": "NIE\r\n"}, {"input": "uu\r\n", "output": "NIE\r\n"}, {"input": "ZoZ\r\n", "output": "NIE\r\n"}, {"input": "mom\r\n", "output": "NIE\r\n"}, {"input": "uou\r\n", "output": "NIE\r\n"}, {"input": "u\r\n", "output": "NIE\r\n"}, {"input": "JL\r\n", "output": "NIE\r\n"}, {"input": "mOm\r\n", "output": "NIE\r\n"}, {"input": "llll\r\n", "output": "NIE\r\n"}, {"input": "ouo\r\n", "output": "NIE\r\n"}, {"input": "aa\r\n", "output": "NIE\r\n"}, {"input": "olo\r\n", "output": "NIE\r\n"}, {"input": "S\r\n", "output": "NIE\r\n"}, {"input": "lAl\r\n", "output": "NIE\r\n"}, {"input": "nnnn\r\n", "output": "NIE\r\n"}, {"input": "ZzZ\r\n", "output": "NIE\r\n"}, {"input": "bNd\r\n", "output": "NIE\r\n"}, {"input": "ZZ\r\n", "output": "NIE\r\n"}, {"input": "oNoNo\r\n", "output": "NIE\r\n"}, {"input": "l\r\n", "output": "NIE\r\n"}, {"input": "zz\r\n", "output": "NIE\r\n"}, {"input": "NON\r\n", "output": "NIE\r\n"}, {"input": "nn\r\n", "output": "NIE\r\n"}, {"input": "NoN\r\n", "output": "NIE\r\n"}, {"input": "sos\r\n", "output": "NIE\r\n"}, {"input": "lol\r\n", "output": "NIE\r\n"}, {"input": "mmm\r\n", "output": "NIE\r\n"}, {"input": "YAiAY\r\n", "output": "NIE\r\n"}, {"input": "ipIqi\r\n", "output": "NIE\r\n"}, {"input": "AAA\r\n", "output": "TAK\r\n"}, {"input": "uoOou\r\n", "output": "NIE\r\n"}, {"input": "SOS\r\n", "output": "NIE\r\n"}, {"input": "NN\r\n", "output": "NIE\r\n"}, {"input": "n\r\n", "output": "NIE\r\n"}, {"input": "h\r\n", "output": "NIE\r\n"}, {"input": "blld\r\n", "output": "NIE\r\n"}, {"input": "ipOqi\r\n", "output": "NIE\r\n"}, {"input": "pop\r\n", "output": "NIE\r\n"}, {"input": "BB\r\n", "output": "NIE\r\n"}, {"input": "OuO\r\n", "output": "NIE\r\n"}, {"input": "lxl\r\n", "output": "NIE\r\n"}, {"input": "Z\r\n", "output": "NIE\r\n"}, {"input": "vvivv\r\n", "output": "NIE\r\n"}, {"input": "nnnnnnnnnnnnn\r\n", "output": "NIE\r\n"}, {"input": "AA\r\n", "output": "TAK\r\n"}, {"input": "t\r\n", "output": "NIE\r\n"}, {"input": "z\r\n", "output": "NIE\r\n"}, {"input": "mmmAmmm\r\n", "output": "NIE\r\n"}, {"input": "qlililp\r\n", "output": "NIE\r\n"}, {"input": "mpOqm\r\n", "output": "NIE\r\n"}, {"input": "iiiiiiiiii\r\n", "output": "NIE\r\n"}, {"input": "BAAAB\r\n", "output": "NIE\r\n"}, {"input": "UA\r\n", "output": "NIE\r\n"}, {"input": "mmmmmmm\r\n", "output": "NIE\r\n"}, {"input": "NpOqN\r\n", "output": "NIE\r\n"}, {"input": "uOu\r\n", "output": "NIE\r\n"}, {"input": "uuu\r\n", "output": "NIE\r\n"}, {"input": "NAMAN\r\n", "output": "NIE\r\n"}, {"input": "lllll\r\n", "output": "NIE\r\n"}, {"input": "T\r\n", "output": "TAK\r\n"}, {"input": "mmmmmmmmmmmmmmmm\r\n", "output": "NIE\r\n"}, {"input": "AiiA\r\n", "output": "NIE\r\n"}, {"input": "iOi\r\n", "output": "NIE\r\n"}, {"input": "lll\r\n", "output": "NIE\r\n"}, {"input": "N\r\n", "output": "NIE\r\n"}, {"input": "viv\r\n", "output": "NIE\r\n"}, {"input": "oiio\r\n", "output": "NIE\r\n"}, {"input": "AiiiA\r\n", "output": "NIE\r\n"}, {"input": "NNNN\r\n", "output": "NIE\r\n"}, {"input": "ixi\r\n", "output": "NIE\r\n"}, {"input": "AuuA\r\n", "output": "NIE\r\n"}, {"input": "AAAANANAAAA\r\n", "output": "NIE\r\n"}, {"input": "mmmmm\r\n", "output": "NIE\r\n"}, {"input": "oYo\r\n", "output": "TAK\r\n"}, {"input": "dd\r\n", "output": "NIE\r\n"}, {"input": "A\r\n", "output": "TAK\r\n"}, {"input": "ioh\r\n", "output": "NIE\r\n"}, {"input": "mmmm\r\n", "output": "NIE\r\n"}, {"input": "uuuu\r\n", "output": "NIE\r\n"}, {"input": "puq\r\n", "output": "NIE\r\n"}, {"input": "rrrrrr\r\n", "output": "NIE\r\n"}, {"input": "c\r\n", "output": "NIE\r\n"}, {"input": "AbpA\r\n", "output": "NIE\r\n"}, {"input": "qAq\r\n", "output": "NIE\r\n"}, {"input": "tt\r\n", "output": "NIE\r\n"}, {"input": "mnmnm\r\n", "output": "NIE\r\n"}, {"input": "sss\r\n", "output": "NIE\r\n"}, {"input": "yy\r\n", "output": "NIE\r\n"}, {"input": "bob\r\n", "output": "NIE\r\n"}, {"input": "NAN\r\n", "output": "NIE\r\n"}, {"input": "mAm\r\n", "output": "NIE\r\n"}, {"input": "tAt\r\n", "output": "NIE\r\n"}, {"input": "yAy\r\n", "output": "NIE\r\n"}, {"input": "zAz\r\n", "output": "NIE\r\n"}, {"input": "aZ\r\n", "output": "NIE\r\n"}, {"input": "hh\r\n", "output": "NIE\r\n"}, {"input": "bbbb\r\n", "output": "NIE\r\n"}, {"input": "ZAZ\r\n", "output": "NIE\r\n"}, {"input": "Y\r\n", "output": "TAK\r\n"}, {"input": "AAMM\r\n", "output": "NIE\r\n"}, {"input": "lml\r\n", "output": "NIE\r\n"}, {"input": "AZA\r\n", "output": "NIE\r\n"}, {"input": "mXm\r\n", "output": "NIE\r\n"}, {"input": "bd\r\n", "output": "TAK\r\n"}, {"input": "H\r\n", "output": "TAK\r\n"}, {"input": "uvu\r\n", "output": "NIE\r\n"}, {"input": "dxxd\r\n", "output": "NIE\r\n"}, {"input": "dp\r\n", "output": "NIE\r\n"}, {"input": "vV\r\n", "output": "NIE\r\n"}, {"input": "vMo\r\n", "output": "NIE\r\n"}, {"input": "O\r\n", "output": "TAK\r\n"}, {"input": "vYv\r\n", "output": "TAK\r\n"}, {"input": "fv\r\n", "output": "NIE\r\n"}, {"input": "U\r\n", "output": "TAK\r\n"}, {"input": "iAi\r\n", "output": "NIE\r\n"}, {"input": "I\r\n", "output": "TAK\r\n"}, {"input": "VxrV\r\n", "output": "NIE\r\n"}, {"input": "POP\r\n", "output": "NIE\r\n"}, {"input": "bid\r\n", "output": "NIE\r\n"}, {"input": "bmd\r\n", "output": "NIE\r\n"}, {"input": "AiA\r\n", "output": "NIE\r\n"}, {"input": "mmmmmm\r\n", "output": "NIE\r\n"}, {"input": "XHX\r\n", "output": "TAK\r\n"}, {"input": "llllll\r\n", "output": "NIE\r\n"}, {"input": "aAa\r\n", "output": "NIE\r\n"}, {"input": "Db\r\n", "output": "NIE\r\n"}, {"input": "lOl\r\n", "output": "NIE\r\n"}, {"input": "bzd\r\n", "output": "NIE\r\n"}]
| false |
stdio
| null | true |
691/B
|
691
|
B
|
PyPy 3
|
TESTS
| 24 | 124 | 23,244,800 |
20033974
|
#!/usr/bin/env python3
def check(s):
chars = 'AHIMOoTUVvWwXxY'
sr = list(reversed(s))
for i in range(len(s)):
if s[i] not in chars + 'dbpq':
return False
for a, b in [('d', 'b'), ('b', 'd'),
('q', 'p'), ('p', 'q')]:
if s[i] == a and sr[i] != b:
return False
return True
if __name__ == '__main__':
s = input()
if check(s):
print('TAK')
else:
print('NIE')
| 168 | 62 | 0 |
19084773
|
s = str(input())
n = len(s)
ss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y']
ss2 = [('d','b'),('q','p'),('p','q'),('b','d')]
for i in range(0, n//2):
if s[i]==s[n-1-i]:
if not (s[i] in ss):
print("NIE")
exit()
else:
if not ((s[i],s[n-1-i]) in ss2):
print("NIE")
exit()
if n%2 != 0:
if s[n//2] in ss:
print("TAK")
else:
print("NIE")
else:
print("TAK")
|
Educational Codeforces Round 14
|
ICPC
| 2,016 | 1 | 256 |
s-palindrome
|
Let's call a string "s-palindrome" if it is symmetric about the middle of the string. For example, the string "oHo" is "s-palindrome", but the string "aa" is not. The string "aa" is not "s-palindrome", because the second half of it is not a mirror reflection of the first half.
English alphabet
You are given a string s. Check if the string is "s-palindrome".
|
The only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.
|
Print "TAK" if the string s is "s-palindrome" and "NIE" otherwise.
| null | null |
[{"input": "oXoxoXo", "output": "TAK"}, {"input": "bod", "output": "TAK"}, {"input": "ER", "output": "NIE"}]
| 1,600 |
["implementation", "strings"]
| 168 |
[{"input": "oXoxoXo\r\n", "output": "TAK\r\n"}, {"input": "bod\r\n", "output": "TAK\r\n"}, {"input": "ER\r\n", "output": "NIE\r\n"}, {"input": "o\r\n", "output": "TAK\r\n"}, {"input": "a\r\n", "output": "NIE\r\n"}, {"input": "opo\r\n", "output": "NIE\r\n"}, {"input": "HCMoxkgbNb\r\n", "output": "NIE\r\n"}, {"input": "vMhhXCMWDe\r\n", "output": "NIE\r\n"}, {"input": "iIcamjTRFH\r\n", "output": "NIE\r\n"}, {"input": "WvoWvvWovW\r\n", "output": "TAK\r\n"}, {"input": "WXxAdbAxXW\r\n", "output": "TAK\r\n"}, {"input": "vqMTUUTMpv\r\n", "output": "TAK\r\n"}, {"input": "iii\r\n", "output": "NIE\r\n"}, {"input": "AAWW\r\n", "output": "NIE\r\n"}, {"input": "ss\r\n", "output": "NIE\r\n"}, {"input": "i\r\n", "output": "NIE\r\n"}, {"input": "ii\r\n", "output": "NIE\r\n"}, {"input": "mm\r\n", "output": "NIE\r\n"}, {"input": "LJ\r\n", "output": "NIE\r\n"}, {"input": "m\r\n", "output": "NIE\r\n"}, {"input": "ioi\r\n", "output": "NIE\r\n"}, {"input": "OA\r\n", "output": "NIE\r\n"}, {"input": "aaaiaaa\r\n", "output": "NIE\r\n"}, {"input": "SS\r\n", "output": "NIE\r\n"}, {"input": "iiii\r\n", "output": "NIE\r\n"}, {"input": "ssops\r\n", "output": "NIE\r\n"}, {"input": "ssss\r\n", "output": "NIE\r\n"}, {"input": "ll\r\n", "output": "NIE\r\n"}, {"input": "s\r\n", "output": "NIE\r\n"}, {"input": "bb\r\n", "output": "NIE\r\n"}, {"input": "uu\r\n", "output": "NIE\r\n"}, {"input": "ZoZ\r\n", "output": "NIE\r\n"}, {"input": "mom\r\n", "output": "NIE\r\n"}, {"input": "uou\r\n", "output": "NIE\r\n"}, {"input": "u\r\n", "output": "NIE\r\n"}, {"input": "JL\r\n", "output": "NIE\r\n"}, {"input": "mOm\r\n", "output": "NIE\r\n"}, {"input": "llll\r\n", "output": "NIE\r\n"}, {"input": "ouo\r\n", "output": "NIE\r\n"}, {"input": "aa\r\n", "output": "NIE\r\n"}, {"input": "olo\r\n", "output": "NIE\r\n"}, {"input": "S\r\n", "output": "NIE\r\n"}, {"input": "lAl\r\n", "output": "NIE\r\n"}, {"input": "nnnn\r\n", "output": "NIE\r\n"}, {"input": "ZzZ\r\n", "output": "NIE\r\n"}, {"input": "bNd\r\n", "output": "NIE\r\n"}, {"input": "ZZ\r\n", "output": "NIE\r\n"}, {"input": "oNoNo\r\n", "output": "NIE\r\n"}, {"input": "l\r\n", "output": "NIE\r\n"}, {"input": "zz\r\n", "output": "NIE\r\n"}, {"input": "NON\r\n", "output": "NIE\r\n"}, {"input": "nn\r\n", "output": "NIE\r\n"}, {"input": "NoN\r\n", "output": "NIE\r\n"}, {"input": "sos\r\n", "output": "NIE\r\n"}, {"input": "lol\r\n", "output": "NIE\r\n"}, {"input": "mmm\r\n", "output": "NIE\r\n"}, {"input": "YAiAY\r\n", "output": "NIE\r\n"}, {"input": "ipIqi\r\n", "output": "NIE\r\n"}, {"input": "AAA\r\n", "output": "TAK\r\n"}, {"input": "uoOou\r\n", "output": "NIE\r\n"}, {"input": "SOS\r\n", "output": "NIE\r\n"}, {"input": "NN\r\n", "output": "NIE\r\n"}, {"input": "n\r\n", "output": "NIE\r\n"}, {"input": "h\r\n", "output": "NIE\r\n"}, {"input": "blld\r\n", "output": "NIE\r\n"}, {"input": "ipOqi\r\n", "output": "NIE\r\n"}, {"input": "pop\r\n", "output": "NIE\r\n"}, {"input": "BB\r\n", "output": "NIE\r\n"}, {"input": "OuO\r\n", "output": "NIE\r\n"}, {"input": "lxl\r\n", "output": "NIE\r\n"}, {"input": "Z\r\n", "output": "NIE\r\n"}, {"input": "vvivv\r\n", "output": "NIE\r\n"}, {"input": "nnnnnnnnnnnnn\r\n", "output": "NIE\r\n"}, {"input": "AA\r\n", "output": "TAK\r\n"}, {"input": "t\r\n", "output": "NIE\r\n"}, {"input": "z\r\n", "output": "NIE\r\n"}, {"input": "mmmAmmm\r\n", "output": "NIE\r\n"}, {"input": "qlililp\r\n", "output": "NIE\r\n"}, {"input": "mpOqm\r\n", "output": "NIE\r\n"}, {"input": "iiiiiiiiii\r\n", "output": "NIE\r\n"}, {"input": "BAAAB\r\n", "output": "NIE\r\n"}, {"input": "UA\r\n", "output": "NIE\r\n"}, {"input": "mmmmmmm\r\n", "output": "NIE\r\n"}, {"input": "NpOqN\r\n", "output": "NIE\r\n"}, {"input": "uOu\r\n", "output": "NIE\r\n"}, {"input": "uuu\r\n", "output": "NIE\r\n"}, {"input": "NAMAN\r\n", "output": "NIE\r\n"}, {"input": "lllll\r\n", "output": "NIE\r\n"}, {"input": "T\r\n", "output": "TAK\r\n"}, {"input": "mmmmmmmmmmmmmmmm\r\n", "output": "NIE\r\n"}, {"input": "AiiA\r\n", "output": "NIE\r\n"}, {"input": "iOi\r\n", "output": "NIE\r\n"}, {"input": "lll\r\n", "output": "NIE\r\n"}, {"input": "N\r\n", "output": "NIE\r\n"}, {"input": "viv\r\n", "output": "NIE\r\n"}, {"input": "oiio\r\n", "output": "NIE\r\n"}, {"input": "AiiiA\r\n", "output": "NIE\r\n"}, {"input": "NNNN\r\n", "output": "NIE\r\n"}, {"input": "ixi\r\n", "output": "NIE\r\n"}, {"input": "AuuA\r\n", "output": "NIE\r\n"}, {"input": "AAAANANAAAA\r\n", "output": "NIE\r\n"}, {"input": "mmmmm\r\n", "output": "NIE\r\n"}, {"input": "oYo\r\n", "output": "TAK\r\n"}, {"input": "dd\r\n", "output": "NIE\r\n"}, {"input": "A\r\n", "output": "TAK\r\n"}, {"input": "ioh\r\n", "output": "NIE\r\n"}, {"input": "mmmm\r\n", "output": "NIE\r\n"}, {"input": "uuuu\r\n", "output": "NIE\r\n"}, {"input": "puq\r\n", "output": "NIE\r\n"}, {"input": "rrrrrr\r\n", "output": "NIE\r\n"}, {"input": "c\r\n", "output": "NIE\r\n"}, {"input": "AbpA\r\n", "output": "NIE\r\n"}, {"input": "qAq\r\n", "output": "NIE\r\n"}, {"input": "tt\r\n", "output": "NIE\r\n"}, {"input": "mnmnm\r\n", "output": "NIE\r\n"}, {"input": "sss\r\n", "output": "NIE\r\n"}, {"input": "yy\r\n", "output": "NIE\r\n"}, {"input": "bob\r\n", "output": "NIE\r\n"}, {"input": "NAN\r\n", "output": "NIE\r\n"}, {"input": "mAm\r\n", "output": "NIE\r\n"}, {"input": "tAt\r\n", "output": "NIE\r\n"}, {"input": "yAy\r\n", "output": "NIE\r\n"}, {"input": "zAz\r\n", "output": "NIE\r\n"}, {"input": "aZ\r\n", "output": "NIE\r\n"}, {"input": "hh\r\n", "output": "NIE\r\n"}, {"input": "bbbb\r\n", "output": "NIE\r\n"}, {"input": "ZAZ\r\n", "output": "NIE\r\n"}, {"input": "Y\r\n", "output": "TAK\r\n"}, {"input": "AAMM\r\n", "output": "NIE\r\n"}, {"input": "lml\r\n", "output": "NIE\r\n"}, {"input": "AZA\r\n", "output": "NIE\r\n"}, {"input": "mXm\r\n", "output": "NIE\r\n"}, {"input": "bd\r\n", "output": "TAK\r\n"}, {"input": "H\r\n", "output": "TAK\r\n"}, {"input": "uvu\r\n", "output": "NIE\r\n"}, {"input": "dxxd\r\n", "output": "NIE\r\n"}, {"input": "dp\r\n", "output": "NIE\r\n"}, {"input": "vV\r\n", "output": "NIE\r\n"}, {"input": "vMo\r\n", "output": "NIE\r\n"}, {"input": "O\r\n", "output": "TAK\r\n"}, {"input": "vYv\r\n", "output": "TAK\r\n"}, {"input": "fv\r\n", "output": "NIE\r\n"}, {"input": "U\r\n", "output": "TAK\r\n"}, {"input": "iAi\r\n", "output": "NIE\r\n"}, {"input": "I\r\n", "output": "TAK\r\n"}, {"input": "VxrV\r\n", "output": "NIE\r\n"}, {"input": "POP\r\n", "output": "NIE\r\n"}, {"input": "bid\r\n", "output": "NIE\r\n"}, {"input": "bmd\r\n", "output": "NIE\r\n"}, {"input": "AiA\r\n", "output": "NIE\r\n"}, {"input": "mmmmmm\r\n", "output": "NIE\r\n"}, {"input": "XHX\r\n", "output": "TAK\r\n"}, {"input": "llllll\r\n", "output": "NIE\r\n"}, {"input": "aAa\r\n", "output": "NIE\r\n"}, {"input": "Db\r\n", "output": "NIE\r\n"}, {"input": "lOl\r\n", "output": "NIE\r\n"}, {"input": "bzd\r\n", "output": "NIE\r\n"}]
| false |
stdio
| null | true |
858/E
|
858
|
E
|
Python 3
|
TESTS
| 1 | 46 | 204,800 |
30971427
|
n = int(input())
top = set()
bottom = set()
for i in range(n):
name, type = input().split()
if type == '1':
top.add(name)
else:
bottom.add(name)
a = len(top)
b = len(bottom)
sa = set(str(i) for i in range(1, a + 1))
q = sa & top
sa -= q
top -= q
sb = set(str(i) for i in range(a + 1, b + a + 1))
q = sb & bottom
sb -= q
bottom -= q
if sa | sb == set():
print(0)
exit(0)
c = len(sa | sb)
if sa - bottom | sb - top == set():
x, y = top.pop(), '0' * 7
c += 1
print(c)
print('move', x, y)
top.add(y)
else:
print(c)
while not (len(sa) == 0 and len(sb) == 0):
if len(top & sb) > 0 and len(sa - bottom) > 0:
x, y = set(top & sb).pop(), set(sa - bottom).pop()
print('move', x, y)
top.remove(x)
sa.remove(y)
elif len(bottom & sa) > 0 and len(sb - top) > 0:
x, y = set(bottom & sa).pop(), set(sb - top).pop()
print('move', x, y)
bottom.remove(x)
sb.remove(y)
elif len(top) > 0:
x, y = top.pop(), sa.pop()
print('move', x, y)
else:
x, y = bottom.pop(), sb.pop()
print('move', x, y)
| 165 | 295 | 27,136,000 |
230751905
|
n = int(input())
t = [1] + [0] * n
b, a = d = [], []
h, s = [], []
for i in range(n):
f, k = input().split()
d[int(k)].append(f)
m = len(a)
for i in a:
if i.isdigit() and i[0] != '0':
j = int(i)
if 0 < j <= m:
t[j] = 1
elif m < j <= n:
t[j] = -1
else:
s.append(i)
else:
s.append(i)
for i in b:
if i.isdigit() and i[0] != '0':
j = int(i)
if m < j <= n:
t[j] = 1
elif 0 < j <= m:
t[j] = -1
else:
s.append(i)
else:
s.append(i)
x = [j for j in range(1, m + 1) if t[j] < 0]
y = [j for j in range(m + 1, n + 1) if t[j] < 0]
u = [j for j in range(1, m + 1) if not t[j]]
v = [j for j in range(m + 1, n + 1) if not t[j]]
if not s and (x or y):
s = ['0']
if y:
i = y.pop()
v.append(i)
else:
i = x.pop()
u.append(i)
h.append(str(i) + ' 0')
t[i] = 0
while x or y:
if v and x:
i = x.pop()
j = v.pop()
t[j] = 1
h.append(str(i) + ' ' + str(j))
u.append(i)
else:
u, v, x, y = v, u, y, x
k = 1
for j in s:
while t[k] == 1: k += 1
h.append(j + ' ' + str(k))
k += 1
d = '\nmove '
print(str(len(h)) + d + d.join(h) if h else 0)
|
Технокубок 2018 - Отборочный Раунд 1
|
CF
| 2,017 | 2 | 256 |
Tests Renumeration
|
The All-Berland National Olympiad in Informatics has just ended! Now Vladimir wants to upload the contest from the Olympiad as a gym to a popular Codehorses website.
Unfortunately, the archive with Olympiad's data is a mess. For example, the files with tests are named arbitrary without any logic.
Vladimir wants to rename the files with tests so that their names are distinct integers starting from 1 without any gaps, namely, "1", "2", ..., "n', where n is the total number of tests.
Some of the files contain tests from statements (examples), while others contain regular tests. It is possible that there are no examples, and it is possible that all tests are examples. Vladimir wants to rename the files so that the examples are the first several tests, all all the next files contain regular tests only.
The only operation Vladimir can perform is the "move" command. Vladimir wants to write a script file, each of the lines in which is "move file_1 file_2", that means that the file "file_1" is to be renamed to "file_2". If there is a file "file_2" at the moment of this line being run, then this file is to be rewritten. After the line "move file_1 file_2" the file "file_1" doesn't exist, but there is a file "file_2" with content equal to the content of "file_1" before the "move" command.
Help Vladimir to write the script file with the minimum possible number of lines so that after this script is run:
- all examples are the first several tests having filenames "1", "2", ..., "e", where e is the total number of examples;
- all other files contain regular tests with filenames "e + 1", "e + 2", ..., "n", where n is the total number of all tests.
|
The first line contains single integer n (1 ≤ n ≤ 105) — the number of files with tests.
n lines follow, each describing a file with test. Each line has a form of "name_i type_i", where "name_i" is the filename, and "type_i" equals "1", if the i-th file contains an example test, and "0" if it contains a regular test. Filenames of each file are strings of digits and small English letters with length from 1 to 6 characters. The filenames are guaranteed to be distinct.
|
In the first line print the minimum number of lines in Vladimir's script file.
After that print the script file, each line should be "move file_1 file_2", where "file_1" is an existing at the moment of this line being run filename, and "file_2" — is a string of digits and small English letters with length from 1 to 6.
| null | null |
[{"input": "5\n01 0\n2 1\n2extra 0\n3 1\n99 0", "output": "4\nmove 3 1\nmove 01 5\nmove 2extra 4\nmove 99 3"}, {"input": "2\n1 0\n2 1", "output": "3\nmove 1 3\nmove 2 1\nmove 3 2"}, {"input": "5\n1 0\n11 1\n111 0\n1111 1\n11111 0", "output": "5\nmove 1 5\nmove 11 1\nmove 1111 2\nmove 111 4\nmove 11111 3"}]
| 2,200 |
["greedy", "implementation"]
| 165 |
[{"input": "5\r\n01 0\r\n2 1\r\n2extra 0\r\n3 1\r\n99 0\r\n", "output": "4\r\nmove 3 1\r\nmove 01 5\r\nmove 2extra 4\r\nmove 99 3\r\n"}, {"input": "2\r\n1 0\r\n2 1\r\n", "output": "3\r\nmove 1 dytuig\r\nmove 2 1\r\nmove dytuig 2\r\n"}, {"input": "5\r\n1 0\r\n11 1\r\n111 0\r\n1111 1\r\n11111 0\r\n", "output": "5\r\nmove 1 5\r\nmove 11 1\r\nmove 1111 2\r\nmove 111 4\r\nmove 11111 3\r\n"}, {"input": "4\r\nir7oz8 1\r\nvj4v5t 1\r\nkwkahb 1\r\nj5s8o1 0\r\n", "output": "4\r\nmove ir7oz8 1\r\nmove vj4v5t 2\r\nmove kwkahb 3\r\nmove j5s8o1 4\r\n"}, {"input": "4\r\n3 1\r\n1o0bp2 0\r\n9tn379 0\r\nv04v6j 1\r\n", "output": "4\r\nmove 3 1\r\nmove v04v6j 2\r\nmove 1o0bp2 4\r\nmove 9tn379 3\r\n"}, {"input": "4\r\n1 0\r\nsc7czx 0\r\nfr4033 1\r\n3 0\r\n", "output": "3\r\nmove 1 4\r\nmove fr4033 1\r\nmove sc7czx 2\r\n"}, {"input": "4\r\n4 0\r\n1 0\r\n2 0\r\nizfotg 1\r\n", "output": "2\r\nmove 1 3\r\nmove izfotg 1\r\n"}, {"input": "4\r\n2 0\r\n3 0\r\n1 1\r\n4 1\r\n", "output": "3\r\nmove 2 0b9r8j\r\nmove 4 2\r\nmove 0b9r8j 4\r\n"}, {"input": "5\r\npuusew 1\r\npvoy4h 0\r\nwdzx4r 0\r\n1z84cx 0\r\nozsuvd 0\r\n", "output": "5\r\nmove puusew 1\r\nmove pvoy4h 5\r\nmove wdzx4r 4\r\nmove 1z84cx 3\r\nmove ozsuvd 2\r\n"}, {"input": "5\r\n949pnr 1\r\n9sxhcr 0\r\n5 1\r\nx8srx3 1\r\ncl7ppd 1\r\n", "output": "5\r\nmove 5 1\r\nmove 949pnr 2\r\nmove x8srx3 3\r\nmove cl7ppd 4\r\nmove 9sxhcr 5\r\n"}, {"input": "5\r\n2 0\r\n1 0\r\np2gcxf 1\r\nwfyoiq 1\r\nzjw3vg 1\r\n", "output": "5\r\nmove 2 5\r\nmove 1 4\r\nmove p2gcxf 1\r\nmove wfyoiq 2\r\nmove zjw3vg 3\r\n"}, {"input": "5\r\nogvgi7 0\r\n3 1\r\n4 1\r\n1 1\r\nm5nhux 0\r\n", "output": "3\r\nmove 4 2\r\nmove ogvgi7 5\r\nmove m5nhux 4\r\n"}, {"input": "5\r\nt6kdte 1\r\n2 1\r\n4 1\r\n5 1\r\n3 1\r\n", "output": "1\r\nmove t6kdte 1\r\n"}, {"input": "5\r\n2 0\r\n3 1\r\n4 0\r\n1 1\r\n5 1\r\n", "output": "3\r\nmove 2 p6w7mu\r\nmove 5 2\r\nmove p6w7mu 5\r\n"}, {"input": "1\r\nsd84r7 1\r\n", "output": "1\r\nmove sd84r7 1\r\n"}, {"input": "1\r\n1 0\r\n", "output": "0\r\n"}, {"input": "2\r\n5xzjm4 0\r\njoa6mr 1\r\n", "output": "2\r\nmove joa6mr 1\r\nmove 5xzjm4 2\r\n"}, {"input": "2\r\n1 0\r\nxdkh5a 1\r\n", "output": "2\r\nmove 1 2\r\nmove xdkh5a 1\r\n"}, {"input": "2\r\n1 0\r\n2 0\r\n", "output": "0\r\n"}, {"input": "3\r\nz1nwrd 1\r\nt0xrja 0\r\n106qy1 0\r\n", "output": "3\r\nmove z1nwrd 1\r\nmove t0xrja 3\r\nmove 106qy1 2\r\n"}, {"input": "3\r\nt4hdos 0\r\ndhje0g 0\r\n3 0\r\n", "output": "2\r\nmove t4hdos 2\r\nmove dhje0g 1\r\n"}, {"input": "3\r\n3 0\r\n26mp5s 0\r\n1 1\r\n", "output": "1\r\nmove 26mp5s 2\r\n"}, {"input": "3\r\n2 1\r\n1 0\r\n3 0\r\n", "output": "3\r\nmove 2 1ntx05\r\nmove 1 2\r\nmove 1ntx05 1\r\n"}, {"input": "1\r\nprzvln 0\r\n", "output": "1\r\nmove przvln 1\r\n"}, {"input": "2\r\nkfsipl 0\r\n1jj1ol 0\r\n", "output": "2\r\nmove kfsipl 2\r\nmove 1jj1ol 1\r\n"}, {"input": "3\r\n2x7a4g 0\r\n27lqe6 0\r\nzfo3sp 0\r\n", "output": "3\r\nmove 2x7a4g 3\r\nmove 27lqe6 2\r\nmove zfo3sp 1\r\n"}, {"input": "1\r\nxzp9ni 1\r\n", "output": "1\r\nmove xzp9ni 1\r\n"}, {"input": "1\r\nabbdf7 1\r\n", "output": "1\r\nmove abbdf7 1\r\n"}, {"input": "2\r\ndbif39 1\r\ne8dkf8 0\r\n", "output": "2\r\nmove dbif39 1\r\nmove e8dkf8 2\r\n"}, {"input": "2\r\n2 0\r\njkwekx 1\r\n", "output": "1\r\nmove jkwekx 1\r\n"}, {"input": "3\r\nn3pmj8 0\r\n2alui6 0\r\ne7lf4u 1\r\n", "output": "3\r\nmove e7lf4u 1\r\nmove n3pmj8 3\r\nmove 2alui6 2\r\n"}, {"input": "3\r\ndr1lp8 0\r\n1 0\r\n6a2egk 1\r\n", "output": "3\r\nmove 1 3\r\nmove 6a2egk 1\r\nmove dr1lp8 2\r\n"}, {"input": "4\r\nyi9ta0 1\r\nmeljgm 0\r\nf7bqon 0\r\n5bbvun 0\r\n", "output": "4\r\nmove yi9ta0 1\r\nmove meljgm 4\r\nmove f7bqon 3\r\nmove 5bbvun 2\r\n"}, {"input": "4\r\n0la3gu 0\r\nzhrmyb 1\r\n3iprc0 0\r\n3 0\r\n", "output": "3\r\nmove zhrmyb 1\r\nmove 0la3gu 4\r\nmove 3iprc0 2\r\n"}, {"input": "1\r\n1 1\r\n", "output": "0\r\n"}, {"input": "1\r\n1 1\r\n", "output": "0\r\n"}, {"input": "2\r\n17dgbb 0\r\n2 1\r\n", "output": "2\r\nmove 2 1\r\nmove 17dgbb 2\r\n"}, {"input": "2\r\n1 0\r\n2 1\r\n", "output": "3\r\nmove 1 xrjgjv\r\nmove 2 1\r\nmove xrjgjv 2\r\n"}, {"input": "3\r\nscrn8k 0\r\n3 1\r\nycvm9s 0\r\n", "output": "3\r\nmove 3 1\r\nmove scrn8k 3\r\nmove ycvm9s 2\r\n"}, {"input": "3\r\nt0dfz3 0\r\n3 0\r\n1 1\r\n", "output": "1\r\nmove t0dfz3 2\r\n"}, {"input": "4\r\nkgw83p 0\r\np3p3ch 0\r\n4 1\r\n0te9lv 0\r\n", "output": "4\r\nmove 4 1\r\nmove kgw83p 4\r\nmove p3p3ch 3\r\nmove 0te9lv 2\r\n"}, {"input": "4\r\n3 1\r\nnj94jx 0\r\n3a5ad1 0\r\n1 0\r\n", "output": "4\r\nmove 1 4\r\nmove 3 1\r\nmove nj94jx 3\r\nmove 3a5ad1 2\r\n"}, {"input": "2\r\no9z069 1\r\n5hools 1\r\n", "output": "2\r\nmove o9z069 1\r\nmove 5hools 2\r\n"}, {"input": "2\r\nyzzyab 1\r\n728oq0 1\r\n", "output": "2\r\nmove yzzyab 1\r\nmove 728oq0 2\r\n"}, {"input": "2\r\nqy2kmc 1\r\nqb4crj 1\r\n", "output": "2\r\nmove qy2kmc 1\r\nmove qb4crj 2\r\n"}, {"input": "3\r\nunw560 1\r\n0iswxk 0\r\ndonjp9 1\r\n", "output": "3\r\nmove unw560 1\r\nmove donjp9 2\r\nmove 0iswxk 3\r\n"}, {"input": "3\r\n2 0\r\nuv8c54 1\r\n508bb0 1\r\n", "output": "3\r\nmove 2 3\r\nmove uv8c54 1\r\nmove 508bb0 2\r\n"}, {"input": "3\r\n9afh0z 1\r\n0qcaht 1\r\n3 0\r\n", "output": "2\r\nmove 9afh0z 1\r\nmove 0qcaht 2\r\n"}, {"input": "4\r\n2kk04q 0\r\nkdktvk 1\r\nc4i5k8 1\r\nawaock 0\r\n", "output": "4\r\nmove kdktvk 1\r\nmove c4i5k8 2\r\nmove 2kk04q 4\r\nmove awaock 3\r\n"}, {"input": "4\r\n2 0\r\nmqbjos 0\r\n6mhijg 1\r\n6wum8y 1\r\n", "output": "4\r\nmove 2 4\r\nmove 6mhijg 1\r\nmove 6wum8y 2\r\nmove mqbjos 3\r\n"}, {"input": "4\r\n4 0\r\npa613p 1\r\nuuizq7 1\r\n2 0\r\n", "output": "3\r\nmove 2 3\r\nmove pa613p 1\r\nmove uuizq7 2\r\n"}, {"input": "5\r\nw0g96a 1\r\nv99tdi 0\r\nmywrle 0\r\nweh22w 1\r\n9hywt4 0\r\n", "output": "5\r\nmove w0g96a 1\r\nmove weh22w 2\r\nmove v99tdi 5\r\nmove mywrle 4\r\nmove 9hywt4 3\r\n"}, {"input": "5\r\n5 0\r\n12qcjd 1\r\nuthzbz 0\r\nb3670z 0\r\nl2u93o 1\r\n", "output": "4\r\nmove 12qcjd 1\r\nmove l2u93o 2\r\nmove uthzbz 4\r\nmove b3670z 3\r\n"}, {"input": "5\r\n0jc7xb 1\r\n2 0\r\n1m7l9s 0\r\n9xzkau 1\r\n1 0\r\n", "output": "5\r\nmove 2 5\r\nmove 1 4\r\nmove 0jc7xb 1\r\nmove 9xzkau 2\r\nmove 1m7l9s 3\r\n"}, {"input": "2\r\n1 1\r\nvinxur 1\r\n", "output": "1\r\nmove vinxur 2\r\n"}, {"input": "2\r\n1qe46n 1\r\n1 1\r\n", "output": "1\r\nmove 1qe46n 2\r\n"}, {"input": "2\r\n1 1\r\ng5jlzp 1\r\n", "output": "1\r\nmove g5jlzp 2\r\n"}, {"input": "3\r\nc8p28p 1\r\n2 1\r\nvk4gdf 0\r\n", "output": "2\r\nmove c8p28p 1\r\nmove vk4gdf 3\r\n"}, {"input": "3\r\n2 1\r\n3 0\r\nhs9j9t 1\r\n", "output": "1\r\nmove hs9j9t 1\r\n"}, {"input": "3\r\n2 1\r\n1 0\r\nomitxh 1\r\n", "output": "2\r\nmove 1 3\r\nmove omitxh 1\r\n"}, {"input": "4\r\n4 1\r\nu9do88 1\r\n787at9 0\r\nfcud6k 0\r\n", "output": "4\r\nmove 4 1\r\nmove u9do88 2\r\nmove 787at9 4\r\nmove fcud6k 3\r\n"}, {"input": "4\r\n3 0\r\nqvw4ow 1\r\nne0ng9 0\r\n1 1\r\n", "output": "2\r\nmove qvw4ow 2\r\nmove ne0ng9 4\r\n"}, {"input": "4\r\ng6ugrm 1\r\n1 1\r\n3 0\r\n2 0\r\n", "output": "2\r\nmove 2 4\r\nmove g6ugrm 2\r\n"}, {"input": "5\r\n5 1\r\nz9zr7d 0\r\ne8rwo4 1\r\nrfpjp6 0\r\ngz6dhj 0\r\n", "output": "5\r\nmove 5 1\r\nmove e8rwo4 2\r\nmove z9zr7d 5\r\nmove rfpjp6 4\r\nmove gz6dhj 3\r\n"}, {"input": "5\r\n5sn77g 0\r\nsetddt 1\r\nbz16cb 0\r\n4 1\r\n2 0\r\n", "output": "5\r\nmove 4 1\r\nmove 2 5\r\nmove setddt 2\r\nmove 5sn77g 4\r\nmove bz16cb 3\r\n"}, {"input": "5\r\n1 1\r\nx2miqh 1\r\n3 0\r\n2 0\r\n1rq643 0\r\n", "output": "3\r\nmove 2 5\r\nmove x2miqh 2\r\nmove 1rq643 4\r\n"}, {"input": "2\r\n1 1\r\n2 1\r\n", "output": "0\r\n"}, {"input": "2\r\n1 1\r\n2 1\r\n", "output": "0\r\n"}, {"input": "2\r\n2 1\r\n1 1\r\n", "output": "0\r\n"}, {"input": "3\r\n3 1\r\nav5vex 0\r\n1 1\r\n", "output": "2\r\nmove 3 2\r\nmove av5vex 3\r\n"}, {"input": "3\r\n3 1\r\n1 0\r\n2 1\r\n", "output": "3\r\nmove 3 fopgrb\r\nmove 1 3\r\nmove fopgrb 1\r\n"}, {"input": "3\r\n3 1\r\n1 0\r\n2 1\r\n", "output": "3\r\nmove 3 wzgsm0\r\nmove 1 3\r\nmove wzgsm0 1\r\n"}, {"input": "4\r\ny9144q 0\r\n3 1\r\n2 1\r\ns0bdnf 0\r\n", "output": "3\r\nmove 3 1\r\nmove y9144q 4\r\nmove s0bdnf 3\r\n"}, {"input": "4\r\n4 1\r\n1 0\r\n3 1\r\nmod9zl 0\r\n", "output": "4\r\nmove 4 2\r\nmove 1 4\r\nmove 3 1\r\nmove mod9zl 3\r\n"}, {"input": "4\r\n4 1\r\n3 1\r\n1 0\r\n2 0\r\n", "output": "5\r\nmove 4 ow3q4a\r\nmove 1 4\r\nmove 3 1\r\nmove 2 3\r\nmove ow3q4a 2\r\n"}, {"input": "5\r\n1 1\r\nnoidnv 0\r\n3 1\r\nx3xiiz 0\r\n1lfa9v 0\r\n", "output": "4\r\nmove 3 2\r\nmove noidnv 5\r\nmove x3xiiz 4\r\nmove 1lfa9v 3\r\n"}, {"input": "5\r\n1 1\r\nvsyajx 0\r\n783b38 0\r\n4 0\r\n2 1\r\n", "output": "2\r\nmove vsyajx 5\r\nmove 783b38 3\r\n"}, {"input": "5\r\n3 1\r\n5 0\r\ncvfl8i 0\r\n4 1\r\n2 0\r\n", "output": "4\r\nmove 3 1\r\nmove 2 3\r\nmove 4 2\r\nmove cvfl8i 4\r\n"}, {"input": "3\r\nbxo0pe 1\r\nbt50pa 1\r\n2tx68t 1\r\n", "output": "3\r\nmove bxo0pe 1\r\nmove bt50pa 2\r\nmove 2tx68t 3\r\n"}, {"input": "3\r\nj9rnac 1\r\noetwfz 1\r\nd6n3ww 1\r\n", "output": "3\r\nmove j9rnac 1\r\nmove oetwfz 2\r\nmove d6n3ww 3\r\n"}, {"input": "3\r\naf2f6j 1\r\nmjni5l 1\r\njvyxgc 1\r\n", "output": "3\r\nmove af2f6j 1\r\nmove mjni5l 2\r\nmove jvyxgc 3\r\n"}, {"input": "3\r\nr2qlj2 1\r\nt8wf1y 1\r\nigids8 1\r\n", "output": "3\r\nmove r2qlj2 1\r\nmove t8wf1y 2\r\nmove igids8 3\r\n"}, {"input": "4\r\nuilh9a 0\r\n4lxxh9 1\r\nkqdpzy 1\r\nn1d7hd 1\r\n", "output": "4\r\nmove 4lxxh9 1\r\nmove kqdpzy 2\r\nmove n1d7hd 3\r\nmove uilh9a 4\r\n"}, {"input": "4\r\n3 0\r\niipymv 1\r\nvakd5b 1\r\n2ktczv 1\r\n", "output": "4\r\nmove 3 4\r\nmove iipymv 1\r\nmove vakd5b 2\r\nmove 2ktczv 3\r\n"}, {"input": "4\r\nq4b449 1\r\n3 0\r\ncjg1x2 1\r\ne878er 1\r\n", "output": "4\r\nmove 3 4\r\nmove q4b449 1\r\nmove cjg1x2 2\r\nmove e878er 3\r\n"}, {"input": "4\r\n9f4aoa 1\r\n4 0\r\nf4m1ec 1\r\nqyr2h6 1\r\n", "output": "3\r\nmove 9f4aoa 1\r\nmove f4m1ec 2\r\nmove qyr2h6 3\r\n"}, {"input": "5\r\n73s1nt 1\r\nsbngv2 0\r\n4n3qri 1\r\nbyhzp8 1\r\nadpjs4 0\r\n", "output": "5\r\nmove 73s1nt 1\r\nmove 4n3qri 2\r\nmove byhzp8 3\r\nmove sbngv2 5\r\nmove adpjs4 4\r\n"}, {"input": "5\r\n7ajg8o 1\r\np7cqxy 1\r\n3qrp34 0\r\nh93m07 1\r\n2 0\r\n", "output": "5\r\nmove 2 5\r\nmove 7ajg8o 1\r\nmove p7cqxy 2\r\nmove h93m07 3\r\nmove 3qrp34 4\r\n"}, {"input": "5\r\ny0wnwz 1\r\n5 0\r\n0totai 1\r\n1 0\r\nym8xwz 1\r\n", "output": "4\r\nmove 1 4\r\nmove y0wnwz 1\r\nmove 0totai 2\r\nmove ym8xwz 3\r\n"}, {"input": "5\r\n5 0\r\n4 0\r\n5nvzu4 1\r\nvkpzzk 1\r\nzamzcz 1\r\n", "output": "3\r\nmove 5nvzu4 1\r\nmove vkpzzk 2\r\nmove zamzcz 3\r\n"}, {"input": "6\r\np1wjw9 1\r\nueksby 0\r\nu1ixfc 1\r\nj3lk2e 1\r\n36iskv 0\r\n9imqi1 0\r\n", "output": "6\r\nmove p1wjw9 1\r\nmove u1ixfc 2\r\nmove j3lk2e 3\r\nmove ueksby 6\r\nmove 36iskv 5\r\nmove 9imqi1 4\r\n"}, {"input": "6\r\n6slonw 1\r\nptk9mc 1\r\n57a4nq 0\r\nhiq2f7 1\r\n2 0\r\nc0gtv3 0\r\n", "output": "6\r\nmove 2 6\r\nmove 6slonw 1\r\nmove ptk9mc 2\r\nmove hiq2f7 3\r\nmove 57a4nq 5\r\nmove c0gtv3 4\r\n"}, {"input": "6\r\n5 0\r\n2 0\r\ncbhvyf 1\r\nl1z5mg 0\r\nwkwhby 1\r\nx7fdh9 1\r\n", "output": "5\r\nmove 2 6\r\nmove cbhvyf 1\r\nmove wkwhby 2\r\nmove x7fdh9 3\r\nmove l1z5mg 4\r\n"}, {"input": "6\r\n1t68ks 1\r\npkbj1g 1\r\n5 0\r\n5pw8wm 1\r\n1 0\r\n4 0\r\n", "output": "4\r\nmove 1 6\r\nmove 1t68ks 1\r\nmove pkbj1g 2\r\nmove 5pw8wm 3\r\n"}, {"input": "3\r\n1 1\r\n7ph5fw 1\r\ntfxz1j 1\r\n", "output": "2\r\nmove 7ph5fw 2\r\nmove tfxz1j 3\r\n"}, {"input": "3\r\norwsz0 1\r\nmbt097 1\r\n3 1\r\n", "output": "2\r\nmove orwsz0 1\r\nmove mbt097 2\r\n"}, {"input": "3\r\n1 1\r\nzwfnx2 1\r\n7g8t6z 1\r\n", "output": "2\r\nmove zwfnx2 2\r\nmove 7g8t6z 3\r\n"}, {"input": "3\r\nqmf7iz 1\r\ndjwdce 1\r\n1 1\r\n", "output": "2\r\nmove qmf7iz 2\r\nmove djwdce 3\r\n"}, {"input": "4\r\n4i2i2a 0\r\n4 1\r\npf618n 1\r\nlx6nmh 1\r\n", "output": "4\r\nmove 4 1\r\nmove pf618n 2\r\nmove lx6nmh 3\r\nmove 4i2i2a 4\r\n"}, {"input": "4\r\nxpteku 1\r\n1 0\r\n4 1\r\n73xpqz 1\r\n", "output": "4\r\nmove 4 2\r\nmove 1 4\r\nmove xpteku 1\r\nmove 73xpqz 3\r\n"}, {"input": "4\r\n1wp56i 1\r\n2 1\r\n1 0\r\n6m76jb 1\r\n", "output": "3\r\nmove 1 4\r\nmove 1wp56i 1\r\nmove 6m76jb 3\r\n"}, {"input": "4\r\n3 1\r\nyumiqt 1\r\n1 0\r\nt19jus 1\r\n", "output": "3\r\nmove 1 4\r\nmove yumiqt 1\r\nmove t19jus 2\r\n"}, {"input": "5\r\nynagvf 1\r\n3 1\r\nojz4mm 1\r\ndovec3 0\r\nnc1jye 0\r\n", "output": "4\r\nmove ynagvf 1\r\nmove ojz4mm 2\r\nmove dovec3 5\r\nmove nc1jye 4\r\n"}, {"input": "5\r\n5 1\r\nwje9ts 1\r\nkytn5q 1\r\n7frk8z 0\r\n3 0\r\n", "output": "5\r\nmove 5 1\r\nmove 3 5\r\nmove wje9ts 2\r\nmove kytn5q 3\r\nmove 7frk8z 4\r\n"}, {"input": "5\r\n1 0\r\n4 1\r\n3 0\r\nlog9cm 1\r\nu5m0ls 1\r\n", "output": "5\r\nmove 4 2\r\nmove 1 5\r\nmove 3 4\r\nmove log9cm 1\r\nmove u5m0ls 3\r\n"}, {"input": "5\r\nh015vv 1\r\n3 1\r\n1 0\r\n9w2keb 1\r\n2 0\r\n", "output": "4\r\nmove 1 5\r\nmove 2 4\r\nmove h015vv 1\r\nmove 9w2keb 2\r\n"}, {"input": "6\r\n0zluka 0\r\nqp7q8l 1\r\nwglqu8 1\r\n9i7kta 0\r\nnwf8m3 0\r\n3 1\r\n", "output": "5\r\nmove qp7q8l 1\r\nmove wglqu8 2\r\nmove 0zluka 6\r\nmove 9i7kta 5\r\nmove nwf8m3 4\r\n"}, {"input": "6\r\n3 1\r\n1h3t85 1\r\n5 0\r\nrf2ikt 0\r\n3vhl6e 1\r\n5l3oka 0\r\n", "output": "4\r\nmove 1h3t85 1\r\nmove 3vhl6e 2\r\nmove rf2ikt 6\r\nmove 5l3oka 4\r\n"}, {"input": "6\r\n2 0\r\n3 0\r\nw9h0pv 1\r\n5 1\r\nq92z4i 0\r\n6qb4ia 1\r\n", "output": "6\r\nmove 5 1\r\nmove 2 6\r\nmove 3 5\r\nmove w9h0pv 2\r\nmove 6qb4ia 3\r\nmove q92z4i 4\r\n"}, {"input": "6\r\n4 1\r\n410jiy 1\r\n1 0\r\n6 0\r\nxc98l2 1\r\n5 0\r\n", "output": "4\r\nmove 4 2\r\nmove 1 4\r\nmove 410jiy 1\r\nmove xc98l2 3\r\n"}, {"input": "3\r\n1 1\r\nc9qyld 1\r\n3 1\r\n", "output": "1\r\nmove c9qyld 2\r\n"}, {"input": "3\r\ngdm5ri 1\r\n1 1\r\n2 1\r\n", "output": "1\r\nmove gdm5ri 3\r\n"}, {"input": "3\r\n3 1\r\n2 1\r\ni19lnk 1\r\n", "output": "1\r\nmove i19lnk 1\r\n"}, {"input": "3\r\ncxbbpd 1\r\n3 1\r\n1 1\r\n", "output": "1\r\nmove cxbbpd 2\r\n"}, {"input": "4\r\nwy6i6o 0\r\n1 1\r\n3 1\r\niy1dq6 1\r\n", "output": "2\r\nmove iy1dq6 2\r\nmove wy6i6o 4\r\n"}, {"input": "4\r\n4 1\r\nwgh8s0 1\r\n1 0\r\n2 1\r\n", "output": "3\r\nmove 4 3\r\nmove 1 4\r\nmove wgh8s0 1\r\n"}, {"input": "4\r\nhex0ur 1\r\n4 1\r\n3 0\r\n2 1\r\n", "output": "3\r\nmove 4 1\r\nmove 3 4\r\nmove hex0ur 3\r\n"}, {"input": "4\r\n4 1\r\n1 1\r\n3 0\r\n4soxj3 1\r\n", "output": "3\r\nmove 4 2\r\nmove 3 4\r\nmove 4soxj3 3\r\n"}, {"input": "5\r\n5sbtul 1\r\n2 1\r\n8i2duz 0\r\n5 1\r\n4b85z6 0\r\n", "output": "4\r\nmove 5 1\r\nmove 5sbtul 3\r\nmove 8i2duz 5\r\nmove 4b85z6 4\r\n"}, {"input": "5\r\n3 1\r\n4 0\r\nejo0a4 1\r\ngqzdbk 0\r\n1 1\r\n", "output": "2\r\nmove ejo0a4 2\r\nmove gqzdbk 5\r\n"}, {"input": "5\r\n2y4agr 1\r\n5 0\r\n3 0\r\n1 1\r\n4 1\r\n", "output": "3\r\nmove 4 2\r\nmove 3 4\r\nmove 2y4agr 3\r\n"}, {"input": "5\r\n2 0\r\n1 1\r\nq4hyeg 1\r\n5 0\r\n4 1\r\n", "output": "3\r\nmove 4 3\r\nmove 2 4\r\nmove q4hyeg 2\r\n"}, {"input": "6\r\n5 1\r\nrdm6fu 0\r\n4 1\r\noclx1h 0\r\n7l3kg1 1\r\nq25te0 0\r\n", "output": "6\r\nmove 5 1\r\nmove 4 2\r\nmove 7l3kg1 3\r\nmove rdm6fu 6\r\nmove oclx1h 5\r\nmove q25te0 4\r\n"}, {"input": "6\r\n1 0\r\np4tuyt 0\r\n5 1\r\n2 1\r\nwrrcmu 1\r\n3r4wqz 0\r\n", "output": "5\r\nmove 5 3\r\nmove 1 6\r\nmove wrrcmu 1\r\nmove p4tuyt 5\r\nmove 3r4wqz 4\r\n"}, {"input": "6\r\n5 1\r\n6 0\r\nxhfzge 0\r\n3 1\r\n1 0\r\n1n9mqv 1\r\n", "output": "4\r\nmove 5 2\r\nmove 1 5\r\nmove 1n9mqv 1\r\nmove xhfzge 4\r\n"}, {"input": "6\r\nhmpfsz 1\r\n6 0\r\n5 1\r\n4 0\r\n1 0\r\n3 1\r\n", "output": "3\r\nmove 5 2\r\nmove 1 5\r\nmove hmpfsz 1\r\n"}, {"input": "3\r\n1 1\r\n3 1\r\n2 1\r\n", "output": "0\r\n"}, {"input": "3\r\n2 1\r\n3 1\r\n1 1\r\n", "output": "0\r\n"}, {"input": "3\r\n2 1\r\n1 1\r\n3 1\r\n", "output": "0\r\n"}, {"input": "3\r\n1 1\r\n2 1\r\n3 1\r\n", "output": "0\r\n"}, {"input": "4\r\n3 1\r\n1 1\r\n4 1\r\nd1cks2 0\r\n", "output": "2\r\nmove 4 2\r\nmove d1cks2 4\r\n"}, {"input": "4\r\n4 0\r\n3 1\r\n1 1\r\n2 1\r\n", "output": "0\r\n"}, {"input": "4\r\n2 1\r\n4 1\r\n1 0\r\n3 1\r\n", "output": "3\r\nmove 4 e15gvb\r\nmove 1 4\r\nmove e15gvb 1\r\n"}, {"input": "4\r\n4 1\r\n1 1\r\n3 1\r\n2 0\r\n", "output": "3\r\nmove 4 7l41cc\r\nmove 2 4\r\nmove 7l41cc 2\r\n"}, {"input": "5\r\n4 1\r\nhvshea 0\r\naio11n 0\r\n2 1\r\n3 1\r\n", "output": "3\r\nmove 4 1\r\nmove hvshea 5\r\nmove aio11n 4\r\n"}, {"input": "5\r\n5 0\r\nts7a1c 0\r\n4 1\r\n1 1\r\n2 1\r\n", "output": "2\r\nmove 4 3\r\nmove ts7a1c 4\r\n"}, {"input": "5\r\n4 0\r\n3 1\r\n5 0\r\n2 1\r\n1 1\r\n", "output": "0\r\n"}, {"input": "5\r\n3 1\r\n5 0\r\n4 1\r\n1 1\r\n2 0\r\n", "output": "3\r\nmove 4 kmnhgt\r\nmove 2 4\r\nmove kmnhgt 2\r\n"}, {"input": "6\r\neik3kw 0\r\n5 1\r\nzoonoj 0\r\n2 1\r\n1 1\r\nivzfie 0\r\n", "output": "4\r\nmove 5 3\r\nmove eik3kw 6\r\nmove zoonoj 5\r\nmove ivzfie 4\r\n"}, {"input": "6\r\n7igwk9 0\r\n6 1\r\n5 1\r\ndx2yu0 0\r\n2 0\r\n1 1\r\n", "output": "5\r\nmove 6 3\r\nmove 2 6\r\nmove 5 2\r\nmove 7igwk9 5\r\nmove dx2yu0 4\r\n"}, {"input": "6\r\nc3py3h 0\r\n2 1\r\n4 0\r\n3 0\r\n1 1\r\n5 1\r\n", "output": "3\r\nmove 3 6\r\nmove 5 3\r\nmove c3py3h 5\r\n"}, {"input": "6\r\n1 1\r\n3 0\r\n2 1\r\n6 1\r\n4 0\r\n5 0\r\n", "output": "3\r\nmove 3 4r6zp7\r\nmove 6 3\r\nmove 4r6zp7 6\r\n"}, {"input": "20\r\nphp8vy 1\r\nkeeona 0\r\n8 0\r\nwzf4eb 0\r\n16 1\r\n9 0\r\nf2548d 0\r\n11 0\r\nyszsig 0\r\nyyf4q2 0\r\n1pon1p 1\r\njvpwuo 0\r\nd9stsx 0\r\ne14bkx 1\r\n5 0\r\n17 0\r\nsbklx4 0\r\nsfms2u 1\r\n6 0\r\n18 1\r\n", "output": "16\r\nmove 16 1\r\nmove 18 2\r\nmove 5 20\r\nmove 6 19\r\nmove php8vy 3\r\nmove 1pon1p 4\r\nmove e14bkx 5\r\nmove sfms2u 6\r\nmove keeona 18\r\nmove wzf4eb 16\r\nmove f2548d 15\r\nmove yszsig 14\r\nmove yyf4q2 13\r\nmove jvpwuo 12\r\nmove d9stsx 10\r\nmove sbklx4 7\r\n"}, {"input": "4\r\n3 1\r\n4 1\r\n1 0\r\n2 0\r\n", "output": "5\r\nmove 3 41nqph\r\nmove 1 3\r\nmove 4 1\r\nmove 2 4\r\nmove 41nqph 2\r\n"}, {"input": "1\r\n01 1\r\n", "output": "1\r\nmove 01 1\r\n"}, {"input": "2\r\n01 0\r\n02 1\r\n", "output": "2\r\nmove 02 1\r\nmove 01 2\r\n"}]
| false |
stdio
|
import sys
def main():
input_path = sys.argv[1]
output_path = sys.argv[2]
submission_path = sys.argv[3]
with open(input_path) as f:
n = int(f.readline())
files = []
type1_count = 0
for _ in range(n):
line = f.readline().strip()
name, typ = line.split()
files.append((name, typ))
if typ == '1':
type1_count += 1
e = type1_count
cnt = 0
valid_numbers = set()
for name, typ in files:
if name.isdigit() and (len(name) == 1 or name[0] != '0'):
num = int(name)
if 1 <= num <= n:
valid_numbers.add(num)
if typ == '1':
if not name.isdigit() or (len(name) > 1 and name[0] == '0'):
cnt += 1
continue
num = int(name)
if not (1 <= num <= e):
cnt += 1
else:
if not name.isdigit() or (len(name) > 1 and name[0] == '0'):
cnt += 1
continue
num = int(name)
if not (e + 1 <= num <= n):
cnt += 1
initial_free = n - len(valid_numbers)
minimal_steps = cnt + 1 if (initial_free == 0 and cnt > 0) else cnt
with open(submission_path) as f:
lines = f.read().splitlines()
if not lines:
print(0)
return
try:
k = int(lines[0])
except:
print(0)
return
if k != minimal_steps:
print(0)
return
moves = lines[1:]
if len(moves) != k:
print(0)
return
current_files = {name: typ for name, typ in files}
for move in moves:
parts = move.split()
if len(parts) != 3 or parts[0] != 'move':
print(0)
return
src, dst = parts[1], parts[2]
if src not in current_files:
print(0)
return
typ = current_files.pop(src)
current_files[dst] = typ
names = list(current_files.keys())
if len(names) != n:
print(0)
return
nums = []
for name in names:
if not name.isdigit() or (len(name) > 1 and name[0] == '0'):
print(0)
return
num = int(name)
if num < 1 or num > n:
print(0)
return
nums.append(num)
if sorted(nums) != list(range(1, n + 1)):
print(0)
return
for name, typ in current_files.items():
num = int(name)
if typ == '1' and num > e:
print(0)
return
if typ == '0' and num <= e:
print(0)
return
print(1)
if __name__ == "__main__":
main()
| true |
691/B
|
691
|
B
|
PyPy 3
|
TESTS
| 38 | 93 | 0 |
110982063
|
s = input()
d = {"b" : "d","d":"b","l":"l","o":"o","p":"q","q":"p","v":"v","w":"w","x":"x","A":"A","H":"H","I":"I","M":"M","O":"O","T":"T","U":"U","V":"V","W":"W","X":"X","Y":"Y"}
n = len(s)//2
flag = 0
l = []
if len(s)%2 == 0:
i = n-1
j = n
else:
i = n
j = n
while i > -1:
if s[i] not in d:
flag = 1
break
l.append(d[s[i]])
i -= 1
if flag:
print("NIE")
exit()
o = []
for e in range(j,len(s)):
o.append(s[e])
if o == l:
print("TAK")
else:
print("NIE")
| 168 | 62 | 0 |
19099266
|
'''
Created on Jul 14, 2016
@author: Md. Rezwanul Haque
'''
s = input()
D = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}
for(c1,c2) in zip(s, s[::-1]):
if(D.get(c1, '') != c2):
print("NIE")
exit()
print("TAK")
|
Educational Codeforces Round 14
|
ICPC
| 2,016 | 1 | 256 |
s-palindrome
|
Let's call a string "s-palindrome" if it is symmetric about the middle of the string. For example, the string "oHo" is "s-palindrome", but the string "aa" is not. The string "aa" is not "s-palindrome", because the second half of it is not a mirror reflection of the first half.
English alphabet
You are given a string s. Check if the string is "s-palindrome".
|
The only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.
|
Print "TAK" if the string s is "s-palindrome" and "NIE" otherwise.
| null | null |
[{"input": "oXoxoXo", "output": "TAK"}, {"input": "bod", "output": "TAK"}, {"input": "ER", "output": "NIE"}]
| 1,600 |
["implementation", "strings"]
| 168 |
[{"input": "oXoxoXo\r\n", "output": "TAK\r\n"}, {"input": "bod\r\n", "output": "TAK\r\n"}, {"input": "ER\r\n", "output": "NIE\r\n"}, {"input": "o\r\n", "output": "TAK\r\n"}, {"input": "a\r\n", "output": "NIE\r\n"}, {"input": "opo\r\n", "output": "NIE\r\n"}, {"input": "HCMoxkgbNb\r\n", "output": "NIE\r\n"}, {"input": "vMhhXCMWDe\r\n", "output": "NIE\r\n"}, {"input": "iIcamjTRFH\r\n", "output": "NIE\r\n"}, {"input": "WvoWvvWovW\r\n", "output": "TAK\r\n"}, {"input": "WXxAdbAxXW\r\n", "output": "TAK\r\n"}, {"input": "vqMTUUTMpv\r\n", "output": "TAK\r\n"}, {"input": "iii\r\n", "output": "NIE\r\n"}, {"input": "AAWW\r\n", "output": "NIE\r\n"}, {"input": "ss\r\n", "output": "NIE\r\n"}, {"input": "i\r\n", "output": "NIE\r\n"}, {"input": "ii\r\n", "output": "NIE\r\n"}, {"input": "mm\r\n", "output": "NIE\r\n"}, {"input": "LJ\r\n", "output": "NIE\r\n"}, {"input": "m\r\n", "output": "NIE\r\n"}, {"input": "ioi\r\n", "output": "NIE\r\n"}, {"input": "OA\r\n", "output": "NIE\r\n"}, {"input": "aaaiaaa\r\n", "output": "NIE\r\n"}, {"input": "SS\r\n", "output": "NIE\r\n"}, {"input": "iiii\r\n", "output": "NIE\r\n"}, {"input": "ssops\r\n", "output": "NIE\r\n"}, {"input": "ssss\r\n", "output": "NIE\r\n"}, {"input": "ll\r\n", "output": "NIE\r\n"}, {"input": "s\r\n", "output": "NIE\r\n"}, {"input": "bb\r\n", "output": "NIE\r\n"}, {"input": "uu\r\n", "output": "NIE\r\n"}, {"input": "ZoZ\r\n", "output": "NIE\r\n"}, {"input": "mom\r\n", "output": "NIE\r\n"}, {"input": "uou\r\n", "output": "NIE\r\n"}, {"input": "u\r\n", "output": "NIE\r\n"}, {"input": "JL\r\n", "output": "NIE\r\n"}, {"input": "mOm\r\n", "output": "NIE\r\n"}, {"input": "llll\r\n", "output": "NIE\r\n"}, {"input": "ouo\r\n", "output": "NIE\r\n"}, {"input": "aa\r\n", "output": "NIE\r\n"}, {"input": "olo\r\n", "output": "NIE\r\n"}, {"input": "S\r\n", "output": "NIE\r\n"}, {"input": "lAl\r\n", "output": "NIE\r\n"}, {"input": "nnnn\r\n", "output": "NIE\r\n"}, {"input": "ZzZ\r\n", "output": "NIE\r\n"}, {"input": "bNd\r\n", "output": "NIE\r\n"}, {"input": "ZZ\r\n", "output": "NIE\r\n"}, {"input": "oNoNo\r\n", "output": "NIE\r\n"}, {"input": "l\r\n", "output": "NIE\r\n"}, {"input": "zz\r\n", "output": "NIE\r\n"}, {"input": "NON\r\n", "output": "NIE\r\n"}, {"input": "nn\r\n", "output": "NIE\r\n"}, {"input": "NoN\r\n", "output": "NIE\r\n"}, {"input": "sos\r\n", "output": "NIE\r\n"}, {"input": "lol\r\n", "output": "NIE\r\n"}, {"input": "mmm\r\n", "output": "NIE\r\n"}, {"input": "YAiAY\r\n", "output": "NIE\r\n"}, {"input": "ipIqi\r\n", "output": "NIE\r\n"}, {"input": "AAA\r\n", "output": "TAK\r\n"}, {"input": "uoOou\r\n", "output": "NIE\r\n"}, {"input": "SOS\r\n", "output": "NIE\r\n"}, {"input": "NN\r\n", "output": "NIE\r\n"}, {"input": "n\r\n", "output": "NIE\r\n"}, {"input": "h\r\n", "output": "NIE\r\n"}, {"input": "blld\r\n", "output": "NIE\r\n"}, {"input": "ipOqi\r\n", "output": "NIE\r\n"}, {"input": "pop\r\n", "output": "NIE\r\n"}, {"input": "BB\r\n", "output": "NIE\r\n"}, {"input": "OuO\r\n", "output": "NIE\r\n"}, {"input": "lxl\r\n", "output": "NIE\r\n"}, {"input": "Z\r\n", "output": "NIE\r\n"}, {"input": "vvivv\r\n", "output": "NIE\r\n"}, {"input": "nnnnnnnnnnnnn\r\n", "output": "NIE\r\n"}, {"input": "AA\r\n", "output": "TAK\r\n"}, {"input": "t\r\n", "output": "NIE\r\n"}, {"input": "z\r\n", "output": "NIE\r\n"}, {"input": "mmmAmmm\r\n", "output": "NIE\r\n"}, {"input": "qlililp\r\n", "output": "NIE\r\n"}, {"input": "mpOqm\r\n", "output": "NIE\r\n"}, {"input": "iiiiiiiiii\r\n", "output": "NIE\r\n"}, {"input": "BAAAB\r\n", "output": "NIE\r\n"}, {"input": "UA\r\n", "output": "NIE\r\n"}, {"input": "mmmmmmm\r\n", "output": "NIE\r\n"}, {"input": "NpOqN\r\n", "output": "NIE\r\n"}, {"input": "uOu\r\n", "output": "NIE\r\n"}, {"input": "uuu\r\n", "output": "NIE\r\n"}, {"input": "NAMAN\r\n", "output": "NIE\r\n"}, {"input": "lllll\r\n", "output": "NIE\r\n"}, {"input": "T\r\n", "output": "TAK\r\n"}, {"input": "mmmmmmmmmmmmmmmm\r\n", "output": "NIE\r\n"}, {"input": "AiiA\r\n", "output": "NIE\r\n"}, {"input": "iOi\r\n", "output": "NIE\r\n"}, {"input": "lll\r\n", "output": "NIE\r\n"}, {"input": "N\r\n", "output": "NIE\r\n"}, {"input": "viv\r\n", "output": "NIE\r\n"}, {"input": "oiio\r\n", "output": "NIE\r\n"}, {"input": "AiiiA\r\n", "output": "NIE\r\n"}, {"input": "NNNN\r\n", "output": "NIE\r\n"}, {"input": "ixi\r\n", "output": "NIE\r\n"}, {"input": "AuuA\r\n", "output": "NIE\r\n"}, {"input": "AAAANANAAAA\r\n", "output": "NIE\r\n"}, {"input": "mmmmm\r\n", "output": "NIE\r\n"}, {"input": "oYo\r\n", "output": "TAK\r\n"}, {"input": "dd\r\n", "output": "NIE\r\n"}, {"input": "A\r\n", "output": "TAK\r\n"}, {"input": "ioh\r\n", "output": "NIE\r\n"}, {"input": "mmmm\r\n", "output": "NIE\r\n"}, {"input": "uuuu\r\n", "output": "NIE\r\n"}, {"input": "puq\r\n", "output": "NIE\r\n"}, {"input": "rrrrrr\r\n", "output": "NIE\r\n"}, {"input": "c\r\n", "output": "NIE\r\n"}, {"input": "AbpA\r\n", "output": "NIE\r\n"}, {"input": "qAq\r\n", "output": "NIE\r\n"}, {"input": "tt\r\n", "output": "NIE\r\n"}, {"input": "mnmnm\r\n", "output": "NIE\r\n"}, {"input": "sss\r\n", "output": "NIE\r\n"}, {"input": "yy\r\n", "output": "NIE\r\n"}, {"input": "bob\r\n", "output": "NIE\r\n"}, {"input": "NAN\r\n", "output": "NIE\r\n"}, {"input": "mAm\r\n", "output": "NIE\r\n"}, {"input": "tAt\r\n", "output": "NIE\r\n"}, {"input": "yAy\r\n", "output": "NIE\r\n"}, {"input": "zAz\r\n", "output": "NIE\r\n"}, {"input": "aZ\r\n", "output": "NIE\r\n"}, {"input": "hh\r\n", "output": "NIE\r\n"}, {"input": "bbbb\r\n", "output": "NIE\r\n"}, {"input": "ZAZ\r\n", "output": "NIE\r\n"}, {"input": "Y\r\n", "output": "TAK\r\n"}, {"input": "AAMM\r\n", "output": "NIE\r\n"}, {"input": "lml\r\n", "output": "NIE\r\n"}, {"input": "AZA\r\n", "output": "NIE\r\n"}, {"input": "mXm\r\n", "output": "NIE\r\n"}, {"input": "bd\r\n", "output": "TAK\r\n"}, {"input": "H\r\n", "output": "TAK\r\n"}, {"input": "uvu\r\n", "output": "NIE\r\n"}, {"input": "dxxd\r\n", "output": "NIE\r\n"}, {"input": "dp\r\n", "output": "NIE\r\n"}, {"input": "vV\r\n", "output": "NIE\r\n"}, {"input": "vMo\r\n", "output": "NIE\r\n"}, {"input": "O\r\n", "output": "TAK\r\n"}, {"input": "vYv\r\n", "output": "TAK\r\n"}, {"input": "fv\r\n", "output": "NIE\r\n"}, {"input": "U\r\n", "output": "TAK\r\n"}, {"input": "iAi\r\n", "output": "NIE\r\n"}, {"input": "I\r\n", "output": "TAK\r\n"}, {"input": "VxrV\r\n", "output": "NIE\r\n"}, {"input": "POP\r\n", "output": "NIE\r\n"}, {"input": "bid\r\n", "output": "NIE\r\n"}, {"input": "bmd\r\n", "output": "NIE\r\n"}, {"input": "AiA\r\n", "output": "NIE\r\n"}, {"input": "mmmmmm\r\n", "output": "NIE\r\n"}, {"input": "XHX\r\n", "output": "TAK\r\n"}, {"input": "llllll\r\n", "output": "NIE\r\n"}, {"input": "aAa\r\n", "output": "NIE\r\n"}, {"input": "Db\r\n", "output": "NIE\r\n"}, {"input": "lOl\r\n", "output": "NIE\r\n"}, {"input": "bzd\r\n", "output": "NIE\r\n"}]
| false |
stdio
| null | true |
792/C
|
792
|
C
|
Python 3
|
TESTS
| 37 | 140 | 7,987,200 |
25858647
|
import sys
s = list(input())
digsum = 0
rem = [0 for i in range(len(s))]
for i in range(0, len(s)):
dig = ord(s[i]) - ord('0');
digsum += dig
rem[i] = dig % 3
currem = digsum % 3
if currem == 0:
print(''.join(s))
sys.exit()
if len(s) == 1:
print(-1)
sys.exit()
inds1 = []
inds2 = []
for i in range(len(rem) - 1, -1, -1):
if (rem[i] == 2 and len(inds2) < 2):
inds2.append(i)
if (rem[i] == 1 and len(inds1) < 2):
inds1.append(i)
inds2.sort()
inds1.sort()
vs = []
if currem == 1:
if( len (inds1) >= 1):
vs.append(s[:inds1[0]] + s[inds1[0] + 1:])
if len(inds2) == 2:
vs.append(s[:inds2[0]] + s[inds2[0] + 1: inds2[1]] + s[inds2[1] + 1:])
if currem == 2:
if( len (inds2) >= 1):
vs.append(s[:inds2[0]] + s[inds2[0] + 1:])
if len(inds1) == 2:
vs.append(s[:inds1[0]] + s[inds1[0] + 1: inds1[1]] + s[inds1[1] + 1:])
ans = -1
anslen = 0;
for i in range(len(vs)):
ln = len(vs[i])
for j in range(len(vs[i])):
if vs[i][j] != '0' or j == len(vs[i]) - 1:
break
ln -= 1
vs[i] = vs[i][-ln:]
if ln != 0 and (ans == -1 or anslen < ln):
anslen = ln
ans = i
if ans == -1:
print(-1)
else:
print(''.join(vs[ans]))
| 162 | 77 | 6,860,800 |
26445505
|
import re
s = input()
t = s.translate(str.maketrans("0123456789", "0120120120"))
x = (t.count('1') + t.count('2') * 2) % 3
if x:
res = ['']
l = t.rsplit("12"[x == 2], 1)
if len(l) == 2:
a = len(l[0])
res.append((s[:a], s[a + 1:]))
l = t.rsplit("12"[x == 1], 2)
if len(l) == 3:
a, b = map(len, l[:2])
res.append((s[:a], s[a + 1:a + b + 1], s[a + b + 2:]))
s = max((re.sub(r'^0*(\d)', r'\1', ''.join(e)) for e in res), key=len)
print(s or '-1')
|
Educational Codeforces Round 18
|
ICPC
| 2,017 | 1 | 256 |
Divide by Three
|
A positive integer number n is written on a blackboard. It consists of not more than 105 digits. You have to transform it into a beautiful number by erasing some of the digits, and you want to erase as few digits as possible.
The number is called beautiful if it consists of at least one digit, doesn't have leading zeroes and is a multiple of 3. For example, 0, 99, 10110 are beautiful numbers, and 00, 03, 122 are not.
Write a program which for the given n will find a beautiful number such that n can be transformed into this number by erasing as few digits as possible. You can erase an arbitraty set of digits. For example, they don't have to go one after another in the number n.
If it's impossible to obtain a beautiful number, print -1. If there are multiple answers, print any of them.
|
The first line of input contains n — a positive integer number without leading zeroes (1 ≤ n < 10100000).
|
Print one number — any beautiful number obtained by erasing as few as possible digits. If there is no answer, print - 1.
| null |
In the first example it is enough to erase only the first digit to obtain a multiple of 3. But if we erase the first digit, then we obtain a number with a leading zero. So the minimum number of digits to be erased is two.
|
[{"input": "1033", "output": "33"}, {"input": "10", "output": "0"}, {"input": "11", "output": "-1"}]
| 2,000 |
["dp", "greedy", "math", "number theory"]
| 162 |
[{"input": "1033\r\n", "output": "33\r\n"}, {"input": "10\r\n", "output": "0\r\n"}, {"input": "11\r\n", "output": "-1\r\n"}, {"input": "3\r\n", "output": "3\r\n"}, {"input": "1\r\n", "output": "-1\r\n"}, {"input": "117\r\n", "output": "117\r\n"}, {"input": "518\r\n", "output": "18\r\n"}, {"input": "327\r\n", "output": "327\r\n"}, {"input": "270461\r\n", "output": "70461\r\n"}, {"input": "609209\r\n", "output": "60909\r\n"}, {"input": "110930\r\n", "output": "930\r\n"}, {"input": "37616145150713688775\r\n", "output": "3616145150713688775\r\n"}, {"input": "98509135612114839419\r\n", "output": "9509135612114839419\r\n"}, {"input": "41674994051436988162\r\n", "output": "1674994051436988162\r\n"}, {"input": "82547062721736129804\r\n", "output": "82547062721736129804\r\n"}, {"input": "4902501252475186372406731932548506197390793597574544727433297197476846519276598727359617092494798814\r\n", "output": "490501252475186372406731932548506197390793597574544727433297197476846519276598727359617092494798814\r\n"}, {"input": "1291007209605301446874998623691572528836214969878676835460982410817526074579818247646933326771899122\r\n", "output": "1291007209605301446874998623691572528836214969878676835460982410817526074579818247646933326771899122\r\n"}, {"input": "5388306043547446322173224045662327678394712363272776811399689704247387317165308057863239568137902157\r\n", "output": "538830603547446322173224045662327678394712363272776811399689704247387317165308057863239568137902157\r\n"}, {"input": "20000111\r\n", "output": "200001\r\n"}, {"input": "100222\r\n", "output": "1002\r\n"}, {"input": "202\r\n", "output": "0\r\n"}, {"input": "100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000033\r\n", "output": "33\r\n"}, {"input": "101\r\n", "output": "0\r\n"}, {"input": "1000000222\r\n", "output": "10000002\r\n"}, {"input": "1001\r\n", "output": "0\r\n"}, {"input": "205\r\n", "output": "0\r\n"}, {"input": "102211\r\n", "output": "10221\r\n"}, {"input": "100000002022\r\n", "output": "1000000002\r\n"}, {"input": "20203\r\n", "output": "3\r\n"}, {"input": "1002001\r\n", "output": "100200\r\n"}, {"input": "10002223\r\n", "output": "100023\r\n"}, {"input": "1002223\r\n", "output": "10023\r\n"}, {"input": "100000231\r\n", "output": "10000023\r\n"}, {"input": "220\r\n", "output": "0\r\n"}, {"input": "322\r\n", "output": "3\r\n"}, {"input": "100000222\r\n", "output": "1000002\r\n"}, {"input": "10033\r\n", "output": "33\r\n"}, {"input": "2003302\r\n", "output": "330\r\n"}, {"input": "10011001\r\n", "output": "1001001\r\n"}, {"input": "20000000011001111\r\n", "output": "200000000001111\r\n"}, {"input": "100000000\r\n", "output": "0\r\n"}, {"input": "1000\r\n", "output": "0\r\n"}, {"input": "200000000000000000000000000008\r\n", "output": "0\r\n"}, {"input": "1000000000000222\r\n", "output": "10000000000002\r\n"}, {"input": "100000000000000000222\r\n", "output": "1000000000000000002\r\n"}, {"input": "29512\r\n", "output": "2952\r\n"}, {"input": "88888888888888\r\n", "output": "888888888888\r\n"}, {"input": "100000000000222\r\n", "output": "1000000000002\r\n"}, {"input": "11000000\r\n", "output": "0\r\n"}, {"input": "2200\r\n", "output": "0\r\n"}, {"input": "10000555\r\n", "output": "100005\r\n"}, {"input": "1000222\r\n", "output": "10002\r\n"}, {"input": "10021\r\n", "output": "1002\r\n"}, {"input": "223\r\n", "output": "3\r\n"}, {"input": "1013\r\n", "output": "3\r\n"}, {"input": "100020001\r\n", "output": "10002000\r\n"}, {"input": "20000000000000000000932\r\n", "output": "93\r\n"}, {"input": "1010\r\n", "output": "0\r\n"}, {"input": "2000000002222\r\n", "output": "20000000022\r\n"}, {"input": "10213\r\n", "output": "1023\r\n"}, {"input": "109111\r\n", "output": "10911\r\n"}, {"input": "1010101010\r\n", "output": "10001010\r\n"}, {"input": "300055\r\n", "output": "3000\r\n"}, {"input": "200200\r\n", "output": "0\r\n"}, {"input": "202222\r\n", "output": "2022\r\n"}, {"input": "4000888\r\n", "output": "40008\r\n"}, {"input": "200000111\r\n", "output": "2000001\r\n"}, {"input": "2000000111\r\n", "output": "20000001\r\n"}, {"input": "1000000\r\n", "output": "0\r\n"}, {"input": "1003301\r\n", "output": "330\r\n"}, {"input": "100001\r\n", "output": "0\r\n"}, {"input": "40000000000000000000888\r\n", "output": "400000000000000000008\r\n"}, {"input": "100000\r\n", "output": "0\r\n"}, {"input": "4000000888\r\n", "output": "40000008\r\n"}, {"input": "334733\r\n", "output": "3333\r\n"}, {"input": "1000002220\r\n", "output": "10000020\r\n"}, {"input": "100321\r\n", "output": "10032\r\n"}, {"input": "101111\r\n", "output": "1011\r\n"}, {"input": "100000000222\r\n", "output": "1000000002\r\n"}, {"input": "10001\r\n", "output": "0\r\n"}, {"input": "7\r\n", "output": "-1\r\n"}, {"input": "2000000000111\r\n", "output": "20000000001\r\n"}, {"input": "100000001\r\n", "output": "0\r\n"}, {"input": "10000000000222\r\n", "output": "100000000002\r\n"}, {"input": "200000000000000111\r\n", "output": "2000000000000001\r\n"}, {"input": "404044\r\n", "output": "40044\r\n"}, {"input": "30202\r\n", "output": "300\r\n"}, {"input": "20000000000000000111\r\n", "output": "200000000000000001\r\n"}, {"input": "707\r\n", "output": "0\r\n"}, {"input": "20000300000000003000050000003\r\n", "output": "30000000000300000000003\r\n"}, {"input": "400000888\r\n", "output": "4000008\r\n"}, {"input": "2888\r\n", "output": "888\r\n"}, {"input": "200111\r\n", "output": "2001\r\n"}, {"input": "10000000888\r\n", "output": "100000008\r\n"}, {"input": "40000888\r\n", "output": "400008\r\n"}, {"input": "40404044\r\n", "output": "400044\r\n"}, {"input": "5500000000\r\n", "output": "0\r\n"}, {"input": "100012\r\n", "output": "10002\r\n"}, {"input": "1000007\r\n", "output": "0\r\n"}, {"input": "200093\r\n", "output": "93\r\n"}, {"input": "10000000222\r\n", "output": "100000002\r\n"}, {"input": "20000000002\r\n", "output": "0\r\n"}, {"input": "74333\r\n", "output": "333\r\n"}, {"input": "200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\r\n", "output": "0\r\n"}, {"input": "10000000111\r\n", "output": "1000000011\r\n"}, {"input": "100007\r\n", "output": "0\r\n"}, {"input": "20000006711\r\n", "output": "200000061\r\n"}, {"input": "8059\r\n", "output": "9\r\n"}, {"input": "8008\r\n", "output": "0\r\n"}, {"input": "88\r\n", "output": "-1\r\n"}, {"input": "2002\r\n", "output": "0\r\n"}, {"input": "2000111\r\n", "output": "20001\r\n"}, {"input": "100000000100000002\r\n", "output": "10000000000000002\r\n"}, {"input": "1000000000000000000000000000000000\r\n", "output": "0\r\n"}, {"input": "10000000000000000222\r\n", "output": "100000000000000002\r\n"}, {"input": "1000001\r\n", "output": "0\r\n"}, {"input": "200000000000111\r\n", "output": "2000000000001\r\n"}, {"input": "2000000002\r\n", "output": "0\r\n"}, {"input": "2010000100001\r\n", "output": "10000100001\r\n"}, {"input": "200330\r\n", "output": "330\r\n"}, {"input": "10000222\r\n", "output": "100002\r\n"}, {"input": "2005\r\n", "output": "0\r\n"}, {"input": "100000000000822\r\n", "output": "1000000000002\r\n"}, {"input": "10000000000000000000000\r\n", "output": "0\r\n"}, {"input": "7046\r\n", "output": "6\r\n"}, {"input": "4000117\r\n", "output": "400017\r\n"}, {"input": "971\r\n", "output": "9\r\n"}, {"input": "404\r\n", "output": "0\r\n"}, {"input": "5\r\n", "output": "-1\r\n"}, {"input": "164\r\n", "output": "6\r\n"}, {"input": "140\r\n", "output": "0\r\n"}, {"input": "74\r\n", "output": "-1\r\n"}, {"input": "2058232\r\n", "output": "20232\r\n"}, {"input": "4\r\n", "output": "-1\r\n"}, {"input": "20206\r\n", "output": "6\r\n"}, {"input": "103310\r\n", "output": "330\r\n"}, {"input": "100\r\n", "output": "0\r\n"}, {"input": "417179\r\n", "output": "7179\r\n"}, {"input": "70558\r\n", "output": "558\r\n"}, {"input": "298\r\n", "output": "9\r\n"}, {"input": "7003\r\n", "output": "3\r\n"}, {"input": "2212\r\n", "output": "222\r\n"}, {"input": "1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001\r\n", "output": "0\r\n"}, {"input": "2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002\r\n", "output": "0\r\n"}, {"input": "1002200\r\n", "output": "100200\r\n"}, {"input": "1222\r\n", "output": "222\r\n"}, {"input": "101200100\r\n", "output": "10100100\r\n"}, {"input": "1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003\r\n", "output": "3\r\n"}, {"input": "20020201\r\n", "output": "2002020\r\n"}, {"input": "12122\r\n", "output": "1122\r\n"}, {"input": "20200\r\n", "output": "0\r\n"}, {"input": "2\r\n", "output": "-1\r\n"}, {"input": "1000000000000258\r\n", "output": "10000000000008\r\n"}]
| false |
stdio
|
import sys
def is_subsequence(s, t):
t_iter = iter(t)
try:
for c in s:
while next(t_iter) != c:
pass
return True
except StopIteration:
return False
def is_beautiful(s):
if not s:
return False
if s[0] == '0' and len(s) > 1:
return False
total = sum(int(c) for c in s)
return total % 3 == 0
def compute_max_length(n):
sum_digits = sum(int(c) for c in n)
sum_mod3 = sum_digits % 3
has_zero = '0' in n
if sum_mod3 == 0:
if n[0] != '0':
return len(n)
first_non_zero = next((i for i, c in enumerate(n) if c != '0'), None)
if first_non_zero is None:
return 1
return len(n) - first_non_zero
else:
candidates = []
for i, c in enumerate(n):
if int(c) % 3 == sum_mod3:
new_n = n[:i] + n[i+1:]
if not new_n:
continue
first_non_zero = next((j for j, ch in enumerate(new_n) if ch != '0'), None)
if first_non_zero is None:
candidates.append(1)
else:
candidates.append(len(new_n) - first_non_zero)
target_mod = (3 - sum_mod3) % 3
mod_digits = [i for i, c in enumerate(n) if int(c) % 3 == target_mod]
if len(mod_digits) >= 2:
i, j = mod_digits[-2], mod_digits[-1]
new_n = n[:i] + n[i+1:j] + n[j+1:]
if new_n:
first_non_zero = next((k for k, ch in enumerate(new_n) if ch != '0'), None)
if first_non_zero is None:
candidates.append(1)
else:
candidates.append(len(new_n) - first_non_zero)
if has_zero:
candidates.append(1)
return max(candidates) if candidates else 0
def main(input_path, output_path, submission_path):
with open(input_path, 'r') as f:
n = f.read().strip()
with open(submission_path, 'r') as f:
submission = f.read().strip()
if submission == '-1':
max_len = compute_max_length(n)
print(100 if max_len == 0 else 0)
else:
if not is_subsequence(submission, n) or not is_beautiful(submission):
print(0)
return
max_len = compute_max_length(n)
print(100 if len(submission) == max_len else 0)
if __name__ == '__main__':
input_path, output_path, submission_path = sys.argv[1], sys.argv[2], sys.argv[3]
main(input_path, output_path, submission_path)
| true |
818/C
|
818
|
C
|
Python 3
|
TESTS
| 6 | 61 | 5,632,000 |
34566012
|
def main():
# import sys
d = int(input())
n, m = [int(x) for x in input().split()]
point = []
for x in range(d):
point.append([int(x) for x in input().split()])
point[-1].append(x+1)
q = [int(x) for x in input().split()]
def cntl(n):
# print(max(n[0],n[2]))
return min(n[0],n[2])
point.sort(key = cntl)
t = 0
debag = 0
def relax():
global debag
debag = 1
return
if(t == q[0]):
relax()
else:
id1 = 0
for i in range(len(point)-1):
if(min(point[i][0],point[i][2]) < min(point[i+1][0],point[i+1][2])):
t+=1
if(t<=q[0]):
id1 = i+1
point = point[id1:]
if(len(point)==1):
print(point[0][4])
return
# sys.exit(0)
if(t == q[1]):
relax()
else:
id1 = len(point)
for i in range(len(point)-1,0,-1):
if(max(point[i][0],point[i][2]) < max(point[i-1][0],point[i-1][2])):
t+=1
if(t<=q[0]):
id1 = i
point = point[:id1]
if(len(point)==1):
print(point[0][4])
return
def cntb(n):
return min(n[1],n[3])
point.sort(key = cntb)
if(t == q[2]):
relax()
else:
id1 = 0
for i in range(len(point)-1):
if(min(point[i][1],point[i][3]) < min(point[i+1][1],point[i+1][3])):
t+=1
if(t<=q[2]):
id1 = i+1
point = point[id1:]
if(len(point)==1):
print(point[0][4])
return
if(t == q[3]):
relax()
else:
id1 = len(point)
for i in range(len(point)-1,0,-1):
if(max(point[i][1],point[i][3]) < max(point[i-1][1],point[i-1][3])):
t+=1
if(t<=q[3]):
id1 = i
point = point[:id1]
if(len(point)!=1):
print(-1)
else:
print(point[0][4])
main()
| 212 | 560 | 17,920,000 |
93166980
|
import sys
from bisect import bisect_left, bisect_right
d = int(sys.stdin.buffer.readline().decode('utf-8'))
n, m = map(int, sys.stdin.buffer.readline().decode('utf-8').split())
a = [list(map(int, sys.stdin.buffer.readline().decode('utf-8').split()))
for _ in range(d)]
cnt = list(map(int, sys.stdin.buffer.readline().decode('utf-8').split()))
left, right, top, bottom = [], [], [], []
for x1, y1, x2, y2 in a:
left.append(min(x1, x2))
right.append(-max(x1, x2))
top.append(min(y1, y2))
bottom.append(-max(y1, y2))
left.sort()
right.sort()
top.sort()
bottom.sort()
for i, (x1, y1, x2, y2) in enumerate(a, start=1):
c = [
bisect_left(left, max(x1, x2)) - (1 if x1 != x2 else 0),
bisect_left(right, -min(x1, x2)) - (1 if x1 != x2 else 0),
bisect_left(top, max(y1, y2)) - (1 if y1 != y2 else 0),
bisect_left(bottom, -min(y1, y2)) - (1 if y1 != y2 else 0)
]
if c == cnt:
print(i)
exit()
print(-1)
|
Educational Codeforces Round 24
|
ICPC
| 2,017 | 1 | 256 |
Sofa Thief
|
Yet another round on DecoForces is coming! Grandpa Maks wanted to participate in it but someone has stolen his precious sofa! And how can one perform well with such a major loss?
Fortunately, the thief had left a note for Grandpa Maks. This note got Maks to the sofa storehouse. Still he had no idea which sofa belongs to him as they all looked the same!
The storehouse is represented as matrix n × m. Every sofa takes two neighbouring by some side cells. No cell is covered by more than one sofa. There can be empty cells.
Sofa A is standing to the left of sofa B if there exist two such cells a and b that xa < xb, a is covered by A and b is covered by B. Sofa A is standing to the top of sofa B if there exist two such cells a and b that ya < yb, a is covered by A and b is covered by B. Right and bottom conditions are declared the same way.
Note that in all conditions A ≠ B. Also some sofa A can be both to the top of another sofa B and to the bottom of it. The same is for left and right conditions.
The note also stated that there are cntl sofas to the left of Grandpa Maks's sofa, cntr — to the right, cntt — to the top and cntb — to the bottom.
Grandpa Maks asks you to help him to identify his sofa. It is guaranteed that there is no more than one sofa of given conditions.
Output the number of Grandpa Maks's sofa. If there is no such sofa that all the conditions are met for it then output -1.
|
The first line contains one integer number d (1 ≤ d ≤ 105) — the number of sofas in the storehouse.
The second line contains two integer numbers n, m (1 ≤ n, m ≤ 105) — the size of the storehouse.
Next d lines contains four integer numbers x1, y1, x2, y2 (1 ≤ x1, x2 ≤ n, 1 ≤ y1, y2 ≤ m) — coordinates of the i-th sofa. It is guaranteed that cells (x1, y1) and (x2, y2) have common side, (x1, y1) ≠ (x2, y2) and no cell is covered by more than one sofa.
The last line contains four integer numbers cntl, cntr, cntt, cntb (0 ≤ cntl, cntr, cntt, cntb ≤ d - 1).
|
Print the number of the sofa for which all the conditions are met. Sofas are numbered 1 through d as given in input. If there is no such sofa then print -1.
| null |
Let's consider the second example.
- The first sofa has 0 to its left, 2 sofas to its right ((1, 1) is to the left of both (5, 5) and (5, 4)), 0 to its top and 2 to its bottom (both 2nd and 3rd sofas are below).
- The second sofa has cntl = 2, cntr = 1, cntt = 2 and cntb = 0.
- The third sofa has cntl = 2, cntr = 1, cntt = 1 and cntb = 1.
So the second one corresponds to the given conditions.
In the third example
- The first sofa has cntl = 1, cntr = 1, cntt = 0 and cntb = 1.
- The second sofa has cntl = 1, cntr = 1, cntt = 1 and cntb = 0.
And there is no sofa with the set (1, 0, 0, 0) so the answer is -1.
|
[{"input": "2\n3 2\n3 1 3 2\n1 2 2 2\n1 0 0 1", "output": "1"}, {"input": "3\n10 10\n1 2 1 1\n5 5 6 5\n6 4 5 4\n2 1 2 0", "output": "2"}, {"input": "2\n2 2\n2 1 1 1\n1 2 2 2\n1 0 0 0", "output": "-1"}]
| 2,000 |
["brute force", "implementation"]
| 212 |
[{"input": "2\r\n3 2\r\n3 1 3 2\r\n1 2 2 2\r\n1 0 0 1\r\n", "output": "1\r\n"}, {"input": "3\r\n10 10\r\n1 2 1 1\r\n5 5 6 5\r\n6 4 5 4\r\n2 1 2 0\r\n", "output": "2\r\n"}, {"input": "2\r\n2 2\r\n2 1 1 1\r\n1 2 2 2\r\n1 0 0 0\r\n", "output": "-1\r\n"}, {"input": "1\r\n1 2\r\n1 1 1 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n2 1\r\n2 1 1 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n1000 1000\r\n63 902 63 901\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "6\r\n10 10\r\n3 6 3 7\r\n4 9 5 9\r\n5 4 5 3\r\n7 1 8 1\r\n9 10 8 10\r\n7 7 7 8\r\n0 5 2 3\r\n", "output": "1\r\n"}, {"input": "2\r\n4 4\r\n3 1 3 2\r\n2 2 2 1\r\n0 0 0 0\r\n", "output": "-1\r\n"}, {"input": "2\r\n2 2\r\n1 1 1 2\r\n2 1 2 2\r\n0 1 1 1\r\n", "output": "1\r\n"}, {"input": "2\r\n2 2\r\n1 1 1 2\r\n2 1 2 2\r\n1 0 1 1\r\n", "output": "2\r\n"}, {"input": "2\r\n2 2\r\n1 1 1 2\r\n2 1 2 2\r\n0 1 1 0\r\n", "output": "-1\r\n"}, {"input": "1\r\n1 2\r\n1 2 1 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n1 3\r\n1 2 1 3\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n1 4\r\n1 2 1 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n1 5\r\n1 4 1 3\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n1 6\r\n1 6 1 5\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n1 7\r\n1 6 1 7\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n2 1\r\n2 1 1 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n2 2\r\n2 2 2 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n2 3\r\n1 2 1 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n2 4\r\n2 3 2 4\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n2 5\r\n2 4 1 4\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n2 6\r\n2 1 1 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n2 7\r\n2 7 2 6\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n3 1\r\n2 1 3 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n3 2\r\n1 1 2 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n3 3\r\n3 2 3 3\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n3 4\r\n2 1 2 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n3 5\r\n2 2 2 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n3 6\r\n1 4 2 4\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n3 7\r\n2 2 1 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n4 1\r\n1 1 2 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n4 2\r\n1 1 1 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n4 3\r\n4 3 4 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n4 4\r\n3 2 3 3\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n4 5\r\n1 2 2 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n4 6\r\n4 3 4 4\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n4 7\r\n3 6 4 6\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n5 1\r\n2 1 1 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n5 2\r\n5 1 4 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n5 3\r\n4 2 3 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n5 4\r\n2 4 3 4\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n5 5\r\n4 1 3 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n5 6\r\n3 3 3 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n5 7\r\n1 6 1 7\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n6 1\r\n6 1 5 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n6 2\r\n4 2 5 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n6 3\r\n1 2 1 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n6 4\r\n2 2 3 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n6 5\r\n6 1 6 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n6 6\r\n4 1 3 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n6 7\r\n6 7 6 6\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n7 1\r\n6 1 7 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n7 2\r\n4 2 4 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n7 3\r\n7 1 7 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n7 4\r\n3 3 3 4\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n7 5\r\n6 4 7 4\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n7 6\r\n2 2 2 3\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n7 7\r\n1 3 2 3\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n1 4\r\n1 4 1 3\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "2\r\n1 5\r\n1 5 1 4\r\n1 1 1 2\r\n0 0 1 0\r\n", "output": "1\r\n"}, {"input": "1\r\n1 6\r\n1 2 1 3\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "2\r\n1 7\r\n1 7 1 6\r\n1 4 1 5\r\n0 0 1 0\r\n", "output": "1\r\n"}, {"input": "1\r\n2 2\r\n2 1 2 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "2\r\n2 3\r\n2 3 1 3\r\n1 2 2 2\r\n0 0 0 1\r\n", "output": "-1\r\n"}, {"input": "2\r\n2 4\r\n2 2 2 1\r\n2 4 1 4\r\n0 1 1 0\r\n", "output": "2\r\n"}, {"input": "2\r\n2 5\r\n2 2 2 1\r\n1 3 1 4\r\n1 0 0 1\r\n", "output": "1\r\n"}, {"input": "2\r\n2 6\r\n1 2 1 1\r\n2 1 2 2\r\n1 0 1 1\r\n", "output": "2\r\n"}, {"input": "2\r\n2 7\r\n2 4 2 5\r\n2 7 1 7\r\n0 0 1 0\r\n", "output": "-1\r\n"}, {"input": "2\r\n3 2\r\n1 2 2 2\r\n1 1 2 1\r\n0 0 1 0\r\n", "output": "-1\r\n"}, {"input": "2\r\n3 3\r\n2 1 1 1\r\n1 2 2 2\r\n0 0 0 1\r\n", "output": "-1\r\n"}, {"input": "1\r\n3 4\r\n1 3 1 4\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "2\r\n3 5\r\n1 2 1 1\r\n3 1 2 1\r\n0 1 0 0\r\n", "output": "-1\r\n"}, {"input": "2\r\n3 6\r\n3 2 3 1\r\n3 6 2 6\r\n0 0 0 1\r\n", "output": "-1\r\n"}, {"input": "2\r\n3 7\r\n3 6 3 5\r\n2 4 2 3\r\n0 1 0 1\r\n", "output": "2\r\n"}, {"input": "2\r\n4 1\r\n3 1 4 1\r\n1 1 2 1\r\n0 1 0 0\r\n", "output": "2\r\n"}, {"input": "1\r\n4 2\r\n4 1 3 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "2\r\n4 3\r\n3 1 2 1\r\n1 2 1 1\r\n1 0 0 1\r\n", "output": "1\r\n"}, {"input": "1\r\n4 4\r\n4 1 3 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "2\r\n4 5\r\n3 1 4 1\r\n4 2 4 3\r\n0 1 0 1\r\n", "output": "1\r\n"}, {"input": "2\r\n4 6\r\n2 3 2 4\r\n2 6 2 5\r\n0 0 0 1\r\n", "output": "1\r\n"}, {"input": "2\r\n4 7\r\n1 7 2 7\r\n4 1 3 1\r\n1 0 0 1\r\n", "output": "2\r\n"}, {"input": "2\r\n5 1\r\n2 1 1 1\r\n5 1 4 1\r\n1 0 0 0\r\n", "output": "2\r\n"}, {"input": "2\r\n5 2\r\n1 1 1 2\r\n2 2 3 2\r\n1 0 1 0\r\n", "output": "2\r\n"}, {"input": "2\r\n5 3\r\n1 1 1 2\r\n5 2 5 3\r\n0 1 0 1\r\n", "output": "1\r\n"}, {"input": "2\r\n5 4\r\n4 4 4 3\r\n4 2 5 2\r\n0 0 0 1\r\n", "output": "-1\r\n"}, {"input": "2\r\n5 5\r\n3 4 3 5\r\n4 1 3 1\r\n1 0 0 1\r\n", "output": "2\r\n"}, {"input": "2\r\n5 6\r\n2 4 3 4\r\n5 2 5 1\r\n0 1 1 0\r\n", "output": "1\r\n"}, {"input": "2\r\n5 7\r\n2 7 1 7\r\n2 4 3 4\r\n0 0 0 1\r\n", "output": "-1\r\n"}, {"input": "1\r\n6 1\r\n3 1 4 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n6 2\r\n5 1 6 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "2\r\n6 3\r\n2 2 2 1\r\n3 2 3 1\r\n0 1 0 0\r\n", "output": "-1\r\n"}, {"input": "2\r\n6 4\r\n6 4 5 4\r\n4 3 4 2\r\n1 0 1 0\r\n", "output": "1\r\n"}, {"input": "2\r\n6 5\r\n2 4 2 3\r\n5 4 4 4\r\n1 0 0 0\r\n", "output": "-1\r\n"}, {"input": "2\r\n6 6\r\n6 6 5 6\r\n1 3 1 2\r\n1 0 1 0\r\n", "output": "1\r\n"}, {"input": "2\r\n6 7\r\n1 3 1 4\r\n5 2 5 1\r\n0 1 1 0\r\n", "output": "1\r\n"}, {"input": "1\r\n7 1\r\n6 1 7 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "2\r\n7 2\r\n5 2 4 2\r\n2 1 2 2\r\n0 1 0 1\r\n", "output": "2\r\n"}, {"input": "2\r\n7 3\r\n7 2 6 2\r\n1 2 2 2\r\n0 1 0 0\r\n", "output": "2\r\n"}, {"input": "2\r\n7 4\r\n6 1 6 2\r\n2 3 1 3\r\n1 0 0 1\r\n", "output": "1\r\n"}, {"input": "2\r\n7 5\r\n2 3 1 3\r\n4 3 3 3\r\n1 0 0 0\r\n", "output": "2\r\n"}, {"input": "2\r\n7 6\r\n5 1 6 1\r\n2 5 3 5\r\n0 1 1 0\r\n", "output": "2\r\n"}, {"input": "2\r\n7 7\r\n2 3 2 4\r\n5 4 5 5\r\n0 1 0 1\r\n", "output": "1\r\n"}, {"input": "1\r\n1 6\r\n1 4 1 5\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n1 7\r\n1 1 1 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n2 3\r\n1 1 2 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "3\r\n2 4\r\n1 3 1 4\r\n2 4 2 3\r\n2 2 1 2\r\n0 0 0 2\r\n", "output": "-1\r\n"}, {"input": "3\r\n2 5\r\n2 5 1 5\r\n2 3 2 2\r\n1 1 2 1\r\n0 0 1 1\r\n", "output": "-1\r\n"}, {"input": "1\r\n2 6\r\n1 3 1 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "3\r\n2 7\r\n2 6 2 7\r\n1 4 1 5\r\n2 2 2 3\r\n1 0 0 2\r\n", "output": "3\r\n"}, {"input": "1\r\n3 2\r\n3 2 2 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n3 3\r\n2 3 3 3\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "2\r\n3 4\r\n3 1 3 2\r\n3 4 2 4\r\n0 1 1 0\r\n", "output": "2\r\n"}, {"input": "3\r\n3 5\r\n3 4 3 5\r\n3 2 3 1\r\n1 3 2 3\r\n1 0 0 2\r\n", "output": "2\r\n"}, {"input": "2\r\n3 6\r\n1 1 2 1\r\n1 3 2 3\r\n0 0 1 0\r\n", "output": "-1\r\n"}, {"input": "1\r\n3 7\r\n2 1 3 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "3\r\n4 2\r\n1 2 2 2\r\n3 1 4 1\r\n3 2 4 2\r\n0 2 1 0\r\n", "output": "1\r\n"}, {"input": "2\r\n4 3\r\n4 3 3 3\r\n2 2 2 1\r\n1 0 1 0\r\n", "output": "1\r\n"}, {"input": "3\r\n4 4\r\n2 3 2 4\r\n4 4 4 3\r\n2 2 1 2\r\n0 2 0 2\r\n", "output": "3\r\n"}, {"input": "3\r\n4 5\r\n2 4 1 4\r\n1 3 1 2\r\n2 1 1 1\r\n2 1 2 0\r\n", "output": "1\r\n"}, {"input": "2\r\n4 6\r\n3 3 4 3\r\n4 6 3 6\r\n0 0 1 0\r\n", "output": "-1\r\n"}, {"input": "3\r\n4 7\r\n2 7 3 7\r\n4 4 4 5\r\n3 4 3 3\r\n2 0 0 1\r\n", "output": "-1\r\n"}, {"input": "1\r\n5 2\r\n1 1 1 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "3\r\n5 3\r\n1 2 1 3\r\n5 2 5 3\r\n1 1 2 1\r\n1 1 0 2\r\n", "output": "3\r\n"}, {"input": "3\r\n5 4\r\n4 1 4 2\r\n1 1 1 2\r\n5 1 5 2\r\n0 2 2 2\r\n", "output": "2\r\n"}, {"input": "2\r\n5 5\r\n3 3 4 3\r\n5 2 4 2\r\n0 0 0 1\r\n", "output": "-1\r\n"}, {"input": "3\r\n5 6\r\n5 2 4 2\r\n1 1 1 2\r\n5 1 4 1\r\n2 1 2 0\r\n", "output": "1\r\n"}, {"input": "3\r\n5 7\r\n5 4 4 4\r\n1 2 1 1\r\n2 5 2 4\r\n0 2 0 2\r\n", "output": "2\r\n"}, {"input": "2\r\n6 1\r\n3 1 2 1\r\n4 1 5 1\r\n1 0 0 0\r\n", "output": "2\r\n"}, {"input": "3\r\n6 2\r\n5 2 5 1\r\n6 1 6 2\r\n3 2 2 2\r\n2 0 0 0\r\n", "output": "-1\r\n"}, {"input": "3\r\n6 3\r\n2 1 2 2\r\n6 2 6 1\r\n1 2 1 1\r\n1 1 0 0\r\n", "output": "-1\r\n"}, {"input": "3\r\n6 4\r\n1 2 2 2\r\n3 1 3 2\r\n2 3 2 4\r\n0 2 0 1\r\n", "output": "-1\r\n"}, {"input": "3\r\n6 5\r\n2 2 2 1\r\n5 4 6 4\r\n4 4 4 3\r\n2 0 1 0\r\n", "output": "-1\r\n"}, {"input": "3\r\n6 6\r\n4 4 4 5\r\n2 3 1 3\r\n3 4 3 3\r\n0 2 0 1\r\n", "output": "-1\r\n"}, {"input": "3\r\n6 7\r\n3 4 3 5\r\n5 4 6 4\r\n4 5 4 4\r\n1 1 1 0\r\n", "output": "-1\r\n"}, {"input": "3\r\n7 1\r\n4 1 5 1\r\n3 1 2 1\r\n6 1 7 1\r\n2 0 0 0\r\n", "output": "3\r\n"}, {"input": "3\r\n7 2\r\n7 1 7 2\r\n5 1 4 1\r\n3 1 3 2\r\n0 2 2 1\r\n", "output": "3\r\n"}, {"input": "3\r\n7 3\r\n2 3 3 3\r\n5 1 6 1\r\n7 2 7 1\r\n0 2 2 0\r\n", "output": "1\r\n"}, {"input": "3\r\n7 4\r\n5 4 6 4\r\n6 1 6 2\r\n5 1 4 1\r\n0 2 0 1\r\n", "output": "-1\r\n"}, {"input": "3\r\n7 5\r\n2 2 2 3\r\n7 1 7 2\r\n1 4 1 3\r\n2 0 0 2\r\n", "output": "2\r\n"}, {"input": "3\r\n7 6\r\n2 6 2 5\r\n2 2 1 2\r\n4 4 3 4\r\n0 1 0 2\r\n", "output": "-1\r\n"}, {"input": "1\r\n7 7\r\n5 4 6 4\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n2 4\r\n1 1 1 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "3\r\n2 5\r\n2 4 2 5\r\n2 1 1 1\r\n2 2 1 2\r\n0 1 1 1\r\n", "output": "-1\r\n"}, {"input": "3\r\n2 6\r\n1 3 1 2\r\n2 2 2 1\r\n2 5 2 6\r\n1 0 0 1\r\n", "output": "-1\r\n"}, {"input": "1\r\n2 7\r\n2 1 1 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "4\r\n3 3\r\n3 1 2 1\r\n3 3 2 3\r\n1 3 1 2\r\n3 2 2 2\r\n0 3 2 1\r\n", "output": "3\r\n"}, {"input": "4\r\n3 4\r\n2 4 3 4\r\n3 3 3 2\r\n1 2 2 2\r\n3 1 2 1\r\n0 3 1 1\r\n", "output": "-1\r\n"}, {"input": "4\r\n3 5\r\n2 3 1 3\r\n1 5 1 4\r\n2 5 2 4\r\n2 2 1 2\r\n1 0 3 1\r\n", "output": "-1\r\n"}, {"input": "2\r\n3 6\r\n1 5 1 6\r\n3 5 3 4\r\n1 0 0 1\r\n", "output": "2\r\n"}, {"input": "4\r\n3 7\r\n1 2 1 1\r\n3 3 3 4\r\n2 1 3 1\r\n2 6 3 6\r\n1 1 3 0\r\n", "output": "-1\r\n"}, {"input": "3\r\n4 2\r\n2 2 3 2\r\n1 1 1 2\r\n4 2 4 1\r\n2 0 0 0\r\n", "output": "-1\r\n"}, {"input": "2\r\n4 3\r\n1 2 1 1\r\n3 1 3 2\r\n0 1 0 0\r\n", "output": "-1\r\n"}, {"input": "2\r\n4 4\r\n3 1 4 1\r\n3 4 4 4\r\n0 0 1 0\r\n", "output": "-1\r\n"}, {"input": "2\r\n4 5\r\n3 1 3 2\r\n2 1 2 2\r\n1 0 0 0\r\n", "output": "-1\r\n"}, {"input": "4\r\n4 6\r\n1 5 2 5\r\n3 4 3 5\r\n1 1 1 2\r\n4 1 4 2\r\n2 1 2 0\r\n", "output": "-1\r\n"}, {"input": "3\r\n4 7\r\n4 2 4 3\r\n1 4 1 3\r\n1 2 1 1\r\n0 1 0 2\r\n", "output": "3\r\n"}, {"input": "3\r\n5 2\r\n1 1 2 1\r\n3 1 4 1\r\n3 2 2 2\r\n1 1 2 0\r\n", "output": "3\r\n"}, {"input": "1\r\n5 3\r\n2 1 1 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "2\r\n5 4\r\n1 2 1 3\r\n5 4 5 3\r\n1 0 0 0\r\n", "output": "-1\r\n"}, {"input": "4\r\n5 5\r\n5 1 4 1\r\n3 3 3 4\r\n1 3 2 3\r\n2 1 2 2\r\n0 2 0 2\r\n", "output": "-1\r\n"}, {"input": "3\r\n5 6\r\n4 6 4 5\r\n1 5 1 6\r\n5 5 5 4\r\n0 2 1 0\r\n", "output": "-1\r\n"}, {"input": "3\r\n5 7\r\n1 5 1 4\r\n2 5 3 5\r\n4 4 3 4\r\n2 0 0 1\r\n", "output": "-1\r\n"}, {"input": "2\r\n6 2\r\n1 1 2 1\r\n6 1 5 1\r\n0 1 0 0\r\n", "output": "1\r\n"}, {"input": "2\r\n6 3\r\n3 3 4 3\r\n5 3 6 3\r\n1 0 0 0\r\n", "output": "2\r\n"}, {"input": "4\r\n6 4\r\n3 2 3 1\r\n4 1 5 1\r\n6 1 6 2\r\n2 2 1 2\r\n2 1 0 3\r\n", "output": "2\r\n"}, {"input": "3\r\n6 5\r\n5 4 5 3\r\n1 3 1 2\r\n2 1 1 1\r\n1 1 0 2\r\n", "output": "3\r\n"}, {"input": "3\r\n6 6\r\n1 2 2 2\r\n1 5 1 6\r\n6 6 6 5\r\n0 1 1 0\r\n", "output": "-1\r\n"}, {"input": "4\r\n6 7\r\n5 4 5 5\r\n4 4 3 4\r\n2 1 1 1\r\n6 3 6 2\r\n1 2 2 0\r\n", "output": "-1\r\n"}, {"input": "3\r\n7 2\r\n5 1 6 1\r\n2 2 3 2\r\n2 1 1 1\r\n2 0 0 1\r\n", "output": "1\r\n"}, {"input": "4\r\n7 3\r\n6 1 7 1\r\n3 1 4 1\r\n6 2 5 2\r\n2 1 1 1\r\n2 1 3 0\r\n", "output": "3\r\n"}, {"input": "4\r\n7 4\r\n4 2 3 2\r\n5 2 5 3\r\n3 4 2 4\r\n6 2 6 1\r\n3 0 0 3\r\n", "output": "4\r\n"}, {"input": "1\r\n7 5\r\n6 5 7 5\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "3\r\n7 6\r\n2 6 1 6\r\n2 4 2 5\r\n3 2 2 2\r\n1 0 0 2\r\n", "output": "-1\r\n"}, {"input": "4\r\n7 7\r\n4 6 5 6\r\n7 4 7 5\r\n7 1 7 2\r\n2 6 2 5\r\n1 2 2 0\r\n", "output": "-1\r\n"}, {"input": "4\r\n2 5\r\n1 3 2 3\r\n1 5 1 4\r\n1 2 2 2\r\n1 1 2 1\r\n0 0 3 0\r\n", "output": "-1\r\n"}, {"input": "2\r\n2 6\r\n2 1 2 2\r\n1 2 1 1\r\n1 0 0 0\r\n", "output": "-1\r\n"}, {"input": "4\r\n2 7\r\n1 2 2 2\r\n2 6 2 5\r\n2 3 1 3\r\n1 5 1 4\r\n0 3 2 1\r\n", "output": "4\r\n"}, {"input": "3\r\n3 4\r\n2 2 3 2\r\n1 2 1 3\r\n3 1 2 1\r\n1 0 0 2\r\n", "output": "-1\r\n"}, {"input": "4\r\n3 5\r\n3 1 3 2\r\n2 3 2 2\r\n2 5 1 5\r\n3 4 3 3\r\n2 0 2 1\r\n", "output": "4\r\n"}, {"input": "4\r\n3 6\r\n3 1 2 1\r\n1 2 2 2\r\n2 3 3 3\r\n1 5 1 4\r\n0 2 3 0\r\n", "output": "-1\r\n"}, {"input": "3\r\n3 7\r\n3 2 2 2\r\n3 5 2 5\r\n3 7 2 7\r\n0 0 1 1\r\n", "output": "-1\r\n"}, {"input": "4\r\n4 3\r\n3 2 3 3\r\n4 2 4 1\r\n1 2 1 3\r\n3 1 2 1\r\n0 3 1 0\r\n", "output": "-1\r\n"}, {"input": "4\r\n4 4\r\n2 4 1 4\r\n1 2 1 3\r\n4 3 4 4\r\n3 3 3 2\r\n0 2 0 2\r\n", "output": "-1\r\n"}, {"input": "3\r\n4 5\r\n4 5 3 5\r\n4 2 3 2\r\n2 1 3 1\r\n0 1 0 2\r\n", "output": "-1\r\n"}, {"input": "5\r\n4 6\r\n4 3 3 3\r\n4 2 4 1\r\n3 6 2 6\r\n2 4 2 3\r\n1 1 1 2\r\n1 2 2 1\r\n", "output": "-1\r\n"}, {"input": "2\r\n4 7\r\n2 6 2 7\r\n2 5 2 4\r\n0 0 1 0\r\n", "output": "1\r\n"}, {"input": "1\r\n5 2\r\n2 2 2 1\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "1\r\n5 3\r\n4 2 3 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "2\r\n5 4\r\n3 1 2 1\r\n3 4 3 3\r\n0 0 1 0\r\n", "output": "-1\r\n"}, {"input": "1\r\n5 5\r\n3 4 2 4\r\n0 0 0 0\r\n", "output": "1\r\n"}, {"input": "4\r\n5 6\r\n5 3 5 2\r\n4 5 3 5\r\n1 2 1 3\r\n1 1 2 1\r\n3 0 1 1\r\n", "output": "-1\r\n"}, {"input": "5\r\n5 7\r\n5 5 5 6\r\n2 4 2 5\r\n2 3 1 3\r\n4 7 3 7\r\n4 1 5 1\r\n0 3 2 2\r\n", "output": "-1\r\n"}, {"input": "2\r\n6 2\r\n5 2 5 1\r\n4 2 4 1\r\n1 0 1 1\r\n", "output": "1\r\n"}, {"input": "3\r\n6 3\r\n2 2 2 3\r\n3 3 4 3\r\n4 2 4 1\r\n1 1 1 0\r\n", "output": "-1\r\n"}, {"input": "4\r\n6 4\r\n2 3 1 3\r\n4 4 3 4\r\n5 4 6 4\r\n1 4 2 4\r\n0 2 1 0\r\n", "output": "-1\r\n"}, {"input": "5\r\n6 5\r\n1 5 1 4\r\n4 2 4 3\r\n2 2 1 2\r\n2 3 1 3\r\n3 2 3 3\r\n0 2 0 3\r\n", "output": "-1\r\n"}, {"input": "4\r\n6 6\r\n4 3 4 2\r\n2 3 2 4\r\n4 4 5 4\r\n5 2 5 3\r\n0 3 2 0\r\n", "output": "-1\r\n"}, {"input": "5\r\n6 7\r\n1 6 1 5\r\n3 6 2 6\r\n5 1 4 1\r\n2 5 3 5\r\n5 3 5 2\r\n3 0 0 4\r\n", "output": "-1\r\n"}, {"input": "2\r\n7 2\r\n3 1 4 1\r\n7 1 7 2\r\n0 1 0 1\r\n", "output": "1\r\n"}, {"input": "2\r\n7 3\r\n6 3 7 3\r\n4 1 3 1\r\n0 1 0 1\r\n", "output": "2\r\n"}, {"input": "5\r\n7 4\r\n3 1 2 1\r\n5 2 5 1\r\n4 2 3 2\r\n7 3 6 3\r\n4 3 5 3\r\n1 2 2 2\r\n", "output": "-1\r\n"}, {"input": "5\r\n7 5\r\n5 3 5 2\r\n3 5 2 5\r\n1 3 1 4\r\n3 3 3 4\r\n4 1 3 1\r\n1 2 4 0\r\n", "output": "-1\r\n"}, {"input": "5\r\n7 6\r\n5 5 5 4\r\n6 1 7 1\r\n5 2 5 1\r\n1 1 2 1\r\n4 6 3 6\r\n1 3 4 0\r\n", "output": "5\r\n"}, {"input": "3\r\n7 7\r\n2 6 1 6\r\n7 2 6 2\r\n3 1 3 2\r\n2 0 1 1\r\n", "output": "2\r\n"}]
| false |
stdio
| null | true |
691/B
|
691
|
B
|
PyPy 3
|
TESTS
| 28 | 109 | 20,480,000 |
127190638
|
from collections import defaultdict
import sys
input = sys.stdin.readline
d = defaultdict(lambda : "?")
for i in list("AHIMmOoTUVvWwXxY"):
d[i] = i
d["b"] = "d"
d["d"] = "b"
d["p"] = "q"
d["q"] = "p"
s = list(input().rstrip())
n = len(s)
ans = "TAK"
for i in range(n):
if not d[s[i]] == s[n - i - 1]:
ans = "NIE"
break
print(ans)
| 168 | 62 | 0 |
19110383
|
import sys
pairs = [
'AA', 'HH', 'II', 'MM', 'OO', 'TT', 'UU', 'VV', 'WW', 'XX', 'YY',
'bd', 'db', 'oo', 'pq', 'qp', 'vv', 'ww', 'xx'
]
s = input()
l, r = 0, len(s) - 1
while l <= r:
if s[l] + s[r] not in pairs:
print("NIE")
sys.exit(0)
l += 1
r -= 1
print("TAK")
|
Educational Codeforces Round 14
|
ICPC
| 2,016 | 1 | 256 |
s-palindrome
|
Let's call a string "s-palindrome" if it is symmetric about the middle of the string. For example, the string "oHo" is "s-palindrome", but the string "aa" is not. The string "aa" is not "s-palindrome", because the second half of it is not a mirror reflection of the first half.
English alphabet
You are given a string s. Check if the string is "s-palindrome".
|
The only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.
|
Print "TAK" if the string s is "s-palindrome" and "NIE" otherwise.
| null | null |
[{"input": "oXoxoXo", "output": "TAK"}, {"input": "bod", "output": "TAK"}, {"input": "ER", "output": "NIE"}]
| 1,600 |
["implementation", "strings"]
| 168 |
[{"input": "oXoxoXo\r\n", "output": "TAK\r\n"}, {"input": "bod\r\n", "output": "TAK\r\n"}, {"input": "ER\r\n", "output": "NIE\r\n"}, {"input": "o\r\n", "output": "TAK\r\n"}, {"input": "a\r\n", "output": "NIE\r\n"}, {"input": "opo\r\n", "output": "NIE\r\n"}, {"input": "HCMoxkgbNb\r\n", "output": "NIE\r\n"}, {"input": "vMhhXCMWDe\r\n", "output": "NIE\r\n"}, {"input": "iIcamjTRFH\r\n", "output": "NIE\r\n"}, {"input": "WvoWvvWovW\r\n", "output": "TAK\r\n"}, {"input": "WXxAdbAxXW\r\n", "output": "TAK\r\n"}, {"input": "vqMTUUTMpv\r\n", "output": "TAK\r\n"}, {"input": "iii\r\n", "output": "NIE\r\n"}, {"input": "AAWW\r\n", "output": "NIE\r\n"}, {"input": "ss\r\n", "output": "NIE\r\n"}, {"input": "i\r\n", "output": "NIE\r\n"}, {"input": "ii\r\n", "output": "NIE\r\n"}, {"input": "mm\r\n", "output": "NIE\r\n"}, {"input": "LJ\r\n", "output": "NIE\r\n"}, {"input": "m\r\n", "output": "NIE\r\n"}, {"input": "ioi\r\n", "output": "NIE\r\n"}, {"input": "OA\r\n", "output": "NIE\r\n"}, {"input": "aaaiaaa\r\n", "output": "NIE\r\n"}, {"input": "SS\r\n", "output": "NIE\r\n"}, {"input": "iiii\r\n", "output": "NIE\r\n"}, {"input": "ssops\r\n", "output": "NIE\r\n"}, {"input": "ssss\r\n", "output": "NIE\r\n"}, {"input": "ll\r\n", "output": "NIE\r\n"}, {"input": "s\r\n", "output": "NIE\r\n"}, {"input": "bb\r\n", "output": "NIE\r\n"}, {"input": "uu\r\n", "output": "NIE\r\n"}, {"input": "ZoZ\r\n", "output": "NIE\r\n"}, {"input": "mom\r\n", "output": "NIE\r\n"}, {"input": "uou\r\n", "output": "NIE\r\n"}, {"input": "u\r\n", "output": "NIE\r\n"}, {"input": "JL\r\n", "output": "NIE\r\n"}, {"input": "mOm\r\n", "output": "NIE\r\n"}, {"input": "llll\r\n", "output": "NIE\r\n"}, {"input": "ouo\r\n", "output": "NIE\r\n"}, {"input": "aa\r\n", "output": "NIE\r\n"}, {"input": "olo\r\n", "output": "NIE\r\n"}, {"input": "S\r\n", "output": "NIE\r\n"}, {"input": "lAl\r\n", "output": "NIE\r\n"}, {"input": "nnnn\r\n", "output": "NIE\r\n"}, {"input": "ZzZ\r\n", "output": "NIE\r\n"}, {"input": "bNd\r\n", "output": "NIE\r\n"}, {"input": "ZZ\r\n", "output": "NIE\r\n"}, {"input": "oNoNo\r\n", "output": "NIE\r\n"}, {"input": "l\r\n", "output": "NIE\r\n"}, {"input": "zz\r\n", "output": "NIE\r\n"}, {"input": "NON\r\n", "output": "NIE\r\n"}, {"input": "nn\r\n", "output": "NIE\r\n"}, {"input": "NoN\r\n", "output": "NIE\r\n"}, {"input": "sos\r\n", "output": "NIE\r\n"}, {"input": "lol\r\n", "output": "NIE\r\n"}, {"input": "mmm\r\n", "output": "NIE\r\n"}, {"input": "YAiAY\r\n", "output": "NIE\r\n"}, {"input": "ipIqi\r\n", "output": "NIE\r\n"}, {"input": "AAA\r\n", "output": "TAK\r\n"}, {"input": "uoOou\r\n", "output": "NIE\r\n"}, {"input": "SOS\r\n", "output": "NIE\r\n"}, {"input": "NN\r\n", "output": "NIE\r\n"}, {"input": "n\r\n", "output": "NIE\r\n"}, {"input": "h\r\n", "output": "NIE\r\n"}, {"input": "blld\r\n", "output": "NIE\r\n"}, {"input": "ipOqi\r\n", "output": "NIE\r\n"}, {"input": "pop\r\n", "output": "NIE\r\n"}, {"input": "BB\r\n", "output": "NIE\r\n"}, {"input": "OuO\r\n", "output": "NIE\r\n"}, {"input": "lxl\r\n", "output": "NIE\r\n"}, {"input": "Z\r\n", "output": "NIE\r\n"}, {"input": "vvivv\r\n", "output": "NIE\r\n"}, {"input": "nnnnnnnnnnnnn\r\n", "output": "NIE\r\n"}, {"input": "AA\r\n", "output": "TAK\r\n"}, {"input": "t\r\n", "output": "NIE\r\n"}, {"input": "z\r\n", "output": "NIE\r\n"}, {"input": "mmmAmmm\r\n", "output": "NIE\r\n"}, {"input": "qlililp\r\n", "output": "NIE\r\n"}, {"input": "mpOqm\r\n", "output": "NIE\r\n"}, {"input": "iiiiiiiiii\r\n", "output": "NIE\r\n"}, {"input": "BAAAB\r\n", "output": "NIE\r\n"}, {"input": "UA\r\n", "output": "NIE\r\n"}, {"input": "mmmmmmm\r\n", "output": "NIE\r\n"}, {"input": "NpOqN\r\n", "output": "NIE\r\n"}, {"input": "uOu\r\n", "output": "NIE\r\n"}, {"input": "uuu\r\n", "output": "NIE\r\n"}, {"input": "NAMAN\r\n", "output": "NIE\r\n"}, {"input": "lllll\r\n", "output": "NIE\r\n"}, {"input": "T\r\n", "output": "TAK\r\n"}, {"input": "mmmmmmmmmmmmmmmm\r\n", "output": "NIE\r\n"}, {"input": "AiiA\r\n", "output": "NIE\r\n"}, {"input": "iOi\r\n", "output": "NIE\r\n"}, {"input": "lll\r\n", "output": "NIE\r\n"}, {"input": "N\r\n", "output": "NIE\r\n"}, {"input": "viv\r\n", "output": "NIE\r\n"}, {"input": "oiio\r\n", "output": "NIE\r\n"}, {"input": "AiiiA\r\n", "output": "NIE\r\n"}, {"input": "NNNN\r\n", "output": "NIE\r\n"}, {"input": "ixi\r\n", "output": "NIE\r\n"}, {"input": "AuuA\r\n", "output": "NIE\r\n"}, {"input": "AAAANANAAAA\r\n", "output": "NIE\r\n"}, {"input": "mmmmm\r\n", "output": "NIE\r\n"}, {"input": "oYo\r\n", "output": "TAK\r\n"}, {"input": "dd\r\n", "output": "NIE\r\n"}, {"input": "A\r\n", "output": "TAK\r\n"}, {"input": "ioh\r\n", "output": "NIE\r\n"}, {"input": "mmmm\r\n", "output": "NIE\r\n"}, {"input": "uuuu\r\n", "output": "NIE\r\n"}, {"input": "puq\r\n", "output": "NIE\r\n"}, {"input": "rrrrrr\r\n", "output": "NIE\r\n"}, {"input": "c\r\n", "output": "NIE\r\n"}, {"input": "AbpA\r\n", "output": "NIE\r\n"}, {"input": "qAq\r\n", "output": "NIE\r\n"}, {"input": "tt\r\n", "output": "NIE\r\n"}, {"input": "mnmnm\r\n", "output": "NIE\r\n"}, {"input": "sss\r\n", "output": "NIE\r\n"}, {"input": "yy\r\n", "output": "NIE\r\n"}, {"input": "bob\r\n", "output": "NIE\r\n"}, {"input": "NAN\r\n", "output": "NIE\r\n"}, {"input": "mAm\r\n", "output": "NIE\r\n"}, {"input": "tAt\r\n", "output": "NIE\r\n"}, {"input": "yAy\r\n", "output": "NIE\r\n"}, {"input": "zAz\r\n", "output": "NIE\r\n"}, {"input": "aZ\r\n", "output": "NIE\r\n"}, {"input": "hh\r\n", "output": "NIE\r\n"}, {"input": "bbbb\r\n", "output": "NIE\r\n"}, {"input": "ZAZ\r\n", "output": "NIE\r\n"}, {"input": "Y\r\n", "output": "TAK\r\n"}, {"input": "AAMM\r\n", "output": "NIE\r\n"}, {"input": "lml\r\n", "output": "NIE\r\n"}, {"input": "AZA\r\n", "output": "NIE\r\n"}, {"input": "mXm\r\n", "output": "NIE\r\n"}, {"input": "bd\r\n", "output": "TAK\r\n"}, {"input": "H\r\n", "output": "TAK\r\n"}, {"input": "uvu\r\n", "output": "NIE\r\n"}, {"input": "dxxd\r\n", "output": "NIE\r\n"}, {"input": "dp\r\n", "output": "NIE\r\n"}, {"input": "vV\r\n", "output": "NIE\r\n"}, {"input": "vMo\r\n", "output": "NIE\r\n"}, {"input": "O\r\n", "output": "TAK\r\n"}, {"input": "vYv\r\n", "output": "TAK\r\n"}, {"input": "fv\r\n", "output": "NIE\r\n"}, {"input": "U\r\n", "output": "TAK\r\n"}, {"input": "iAi\r\n", "output": "NIE\r\n"}, {"input": "I\r\n", "output": "TAK\r\n"}, {"input": "VxrV\r\n", "output": "NIE\r\n"}, {"input": "POP\r\n", "output": "NIE\r\n"}, {"input": "bid\r\n", "output": "NIE\r\n"}, {"input": "bmd\r\n", "output": "NIE\r\n"}, {"input": "AiA\r\n", "output": "NIE\r\n"}, {"input": "mmmmmm\r\n", "output": "NIE\r\n"}, {"input": "XHX\r\n", "output": "TAK\r\n"}, {"input": "llllll\r\n", "output": "NIE\r\n"}, {"input": "aAa\r\n", "output": "NIE\r\n"}, {"input": "Db\r\n", "output": "NIE\r\n"}, {"input": "lOl\r\n", "output": "NIE\r\n"}, {"input": "bzd\r\n", "output": "NIE\r\n"}]
| false |
stdio
| null | true |
691/B
|
691
|
B
|
PyPy 3
|
TESTS
| 28 | 140 | 20,172,800 |
80008474
|
def f(s):
i=0
n=len(s)
j = int(n)-1
S = {'A','H','I','M','m','O','o','T','U','V','v','W','w','X','x','Y'}
while(i<=j):
if((s[i]=='b' and s[j]=='d') or (s[i]=='d' and s[j]=='b')):
i+=1
j-=1
continue
if((s[i]=='p' and s[j]=='q') or (s[i]=='q' and s[j]=='p')):
i+=1
j-=1
continue
if(s[i]!=s[j] or (s[i] not in S) or (s[j] not in S)):
return False
i+=1
j-=1
return True
s=input()
if(f(s)):print('TAK')
else:print('NIE')
| 168 | 62 | 0 |
148521856
|
s = input()
print(all([
s[i] + s[-i-1] in "AA.HH.II.MM.OO.oo.TT.UU.VV.vv.WW.ww.XX.xx.YY.bd.db.pq.qp"
for i in range(len(s))
]) and "TAK" or "NIE")
|
Educational Codeforces Round 14
|
ICPC
| 2,016 | 1 | 256 |
s-palindrome
|
Let's call a string "s-palindrome" if it is symmetric about the middle of the string. For example, the string "oHo" is "s-palindrome", but the string "aa" is not. The string "aa" is not "s-palindrome", because the second half of it is not a mirror reflection of the first half.
English alphabet
You are given a string s. Check if the string is "s-palindrome".
|
The only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.
|
Print "TAK" if the string s is "s-palindrome" and "NIE" otherwise.
| null | null |
[{"input": "oXoxoXo", "output": "TAK"}, {"input": "bod", "output": "TAK"}, {"input": "ER", "output": "NIE"}]
| 1,600 |
["implementation", "strings"]
| 168 |
[{"input": "oXoxoXo\r\n", "output": "TAK\r\n"}, {"input": "bod\r\n", "output": "TAK\r\n"}, {"input": "ER\r\n", "output": "NIE\r\n"}, {"input": "o\r\n", "output": "TAK\r\n"}, {"input": "a\r\n", "output": "NIE\r\n"}, {"input": "opo\r\n", "output": "NIE\r\n"}, {"input": "HCMoxkgbNb\r\n", "output": "NIE\r\n"}, {"input": "vMhhXCMWDe\r\n", "output": "NIE\r\n"}, {"input": "iIcamjTRFH\r\n", "output": "NIE\r\n"}, {"input": "WvoWvvWovW\r\n", "output": "TAK\r\n"}, {"input": "WXxAdbAxXW\r\n", "output": "TAK\r\n"}, {"input": "vqMTUUTMpv\r\n", "output": "TAK\r\n"}, {"input": "iii\r\n", "output": "NIE\r\n"}, {"input": "AAWW\r\n", "output": "NIE\r\n"}, {"input": "ss\r\n", "output": "NIE\r\n"}, {"input": "i\r\n", "output": "NIE\r\n"}, {"input": "ii\r\n", "output": "NIE\r\n"}, {"input": "mm\r\n", "output": "NIE\r\n"}, {"input": "LJ\r\n", "output": "NIE\r\n"}, {"input": "m\r\n", "output": "NIE\r\n"}, {"input": "ioi\r\n", "output": "NIE\r\n"}, {"input": "OA\r\n", "output": "NIE\r\n"}, {"input": "aaaiaaa\r\n", "output": "NIE\r\n"}, {"input": "SS\r\n", "output": "NIE\r\n"}, {"input": "iiii\r\n", "output": "NIE\r\n"}, {"input": "ssops\r\n", "output": "NIE\r\n"}, {"input": "ssss\r\n", "output": "NIE\r\n"}, {"input": "ll\r\n", "output": "NIE\r\n"}, {"input": "s\r\n", "output": "NIE\r\n"}, {"input": "bb\r\n", "output": "NIE\r\n"}, {"input": "uu\r\n", "output": "NIE\r\n"}, {"input": "ZoZ\r\n", "output": "NIE\r\n"}, {"input": "mom\r\n", "output": "NIE\r\n"}, {"input": "uou\r\n", "output": "NIE\r\n"}, {"input": "u\r\n", "output": "NIE\r\n"}, {"input": "JL\r\n", "output": "NIE\r\n"}, {"input": "mOm\r\n", "output": "NIE\r\n"}, {"input": "llll\r\n", "output": "NIE\r\n"}, {"input": "ouo\r\n", "output": "NIE\r\n"}, {"input": "aa\r\n", "output": "NIE\r\n"}, {"input": "olo\r\n", "output": "NIE\r\n"}, {"input": "S\r\n", "output": "NIE\r\n"}, {"input": "lAl\r\n", "output": "NIE\r\n"}, {"input": "nnnn\r\n", "output": "NIE\r\n"}, {"input": "ZzZ\r\n", "output": "NIE\r\n"}, {"input": "bNd\r\n", "output": "NIE\r\n"}, {"input": "ZZ\r\n", "output": "NIE\r\n"}, {"input": "oNoNo\r\n", "output": "NIE\r\n"}, {"input": "l\r\n", "output": "NIE\r\n"}, {"input": "zz\r\n", "output": "NIE\r\n"}, {"input": "NON\r\n", "output": "NIE\r\n"}, {"input": "nn\r\n", "output": "NIE\r\n"}, {"input": "NoN\r\n", "output": "NIE\r\n"}, {"input": "sos\r\n", "output": "NIE\r\n"}, {"input": "lol\r\n", "output": "NIE\r\n"}, {"input": "mmm\r\n", "output": "NIE\r\n"}, {"input": "YAiAY\r\n", "output": "NIE\r\n"}, {"input": "ipIqi\r\n", "output": "NIE\r\n"}, {"input": "AAA\r\n", "output": "TAK\r\n"}, {"input": "uoOou\r\n", "output": "NIE\r\n"}, {"input": "SOS\r\n", "output": "NIE\r\n"}, {"input": "NN\r\n", "output": "NIE\r\n"}, {"input": "n\r\n", "output": "NIE\r\n"}, {"input": "h\r\n", "output": "NIE\r\n"}, {"input": "blld\r\n", "output": "NIE\r\n"}, {"input": "ipOqi\r\n", "output": "NIE\r\n"}, {"input": "pop\r\n", "output": "NIE\r\n"}, {"input": "BB\r\n", "output": "NIE\r\n"}, {"input": "OuO\r\n", "output": "NIE\r\n"}, {"input": "lxl\r\n", "output": "NIE\r\n"}, {"input": "Z\r\n", "output": "NIE\r\n"}, {"input": "vvivv\r\n", "output": "NIE\r\n"}, {"input": "nnnnnnnnnnnnn\r\n", "output": "NIE\r\n"}, {"input": "AA\r\n", "output": "TAK\r\n"}, {"input": "t\r\n", "output": "NIE\r\n"}, {"input": "z\r\n", "output": "NIE\r\n"}, {"input": "mmmAmmm\r\n", "output": "NIE\r\n"}, {"input": "qlililp\r\n", "output": "NIE\r\n"}, {"input": "mpOqm\r\n", "output": "NIE\r\n"}, {"input": "iiiiiiiiii\r\n", "output": "NIE\r\n"}, {"input": "BAAAB\r\n", "output": "NIE\r\n"}, {"input": "UA\r\n", "output": "NIE\r\n"}, {"input": "mmmmmmm\r\n", "output": "NIE\r\n"}, {"input": "NpOqN\r\n", "output": "NIE\r\n"}, {"input": "uOu\r\n", "output": "NIE\r\n"}, {"input": "uuu\r\n", "output": "NIE\r\n"}, {"input": "NAMAN\r\n", "output": "NIE\r\n"}, {"input": "lllll\r\n", "output": "NIE\r\n"}, {"input": "T\r\n", "output": "TAK\r\n"}, {"input": "mmmmmmmmmmmmmmmm\r\n", "output": "NIE\r\n"}, {"input": "AiiA\r\n", "output": "NIE\r\n"}, {"input": "iOi\r\n", "output": "NIE\r\n"}, {"input": "lll\r\n", "output": "NIE\r\n"}, {"input": "N\r\n", "output": "NIE\r\n"}, {"input": "viv\r\n", "output": "NIE\r\n"}, {"input": "oiio\r\n", "output": "NIE\r\n"}, {"input": "AiiiA\r\n", "output": "NIE\r\n"}, {"input": "NNNN\r\n", "output": "NIE\r\n"}, {"input": "ixi\r\n", "output": "NIE\r\n"}, {"input": "AuuA\r\n", "output": "NIE\r\n"}, {"input": "AAAANANAAAA\r\n", "output": "NIE\r\n"}, {"input": "mmmmm\r\n", "output": "NIE\r\n"}, {"input": "oYo\r\n", "output": "TAK\r\n"}, {"input": "dd\r\n", "output": "NIE\r\n"}, {"input": "A\r\n", "output": "TAK\r\n"}, {"input": "ioh\r\n", "output": "NIE\r\n"}, {"input": "mmmm\r\n", "output": "NIE\r\n"}, {"input": "uuuu\r\n", "output": "NIE\r\n"}, {"input": "puq\r\n", "output": "NIE\r\n"}, {"input": "rrrrrr\r\n", "output": "NIE\r\n"}, {"input": "c\r\n", "output": "NIE\r\n"}, {"input": "AbpA\r\n", "output": "NIE\r\n"}, {"input": "qAq\r\n", "output": "NIE\r\n"}, {"input": "tt\r\n", "output": "NIE\r\n"}, {"input": "mnmnm\r\n", "output": "NIE\r\n"}, {"input": "sss\r\n", "output": "NIE\r\n"}, {"input": "yy\r\n", "output": "NIE\r\n"}, {"input": "bob\r\n", "output": "NIE\r\n"}, {"input": "NAN\r\n", "output": "NIE\r\n"}, {"input": "mAm\r\n", "output": "NIE\r\n"}, {"input": "tAt\r\n", "output": "NIE\r\n"}, {"input": "yAy\r\n", "output": "NIE\r\n"}, {"input": "zAz\r\n", "output": "NIE\r\n"}, {"input": "aZ\r\n", "output": "NIE\r\n"}, {"input": "hh\r\n", "output": "NIE\r\n"}, {"input": "bbbb\r\n", "output": "NIE\r\n"}, {"input": "ZAZ\r\n", "output": "NIE\r\n"}, {"input": "Y\r\n", "output": "TAK\r\n"}, {"input": "AAMM\r\n", "output": "NIE\r\n"}, {"input": "lml\r\n", "output": "NIE\r\n"}, {"input": "AZA\r\n", "output": "NIE\r\n"}, {"input": "mXm\r\n", "output": "NIE\r\n"}, {"input": "bd\r\n", "output": "TAK\r\n"}, {"input": "H\r\n", "output": "TAK\r\n"}, {"input": "uvu\r\n", "output": "NIE\r\n"}, {"input": "dxxd\r\n", "output": "NIE\r\n"}, {"input": "dp\r\n", "output": "NIE\r\n"}, {"input": "vV\r\n", "output": "NIE\r\n"}, {"input": "vMo\r\n", "output": "NIE\r\n"}, {"input": "O\r\n", "output": "TAK\r\n"}, {"input": "vYv\r\n", "output": "TAK\r\n"}, {"input": "fv\r\n", "output": "NIE\r\n"}, {"input": "U\r\n", "output": "TAK\r\n"}, {"input": "iAi\r\n", "output": "NIE\r\n"}, {"input": "I\r\n", "output": "TAK\r\n"}, {"input": "VxrV\r\n", "output": "NIE\r\n"}, {"input": "POP\r\n", "output": "NIE\r\n"}, {"input": "bid\r\n", "output": "NIE\r\n"}, {"input": "bmd\r\n", "output": "NIE\r\n"}, {"input": "AiA\r\n", "output": "NIE\r\n"}, {"input": "mmmmmm\r\n", "output": "NIE\r\n"}, {"input": "XHX\r\n", "output": "TAK\r\n"}, {"input": "llllll\r\n", "output": "NIE\r\n"}, {"input": "aAa\r\n", "output": "NIE\r\n"}, {"input": "Db\r\n", "output": "NIE\r\n"}, {"input": "lOl\r\n", "output": "NIE\r\n"}, {"input": "bzd\r\n", "output": "NIE\r\n"}]
| false |
stdio
| null | true |
792/C
|
792
|
C
|
PyPy 3
|
TESTS
| 36 | 139 | 30,208,000 |
26737037
|
def f(n, r, k):
tmp = n
for t in range(k):
for i in range(len(tmp) - 1, -1, -1):
if int(tmp[i]) % 3 == r:
tmp = tmp[:i] + tmp[i + 1:]
break
for i in range(len(tmp) - 1):
if int(tmp[i]) != 0:
return ''.join(tmp[i:])
if len(tmp) == 0 or 0 < int(tmp[len(tmp) - 1]):
return ''
else:
return '0'
n = list(input())
cnt = {i: 0 for i in range(3)}
for d in n:
cnt[int(d) % 3] += 1
r = (cnt[1] + 2 * cnt[2]) % 3
if r == 0:
print(''.join(n))
else:
ans = []
if 0 < cnt[r]:
ans.append(f(n, r, 1))
if 1 < cnt[3 - r]:
ans.append(f(n, 3 - r, 2))
if len(ans) == 0 or len(''.join(ans)) == 0:
print(-1)
elif len(ans[-1]) <= len(ans[0]):
print(ans[0])
else:
print(ans[-1])
| 162 | 109 | 6,246,400 |
28276110
|
n = list(input())
leng = 0
mp=[0,0,0]
for x in n:
leng += 1
mp[int(x)%3]+=1
tot = (mp[1]+2*mp[2])%3
if tot == 0:
print("".join(n))
exit()
if mp[tot] == 0:
do = tot ^ 3
cnt = 2
else:
if mp[tot] == 1 and int(n[0])%3==tot and n[1:3] == ['0','0']:
do =tot^3
cnt = 2
if mp[do] == 0:
do = tot
cnt = 1
else:
do = tot
cnt =1
index = leng-1
if cnt>=leng:
print(-1)
exit()
for x in range(cnt):
while int(n[index])%3 != do:
index-=1
n[index] = ""
index -=1
index = 0
ans = "".join(n)
while ans[index] == '0' and index<leng-cnt-1:
index+=1
print(ans[index:])
|
Educational Codeforces Round 18
|
ICPC
| 2,017 | 1 | 256 |
Divide by Three
|
A positive integer number n is written on a blackboard. It consists of not more than 105 digits. You have to transform it into a beautiful number by erasing some of the digits, and you want to erase as few digits as possible.
The number is called beautiful if it consists of at least one digit, doesn't have leading zeroes and is a multiple of 3. For example, 0, 99, 10110 are beautiful numbers, and 00, 03, 122 are not.
Write a program which for the given n will find a beautiful number such that n can be transformed into this number by erasing as few digits as possible. You can erase an arbitraty set of digits. For example, they don't have to go one after another in the number n.
If it's impossible to obtain a beautiful number, print -1. If there are multiple answers, print any of them.
|
The first line of input contains n — a positive integer number without leading zeroes (1 ≤ n < 10100000).
|
Print one number — any beautiful number obtained by erasing as few as possible digits. If there is no answer, print - 1.
| null |
In the first example it is enough to erase only the first digit to obtain a multiple of 3. But if we erase the first digit, then we obtain a number with a leading zero. So the minimum number of digits to be erased is two.
|
[{"input": "1033", "output": "33"}, {"input": "10", "output": "0"}, {"input": "11", "output": "-1"}]
| 2,000 |
["dp", "greedy", "math", "number theory"]
| 162 |
[{"input": "1033\r\n", "output": "33\r\n"}, {"input": "10\r\n", "output": "0\r\n"}, {"input": "11\r\n", "output": "-1\r\n"}, {"input": "3\r\n", "output": "3\r\n"}, {"input": "1\r\n", "output": "-1\r\n"}, {"input": "117\r\n", "output": "117\r\n"}, {"input": "518\r\n", "output": "18\r\n"}, {"input": "327\r\n", "output": "327\r\n"}, {"input": "270461\r\n", "output": "70461\r\n"}, {"input": "609209\r\n", "output": "60909\r\n"}, {"input": "110930\r\n", "output": "930\r\n"}, {"input": "37616145150713688775\r\n", "output": "3616145150713688775\r\n"}, {"input": "98509135612114839419\r\n", "output": "9509135612114839419\r\n"}, {"input": "41674994051436988162\r\n", "output": "1674994051436988162\r\n"}, {"input": "82547062721736129804\r\n", "output": "82547062721736129804\r\n"}, {"input": "4902501252475186372406731932548506197390793597574544727433297197476846519276598727359617092494798814\r\n", "output": "490501252475186372406731932548506197390793597574544727433297197476846519276598727359617092494798814\r\n"}, {"input": "1291007209605301446874998623691572528836214969878676835460982410817526074579818247646933326771899122\r\n", "output": "1291007209605301446874998623691572528836214969878676835460982410817526074579818247646933326771899122\r\n"}, {"input": "5388306043547446322173224045662327678394712363272776811399689704247387317165308057863239568137902157\r\n", "output": "538830603547446322173224045662327678394712363272776811399689704247387317165308057863239568137902157\r\n"}, {"input": "20000111\r\n", "output": "200001\r\n"}, {"input": "100222\r\n", "output": "1002\r\n"}, {"input": "202\r\n", "output": "0\r\n"}, {"input": "100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000033\r\n", "output": "33\r\n"}, {"input": "101\r\n", "output": "0\r\n"}, {"input": "1000000222\r\n", "output": "10000002\r\n"}, {"input": "1001\r\n", "output": "0\r\n"}, {"input": "205\r\n", "output": "0\r\n"}, {"input": "102211\r\n", "output": "10221\r\n"}, {"input": "100000002022\r\n", "output": "1000000002\r\n"}, {"input": "20203\r\n", "output": "3\r\n"}, {"input": "1002001\r\n", "output": "100200\r\n"}, {"input": "10002223\r\n", "output": "100023\r\n"}, {"input": "1002223\r\n", "output": "10023\r\n"}, {"input": "100000231\r\n", "output": "10000023\r\n"}, {"input": "220\r\n", "output": "0\r\n"}, {"input": "322\r\n", "output": "3\r\n"}, {"input": "100000222\r\n", "output": "1000002\r\n"}, {"input": "10033\r\n", "output": "33\r\n"}, {"input": "2003302\r\n", "output": "330\r\n"}, {"input": "10011001\r\n", "output": "1001001\r\n"}, {"input": "20000000011001111\r\n", "output": "200000000001111\r\n"}, {"input": "100000000\r\n", "output": "0\r\n"}, {"input": "1000\r\n", "output": "0\r\n"}, {"input": "200000000000000000000000000008\r\n", "output": "0\r\n"}, {"input": "1000000000000222\r\n", "output": "10000000000002\r\n"}, {"input": "100000000000000000222\r\n", "output": "1000000000000000002\r\n"}, {"input": "29512\r\n", "output": "2952\r\n"}, {"input": "88888888888888\r\n", "output": "888888888888\r\n"}, {"input": "100000000000222\r\n", "output": "1000000000002\r\n"}, {"input": "11000000\r\n", "output": "0\r\n"}, {"input": "2200\r\n", "output": "0\r\n"}, {"input": "10000555\r\n", "output": "100005\r\n"}, {"input": "1000222\r\n", "output": "10002\r\n"}, {"input": "10021\r\n", "output": "1002\r\n"}, {"input": "223\r\n", "output": "3\r\n"}, {"input": "1013\r\n", "output": "3\r\n"}, {"input": "100020001\r\n", "output": "10002000\r\n"}, {"input": "20000000000000000000932\r\n", "output": "93\r\n"}, {"input": "1010\r\n", "output": "0\r\n"}, {"input": "2000000002222\r\n", "output": "20000000022\r\n"}, {"input": "10213\r\n", "output": "1023\r\n"}, {"input": "109111\r\n", "output": "10911\r\n"}, {"input": "1010101010\r\n", "output": "10001010\r\n"}, {"input": "300055\r\n", "output": "3000\r\n"}, {"input": "200200\r\n", "output": "0\r\n"}, {"input": "202222\r\n", "output": "2022\r\n"}, {"input": "4000888\r\n", "output": "40008\r\n"}, {"input": "200000111\r\n", "output": "2000001\r\n"}, {"input": "2000000111\r\n", "output": "20000001\r\n"}, {"input": "1000000\r\n", "output": "0\r\n"}, {"input": "1003301\r\n", "output": "330\r\n"}, {"input": "100001\r\n", "output": "0\r\n"}, {"input": "40000000000000000000888\r\n", "output": "400000000000000000008\r\n"}, {"input": "100000\r\n", "output": "0\r\n"}, {"input": "4000000888\r\n", "output": "40000008\r\n"}, {"input": "334733\r\n", "output": "3333\r\n"}, {"input": "1000002220\r\n", "output": "10000020\r\n"}, {"input": "100321\r\n", "output": "10032\r\n"}, {"input": "101111\r\n", "output": "1011\r\n"}, {"input": "100000000222\r\n", "output": "1000000002\r\n"}, {"input": "10001\r\n", "output": "0\r\n"}, {"input": "7\r\n", "output": "-1\r\n"}, {"input": "2000000000111\r\n", "output": "20000000001\r\n"}, {"input": "100000001\r\n", "output": "0\r\n"}, {"input": "10000000000222\r\n", "output": "100000000002\r\n"}, {"input": "200000000000000111\r\n", "output": "2000000000000001\r\n"}, {"input": "404044\r\n", "output": "40044\r\n"}, {"input": "30202\r\n", "output": "300\r\n"}, {"input": "20000000000000000111\r\n", "output": "200000000000000001\r\n"}, {"input": "707\r\n", "output": "0\r\n"}, {"input": "20000300000000003000050000003\r\n", "output": "30000000000300000000003\r\n"}, {"input": "400000888\r\n", "output": "4000008\r\n"}, {"input": "2888\r\n", "output": "888\r\n"}, {"input": "200111\r\n", "output": "2001\r\n"}, {"input": "10000000888\r\n", "output": "100000008\r\n"}, {"input": "40000888\r\n", "output": "400008\r\n"}, {"input": "40404044\r\n", "output": "400044\r\n"}, {"input": "5500000000\r\n", "output": "0\r\n"}, {"input": "100012\r\n", "output": "10002\r\n"}, {"input": "1000007\r\n", "output": "0\r\n"}, {"input": "200093\r\n", "output": "93\r\n"}, {"input": "10000000222\r\n", "output": "100000002\r\n"}, {"input": "20000000002\r\n", "output": "0\r\n"}, {"input": "74333\r\n", "output": "333\r\n"}, {"input": "200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\r\n", "output": "0\r\n"}, {"input": "10000000111\r\n", "output": "1000000011\r\n"}, {"input": "100007\r\n", "output": "0\r\n"}, {"input": "20000006711\r\n", "output": "200000061\r\n"}, {"input": "8059\r\n", "output": "9\r\n"}, {"input": "8008\r\n", "output": "0\r\n"}, {"input": "88\r\n", "output": "-1\r\n"}, {"input": "2002\r\n", "output": "0\r\n"}, {"input": "2000111\r\n", "output": "20001\r\n"}, {"input": "100000000100000002\r\n", "output": "10000000000000002\r\n"}, {"input": "1000000000000000000000000000000000\r\n", "output": "0\r\n"}, {"input": "10000000000000000222\r\n", "output": "100000000000000002\r\n"}, {"input": "1000001\r\n", "output": "0\r\n"}, {"input": "200000000000111\r\n", "output": "2000000000001\r\n"}, {"input": "2000000002\r\n", "output": "0\r\n"}, {"input": "2010000100001\r\n", "output": "10000100001\r\n"}, {"input": "200330\r\n", "output": "330\r\n"}, {"input": "10000222\r\n", "output": "100002\r\n"}, {"input": "2005\r\n", "output": "0\r\n"}, {"input": "100000000000822\r\n", "output": "1000000000002\r\n"}, {"input": "10000000000000000000000\r\n", "output": "0\r\n"}, {"input": "7046\r\n", "output": "6\r\n"}, {"input": "4000117\r\n", "output": "400017\r\n"}, {"input": "971\r\n", "output": "9\r\n"}, {"input": "404\r\n", "output": "0\r\n"}, {"input": "5\r\n", "output": "-1\r\n"}, {"input": "164\r\n", "output": "6\r\n"}, {"input": "140\r\n", "output": "0\r\n"}, {"input": "74\r\n", "output": "-1\r\n"}, {"input": "2058232\r\n", "output": "20232\r\n"}, {"input": "4\r\n", "output": "-1\r\n"}, {"input": "20206\r\n", "output": "6\r\n"}, {"input": "103310\r\n", "output": "330\r\n"}, {"input": "100\r\n", "output": "0\r\n"}, {"input": "417179\r\n", "output": "7179\r\n"}, {"input": "70558\r\n", "output": "558\r\n"}, {"input": "298\r\n", "output": "9\r\n"}, {"input": "7003\r\n", "output": "3\r\n"}, {"input": "2212\r\n", "output": "222\r\n"}, {"input": "1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001\r\n", "output": "0\r\n"}, {"input": "2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002\r\n", "output": "0\r\n"}, {"input": "1002200\r\n", "output": "100200\r\n"}, {"input": "1222\r\n", "output": "222\r\n"}, {"input": "101200100\r\n", "output": "10100100\r\n"}, {"input": "1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003\r\n", "output": "3\r\n"}, {"input": "20020201\r\n", "output": "2002020\r\n"}, {"input": "12122\r\n", "output": "1122\r\n"}, {"input": "20200\r\n", "output": "0\r\n"}, {"input": "2\r\n", "output": "-1\r\n"}, {"input": "1000000000000258\r\n", "output": "10000000000008\r\n"}]
| false |
stdio
|
import sys
def is_subsequence(s, t):
t_iter = iter(t)
try:
for c in s:
while next(t_iter) != c:
pass
return True
except StopIteration:
return False
def is_beautiful(s):
if not s:
return False
if s[0] == '0' and len(s) > 1:
return False
total = sum(int(c) for c in s)
return total % 3 == 0
def compute_max_length(n):
sum_digits = sum(int(c) for c in n)
sum_mod3 = sum_digits % 3
has_zero = '0' in n
if sum_mod3 == 0:
if n[0] != '0':
return len(n)
first_non_zero = next((i for i, c in enumerate(n) if c != '0'), None)
if first_non_zero is None:
return 1
return len(n) - first_non_zero
else:
candidates = []
for i, c in enumerate(n):
if int(c) % 3 == sum_mod3:
new_n = n[:i] + n[i+1:]
if not new_n:
continue
first_non_zero = next((j for j, ch in enumerate(new_n) if ch != '0'), None)
if first_non_zero is None:
candidates.append(1)
else:
candidates.append(len(new_n) - first_non_zero)
target_mod = (3 - sum_mod3) % 3
mod_digits = [i for i, c in enumerate(n) if int(c) % 3 == target_mod]
if len(mod_digits) >= 2:
i, j = mod_digits[-2], mod_digits[-1]
new_n = n[:i] + n[i+1:j] + n[j+1:]
if new_n:
first_non_zero = next((k for k, ch in enumerate(new_n) if ch != '0'), None)
if first_non_zero is None:
candidates.append(1)
else:
candidates.append(len(new_n) - first_non_zero)
if has_zero:
candidates.append(1)
return max(candidates) if candidates else 0
def main(input_path, output_path, submission_path):
with open(input_path, 'r') as f:
n = f.read().strip()
with open(submission_path, 'r') as f:
submission = f.read().strip()
if submission == '-1':
max_len = compute_max_length(n)
print(100 if max_len == 0 else 0)
else:
if not is_subsequence(submission, n) or not is_beautiful(submission):
print(0)
return
max_len = compute_max_length(n)
print(100 if len(submission) == max_len else 0)
if __name__ == '__main__':
input_path, output_path, submission_path = sys.argv[1], sys.argv[2], sys.argv[3]
main(input_path, output_path, submission_path)
| true |
691/B
|
691
|
B
|
Python 3
|
TESTS
| 23 | 109 | 307,200 |
55610602
|
d = {'o': 'o', 'I': 'I', 'H': 'H', 'i': 'i', 'b': 'd', 'x': 'x',
'X': 'X', 'V': 'V', 'v': 'v', 'U': 'U', 'W': 'W', 'w': 'w',
'M': 'M', 'A': 'A', 'Y': 'Y', 'T': 'T', 'p': 'q', 'q': 'p',
'd': 'b', 'O': 'O'}
c = ['U', 'I', 'O', 'T', 'H', 'i', 'X', 'x', 'o', 'M', 'A', 'W', 'w',
'V', 'v', 'Y', ]
s = input()
if len(s) % 2 == 0:
n = len(s) // 2
j = len(s) // 2 + 1
i = 0
while i < n:
if s[i] not in d:
print('NIE')
exit()
if d[s[i]] != s[len(s) - i - 1]:
print('NIE')
exit()
i += 1
print('TAK')
else:
if s[len(s) // 2] not in c:
print('NIE')
exit()
for i in range(len(s) // 2):
if s[i] not in d:
print('NIE')
exit()
if d[s[i]] != s[len(s) - i - 1]:
print('NIE')
exit()
print('TAK')
| 168 | 62 | 4,608,000 |
19725920
|
def check(s):
p='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
q='A HI M O TUVWXY d b oqp vwx '
for i in range(len(s)):
if q[ p.find(s[i]) ]!=s[-i-1]:
return False
return True
print('TAK' if check(input()) else 'NIE')
|
Educational Codeforces Round 14
|
ICPC
| 2,016 | 1 | 256 |
s-palindrome
|
Let's call a string "s-palindrome" if it is symmetric about the middle of the string. For example, the string "oHo" is "s-palindrome", but the string "aa" is not. The string "aa" is not "s-palindrome", because the second half of it is not a mirror reflection of the first half.
English alphabet
You are given a string s. Check if the string is "s-palindrome".
|
The only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.
|
Print "TAK" if the string s is "s-palindrome" and "NIE" otherwise.
| null | null |
[{"input": "oXoxoXo", "output": "TAK"}, {"input": "bod", "output": "TAK"}, {"input": "ER", "output": "NIE"}]
| 1,600 |
["implementation", "strings"]
| 168 |
[{"input": "oXoxoXo\r\n", "output": "TAK\r\n"}, {"input": "bod\r\n", "output": "TAK\r\n"}, {"input": "ER\r\n", "output": "NIE\r\n"}, {"input": "o\r\n", "output": "TAK\r\n"}, {"input": "a\r\n", "output": "NIE\r\n"}, {"input": "opo\r\n", "output": "NIE\r\n"}, {"input": "HCMoxkgbNb\r\n", "output": "NIE\r\n"}, {"input": "vMhhXCMWDe\r\n", "output": "NIE\r\n"}, {"input": "iIcamjTRFH\r\n", "output": "NIE\r\n"}, {"input": "WvoWvvWovW\r\n", "output": "TAK\r\n"}, {"input": "WXxAdbAxXW\r\n", "output": "TAK\r\n"}, {"input": "vqMTUUTMpv\r\n", "output": "TAK\r\n"}, {"input": "iii\r\n", "output": "NIE\r\n"}, {"input": "AAWW\r\n", "output": "NIE\r\n"}, {"input": "ss\r\n", "output": "NIE\r\n"}, {"input": "i\r\n", "output": "NIE\r\n"}, {"input": "ii\r\n", "output": "NIE\r\n"}, {"input": "mm\r\n", "output": "NIE\r\n"}, {"input": "LJ\r\n", "output": "NIE\r\n"}, {"input": "m\r\n", "output": "NIE\r\n"}, {"input": "ioi\r\n", "output": "NIE\r\n"}, {"input": "OA\r\n", "output": "NIE\r\n"}, {"input": "aaaiaaa\r\n", "output": "NIE\r\n"}, {"input": "SS\r\n", "output": "NIE\r\n"}, {"input": "iiii\r\n", "output": "NIE\r\n"}, {"input": "ssops\r\n", "output": "NIE\r\n"}, {"input": "ssss\r\n", "output": "NIE\r\n"}, {"input": "ll\r\n", "output": "NIE\r\n"}, {"input": "s\r\n", "output": "NIE\r\n"}, {"input": "bb\r\n", "output": "NIE\r\n"}, {"input": "uu\r\n", "output": "NIE\r\n"}, {"input": "ZoZ\r\n", "output": "NIE\r\n"}, {"input": "mom\r\n", "output": "NIE\r\n"}, {"input": "uou\r\n", "output": "NIE\r\n"}, {"input": "u\r\n", "output": "NIE\r\n"}, {"input": "JL\r\n", "output": "NIE\r\n"}, {"input": "mOm\r\n", "output": "NIE\r\n"}, {"input": "llll\r\n", "output": "NIE\r\n"}, {"input": "ouo\r\n", "output": "NIE\r\n"}, {"input": "aa\r\n", "output": "NIE\r\n"}, {"input": "olo\r\n", "output": "NIE\r\n"}, {"input": "S\r\n", "output": "NIE\r\n"}, {"input": "lAl\r\n", "output": "NIE\r\n"}, {"input": "nnnn\r\n", "output": "NIE\r\n"}, {"input": "ZzZ\r\n", "output": "NIE\r\n"}, {"input": "bNd\r\n", "output": "NIE\r\n"}, {"input": "ZZ\r\n", "output": "NIE\r\n"}, {"input": "oNoNo\r\n", "output": "NIE\r\n"}, {"input": "l\r\n", "output": "NIE\r\n"}, {"input": "zz\r\n", "output": "NIE\r\n"}, {"input": "NON\r\n", "output": "NIE\r\n"}, {"input": "nn\r\n", "output": "NIE\r\n"}, {"input": "NoN\r\n", "output": "NIE\r\n"}, {"input": "sos\r\n", "output": "NIE\r\n"}, {"input": "lol\r\n", "output": "NIE\r\n"}, {"input": "mmm\r\n", "output": "NIE\r\n"}, {"input": "YAiAY\r\n", "output": "NIE\r\n"}, {"input": "ipIqi\r\n", "output": "NIE\r\n"}, {"input": "AAA\r\n", "output": "TAK\r\n"}, {"input": "uoOou\r\n", "output": "NIE\r\n"}, {"input": "SOS\r\n", "output": "NIE\r\n"}, {"input": "NN\r\n", "output": "NIE\r\n"}, {"input": "n\r\n", "output": "NIE\r\n"}, {"input": "h\r\n", "output": "NIE\r\n"}, {"input": "blld\r\n", "output": "NIE\r\n"}, {"input": "ipOqi\r\n", "output": "NIE\r\n"}, {"input": "pop\r\n", "output": "NIE\r\n"}, {"input": "BB\r\n", "output": "NIE\r\n"}, {"input": "OuO\r\n", "output": "NIE\r\n"}, {"input": "lxl\r\n", "output": "NIE\r\n"}, {"input": "Z\r\n", "output": "NIE\r\n"}, {"input": "vvivv\r\n", "output": "NIE\r\n"}, {"input": "nnnnnnnnnnnnn\r\n", "output": "NIE\r\n"}, {"input": "AA\r\n", "output": "TAK\r\n"}, {"input": "t\r\n", "output": "NIE\r\n"}, {"input": "z\r\n", "output": "NIE\r\n"}, {"input": "mmmAmmm\r\n", "output": "NIE\r\n"}, {"input": "qlililp\r\n", "output": "NIE\r\n"}, {"input": "mpOqm\r\n", "output": "NIE\r\n"}, {"input": "iiiiiiiiii\r\n", "output": "NIE\r\n"}, {"input": "BAAAB\r\n", "output": "NIE\r\n"}, {"input": "UA\r\n", "output": "NIE\r\n"}, {"input": "mmmmmmm\r\n", "output": "NIE\r\n"}, {"input": "NpOqN\r\n", "output": "NIE\r\n"}, {"input": "uOu\r\n", "output": "NIE\r\n"}, {"input": "uuu\r\n", "output": "NIE\r\n"}, {"input": "NAMAN\r\n", "output": "NIE\r\n"}, {"input": "lllll\r\n", "output": "NIE\r\n"}, {"input": "T\r\n", "output": "TAK\r\n"}, {"input": "mmmmmmmmmmmmmmmm\r\n", "output": "NIE\r\n"}, {"input": "AiiA\r\n", "output": "NIE\r\n"}, {"input": "iOi\r\n", "output": "NIE\r\n"}, {"input": "lll\r\n", "output": "NIE\r\n"}, {"input": "N\r\n", "output": "NIE\r\n"}, {"input": "viv\r\n", "output": "NIE\r\n"}, {"input": "oiio\r\n", "output": "NIE\r\n"}, {"input": "AiiiA\r\n", "output": "NIE\r\n"}, {"input": "NNNN\r\n", "output": "NIE\r\n"}, {"input": "ixi\r\n", "output": "NIE\r\n"}, {"input": "AuuA\r\n", "output": "NIE\r\n"}, {"input": "AAAANANAAAA\r\n", "output": "NIE\r\n"}, {"input": "mmmmm\r\n", "output": "NIE\r\n"}, {"input": "oYo\r\n", "output": "TAK\r\n"}, {"input": "dd\r\n", "output": "NIE\r\n"}, {"input": "A\r\n", "output": "TAK\r\n"}, {"input": "ioh\r\n", "output": "NIE\r\n"}, {"input": "mmmm\r\n", "output": "NIE\r\n"}, {"input": "uuuu\r\n", "output": "NIE\r\n"}, {"input": "puq\r\n", "output": "NIE\r\n"}, {"input": "rrrrrr\r\n", "output": "NIE\r\n"}, {"input": "c\r\n", "output": "NIE\r\n"}, {"input": "AbpA\r\n", "output": "NIE\r\n"}, {"input": "qAq\r\n", "output": "NIE\r\n"}, {"input": "tt\r\n", "output": "NIE\r\n"}, {"input": "mnmnm\r\n", "output": "NIE\r\n"}, {"input": "sss\r\n", "output": "NIE\r\n"}, {"input": "yy\r\n", "output": "NIE\r\n"}, {"input": "bob\r\n", "output": "NIE\r\n"}, {"input": "NAN\r\n", "output": "NIE\r\n"}, {"input": "mAm\r\n", "output": "NIE\r\n"}, {"input": "tAt\r\n", "output": "NIE\r\n"}, {"input": "yAy\r\n", "output": "NIE\r\n"}, {"input": "zAz\r\n", "output": "NIE\r\n"}, {"input": "aZ\r\n", "output": "NIE\r\n"}, {"input": "hh\r\n", "output": "NIE\r\n"}, {"input": "bbbb\r\n", "output": "NIE\r\n"}, {"input": "ZAZ\r\n", "output": "NIE\r\n"}, {"input": "Y\r\n", "output": "TAK\r\n"}, {"input": "AAMM\r\n", "output": "NIE\r\n"}, {"input": "lml\r\n", "output": "NIE\r\n"}, {"input": "AZA\r\n", "output": "NIE\r\n"}, {"input": "mXm\r\n", "output": "NIE\r\n"}, {"input": "bd\r\n", "output": "TAK\r\n"}, {"input": "H\r\n", "output": "TAK\r\n"}, {"input": "uvu\r\n", "output": "NIE\r\n"}, {"input": "dxxd\r\n", "output": "NIE\r\n"}, {"input": "dp\r\n", "output": "NIE\r\n"}, {"input": "vV\r\n", "output": "NIE\r\n"}, {"input": "vMo\r\n", "output": "NIE\r\n"}, {"input": "O\r\n", "output": "TAK\r\n"}, {"input": "vYv\r\n", "output": "TAK\r\n"}, {"input": "fv\r\n", "output": "NIE\r\n"}, {"input": "U\r\n", "output": "TAK\r\n"}, {"input": "iAi\r\n", "output": "NIE\r\n"}, {"input": "I\r\n", "output": "TAK\r\n"}, {"input": "VxrV\r\n", "output": "NIE\r\n"}, {"input": "POP\r\n", "output": "NIE\r\n"}, {"input": "bid\r\n", "output": "NIE\r\n"}, {"input": "bmd\r\n", "output": "NIE\r\n"}, {"input": "AiA\r\n", "output": "NIE\r\n"}, {"input": "mmmmmm\r\n", "output": "NIE\r\n"}, {"input": "XHX\r\n", "output": "TAK\r\n"}, {"input": "llllll\r\n", "output": "NIE\r\n"}, {"input": "aAa\r\n", "output": "NIE\r\n"}, {"input": "Db\r\n", "output": "NIE\r\n"}, {"input": "lOl\r\n", "output": "NIE\r\n"}, {"input": "bzd\r\n", "output": "NIE\r\n"}]
| false |
stdio
| null | true |
792/C
|
792
|
C
|
Python 3
|
TESTS
| 59 | 140 | 9,523,200 |
37535803
|
#!/usr/bin/env python3
# solution after hint:(
sn = input().strip()
n = len(sn)
def rem3(sn):
return sum(map(int, sn)) % 3
def buildn(sn, com, start=0):
return ''.join(sn[start + i] for i in com)
def subminbeau2(sn, start=0):
n = len(sn)
r3 = rem3(sn[start:])
nums = set(sn[1 + start:])
nums3 = set((int(i) % 3) for i in nums)
if r3 == 0:
return (0, sn[start:])
elif r3 in nums3:
p1 = sn.find(str(r3), start + 1)
return (1, sn[start:p1] + sn[p1 + 1:])
elif sn[1 + start:].count(str(3 - r3)) >= 2:
p1 = sn.find(str(3 - r3), start + 1)
p2 = sn.find(str(3 - r3), p1 + 1)
return (2, sn[start:p1] + sn[p1 + 1:p2] + sn[p2 + 1:])
else:
return (-1, None)
def minbeau(sn):
n = len(sn)
nnzs = [i for i, c in enumerate(sn) if (c != '0')]
res = (n, '')
for i in nnzs[:3]:
(td, d3n) = subminbeau2(sn, i)
if td >= 0:
res = min(res, (i + td, d3n))
if res[0] < n:
return res[1]
elif '0' in sn:
return '0'
else:
return '-1'
print (minbeau(sn))
| 162 | 109 | 6,553,600 |
25896991
|
def sumstr(s):
sums = 0
for i in range(len(s)):
sums += int(s[i])
return sums
def mod3(s):
sums = sumstr(s)
return sums % 3
def onlyzeros(s):
i = 0
while i < len(s):
if s[i] != '0':
return False
i += 1
return True
def lastin(s, s1):
maxf = -1
#d = '-'
for d in s1:
f = s.rfind(d)
#print(d, f, maxf)
if f > maxf:
maxf = f
return maxf
def del1(s, s1):
if s[0] == '-':
return '-'
maxf = lastin(s, s1)
#print('lastfin', maxf)
if maxf != -1:
#found digit
if maxf != 0:
#not first or can del first
ret = s[:maxf]
if maxf + 1 < len(s):
ret = ret + s[maxf + 1:]
return ret
elif len(s) > 1 and s[1] != '0':
return s[1:]
elif len(s) == 1:
return '-'
else:
ind = 1
while ind < len(s) and s[ind] == '0':
ind += 1
if ind == len(s):
return '0'
else:
return s[ind:]
else:
return '-'
def only0(s):
if '0' in s:
return '0'
else:
return '-'
from random import randint
def testing():
s = input()
#n = randint(0, 10000000000000000)
#n = 0
#s = str(n)
#print(s, mod3(s))
m3 = mod3(s)
if m3 == 0:
print(s)
elif m3 == 1:
var1 = del1(s, '147')
var2 = del1(del1(s, '258'), '258')
var3 = only0(s)
l1 = len(var1)
l2 = len(var2)
if l1 > l2:
#not -
#print('v1')
print(var1)
elif l2 > l1:
#print('v2')
print(var2)
else:
#eq
if var1[0] != '-':
print(var1)
elif var2[0] != '-':
print(var2)
elif var3[0] != '-':
print(var3)
else:
print(-1)
elif m3 == 2:
var1 = del1(s, '258')
var2 = del1(del1(s, '147'), '147')
var3 = only0(s)
l1 = len(var1)
l2 = len(var2)
if l1 > l2:
#not -
print(var1)
#print('v1')
elif l2 > l1:
print(var2)
#print('v2')
else:
#eq
if var1[0] != '-':
print(var1)
elif var2[0] != '-':
print(var2)
elif var3[0] != '-':
print(var3)
else:
print(-1)
#print('\n\n')
for i in range(1):
testing()
|
Educational Codeforces Round 18
|
ICPC
| 2,017 | 1 | 256 |
Divide by Three
|
A positive integer number n is written on a blackboard. It consists of not more than 105 digits. You have to transform it into a beautiful number by erasing some of the digits, and you want to erase as few digits as possible.
The number is called beautiful if it consists of at least one digit, doesn't have leading zeroes and is a multiple of 3. For example, 0, 99, 10110 are beautiful numbers, and 00, 03, 122 are not.
Write a program which for the given n will find a beautiful number such that n can be transformed into this number by erasing as few digits as possible. You can erase an arbitraty set of digits. For example, they don't have to go one after another in the number n.
If it's impossible to obtain a beautiful number, print -1. If there are multiple answers, print any of them.
|
The first line of input contains n — a positive integer number without leading zeroes (1 ≤ n < 10100000).
|
Print one number — any beautiful number obtained by erasing as few as possible digits. If there is no answer, print - 1.
| null |
In the first example it is enough to erase only the first digit to obtain a multiple of 3. But if we erase the first digit, then we obtain a number with a leading zero. So the minimum number of digits to be erased is two.
|
[{"input": "1033", "output": "33"}, {"input": "10", "output": "0"}, {"input": "11", "output": "-1"}]
| 2,000 |
["dp", "greedy", "math", "number theory"]
| 162 |
[{"input": "1033\r\n", "output": "33\r\n"}, {"input": "10\r\n", "output": "0\r\n"}, {"input": "11\r\n", "output": "-1\r\n"}, {"input": "3\r\n", "output": "3\r\n"}, {"input": "1\r\n", "output": "-1\r\n"}, {"input": "117\r\n", "output": "117\r\n"}, {"input": "518\r\n", "output": "18\r\n"}, {"input": "327\r\n", "output": "327\r\n"}, {"input": "270461\r\n", "output": "70461\r\n"}, {"input": "609209\r\n", "output": "60909\r\n"}, {"input": "110930\r\n", "output": "930\r\n"}, {"input": "37616145150713688775\r\n", "output": "3616145150713688775\r\n"}, {"input": "98509135612114839419\r\n", "output": "9509135612114839419\r\n"}, {"input": "41674994051436988162\r\n", "output": "1674994051436988162\r\n"}, {"input": "82547062721736129804\r\n", "output": "82547062721736129804\r\n"}, {"input": "4902501252475186372406731932548506197390793597574544727433297197476846519276598727359617092494798814\r\n", "output": "490501252475186372406731932548506197390793597574544727433297197476846519276598727359617092494798814\r\n"}, {"input": "1291007209605301446874998623691572528836214969878676835460982410817526074579818247646933326771899122\r\n", "output": "1291007209605301446874998623691572528836214969878676835460982410817526074579818247646933326771899122\r\n"}, {"input": "5388306043547446322173224045662327678394712363272776811399689704247387317165308057863239568137902157\r\n", "output": "538830603547446322173224045662327678394712363272776811399689704247387317165308057863239568137902157\r\n"}, {"input": "20000111\r\n", "output": "200001\r\n"}, {"input": "100222\r\n", "output": "1002\r\n"}, {"input": "202\r\n", "output": "0\r\n"}, {"input": "100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000033\r\n", "output": "33\r\n"}, {"input": "101\r\n", "output": "0\r\n"}, {"input": "1000000222\r\n", "output": "10000002\r\n"}, {"input": "1001\r\n", "output": "0\r\n"}, {"input": "205\r\n", "output": "0\r\n"}, {"input": "102211\r\n", "output": "10221\r\n"}, {"input": "100000002022\r\n", "output": "1000000002\r\n"}, {"input": "20203\r\n", "output": "3\r\n"}, {"input": "1002001\r\n", "output": "100200\r\n"}, {"input": "10002223\r\n", "output": "100023\r\n"}, {"input": "1002223\r\n", "output": "10023\r\n"}, {"input": "100000231\r\n", "output": "10000023\r\n"}, {"input": "220\r\n", "output": "0\r\n"}, {"input": "322\r\n", "output": "3\r\n"}, {"input": "100000222\r\n", "output": "1000002\r\n"}, {"input": "10033\r\n", "output": "33\r\n"}, {"input": "2003302\r\n", "output": "330\r\n"}, {"input": "10011001\r\n", "output": "1001001\r\n"}, {"input": "20000000011001111\r\n", "output": "200000000001111\r\n"}, {"input": "100000000\r\n", "output": "0\r\n"}, {"input": "1000\r\n", "output": "0\r\n"}, {"input": "200000000000000000000000000008\r\n", "output": "0\r\n"}, {"input": "1000000000000222\r\n", "output": "10000000000002\r\n"}, {"input": "100000000000000000222\r\n", "output": "1000000000000000002\r\n"}, {"input": "29512\r\n", "output": "2952\r\n"}, {"input": "88888888888888\r\n", "output": "888888888888\r\n"}, {"input": "100000000000222\r\n", "output": "1000000000002\r\n"}, {"input": "11000000\r\n", "output": "0\r\n"}, {"input": "2200\r\n", "output": "0\r\n"}, {"input": "10000555\r\n", "output": "100005\r\n"}, {"input": "1000222\r\n", "output": "10002\r\n"}, {"input": "10021\r\n", "output": "1002\r\n"}, {"input": "223\r\n", "output": "3\r\n"}, {"input": "1013\r\n", "output": "3\r\n"}, {"input": "100020001\r\n", "output": "10002000\r\n"}, {"input": "20000000000000000000932\r\n", "output": "93\r\n"}, {"input": "1010\r\n", "output": "0\r\n"}, {"input": "2000000002222\r\n", "output": "20000000022\r\n"}, {"input": "10213\r\n", "output": "1023\r\n"}, {"input": "109111\r\n", "output": "10911\r\n"}, {"input": "1010101010\r\n", "output": "10001010\r\n"}, {"input": "300055\r\n", "output": "3000\r\n"}, {"input": "200200\r\n", "output": "0\r\n"}, {"input": "202222\r\n", "output": "2022\r\n"}, {"input": "4000888\r\n", "output": "40008\r\n"}, {"input": "200000111\r\n", "output": "2000001\r\n"}, {"input": "2000000111\r\n", "output": "20000001\r\n"}, {"input": "1000000\r\n", "output": "0\r\n"}, {"input": "1003301\r\n", "output": "330\r\n"}, {"input": "100001\r\n", "output": "0\r\n"}, {"input": "40000000000000000000888\r\n", "output": "400000000000000000008\r\n"}, {"input": "100000\r\n", "output": "0\r\n"}, {"input": "4000000888\r\n", "output": "40000008\r\n"}, {"input": "334733\r\n", "output": "3333\r\n"}, {"input": "1000002220\r\n", "output": "10000020\r\n"}, {"input": "100321\r\n", "output": "10032\r\n"}, {"input": "101111\r\n", "output": "1011\r\n"}, {"input": "100000000222\r\n", "output": "1000000002\r\n"}, {"input": "10001\r\n", "output": "0\r\n"}, {"input": "7\r\n", "output": "-1\r\n"}, {"input": "2000000000111\r\n", "output": "20000000001\r\n"}, {"input": "100000001\r\n", "output": "0\r\n"}, {"input": "10000000000222\r\n", "output": "100000000002\r\n"}, {"input": "200000000000000111\r\n", "output": "2000000000000001\r\n"}, {"input": "404044\r\n", "output": "40044\r\n"}, {"input": "30202\r\n", "output": "300\r\n"}, {"input": "20000000000000000111\r\n", "output": "200000000000000001\r\n"}, {"input": "707\r\n", "output": "0\r\n"}, {"input": "20000300000000003000050000003\r\n", "output": "30000000000300000000003\r\n"}, {"input": "400000888\r\n", "output": "4000008\r\n"}, {"input": "2888\r\n", "output": "888\r\n"}, {"input": "200111\r\n", "output": "2001\r\n"}, {"input": "10000000888\r\n", "output": "100000008\r\n"}, {"input": "40000888\r\n", "output": "400008\r\n"}, {"input": "40404044\r\n", "output": "400044\r\n"}, {"input": "5500000000\r\n", "output": "0\r\n"}, {"input": "100012\r\n", "output": "10002\r\n"}, {"input": "1000007\r\n", "output": "0\r\n"}, {"input": "200093\r\n", "output": "93\r\n"}, {"input": "10000000222\r\n", "output": "100000002\r\n"}, {"input": "20000000002\r\n", "output": "0\r\n"}, {"input": "74333\r\n", "output": "333\r\n"}, {"input": "200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\r\n", "output": "0\r\n"}, {"input": "10000000111\r\n", "output": "1000000011\r\n"}, {"input": "100007\r\n", "output": "0\r\n"}, {"input": "20000006711\r\n", "output": "200000061\r\n"}, {"input": "8059\r\n", "output": "9\r\n"}, {"input": "8008\r\n", "output": "0\r\n"}, {"input": "88\r\n", "output": "-1\r\n"}, {"input": "2002\r\n", "output": "0\r\n"}, {"input": "2000111\r\n", "output": "20001\r\n"}, {"input": "100000000100000002\r\n", "output": "10000000000000002\r\n"}, {"input": "1000000000000000000000000000000000\r\n", "output": "0\r\n"}, {"input": "10000000000000000222\r\n", "output": "100000000000000002\r\n"}, {"input": "1000001\r\n", "output": "0\r\n"}, {"input": "200000000000111\r\n", "output": "2000000000001\r\n"}, {"input": "2000000002\r\n", "output": "0\r\n"}, {"input": "2010000100001\r\n", "output": "10000100001\r\n"}, {"input": "200330\r\n", "output": "330\r\n"}, {"input": "10000222\r\n", "output": "100002\r\n"}, {"input": "2005\r\n", "output": "0\r\n"}, {"input": "100000000000822\r\n", "output": "1000000000002\r\n"}, {"input": "10000000000000000000000\r\n", "output": "0\r\n"}, {"input": "7046\r\n", "output": "6\r\n"}, {"input": "4000117\r\n", "output": "400017\r\n"}, {"input": "971\r\n", "output": "9\r\n"}, {"input": "404\r\n", "output": "0\r\n"}, {"input": "5\r\n", "output": "-1\r\n"}, {"input": "164\r\n", "output": "6\r\n"}, {"input": "140\r\n", "output": "0\r\n"}, {"input": "74\r\n", "output": "-1\r\n"}, {"input": "2058232\r\n", "output": "20232\r\n"}, {"input": "4\r\n", "output": "-1\r\n"}, {"input": "20206\r\n", "output": "6\r\n"}, {"input": "103310\r\n", "output": "330\r\n"}, {"input": "100\r\n", "output": "0\r\n"}, {"input": "417179\r\n", "output": "7179\r\n"}, {"input": "70558\r\n", "output": "558\r\n"}, {"input": "298\r\n", "output": "9\r\n"}, {"input": "7003\r\n", "output": "3\r\n"}, {"input": "2212\r\n", "output": "222\r\n"}, {"input": "1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001\r\n", "output": "0\r\n"}, {"input": "2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002\r\n", "output": "0\r\n"}, {"input": "1002200\r\n", "output": "100200\r\n"}, {"input": "1222\r\n", "output": "222\r\n"}, {"input": "101200100\r\n", "output": "10100100\r\n"}, {"input": "1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003\r\n", "output": "3\r\n"}, {"input": "20020201\r\n", "output": "2002020\r\n"}, {"input": "12122\r\n", "output": "1122\r\n"}, {"input": "20200\r\n", "output": "0\r\n"}, {"input": "2\r\n", "output": "-1\r\n"}, {"input": "1000000000000258\r\n", "output": "10000000000008\r\n"}]
| false |
stdio
|
import sys
def is_subsequence(s, t):
t_iter = iter(t)
try:
for c in s:
while next(t_iter) != c:
pass
return True
except StopIteration:
return False
def is_beautiful(s):
if not s:
return False
if s[0] == '0' and len(s) > 1:
return False
total = sum(int(c) for c in s)
return total % 3 == 0
def compute_max_length(n):
sum_digits = sum(int(c) for c in n)
sum_mod3 = sum_digits % 3
has_zero = '0' in n
if sum_mod3 == 0:
if n[0] != '0':
return len(n)
first_non_zero = next((i for i, c in enumerate(n) if c != '0'), None)
if first_non_zero is None:
return 1
return len(n) - first_non_zero
else:
candidates = []
for i, c in enumerate(n):
if int(c) % 3 == sum_mod3:
new_n = n[:i] + n[i+1:]
if not new_n:
continue
first_non_zero = next((j for j, ch in enumerate(new_n) if ch != '0'), None)
if first_non_zero is None:
candidates.append(1)
else:
candidates.append(len(new_n) - first_non_zero)
target_mod = (3 - sum_mod3) % 3
mod_digits = [i for i, c in enumerate(n) if int(c) % 3 == target_mod]
if len(mod_digits) >= 2:
i, j = mod_digits[-2], mod_digits[-1]
new_n = n[:i] + n[i+1:j] + n[j+1:]
if new_n:
first_non_zero = next((k for k, ch in enumerate(new_n) if ch != '0'), None)
if first_non_zero is None:
candidates.append(1)
else:
candidates.append(len(new_n) - first_non_zero)
if has_zero:
candidates.append(1)
return max(candidates) if candidates else 0
def main(input_path, output_path, submission_path):
with open(input_path, 'r') as f:
n = f.read().strip()
with open(submission_path, 'r') as f:
submission = f.read().strip()
if submission == '-1':
max_len = compute_max_length(n)
print(100 if max_len == 0 else 0)
else:
if not is_subsequence(submission, n) or not is_beautiful(submission):
print(0)
return
max_len = compute_max_length(n)
print(100 if len(submission) == max_len else 0)
if __name__ == '__main__':
input_path, output_path, submission_path = sys.argv[1], sys.argv[2], sys.argv[3]
main(input_path, output_path, submission_path)
| true |
837/B
|
837
|
B
|
Python 3
|
TESTS
| 107 | 77 | 4,915,200 |
29204823
|
N, M = map(int, input().split())
flag = [input() for n in range(N)]
def get_rect_of_color(color):
rect_points = []
for i, row in enumerate(flag):
first = True
tmp = [None] * 4
for j, char in enumerate(row):
if char == color:
if first:
first = False
tmp[0], tmp[1] = i, j
tmp[2], tmp[3] = i, j
if tmp[0] is not None:
rect_points += [tmp]
return rect_points
def get_bounding_rect(rect):
last_pos = rect[0]
first = True
for row in rect:
if first:
first = False
continue
ly1, lx1, ly2, lx2 = last_pos
y1, x1, y2, x2 = row
# print(y1, x1, y2, x2)
# print(ly1, lx1, ly2, lx2)
if y1 - ly1 != 1 or y2 - ly2 != 1 or\
x1 - lx1 != 0 or x2 - lx2 != 0:
raise Exception()
last_pos = row
return (
(rect[0][0], rect[0][1]),
(rect[-1][2], rect[-1][3]),
)
try:
R = get_bounding_rect(get_rect_of_color('R'))
G = get_bounding_rect(get_rect_of_color('G'))
B = get_bounding_rect(get_rect_of_color('B'))
Rh = abs(R[1][0] - R[0][0])
Bh = abs(B[1][0] - B[0][0])
Gh = abs(G[1][0] - G[0][0])
Rw = abs(R[1][1] - R[0][1])
Bw = abs(B[1][1] - B[0][1])
Gw = abs(G[1][1] - G[0][1])
# print(Rh, Bh, Gh)
# print(Rw, Bw, Gw)
if len(set([Rw, Bw, Gw])) != 1 or len(set([Rh, Bh, Gh])) != 1:
print('NO')
else:
print('YES')
except Exception:
print('NO')
| 153 | 46 | 0 |
188298470
|
# First of all, we should validate the input by checking the eligibilities in a function called 'validate_flag'
def validate_flag(field: list) -> bool:
# First, we validate the number of colors in the field
total_colors = set()
for row in field:
total_colors.update(row)
# If it is not exactly 3 colors, return false
if len(total_colors) != 3:
return False
r,g,b=0,0,0
# Now we keep a count of the colors and see whether each color appears (n/3) times.
for i in range(len(field)):
colors = set(field[i])
if len(colors) != 1:
return False
color = colors.pop()
if color == 'R':
r += 1
elif color == 'G':
g += 1
elif color == 'B':
b += 1
if i != 0 and len(set(field[i])) == 1 and field[i][0] != field[i - 1][0]:
if i % (len(field) // 3) != 0:
return False
if r==g==b:
return True
return False
def solve() -> None:
# Read Input
n,m = [int(num) for num in input().strip().split()]
field = []
for i in range(n):
field.append(list(input().strip()))
flag_vertical = validate_flag(field)
# Transpose the input for horizontal flag comparision
trans_field=list(map(list,zip(*field)))
flag_horizontal = validate_flag(trans_field)
# If either of the horizontal or vertical flag is True, then the input is a a flag. Else Not.
if flag_vertical or flag_horizontal:
print("YES")
else:
print("NO")
# Testing the function using assert for the given test Cases
solve()
|
Educational Codeforces Round 26
|
ICPC
| 2,017 | 1 | 256 |
Flag of Berland
|
The flag of Berland is such rectangular field n × m that satisfies following conditions:
- Flag consists of three colors which correspond to letters 'R', 'G' and 'B'.
- Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color.
- Each color should be used in exactly one stripe.
You are given a field n × m, consisting of characters 'R', 'G' and 'B'. Output "YES" (without quotes) if this field corresponds to correct flag of Berland. Otherwise, print "NO" (without quotes).
|
The first line contains two integer numbers n and m (1 ≤ n, m ≤ 100) — the sizes of the field.
Each of the following n lines consisting of m characters 'R', 'G' and 'B' — the description of the field.
|
Print "YES" (without quotes) if the given field corresponds to correct flag of Berland . Otherwise, print "NO" (without quotes).
| null |
The field in the third example doesn't have three parralel stripes.
Rows of the field in the fourth example are parralel to each other and to borders. But they have different heights — 2, 1 and 1.
|
[{"input": "6 5\nRRRRR\nRRRRR\nBBBBB\nBBBBB\nGGGGG\nGGGGG", "output": "YES"}, {"input": "4 3\nBRG\nBRG\nBRG\nBRG", "output": "YES"}, {"input": "6 7\nRRRGGGG\nRRRGGGG\nRRRGGGG\nRRRBBBB\nRRRBBBB\nRRRBBBB", "output": "NO"}, {"input": "4 4\nRRRR\nRRRR\nBBBB\nGGGG", "output": "NO"}]
| 1,600 |
["brute force", "implementation"]
| 153 |
[{"input": "6 5\r\nRRRRR\r\nRRRRR\r\nBBBBB\r\nBBBBB\r\nGGGGG\r\nGGGGG\r\n", "output": "YES\r\n"}, {"input": "4 3\r\nBRG\r\nBRG\r\nBRG\r\nBRG\r\n", "output": "YES\r\n"}, {"input": "6 7\r\nRRRGGGG\r\nRRRGGGG\r\nRRRGGGG\r\nRRRBBBB\r\nRRRBBBB\r\nRRRBBBB\r\n", "output": "NO\r\n"}, {"input": "4 4\r\nRRRR\r\nRRRR\r\nBBBB\r\nGGGG\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nGRB\r\n", "output": "YES\r\n"}, {"input": "3 1\r\nR\r\nG\r\nB\r\n", "output": "YES\r\n"}, {"input": "4 3\r\nRGB\r\nGRB\r\nGRB\r\nGRB\r\n", "output": "NO\r\n"}, {"input": "4 6\r\nGGRRBB\r\nGGRRBB\r\nGGRRBB\r\nRRGGBB\r\n", "output": "NO\r\n"}, {"input": "100 3\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nGRB\r\n", "output": "NO\r\n"}, {"input": "3 100\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\nRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRG\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nR\r\nR\r\nB\r\n", "output": "NO\r\n"}, {"input": "3 2\r\nRR\r\nBB\r\nRR\r\n", "output": "NO\r\n"}, {"input": "3 2\r\nRR\r\nBG\r\nBG\r\n", "output": "NO\r\n"}, {"input": "3 2\r\nBB\r\nRR\r\nBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nRRR\r\nRRR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nGGG\r\nGGG\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRGG\r\n", "output": "NO\r\n"}, {"input": "4 3\r\nRGR\r\nRGR\r\nRGR\r\nRGR\r\n", "output": "NO\r\n"}, {"input": "3 4\r\nRRGG\r\nRRGG\r\nBBBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nBRG\r\nBRG\r\nBRG\r\n", "output": "YES\r\n"}, {"input": "3 1\r\nR\r\nG\r\nR\r\n", "output": "NO\r\n"}, {"input": "5 3\r\nBBG\r\nBBG\r\nBBG\r\nBBG\r\nBBG\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nGGG\r\nRRR\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRGR\r\n", "output": "NO\r\n"}, {"input": "3 6\r\nRRBBGG\r\nRRBBGG\r\nRRBBGG\r\n", "output": "YES\r\n"}, {"input": "6 6\r\nRRBBGG\r\nRRBBGG\r\nRRBBGG\r\nRRBBGG\r\nRRBBGG\r\nRRBBGG\r\n", "output": "YES\r\n"}, {"input": "4 3\r\nRRR\r\nGGG\r\nBBB\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nBBB\r\nRRR\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nB\r\nR\r\nB\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nBGB\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nB\r\nB\r\nB\r\n", "output": "NO\r\n"}, {"input": "3 4\r\nRRRR\r\nBBBB\r\nRRRR\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRGGGBB\r\n", "output": "NO\r\n"}, {"input": "9 3\r\nBBB\r\nBBB\r\nBBB\r\nGGG\r\nGGG\r\nGRG\r\nRGR\r\nRRR\r\nRRR\r\n", "output": "NO\r\n"}, {"input": "4 4\r\nRGBB\r\nRGBB\r\nRGBB\r\nRGBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRBR\r\nRBR\r\nRBR\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRRRRBB\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRRRRRR\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRRGGGG\r\n", "output": "NO\r\n"}, {"input": "4 4\r\nRRRR\r\nRRRR\r\nRRRR\r\nRRRR\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nB\r\nG\r\nB\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nR\r\nR\r\nR\r\n", "output": "NO\r\n"}, {"input": "1 9\r\nRRRGGGBBB\r\n", "output": "YES\r\n"}, {"input": "1 3\r\nRRR\r\n", "output": "NO\r\n"}, {"input": "3 5\r\nRRRRR\r\nBBBBB\r\nBBBBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nGGG\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "1 1\r\nR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGR\r\nRGR\r\nRGR\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRBG\r\nGBR\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nRGB\r\nRGB\r\n", "output": "YES\r\n"}, {"input": "1 3\r\nBRB\r\n", "output": "NO\r\n"}, {"input": "2 1\r\nR\r\nB\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRBR\r\n", "output": "NO\r\n"}, {"input": "3 5\r\nRRGBB\r\nRRGBB\r\nRRGBB\r\n", "output": "NO\r\n"}, {"input": "5 3\r\nBBR\r\nBBR\r\nBBR\r\nBBR\r\nBBR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nRBG\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "1 2\r\nRB\r\n", "output": "NO\r\n"}, {"input": "4 3\r\nBBB\r\nBBB\r\nBBB\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "36 6\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\n", "output": "NO\r\n"}, {"input": "4 1\r\nR\r\nB\r\nG\r\nR\r\n", "output": "NO\r\n"}, {"input": "13 12\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\n", "output": "NO\r\n"}, {"input": "2 2\r\nRR\r\nRR\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nRRGGBB\r\nGRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\n", "output": "NO\r\n"}, {"input": "70 3\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\n", "output": "NO\r\n"}, {"input": "4 3\r\nBBG\r\nBBG\r\nBBG\r\nBBG\r\n", "output": "NO\r\n"}, {"input": "6 3\r\nBBB\r\nGGG\r\nRRR\r\nBRG\r\nBRG\r\nBRG\r\n", "output": "NO\r\n"}, {"input": "3 6\r\nRRBBGG\r\nRBBBGG\r\nRBBBGG\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nGGGGGG\r\nGGGGGG\r\nBBBBBB\r\nBBBBBB\r\nGGGGGG\r\nGGGGGG\r\n", "output": "NO\r\n"}, {"input": "6 1\r\nR\r\nB\r\nG\r\nR\r\nB\r\nG\r\n", "output": "NO\r\n"}, {"input": "6 5\r\nRRRRR\r\nBBBBB\r\nGGGGG\r\nRRRRR\r\nBBBBB\r\nGGGGG\r\n", "output": "NO\r\n"}, {"input": "6 3\r\nRRR\r\nGGG\r\nBBB\r\nRRR\r\nGGG\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "6 5\r\nRRRRR\r\nRRRRR\r\nRRRRR\r\nGGGGG\r\nGGGGG\r\nGGGGG\r\n", "output": "NO\r\n"}, {"input": "15 28\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\n", "output": "NO\r\n"}, {"input": "21 10\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nBBBBBBBBBB\r\nBBBBBBBBBB\r\nBBBBBGBBBB\r\nBBBBBBBBBB\r\nBBBBBBBBBB\r\nBBBBBBBBBB\r\nBBBBBBBBBB\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\n", "output": "NO\r\n"}, {"input": "3 2\r\nRR\r\nGB\r\nGB\r\n", "output": "NO\r\n"}, {"input": "3 2\r\nRG\r\nRG\r\nBB\r\n", "output": "NO\r\n"}, {"input": "6 5\r\nRRRRR\r\nRRRRR\r\nBBBBB\r\nBBBBB\r\nRRRRR\r\nRRRRR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nGBR\r\nBRG\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nBGR\r\nBGR\r\nBGR\r\n", "output": "YES\r\n"}, {"input": "6 6\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\n", "output": "YES\r\n"}, {"input": "4 2\r\nRR\r\nGG\r\nRR\r\nBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nRRR\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "8 6\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\n", "output": "NO\r\n"}, {"input": "3 4\r\nRRRR\r\nRRRR\r\nGGGG\r\n", "output": "NO\r\n"}, {"input": "3 4\r\nRRRR\r\nRRRR\r\nRRRR\r\n", "output": "NO\r\n"}, {"input": "6 1\r\nR\r\nR\r\nR\r\nR\r\nR\r\nR\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRRBBGG\r\n", "output": "YES\r\n"}, {"input": "1 6\r\nRGBRGB\r\n", "output": "NO\r\n"}, {"input": "3 4\r\nRRRR\r\nGGGG\r\nRRRR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRB\r\nGRG\r\nGBB\r\n", "output": "NO\r\n"}, {"input": "3 7\r\nRRGGBBB\r\nRRGGBBB\r\nRRGGBBB\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nG\r\nR\r\nR\r\n", "output": "NO\r\n"}, {"input": "2 3\r\nRGG\r\nRBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRG\r\nGGG\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nRBB\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGR\r\nRGB\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nB\r\nR\r\nR\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nGRR\r\n", "output": "NO\r\n"}, {"input": "4 4\r\nRRRR\r\nGGGG\r\nBBBB\r\nBBBB\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nGGR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nGGB\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGR\r\nGGG\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nRRRRRR\r\nGGGGGG\r\nGGGGGG\r\nGGGGGG\r\nBBBBBB\r\nBBBBBB\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nRRRRRR\r\nRRRRRR\r\nGGGGGG\r\nBBBBBB\r\nBBBBBB\r\nBBBBBB\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nG\r\nB\r\nR\r\n", "output": "YES\r\n"}, {"input": "3 3\r\nGGB\r\nRGB\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nGRR\r\nGGG\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nRRRRRR\r\nRRRRRR\r\nGGGGGG\r\nGGGGGG\r\nBBBBBB\r\nRRRRRR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nGBG\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "3 8\r\nRRGGBBBB\r\nRRGGBBBB\r\nRRGGBBBB\r\n", "output": "NO\r\n"}, {"input": "2 2\r\nRR\r\nGG\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nRGR\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRBG\r\n", "output": "YES\r\n"}, {"input": "2 6\r\nRRGGBB\r\nGGRRBB\r\n", "output": "NO\r\n"}, {"input": "6 2\r\nRR\r\nGG\r\nBB\r\nRR\r\nGG\r\nBB\r\n", "output": "NO\r\n"}, {"input": "1 5\r\nRRGGB\r\n", "output": "NO\r\n"}, {"input": "1 2\r\nRG\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRGBRBG\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRRRGGB\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRGB\r\n", "output": "YES\r\n"}, {"input": "4 3\r\nRRR\r\nBBR\r\nGBB\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "6 3\r\nRRR\r\nBBB\r\nBBB\r\nBBB\r\nGGG\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRBG\r\nRBG\r\nRBG\r\n", "output": "YES\r\n"}, {"input": "6 3\r\nRRR\r\nBBB\r\nGGG\r\nRRR\r\nBBB\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "1 4\r\nRGBB\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\n", "output": "NO\r\n"}, {"input": "6 5\r\nRRRRR\r\nRRRRR\r\nGGGGG\r\nGGGGG\r\nRRRRR\r\nRRRRR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nBRG\r\nGBR\r\n", "output": "NO\r\n"}, {"input": "6 10\r\nRRRRRRRRRR\r\nGGGGGGGGGG\r\nBBBBBBBBBB\r\nRRRRRRRRRR\r\nGGGGGGGGGG\r\nBBBBBBBBBB\r\n", "output": "NO\r\n"}, {"input": "20 6\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\n", "output": "YES\r\n"}, {"input": "4 1\r\nR\r\nG\r\nB\r\nR\r\n", "output": "NO\r\n"}, {"input": "1 4\r\nRGBR\r\n", "output": "NO\r\n"}, {"input": "2 4\r\nRGBB\r\nRRGB\r\n", "output": "NO\r\n"}]
| false |
stdio
| null | true |
837/B
|
837
|
B
|
Python 3
|
TESTS
| 127 | 93 | 5,120,000 |
29167646
|
import re
n,m =map(int,input().split())
data = [ input() for _ in range(n)]
temp = ''.join([data[i][0] for i in range(n)])
f1=False
count={}
i=0
mark=temp[0]
while i<n and temp[i]==mark:
i+=1
count[mark]=i
j=i
if j<n:
mark=temp[j]
while j<n and temp[j]==mark :
j+=1
count[mark]=j-i
if j<n:
count[temp[j]]=n-j
if 'R' in count and 'G' in count and 'B' in count and count['R']==count['G'] and count['G']==count['B']:
f1=True
for i in range(n):
mark=data[i][0]
for j in range(1,m):
if data[i][j]!=mark:
f1=False
break
if not f1:
break
#print(count)
f2=False
count={}
data = list(zip(*data))
n,m=m,n
temp = ''.join([data[i][0] for i in range(n)])
i=0
mark=temp[0]
while i<n and temp[i]==mark:
i+=1
count[mark]=i
j=i
if j<n:
mark=temp[j]
while j<n and temp[j]==mark :
j+=1
count[mark]=j-i
if j<n:
count[temp[j]]=n-j
if 'R' in count and 'G' in count and 'B' in count and count['R']==count['G'] and count['G']==count['B']:
f2=True
for i in range(n):
mark=data[i][0]
for j in range(1,m):
if data[i][j]!=mark:
f2=False
break
if not f2:
break
if f1 or f2:
print('YES')
else:
print('NO')
| 153 | 61 | 4,608,000 |
29264658
|
def c(f, n, m):
if n % 3 != 0:return 0
s=n//3;s=f[0],f[s],f[2*s]
if set(s)!=set(map(lambda x:x*m,'RGB')):return 0
for i in range(n):
if f[i] != s[i*3 // n]:return 0
return 1
n,m=map(int, input().split())
f=[input() for _ in range(n)]
print('Yes'if c(f,n,m) or c([''.join(f[j][i] for j in range(n)) for i in range(m)],m,n)else'No')
|
Educational Codeforces Round 26
|
ICPC
| 2,017 | 1 | 256 |
Flag of Berland
|
The flag of Berland is such rectangular field n × m that satisfies following conditions:
- Flag consists of three colors which correspond to letters 'R', 'G' and 'B'.
- Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color.
- Each color should be used in exactly one stripe.
You are given a field n × m, consisting of characters 'R', 'G' and 'B'. Output "YES" (without quotes) if this field corresponds to correct flag of Berland. Otherwise, print "NO" (without quotes).
|
The first line contains two integer numbers n and m (1 ≤ n, m ≤ 100) — the sizes of the field.
Each of the following n lines consisting of m characters 'R', 'G' and 'B' — the description of the field.
|
Print "YES" (without quotes) if the given field corresponds to correct flag of Berland . Otherwise, print "NO" (without quotes).
| null |
The field in the third example doesn't have three parralel stripes.
Rows of the field in the fourth example are parralel to each other and to borders. But they have different heights — 2, 1 and 1.
|
[{"input": "6 5\nRRRRR\nRRRRR\nBBBBB\nBBBBB\nGGGGG\nGGGGG", "output": "YES"}, {"input": "4 3\nBRG\nBRG\nBRG\nBRG", "output": "YES"}, {"input": "6 7\nRRRGGGG\nRRRGGGG\nRRRGGGG\nRRRBBBB\nRRRBBBB\nRRRBBBB", "output": "NO"}, {"input": "4 4\nRRRR\nRRRR\nBBBB\nGGGG", "output": "NO"}]
| 1,600 |
["brute force", "implementation"]
| 153 |
[{"input": "6 5\r\nRRRRR\r\nRRRRR\r\nBBBBB\r\nBBBBB\r\nGGGGG\r\nGGGGG\r\n", "output": "YES\r\n"}, {"input": "4 3\r\nBRG\r\nBRG\r\nBRG\r\nBRG\r\n", "output": "YES\r\n"}, {"input": "6 7\r\nRRRGGGG\r\nRRRGGGG\r\nRRRGGGG\r\nRRRBBBB\r\nRRRBBBB\r\nRRRBBBB\r\n", "output": "NO\r\n"}, {"input": "4 4\r\nRRRR\r\nRRRR\r\nBBBB\r\nGGGG\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nGRB\r\n", "output": "YES\r\n"}, {"input": "3 1\r\nR\r\nG\r\nB\r\n", "output": "YES\r\n"}, {"input": "4 3\r\nRGB\r\nGRB\r\nGRB\r\nGRB\r\n", "output": "NO\r\n"}, {"input": "4 6\r\nGGRRBB\r\nGGRRBB\r\nGGRRBB\r\nRRGGBB\r\n", "output": "NO\r\n"}, {"input": "100 3\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nGRB\r\n", "output": "NO\r\n"}, {"input": "3 100\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\nRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRG\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nR\r\nR\r\nB\r\n", "output": "NO\r\n"}, {"input": "3 2\r\nRR\r\nBB\r\nRR\r\n", "output": "NO\r\n"}, {"input": "3 2\r\nRR\r\nBG\r\nBG\r\n", "output": "NO\r\n"}, {"input": "3 2\r\nBB\r\nRR\r\nBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nRRR\r\nRRR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nGGG\r\nGGG\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRGG\r\n", "output": "NO\r\n"}, {"input": "4 3\r\nRGR\r\nRGR\r\nRGR\r\nRGR\r\n", "output": "NO\r\n"}, {"input": "3 4\r\nRRGG\r\nRRGG\r\nBBBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nBRG\r\nBRG\r\nBRG\r\n", "output": "YES\r\n"}, {"input": "3 1\r\nR\r\nG\r\nR\r\n", "output": "NO\r\n"}, {"input": "5 3\r\nBBG\r\nBBG\r\nBBG\r\nBBG\r\nBBG\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nGGG\r\nRRR\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRGR\r\n", "output": "NO\r\n"}, {"input": "3 6\r\nRRBBGG\r\nRRBBGG\r\nRRBBGG\r\n", "output": "YES\r\n"}, {"input": "6 6\r\nRRBBGG\r\nRRBBGG\r\nRRBBGG\r\nRRBBGG\r\nRRBBGG\r\nRRBBGG\r\n", "output": "YES\r\n"}, {"input": "4 3\r\nRRR\r\nGGG\r\nBBB\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nBBB\r\nRRR\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nB\r\nR\r\nB\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nBGB\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nB\r\nB\r\nB\r\n", "output": "NO\r\n"}, {"input": "3 4\r\nRRRR\r\nBBBB\r\nRRRR\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRGGGBB\r\n", "output": "NO\r\n"}, {"input": "9 3\r\nBBB\r\nBBB\r\nBBB\r\nGGG\r\nGGG\r\nGRG\r\nRGR\r\nRRR\r\nRRR\r\n", "output": "NO\r\n"}, {"input": "4 4\r\nRGBB\r\nRGBB\r\nRGBB\r\nRGBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRBR\r\nRBR\r\nRBR\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRRRRBB\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRRRRRR\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRRGGGG\r\n", "output": "NO\r\n"}, {"input": "4 4\r\nRRRR\r\nRRRR\r\nRRRR\r\nRRRR\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nB\r\nG\r\nB\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nR\r\nR\r\nR\r\n", "output": "NO\r\n"}, {"input": "1 9\r\nRRRGGGBBB\r\n", "output": "YES\r\n"}, {"input": "1 3\r\nRRR\r\n", "output": "NO\r\n"}, {"input": "3 5\r\nRRRRR\r\nBBBBB\r\nBBBBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nGGG\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "1 1\r\nR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGR\r\nRGR\r\nRGR\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRBG\r\nGBR\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nRGB\r\nRGB\r\n", "output": "YES\r\n"}, {"input": "1 3\r\nBRB\r\n", "output": "NO\r\n"}, {"input": "2 1\r\nR\r\nB\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRBR\r\n", "output": "NO\r\n"}, {"input": "3 5\r\nRRGBB\r\nRRGBB\r\nRRGBB\r\n", "output": "NO\r\n"}, {"input": "5 3\r\nBBR\r\nBBR\r\nBBR\r\nBBR\r\nBBR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nRBG\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "1 2\r\nRB\r\n", "output": "NO\r\n"}, {"input": "4 3\r\nBBB\r\nBBB\r\nBBB\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "36 6\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\n", "output": "NO\r\n"}, {"input": "4 1\r\nR\r\nB\r\nG\r\nR\r\n", "output": "NO\r\n"}, {"input": "13 12\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\n", "output": "NO\r\n"}, {"input": "2 2\r\nRR\r\nRR\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nRRGGBB\r\nGRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\n", "output": "NO\r\n"}, {"input": "70 3\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\n", "output": "NO\r\n"}, {"input": "4 3\r\nBBG\r\nBBG\r\nBBG\r\nBBG\r\n", "output": "NO\r\n"}, {"input": "6 3\r\nBBB\r\nGGG\r\nRRR\r\nBRG\r\nBRG\r\nBRG\r\n", "output": "NO\r\n"}, {"input": "3 6\r\nRRBBGG\r\nRBBBGG\r\nRBBBGG\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nGGGGGG\r\nGGGGGG\r\nBBBBBB\r\nBBBBBB\r\nGGGGGG\r\nGGGGGG\r\n", "output": "NO\r\n"}, {"input": "6 1\r\nR\r\nB\r\nG\r\nR\r\nB\r\nG\r\n", "output": "NO\r\n"}, {"input": "6 5\r\nRRRRR\r\nBBBBB\r\nGGGGG\r\nRRRRR\r\nBBBBB\r\nGGGGG\r\n", "output": "NO\r\n"}, {"input": "6 3\r\nRRR\r\nGGG\r\nBBB\r\nRRR\r\nGGG\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "6 5\r\nRRRRR\r\nRRRRR\r\nRRRRR\r\nGGGGG\r\nGGGGG\r\nGGGGG\r\n", "output": "NO\r\n"}, {"input": "15 28\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\n", "output": "NO\r\n"}, {"input": "21 10\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nBBBBBBBBBB\r\nBBBBBBBBBB\r\nBBBBBGBBBB\r\nBBBBBBBBBB\r\nBBBBBBBBBB\r\nBBBBBBBBBB\r\nBBBBBBBBBB\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\n", "output": "NO\r\n"}, {"input": "3 2\r\nRR\r\nGB\r\nGB\r\n", "output": "NO\r\n"}, {"input": "3 2\r\nRG\r\nRG\r\nBB\r\n", "output": "NO\r\n"}, {"input": "6 5\r\nRRRRR\r\nRRRRR\r\nBBBBB\r\nBBBBB\r\nRRRRR\r\nRRRRR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nGBR\r\nBRG\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nBGR\r\nBGR\r\nBGR\r\n", "output": "YES\r\n"}, {"input": "6 6\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\n", "output": "YES\r\n"}, {"input": "4 2\r\nRR\r\nGG\r\nRR\r\nBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nRRR\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "8 6\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\n", "output": "NO\r\n"}, {"input": "3 4\r\nRRRR\r\nRRRR\r\nGGGG\r\n", "output": "NO\r\n"}, {"input": "3 4\r\nRRRR\r\nRRRR\r\nRRRR\r\n", "output": "NO\r\n"}, {"input": "6 1\r\nR\r\nR\r\nR\r\nR\r\nR\r\nR\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRRBBGG\r\n", "output": "YES\r\n"}, {"input": "1 6\r\nRGBRGB\r\n", "output": "NO\r\n"}, {"input": "3 4\r\nRRRR\r\nGGGG\r\nRRRR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRB\r\nGRG\r\nGBB\r\n", "output": "NO\r\n"}, {"input": "3 7\r\nRRGGBBB\r\nRRGGBBB\r\nRRGGBBB\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nG\r\nR\r\nR\r\n", "output": "NO\r\n"}, {"input": "2 3\r\nRGG\r\nRBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRG\r\nGGG\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nRBB\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGR\r\nRGB\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nB\r\nR\r\nR\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nGRR\r\n", "output": "NO\r\n"}, {"input": "4 4\r\nRRRR\r\nGGGG\r\nBBBB\r\nBBBB\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nGGR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nGGB\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGR\r\nGGG\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nRRRRRR\r\nGGGGGG\r\nGGGGGG\r\nGGGGGG\r\nBBBBBB\r\nBBBBBB\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nRRRRRR\r\nRRRRRR\r\nGGGGGG\r\nBBBBBB\r\nBBBBBB\r\nBBBBBB\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nG\r\nB\r\nR\r\n", "output": "YES\r\n"}, {"input": "3 3\r\nGGB\r\nRGB\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nGRR\r\nGGG\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nRRRRRR\r\nRRRRRR\r\nGGGGGG\r\nGGGGGG\r\nBBBBBB\r\nRRRRRR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nGBG\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "3 8\r\nRRGGBBBB\r\nRRGGBBBB\r\nRRGGBBBB\r\n", "output": "NO\r\n"}, {"input": "2 2\r\nRR\r\nGG\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nRGR\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRBG\r\n", "output": "YES\r\n"}, {"input": "2 6\r\nRRGGBB\r\nGGRRBB\r\n", "output": "NO\r\n"}, {"input": "6 2\r\nRR\r\nGG\r\nBB\r\nRR\r\nGG\r\nBB\r\n", "output": "NO\r\n"}, {"input": "1 5\r\nRRGGB\r\n", "output": "NO\r\n"}, {"input": "1 2\r\nRG\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRGBRBG\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRRRGGB\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRGB\r\n", "output": "YES\r\n"}, {"input": "4 3\r\nRRR\r\nBBR\r\nGBB\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "6 3\r\nRRR\r\nBBB\r\nBBB\r\nBBB\r\nGGG\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRBG\r\nRBG\r\nRBG\r\n", "output": "YES\r\n"}, {"input": "6 3\r\nRRR\r\nBBB\r\nGGG\r\nRRR\r\nBBB\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "1 4\r\nRGBB\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\n", "output": "NO\r\n"}, {"input": "6 5\r\nRRRRR\r\nRRRRR\r\nGGGGG\r\nGGGGG\r\nRRRRR\r\nRRRRR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nBRG\r\nGBR\r\n", "output": "NO\r\n"}, {"input": "6 10\r\nRRRRRRRRRR\r\nGGGGGGGGGG\r\nBBBBBBBBBB\r\nRRRRRRRRRR\r\nGGGGGGGGGG\r\nBBBBBBBBBB\r\n", "output": "NO\r\n"}, {"input": "20 6\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\n", "output": "YES\r\n"}, {"input": "4 1\r\nR\r\nG\r\nB\r\nR\r\n", "output": "NO\r\n"}, {"input": "1 4\r\nRGBR\r\n", "output": "NO\r\n"}, {"input": "2 4\r\nRGBB\r\nRRGB\r\n", "output": "NO\r\n"}]
| false |
stdio
| null | true |
837/B
|
837
|
B
|
PyPy 3
|
TESTS
| 127 | 234 | 3,174,400 |
81700781
|
import math as mt
import sys,string
input=sys.stdin.readline
from collections import defaultdict
L=lambda : list(map(int,input().split()))
Ls=lambda : list(input().split())
M=lambda : map(int,input().split())
I=lambda :int(input())
n,m=M()
l=[]
flag=0
for i in range(n):
s=input().strip()
x=set([])
for j in s:
x.add(j)
if(len(x)==1):
flag=1
l.append(s)
if(flag==1 and n%3!=0):
print("NO")
exit()
elif(flag==1 and n%3==0):
x=set([])
for i in range(n//3):
r=set([])
for j in l[i]:
r.add(j)
if(len(r)==1):
x.add(str(l[i]))
if(len(x)!=1):
print("NO")
exit()
else:
print("NO")
exit()
for i in range(n//3,2*n//3):
r=set([])
for j in l[i]:
r.add(j)
if(len(r)==1):
x.add(str(l[i]))
if(len(x)!=2):
print("NO")
exit()
else:
print("NO")
exit()
for i in range(2*n//3,n):
r=set([])
for j in l[i]:
r.add(j)
if(len(r)==1):
x.add(str(l[i]))
if(len(x)!=3):
print("NO")
exit()
else:
print("NO")
exit()
if(len(x)==3):
print("YES")
exit()
else:
print("NO")
exit()
else:
if(m%3!=0):
print("NO")
exit()
e=[]
for i in range(m):
x=[]
for j in range(n):
x.append(l[j][i])
e.append(x)
l=e[::]
#print(*l)
d=n
n=m
m=d
x=set([])
for i in range(n//3):
r=set([])
for j in l[i]:
r.add(j)
if(len(r)==1):
x.add(str(l[i]))
if(len(x)!=1):
print("NO")
exit()
else:
print("NO")
exit()
for i in range(n//3,2*n//3):
r=set([])
for j in l[i]:
r.add(j)
if(len(r)==1):
x.add(str(l[i]))
if(len(x)!=2):
print("NO")
exit()
else:
print("NO")
exit()
for i in range(2*n//3,n):
r=set([])
for j in l[i]:
r.add(j)
if(len(r)==1):
x.add(str(l[i]))
if(len(x)!=3):
print("NO")
exit()
else:
print("NO")
exit()
if(len(x)==3):
print("YES")
exit()
else:
print("NO")
exit()
| 153 | 62 | 0 |
30220071
|
def solve_h(lines):
'''
>>> solve_h(['R', 'G', 'B'])
True
>>> solve_h(['RRR', 'GGG', 'BBB'])
True
>>> solve_h(['RRR', 'RRR', 'GGG', 'GGG', 'BBB', 'BBB'])
True
>>> solve_h(['RRR', 'RRR', 'RRR', 'GGG', 'BBB', 'BBB'])
False
>>> solve_h(['R', 'G', 'A'])
False
'''
if len(lines) == 0:
return False
if len(lines) % 3 != 0:
return False
strip = len(lines) // 3
colors = []
for i, line in enumerate(lines):
if i % strip == 0:
colors.append(line[0])
if not all(ch == colors[-1] for ch in line):
return False
if set(colors) != set('RGB'):
return False
return True
def transpose(lines):
'''
>>> transpose(['ABC', 'ABC'])
['AA', 'BB', 'CC']
>>> transpose(['ABCD', 'ABCD'])
['AA', 'BB', 'CC', 'DD']
'''
return list(''.join(chs) for chs in zip(*lines))
def solve_v(lines):
return solve_h(transpose(lines))
def solve(lines):
'''
>>> solve(['RGB', 'RGB'])
True
>>> solve(['RR', 'GG'])
False
>>> solve(['RGB', 'RGB', 'RGB', 'RGB'])
True
>>> solve('RRRGGGG RRRGGGG RRRGGGG RRRBBBB RRRBBBB RRRBBBB'.split())
False
>>> solve('RRRR RRRR BBBB GGGG'.split())
False
>>> solve('RRRR BBBB GGGG'.split())
True
>>> solve('BRG BRG BRG BRG'.split())
True
'''
return solve_h(lines) or solve_v(lines)
if __name__ == '__main__':
h, w = map(int, input().split())
lines = [input() for _ in range(h)]
print('YES' if solve(lines) else 'NO')
|
Educational Codeforces Round 26
|
ICPC
| 2,017 | 1 | 256 |
Flag of Berland
|
The flag of Berland is such rectangular field n × m that satisfies following conditions:
- Flag consists of three colors which correspond to letters 'R', 'G' and 'B'.
- Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color.
- Each color should be used in exactly one stripe.
You are given a field n × m, consisting of characters 'R', 'G' and 'B'. Output "YES" (without quotes) if this field corresponds to correct flag of Berland. Otherwise, print "NO" (without quotes).
|
The first line contains two integer numbers n and m (1 ≤ n, m ≤ 100) — the sizes of the field.
Each of the following n lines consisting of m characters 'R', 'G' and 'B' — the description of the field.
|
Print "YES" (without quotes) if the given field corresponds to correct flag of Berland . Otherwise, print "NO" (without quotes).
| null |
The field in the third example doesn't have three parralel stripes.
Rows of the field in the fourth example are parralel to each other and to borders. But they have different heights — 2, 1 and 1.
|
[{"input": "6 5\nRRRRR\nRRRRR\nBBBBB\nBBBBB\nGGGGG\nGGGGG", "output": "YES"}, {"input": "4 3\nBRG\nBRG\nBRG\nBRG", "output": "YES"}, {"input": "6 7\nRRRGGGG\nRRRGGGG\nRRRGGGG\nRRRBBBB\nRRRBBBB\nRRRBBBB", "output": "NO"}, {"input": "4 4\nRRRR\nRRRR\nBBBB\nGGGG", "output": "NO"}]
| 1,600 |
["brute force", "implementation"]
| 153 |
[{"input": "6 5\r\nRRRRR\r\nRRRRR\r\nBBBBB\r\nBBBBB\r\nGGGGG\r\nGGGGG\r\n", "output": "YES\r\n"}, {"input": "4 3\r\nBRG\r\nBRG\r\nBRG\r\nBRG\r\n", "output": "YES\r\n"}, {"input": "6 7\r\nRRRGGGG\r\nRRRGGGG\r\nRRRGGGG\r\nRRRBBBB\r\nRRRBBBB\r\nRRRBBBB\r\n", "output": "NO\r\n"}, {"input": "4 4\r\nRRRR\r\nRRRR\r\nBBBB\r\nGGGG\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nGRB\r\n", "output": "YES\r\n"}, {"input": "3 1\r\nR\r\nG\r\nB\r\n", "output": "YES\r\n"}, {"input": "4 3\r\nRGB\r\nGRB\r\nGRB\r\nGRB\r\n", "output": "NO\r\n"}, {"input": "4 6\r\nGGRRBB\r\nGGRRBB\r\nGGRRBB\r\nRRGGBB\r\n", "output": "NO\r\n"}, {"input": "100 3\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nGRB\r\n", "output": "NO\r\n"}, {"input": "3 100\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\nRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRG\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nR\r\nR\r\nB\r\n", "output": "NO\r\n"}, {"input": "3 2\r\nRR\r\nBB\r\nRR\r\n", "output": "NO\r\n"}, {"input": "3 2\r\nRR\r\nBG\r\nBG\r\n", "output": "NO\r\n"}, {"input": "3 2\r\nBB\r\nRR\r\nBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nRRR\r\nRRR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nGGG\r\nGGG\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRGG\r\n", "output": "NO\r\n"}, {"input": "4 3\r\nRGR\r\nRGR\r\nRGR\r\nRGR\r\n", "output": "NO\r\n"}, {"input": "3 4\r\nRRGG\r\nRRGG\r\nBBBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nBRG\r\nBRG\r\nBRG\r\n", "output": "YES\r\n"}, {"input": "3 1\r\nR\r\nG\r\nR\r\n", "output": "NO\r\n"}, {"input": "5 3\r\nBBG\r\nBBG\r\nBBG\r\nBBG\r\nBBG\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nGGG\r\nRRR\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRGR\r\n", "output": "NO\r\n"}, {"input": "3 6\r\nRRBBGG\r\nRRBBGG\r\nRRBBGG\r\n", "output": "YES\r\n"}, {"input": "6 6\r\nRRBBGG\r\nRRBBGG\r\nRRBBGG\r\nRRBBGG\r\nRRBBGG\r\nRRBBGG\r\n", "output": "YES\r\n"}, {"input": "4 3\r\nRRR\r\nGGG\r\nBBB\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nBBB\r\nRRR\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nB\r\nR\r\nB\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nBGB\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nB\r\nB\r\nB\r\n", "output": "NO\r\n"}, {"input": "3 4\r\nRRRR\r\nBBBB\r\nRRRR\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRGGGBB\r\n", "output": "NO\r\n"}, {"input": "9 3\r\nBBB\r\nBBB\r\nBBB\r\nGGG\r\nGGG\r\nGRG\r\nRGR\r\nRRR\r\nRRR\r\n", "output": "NO\r\n"}, {"input": "4 4\r\nRGBB\r\nRGBB\r\nRGBB\r\nRGBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRBR\r\nRBR\r\nRBR\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRRRRBB\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRRRRRR\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRRGGGG\r\n", "output": "NO\r\n"}, {"input": "4 4\r\nRRRR\r\nRRRR\r\nRRRR\r\nRRRR\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nB\r\nG\r\nB\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nR\r\nR\r\nR\r\n", "output": "NO\r\n"}, {"input": "1 9\r\nRRRGGGBBB\r\n", "output": "YES\r\n"}, {"input": "1 3\r\nRRR\r\n", "output": "NO\r\n"}, {"input": "3 5\r\nRRRRR\r\nBBBBB\r\nBBBBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nGGG\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "1 1\r\nR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGR\r\nRGR\r\nRGR\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRBG\r\nGBR\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nRGB\r\nRGB\r\n", "output": "YES\r\n"}, {"input": "1 3\r\nBRB\r\n", "output": "NO\r\n"}, {"input": "2 1\r\nR\r\nB\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRBR\r\n", "output": "NO\r\n"}, {"input": "3 5\r\nRRGBB\r\nRRGBB\r\nRRGBB\r\n", "output": "NO\r\n"}, {"input": "5 3\r\nBBR\r\nBBR\r\nBBR\r\nBBR\r\nBBR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nRBG\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "1 2\r\nRB\r\n", "output": "NO\r\n"}, {"input": "4 3\r\nBBB\r\nBBB\r\nBBB\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "36 6\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\n", "output": "NO\r\n"}, {"input": "4 1\r\nR\r\nB\r\nG\r\nR\r\n", "output": "NO\r\n"}, {"input": "13 12\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\n", "output": "NO\r\n"}, {"input": "2 2\r\nRR\r\nRR\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nRRGGBB\r\nGRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\n", "output": "NO\r\n"}, {"input": "70 3\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\n", "output": "NO\r\n"}, {"input": "4 3\r\nBBG\r\nBBG\r\nBBG\r\nBBG\r\n", "output": "NO\r\n"}, {"input": "6 3\r\nBBB\r\nGGG\r\nRRR\r\nBRG\r\nBRG\r\nBRG\r\n", "output": "NO\r\n"}, {"input": "3 6\r\nRRBBGG\r\nRBBBGG\r\nRBBBGG\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nGGGGGG\r\nGGGGGG\r\nBBBBBB\r\nBBBBBB\r\nGGGGGG\r\nGGGGGG\r\n", "output": "NO\r\n"}, {"input": "6 1\r\nR\r\nB\r\nG\r\nR\r\nB\r\nG\r\n", "output": "NO\r\n"}, {"input": "6 5\r\nRRRRR\r\nBBBBB\r\nGGGGG\r\nRRRRR\r\nBBBBB\r\nGGGGG\r\n", "output": "NO\r\n"}, {"input": "6 3\r\nRRR\r\nGGG\r\nBBB\r\nRRR\r\nGGG\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "6 5\r\nRRRRR\r\nRRRRR\r\nRRRRR\r\nGGGGG\r\nGGGGG\r\nGGGGG\r\n", "output": "NO\r\n"}, {"input": "15 28\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\n", "output": "NO\r\n"}, {"input": "21 10\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nBBBBBBBBBB\r\nBBBBBBBBBB\r\nBBBBBGBBBB\r\nBBBBBBBBBB\r\nBBBBBBBBBB\r\nBBBBBBBBBB\r\nBBBBBBBBBB\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\n", "output": "NO\r\n"}, {"input": "3 2\r\nRR\r\nGB\r\nGB\r\n", "output": "NO\r\n"}, {"input": "3 2\r\nRG\r\nRG\r\nBB\r\n", "output": "NO\r\n"}, {"input": "6 5\r\nRRRRR\r\nRRRRR\r\nBBBBB\r\nBBBBB\r\nRRRRR\r\nRRRRR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nGBR\r\nBRG\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nBGR\r\nBGR\r\nBGR\r\n", "output": "YES\r\n"}, {"input": "6 6\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\n", "output": "YES\r\n"}, {"input": "4 2\r\nRR\r\nGG\r\nRR\r\nBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nRRR\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "8 6\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\n", "output": "NO\r\n"}, {"input": "3 4\r\nRRRR\r\nRRRR\r\nGGGG\r\n", "output": "NO\r\n"}, {"input": "3 4\r\nRRRR\r\nRRRR\r\nRRRR\r\n", "output": "NO\r\n"}, {"input": "6 1\r\nR\r\nR\r\nR\r\nR\r\nR\r\nR\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRRBBGG\r\n", "output": "YES\r\n"}, {"input": "1 6\r\nRGBRGB\r\n", "output": "NO\r\n"}, {"input": "3 4\r\nRRRR\r\nGGGG\r\nRRRR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRB\r\nGRG\r\nGBB\r\n", "output": "NO\r\n"}, {"input": "3 7\r\nRRGGBBB\r\nRRGGBBB\r\nRRGGBBB\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nG\r\nR\r\nR\r\n", "output": "NO\r\n"}, {"input": "2 3\r\nRGG\r\nRBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRG\r\nGGG\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nRBB\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGR\r\nRGB\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nB\r\nR\r\nR\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nGRR\r\n", "output": "NO\r\n"}, {"input": "4 4\r\nRRRR\r\nGGGG\r\nBBBB\r\nBBBB\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nGGR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nGGB\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGR\r\nGGG\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nRRRRRR\r\nGGGGGG\r\nGGGGGG\r\nGGGGGG\r\nBBBBBB\r\nBBBBBB\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nRRRRRR\r\nRRRRRR\r\nGGGGGG\r\nBBBBBB\r\nBBBBBB\r\nBBBBBB\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nG\r\nB\r\nR\r\n", "output": "YES\r\n"}, {"input": "3 3\r\nGGB\r\nRGB\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nGRR\r\nGGG\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nRRRRRR\r\nRRRRRR\r\nGGGGGG\r\nGGGGGG\r\nBBBBBB\r\nRRRRRR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nGBG\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "3 8\r\nRRGGBBBB\r\nRRGGBBBB\r\nRRGGBBBB\r\n", "output": "NO\r\n"}, {"input": "2 2\r\nRR\r\nGG\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nRGR\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRBG\r\n", "output": "YES\r\n"}, {"input": "2 6\r\nRRGGBB\r\nGGRRBB\r\n", "output": "NO\r\n"}, {"input": "6 2\r\nRR\r\nGG\r\nBB\r\nRR\r\nGG\r\nBB\r\n", "output": "NO\r\n"}, {"input": "1 5\r\nRRGGB\r\n", "output": "NO\r\n"}, {"input": "1 2\r\nRG\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRGBRBG\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRRRGGB\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRGB\r\n", "output": "YES\r\n"}, {"input": "4 3\r\nRRR\r\nBBR\r\nGBB\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "6 3\r\nRRR\r\nBBB\r\nBBB\r\nBBB\r\nGGG\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRBG\r\nRBG\r\nRBG\r\n", "output": "YES\r\n"}, {"input": "6 3\r\nRRR\r\nBBB\r\nGGG\r\nRRR\r\nBBB\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "1 4\r\nRGBB\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\n", "output": "NO\r\n"}, {"input": "6 5\r\nRRRRR\r\nRRRRR\r\nGGGGG\r\nGGGGG\r\nRRRRR\r\nRRRRR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nBRG\r\nGBR\r\n", "output": "NO\r\n"}, {"input": "6 10\r\nRRRRRRRRRR\r\nGGGGGGGGGG\r\nBBBBBBBBBB\r\nRRRRRRRRRR\r\nGGGGGGGGGG\r\nBBBBBBBBBB\r\n", "output": "NO\r\n"}, {"input": "20 6\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\n", "output": "YES\r\n"}, {"input": "4 1\r\nR\r\nG\r\nB\r\nR\r\n", "output": "NO\r\n"}, {"input": "1 4\r\nRGBR\r\n", "output": "NO\r\n"}, {"input": "2 4\r\nRGBB\r\nRRGB\r\n", "output": "NO\r\n"}]
| false |
stdio
| null | true |
837/B
|
837
|
B
|
Python 3
|
TESTS
| 113 | 124 | 0 |
40912880
|
n,m=list(map(int,input().split()))
l=[0]*n
for i in range(n):
l[i]=input()
types=['B','G','R']
first=[]
second=[]
third=[]
counter=0
container=0
ans=[]
ans1=[]
if l[0].count('B')==l[0].count('R') and l[0].count('B')==l[0].count('G') :
first.append(l[0][0])
types.remove(first[0])
for i in range(len(l[0])):
if first[-1]==l[0][i]:
counter+=1
else:
first[0]=first[0]*counter
break
first1=first.copy()
second.append(types[0])
second[0]=second[0]*counter
second1 = second.copy()
third.append(types[1])
third[0] = third[0] * counter
list(third)
third1=third.copy()
first= first[0]+second[0]+third[0]
first1 = first1[0]+third[0]+second[0]
ans.append(first)
ans1.append(first1)
ans*=n
ans1*=n
else:
if l.count('B')==l.count('R')==l.count('G'):
first.append(l[0])
for i in range(len(l)):
if first[-1]==l[i]:
first.append(l[i])
else:
break
first.pop(0)
types.remove(first[0][0])
first1=first.copy()
second.append(0)
second[0]=types[0]*len(l[0])
second*=len(first)
second1=second.copy()
third.append(0)
third[0] = types[1] * len(l[0])
third *= len(first)
third1=third.copy()
first+=second
first+=third
first1+=third1
first1+=second1
ans=first
ans1=first1
if ans==l or ans1==l:
print('YES')
exit()
else:
print('NO')
exit()
| 153 | 62 | 307,200 |
31198872
|
import sys
#sys.stdin = open("input2","r")
n,m = map(int,input().split())
s = []
for i in range(n):
string = input()
s.append(string)
no = 0
# row mix check
r_mix = 0
for i in range(n):
cnt_r = s[i].count('R')
cnt_b = s[i].count('B')
cnt_g = s[i].count('G')
if ((cnt_r and cnt_b) or (cnt_b and cnt_g) or (cnt_g and cnt_r) ):
r_mix = 1
# col mix check
c_mix = 0
for j in range(m):
cnt_r = cnt_b = cnt_g = 0
for i in range(n):
if (s[i][j] == 'R'):
cnt_r += 1
elif (s[i][j] == 'B'):
cnt_b += 1
elif(s[i][j] == 'G'):
cnt_g += 1
if ((cnt_r and cnt_b) or (cnt_b and cnt_g) or (cnt_g and cnt_r) ):
c_mix = 1
if (r_mix == 1 and c_mix == 1) or ( r_mix == 0 and c_mix == 0):
no = 1
if(r_mix == 1):
cnt_b = cnt_g = cnt_r = 0
if s[0][0] == 'R':
cnt_r += 1
elif s[0][0] == 'G':
cnt_g += 1
elif s[0][0] == 'B':
cnt_b += 1
f,c = -1,1
for j in range(0,m-1):
if s[0][j] == s[0][j+1]:
c += 1
else:
if s[0][j+1] == 'R':
cnt_r += 1
elif s[0][j + 1] == 'G':
cnt_g += 1
elif s[0][j + 1] == 'B':
cnt_b += 1
if f == -1:
f = c
if f != c:
no = 1
break
c = 1
if ((f != c) or (cnt_r != 1 or cnt_b != 1 or cnt_g != 1)):
no = 1
if (c_mix):
f = -1
c = 1
cnt_b = 0
cnt_g = 0
cnt_r = 0
if s[0][0] == 'R':
cnt_r += 1
elif s[0][0] == 'G':
cnt_g += 1
elif s[0][0] == 'B':
cnt_b += 1
for i in range(0, n-1):
if s[i][0] == s[i+1][0]:
c += 1
#print('c',c)
else:
if s[i + 1][0] == 'R':
cnt_r += 1
elif s[i + 1][0] == 'G':
cnt_g += 1
elif s[i + 1][0] == 'B':
cnt_b += 1
if f == -1:
f = c
#print('f',f)
if f != c:
#print(f,c)
no = 1
break
c = 1
#print(cnt_r,cnt_b,cnt_g)
if ((f != c) or (cnt_r != 1 or cnt_b != 1 or cnt_g != 1)):
no = 1
if no == 1:
print('NO')
else:
print('YES')
|
Educational Codeforces Round 26
|
ICPC
| 2,017 | 1 | 256 |
Flag of Berland
|
The flag of Berland is such rectangular field n × m that satisfies following conditions:
- Flag consists of three colors which correspond to letters 'R', 'G' and 'B'.
- Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color.
- Each color should be used in exactly one stripe.
You are given a field n × m, consisting of characters 'R', 'G' and 'B'. Output "YES" (without quotes) if this field corresponds to correct flag of Berland. Otherwise, print "NO" (without quotes).
|
The first line contains two integer numbers n and m (1 ≤ n, m ≤ 100) — the sizes of the field.
Each of the following n lines consisting of m characters 'R', 'G' and 'B' — the description of the field.
|
Print "YES" (without quotes) if the given field corresponds to correct flag of Berland . Otherwise, print "NO" (without quotes).
| null |
The field in the third example doesn't have three parralel stripes.
Rows of the field in the fourth example are parralel to each other and to borders. But they have different heights — 2, 1 and 1.
|
[{"input": "6 5\nRRRRR\nRRRRR\nBBBBB\nBBBBB\nGGGGG\nGGGGG", "output": "YES"}, {"input": "4 3\nBRG\nBRG\nBRG\nBRG", "output": "YES"}, {"input": "6 7\nRRRGGGG\nRRRGGGG\nRRRGGGG\nRRRBBBB\nRRRBBBB\nRRRBBBB", "output": "NO"}, {"input": "4 4\nRRRR\nRRRR\nBBBB\nGGGG", "output": "NO"}]
| 1,600 |
["brute force", "implementation"]
| 153 |
[{"input": "6 5\r\nRRRRR\r\nRRRRR\r\nBBBBB\r\nBBBBB\r\nGGGGG\r\nGGGGG\r\n", "output": "YES\r\n"}, {"input": "4 3\r\nBRG\r\nBRG\r\nBRG\r\nBRG\r\n", "output": "YES\r\n"}, {"input": "6 7\r\nRRRGGGG\r\nRRRGGGG\r\nRRRGGGG\r\nRRRBBBB\r\nRRRBBBB\r\nRRRBBBB\r\n", "output": "NO\r\n"}, {"input": "4 4\r\nRRRR\r\nRRRR\r\nBBBB\r\nGGGG\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nGRB\r\n", "output": "YES\r\n"}, {"input": "3 1\r\nR\r\nG\r\nB\r\n", "output": "YES\r\n"}, {"input": "4 3\r\nRGB\r\nGRB\r\nGRB\r\nGRB\r\n", "output": "NO\r\n"}, {"input": "4 6\r\nGGRRBB\r\nGGRRBB\r\nGGRRBB\r\nRRGGBB\r\n", "output": "NO\r\n"}, {"input": "100 3\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nGRB\r\n", "output": "NO\r\n"}, {"input": "3 100\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\nRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRG\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nR\r\nR\r\nB\r\n", "output": "NO\r\n"}, {"input": "3 2\r\nRR\r\nBB\r\nRR\r\n", "output": "NO\r\n"}, {"input": "3 2\r\nRR\r\nBG\r\nBG\r\n", "output": "NO\r\n"}, {"input": "3 2\r\nBB\r\nRR\r\nBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nRRR\r\nRRR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nGGG\r\nGGG\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRGG\r\n", "output": "NO\r\n"}, {"input": "4 3\r\nRGR\r\nRGR\r\nRGR\r\nRGR\r\n", "output": "NO\r\n"}, {"input": "3 4\r\nRRGG\r\nRRGG\r\nBBBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nBRG\r\nBRG\r\nBRG\r\n", "output": "YES\r\n"}, {"input": "3 1\r\nR\r\nG\r\nR\r\n", "output": "NO\r\n"}, {"input": "5 3\r\nBBG\r\nBBG\r\nBBG\r\nBBG\r\nBBG\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nGGG\r\nRRR\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRGR\r\n", "output": "NO\r\n"}, {"input": "3 6\r\nRRBBGG\r\nRRBBGG\r\nRRBBGG\r\n", "output": "YES\r\n"}, {"input": "6 6\r\nRRBBGG\r\nRRBBGG\r\nRRBBGG\r\nRRBBGG\r\nRRBBGG\r\nRRBBGG\r\n", "output": "YES\r\n"}, {"input": "4 3\r\nRRR\r\nGGG\r\nBBB\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nBBB\r\nRRR\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nB\r\nR\r\nB\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nBGB\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nB\r\nB\r\nB\r\n", "output": "NO\r\n"}, {"input": "3 4\r\nRRRR\r\nBBBB\r\nRRRR\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRGGGBB\r\n", "output": "NO\r\n"}, {"input": "9 3\r\nBBB\r\nBBB\r\nBBB\r\nGGG\r\nGGG\r\nGRG\r\nRGR\r\nRRR\r\nRRR\r\n", "output": "NO\r\n"}, {"input": "4 4\r\nRGBB\r\nRGBB\r\nRGBB\r\nRGBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRBR\r\nRBR\r\nRBR\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRRRRBB\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRRRRRR\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRRGGGG\r\n", "output": "NO\r\n"}, {"input": "4 4\r\nRRRR\r\nRRRR\r\nRRRR\r\nRRRR\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nB\r\nG\r\nB\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nR\r\nR\r\nR\r\n", "output": "NO\r\n"}, {"input": "1 9\r\nRRRGGGBBB\r\n", "output": "YES\r\n"}, {"input": "1 3\r\nRRR\r\n", "output": "NO\r\n"}, {"input": "3 5\r\nRRRRR\r\nBBBBB\r\nBBBBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nGGG\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "1 1\r\nR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGR\r\nRGR\r\nRGR\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRBG\r\nGBR\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nRGB\r\nRGB\r\n", "output": "YES\r\n"}, {"input": "1 3\r\nBRB\r\n", "output": "NO\r\n"}, {"input": "2 1\r\nR\r\nB\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRBR\r\n", "output": "NO\r\n"}, {"input": "3 5\r\nRRGBB\r\nRRGBB\r\nRRGBB\r\n", "output": "NO\r\n"}, {"input": "5 3\r\nBBR\r\nBBR\r\nBBR\r\nBBR\r\nBBR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nRBG\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "1 2\r\nRB\r\n", "output": "NO\r\n"}, {"input": "4 3\r\nBBB\r\nBBB\r\nBBB\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "36 6\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\n", "output": "NO\r\n"}, {"input": "4 1\r\nR\r\nB\r\nG\r\nR\r\n", "output": "NO\r\n"}, {"input": "13 12\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\n", "output": "NO\r\n"}, {"input": "2 2\r\nRR\r\nRR\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nRRGGBB\r\nGRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\n", "output": "NO\r\n"}, {"input": "70 3\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\n", "output": "NO\r\n"}, {"input": "4 3\r\nBBG\r\nBBG\r\nBBG\r\nBBG\r\n", "output": "NO\r\n"}, {"input": "6 3\r\nBBB\r\nGGG\r\nRRR\r\nBRG\r\nBRG\r\nBRG\r\n", "output": "NO\r\n"}, {"input": "3 6\r\nRRBBGG\r\nRBBBGG\r\nRBBBGG\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nGGGGGG\r\nGGGGGG\r\nBBBBBB\r\nBBBBBB\r\nGGGGGG\r\nGGGGGG\r\n", "output": "NO\r\n"}, {"input": "6 1\r\nR\r\nB\r\nG\r\nR\r\nB\r\nG\r\n", "output": "NO\r\n"}, {"input": "6 5\r\nRRRRR\r\nBBBBB\r\nGGGGG\r\nRRRRR\r\nBBBBB\r\nGGGGG\r\n", "output": "NO\r\n"}, {"input": "6 3\r\nRRR\r\nGGG\r\nBBB\r\nRRR\r\nGGG\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "6 5\r\nRRRRR\r\nRRRRR\r\nRRRRR\r\nGGGGG\r\nGGGGG\r\nGGGGG\r\n", "output": "NO\r\n"}, {"input": "15 28\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\n", "output": "NO\r\n"}, {"input": "21 10\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nBBBBBBBBBB\r\nBBBBBBBBBB\r\nBBBBBGBBBB\r\nBBBBBBBBBB\r\nBBBBBBBBBB\r\nBBBBBBBBBB\r\nBBBBBBBBBB\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\n", "output": "NO\r\n"}, {"input": "3 2\r\nRR\r\nGB\r\nGB\r\n", "output": "NO\r\n"}, {"input": "3 2\r\nRG\r\nRG\r\nBB\r\n", "output": "NO\r\n"}, {"input": "6 5\r\nRRRRR\r\nRRRRR\r\nBBBBB\r\nBBBBB\r\nRRRRR\r\nRRRRR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nGBR\r\nBRG\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nBGR\r\nBGR\r\nBGR\r\n", "output": "YES\r\n"}, {"input": "6 6\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\n", "output": "YES\r\n"}, {"input": "4 2\r\nRR\r\nGG\r\nRR\r\nBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nRRR\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "8 6\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\n", "output": "NO\r\n"}, {"input": "3 4\r\nRRRR\r\nRRRR\r\nGGGG\r\n", "output": "NO\r\n"}, {"input": "3 4\r\nRRRR\r\nRRRR\r\nRRRR\r\n", "output": "NO\r\n"}, {"input": "6 1\r\nR\r\nR\r\nR\r\nR\r\nR\r\nR\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRRBBGG\r\n", "output": "YES\r\n"}, {"input": "1 6\r\nRGBRGB\r\n", "output": "NO\r\n"}, {"input": "3 4\r\nRRRR\r\nGGGG\r\nRRRR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRB\r\nGRG\r\nGBB\r\n", "output": "NO\r\n"}, {"input": "3 7\r\nRRGGBBB\r\nRRGGBBB\r\nRRGGBBB\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nG\r\nR\r\nR\r\n", "output": "NO\r\n"}, {"input": "2 3\r\nRGG\r\nRBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRG\r\nGGG\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nRBB\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGR\r\nRGB\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nB\r\nR\r\nR\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nGRR\r\n", "output": "NO\r\n"}, {"input": "4 4\r\nRRRR\r\nGGGG\r\nBBBB\r\nBBBB\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nGGR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nGGB\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGR\r\nGGG\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nRRRRRR\r\nGGGGGG\r\nGGGGGG\r\nGGGGGG\r\nBBBBBB\r\nBBBBBB\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nRRRRRR\r\nRRRRRR\r\nGGGGGG\r\nBBBBBB\r\nBBBBBB\r\nBBBBBB\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nG\r\nB\r\nR\r\n", "output": "YES\r\n"}, {"input": "3 3\r\nGGB\r\nRGB\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nGRR\r\nGGG\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nRRRRRR\r\nRRRRRR\r\nGGGGGG\r\nGGGGGG\r\nBBBBBB\r\nRRRRRR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nGBG\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "3 8\r\nRRGGBBBB\r\nRRGGBBBB\r\nRRGGBBBB\r\n", "output": "NO\r\n"}, {"input": "2 2\r\nRR\r\nGG\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nRGR\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRBG\r\n", "output": "YES\r\n"}, {"input": "2 6\r\nRRGGBB\r\nGGRRBB\r\n", "output": "NO\r\n"}, {"input": "6 2\r\nRR\r\nGG\r\nBB\r\nRR\r\nGG\r\nBB\r\n", "output": "NO\r\n"}, {"input": "1 5\r\nRRGGB\r\n", "output": "NO\r\n"}, {"input": "1 2\r\nRG\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRGBRBG\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRRRGGB\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRGB\r\n", "output": "YES\r\n"}, {"input": "4 3\r\nRRR\r\nBBR\r\nGBB\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "6 3\r\nRRR\r\nBBB\r\nBBB\r\nBBB\r\nGGG\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRBG\r\nRBG\r\nRBG\r\n", "output": "YES\r\n"}, {"input": "6 3\r\nRRR\r\nBBB\r\nGGG\r\nRRR\r\nBBB\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "1 4\r\nRGBB\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\n", "output": "NO\r\n"}, {"input": "6 5\r\nRRRRR\r\nRRRRR\r\nGGGGG\r\nGGGGG\r\nRRRRR\r\nRRRRR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nBRG\r\nGBR\r\n", "output": "NO\r\n"}, {"input": "6 10\r\nRRRRRRRRRR\r\nGGGGGGGGGG\r\nBBBBBBBBBB\r\nRRRRRRRRRR\r\nGGGGGGGGGG\r\nBBBBBBBBBB\r\n", "output": "NO\r\n"}, {"input": "20 6\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\n", "output": "YES\r\n"}, {"input": "4 1\r\nR\r\nG\r\nB\r\nR\r\n", "output": "NO\r\n"}, {"input": "1 4\r\nRGBR\r\n", "output": "NO\r\n"}, {"input": "2 4\r\nRGBB\r\nRRGB\r\n", "output": "NO\r\n"}]
| false |
stdio
| null | true |
792/C
|
792
|
C
|
Python 3
|
TESTS
| 34 | 155 | 9,318,400 |
26250901
|
def checkBeauty (digi):
total = 0
for i in range(0,len(digi)):
total += int(digi[i])
return total % 3
def modThree (digi):
zero = []
one = []
two = []
for i in range(0,len(digi)):
if int(digi[i]) % 3 == 0:
zero.append(i)
elif int(digi[i]) % 3 == 1:
one.append(i)
else:
two.append(i)
modResult = []
modResult.append(zero)
modResult.append(one)
modResult.append(two)
return modResult
def checkHead (digi):
if len(digi) == 0: return -1
while len(digi) > 1:
if int(digi[0]) == 0:
digi.pop(0)
else: break
return "".join(digi)
x = list(input())
modResult = modThree(x)
numToDel = checkBeauty(x)
finalResult = -1
delOne = []
delTwo = []
if numToDel == 0:
finalResult = checkHead(x)
elif numToDel == 1:
if len(modResult[1]) != 0:
delOne = x[:]
delOne.pop(modResult[1][0])
if len(modResult[2]) > 1:
delTwo = x[:]
delTwo.pop(modResult[2][0])
delTwo.pop(modResult[2][1] - 1)
else:
if len(modResult[2]) != 0:
delTwo = x[:]
delTwo.pop(modResult[2][0])
if len(modResult[1]) > 1:
delOne = x[:]
delOne.pop(modResult[1][0])
delOne.pop(modResult[1][1] - 1)
resultOne = checkHead(delOne)
resultTwo = checkHead(delTwo)
if resultOne == -1 and resultTwo != -1:
finalResult = resultTwo
elif resultOne != -1 and resultTwo == -1:
finalResult = resultOne
elif resultOne != -1 and resultTwo != -1:
finalResult = resultTwo if len(resultTwo) > len(resultOne) else resultOne
print (finalResult)
| 162 | 109 | 7,168,000 |
32921983
|
import re
f = lambda t: re.sub(r'^0+(\d)', r'\1', t)
g = lambda k: n - p.index(s, k)
t = input()
n = len(t) - 1
p = [int(q) % 3 for q in t][::-1]
s = sum(p) % 3
if s == 0:
print(t)
exit()
u = v = ''
if s in p:
i = g(0)
u = f(t[:i] + t[i + 1:])
s = 3 - s
if p.count(s) > 1:
i = g(0)
j = g(n - i + 1)
v = f(t[:j] + t[j + 1:i] + t[i + 1:])
t = u if len(u) > len(v) else v
print(t if t else -1)
|
Educational Codeforces Round 18
|
ICPC
| 2,017 | 1 | 256 |
Divide by Three
|
A positive integer number n is written on a blackboard. It consists of not more than 105 digits. You have to transform it into a beautiful number by erasing some of the digits, and you want to erase as few digits as possible.
The number is called beautiful if it consists of at least one digit, doesn't have leading zeroes and is a multiple of 3. For example, 0, 99, 10110 are beautiful numbers, and 00, 03, 122 are not.
Write a program which for the given n will find a beautiful number such that n can be transformed into this number by erasing as few digits as possible. You can erase an arbitraty set of digits. For example, they don't have to go one after another in the number n.
If it's impossible to obtain a beautiful number, print -1. If there are multiple answers, print any of them.
|
The first line of input contains n — a positive integer number without leading zeroes (1 ≤ n < 10100000).
|
Print one number — any beautiful number obtained by erasing as few as possible digits. If there is no answer, print - 1.
| null |
In the first example it is enough to erase only the first digit to obtain a multiple of 3. But if we erase the first digit, then we obtain a number with a leading zero. So the minimum number of digits to be erased is two.
|
[{"input": "1033", "output": "33"}, {"input": "10", "output": "0"}, {"input": "11", "output": "-1"}]
| 2,000 |
["dp", "greedy", "math", "number theory"]
| 162 |
[{"input": "1033\r\n", "output": "33\r\n"}, {"input": "10\r\n", "output": "0\r\n"}, {"input": "11\r\n", "output": "-1\r\n"}, {"input": "3\r\n", "output": "3\r\n"}, {"input": "1\r\n", "output": "-1\r\n"}, {"input": "117\r\n", "output": "117\r\n"}, {"input": "518\r\n", "output": "18\r\n"}, {"input": "327\r\n", "output": "327\r\n"}, {"input": "270461\r\n", "output": "70461\r\n"}, {"input": "609209\r\n", "output": "60909\r\n"}, {"input": "110930\r\n", "output": "930\r\n"}, {"input": "37616145150713688775\r\n", "output": "3616145150713688775\r\n"}, {"input": "98509135612114839419\r\n", "output": "9509135612114839419\r\n"}, {"input": "41674994051436988162\r\n", "output": "1674994051436988162\r\n"}, {"input": "82547062721736129804\r\n", "output": "82547062721736129804\r\n"}, {"input": "4902501252475186372406731932548506197390793597574544727433297197476846519276598727359617092494798814\r\n", "output": "490501252475186372406731932548506197390793597574544727433297197476846519276598727359617092494798814\r\n"}, {"input": "1291007209605301446874998623691572528836214969878676835460982410817526074579818247646933326771899122\r\n", "output": "1291007209605301446874998623691572528836214969878676835460982410817526074579818247646933326771899122\r\n"}, {"input": "5388306043547446322173224045662327678394712363272776811399689704247387317165308057863239568137902157\r\n", "output": "538830603547446322173224045662327678394712363272776811399689704247387317165308057863239568137902157\r\n"}, {"input": "20000111\r\n", "output": "200001\r\n"}, {"input": "100222\r\n", "output": "1002\r\n"}, {"input": "202\r\n", "output": "0\r\n"}, {"input": "100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000033\r\n", "output": "33\r\n"}, {"input": "101\r\n", "output": "0\r\n"}, {"input": "1000000222\r\n", "output": "10000002\r\n"}, {"input": "1001\r\n", "output": "0\r\n"}, {"input": "205\r\n", "output": "0\r\n"}, {"input": "102211\r\n", "output": "10221\r\n"}, {"input": "100000002022\r\n", "output": "1000000002\r\n"}, {"input": "20203\r\n", "output": "3\r\n"}, {"input": "1002001\r\n", "output": "100200\r\n"}, {"input": "10002223\r\n", "output": "100023\r\n"}, {"input": "1002223\r\n", "output": "10023\r\n"}, {"input": "100000231\r\n", "output": "10000023\r\n"}, {"input": "220\r\n", "output": "0\r\n"}, {"input": "322\r\n", "output": "3\r\n"}, {"input": "100000222\r\n", "output": "1000002\r\n"}, {"input": "10033\r\n", "output": "33\r\n"}, {"input": "2003302\r\n", "output": "330\r\n"}, {"input": "10011001\r\n", "output": "1001001\r\n"}, {"input": "20000000011001111\r\n", "output": "200000000001111\r\n"}, {"input": "100000000\r\n", "output": "0\r\n"}, {"input": "1000\r\n", "output": "0\r\n"}, {"input": "200000000000000000000000000008\r\n", "output": "0\r\n"}, {"input": "1000000000000222\r\n", "output": "10000000000002\r\n"}, {"input": "100000000000000000222\r\n", "output": "1000000000000000002\r\n"}, {"input": "29512\r\n", "output": "2952\r\n"}, {"input": "88888888888888\r\n", "output": "888888888888\r\n"}, {"input": "100000000000222\r\n", "output": "1000000000002\r\n"}, {"input": "11000000\r\n", "output": "0\r\n"}, {"input": "2200\r\n", "output": "0\r\n"}, {"input": "10000555\r\n", "output": "100005\r\n"}, {"input": "1000222\r\n", "output": "10002\r\n"}, {"input": "10021\r\n", "output": "1002\r\n"}, {"input": "223\r\n", "output": "3\r\n"}, {"input": "1013\r\n", "output": "3\r\n"}, {"input": "100020001\r\n", "output": "10002000\r\n"}, {"input": "20000000000000000000932\r\n", "output": "93\r\n"}, {"input": "1010\r\n", "output": "0\r\n"}, {"input": "2000000002222\r\n", "output": "20000000022\r\n"}, {"input": "10213\r\n", "output": "1023\r\n"}, {"input": "109111\r\n", "output": "10911\r\n"}, {"input": "1010101010\r\n", "output": "10001010\r\n"}, {"input": "300055\r\n", "output": "3000\r\n"}, {"input": "200200\r\n", "output": "0\r\n"}, {"input": "202222\r\n", "output": "2022\r\n"}, {"input": "4000888\r\n", "output": "40008\r\n"}, {"input": "200000111\r\n", "output": "2000001\r\n"}, {"input": "2000000111\r\n", "output": "20000001\r\n"}, {"input": "1000000\r\n", "output": "0\r\n"}, {"input": "1003301\r\n", "output": "330\r\n"}, {"input": "100001\r\n", "output": "0\r\n"}, {"input": "40000000000000000000888\r\n", "output": "400000000000000000008\r\n"}, {"input": "100000\r\n", "output": "0\r\n"}, {"input": "4000000888\r\n", "output": "40000008\r\n"}, {"input": "334733\r\n", "output": "3333\r\n"}, {"input": "1000002220\r\n", "output": "10000020\r\n"}, {"input": "100321\r\n", "output": "10032\r\n"}, {"input": "101111\r\n", "output": "1011\r\n"}, {"input": "100000000222\r\n", "output": "1000000002\r\n"}, {"input": "10001\r\n", "output": "0\r\n"}, {"input": "7\r\n", "output": "-1\r\n"}, {"input": "2000000000111\r\n", "output": "20000000001\r\n"}, {"input": "100000001\r\n", "output": "0\r\n"}, {"input": "10000000000222\r\n", "output": "100000000002\r\n"}, {"input": "200000000000000111\r\n", "output": "2000000000000001\r\n"}, {"input": "404044\r\n", "output": "40044\r\n"}, {"input": "30202\r\n", "output": "300\r\n"}, {"input": "20000000000000000111\r\n", "output": "200000000000000001\r\n"}, {"input": "707\r\n", "output": "0\r\n"}, {"input": "20000300000000003000050000003\r\n", "output": "30000000000300000000003\r\n"}, {"input": "400000888\r\n", "output": "4000008\r\n"}, {"input": "2888\r\n", "output": "888\r\n"}, {"input": "200111\r\n", "output": "2001\r\n"}, {"input": "10000000888\r\n", "output": "100000008\r\n"}, {"input": "40000888\r\n", "output": "400008\r\n"}, {"input": "40404044\r\n", "output": "400044\r\n"}, {"input": "5500000000\r\n", "output": "0\r\n"}, {"input": "100012\r\n", "output": "10002\r\n"}, {"input": "1000007\r\n", "output": "0\r\n"}, {"input": "200093\r\n", "output": "93\r\n"}, {"input": "10000000222\r\n", "output": "100000002\r\n"}, {"input": "20000000002\r\n", "output": "0\r\n"}, {"input": "74333\r\n", "output": "333\r\n"}, {"input": "200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\r\n", "output": "0\r\n"}, {"input": "10000000111\r\n", "output": "1000000011\r\n"}, {"input": "100007\r\n", "output": "0\r\n"}, {"input": "20000006711\r\n", "output": "200000061\r\n"}, {"input": "8059\r\n", "output": "9\r\n"}, {"input": "8008\r\n", "output": "0\r\n"}, {"input": "88\r\n", "output": "-1\r\n"}, {"input": "2002\r\n", "output": "0\r\n"}, {"input": "2000111\r\n", "output": "20001\r\n"}, {"input": "100000000100000002\r\n", "output": "10000000000000002\r\n"}, {"input": "1000000000000000000000000000000000\r\n", "output": "0\r\n"}, {"input": "10000000000000000222\r\n", "output": "100000000000000002\r\n"}, {"input": "1000001\r\n", "output": "0\r\n"}, {"input": "200000000000111\r\n", "output": "2000000000001\r\n"}, {"input": "2000000002\r\n", "output": "0\r\n"}, {"input": "2010000100001\r\n", "output": "10000100001\r\n"}, {"input": "200330\r\n", "output": "330\r\n"}, {"input": "10000222\r\n", "output": "100002\r\n"}, {"input": "2005\r\n", "output": "0\r\n"}, {"input": "100000000000822\r\n", "output": "1000000000002\r\n"}, {"input": "10000000000000000000000\r\n", "output": "0\r\n"}, {"input": "7046\r\n", "output": "6\r\n"}, {"input": "4000117\r\n", "output": "400017\r\n"}, {"input": "971\r\n", "output": "9\r\n"}, {"input": "404\r\n", "output": "0\r\n"}, {"input": "5\r\n", "output": "-1\r\n"}, {"input": "164\r\n", "output": "6\r\n"}, {"input": "140\r\n", "output": "0\r\n"}, {"input": "74\r\n", "output": "-1\r\n"}, {"input": "2058232\r\n", "output": "20232\r\n"}, {"input": "4\r\n", "output": "-1\r\n"}, {"input": "20206\r\n", "output": "6\r\n"}, {"input": "103310\r\n", "output": "330\r\n"}, {"input": "100\r\n", "output": "0\r\n"}, {"input": "417179\r\n", "output": "7179\r\n"}, {"input": "70558\r\n", "output": "558\r\n"}, {"input": "298\r\n", "output": "9\r\n"}, {"input": "7003\r\n", "output": "3\r\n"}, {"input": "2212\r\n", "output": "222\r\n"}, {"input": "1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001\r\n", "output": "0\r\n"}, {"input": "2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002\r\n", "output": "0\r\n"}, {"input": "1002200\r\n", "output": "100200\r\n"}, {"input": "1222\r\n", "output": "222\r\n"}, {"input": "101200100\r\n", "output": "10100100\r\n"}, {"input": "1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003\r\n", "output": "3\r\n"}, {"input": "20020201\r\n", "output": "2002020\r\n"}, {"input": "12122\r\n", "output": "1122\r\n"}, {"input": "20200\r\n", "output": "0\r\n"}, {"input": "2\r\n", "output": "-1\r\n"}, {"input": "1000000000000258\r\n", "output": "10000000000008\r\n"}]
| false |
stdio
|
import sys
def is_subsequence(s, t):
t_iter = iter(t)
try:
for c in s:
while next(t_iter) != c:
pass
return True
except StopIteration:
return False
def is_beautiful(s):
if not s:
return False
if s[0] == '0' and len(s) > 1:
return False
total = sum(int(c) for c in s)
return total % 3 == 0
def compute_max_length(n):
sum_digits = sum(int(c) for c in n)
sum_mod3 = sum_digits % 3
has_zero = '0' in n
if sum_mod3 == 0:
if n[0] != '0':
return len(n)
first_non_zero = next((i for i, c in enumerate(n) if c != '0'), None)
if first_non_zero is None:
return 1
return len(n) - first_non_zero
else:
candidates = []
for i, c in enumerate(n):
if int(c) % 3 == sum_mod3:
new_n = n[:i] + n[i+1:]
if not new_n:
continue
first_non_zero = next((j for j, ch in enumerate(new_n) if ch != '0'), None)
if first_non_zero is None:
candidates.append(1)
else:
candidates.append(len(new_n) - first_non_zero)
target_mod = (3 - sum_mod3) % 3
mod_digits = [i for i, c in enumerate(n) if int(c) % 3 == target_mod]
if len(mod_digits) >= 2:
i, j = mod_digits[-2], mod_digits[-1]
new_n = n[:i] + n[i+1:j] + n[j+1:]
if new_n:
first_non_zero = next((k for k, ch in enumerate(new_n) if ch != '0'), None)
if first_non_zero is None:
candidates.append(1)
else:
candidates.append(len(new_n) - first_non_zero)
if has_zero:
candidates.append(1)
return max(candidates) if candidates else 0
def main(input_path, output_path, submission_path):
with open(input_path, 'r') as f:
n = f.read().strip()
with open(submission_path, 'r') as f:
submission = f.read().strip()
if submission == '-1':
max_len = compute_max_length(n)
print(100 if max_len == 0 else 0)
else:
if not is_subsequence(submission, n) or not is_beautiful(submission):
print(0)
return
max_len = compute_max_length(n)
print(100 if len(submission) == max_len else 0)
if __name__ == '__main__':
input_path, output_path, submission_path = sys.argv[1], sys.argv[2], sys.argv[3]
main(input_path, output_path, submission_path)
| true |
807/A
|
807
|
A
|
Python 3
|
TESTS
| 43 | 109 | 102,400 |
47254713
|
n=int(input())
x,y=[],[]
for i in range(n):
a,b=map(int,input().split())
x.append(a)
y.append(b)
z=x[:]
z.sort()
z.reverse()
if z==y:
print("maybe")
exit()
if x==y:
print("unrated")
exit()
if x!=y:
print("rated")
| 150 | 46 | 0 |
131984875
|
t=int(input())
c=0
l=[]
for i in range(t):
a,b=map(int,input().split())
l.append(b)
if a==b:
c=c+1
if c!=t:
print("rated")
else:
r=l[:]
r.sort(reverse=True)
if l==r:
print("maybe")
else:
print("unrated")
|
Codeforces Round 412 (rated, Div. 2, base on VK Cup 2017 Round 3)
|
CF
| 2,017 | 2 | 256 |
Is it rated?
|
Is it rated?
Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it.
Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before and after the round is known.
It's known that if at least one participant's rating has changed, then the round was rated for sure.
It's also known that if the round was rated and a participant with lower rating took a better place in the standings than a participant with higher rating, then at least one round participant's rating has changed.
In this problem, you should not make any other assumptions about the rating system.
Determine if the current round is rated, unrated, or it's impossible to determine whether it is rated of not.
|
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of round participants.
Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 4126) — the rating of the i-th participant before and after the round, respectively. The participants are listed in order from the top to the bottom of the standings.
|
If the round is rated for sure, print "rated". If the round is unrated for sure, print "unrated". If it's impossible to determine whether the round is rated or not, print "maybe".
| null |
In the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated.
In the second example, no one's rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, someone's rating would've changed for sure.
In the third example, no one's rating has changed, and the participants took places in non-increasing order of their rating. Therefore, it's impossible to determine whether the round is rated or not.
|
[{"input": "6\n3060 3060\n2194 2194\n2876 2903\n2624 2624\n3007 2991\n2884 2884", "output": "rated"}, {"input": "4\n1500 1500\n1300 1300\n1200 1200\n1400 1400", "output": "unrated"}, {"input": "5\n3123 3123\n2777 2777\n2246 2246\n2246 2246\n1699 1699", "output": "maybe"}]
| 900 |
["implementation", "sortings"]
| 150 |
[{"input": "6\r\n3060 3060\r\n2194 2194\r\n2876 2903\r\n2624 2624\r\n3007 2991\r\n2884 2884\r\n", "output": "rated\r\n"}, {"input": "4\r\n1500 1500\r\n1300 1300\r\n1200 1200\r\n1400 1400\r\n", "output": "unrated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n1699 1699\r\n", "output": "maybe\r\n"}, {"input": "2\r\n1 1\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "2\r\n4126 4126\r\n4126 4126\r\n", "output": "maybe\r\n"}, {"input": "10\r\n446 446\r\n1331 1331\r\n3594 3594\r\n1346 1902\r\n91 91\r\n3590 3590\r\n2437 2437\r\n4007 3871\r\n2797 699\r\n1423 1423\r\n", "output": "rated\r\n"}, {"input": "10\r\n4078 4078\r\n2876 2876\r\n1061 1061\r\n3721 3721\r\n143 143\r\n2992 2992\r\n3279 3279\r\n3389 3389\r\n1702 1702\r\n1110 1110\r\n", "output": "unrated\r\n"}, {"input": "10\r\n4078 4078\r\n3721 3721\r\n3389 3389\r\n3279 3279\r\n2992 2992\r\n2876 2876\r\n1702 1702\r\n1110 1110\r\n1061 1061\r\n143 143\r\n", "output": "maybe\r\n"}, {"input": "2\r\n3936 3936\r\n2967 2967\r\n", "output": "maybe\r\n"}, {"input": "2\r\n1 1\r\n2 2\r\n", "output": "unrated\r\n"}, {"input": "2\r\n2 2\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "2\r\n2 1\r\n1 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n2967 2967\r\n3936 3936\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1200 1200\r\n1200 1200\r\n1300 1300\r\n", "output": "unrated\r\n"}, {"input": "3\r\n3 3\r\n2 2\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "3\r\n1 1\r\n1 1\r\n2 2\r\n", "output": "unrated\r\n"}, {"input": "2\r\n3 2\r\n3 2\r\n", "output": "rated\r\n"}, {"input": "3\r\n5 5\r\n4 4\r\n3 4\r\n", "output": "rated\r\n"}, {"input": "3\r\n200 200\r\n200 200\r\n300 300\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1 1\r\n2 2\r\n3 3\r\n", "output": "unrated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2245 2245\r\n1699 1699\r\n", "output": "maybe\r\n"}, {"input": "2\r\n10 10\r\n8 8\r\n", "output": "maybe\r\n"}, {"input": "3\r\n1500 1500\r\n1500 1500\r\n1600 1600\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1500 1500\r\n1500 1500\r\n1700 1700\r\n", "output": "unrated\r\n"}, {"input": "4\r\n100 100\r\n100 100\r\n70 70\r\n80 80\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1 2\r\n2 1\r\n", "output": "rated\r\n"}, {"input": "3\r\n5 5\r\n4 3\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "3\r\n1600 1650\r\n1500 1550\r\n1400 1450\r\n", "output": "rated\r\n"}, {"input": "4\r\n2000 2000\r\n1500 1500\r\n1500 1500\r\n1700 1700\r\n", "output": "unrated\r\n"}, {"input": "4\r\n1500 1500\r\n1400 1400\r\n1400 1400\r\n1700 1700\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1600 1600\r\n1400 1400\r\n", "output": "maybe\r\n"}, {"input": "2\r\n3 1\r\n9 8\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 1\r\n1 1\r\n", "output": "rated\r\n"}, {"input": "4\r\n4123 4123\r\n4123 4123\r\n2670 2670\r\n3670 3670\r\n", "output": "unrated\r\n"}, {"input": "2\r\n2 2\r\n3 3\r\n", "output": "unrated\r\n"}, {"input": "2\r\n10 11\r\n5 4\r\n", "output": "rated\r\n"}, {"input": "2\r\n15 14\r\n13 12\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 1\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "3\r\n2670 2670\r\n3670 3670\r\n4106 4106\r\n", "output": "unrated\r\n"}, {"input": "3\r\n4 5\r\n3 3\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n10 9\r\n10 10\r\n", "output": "rated\r\n"}, {"input": "3\r\n1011 1011\r\n1011 999\r\n2200 2100\r\n", "output": "rated\r\n"}, {"input": "2\r\n3 3\r\n5 5\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1500 1500\r\n3000 2000\r\n", "output": "rated\r\n"}, {"input": "2\r\n5 6\r\n5 5\r\n", "output": "rated\r\n"}, {"input": "3\r\n2000 2000\r\n1500 1501\r\n500 500\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 3\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n3 3\r\n2 2\r\n", "output": "maybe\r\n"}, {"input": "2\r\n1 2\r\n1 1\r\n", "output": "rated\r\n"}, {"input": "4\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n1699 1699\r\n", "output": "maybe\r\n"}, {"input": "2\r\n15 14\r\n14 13\r\n", "output": "rated\r\n"}, {"input": "4\r\n3000 3000\r\n2900 2900\r\n3000 3000\r\n2900 2900\r\n", "output": "unrated\r\n"}, {"input": "6\r\n30 3060\r\n24 2194\r\n26 2903\r\n24 2624\r\n37 2991\r\n24 2884\r\n", "output": "rated\r\n"}, {"input": "2\r\n100 99\r\n100 100\r\n", "output": "rated\r\n"}, {"input": "4\r\n2 2\r\n1 1\r\n1 1\r\n2 2\r\n", "output": "unrated\r\n"}, {"input": "3\r\n100 101\r\n100 100\r\n100 100\r\n", "output": "rated\r\n"}, {"input": "4\r\n1000 1001\r\n900 900\r\n950 950\r\n890 890\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 3\r\n1 1\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 2\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "2\r\n3 2\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n3 2\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "2\r\n1 1\r\n2 2\r\n", "output": "unrated\r\n"}, {"input": "3\r\n3 2\r\n3 3\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "4\r\n1500 1501\r\n1300 1300\r\n1200 1200\r\n1400 1400\r\n", "output": "rated\r\n"}, {"input": "3\r\n1000 1000\r\n500 500\r\n400 300\r\n", "output": "rated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n3000 3000\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1 1\r\n2 3\r\n", "output": "rated\r\n"}, {"input": "2\r\n6 2\r\n6 2\r\n", "output": "rated\r\n"}, {"input": "5\r\n3123 3123\r\n1699 1699\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1500 1500\r\n1600 1600\r\n", "output": "unrated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2241 2241\r\n1699 1699\r\n", "output": "maybe\r\n"}, {"input": "2\r\n20 30\r\n10 5\r\n", "output": "rated\r\n"}, {"input": "3\r\n1 1\r\n2 2\r\n1 1\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1 2\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "5\r\n5 5\r\n4 4\r\n3 3\r\n2 2\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "2\r\n2 2\r\n2 1\r\n", "output": "rated\r\n"}, {"input": "2\r\n100 100\r\n90 89\r\n", "output": "rated\r\n"}, {"input": "2\r\n1000 900\r\n2000 2000\r\n", "output": "rated\r\n"}, {"input": "2\r\n50 10\r\n10 50\r\n", "output": "rated\r\n"}, {"input": "2\r\n200 200\r\n100 100\r\n", "output": "maybe\r\n"}, {"input": "3\r\n2 2\r\n2 2\r\n3 3\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1000 1000\r\n300 300\r\n100 100\r\n", "output": "maybe\r\n"}, {"input": "4\r\n2 2\r\n2 2\r\n3 3\r\n4 4\r\n", "output": "unrated\r\n"}, {"input": "2\r\n5 3\r\n6 3\r\n", "output": "rated\r\n"}, {"input": "2\r\n1200 1100\r\n1200 1000\r\n", "output": "rated\r\n"}, {"input": "2\r\n5 5\r\n4 4\r\n", "output": "maybe\r\n"}, {"input": "2\r\n5 5\r\n3 3\r\n", "output": "maybe\r\n"}, {"input": "5\r\n1500 1500\r\n1300 1300\r\n1200 1200\r\n1400 1400\r\n1100 1100\r\n", "output": "unrated\r\n"}, {"input": "5\r\n10 10\r\n9 9\r\n8 8\r\n7 7\r\n6 6\r\n", "output": "maybe\r\n"}, {"input": "3\r\n1000 1000\r\n300 300\r\n10 10\r\n", "output": "maybe\r\n"}, {"input": "5\r\n6 6\r\n5 5\r\n4 4\r\n3 3\r\n2 2\r\n", "output": "maybe\r\n"}, {"input": "2\r\n3 3\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "4\r\n2 2\r\n2 2\r\n2 2\r\n3 3\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1000 1000\r\n700 700\r\n", "output": "maybe\r\n"}, {"input": "2\r\n4 3\r\n5 3\r\n", "output": "rated\r\n"}, {"input": "2\r\n1000 1000\r\n1100 1100\r\n", "output": "unrated\r\n"}, {"input": "4\r\n5 5\r\n4 4\r\n3 3\r\n2 2\r\n", "output": "maybe\r\n"}, {"input": "3\r\n1 1\r\n2 3\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n1 2\r\n1 3\r\n", "output": "rated\r\n"}, {"input": "2\r\n3 3\r\n1 2\r\n", "output": "rated\r\n"}, {"input": "4\r\n1501 1500\r\n1300 1300\r\n1200 1200\r\n1400 1400\r\n", "output": "rated\r\n"}, {"input": "5\r\n1 1\r\n2 2\r\n3 3\r\n4 4\r\n5 5\r\n", "output": "unrated\r\n"}, {"input": "2\r\n10 10\r\n1 2\r\n", "output": "rated\r\n"}, {"input": "6\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n1699 1699\r\n1900 1900\r\n", "output": "unrated\r\n"}, {"input": "6\r\n3123 3123\r\n2777 2777\r\n3000 3000\r\n2246 2246\r\n2246 2246\r\n1699 1699\r\n", "output": "unrated\r\n"}, {"input": "2\r\n100 100\r\n110 110\r\n", "output": "unrated\r\n"}, {"input": "3\r\n3 3\r\n3 3\r\n4 4\r\n", "output": "unrated\r\n"}, {"input": "3\r\n3 3\r\n3 2\r\n4 4\r\n", "output": "rated\r\n"}, {"input": "3\r\n5 2\r\n4 4\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "4\r\n4 4\r\n3 3\r\n2 2\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "2\r\n1 1\r\n3 2\r\n", "output": "rated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n2699 2699\r\n", "output": "unrated\r\n"}, {"input": "3\r\n3 3\r\n3 3\r\n3 4\r\n", "output": "rated\r\n"}, {"input": "3\r\n1 2\r\n2 2\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "3\r\n1 2\r\n1 2\r\n1 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 1\r\n2 1\r\n", "output": "rated\r\n"}, {"input": "2\r\n1 2\r\n3 4\r\n", "output": "rated\r\n"}, {"input": "2\r\n3 2\r\n2 3\r\n", "output": "rated\r\n"}, {"input": "3\r\n1500 1500\r\n1600 1600\r\n1600 1600\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1 1\r\n3 3\r\n4 4\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1 1\r\n2 2\r\n2 2\r\n", "output": "unrated\r\n"}, {"input": "2\r\n10 12\r\n8 8\r\n", "output": "rated\r\n"}, {"input": "5\r\n1200 1200\r\n1500 1500\r\n1500 1500\r\n1500 1500\r\n1500 1500\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1 2\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "3\r\n1500 1400\r\n1200 1200\r\n1100 1100\r\n", "output": "rated\r\n"}, {"input": "2\r\n10 12\r\n10 10\r\n", "output": "rated\r\n"}, {"input": "3\r\n1500 1500\r\n1400 1400\r\n1300 1300\r\n", "output": "maybe\r\n"}, {"input": "3\r\n3 3\r\n4 4\r\n5 5\r\n", "output": "unrated\r\n"}, {"input": "3\r\n2 6\r\n3 5\r\n4 4\r\n", "output": "rated\r\n"}, {"input": "2\r\n5 6\r\n4 6\r\n", "output": "rated\r\n"}, {"input": "4\r\n10 10\r\n10 10\r\n7 7\r\n8 8\r\n", "output": "unrated\r\n"}, {"input": "2\r\n4 4\r\n3 3\r\n", "output": "maybe\r\n"}]
| false |
stdio
| null | true |
598/C
|
598
|
C
|
Python 3
|
TESTS
| 113 | 841 | 22,016,000 |
116184762
|
import sys
from math import atan2, degrees
from decimal import Decimal
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7
def resolve():
n = int(input())
XY = []
for i in range(n):
x, y = map(int, input().split())
theta = Decimal(degrees(atan2(y, x)))
XY.append((theta, i + 1))
XY.sort()
mi = f_inf
res = [-1, -1]
for i in range(n):
t1, idx1 = XY[i]
t2, idx2 = XY[i - 1]
diff = abs(Decimal(t1) - Decimal(t2))
diff = Decimal(min(360 - diff, diff))
if mi > diff:
mi = Decimal(diff)
res = [idx1, idx2]
print(*res)
if __name__ == '__main__':
resolve()
| 163 | 779 | 41,369,600 |
175306822
|
from sys import stdin
input=lambda :stdin.readline()[:-1]
def compare(a,b):
# 比較関数 (a<=b)
# 偏角ソート
ax, ay = a[:2]
bx, by = b[:2]
if ay < 0:
return by >= 0 or ax * by - ay * bx > 0
if ay == 0:
return ax >= 0 and (by > 0 or (by == 0 and bx < 0))
return by >= 0 and (ax * by - ay * bx) > 0
def merge(l, r):
new = []
ln = 0
rn = 0
while ln < len(l) and rn < len(r):
if compare(l[ln],r[rn]):
new.append(l[ln])
ln += 1
else:
new.append(r[rn])
rn += 1
for i in range(ln, len(l)):
new.append(l[i])
for i in range(rn, len(r)):
new.append(r[i])
return new
def MergeSort(l):
if len(l) == 0:
return []
if len(l) == 1:
return l
else:
a = l[:len(l)//2]
b = l[len(l)//2:]
return merge(MergeSort(a), MergeSort(b))
n=int(input())
xy=[]
for i in range(n):
x,y=map(int,input().split())
xy.append((x,y,i))
xy=MergeSort(xy)
def cos(i,j):
xi,yi=xy[i][:2]
xj,yj=xy[j][:2]
den=(xi*xi+yi*yi)*(xj*xj+yj*yj)
num=xi*xj+yi*yj
if num>=0:
return 1,num**2,den
else:
return -1,num**2,den
def comp(sgn1,num1,den1,sgn2,num2,den2):
# return 1>=2
if sgn1>sgn2:
return True
if sgn1<sgn2:
return False
if sgn1==1:
return num1*den2>=den1*num2
else:
return num1*den2<=den1*num2
sgn,num,den=-1,1,1
for i in range(n):
j=(i+1)%n
sgn1,num1,den1=cos(i,j)
if comp(sgn1,num1,den1,sgn,num,den):
ans1=xy[i][2]
ans2=xy[j][2]
sgn,num,den=sgn1,num1,den1
print(ans1+1,ans2+1)
|
Educational Codeforces Round 1
|
ICPC
| 2,015 | 2 | 256 |
Nearest vectors
|
You are given the set of vectors on the plane, each of them starting at the origin. Your task is to find a pair of vectors with the minimal non-oriented angle between them.
Non-oriented angle is non-negative value, minimal between clockwise and counterclockwise direction angles. Non-oriented angle is always between 0 and π. For example, opposite directions vectors have angle equals to π.
|
First line of the input contains a single integer n (2 ≤ n ≤ 100 000) — the number of vectors.
The i-th of the following n lines contains two integers xi and yi (|x|, |y| ≤ 10 000, x2 + y2 > 0) — the coordinates of the i-th vector. Vectors are numbered from 1 to n in order of appearing in the input. It is guaranteed that no two vectors in the input share the same direction (but they still can have opposite directions).
|
Print two integer numbers a and b (a ≠ b) — a pair of indices of vectors with the minimal non-oriented angle. You can print the numbers in any order. If there are many possible answers, print any.
| null | null |
[{"input": "4\n-1 0\n0 -1\n1 0\n1 1", "output": "3 4"}, {"input": "6\n-1 0\n0 -1\n1 0\n1 1\n-4 -5\n-4 -6", "output": "6 5"}]
| 2,300 |
["geometry", "sortings"]
| 163 |
[{"input": "4\r\n-1 0\r\n0 -1\r\n1 0\r\n1 1\r\n", "output": "3 4\r\n"}, {"input": "6\r\n-1 0\r\n0 -1\r\n1 0\r\n1 1\r\n-4 -5\r\n-4 -6\r\n", "output": "5 6\r\n"}, {"input": "10\r\n8 6\r\n-7 -3\r\n9 8\r\n7 10\r\n-3 -8\r\n3 7\r\n6 -8\r\n-9 8\r\n9 2\r\n6 7\r\n", "output": "1 3\r\n"}, {"input": "20\r\n-9 8\r\n-7 3\r\n0 10\r\n3 7\r\n6 -9\r\n6 8\r\n7 -6\r\n-6 10\r\n-10 3\r\n-8 -10\r\n10 -2\r\n1 -8\r\n-8 10\r\n10 10\r\n10 6\r\n-5 6\r\n5 -8\r\n5 -9\r\n-9 -1\r\n9 2\r\n", "output": "13 16\r\n"}, {"input": "2\r\n351 -4175\r\n-328 -657\r\n", "output": "2 1\r\n"}, {"input": "3\r\n620 -1189\r\n8101 -2770\r\n3347 3473\r\n", "output": "1 2\r\n"}, {"input": "4\r\n-7061 -5800\r\n-3471 -9470\r\n-7639 2529\r\n5657 -6522\r\n", "output": "1 2\r\n"}, {"input": "5\r\n-7519 -3395\r\n-32 -257\r\n-4827 -1889\r\n9545 -7037\r\n2767 583\r\n", "output": "3 1\r\n"}, {"input": "6\r\n-5120 -3251\r\n8269 -7984\r\n841 3396\r\n3136 -7551\r\n-1280 -3013\r\n-3263 -3278\r\n", "output": "1 6\r\n"}, {"input": "7\r\n-2722 6597\r\n-3303 200\r\n6508 -1021\r\n-1107 -1042\r\n6875 7616\r\n-3047 6749\r\n662 -1979\r\n", "output": "1 6\r\n"}, {"input": "8\r\n-36 749\r\n5126 943\r\n1165 533\r\n-1647 -5725\r\n5031 6532\r\n5956 8447\r\n2297 -2284\r\n1986 6937\r\n", "output": "5 6\r\n"}, {"input": "9\r\n-391 -1706\r\n995 -5756\r\n-5013 -154\r\n1121 3160\r\n-7111 8303\r\n-7303 -2414\r\n-7791 -935\r\n7576 -9361\r\n1072 203\r\n", "output": "3 7\r\n"}, {"input": "10\r\n-9920 -5477\r\n9691 -3200\r\n754 885\r\n-1895 1768\r\n-941 1588\r\n6293 -2631\r\n-2288 9129\r\n4067 696\r\n-6754 9869\r\n-5747 701\r\n", "output": "5 9\r\n"}, {"input": "2\r\n1 0\r\n-1 0\r\n", "output": "1 2\r\n"}, {"input": "2\r\n0 1\r\n0 -1\r\n", "output": "1 2\r\n"}, {"input": "2\r\n2131 -3249\r\n-2131 3249\r\n", "output": "2 1\r\n"}, {"input": "3\r\n-5 1\r\n-5 -1\r\n5 0\r\n", "output": "1 2\r\n"}, {"input": "3\r\n-100 1\r\n-100 -1\r\n0 100\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 10\r\n10 1\r\n10 -1\r\n", "output": "3 2\r\n"}, {"input": "3\r\n3 0\r\n0 3\r\n1 -3\r\n", "output": "3 1\r\n"}, {"input": "3\r\n1 1\r\n-1 0\r\n1 -1\r\n", "output": "3 1\r\n"}, {"input": "3\r\n-1 0\r\n10 -1\r\n1 0\r\n", "output": "2 3\r\n"}, {"input": "4\r\n1 10\r\n10 1\r\n-2 -2\r\n10 -1\r\n", "output": "4 2\r\n"}, {"input": "3\r\n-6 0\r\n6 1\r\n6 -1\r\n", "output": "3 2\r\n"}, {"input": "3\r\n114 1\r\n-514 0\r\n114 -1\r\n", "output": "3 1\r\n"}, {"input": "4\r\n-1 0\r\n0 -1\r\n-1 1\r\n1 0\r\n", "output": "3 1\r\n"}, {"input": "4\r\n2 1\r\n2 -1\r\n-1 1\r\n-1 -1\r\n", "output": "2 1\r\n"}, {"input": "3\r\n3 1\r\n3 -1\r\n0 3\r\n", "output": "2 1\r\n"}, {"input": "3\r\n1 1\r\n9000 1\r\n9000 -1\r\n", "output": "3 2\r\n"}, {"input": "3\r\n1 0\r\n-1 1\r\n-1 -1\r\n", "output": "2 3\r\n"}, {"input": "6\r\n1 1\r\n-1 -1\r\n0 20\r\n100 1\r\n-100 0\r\n100 -1\r\n", "output": "6 4\r\n"}, {"input": "4\r\n1 0\r\n0 1\r\n-1 0\r\n-13 -1\r\n", "output": "3 4\r\n"}, {"input": "3\r\n1 0\r\n-1 0\r\n1 -1\r\n", "output": "3 1\r\n"}, {"input": "3\r\n100 1\r\n-100 0\r\n100 -1\r\n", "output": "3 1\r\n"}, {"input": "3\r\n-100 1\r\n100 0\r\n-100 -1\r\n", "output": "1 3\r\n"}, {"input": "3\r\n1 100\r\n0 -100\r\n-1 100\r\n", "output": "1 3\r\n"}, {"input": "11\r\n-7945 386\r\n7504 -576\r\n-6020 -8277\r\n930 9737\r\n1682 474\r\n-8279 1197\r\n2790 2607\r\n-5514 -9601\r\n-3159 5939\r\n-1806 4207\r\n-9073 -2138\r\n", "output": "10 9\r\n"}, {"input": "3\r\n1 0\r\n10000 -1\r\n1 1\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-7125 -1643\r\n-1235 4071\r\n-75 -8717\r\n2553 9278\r\n", "output": "4 2\r\n"}, {"input": "5\r\n-6 0\r\n6 1\r\n6 -1\r\n0 6\r\n0 -6\r\n", "output": "3 2\r\n"}, {"input": "4\r\n5 5\r\n5 -5\r\n-555 1\r\n-555 -1\r\n", "output": "3 4\r\n"}, {"input": "4\r\n1 1\r\n-1 1\r\n-1 -1\r\n2 -1\r\n", "output": "4 1\r\n"}, {"input": "4\r\n-1 -100\r\n1 -100\r\n-100 -100\r\n100 -100\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 0\r\n1 -1\r\n-4 -6\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-1 -100\r\n1 -100\r\n100 -100\r\n-100 -100\r\n", "output": "1 2\r\n"}, {"input": "4\r\n-1 0\r\n0 -2\r\n-3 3\r\n4 0\r\n", "output": "3 1\r\n"}, {"input": "4\r\n-2 0\r\n0 -3\r\n-5 5\r\n4 0\r\n", "output": "3 1\r\n"}, {"input": "3\r\n1 -100\r\n0 100\r\n-1 -100\r\n", "output": "3 1\r\n"}, {"input": "5\r\n10000 2\r\n10000 -1\r\n10000 -5\r\n10000 -9\r\n10000 -13\r\n", "output": "2 1\r\n"}, {"input": "8\r\n-9580 8545\r\n-9379 -1139\r\n5824 -391\r\n-8722 2765\r\n-1357 -5547\r\n-7700 217\r\n9323 -7008\r\n957 -8356\r\n", "output": "6 2\r\n"}, {"input": "4\r\n5 5\r\n5 -5\r\n-500 1\r\n-500 -1\r\n", "output": "3 4\r\n"}, {"input": "3\r\n30 1\r\n30 -1\r\n0 30\r\n", "output": "2 1\r\n"}, {"input": "4\r\n3966 -1107\r\n8007 -5457\r\n-7753 4945\r\n-2209 -4221\r\n", "output": "2 1\r\n"}, {"input": "4\r\n1 9999\r\n0 1\r\n10000 0\r\n10000 -1\r\n", "output": "4 3\r\n"}, {"input": "3\r\n10000 1\r\n10000 -1\r\n-10000 0\r\n", "output": "2 1\r\n"}, {"input": "13\r\n1 2\r\n2 3\r\n3 4\r\n4 5\r\n5 6\r\n6 7\r\n7 8\r\n8 9\r\n9 10\r\n10 11\r\n11 12\r\n13 14\r\n12 13\r\n", "output": "12 13\r\n"}, {"input": "4\r\n2 1\r\n2 -1\r\n0 1\r\n-1 0\r\n", "output": "2 1\r\n"}, {"input": "4\r\n10 3\r\n10 -3\r\n-500 1\r\n-500 -1\r\n", "output": "3 4\r\n"}, {"input": "4\r\n1 10000\r\n-1 1\r\n10000 0\r\n10000 -1\r\n", "output": "4 3\r\n"}, {"input": "3\r\n0 1\r\n1 0\r\n1 -1\r\n", "output": "3 2\r\n"}, {"input": "3\r\n1 0\r\n0 1\r\n1 -1\r\n", "output": "3 1\r\n"}, {"input": "4\r\n1 1\r\n-1 1\r\n1 -2\r\n-1 -2\r\n", "output": "4 3\r\n"}, {"input": "4\r\n0 -1\r\n-1 0\r\n-1 1\r\n1 0\r\n", "output": "3 2\r\n"}, {"input": "3\r\n-100 1\r\n-100 -1\r\n1 1\r\n", "output": "1 2\r\n"}, {"input": "3\r\n-3 1\r\n-3 -1\r\n2 -3\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 -1\r\n1 0\r\n0 1\r\n", "output": "1 2\r\n"}, {"input": "5\r\n-5 1\r\n0 5\r\n4 1\r\n0 -4\r\n-5 -1\r\n", "output": "1 5\r\n"}, {"input": "4\r\n1 10000\r\n0 1\r\n10000 0\r\n9999 -1\r\n", "output": "1 2\r\n"}, {"input": "4\r\n2 3\r\n2 -3\r\n-3 2\r\n-3 -2\r\n", "output": "3 4\r\n"}, {"input": "3\r\n1 -3\r\n1 0\r\n0 1\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 0\r\n-1 0\r\n-1 -1\r\n", "output": "2 3\r\n"}, {"input": "4\r\n-2 1\r\n-2 -1\r\n1 1\r\n1 -1\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 -1\r\n-1 1\r\n-1 -2\r\n", "output": "3 1\r\n"}, {"input": "3\r\n1 0\r\n-1 -1\r\n1 -1\r\n", "output": "3 1\r\n"}, {"input": "3\r\n5 5\r\n-5 0\r\n5 -5\r\n", "output": "3 1\r\n"}, {"input": "4\r\n1 -2\r\n1 0\r\n-1 0\r\n10 -1\r\n", "output": "4 2\r\n"}, {"input": "3\r\n-1000 1\r\n-1000 -1\r\n1000 0\r\n", "output": "1 2\r\n"}, {"input": "6\r\n1 1\r\n1 -1\r\n-1 1\r\n-1 -1\r\n1 -10000\r\n-1 -10000\r\n", "output": "6 5\r\n"}, {"input": "3\r\n1 1\r\n-1 0\r\n0 -1\r\n", "output": "2 3\r\n"}, {"input": "4\r\n5000 1\r\n5000 -1\r\n-2 -1\r\n2 -1\r\n", "output": "2 1\r\n"}, {"input": "3\r\n1 0\r\n-1 1\r\n-1 -5\r\n", "output": "3 1\r\n"}, {"input": "3\r\n-5374 1323\r\n-4463 -8462\r\n6118 -7918\r\n", "output": "2 3\r\n"}, {"input": "4\r\n-6427 -6285\r\n-5386 -5267\r\n-3898 7239\r\n-3905 7252\r\n", "output": "4 3\r\n"}, {"input": "10\r\n-7 -3\r\n-2 8\r\n9 -9\r\n0 1\r\n4 5\r\n5 3\r\n-3 0\r\n10 2\r\n4 -1\r\n2 -10\r\n", "output": "4 2\r\n"}, {"input": "4\r\n9999 1\r\n9999 -1\r\n-9998 1\r\n-10000 -1\r\n", "output": "2 1\r\n"}, {"input": "4\r\n10000 9999\r\n9999 9998\r\n9998 9997\r\n9997 9996\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-6285 -6427\r\n-5267 -5386\r\n7239 -3898\r\n7252 -3905\r\n", "output": "3 4\r\n"}, {"input": "4\r\n-6427 6285\r\n-5386 5267\r\n3898 -7239\r\n3905 -7252\r\n", "output": "4 3\r\n"}, {"input": "4\r\n-6427 -6285\r\n-5386 -5267\r\n-3898 -7239\r\n-3905 -7252\r\n", "output": "3 4\r\n"}, {"input": "3\r\n0 1\r\n-1 -1\r\n1 -1\r\n", "output": "2 3\r\n"}, {"input": "4\r\n10000 1\r\n9998 -1\r\n-9999 1\r\n-9999 -1\r\n", "output": "3 4\r\n"}, {"input": "3\r\n100 0\r\n100 2\r\n100 -1\r\n", "output": "3 1\r\n"}, {"input": "3\r\n-1 1\r\n-1 -1\r\n1 0\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9844 9986\r\n181 9967\r\n-9812 -9925\r\n-194 -9900\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9800 9981\r\n61 9899\r\n-9926 -9932\r\n-149 -9926\r\n", "output": "3 4\r\n"}, {"input": "4\r\n-9901 9900\r\n-10000 9899\r\n9899 9801\r\n9899 9900\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9934 9989\r\n199 9949\r\n-9917 -9974\r\n-197 -9901\r\n", "output": "3 4\r\n"}, {"input": "3\r\n-1 1\r\n1 0\r\n-1 -1\r\n", "output": "1 3\r\n"}, {"input": "3\r\n1 1\r\n-10 -10\r\n-10 -9\r\n", "output": "3 2\r\n"}, {"input": "3\r\n1 0\r\n10000 -1\r\n-1 0\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9999 1\r\n9999 -1\r\n-10000 1\r\n-10000 -1\r\n", "output": "3 4\r\n"}, {"input": "3\r\n-5 1\r\n-5 -1\r\n1 0\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 0\r\n10000 1\r\n-1 0\r\n", "output": "1 2\r\n"}, {"input": "4\r\n-9990 9995\r\n9994 -9991\r\n-9999 -9992\r\n9993 9992\r\n", "output": "2 4\r\n"}, {"input": "8\r\n1 0\r\n1 1\r\n0 1\r\n-1 1\r\n-1 0\r\n-1 -1\r\n0 -1\r\n1 -2\r\n", "output": "7 8\r\n"}, {"input": "3\r\n-9930 9932\r\n9909 -9909\r\n-9932 -9931\r\n", "output": "3 2\r\n"}, {"input": "4\r\n9876 9977\r\n127 9938\r\n-9820 -9934\r\n-120 -9921\r\n", "output": "3 4\r\n"}, {"input": "3\r\n10000 -1\r\n-1 0\r\n0 -1\r\n", "output": "3 1\r\n"}, {"input": "4\r\n6427 -6285\r\n5386 -5267\r\n3898 7239\r\n3905 7252\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9811 9970\r\n155 9994\r\n-9826 -9977\r\n-159 -9986\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9851 9917\r\n74 9921\r\n-9855 -9916\r\n-77 -9984\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9826 9977\r\n159 9986\r\n-9811 -9970\r\n-155 -9994\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9849 9986\r\n148 9980\r\n-9800 -9999\r\n-116 -9927\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9822 9967\r\n111 9905\r\n-9943 -9986\r\n-163 -9953\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9959 9995\r\n113 9940\r\n-9965 -9931\r\n-148 -9945\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9851 9972\r\n153 9983\r\n-9866 -9926\r\n-183 -9946\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9816 -9979\r\n127 -9940\r\n-9876 9915\r\n-190 9978\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9887 -9917\r\n138 -9977\r\n-9826 9995\r\n-68 9971\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9936 -9965\r\n135 -9949\r\n-9928 9980\r\n-123 9908\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9981 -9985\r\n191 -9956\r\n-9893 9937\r\n-171 9962\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-9811 9970\r\n-155 9994\r\n9826 -9977\r\n159 -9986\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9808 9899\r\n179 9966\r\n-9870 -9961\r\n-179 -9950\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9815 -9936\r\n168 -9937\r\n-9896 9995\r\n-180 9969\r\n", "output": "2 1\r\n"}, {"input": "4\r\n1 1\r\n1 -1\r\n-100 1\r\n-100 -1\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9965 114\r\n87 9916\r\n-9957 -106\r\n-95 -9929\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9895 -9949\r\n188 -9978\r\n-9810 9935\r\n-151 9914\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-9957 106\r\n-95 9929\r\n9965 -114\r\n87 -9916\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-9862 9980\r\n-174 9917\r\n9845 -9967\r\n173 -9980\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9944 9926\r\n9927 9935\r\n-9961 -9929\r\n-9997 -9991\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9917 9909\r\n196 9925\r\n-9971 -9991\r\n-183 -9977\r\n", "output": "3 4\r\n"}]
| false |
stdio
|
import sys
import math
def read_vectors(input_path):
with open(input_path) as f:
n = int(f.readline())
vectors = []
for i in range(n):
x, y = map(int, f.readline().split())
vectors.append( (x, y, i+1) )
return vectors
def compute_angle(x, y):
return math.atan2(y, x) % (2 * math.pi)
def compute_non_oriented_angle(u, v):
ux, uy = u
vx, vy = v
dot = ux * vx + uy * vy
mag_u = math.hypot(ux, uy)
mag_v = math.hypot(vx, vy)
if mag_u == 0 or mag_v == 0:
return 0.0
cos_theta = dot / (mag_u * mag_v)
cos_theta = max(min(cos_theta, 1.0), -1.0)
return math.acos(cos_theta)
def find_min_angle(vectors):
sorted_vectors = sorted(vectors, key=lambda vec: compute_angle(vec[0], vec[1]))
n = len(sorted_vectors)
min_adjacent = math.pi
for i in range(n):
j = (i + 1) % n
u = sorted_vectors[i][0], sorted_vectors[i][1]
v = sorted_vectors[j][0], sorted_vectors[j][1]
theta = compute_non_oriented_angle(u, v)
if theta < min_adjacent:
min_adjacent = theta
angles = []
for vec in sorted_vectors:
x, y, idx = vec
angles.append( compute_angle(x, y) )
min_opposite = math.pi
for i in range(n):
theta_i = angles[i]
target = (theta_i + math.pi) % (2 * math.pi)
low = 0
high = n
while low < high:
mid = (low + high) // 2
if angles[mid] < target:
low = mid + 1
else:
high = mid
candidates = []
if low > 0:
candidates.append(low-1)
if low < n:
candidates.append(low)
candidates.append((low - 1) % n)
candidates = list(set(candidates))
for c in candidates:
if c == i:
continue
c = c % n
vec_c = sorted_vectors[c]
u = sorted_vectors[i][0], sorted_vectors[i][1]
v = vec_c[0], vec_c[1]
current_theta = compute_non_oriented_angle(u, v)
if current_theta < min_opposite:
min_opposite = current_theta
return min(min_adjacent, min_opposite)
def main(input_path, output_path, submission_output_path):
input_vectors = read_vectors(input_path)
with open(submission_output_path) as f:
line = f.readline().strip()
try:
a, b = map(int, line.split())
except:
print(0)
return
n = len(input_vectors)
if a < 1 or a > n or b < 1 or b > n or a == b:
print(0)
return
vec_a = None
vec_b = None
for vec in input_vectors:
if vec[2] == a:
vec_a = vec
if vec[2] == b:
vec_b = vec
if vec_a is None or vec_b is None:
print(0)
return
u = (vec_a[0], vec_a[1])
v = (vec_b[0], vec_b[1])
theta = compute_non_oriented_angle(u, v)
min_angle = find_min_angle(input_vectors)
epsilon = 1e-9
if abs(theta - min_angle) <= epsilon:
print(1)
else:
print(0)
if __name__ == "__main__":
input_path = sys.argv[1]
output_path = sys.argv[2]
submission_output_path = sys.argv[3]
main(input_path, output_path, submission_output_path)
| true |
837/B
|
837
|
B
|
PyPy 3-64
|
TESTS
| 17 | 77 | 2,969,600 |
210295461
|
import sys
input = lambda: sys.stdin.readline().rstrip()
N,M = map(int, input().split())
S = []
for _ in range(N):
S.append(input())
INF = float('inf')
A = [[INF,INF,-1,-1],[INF,INF,-1,-1],[INF,INF,-1,-1]]
for i in range(N):
for j in range(M):
if S[i][j]=='R':
A[0][0] = min(A[0][0],i)
A[0][1] = min(A[0][1],j)
A[0][2] = max(A[0][2],i)
A[0][3] = max(A[0][3],j)
elif S[i][j]=='G':
A[1][0] = min(A[1][0],i)
A[1][1] = min(A[1][1],j)
A[1][2] = max(A[1][2],i)
A[1][3] = max(A[1][3],j)
else:
A[2][0] = min(A[2][0],i)
A[2][1] = min(A[2][1],j)
A[2][2] = max(A[2][2],i)
A[2][3] = max(A[2][3],j)
A.sort()
#print(A)
D = []
for x1,y1,x2,y2 in A:
t = (x2-x1+1)*(y2-y1+1)
D.append(t)
if len(set(D))==1 and D[0]*3==N*M:
print('YES')
else:
print('NO')
| 153 | 62 | 307,200 |
110106847
|
def rotate_90_degree_anticlckwise(matrix):
new_matrix = []
for i in range(len(matrix[0]), 0, -1):
new_matrix.append(list(map(lambda x: x[i-1], matrix)))
return new_matrix
n,m = map(int,input().split())
mat = []
for i in range(n):
temp = input()
mat.append([i for i in temp])
horiz, verti = False, False
check = True
resH = []
for i in range(n):
if(mat[i].count(mat[i][0]) == m):
first = mat[i][0]
if(resH):
if(resH[-1][0] == first):
resH[-1][1] += 1
else:
resH.append([first, 1])
else:
resH.append([first, 1])
else:
check = False
break
if(len(resH) == 3 and check):
if(len(set([i[1] for i in resH])) == 1 and len(set([i[0] for i in resH])) == 3):
horiz = True
newMat = rotate_90_degree_anticlckwise(mat)
check = True
resV = []
for i in range(m):
if(newMat[i].count(newMat[i][0]) == n):
first = newMat[i][0]
if(resV):
if(resV[-1][0] == first):
resV[-1][1] += 1
else:
resV.append([first, 1])
else:
resV.append([first, 1])
else:
check = False
break
if(len(resV) == 3 and check):
if(len(set([i[1] for i in resV])) == 1 and len(set([i[0] for i in resV])) == 3):
verti = True
if(horiz or verti):
print("YES")
else:
print("NO")
|
Educational Codeforces Round 26
|
ICPC
| 2,017 | 1 | 256 |
Flag of Berland
|
The flag of Berland is such rectangular field n × m that satisfies following conditions:
- Flag consists of three colors which correspond to letters 'R', 'G' and 'B'.
- Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color.
- Each color should be used in exactly one stripe.
You are given a field n × m, consisting of characters 'R', 'G' and 'B'. Output "YES" (without quotes) if this field corresponds to correct flag of Berland. Otherwise, print "NO" (without quotes).
|
The first line contains two integer numbers n and m (1 ≤ n, m ≤ 100) — the sizes of the field.
Each of the following n lines consisting of m characters 'R', 'G' and 'B' — the description of the field.
|
Print "YES" (without quotes) if the given field corresponds to correct flag of Berland . Otherwise, print "NO" (without quotes).
| null |
The field in the third example doesn't have three parralel stripes.
Rows of the field in the fourth example are parralel to each other and to borders. But they have different heights — 2, 1 and 1.
|
[{"input": "6 5\nRRRRR\nRRRRR\nBBBBB\nBBBBB\nGGGGG\nGGGGG", "output": "YES"}, {"input": "4 3\nBRG\nBRG\nBRG\nBRG", "output": "YES"}, {"input": "6 7\nRRRGGGG\nRRRGGGG\nRRRGGGG\nRRRBBBB\nRRRBBBB\nRRRBBBB", "output": "NO"}, {"input": "4 4\nRRRR\nRRRR\nBBBB\nGGGG", "output": "NO"}]
| 1,600 |
["brute force", "implementation"]
| 153 |
[{"input": "6 5\r\nRRRRR\r\nRRRRR\r\nBBBBB\r\nBBBBB\r\nGGGGG\r\nGGGGG\r\n", "output": "YES\r\n"}, {"input": "4 3\r\nBRG\r\nBRG\r\nBRG\r\nBRG\r\n", "output": "YES\r\n"}, {"input": "6 7\r\nRRRGGGG\r\nRRRGGGG\r\nRRRGGGG\r\nRRRBBBB\r\nRRRBBBB\r\nRRRBBBB\r\n", "output": "NO\r\n"}, {"input": "4 4\r\nRRRR\r\nRRRR\r\nBBBB\r\nGGGG\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nGRB\r\n", "output": "YES\r\n"}, {"input": "3 1\r\nR\r\nG\r\nB\r\n", "output": "YES\r\n"}, {"input": "4 3\r\nRGB\r\nGRB\r\nGRB\r\nGRB\r\n", "output": "NO\r\n"}, {"input": "4 6\r\nGGRRBB\r\nGGRRBB\r\nGGRRBB\r\nRRGGBB\r\n", "output": "NO\r\n"}, {"input": "100 3\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nGRB\r\n", "output": "NO\r\n"}, {"input": "3 100\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\nRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRG\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nR\r\nR\r\nB\r\n", "output": "NO\r\n"}, {"input": "3 2\r\nRR\r\nBB\r\nRR\r\n", "output": "NO\r\n"}, {"input": "3 2\r\nRR\r\nBG\r\nBG\r\n", "output": "NO\r\n"}, {"input": "3 2\r\nBB\r\nRR\r\nBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nRRR\r\nRRR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nGGG\r\nGGG\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRGG\r\n", "output": "NO\r\n"}, {"input": "4 3\r\nRGR\r\nRGR\r\nRGR\r\nRGR\r\n", "output": "NO\r\n"}, {"input": "3 4\r\nRRGG\r\nRRGG\r\nBBBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nBRG\r\nBRG\r\nBRG\r\n", "output": "YES\r\n"}, {"input": "3 1\r\nR\r\nG\r\nR\r\n", "output": "NO\r\n"}, {"input": "5 3\r\nBBG\r\nBBG\r\nBBG\r\nBBG\r\nBBG\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nGGG\r\nRRR\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRGR\r\n", "output": "NO\r\n"}, {"input": "3 6\r\nRRBBGG\r\nRRBBGG\r\nRRBBGG\r\n", "output": "YES\r\n"}, {"input": "6 6\r\nRRBBGG\r\nRRBBGG\r\nRRBBGG\r\nRRBBGG\r\nRRBBGG\r\nRRBBGG\r\n", "output": "YES\r\n"}, {"input": "4 3\r\nRRR\r\nGGG\r\nBBB\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nBBB\r\nRRR\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nB\r\nR\r\nB\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nBGB\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nB\r\nB\r\nB\r\n", "output": "NO\r\n"}, {"input": "3 4\r\nRRRR\r\nBBBB\r\nRRRR\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRGGGBB\r\n", "output": "NO\r\n"}, {"input": "9 3\r\nBBB\r\nBBB\r\nBBB\r\nGGG\r\nGGG\r\nGRG\r\nRGR\r\nRRR\r\nRRR\r\n", "output": "NO\r\n"}, {"input": "4 4\r\nRGBB\r\nRGBB\r\nRGBB\r\nRGBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRBR\r\nRBR\r\nRBR\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRRRRBB\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRRRRRR\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRRGGGG\r\n", "output": "NO\r\n"}, {"input": "4 4\r\nRRRR\r\nRRRR\r\nRRRR\r\nRRRR\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nB\r\nG\r\nB\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nR\r\nR\r\nR\r\n", "output": "NO\r\n"}, {"input": "1 9\r\nRRRGGGBBB\r\n", "output": "YES\r\n"}, {"input": "1 3\r\nRRR\r\n", "output": "NO\r\n"}, {"input": "3 5\r\nRRRRR\r\nBBBBB\r\nBBBBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nGGG\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "1 1\r\nR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGR\r\nRGR\r\nRGR\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRBG\r\nGBR\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nRGB\r\nRGB\r\n", "output": "YES\r\n"}, {"input": "1 3\r\nBRB\r\n", "output": "NO\r\n"}, {"input": "2 1\r\nR\r\nB\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRBR\r\n", "output": "NO\r\n"}, {"input": "3 5\r\nRRGBB\r\nRRGBB\r\nRRGBB\r\n", "output": "NO\r\n"}, {"input": "5 3\r\nBBR\r\nBBR\r\nBBR\r\nBBR\r\nBBR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nRBG\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "1 2\r\nRB\r\n", "output": "NO\r\n"}, {"input": "4 3\r\nBBB\r\nBBB\r\nBBB\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "36 6\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\n", "output": "NO\r\n"}, {"input": "4 1\r\nR\r\nB\r\nG\r\nR\r\n", "output": "NO\r\n"}, {"input": "13 12\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\n", "output": "NO\r\n"}, {"input": "2 2\r\nRR\r\nRR\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nRRGGBB\r\nGRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\n", "output": "NO\r\n"}, {"input": "70 3\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\n", "output": "NO\r\n"}, {"input": "4 3\r\nBBG\r\nBBG\r\nBBG\r\nBBG\r\n", "output": "NO\r\n"}, {"input": "6 3\r\nBBB\r\nGGG\r\nRRR\r\nBRG\r\nBRG\r\nBRG\r\n", "output": "NO\r\n"}, {"input": "3 6\r\nRRBBGG\r\nRBBBGG\r\nRBBBGG\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nGGGGGG\r\nGGGGGG\r\nBBBBBB\r\nBBBBBB\r\nGGGGGG\r\nGGGGGG\r\n", "output": "NO\r\n"}, {"input": "6 1\r\nR\r\nB\r\nG\r\nR\r\nB\r\nG\r\n", "output": "NO\r\n"}, {"input": "6 5\r\nRRRRR\r\nBBBBB\r\nGGGGG\r\nRRRRR\r\nBBBBB\r\nGGGGG\r\n", "output": "NO\r\n"}, {"input": "6 3\r\nRRR\r\nGGG\r\nBBB\r\nRRR\r\nGGG\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "6 5\r\nRRRRR\r\nRRRRR\r\nRRRRR\r\nGGGGG\r\nGGGGG\r\nGGGGG\r\n", "output": "NO\r\n"}, {"input": "15 28\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\n", "output": "NO\r\n"}, {"input": "21 10\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nBBBBBBBBBB\r\nBBBBBBBBBB\r\nBBBBBGBBBB\r\nBBBBBBBBBB\r\nBBBBBBBBBB\r\nBBBBBBBBBB\r\nBBBBBBBBBB\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\n", "output": "NO\r\n"}, {"input": "3 2\r\nRR\r\nGB\r\nGB\r\n", "output": "NO\r\n"}, {"input": "3 2\r\nRG\r\nRG\r\nBB\r\n", "output": "NO\r\n"}, {"input": "6 5\r\nRRRRR\r\nRRRRR\r\nBBBBB\r\nBBBBB\r\nRRRRR\r\nRRRRR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nGBR\r\nBRG\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nBGR\r\nBGR\r\nBGR\r\n", "output": "YES\r\n"}, {"input": "6 6\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\n", "output": "YES\r\n"}, {"input": "4 2\r\nRR\r\nGG\r\nRR\r\nBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nRRR\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "8 6\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\n", "output": "NO\r\n"}, {"input": "3 4\r\nRRRR\r\nRRRR\r\nGGGG\r\n", "output": "NO\r\n"}, {"input": "3 4\r\nRRRR\r\nRRRR\r\nRRRR\r\n", "output": "NO\r\n"}, {"input": "6 1\r\nR\r\nR\r\nR\r\nR\r\nR\r\nR\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRRBBGG\r\n", "output": "YES\r\n"}, {"input": "1 6\r\nRGBRGB\r\n", "output": "NO\r\n"}, {"input": "3 4\r\nRRRR\r\nGGGG\r\nRRRR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRB\r\nGRG\r\nGBB\r\n", "output": "NO\r\n"}, {"input": "3 7\r\nRRGGBBB\r\nRRGGBBB\r\nRRGGBBB\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nG\r\nR\r\nR\r\n", "output": "NO\r\n"}, {"input": "2 3\r\nRGG\r\nRBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRG\r\nGGG\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nRBB\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGR\r\nRGB\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nB\r\nR\r\nR\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nGRR\r\n", "output": "NO\r\n"}, {"input": "4 4\r\nRRRR\r\nGGGG\r\nBBBB\r\nBBBB\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nGGR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nGGB\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGR\r\nGGG\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nRRRRRR\r\nGGGGGG\r\nGGGGGG\r\nGGGGGG\r\nBBBBBB\r\nBBBBBB\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nRRRRRR\r\nRRRRRR\r\nGGGGGG\r\nBBBBBB\r\nBBBBBB\r\nBBBBBB\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nG\r\nB\r\nR\r\n", "output": "YES\r\n"}, {"input": "3 3\r\nGGB\r\nRGB\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nGRR\r\nGGG\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nRRRRRR\r\nRRRRRR\r\nGGGGGG\r\nGGGGGG\r\nBBBBBB\r\nRRRRRR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nGBG\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "3 8\r\nRRGGBBBB\r\nRRGGBBBB\r\nRRGGBBBB\r\n", "output": "NO\r\n"}, {"input": "2 2\r\nRR\r\nGG\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nRGR\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRBG\r\n", "output": "YES\r\n"}, {"input": "2 6\r\nRRGGBB\r\nGGRRBB\r\n", "output": "NO\r\n"}, {"input": "6 2\r\nRR\r\nGG\r\nBB\r\nRR\r\nGG\r\nBB\r\n", "output": "NO\r\n"}, {"input": "1 5\r\nRRGGB\r\n", "output": "NO\r\n"}, {"input": "1 2\r\nRG\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRGBRBG\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRRRGGB\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRGB\r\n", "output": "YES\r\n"}, {"input": "4 3\r\nRRR\r\nBBR\r\nGBB\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "6 3\r\nRRR\r\nBBB\r\nBBB\r\nBBB\r\nGGG\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRBG\r\nRBG\r\nRBG\r\n", "output": "YES\r\n"}, {"input": "6 3\r\nRRR\r\nBBB\r\nGGG\r\nRRR\r\nBBB\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "1 4\r\nRGBB\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\n", "output": "NO\r\n"}, {"input": "6 5\r\nRRRRR\r\nRRRRR\r\nGGGGG\r\nGGGGG\r\nRRRRR\r\nRRRRR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nBRG\r\nGBR\r\n", "output": "NO\r\n"}, {"input": "6 10\r\nRRRRRRRRRR\r\nGGGGGGGGGG\r\nBBBBBBBBBB\r\nRRRRRRRRRR\r\nGGGGGGGGGG\r\nBBBBBBBBBB\r\n", "output": "NO\r\n"}, {"input": "20 6\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\n", "output": "YES\r\n"}, {"input": "4 1\r\nR\r\nG\r\nB\r\nR\r\n", "output": "NO\r\n"}, {"input": "1 4\r\nRGBR\r\n", "output": "NO\r\n"}, {"input": "2 4\r\nRGBB\r\nRRGB\r\n", "output": "NO\r\n"}]
| false |
stdio
| null | true |
807/A
|
807
|
A
|
PyPy 3
|
TESTS
| 69 | 233 | 2,150,400 |
97199173
|
from sys import maxsize, stdout, stdin, stderr
# mod = int(1e9 + 7)
import re # can use multiple splits
tup = lambda: map(int, stdin.readline().split())
I = lambda: int(stdin.readline())
lint = lambda: [int(x) for x in stdin.readline().split()]
S = lambda: stdin.readline().replace('\n', '').strip()
def grid(r, c): return [lint() for i in range(r)]
def debug(*args, c=6): print('\033[3{}m'.format(c), *args, '\033[0m', file=stderr)
n = I()
d ={}
f = 1
k =0
for _ in range(n):
a , b = tup()
d[a] = b
if a!=b and f==1:
f = 0
print("rated")
if f==1:
kk = sorted(d.items(),reverse=True)
c =0
r = 1
#print(kk)
for k , v in d.items():
if k ==kk[c][0]:
pass
elif k < kk[c][0]:
r =0
c+=1
if r ==0:print('unrated')
else:print('maybe')
| 150 | 46 | 0 |
132422536
|
a=int(input())
d=[]
e=[]
f=[]
for i in range(a):
b,c=map(int,input().split())
if b==c:
d.append(b)
e.append(b)
e.sort()
d=d[::-1]
if len(d)!=a:
print("rated")
else:
for j in range(len(d)):
if e[j]==d[j]:
f.append(e[j])
if len(f)==a:
print("maybe")
else:
print("unrated")
|
Codeforces Round 412 (rated, Div. 2, base on VK Cup 2017 Round 3)
|
CF
| 2,017 | 2 | 256 |
Is it rated?
|
Is it rated?
Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it.
Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before and after the round is known.
It's known that if at least one participant's rating has changed, then the round was rated for sure.
It's also known that if the round was rated and a participant with lower rating took a better place in the standings than a participant with higher rating, then at least one round participant's rating has changed.
In this problem, you should not make any other assumptions about the rating system.
Determine if the current round is rated, unrated, or it's impossible to determine whether it is rated of not.
|
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of round participants.
Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 4126) — the rating of the i-th participant before and after the round, respectively. The participants are listed in order from the top to the bottom of the standings.
|
If the round is rated for sure, print "rated". If the round is unrated for sure, print "unrated". If it's impossible to determine whether the round is rated or not, print "maybe".
| null |
In the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated.
In the second example, no one's rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, someone's rating would've changed for sure.
In the third example, no one's rating has changed, and the participants took places in non-increasing order of their rating. Therefore, it's impossible to determine whether the round is rated or not.
|
[{"input": "6\n3060 3060\n2194 2194\n2876 2903\n2624 2624\n3007 2991\n2884 2884", "output": "rated"}, {"input": "4\n1500 1500\n1300 1300\n1200 1200\n1400 1400", "output": "unrated"}, {"input": "5\n3123 3123\n2777 2777\n2246 2246\n2246 2246\n1699 1699", "output": "maybe"}]
| 900 |
["implementation", "sortings"]
| 150 |
[{"input": "6\r\n3060 3060\r\n2194 2194\r\n2876 2903\r\n2624 2624\r\n3007 2991\r\n2884 2884\r\n", "output": "rated\r\n"}, {"input": "4\r\n1500 1500\r\n1300 1300\r\n1200 1200\r\n1400 1400\r\n", "output": "unrated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n1699 1699\r\n", "output": "maybe\r\n"}, {"input": "2\r\n1 1\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "2\r\n4126 4126\r\n4126 4126\r\n", "output": "maybe\r\n"}, {"input": "10\r\n446 446\r\n1331 1331\r\n3594 3594\r\n1346 1902\r\n91 91\r\n3590 3590\r\n2437 2437\r\n4007 3871\r\n2797 699\r\n1423 1423\r\n", "output": "rated\r\n"}, {"input": "10\r\n4078 4078\r\n2876 2876\r\n1061 1061\r\n3721 3721\r\n143 143\r\n2992 2992\r\n3279 3279\r\n3389 3389\r\n1702 1702\r\n1110 1110\r\n", "output": "unrated\r\n"}, {"input": "10\r\n4078 4078\r\n3721 3721\r\n3389 3389\r\n3279 3279\r\n2992 2992\r\n2876 2876\r\n1702 1702\r\n1110 1110\r\n1061 1061\r\n143 143\r\n", "output": "maybe\r\n"}, {"input": "2\r\n3936 3936\r\n2967 2967\r\n", "output": "maybe\r\n"}, {"input": "2\r\n1 1\r\n2 2\r\n", "output": "unrated\r\n"}, {"input": "2\r\n2 2\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "2\r\n2 1\r\n1 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n2967 2967\r\n3936 3936\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1200 1200\r\n1200 1200\r\n1300 1300\r\n", "output": "unrated\r\n"}, {"input": "3\r\n3 3\r\n2 2\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "3\r\n1 1\r\n1 1\r\n2 2\r\n", "output": "unrated\r\n"}, {"input": "2\r\n3 2\r\n3 2\r\n", "output": "rated\r\n"}, {"input": "3\r\n5 5\r\n4 4\r\n3 4\r\n", "output": "rated\r\n"}, {"input": "3\r\n200 200\r\n200 200\r\n300 300\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1 1\r\n2 2\r\n3 3\r\n", "output": "unrated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2245 2245\r\n1699 1699\r\n", "output": "maybe\r\n"}, {"input": "2\r\n10 10\r\n8 8\r\n", "output": "maybe\r\n"}, {"input": "3\r\n1500 1500\r\n1500 1500\r\n1600 1600\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1500 1500\r\n1500 1500\r\n1700 1700\r\n", "output": "unrated\r\n"}, {"input": "4\r\n100 100\r\n100 100\r\n70 70\r\n80 80\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1 2\r\n2 1\r\n", "output": "rated\r\n"}, {"input": "3\r\n5 5\r\n4 3\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "3\r\n1600 1650\r\n1500 1550\r\n1400 1450\r\n", "output": "rated\r\n"}, {"input": "4\r\n2000 2000\r\n1500 1500\r\n1500 1500\r\n1700 1700\r\n", "output": "unrated\r\n"}, {"input": "4\r\n1500 1500\r\n1400 1400\r\n1400 1400\r\n1700 1700\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1600 1600\r\n1400 1400\r\n", "output": "maybe\r\n"}, {"input": "2\r\n3 1\r\n9 8\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 1\r\n1 1\r\n", "output": "rated\r\n"}, {"input": "4\r\n4123 4123\r\n4123 4123\r\n2670 2670\r\n3670 3670\r\n", "output": "unrated\r\n"}, {"input": "2\r\n2 2\r\n3 3\r\n", "output": "unrated\r\n"}, {"input": "2\r\n10 11\r\n5 4\r\n", "output": "rated\r\n"}, {"input": "2\r\n15 14\r\n13 12\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 1\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "3\r\n2670 2670\r\n3670 3670\r\n4106 4106\r\n", "output": "unrated\r\n"}, {"input": "3\r\n4 5\r\n3 3\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n10 9\r\n10 10\r\n", "output": "rated\r\n"}, {"input": "3\r\n1011 1011\r\n1011 999\r\n2200 2100\r\n", "output": "rated\r\n"}, {"input": "2\r\n3 3\r\n5 5\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1500 1500\r\n3000 2000\r\n", "output": "rated\r\n"}, {"input": "2\r\n5 6\r\n5 5\r\n", "output": "rated\r\n"}, {"input": "3\r\n2000 2000\r\n1500 1501\r\n500 500\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 3\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n3 3\r\n2 2\r\n", "output": "maybe\r\n"}, {"input": "2\r\n1 2\r\n1 1\r\n", "output": "rated\r\n"}, {"input": "4\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n1699 1699\r\n", "output": "maybe\r\n"}, {"input": "2\r\n15 14\r\n14 13\r\n", "output": "rated\r\n"}, {"input": "4\r\n3000 3000\r\n2900 2900\r\n3000 3000\r\n2900 2900\r\n", "output": "unrated\r\n"}, {"input": "6\r\n30 3060\r\n24 2194\r\n26 2903\r\n24 2624\r\n37 2991\r\n24 2884\r\n", "output": "rated\r\n"}, {"input": "2\r\n100 99\r\n100 100\r\n", "output": "rated\r\n"}, {"input": "4\r\n2 2\r\n1 1\r\n1 1\r\n2 2\r\n", "output": "unrated\r\n"}, {"input": "3\r\n100 101\r\n100 100\r\n100 100\r\n", "output": "rated\r\n"}, {"input": "4\r\n1000 1001\r\n900 900\r\n950 950\r\n890 890\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 3\r\n1 1\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 2\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "2\r\n3 2\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n3 2\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "2\r\n1 1\r\n2 2\r\n", "output": "unrated\r\n"}, {"input": "3\r\n3 2\r\n3 3\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "4\r\n1500 1501\r\n1300 1300\r\n1200 1200\r\n1400 1400\r\n", "output": "rated\r\n"}, {"input": "3\r\n1000 1000\r\n500 500\r\n400 300\r\n", "output": "rated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n3000 3000\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1 1\r\n2 3\r\n", "output": "rated\r\n"}, {"input": "2\r\n6 2\r\n6 2\r\n", "output": "rated\r\n"}, {"input": "5\r\n3123 3123\r\n1699 1699\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1500 1500\r\n1600 1600\r\n", "output": "unrated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2241 2241\r\n1699 1699\r\n", "output": "maybe\r\n"}, {"input": "2\r\n20 30\r\n10 5\r\n", "output": "rated\r\n"}, {"input": "3\r\n1 1\r\n2 2\r\n1 1\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1 2\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "5\r\n5 5\r\n4 4\r\n3 3\r\n2 2\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "2\r\n2 2\r\n2 1\r\n", "output": "rated\r\n"}, {"input": "2\r\n100 100\r\n90 89\r\n", "output": "rated\r\n"}, {"input": "2\r\n1000 900\r\n2000 2000\r\n", "output": "rated\r\n"}, {"input": "2\r\n50 10\r\n10 50\r\n", "output": "rated\r\n"}, {"input": "2\r\n200 200\r\n100 100\r\n", "output": "maybe\r\n"}, {"input": "3\r\n2 2\r\n2 2\r\n3 3\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1000 1000\r\n300 300\r\n100 100\r\n", "output": "maybe\r\n"}, {"input": "4\r\n2 2\r\n2 2\r\n3 3\r\n4 4\r\n", "output": "unrated\r\n"}, {"input": "2\r\n5 3\r\n6 3\r\n", "output": "rated\r\n"}, {"input": "2\r\n1200 1100\r\n1200 1000\r\n", "output": "rated\r\n"}, {"input": "2\r\n5 5\r\n4 4\r\n", "output": "maybe\r\n"}, {"input": "2\r\n5 5\r\n3 3\r\n", "output": "maybe\r\n"}, {"input": "5\r\n1500 1500\r\n1300 1300\r\n1200 1200\r\n1400 1400\r\n1100 1100\r\n", "output": "unrated\r\n"}, {"input": "5\r\n10 10\r\n9 9\r\n8 8\r\n7 7\r\n6 6\r\n", "output": "maybe\r\n"}, {"input": "3\r\n1000 1000\r\n300 300\r\n10 10\r\n", "output": "maybe\r\n"}, {"input": "5\r\n6 6\r\n5 5\r\n4 4\r\n3 3\r\n2 2\r\n", "output": "maybe\r\n"}, {"input": "2\r\n3 3\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "4\r\n2 2\r\n2 2\r\n2 2\r\n3 3\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1000 1000\r\n700 700\r\n", "output": "maybe\r\n"}, {"input": "2\r\n4 3\r\n5 3\r\n", "output": "rated\r\n"}, {"input": "2\r\n1000 1000\r\n1100 1100\r\n", "output": "unrated\r\n"}, {"input": "4\r\n5 5\r\n4 4\r\n3 3\r\n2 2\r\n", "output": "maybe\r\n"}, {"input": "3\r\n1 1\r\n2 3\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n1 2\r\n1 3\r\n", "output": "rated\r\n"}, {"input": "2\r\n3 3\r\n1 2\r\n", "output": "rated\r\n"}, {"input": "4\r\n1501 1500\r\n1300 1300\r\n1200 1200\r\n1400 1400\r\n", "output": "rated\r\n"}, {"input": "5\r\n1 1\r\n2 2\r\n3 3\r\n4 4\r\n5 5\r\n", "output": "unrated\r\n"}, {"input": "2\r\n10 10\r\n1 2\r\n", "output": "rated\r\n"}, {"input": "6\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n1699 1699\r\n1900 1900\r\n", "output": "unrated\r\n"}, {"input": "6\r\n3123 3123\r\n2777 2777\r\n3000 3000\r\n2246 2246\r\n2246 2246\r\n1699 1699\r\n", "output": "unrated\r\n"}, {"input": "2\r\n100 100\r\n110 110\r\n", "output": "unrated\r\n"}, {"input": "3\r\n3 3\r\n3 3\r\n4 4\r\n", "output": "unrated\r\n"}, {"input": "3\r\n3 3\r\n3 2\r\n4 4\r\n", "output": "rated\r\n"}, {"input": "3\r\n5 2\r\n4 4\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "4\r\n4 4\r\n3 3\r\n2 2\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "2\r\n1 1\r\n3 2\r\n", "output": "rated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n2699 2699\r\n", "output": "unrated\r\n"}, {"input": "3\r\n3 3\r\n3 3\r\n3 4\r\n", "output": "rated\r\n"}, {"input": "3\r\n1 2\r\n2 2\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "3\r\n1 2\r\n1 2\r\n1 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 1\r\n2 1\r\n", "output": "rated\r\n"}, {"input": "2\r\n1 2\r\n3 4\r\n", "output": "rated\r\n"}, {"input": "2\r\n3 2\r\n2 3\r\n", "output": "rated\r\n"}, {"input": "3\r\n1500 1500\r\n1600 1600\r\n1600 1600\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1 1\r\n3 3\r\n4 4\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1 1\r\n2 2\r\n2 2\r\n", "output": "unrated\r\n"}, {"input": "2\r\n10 12\r\n8 8\r\n", "output": "rated\r\n"}, {"input": "5\r\n1200 1200\r\n1500 1500\r\n1500 1500\r\n1500 1500\r\n1500 1500\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1 2\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "3\r\n1500 1400\r\n1200 1200\r\n1100 1100\r\n", "output": "rated\r\n"}, {"input": "2\r\n10 12\r\n10 10\r\n", "output": "rated\r\n"}, {"input": "3\r\n1500 1500\r\n1400 1400\r\n1300 1300\r\n", "output": "maybe\r\n"}, {"input": "3\r\n3 3\r\n4 4\r\n5 5\r\n", "output": "unrated\r\n"}, {"input": "3\r\n2 6\r\n3 5\r\n4 4\r\n", "output": "rated\r\n"}, {"input": "2\r\n5 6\r\n4 6\r\n", "output": "rated\r\n"}, {"input": "4\r\n10 10\r\n10 10\r\n7 7\r\n8 8\r\n", "output": "unrated\r\n"}, {"input": "2\r\n4 4\r\n3 3\r\n", "output": "maybe\r\n"}]
| false |
stdio
| null | true |
598/C
|
598
|
C
|
PyPy 3-64
|
TESTS
| 118 | 483 | 17,715,200 |
147382716
|
import sys,math
input = lambda: sys.stdin.readline()[:-1]
get_int = lambda: int(input())
get_int_iter = lambda: map(int,input().split())
get_int_list = lambda: list(map(int,input().split()))
n = get_int()
vectors = []
mod = math.pi * 2
for i in range(1,n+1):
x,y = get_int_iter()
if x != 0:
vectors.append([(math.atan(y/x) + math.pi * (x<0))%mod,i])
else:
vectors.append([(math.pi/2 + math.pi * (y<0))%mod,i])
vectors.sort()
min_angle = mod
i = 0
for x in range(n-1):
curr_angle = vectors[x+1][0] - vectors[x][0]
if curr_angle < min_angle:
min_angle = curr_angle
i = x
if mod + vectors[0][0] - vectors[n-1][0] < min_angle:
print(vectors[0][1],vectors[n-1][1])
else:
print(vectors[i][1],vectors[i+1][1])
| 163 | 1,060 | 35,328,000 |
154855646
|
from math import atan2
s = lambda a, b: a[0] * b[0] + a[1] * b[1]
v = lambda a, b: a[0] * b[1] - a[1] * b[0]
p = []
for i in range(int(input())):
x, y = map(int, input().split())
p.append((atan2(x, y), (x, y), i + 1))
p.sort()
d = [(s(a, b), abs(v(a, b)), i, j) for (x, a, i), (y, b, j) in zip(p, p[1:] + p[:1])]
x = d[0]
for y in d:
if v(y[:2], x[:2]) > 0: x = y
print(x[2], x[3])
|
Educational Codeforces Round 1
|
ICPC
| 2,015 | 2 | 256 |
Nearest vectors
|
You are given the set of vectors on the plane, each of them starting at the origin. Your task is to find a pair of vectors with the minimal non-oriented angle between them.
Non-oriented angle is non-negative value, minimal between clockwise and counterclockwise direction angles. Non-oriented angle is always between 0 and π. For example, opposite directions vectors have angle equals to π.
|
First line of the input contains a single integer n (2 ≤ n ≤ 100 000) — the number of vectors.
The i-th of the following n lines contains two integers xi and yi (|x|, |y| ≤ 10 000, x2 + y2 > 0) — the coordinates of the i-th vector. Vectors are numbered from 1 to n in order of appearing in the input. It is guaranteed that no two vectors in the input share the same direction (but they still can have opposite directions).
|
Print two integer numbers a and b (a ≠ b) — a pair of indices of vectors with the minimal non-oriented angle. You can print the numbers in any order. If there are many possible answers, print any.
| null | null |
[{"input": "4\n-1 0\n0 -1\n1 0\n1 1", "output": "3 4"}, {"input": "6\n-1 0\n0 -1\n1 0\n1 1\n-4 -5\n-4 -6", "output": "6 5"}]
| 2,300 |
["geometry", "sortings"]
| 163 |
[{"input": "4\r\n-1 0\r\n0 -1\r\n1 0\r\n1 1\r\n", "output": "3 4\r\n"}, {"input": "6\r\n-1 0\r\n0 -1\r\n1 0\r\n1 1\r\n-4 -5\r\n-4 -6\r\n", "output": "5 6\r\n"}, {"input": "10\r\n8 6\r\n-7 -3\r\n9 8\r\n7 10\r\n-3 -8\r\n3 7\r\n6 -8\r\n-9 8\r\n9 2\r\n6 7\r\n", "output": "1 3\r\n"}, {"input": "20\r\n-9 8\r\n-7 3\r\n0 10\r\n3 7\r\n6 -9\r\n6 8\r\n7 -6\r\n-6 10\r\n-10 3\r\n-8 -10\r\n10 -2\r\n1 -8\r\n-8 10\r\n10 10\r\n10 6\r\n-5 6\r\n5 -8\r\n5 -9\r\n-9 -1\r\n9 2\r\n", "output": "13 16\r\n"}, {"input": "2\r\n351 -4175\r\n-328 -657\r\n", "output": "2 1\r\n"}, {"input": "3\r\n620 -1189\r\n8101 -2770\r\n3347 3473\r\n", "output": "1 2\r\n"}, {"input": "4\r\n-7061 -5800\r\n-3471 -9470\r\n-7639 2529\r\n5657 -6522\r\n", "output": "1 2\r\n"}, {"input": "5\r\n-7519 -3395\r\n-32 -257\r\n-4827 -1889\r\n9545 -7037\r\n2767 583\r\n", "output": "3 1\r\n"}, {"input": "6\r\n-5120 -3251\r\n8269 -7984\r\n841 3396\r\n3136 -7551\r\n-1280 -3013\r\n-3263 -3278\r\n", "output": "1 6\r\n"}, {"input": "7\r\n-2722 6597\r\n-3303 200\r\n6508 -1021\r\n-1107 -1042\r\n6875 7616\r\n-3047 6749\r\n662 -1979\r\n", "output": "1 6\r\n"}, {"input": "8\r\n-36 749\r\n5126 943\r\n1165 533\r\n-1647 -5725\r\n5031 6532\r\n5956 8447\r\n2297 -2284\r\n1986 6937\r\n", "output": "5 6\r\n"}, {"input": "9\r\n-391 -1706\r\n995 -5756\r\n-5013 -154\r\n1121 3160\r\n-7111 8303\r\n-7303 -2414\r\n-7791 -935\r\n7576 -9361\r\n1072 203\r\n", "output": "3 7\r\n"}, {"input": "10\r\n-9920 -5477\r\n9691 -3200\r\n754 885\r\n-1895 1768\r\n-941 1588\r\n6293 -2631\r\n-2288 9129\r\n4067 696\r\n-6754 9869\r\n-5747 701\r\n", "output": "5 9\r\n"}, {"input": "2\r\n1 0\r\n-1 0\r\n", "output": "1 2\r\n"}, {"input": "2\r\n0 1\r\n0 -1\r\n", "output": "1 2\r\n"}, {"input": "2\r\n2131 -3249\r\n-2131 3249\r\n", "output": "2 1\r\n"}, {"input": "3\r\n-5 1\r\n-5 -1\r\n5 0\r\n", "output": "1 2\r\n"}, {"input": "3\r\n-100 1\r\n-100 -1\r\n0 100\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 10\r\n10 1\r\n10 -1\r\n", "output": "3 2\r\n"}, {"input": "3\r\n3 0\r\n0 3\r\n1 -3\r\n", "output": "3 1\r\n"}, {"input": "3\r\n1 1\r\n-1 0\r\n1 -1\r\n", "output": "3 1\r\n"}, {"input": "3\r\n-1 0\r\n10 -1\r\n1 0\r\n", "output": "2 3\r\n"}, {"input": "4\r\n1 10\r\n10 1\r\n-2 -2\r\n10 -1\r\n", "output": "4 2\r\n"}, {"input": "3\r\n-6 0\r\n6 1\r\n6 -1\r\n", "output": "3 2\r\n"}, {"input": "3\r\n114 1\r\n-514 0\r\n114 -1\r\n", "output": "3 1\r\n"}, {"input": "4\r\n-1 0\r\n0 -1\r\n-1 1\r\n1 0\r\n", "output": "3 1\r\n"}, {"input": "4\r\n2 1\r\n2 -1\r\n-1 1\r\n-1 -1\r\n", "output": "2 1\r\n"}, {"input": "3\r\n3 1\r\n3 -1\r\n0 3\r\n", "output": "2 1\r\n"}, {"input": "3\r\n1 1\r\n9000 1\r\n9000 -1\r\n", "output": "3 2\r\n"}, {"input": "3\r\n1 0\r\n-1 1\r\n-1 -1\r\n", "output": "2 3\r\n"}, {"input": "6\r\n1 1\r\n-1 -1\r\n0 20\r\n100 1\r\n-100 0\r\n100 -1\r\n", "output": "6 4\r\n"}, {"input": "4\r\n1 0\r\n0 1\r\n-1 0\r\n-13 -1\r\n", "output": "3 4\r\n"}, {"input": "3\r\n1 0\r\n-1 0\r\n1 -1\r\n", "output": "3 1\r\n"}, {"input": "3\r\n100 1\r\n-100 0\r\n100 -1\r\n", "output": "3 1\r\n"}, {"input": "3\r\n-100 1\r\n100 0\r\n-100 -1\r\n", "output": "1 3\r\n"}, {"input": "3\r\n1 100\r\n0 -100\r\n-1 100\r\n", "output": "1 3\r\n"}, {"input": "11\r\n-7945 386\r\n7504 -576\r\n-6020 -8277\r\n930 9737\r\n1682 474\r\n-8279 1197\r\n2790 2607\r\n-5514 -9601\r\n-3159 5939\r\n-1806 4207\r\n-9073 -2138\r\n", "output": "10 9\r\n"}, {"input": "3\r\n1 0\r\n10000 -1\r\n1 1\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-7125 -1643\r\n-1235 4071\r\n-75 -8717\r\n2553 9278\r\n", "output": "4 2\r\n"}, {"input": "5\r\n-6 0\r\n6 1\r\n6 -1\r\n0 6\r\n0 -6\r\n", "output": "3 2\r\n"}, {"input": "4\r\n5 5\r\n5 -5\r\n-555 1\r\n-555 -1\r\n", "output": "3 4\r\n"}, {"input": "4\r\n1 1\r\n-1 1\r\n-1 -1\r\n2 -1\r\n", "output": "4 1\r\n"}, {"input": "4\r\n-1 -100\r\n1 -100\r\n-100 -100\r\n100 -100\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 0\r\n1 -1\r\n-4 -6\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-1 -100\r\n1 -100\r\n100 -100\r\n-100 -100\r\n", "output": "1 2\r\n"}, {"input": "4\r\n-1 0\r\n0 -2\r\n-3 3\r\n4 0\r\n", "output": "3 1\r\n"}, {"input": "4\r\n-2 0\r\n0 -3\r\n-5 5\r\n4 0\r\n", "output": "3 1\r\n"}, {"input": "3\r\n1 -100\r\n0 100\r\n-1 -100\r\n", "output": "3 1\r\n"}, {"input": "5\r\n10000 2\r\n10000 -1\r\n10000 -5\r\n10000 -9\r\n10000 -13\r\n", "output": "2 1\r\n"}, {"input": "8\r\n-9580 8545\r\n-9379 -1139\r\n5824 -391\r\n-8722 2765\r\n-1357 -5547\r\n-7700 217\r\n9323 -7008\r\n957 -8356\r\n", "output": "6 2\r\n"}, {"input": "4\r\n5 5\r\n5 -5\r\n-500 1\r\n-500 -1\r\n", "output": "3 4\r\n"}, {"input": "3\r\n30 1\r\n30 -1\r\n0 30\r\n", "output": "2 1\r\n"}, {"input": "4\r\n3966 -1107\r\n8007 -5457\r\n-7753 4945\r\n-2209 -4221\r\n", "output": "2 1\r\n"}, {"input": "4\r\n1 9999\r\n0 1\r\n10000 0\r\n10000 -1\r\n", "output": "4 3\r\n"}, {"input": "3\r\n10000 1\r\n10000 -1\r\n-10000 0\r\n", "output": "2 1\r\n"}, {"input": "13\r\n1 2\r\n2 3\r\n3 4\r\n4 5\r\n5 6\r\n6 7\r\n7 8\r\n8 9\r\n9 10\r\n10 11\r\n11 12\r\n13 14\r\n12 13\r\n", "output": "12 13\r\n"}, {"input": "4\r\n2 1\r\n2 -1\r\n0 1\r\n-1 0\r\n", "output": "2 1\r\n"}, {"input": "4\r\n10 3\r\n10 -3\r\n-500 1\r\n-500 -1\r\n", "output": "3 4\r\n"}, {"input": "4\r\n1 10000\r\n-1 1\r\n10000 0\r\n10000 -1\r\n", "output": "4 3\r\n"}, {"input": "3\r\n0 1\r\n1 0\r\n1 -1\r\n", "output": "3 2\r\n"}, {"input": "3\r\n1 0\r\n0 1\r\n1 -1\r\n", "output": "3 1\r\n"}, {"input": "4\r\n1 1\r\n-1 1\r\n1 -2\r\n-1 -2\r\n", "output": "4 3\r\n"}, {"input": "4\r\n0 -1\r\n-1 0\r\n-1 1\r\n1 0\r\n", "output": "3 2\r\n"}, {"input": "3\r\n-100 1\r\n-100 -1\r\n1 1\r\n", "output": "1 2\r\n"}, {"input": "3\r\n-3 1\r\n-3 -1\r\n2 -3\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 -1\r\n1 0\r\n0 1\r\n", "output": "1 2\r\n"}, {"input": "5\r\n-5 1\r\n0 5\r\n4 1\r\n0 -4\r\n-5 -1\r\n", "output": "1 5\r\n"}, {"input": "4\r\n1 10000\r\n0 1\r\n10000 0\r\n9999 -1\r\n", "output": "1 2\r\n"}, {"input": "4\r\n2 3\r\n2 -3\r\n-3 2\r\n-3 -2\r\n", "output": "3 4\r\n"}, {"input": "3\r\n1 -3\r\n1 0\r\n0 1\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 0\r\n-1 0\r\n-1 -1\r\n", "output": "2 3\r\n"}, {"input": "4\r\n-2 1\r\n-2 -1\r\n1 1\r\n1 -1\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 -1\r\n-1 1\r\n-1 -2\r\n", "output": "3 1\r\n"}, {"input": "3\r\n1 0\r\n-1 -1\r\n1 -1\r\n", "output": "3 1\r\n"}, {"input": "3\r\n5 5\r\n-5 0\r\n5 -5\r\n", "output": "3 1\r\n"}, {"input": "4\r\n1 -2\r\n1 0\r\n-1 0\r\n10 -1\r\n", "output": "4 2\r\n"}, {"input": "3\r\n-1000 1\r\n-1000 -1\r\n1000 0\r\n", "output": "1 2\r\n"}, {"input": "6\r\n1 1\r\n1 -1\r\n-1 1\r\n-1 -1\r\n1 -10000\r\n-1 -10000\r\n", "output": "6 5\r\n"}, {"input": "3\r\n1 1\r\n-1 0\r\n0 -1\r\n", "output": "2 3\r\n"}, {"input": "4\r\n5000 1\r\n5000 -1\r\n-2 -1\r\n2 -1\r\n", "output": "2 1\r\n"}, {"input": "3\r\n1 0\r\n-1 1\r\n-1 -5\r\n", "output": "3 1\r\n"}, {"input": "3\r\n-5374 1323\r\n-4463 -8462\r\n6118 -7918\r\n", "output": "2 3\r\n"}, {"input": "4\r\n-6427 -6285\r\n-5386 -5267\r\n-3898 7239\r\n-3905 7252\r\n", "output": "4 3\r\n"}, {"input": "10\r\n-7 -3\r\n-2 8\r\n9 -9\r\n0 1\r\n4 5\r\n5 3\r\n-3 0\r\n10 2\r\n4 -1\r\n2 -10\r\n", "output": "4 2\r\n"}, {"input": "4\r\n9999 1\r\n9999 -1\r\n-9998 1\r\n-10000 -1\r\n", "output": "2 1\r\n"}, {"input": "4\r\n10000 9999\r\n9999 9998\r\n9998 9997\r\n9997 9996\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-6285 -6427\r\n-5267 -5386\r\n7239 -3898\r\n7252 -3905\r\n", "output": "3 4\r\n"}, {"input": "4\r\n-6427 6285\r\n-5386 5267\r\n3898 -7239\r\n3905 -7252\r\n", "output": "4 3\r\n"}, {"input": "4\r\n-6427 -6285\r\n-5386 -5267\r\n-3898 -7239\r\n-3905 -7252\r\n", "output": "3 4\r\n"}, {"input": "3\r\n0 1\r\n-1 -1\r\n1 -1\r\n", "output": "2 3\r\n"}, {"input": "4\r\n10000 1\r\n9998 -1\r\n-9999 1\r\n-9999 -1\r\n", "output": "3 4\r\n"}, {"input": "3\r\n100 0\r\n100 2\r\n100 -1\r\n", "output": "3 1\r\n"}, {"input": "3\r\n-1 1\r\n-1 -1\r\n1 0\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9844 9986\r\n181 9967\r\n-9812 -9925\r\n-194 -9900\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9800 9981\r\n61 9899\r\n-9926 -9932\r\n-149 -9926\r\n", "output": "3 4\r\n"}, {"input": "4\r\n-9901 9900\r\n-10000 9899\r\n9899 9801\r\n9899 9900\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9934 9989\r\n199 9949\r\n-9917 -9974\r\n-197 -9901\r\n", "output": "3 4\r\n"}, {"input": "3\r\n-1 1\r\n1 0\r\n-1 -1\r\n", "output": "1 3\r\n"}, {"input": "3\r\n1 1\r\n-10 -10\r\n-10 -9\r\n", "output": "3 2\r\n"}, {"input": "3\r\n1 0\r\n10000 -1\r\n-1 0\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9999 1\r\n9999 -1\r\n-10000 1\r\n-10000 -1\r\n", "output": "3 4\r\n"}, {"input": "3\r\n-5 1\r\n-5 -1\r\n1 0\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 0\r\n10000 1\r\n-1 0\r\n", "output": "1 2\r\n"}, {"input": "4\r\n-9990 9995\r\n9994 -9991\r\n-9999 -9992\r\n9993 9992\r\n", "output": "2 4\r\n"}, {"input": "8\r\n1 0\r\n1 1\r\n0 1\r\n-1 1\r\n-1 0\r\n-1 -1\r\n0 -1\r\n1 -2\r\n", "output": "7 8\r\n"}, {"input": "3\r\n-9930 9932\r\n9909 -9909\r\n-9932 -9931\r\n", "output": "3 2\r\n"}, {"input": "4\r\n9876 9977\r\n127 9938\r\n-9820 -9934\r\n-120 -9921\r\n", "output": "3 4\r\n"}, {"input": "3\r\n10000 -1\r\n-1 0\r\n0 -1\r\n", "output": "3 1\r\n"}, {"input": "4\r\n6427 -6285\r\n5386 -5267\r\n3898 7239\r\n3905 7252\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9811 9970\r\n155 9994\r\n-9826 -9977\r\n-159 -9986\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9851 9917\r\n74 9921\r\n-9855 -9916\r\n-77 -9984\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9826 9977\r\n159 9986\r\n-9811 -9970\r\n-155 -9994\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9849 9986\r\n148 9980\r\n-9800 -9999\r\n-116 -9927\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9822 9967\r\n111 9905\r\n-9943 -9986\r\n-163 -9953\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9959 9995\r\n113 9940\r\n-9965 -9931\r\n-148 -9945\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9851 9972\r\n153 9983\r\n-9866 -9926\r\n-183 -9946\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9816 -9979\r\n127 -9940\r\n-9876 9915\r\n-190 9978\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9887 -9917\r\n138 -9977\r\n-9826 9995\r\n-68 9971\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9936 -9965\r\n135 -9949\r\n-9928 9980\r\n-123 9908\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9981 -9985\r\n191 -9956\r\n-9893 9937\r\n-171 9962\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-9811 9970\r\n-155 9994\r\n9826 -9977\r\n159 -9986\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9808 9899\r\n179 9966\r\n-9870 -9961\r\n-179 -9950\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9815 -9936\r\n168 -9937\r\n-9896 9995\r\n-180 9969\r\n", "output": "2 1\r\n"}, {"input": "4\r\n1 1\r\n1 -1\r\n-100 1\r\n-100 -1\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9965 114\r\n87 9916\r\n-9957 -106\r\n-95 -9929\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9895 -9949\r\n188 -9978\r\n-9810 9935\r\n-151 9914\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-9957 106\r\n-95 9929\r\n9965 -114\r\n87 -9916\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-9862 9980\r\n-174 9917\r\n9845 -9967\r\n173 -9980\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9944 9926\r\n9927 9935\r\n-9961 -9929\r\n-9997 -9991\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9917 9909\r\n196 9925\r\n-9971 -9991\r\n-183 -9977\r\n", "output": "3 4\r\n"}]
| false |
stdio
|
import sys
import math
def read_vectors(input_path):
with open(input_path) as f:
n = int(f.readline())
vectors = []
for i in range(n):
x, y = map(int, f.readline().split())
vectors.append( (x, y, i+1) )
return vectors
def compute_angle(x, y):
return math.atan2(y, x) % (2 * math.pi)
def compute_non_oriented_angle(u, v):
ux, uy = u
vx, vy = v
dot = ux * vx + uy * vy
mag_u = math.hypot(ux, uy)
mag_v = math.hypot(vx, vy)
if mag_u == 0 or mag_v == 0:
return 0.0
cos_theta = dot / (mag_u * mag_v)
cos_theta = max(min(cos_theta, 1.0), -1.0)
return math.acos(cos_theta)
def find_min_angle(vectors):
sorted_vectors = sorted(vectors, key=lambda vec: compute_angle(vec[0], vec[1]))
n = len(sorted_vectors)
min_adjacent = math.pi
for i in range(n):
j = (i + 1) % n
u = sorted_vectors[i][0], sorted_vectors[i][1]
v = sorted_vectors[j][0], sorted_vectors[j][1]
theta = compute_non_oriented_angle(u, v)
if theta < min_adjacent:
min_adjacent = theta
angles = []
for vec in sorted_vectors:
x, y, idx = vec
angles.append( compute_angle(x, y) )
min_opposite = math.pi
for i in range(n):
theta_i = angles[i]
target = (theta_i + math.pi) % (2 * math.pi)
low = 0
high = n
while low < high:
mid = (low + high) // 2
if angles[mid] < target:
low = mid + 1
else:
high = mid
candidates = []
if low > 0:
candidates.append(low-1)
if low < n:
candidates.append(low)
candidates.append((low - 1) % n)
candidates = list(set(candidates))
for c in candidates:
if c == i:
continue
c = c % n
vec_c = sorted_vectors[c]
u = sorted_vectors[i][0], sorted_vectors[i][1]
v = vec_c[0], vec_c[1]
current_theta = compute_non_oriented_angle(u, v)
if current_theta < min_opposite:
min_opposite = current_theta
return min(min_adjacent, min_opposite)
def main(input_path, output_path, submission_output_path):
input_vectors = read_vectors(input_path)
with open(submission_output_path) as f:
line = f.readline().strip()
try:
a, b = map(int, line.split())
except:
print(0)
return
n = len(input_vectors)
if a < 1 or a > n or b < 1 or b > n or a == b:
print(0)
return
vec_a = None
vec_b = None
for vec in input_vectors:
if vec[2] == a:
vec_a = vec
if vec[2] == b:
vec_b = vec
if vec_a is None or vec_b is None:
print(0)
return
u = (vec_a[0], vec_a[1])
v = (vec_b[0], vec_b[1])
theta = compute_non_oriented_angle(u, v)
min_angle = find_min_angle(input_vectors)
epsilon = 1e-9
if abs(theta - min_angle) <= epsilon:
print(1)
else:
print(0)
if __name__ == "__main__":
input_path = sys.argv[1]
output_path = sys.argv[2]
submission_output_path = sys.argv[3]
main(input_path, output_path, submission_output_path)
| true |
598/C
|
598
|
C
|
Python 3
|
TESTS
| 113 | 530 | 8,704,000 |
173893303
|
import math
def nearest_vec(L):
L.sort()
L.append(L[0])
min_val = float('inf')
values = [-1, -1]
for r in range(1, len(L)):
x = L[r][0] - L[r - 1][0]
if x < 0:
x += 360
if x < min_val:
min_val = x
values[0] = L[r][1]
values[1] = L[r - 1][1]
return (values)
N = int(input())
L = []
for i in range(N):
x, y = tuple(map(int, input().split()))
L.append([(math.degrees(math.atan2(y, x))), i + 1])
for val in L:
if val[0]<0:
val[0]+=360
print(*nearest_vec(L))
| 163 | 1,153 | 20,992,000 |
112977689
|
from math import atan2
inner = lambda a, b: a[0] * b[0] + a[1] * b[1]
outer = lambda a, b: a[0] * b[1] - a[1] * b[0]
N = int(input())
vectors = []
for i in range(N):
x, y = map(int, input().split())
vectors.append((atan2(y, x), (x, y), i + 1))
vectors.sort()
diff = []
for i in range(N):
diff.append([inner(vectors[i][1], vectors[(i+1)%N][1]), abs(outer(vectors[i][1], vectors[(i+1)%N][1])), vectors[i][2], vectors[(i+1)%N][2]])
min_diff = diff[0]
for d in diff:
if outer(d[:2], min_diff[:2]) > 0: min_diff = d
print(min_diff[2], min_diff[3])
|
Educational Codeforces Round 1
|
ICPC
| 2,015 | 2 | 256 |
Nearest vectors
|
You are given the set of vectors on the plane, each of them starting at the origin. Your task is to find a pair of vectors with the minimal non-oriented angle between them.
Non-oriented angle is non-negative value, minimal between clockwise and counterclockwise direction angles. Non-oriented angle is always between 0 and π. For example, opposite directions vectors have angle equals to π.
|
First line of the input contains a single integer n (2 ≤ n ≤ 100 000) — the number of vectors.
The i-th of the following n lines contains two integers xi and yi (|x|, |y| ≤ 10 000, x2 + y2 > 0) — the coordinates of the i-th vector. Vectors are numbered from 1 to n in order of appearing in the input. It is guaranteed that no two vectors in the input share the same direction (but they still can have opposite directions).
|
Print two integer numbers a and b (a ≠ b) — a pair of indices of vectors with the minimal non-oriented angle. You can print the numbers in any order. If there are many possible answers, print any.
| null | null |
[{"input": "4\n-1 0\n0 -1\n1 0\n1 1", "output": "3 4"}, {"input": "6\n-1 0\n0 -1\n1 0\n1 1\n-4 -5\n-4 -6", "output": "6 5"}]
| 2,300 |
["geometry", "sortings"]
| 163 |
[{"input": "4\r\n-1 0\r\n0 -1\r\n1 0\r\n1 1\r\n", "output": "3 4\r\n"}, {"input": "6\r\n-1 0\r\n0 -1\r\n1 0\r\n1 1\r\n-4 -5\r\n-4 -6\r\n", "output": "5 6\r\n"}, {"input": "10\r\n8 6\r\n-7 -3\r\n9 8\r\n7 10\r\n-3 -8\r\n3 7\r\n6 -8\r\n-9 8\r\n9 2\r\n6 7\r\n", "output": "1 3\r\n"}, {"input": "20\r\n-9 8\r\n-7 3\r\n0 10\r\n3 7\r\n6 -9\r\n6 8\r\n7 -6\r\n-6 10\r\n-10 3\r\n-8 -10\r\n10 -2\r\n1 -8\r\n-8 10\r\n10 10\r\n10 6\r\n-5 6\r\n5 -8\r\n5 -9\r\n-9 -1\r\n9 2\r\n", "output": "13 16\r\n"}, {"input": "2\r\n351 -4175\r\n-328 -657\r\n", "output": "2 1\r\n"}, {"input": "3\r\n620 -1189\r\n8101 -2770\r\n3347 3473\r\n", "output": "1 2\r\n"}, {"input": "4\r\n-7061 -5800\r\n-3471 -9470\r\n-7639 2529\r\n5657 -6522\r\n", "output": "1 2\r\n"}, {"input": "5\r\n-7519 -3395\r\n-32 -257\r\n-4827 -1889\r\n9545 -7037\r\n2767 583\r\n", "output": "3 1\r\n"}, {"input": "6\r\n-5120 -3251\r\n8269 -7984\r\n841 3396\r\n3136 -7551\r\n-1280 -3013\r\n-3263 -3278\r\n", "output": "1 6\r\n"}, {"input": "7\r\n-2722 6597\r\n-3303 200\r\n6508 -1021\r\n-1107 -1042\r\n6875 7616\r\n-3047 6749\r\n662 -1979\r\n", "output": "1 6\r\n"}, {"input": "8\r\n-36 749\r\n5126 943\r\n1165 533\r\n-1647 -5725\r\n5031 6532\r\n5956 8447\r\n2297 -2284\r\n1986 6937\r\n", "output": "5 6\r\n"}, {"input": "9\r\n-391 -1706\r\n995 -5756\r\n-5013 -154\r\n1121 3160\r\n-7111 8303\r\n-7303 -2414\r\n-7791 -935\r\n7576 -9361\r\n1072 203\r\n", "output": "3 7\r\n"}, {"input": "10\r\n-9920 -5477\r\n9691 -3200\r\n754 885\r\n-1895 1768\r\n-941 1588\r\n6293 -2631\r\n-2288 9129\r\n4067 696\r\n-6754 9869\r\n-5747 701\r\n", "output": "5 9\r\n"}, {"input": "2\r\n1 0\r\n-1 0\r\n", "output": "1 2\r\n"}, {"input": "2\r\n0 1\r\n0 -1\r\n", "output": "1 2\r\n"}, {"input": "2\r\n2131 -3249\r\n-2131 3249\r\n", "output": "2 1\r\n"}, {"input": "3\r\n-5 1\r\n-5 -1\r\n5 0\r\n", "output": "1 2\r\n"}, {"input": "3\r\n-100 1\r\n-100 -1\r\n0 100\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 10\r\n10 1\r\n10 -1\r\n", "output": "3 2\r\n"}, {"input": "3\r\n3 0\r\n0 3\r\n1 -3\r\n", "output": "3 1\r\n"}, {"input": "3\r\n1 1\r\n-1 0\r\n1 -1\r\n", "output": "3 1\r\n"}, {"input": "3\r\n-1 0\r\n10 -1\r\n1 0\r\n", "output": "2 3\r\n"}, {"input": "4\r\n1 10\r\n10 1\r\n-2 -2\r\n10 -1\r\n", "output": "4 2\r\n"}, {"input": "3\r\n-6 0\r\n6 1\r\n6 -1\r\n", "output": "3 2\r\n"}, {"input": "3\r\n114 1\r\n-514 0\r\n114 -1\r\n", "output": "3 1\r\n"}, {"input": "4\r\n-1 0\r\n0 -1\r\n-1 1\r\n1 0\r\n", "output": "3 1\r\n"}, {"input": "4\r\n2 1\r\n2 -1\r\n-1 1\r\n-1 -1\r\n", "output": "2 1\r\n"}, {"input": "3\r\n3 1\r\n3 -1\r\n0 3\r\n", "output": "2 1\r\n"}, {"input": "3\r\n1 1\r\n9000 1\r\n9000 -1\r\n", "output": "3 2\r\n"}, {"input": "3\r\n1 0\r\n-1 1\r\n-1 -1\r\n", "output": "2 3\r\n"}, {"input": "6\r\n1 1\r\n-1 -1\r\n0 20\r\n100 1\r\n-100 0\r\n100 -1\r\n", "output": "6 4\r\n"}, {"input": "4\r\n1 0\r\n0 1\r\n-1 0\r\n-13 -1\r\n", "output": "3 4\r\n"}, {"input": "3\r\n1 0\r\n-1 0\r\n1 -1\r\n", "output": "3 1\r\n"}, {"input": "3\r\n100 1\r\n-100 0\r\n100 -1\r\n", "output": "3 1\r\n"}, {"input": "3\r\n-100 1\r\n100 0\r\n-100 -1\r\n", "output": "1 3\r\n"}, {"input": "3\r\n1 100\r\n0 -100\r\n-1 100\r\n", "output": "1 3\r\n"}, {"input": "11\r\n-7945 386\r\n7504 -576\r\n-6020 -8277\r\n930 9737\r\n1682 474\r\n-8279 1197\r\n2790 2607\r\n-5514 -9601\r\n-3159 5939\r\n-1806 4207\r\n-9073 -2138\r\n", "output": "10 9\r\n"}, {"input": "3\r\n1 0\r\n10000 -1\r\n1 1\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-7125 -1643\r\n-1235 4071\r\n-75 -8717\r\n2553 9278\r\n", "output": "4 2\r\n"}, {"input": "5\r\n-6 0\r\n6 1\r\n6 -1\r\n0 6\r\n0 -6\r\n", "output": "3 2\r\n"}, {"input": "4\r\n5 5\r\n5 -5\r\n-555 1\r\n-555 -1\r\n", "output": "3 4\r\n"}, {"input": "4\r\n1 1\r\n-1 1\r\n-1 -1\r\n2 -1\r\n", "output": "4 1\r\n"}, {"input": "4\r\n-1 -100\r\n1 -100\r\n-100 -100\r\n100 -100\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 0\r\n1 -1\r\n-4 -6\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-1 -100\r\n1 -100\r\n100 -100\r\n-100 -100\r\n", "output": "1 2\r\n"}, {"input": "4\r\n-1 0\r\n0 -2\r\n-3 3\r\n4 0\r\n", "output": "3 1\r\n"}, {"input": "4\r\n-2 0\r\n0 -3\r\n-5 5\r\n4 0\r\n", "output": "3 1\r\n"}, {"input": "3\r\n1 -100\r\n0 100\r\n-1 -100\r\n", "output": "3 1\r\n"}, {"input": "5\r\n10000 2\r\n10000 -1\r\n10000 -5\r\n10000 -9\r\n10000 -13\r\n", "output": "2 1\r\n"}, {"input": "8\r\n-9580 8545\r\n-9379 -1139\r\n5824 -391\r\n-8722 2765\r\n-1357 -5547\r\n-7700 217\r\n9323 -7008\r\n957 -8356\r\n", "output": "6 2\r\n"}, {"input": "4\r\n5 5\r\n5 -5\r\n-500 1\r\n-500 -1\r\n", "output": "3 4\r\n"}, {"input": "3\r\n30 1\r\n30 -1\r\n0 30\r\n", "output": "2 1\r\n"}, {"input": "4\r\n3966 -1107\r\n8007 -5457\r\n-7753 4945\r\n-2209 -4221\r\n", "output": "2 1\r\n"}, {"input": "4\r\n1 9999\r\n0 1\r\n10000 0\r\n10000 -1\r\n", "output": "4 3\r\n"}, {"input": "3\r\n10000 1\r\n10000 -1\r\n-10000 0\r\n", "output": "2 1\r\n"}, {"input": "13\r\n1 2\r\n2 3\r\n3 4\r\n4 5\r\n5 6\r\n6 7\r\n7 8\r\n8 9\r\n9 10\r\n10 11\r\n11 12\r\n13 14\r\n12 13\r\n", "output": "12 13\r\n"}, {"input": "4\r\n2 1\r\n2 -1\r\n0 1\r\n-1 0\r\n", "output": "2 1\r\n"}, {"input": "4\r\n10 3\r\n10 -3\r\n-500 1\r\n-500 -1\r\n", "output": "3 4\r\n"}, {"input": "4\r\n1 10000\r\n-1 1\r\n10000 0\r\n10000 -1\r\n", "output": "4 3\r\n"}, {"input": "3\r\n0 1\r\n1 0\r\n1 -1\r\n", "output": "3 2\r\n"}, {"input": "3\r\n1 0\r\n0 1\r\n1 -1\r\n", "output": "3 1\r\n"}, {"input": "4\r\n1 1\r\n-1 1\r\n1 -2\r\n-1 -2\r\n", "output": "4 3\r\n"}, {"input": "4\r\n0 -1\r\n-1 0\r\n-1 1\r\n1 0\r\n", "output": "3 2\r\n"}, {"input": "3\r\n-100 1\r\n-100 -1\r\n1 1\r\n", "output": "1 2\r\n"}, {"input": "3\r\n-3 1\r\n-3 -1\r\n2 -3\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 -1\r\n1 0\r\n0 1\r\n", "output": "1 2\r\n"}, {"input": "5\r\n-5 1\r\n0 5\r\n4 1\r\n0 -4\r\n-5 -1\r\n", "output": "1 5\r\n"}, {"input": "4\r\n1 10000\r\n0 1\r\n10000 0\r\n9999 -1\r\n", "output": "1 2\r\n"}, {"input": "4\r\n2 3\r\n2 -3\r\n-3 2\r\n-3 -2\r\n", "output": "3 4\r\n"}, {"input": "3\r\n1 -3\r\n1 0\r\n0 1\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 0\r\n-1 0\r\n-1 -1\r\n", "output": "2 3\r\n"}, {"input": "4\r\n-2 1\r\n-2 -1\r\n1 1\r\n1 -1\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 -1\r\n-1 1\r\n-1 -2\r\n", "output": "3 1\r\n"}, {"input": "3\r\n1 0\r\n-1 -1\r\n1 -1\r\n", "output": "3 1\r\n"}, {"input": "3\r\n5 5\r\n-5 0\r\n5 -5\r\n", "output": "3 1\r\n"}, {"input": "4\r\n1 -2\r\n1 0\r\n-1 0\r\n10 -1\r\n", "output": "4 2\r\n"}, {"input": "3\r\n-1000 1\r\n-1000 -1\r\n1000 0\r\n", "output": "1 2\r\n"}, {"input": "6\r\n1 1\r\n1 -1\r\n-1 1\r\n-1 -1\r\n1 -10000\r\n-1 -10000\r\n", "output": "6 5\r\n"}, {"input": "3\r\n1 1\r\n-1 0\r\n0 -1\r\n", "output": "2 3\r\n"}, {"input": "4\r\n5000 1\r\n5000 -1\r\n-2 -1\r\n2 -1\r\n", "output": "2 1\r\n"}, {"input": "3\r\n1 0\r\n-1 1\r\n-1 -5\r\n", "output": "3 1\r\n"}, {"input": "3\r\n-5374 1323\r\n-4463 -8462\r\n6118 -7918\r\n", "output": "2 3\r\n"}, {"input": "4\r\n-6427 -6285\r\n-5386 -5267\r\n-3898 7239\r\n-3905 7252\r\n", "output": "4 3\r\n"}, {"input": "10\r\n-7 -3\r\n-2 8\r\n9 -9\r\n0 1\r\n4 5\r\n5 3\r\n-3 0\r\n10 2\r\n4 -1\r\n2 -10\r\n", "output": "4 2\r\n"}, {"input": "4\r\n9999 1\r\n9999 -1\r\n-9998 1\r\n-10000 -1\r\n", "output": "2 1\r\n"}, {"input": "4\r\n10000 9999\r\n9999 9998\r\n9998 9997\r\n9997 9996\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-6285 -6427\r\n-5267 -5386\r\n7239 -3898\r\n7252 -3905\r\n", "output": "3 4\r\n"}, {"input": "4\r\n-6427 6285\r\n-5386 5267\r\n3898 -7239\r\n3905 -7252\r\n", "output": "4 3\r\n"}, {"input": "4\r\n-6427 -6285\r\n-5386 -5267\r\n-3898 -7239\r\n-3905 -7252\r\n", "output": "3 4\r\n"}, {"input": "3\r\n0 1\r\n-1 -1\r\n1 -1\r\n", "output": "2 3\r\n"}, {"input": "4\r\n10000 1\r\n9998 -1\r\n-9999 1\r\n-9999 -1\r\n", "output": "3 4\r\n"}, {"input": "3\r\n100 0\r\n100 2\r\n100 -1\r\n", "output": "3 1\r\n"}, {"input": "3\r\n-1 1\r\n-1 -1\r\n1 0\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9844 9986\r\n181 9967\r\n-9812 -9925\r\n-194 -9900\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9800 9981\r\n61 9899\r\n-9926 -9932\r\n-149 -9926\r\n", "output": "3 4\r\n"}, {"input": "4\r\n-9901 9900\r\n-10000 9899\r\n9899 9801\r\n9899 9900\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9934 9989\r\n199 9949\r\n-9917 -9974\r\n-197 -9901\r\n", "output": "3 4\r\n"}, {"input": "3\r\n-1 1\r\n1 0\r\n-1 -1\r\n", "output": "1 3\r\n"}, {"input": "3\r\n1 1\r\n-10 -10\r\n-10 -9\r\n", "output": "3 2\r\n"}, {"input": "3\r\n1 0\r\n10000 -1\r\n-1 0\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9999 1\r\n9999 -1\r\n-10000 1\r\n-10000 -1\r\n", "output": "3 4\r\n"}, {"input": "3\r\n-5 1\r\n-5 -1\r\n1 0\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 0\r\n10000 1\r\n-1 0\r\n", "output": "1 2\r\n"}, {"input": "4\r\n-9990 9995\r\n9994 -9991\r\n-9999 -9992\r\n9993 9992\r\n", "output": "2 4\r\n"}, {"input": "8\r\n1 0\r\n1 1\r\n0 1\r\n-1 1\r\n-1 0\r\n-1 -1\r\n0 -1\r\n1 -2\r\n", "output": "7 8\r\n"}, {"input": "3\r\n-9930 9932\r\n9909 -9909\r\n-9932 -9931\r\n", "output": "3 2\r\n"}, {"input": "4\r\n9876 9977\r\n127 9938\r\n-9820 -9934\r\n-120 -9921\r\n", "output": "3 4\r\n"}, {"input": "3\r\n10000 -1\r\n-1 0\r\n0 -1\r\n", "output": "3 1\r\n"}, {"input": "4\r\n6427 -6285\r\n5386 -5267\r\n3898 7239\r\n3905 7252\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9811 9970\r\n155 9994\r\n-9826 -9977\r\n-159 -9986\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9851 9917\r\n74 9921\r\n-9855 -9916\r\n-77 -9984\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9826 9977\r\n159 9986\r\n-9811 -9970\r\n-155 -9994\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9849 9986\r\n148 9980\r\n-9800 -9999\r\n-116 -9927\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9822 9967\r\n111 9905\r\n-9943 -9986\r\n-163 -9953\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9959 9995\r\n113 9940\r\n-9965 -9931\r\n-148 -9945\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9851 9972\r\n153 9983\r\n-9866 -9926\r\n-183 -9946\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9816 -9979\r\n127 -9940\r\n-9876 9915\r\n-190 9978\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9887 -9917\r\n138 -9977\r\n-9826 9995\r\n-68 9971\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9936 -9965\r\n135 -9949\r\n-9928 9980\r\n-123 9908\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9981 -9985\r\n191 -9956\r\n-9893 9937\r\n-171 9962\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-9811 9970\r\n-155 9994\r\n9826 -9977\r\n159 -9986\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9808 9899\r\n179 9966\r\n-9870 -9961\r\n-179 -9950\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9815 -9936\r\n168 -9937\r\n-9896 9995\r\n-180 9969\r\n", "output": "2 1\r\n"}, {"input": "4\r\n1 1\r\n1 -1\r\n-100 1\r\n-100 -1\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9965 114\r\n87 9916\r\n-9957 -106\r\n-95 -9929\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9895 -9949\r\n188 -9978\r\n-9810 9935\r\n-151 9914\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-9957 106\r\n-95 9929\r\n9965 -114\r\n87 -9916\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-9862 9980\r\n-174 9917\r\n9845 -9967\r\n173 -9980\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9944 9926\r\n9927 9935\r\n-9961 -9929\r\n-9997 -9991\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9917 9909\r\n196 9925\r\n-9971 -9991\r\n-183 -9977\r\n", "output": "3 4\r\n"}]
| false |
stdio
|
import sys
import math
def read_vectors(input_path):
with open(input_path) as f:
n = int(f.readline())
vectors = []
for i in range(n):
x, y = map(int, f.readline().split())
vectors.append( (x, y, i+1) )
return vectors
def compute_angle(x, y):
return math.atan2(y, x) % (2 * math.pi)
def compute_non_oriented_angle(u, v):
ux, uy = u
vx, vy = v
dot = ux * vx + uy * vy
mag_u = math.hypot(ux, uy)
mag_v = math.hypot(vx, vy)
if mag_u == 0 or mag_v == 0:
return 0.0
cos_theta = dot / (mag_u * mag_v)
cos_theta = max(min(cos_theta, 1.0), -1.0)
return math.acos(cos_theta)
def find_min_angle(vectors):
sorted_vectors = sorted(vectors, key=lambda vec: compute_angle(vec[0], vec[1]))
n = len(sorted_vectors)
min_adjacent = math.pi
for i in range(n):
j = (i + 1) % n
u = sorted_vectors[i][0], sorted_vectors[i][1]
v = sorted_vectors[j][0], sorted_vectors[j][1]
theta = compute_non_oriented_angle(u, v)
if theta < min_adjacent:
min_adjacent = theta
angles = []
for vec in sorted_vectors:
x, y, idx = vec
angles.append( compute_angle(x, y) )
min_opposite = math.pi
for i in range(n):
theta_i = angles[i]
target = (theta_i + math.pi) % (2 * math.pi)
low = 0
high = n
while low < high:
mid = (low + high) // 2
if angles[mid] < target:
low = mid + 1
else:
high = mid
candidates = []
if low > 0:
candidates.append(low-1)
if low < n:
candidates.append(low)
candidates.append((low - 1) % n)
candidates = list(set(candidates))
for c in candidates:
if c == i:
continue
c = c % n
vec_c = sorted_vectors[c]
u = sorted_vectors[i][0], sorted_vectors[i][1]
v = vec_c[0], vec_c[1]
current_theta = compute_non_oriented_angle(u, v)
if current_theta < min_opposite:
min_opposite = current_theta
return min(min_adjacent, min_opposite)
def main(input_path, output_path, submission_output_path):
input_vectors = read_vectors(input_path)
with open(submission_output_path) as f:
line = f.readline().strip()
try:
a, b = map(int, line.split())
except:
print(0)
return
n = len(input_vectors)
if a < 1 or a > n or b < 1 or b > n or a == b:
print(0)
return
vec_a = None
vec_b = None
for vec in input_vectors:
if vec[2] == a:
vec_a = vec
if vec[2] == b:
vec_b = vec
if vec_a is None or vec_b is None:
print(0)
return
u = (vec_a[0], vec_a[1])
v = (vec_b[0], vec_b[1])
theta = compute_non_oriented_angle(u, v)
min_angle = find_min_angle(input_vectors)
epsilon = 1e-9
if abs(theta - min_angle) <= epsilon:
print(1)
else:
print(0)
if __name__ == "__main__":
input_path = sys.argv[1]
output_path = sys.argv[2]
submission_output_path = sys.argv[3]
main(input_path, output_path, submission_output_path)
| true |
598/C
|
598
|
C
|
Python 3
|
TESTS
| 117 | 483 | 9,932,800 |
111295171
|
"""
You are given the set of vectors on the plane, each of them starting at the origin. Your task is to find a pair of vectors with the minimal non-oriented angle between them.
Non-oriented angle is non-negative value, minimal between clockwise and counterclockwise direction angles. Non-oriented angle is always between 0 and π. For example, opposite directions vectors have angle equals to π.
Approach:
Convert all vectors to a radian value
Sort the vectors by radians
Return pair with minimum difference
"""
from math import pi, atan2
n = int(input())
res = list()
for ii in range(n):
vec = [int(x) for x in input().split()]
res.append([ii+1, atan2(*vec)])
res.sort(key=lambda x: x[1])
v = 7
for i in range(n):
x = abs(res[i][1]-res[(i+1) % n][1])
if min(x, 2*pi-x) < v:
best = [res[i][0], res[(i+1) % n][0]]
v = min(x, 2*pi-x)
print("{} {}".format(*best))
| 163 | 1,185 | 29,696,000 |
197816661
|
from functools import cmp_to_key
def is_top(vector):
return vector[1] > 0 or vector[1] == 0 and vector[0] > 0
def cross(first, second):
return first[0] * second[1] - second[0] * first[1]
def dot(first, second):
return first[0]*second[0] + first[1]*second[1]
def polar_cmp(first, second):
if is_top(first) != is_top(second):
return -is_top(first) + is_top(second)
return -cross(first, second)
def angle_less(a1, b1, a2, b2):
first = (dot(a1, b1), abs(cross(a1, b1)))
second = (dot(a2, b2), abs(cross(a2, b2)))
return polar_cmp(first, second) < 0
def main():
vectors = []
n = int(input())
for j in range(n):
vectors.append(tuple((int(i) for i in input().split())) + (j + 1, ))
vectors.sort(key=cmp_to_key(polar_cmp))
best_first = vectors[-1]
best_second = vectors[0]
for i in range(n-1):
if angle_less(vectors[i], vectors[i+1], best_first, best_second):
best_first = vectors[i]
best_second = vectors[i+1]
print(best_first[-1], best_second[-1])
if __name__ == '__main__':
main()
|
Educational Codeforces Round 1
|
ICPC
| 2,015 | 2 | 256 |
Nearest vectors
|
You are given the set of vectors on the plane, each of them starting at the origin. Your task is to find a pair of vectors with the minimal non-oriented angle between them.
Non-oriented angle is non-negative value, minimal between clockwise and counterclockwise direction angles. Non-oriented angle is always between 0 and π. For example, opposite directions vectors have angle equals to π.
|
First line of the input contains a single integer n (2 ≤ n ≤ 100 000) — the number of vectors.
The i-th of the following n lines contains two integers xi and yi (|x|, |y| ≤ 10 000, x2 + y2 > 0) — the coordinates of the i-th vector. Vectors are numbered from 1 to n in order of appearing in the input. It is guaranteed that no two vectors in the input share the same direction (but they still can have opposite directions).
|
Print two integer numbers a and b (a ≠ b) — a pair of indices of vectors with the minimal non-oriented angle. You can print the numbers in any order. If there are many possible answers, print any.
| null | null |
[{"input": "4\n-1 0\n0 -1\n1 0\n1 1", "output": "3 4"}, {"input": "6\n-1 0\n0 -1\n1 0\n1 1\n-4 -5\n-4 -6", "output": "6 5"}]
| 2,300 |
["geometry", "sortings"]
| 163 |
[{"input": "4\r\n-1 0\r\n0 -1\r\n1 0\r\n1 1\r\n", "output": "3 4\r\n"}, {"input": "6\r\n-1 0\r\n0 -1\r\n1 0\r\n1 1\r\n-4 -5\r\n-4 -6\r\n", "output": "5 6\r\n"}, {"input": "10\r\n8 6\r\n-7 -3\r\n9 8\r\n7 10\r\n-3 -8\r\n3 7\r\n6 -8\r\n-9 8\r\n9 2\r\n6 7\r\n", "output": "1 3\r\n"}, {"input": "20\r\n-9 8\r\n-7 3\r\n0 10\r\n3 7\r\n6 -9\r\n6 8\r\n7 -6\r\n-6 10\r\n-10 3\r\n-8 -10\r\n10 -2\r\n1 -8\r\n-8 10\r\n10 10\r\n10 6\r\n-5 6\r\n5 -8\r\n5 -9\r\n-9 -1\r\n9 2\r\n", "output": "13 16\r\n"}, {"input": "2\r\n351 -4175\r\n-328 -657\r\n", "output": "2 1\r\n"}, {"input": "3\r\n620 -1189\r\n8101 -2770\r\n3347 3473\r\n", "output": "1 2\r\n"}, {"input": "4\r\n-7061 -5800\r\n-3471 -9470\r\n-7639 2529\r\n5657 -6522\r\n", "output": "1 2\r\n"}, {"input": "5\r\n-7519 -3395\r\n-32 -257\r\n-4827 -1889\r\n9545 -7037\r\n2767 583\r\n", "output": "3 1\r\n"}, {"input": "6\r\n-5120 -3251\r\n8269 -7984\r\n841 3396\r\n3136 -7551\r\n-1280 -3013\r\n-3263 -3278\r\n", "output": "1 6\r\n"}, {"input": "7\r\n-2722 6597\r\n-3303 200\r\n6508 -1021\r\n-1107 -1042\r\n6875 7616\r\n-3047 6749\r\n662 -1979\r\n", "output": "1 6\r\n"}, {"input": "8\r\n-36 749\r\n5126 943\r\n1165 533\r\n-1647 -5725\r\n5031 6532\r\n5956 8447\r\n2297 -2284\r\n1986 6937\r\n", "output": "5 6\r\n"}, {"input": "9\r\n-391 -1706\r\n995 -5756\r\n-5013 -154\r\n1121 3160\r\n-7111 8303\r\n-7303 -2414\r\n-7791 -935\r\n7576 -9361\r\n1072 203\r\n", "output": "3 7\r\n"}, {"input": "10\r\n-9920 -5477\r\n9691 -3200\r\n754 885\r\n-1895 1768\r\n-941 1588\r\n6293 -2631\r\n-2288 9129\r\n4067 696\r\n-6754 9869\r\n-5747 701\r\n", "output": "5 9\r\n"}, {"input": "2\r\n1 0\r\n-1 0\r\n", "output": "1 2\r\n"}, {"input": "2\r\n0 1\r\n0 -1\r\n", "output": "1 2\r\n"}, {"input": "2\r\n2131 -3249\r\n-2131 3249\r\n", "output": "2 1\r\n"}, {"input": "3\r\n-5 1\r\n-5 -1\r\n5 0\r\n", "output": "1 2\r\n"}, {"input": "3\r\n-100 1\r\n-100 -1\r\n0 100\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 10\r\n10 1\r\n10 -1\r\n", "output": "3 2\r\n"}, {"input": "3\r\n3 0\r\n0 3\r\n1 -3\r\n", "output": "3 1\r\n"}, {"input": "3\r\n1 1\r\n-1 0\r\n1 -1\r\n", "output": "3 1\r\n"}, {"input": "3\r\n-1 0\r\n10 -1\r\n1 0\r\n", "output": "2 3\r\n"}, {"input": "4\r\n1 10\r\n10 1\r\n-2 -2\r\n10 -1\r\n", "output": "4 2\r\n"}, {"input": "3\r\n-6 0\r\n6 1\r\n6 -1\r\n", "output": "3 2\r\n"}, {"input": "3\r\n114 1\r\n-514 0\r\n114 -1\r\n", "output": "3 1\r\n"}, {"input": "4\r\n-1 0\r\n0 -1\r\n-1 1\r\n1 0\r\n", "output": "3 1\r\n"}, {"input": "4\r\n2 1\r\n2 -1\r\n-1 1\r\n-1 -1\r\n", "output": "2 1\r\n"}, {"input": "3\r\n3 1\r\n3 -1\r\n0 3\r\n", "output": "2 1\r\n"}, {"input": "3\r\n1 1\r\n9000 1\r\n9000 -1\r\n", "output": "3 2\r\n"}, {"input": "3\r\n1 0\r\n-1 1\r\n-1 -1\r\n", "output": "2 3\r\n"}, {"input": "6\r\n1 1\r\n-1 -1\r\n0 20\r\n100 1\r\n-100 0\r\n100 -1\r\n", "output": "6 4\r\n"}, {"input": "4\r\n1 0\r\n0 1\r\n-1 0\r\n-13 -1\r\n", "output": "3 4\r\n"}, {"input": "3\r\n1 0\r\n-1 0\r\n1 -1\r\n", "output": "3 1\r\n"}, {"input": "3\r\n100 1\r\n-100 0\r\n100 -1\r\n", "output": "3 1\r\n"}, {"input": "3\r\n-100 1\r\n100 0\r\n-100 -1\r\n", "output": "1 3\r\n"}, {"input": "3\r\n1 100\r\n0 -100\r\n-1 100\r\n", "output": "1 3\r\n"}, {"input": "11\r\n-7945 386\r\n7504 -576\r\n-6020 -8277\r\n930 9737\r\n1682 474\r\n-8279 1197\r\n2790 2607\r\n-5514 -9601\r\n-3159 5939\r\n-1806 4207\r\n-9073 -2138\r\n", "output": "10 9\r\n"}, {"input": "3\r\n1 0\r\n10000 -1\r\n1 1\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-7125 -1643\r\n-1235 4071\r\n-75 -8717\r\n2553 9278\r\n", "output": "4 2\r\n"}, {"input": "5\r\n-6 0\r\n6 1\r\n6 -1\r\n0 6\r\n0 -6\r\n", "output": "3 2\r\n"}, {"input": "4\r\n5 5\r\n5 -5\r\n-555 1\r\n-555 -1\r\n", "output": "3 4\r\n"}, {"input": "4\r\n1 1\r\n-1 1\r\n-1 -1\r\n2 -1\r\n", "output": "4 1\r\n"}, {"input": "4\r\n-1 -100\r\n1 -100\r\n-100 -100\r\n100 -100\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 0\r\n1 -1\r\n-4 -6\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-1 -100\r\n1 -100\r\n100 -100\r\n-100 -100\r\n", "output": "1 2\r\n"}, {"input": "4\r\n-1 0\r\n0 -2\r\n-3 3\r\n4 0\r\n", "output": "3 1\r\n"}, {"input": "4\r\n-2 0\r\n0 -3\r\n-5 5\r\n4 0\r\n", "output": "3 1\r\n"}, {"input": "3\r\n1 -100\r\n0 100\r\n-1 -100\r\n", "output": "3 1\r\n"}, {"input": "5\r\n10000 2\r\n10000 -1\r\n10000 -5\r\n10000 -9\r\n10000 -13\r\n", "output": "2 1\r\n"}, {"input": "8\r\n-9580 8545\r\n-9379 -1139\r\n5824 -391\r\n-8722 2765\r\n-1357 -5547\r\n-7700 217\r\n9323 -7008\r\n957 -8356\r\n", "output": "6 2\r\n"}, {"input": "4\r\n5 5\r\n5 -5\r\n-500 1\r\n-500 -1\r\n", "output": "3 4\r\n"}, {"input": "3\r\n30 1\r\n30 -1\r\n0 30\r\n", "output": "2 1\r\n"}, {"input": "4\r\n3966 -1107\r\n8007 -5457\r\n-7753 4945\r\n-2209 -4221\r\n", "output": "2 1\r\n"}, {"input": "4\r\n1 9999\r\n0 1\r\n10000 0\r\n10000 -1\r\n", "output": "4 3\r\n"}, {"input": "3\r\n10000 1\r\n10000 -1\r\n-10000 0\r\n", "output": "2 1\r\n"}, {"input": "13\r\n1 2\r\n2 3\r\n3 4\r\n4 5\r\n5 6\r\n6 7\r\n7 8\r\n8 9\r\n9 10\r\n10 11\r\n11 12\r\n13 14\r\n12 13\r\n", "output": "12 13\r\n"}, {"input": "4\r\n2 1\r\n2 -1\r\n0 1\r\n-1 0\r\n", "output": "2 1\r\n"}, {"input": "4\r\n10 3\r\n10 -3\r\n-500 1\r\n-500 -1\r\n", "output": "3 4\r\n"}, {"input": "4\r\n1 10000\r\n-1 1\r\n10000 0\r\n10000 -1\r\n", "output": "4 3\r\n"}, {"input": "3\r\n0 1\r\n1 0\r\n1 -1\r\n", "output": "3 2\r\n"}, {"input": "3\r\n1 0\r\n0 1\r\n1 -1\r\n", "output": "3 1\r\n"}, {"input": "4\r\n1 1\r\n-1 1\r\n1 -2\r\n-1 -2\r\n", "output": "4 3\r\n"}, {"input": "4\r\n0 -1\r\n-1 0\r\n-1 1\r\n1 0\r\n", "output": "3 2\r\n"}, {"input": "3\r\n-100 1\r\n-100 -1\r\n1 1\r\n", "output": "1 2\r\n"}, {"input": "3\r\n-3 1\r\n-3 -1\r\n2 -3\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 -1\r\n1 0\r\n0 1\r\n", "output": "1 2\r\n"}, {"input": "5\r\n-5 1\r\n0 5\r\n4 1\r\n0 -4\r\n-5 -1\r\n", "output": "1 5\r\n"}, {"input": "4\r\n1 10000\r\n0 1\r\n10000 0\r\n9999 -1\r\n", "output": "1 2\r\n"}, {"input": "4\r\n2 3\r\n2 -3\r\n-3 2\r\n-3 -2\r\n", "output": "3 4\r\n"}, {"input": "3\r\n1 -3\r\n1 0\r\n0 1\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 0\r\n-1 0\r\n-1 -1\r\n", "output": "2 3\r\n"}, {"input": "4\r\n-2 1\r\n-2 -1\r\n1 1\r\n1 -1\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 -1\r\n-1 1\r\n-1 -2\r\n", "output": "3 1\r\n"}, {"input": "3\r\n1 0\r\n-1 -1\r\n1 -1\r\n", "output": "3 1\r\n"}, {"input": "3\r\n5 5\r\n-5 0\r\n5 -5\r\n", "output": "3 1\r\n"}, {"input": "4\r\n1 -2\r\n1 0\r\n-1 0\r\n10 -1\r\n", "output": "4 2\r\n"}, {"input": "3\r\n-1000 1\r\n-1000 -1\r\n1000 0\r\n", "output": "1 2\r\n"}, {"input": "6\r\n1 1\r\n1 -1\r\n-1 1\r\n-1 -1\r\n1 -10000\r\n-1 -10000\r\n", "output": "6 5\r\n"}, {"input": "3\r\n1 1\r\n-1 0\r\n0 -1\r\n", "output": "2 3\r\n"}, {"input": "4\r\n5000 1\r\n5000 -1\r\n-2 -1\r\n2 -1\r\n", "output": "2 1\r\n"}, {"input": "3\r\n1 0\r\n-1 1\r\n-1 -5\r\n", "output": "3 1\r\n"}, {"input": "3\r\n-5374 1323\r\n-4463 -8462\r\n6118 -7918\r\n", "output": "2 3\r\n"}, {"input": "4\r\n-6427 -6285\r\n-5386 -5267\r\n-3898 7239\r\n-3905 7252\r\n", "output": "4 3\r\n"}, {"input": "10\r\n-7 -3\r\n-2 8\r\n9 -9\r\n0 1\r\n4 5\r\n5 3\r\n-3 0\r\n10 2\r\n4 -1\r\n2 -10\r\n", "output": "4 2\r\n"}, {"input": "4\r\n9999 1\r\n9999 -1\r\n-9998 1\r\n-10000 -1\r\n", "output": "2 1\r\n"}, {"input": "4\r\n10000 9999\r\n9999 9998\r\n9998 9997\r\n9997 9996\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-6285 -6427\r\n-5267 -5386\r\n7239 -3898\r\n7252 -3905\r\n", "output": "3 4\r\n"}, {"input": "4\r\n-6427 6285\r\n-5386 5267\r\n3898 -7239\r\n3905 -7252\r\n", "output": "4 3\r\n"}, {"input": "4\r\n-6427 -6285\r\n-5386 -5267\r\n-3898 -7239\r\n-3905 -7252\r\n", "output": "3 4\r\n"}, {"input": "3\r\n0 1\r\n-1 -1\r\n1 -1\r\n", "output": "2 3\r\n"}, {"input": "4\r\n10000 1\r\n9998 -1\r\n-9999 1\r\n-9999 -1\r\n", "output": "3 4\r\n"}, {"input": "3\r\n100 0\r\n100 2\r\n100 -1\r\n", "output": "3 1\r\n"}, {"input": "3\r\n-1 1\r\n-1 -1\r\n1 0\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9844 9986\r\n181 9967\r\n-9812 -9925\r\n-194 -9900\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9800 9981\r\n61 9899\r\n-9926 -9932\r\n-149 -9926\r\n", "output": "3 4\r\n"}, {"input": "4\r\n-9901 9900\r\n-10000 9899\r\n9899 9801\r\n9899 9900\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9934 9989\r\n199 9949\r\n-9917 -9974\r\n-197 -9901\r\n", "output": "3 4\r\n"}, {"input": "3\r\n-1 1\r\n1 0\r\n-1 -1\r\n", "output": "1 3\r\n"}, {"input": "3\r\n1 1\r\n-10 -10\r\n-10 -9\r\n", "output": "3 2\r\n"}, {"input": "3\r\n1 0\r\n10000 -1\r\n-1 0\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9999 1\r\n9999 -1\r\n-10000 1\r\n-10000 -1\r\n", "output": "3 4\r\n"}, {"input": "3\r\n-5 1\r\n-5 -1\r\n1 0\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 0\r\n10000 1\r\n-1 0\r\n", "output": "1 2\r\n"}, {"input": "4\r\n-9990 9995\r\n9994 -9991\r\n-9999 -9992\r\n9993 9992\r\n", "output": "2 4\r\n"}, {"input": "8\r\n1 0\r\n1 1\r\n0 1\r\n-1 1\r\n-1 0\r\n-1 -1\r\n0 -1\r\n1 -2\r\n", "output": "7 8\r\n"}, {"input": "3\r\n-9930 9932\r\n9909 -9909\r\n-9932 -9931\r\n", "output": "3 2\r\n"}, {"input": "4\r\n9876 9977\r\n127 9938\r\n-9820 -9934\r\n-120 -9921\r\n", "output": "3 4\r\n"}, {"input": "3\r\n10000 -1\r\n-1 0\r\n0 -1\r\n", "output": "3 1\r\n"}, {"input": "4\r\n6427 -6285\r\n5386 -5267\r\n3898 7239\r\n3905 7252\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9811 9970\r\n155 9994\r\n-9826 -9977\r\n-159 -9986\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9851 9917\r\n74 9921\r\n-9855 -9916\r\n-77 -9984\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9826 9977\r\n159 9986\r\n-9811 -9970\r\n-155 -9994\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9849 9986\r\n148 9980\r\n-9800 -9999\r\n-116 -9927\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9822 9967\r\n111 9905\r\n-9943 -9986\r\n-163 -9953\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9959 9995\r\n113 9940\r\n-9965 -9931\r\n-148 -9945\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9851 9972\r\n153 9983\r\n-9866 -9926\r\n-183 -9946\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9816 -9979\r\n127 -9940\r\n-9876 9915\r\n-190 9978\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9887 -9917\r\n138 -9977\r\n-9826 9995\r\n-68 9971\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9936 -9965\r\n135 -9949\r\n-9928 9980\r\n-123 9908\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9981 -9985\r\n191 -9956\r\n-9893 9937\r\n-171 9962\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-9811 9970\r\n-155 9994\r\n9826 -9977\r\n159 -9986\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9808 9899\r\n179 9966\r\n-9870 -9961\r\n-179 -9950\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9815 -9936\r\n168 -9937\r\n-9896 9995\r\n-180 9969\r\n", "output": "2 1\r\n"}, {"input": "4\r\n1 1\r\n1 -1\r\n-100 1\r\n-100 -1\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9965 114\r\n87 9916\r\n-9957 -106\r\n-95 -9929\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9895 -9949\r\n188 -9978\r\n-9810 9935\r\n-151 9914\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-9957 106\r\n-95 9929\r\n9965 -114\r\n87 -9916\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-9862 9980\r\n-174 9917\r\n9845 -9967\r\n173 -9980\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9944 9926\r\n9927 9935\r\n-9961 -9929\r\n-9997 -9991\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9917 9909\r\n196 9925\r\n-9971 -9991\r\n-183 -9977\r\n", "output": "3 4\r\n"}]
| false |
stdio
|
import sys
import math
def read_vectors(input_path):
with open(input_path) as f:
n = int(f.readline())
vectors = []
for i in range(n):
x, y = map(int, f.readline().split())
vectors.append( (x, y, i+1) )
return vectors
def compute_angle(x, y):
return math.atan2(y, x) % (2 * math.pi)
def compute_non_oriented_angle(u, v):
ux, uy = u
vx, vy = v
dot = ux * vx + uy * vy
mag_u = math.hypot(ux, uy)
mag_v = math.hypot(vx, vy)
if mag_u == 0 or mag_v == 0:
return 0.0
cos_theta = dot / (mag_u * mag_v)
cos_theta = max(min(cos_theta, 1.0), -1.0)
return math.acos(cos_theta)
def find_min_angle(vectors):
sorted_vectors = sorted(vectors, key=lambda vec: compute_angle(vec[0], vec[1]))
n = len(sorted_vectors)
min_adjacent = math.pi
for i in range(n):
j = (i + 1) % n
u = sorted_vectors[i][0], sorted_vectors[i][1]
v = sorted_vectors[j][0], sorted_vectors[j][1]
theta = compute_non_oriented_angle(u, v)
if theta < min_adjacent:
min_adjacent = theta
angles = []
for vec in sorted_vectors:
x, y, idx = vec
angles.append( compute_angle(x, y) )
min_opposite = math.pi
for i in range(n):
theta_i = angles[i]
target = (theta_i + math.pi) % (2 * math.pi)
low = 0
high = n
while low < high:
mid = (low + high) // 2
if angles[mid] < target:
low = mid + 1
else:
high = mid
candidates = []
if low > 0:
candidates.append(low-1)
if low < n:
candidates.append(low)
candidates.append((low - 1) % n)
candidates = list(set(candidates))
for c in candidates:
if c == i:
continue
c = c % n
vec_c = sorted_vectors[c]
u = sorted_vectors[i][0], sorted_vectors[i][1]
v = vec_c[0], vec_c[1]
current_theta = compute_non_oriented_angle(u, v)
if current_theta < min_opposite:
min_opposite = current_theta
return min(min_adjacent, min_opposite)
def main(input_path, output_path, submission_output_path):
input_vectors = read_vectors(input_path)
with open(submission_output_path) as f:
line = f.readline().strip()
try:
a, b = map(int, line.split())
except:
print(0)
return
n = len(input_vectors)
if a < 1 or a > n or b < 1 or b > n or a == b:
print(0)
return
vec_a = None
vec_b = None
for vec in input_vectors:
if vec[2] == a:
vec_a = vec
if vec[2] == b:
vec_b = vec
if vec_a is None or vec_b is None:
print(0)
return
u = (vec_a[0], vec_a[1])
v = (vec_b[0], vec_b[1])
theta = compute_non_oriented_angle(u, v)
min_angle = find_min_angle(input_vectors)
epsilon = 1e-9
if abs(theta - min_angle) <= epsilon:
print(1)
else:
print(0)
if __name__ == "__main__":
input_path = sys.argv[1]
output_path = sys.argv[2]
submission_output_path = sys.argv[3]
main(input_path, output_path, submission_output_path)
| true |
598/C
|
598
|
C
|
Python 3
|
TESTS
| 117 | 764 | 14,540,800 |
118716539
|
import math
class vector:
def __init__(self, X, Y, P) -> None:
self.v = math.atan2(X, Y)
self.p = P
def work(v) -> float:
while v < 0:
v += math.pi * 2
while v > math.pi * 2:
v -= math.pi * 2
return min(v, math.pi * 2 - v)
n = int(input())
a = list()
for i in range(0, n):
s = input().split()
a.append(vector(int(s[0]), int(s[1]), i + 1))
a.sort(key=lambda x: x.v)
ans = 0
for i in range(0, n):
if work(a[i].v - a[(i + 1) % n].v) < work(a[ans].v - a[(ans + 1) % n].v):
ans = i
print(a[ans].p, a[(ans + 1) % n].p)
| 163 | 1,201 | 23,347,200 |
112976028
|
from math import atan2
inner = lambda a, b: a[0] * b[0] + a[1] * b[1]
outer = lambda a, b: a[0] * b[1] - a[1] * b[0]
vectors = []
for i in range(int(input())):
x, y = map(int, input().split())
vectors.append((atan2(y, x), (x, y), i + 1))
vectors.sort()
diff = [(inner(vec1, vec2), abs(outer(vec1, vec2)), i, j) for (angle1, vec1, i), (angle2, vec2, j) in zip(vectors, vectors[1:] + vectors[:1])]
min_diff = diff[0]
for d in diff:
if outer(d[:2], min_diff[:2]) > 0: min_diff = d
print(min_diff[2], min_diff[3])
|
Educational Codeforces Round 1
|
ICPC
| 2,015 | 2 | 256 |
Nearest vectors
|
You are given the set of vectors on the plane, each of them starting at the origin. Your task is to find a pair of vectors with the minimal non-oriented angle between them.
Non-oriented angle is non-negative value, minimal between clockwise and counterclockwise direction angles. Non-oriented angle is always between 0 and π. For example, opposite directions vectors have angle equals to π.
|
First line of the input contains a single integer n (2 ≤ n ≤ 100 000) — the number of vectors.
The i-th of the following n lines contains two integers xi and yi (|x|, |y| ≤ 10 000, x2 + y2 > 0) — the coordinates of the i-th vector. Vectors are numbered from 1 to n in order of appearing in the input. It is guaranteed that no two vectors in the input share the same direction (but they still can have opposite directions).
|
Print two integer numbers a and b (a ≠ b) — a pair of indices of vectors with the minimal non-oriented angle. You can print the numbers in any order. If there are many possible answers, print any.
| null | null |
[{"input": "4\n-1 0\n0 -1\n1 0\n1 1", "output": "3 4"}, {"input": "6\n-1 0\n0 -1\n1 0\n1 1\n-4 -5\n-4 -6", "output": "6 5"}]
| 2,300 |
["geometry", "sortings"]
| 163 |
[{"input": "4\r\n-1 0\r\n0 -1\r\n1 0\r\n1 1\r\n", "output": "3 4\r\n"}, {"input": "6\r\n-1 0\r\n0 -1\r\n1 0\r\n1 1\r\n-4 -5\r\n-4 -6\r\n", "output": "5 6\r\n"}, {"input": "10\r\n8 6\r\n-7 -3\r\n9 8\r\n7 10\r\n-3 -8\r\n3 7\r\n6 -8\r\n-9 8\r\n9 2\r\n6 7\r\n", "output": "1 3\r\n"}, {"input": "20\r\n-9 8\r\n-7 3\r\n0 10\r\n3 7\r\n6 -9\r\n6 8\r\n7 -6\r\n-6 10\r\n-10 3\r\n-8 -10\r\n10 -2\r\n1 -8\r\n-8 10\r\n10 10\r\n10 6\r\n-5 6\r\n5 -8\r\n5 -9\r\n-9 -1\r\n9 2\r\n", "output": "13 16\r\n"}, {"input": "2\r\n351 -4175\r\n-328 -657\r\n", "output": "2 1\r\n"}, {"input": "3\r\n620 -1189\r\n8101 -2770\r\n3347 3473\r\n", "output": "1 2\r\n"}, {"input": "4\r\n-7061 -5800\r\n-3471 -9470\r\n-7639 2529\r\n5657 -6522\r\n", "output": "1 2\r\n"}, {"input": "5\r\n-7519 -3395\r\n-32 -257\r\n-4827 -1889\r\n9545 -7037\r\n2767 583\r\n", "output": "3 1\r\n"}, {"input": "6\r\n-5120 -3251\r\n8269 -7984\r\n841 3396\r\n3136 -7551\r\n-1280 -3013\r\n-3263 -3278\r\n", "output": "1 6\r\n"}, {"input": "7\r\n-2722 6597\r\n-3303 200\r\n6508 -1021\r\n-1107 -1042\r\n6875 7616\r\n-3047 6749\r\n662 -1979\r\n", "output": "1 6\r\n"}, {"input": "8\r\n-36 749\r\n5126 943\r\n1165 533\r\n-1647 -5725\r\n5031 6532\r\n5956 8447\r\n2297 -2284\r\n1986 6937\r\n", "output": "5 6\r\n"}, {"input": "9\r\n-391 -1706\r\n995 -5756\r\n-5013 -154\r\n1121 3160\r\n-7111 8303\r\n-7303 -2414\r\n-7791 -935\r\n7576 -9361\r\n1072 203\r\n", "output": "3 7\r\n"}, {"input": "10\r\n-9920 -5477\r\n9691 -3200\r\n754 885\r\n-1895 1768\r\n-941 1588\r\n6293 -2631\r\n-2288 9129\r\n4067 696\r\n-6754 9869\r\n-5747 701\r\n", "output": "5 9\r\n"}, {"input": "2\r\n1 0\r\n-1 0\r\n", "output": "1 2\r\n"}, {"input": "2\r\n0 1\r\n0 -1\r\n", "output": "1 2\r\n"}, {"input": "2\r\n2131 -3249\r\n-2131 3249\r\n", "output": "2 1\r\n"}, {"input": "3\r\n-5 1\r\n-5 -1\r\n5 0\r\n", "output": "1 2\r\n"}, {"input": "3\r\n-100 1\r\n-100 -1\r\n0 100\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 10\r\n10 1\r\n10 -1\r\n", "output": "3 2\r\n"}, {"input": "3\r\n3 0\r\n0 3\r\n1 -3\r\n", "output": "3 1\r\n"}, {"input": "3\r\n1 1\r\n-1 0\r\n1 -1\r\n", "output": "3 1\r\n"}, {"input": "3\r\n-1 0\r\n10 -1\r\n1 0\r\n", "output": "2 3\r\n"}, {"input": "4\r\n1 10\r\n10 1\r\n-2 -2\r\n10 -1\r\n", "output": "4 2\r\n"}, {"input": "3\r\n-6 0\r\n6 1\r\n6 -1\r\n", "output": "3 2\r\n"}, {"input": "3\r\n114 1\r\n-514 0\r\n114 -1\r\n", "output": "3 1\r\n"}, {"input": "4\r\n-1 0\r\n0 -1\r\n-1 1\r\n1 0\r\n", "output": "3 1\r\n"}, {"input": "4\r\n2 1\r\n2 -1\r\n-1 1\r\n-1 -1\r\n", "output": "2 1\r\n"}, {"input": "3\r\n3 1\r\n3 -1\r\n0 3\r\n", "output": "2 1\r\n"}, {"input": "3\r\n1 1\r\n9000 1\r\n9000 -1\r\n", "output": "3 2\r\n"}, {"input": "3\r\n1 0\r\n-1 1\r\n-1 -1\r\n", "output": "2 3\r\n"}, {"input": "6\r\n1 1\r\n-1 -1\r\n0 20\r\n100 1\r\n-100 0\r\n100 -1\r\n", "output": "6 4\r\n"}, {"input": "4\r\n1 0\r\n0 1\r\n-1 0\r\n-13 -1\r\n", "output": "3 4\r\n"}, {"input": "3\r\n1 0\r\n-1 0\r\n1 -1\r\n", "output": "3 1\r\n"}, {"input": "3\r\n100 1\r\n-100 0\r\n100 -1\r\n", "output": "3 1\r\n"}, {"input": "3\r\n-100 1\r\n100 0\r\n-100 -1\r\n", "output": "1 3\r\n"}, {"input": "3\r\n1 100\r\n0 -100\r\n-1 100\r\n", "output": "1 3\r\n"}, {"input": "11\r\n-7945 386\r\n7504 -576\r\n-6020 -8277\r\n930 9737\r\n1682 474\r\n-8279 1197\r\n2790 2607\r\n-5514 -9601\r\n-3159 5939\r\n-1806 4207\r\n-9073 -2138\r\n", "output": "10 9\r\n"}, {"input": "3\r\n1 0\r\n10000 -1\r\n1 1\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-7125 -1643\r\n-1235 4071\r\n-75 -8717\r\n2553 9278\r\n", "output": "4 2\r\n"}, {"input": "5\r\n-6 0\r\n6 1\r\n6 -1\r\n0 6\r\n0 -6\r\n", "output": "3 2\r\n"}, {"input": "4\r\n5 5\r\n5 -5\r\n-555 1\r\n-555 -1\r\n", "output": "3 4\r\n"}, {"input": "4\r\n1 1\r\n-1 1\r\n-1 -1\r\n2 -1\r\n", "output": "4 1\r\n"}, {"input": "4\r\n-1 -100\r\n1 -100\r\n-100 -100\r\n100 -100\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 0\r\n1 -1\r\n-4 -6\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-1 -100\r\n1 -100\r\n100 -100\r\n-100 -100\r\n", "output": "1 2\r\n"}, {"input": "4\r\n-1 0\r\n0 -2\r\n-3 3\r\n4 0\r\n", "output": "3 1\r\n"}, {"input": "4\r\n-2 0\r\n0 -3\r\n-5 5\r\n4 0\r\n", "output": "3 1\r\n"}, {"input": "3\r\n1 -100\r\n0 100\r\n-1 -100\r\n", "output": "3 1\r\n"}, {"input": "5\r\n10000 2\r\n10000 -1\r\n10000 -5\r\n10000 -9\r\n10000 -13\r\n", "output": "2 1\r\n"}, {"input": "8\r\n-9580 8545\r\n-9379 -1139\r\n5824 -391\r\n-8722 2765\r\n-1357 -5547\r\n-7700 217\r\n9323 -7008\r\n957 -8356\r\n", "output": "6 2\r\n"}, {"input": "4\r\n5 5\r\n5 -5\r\n-500 1\r\n-500 -1\r\n", "output": "3 4\r\n"}, {"input": "3\r\n30 1\r\n30 -1\r\n0 30\r\n", "output": "2 1\r\n"}, {"input": "4\r\n3966 -1107\r\n8007 -5457\r\n-7753 4945\r\n-2209 -4221\r\n", "output": "2 1\r\n"}, {"input": "4\r\n1 9999\r\n0 1\r\n10000 0\r\n10000 -1\r\n", "output": "4 3\r\n"}, {"input": "3\r\n10000 1\r\n10000 -1\r\n-10000 0\r\n", "output": "2 1\r\n"}, {"input": "13\r\n1 2\r\n2 3\r\n3 4\r\n4 5\r\n5 6\r\n6 7\r\n7 8\r\n8 9\r\n9 10\r\n10 11\r\n11 12\r\n13 14\r\n12 13\r\n", "output": "12 13\r\n"}, {"input": "4\r\n2 1\r\n2 -1\r\n0 1\r\n-1 0\r\n", "output": "2 1\r\n"}, {"input": "4\r\n10 3\r\n10 -3\r\n-500 1\r\n-500 -1\r\n", "output": "3 4\r\n"}, {"input": "4\r\n1 10000\r\n-1 1\r\n10000 0\r\n10000 -1\r\n", "output": "4 3\r\n"}, {"input": "3\r\n0 1\r\n1 0\r\n1 -1\r\n", "output": "3 2\r\n"}, {"input": "3\r\n1 0\r\n0 1\r\n1 -1\r\n", "output": "3 1\r\n"}, {"input": "4\r\n1 1\r\n-1 1\r\n1 -2\r\n-1 -2\r\n", "output": "4 3\r\n"}, {"input": "4\r\n0 -1\r\n-1 0\r\n-1 1\r\n1 0\r\n", "output": "3 2\r\n"}, {"input": "3\r\n-100 1\r\n-100 -1\r\n1 1\r\n", "output": "1 2\r\n"}, {"input": "3\r\n-3 1\r\n-3 -1\r\n2 -3\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 -1\r\n1 0\r\n0 1\r\n", "output": "1 2\r\n"}, {"input": "5\r\n-5 1\r\n0 5\r\n4 1\r\n0 -4\r\n-5 -1\r\n", "output": "1 5\r\n"}, {"input": "4\r\n1 10000\r\n0 1\r\n10000 0\r\n9999 -1\r\n", "output": "1 2\r\n"}, {"input": "4\r\n2 3\r\n2 -3\r\n-3 2\r\n-3 -2\r\n", "output": "3 4\r\n"}, {"input": "3\r\n1 -3\r\n1 0\r\n0 1\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 0\r\n-1 0\r\n-1 -1\r\n", "output": "2 3\r\n"}, {"input": "4\r\n-2 1\r\n-2 -1\r\n1 1\r\n1 -1\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 -1\r\n-1 1\r\n-1 -2\r\n", "output": "3 1\r\n"}, {"input": "3\r\n1 0\r\n-1 -1\r\n1 -1\r\n", "output": "3 1\r\n"}, {"input": "3\r\n5 5\r\n-5 0\r\n5 -5\r\n", "output": "3 1\r\n"}, {"input": "4\r\n1 -2\r\n1 0\r\n-1 0\r\n10 -1\r\n", "output": "4 2\r\n"}, {"input": "3\r\n-1000 1\r\n-1000 -1\r\n1000 0\r\n", "output": "1 2\r\n"}, {"input": "6\r\n1 1\r\n1 -1\r\n-1 1\r\n-1 -1\r\n1 -10000\r\n-1 -10000\r\n", "output": "6 5\r\n"}, {"input": "3\r\n1 1\r\n-1 0\r\n0 -1\r\n", "output": "2 3\r\n"}, {"input": "4\r\n5000 1\r\n5000 -1\r\n-2 -1\r\n2 -1\r\n", "output": "2 1\r\n"}, {"input": "3\r\n1 0\r\n-1 1\r\n-1 -5\r\n", "output": "3 1\r\n"}, {"input": "3\r\n-5374 1323\r\n-4463 -8462\r\n6118 -7918\r\n", "output": "2 3\r\n"}, {"input": "4\r\n-6427 -6285\r\n-5386 -5267\r\n-3898 7239\r\n-3905 7252\r\n", "output": "4 3\r\n"}, {"input": "10\r\n-7 -3\r\n-2 8\r\n9 -9\r\n0 1\r\n4 5\r\n5 3\r\n-3 0\r\n10 2\r\n4 -1\r\n2 -10\r\n", "output": "4 2\r\n"}, {"input": "4\r\n9999 1\r\n9999 -1\r\n-9998 1\r\n-10000 -1\r\n", "output": "2 1\r\n"}, {"input": "4\r\n10000 9999\r\n9999 9998\r\n9998 9997\r\n9997 9996\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-6285 -6427\r\n-5267 -5386\r\n7239 -3898\r\n7252 -3905\r\n", "output": "3 4\r\n"}, {"input": "4\r\n-6427 6285\r\n-5386 5267\r\n3898 -7239\r\n3905 -7252\r\n", "output": "4 3\r\n"}, {"input": "4\r\n-6427 -6285\r\n-5386 -5267\r\n-3898 -7239\r\n-3905 -7252\r\n", "output": "3 4\r\n"}, {"input": "3\r\n0 1\r\n-1 -1\r\n1 -1\r\n", "output": "2 3\r\n"}, {"input": "4\r\n10000 1\r\n9998 -1\r\n-9999 1\r\n-9999 -1\r\n", "output": "3 4\r\n"}, {"input": "3\r\n100 0\r\n100 2\r\n100 -1\r\n", "output": "3 1\r\n"}, {"input": "3\r\n-1 1\r\n-1 -1\r\n1 0\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9844 9986\r\n181 9967\r\n-9812 -9925\r\n-194 -9900\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9800 9981\r\n61 9899\r\n-9926 -9932\r\n-149 -9926\r\n", "output": "3 4\r\n"}, {"input": "4\r\n-9901 9900\r\n-10000 9899\r\n9899 9801\r\n9899 9900\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9934 9989\r\n199 9949\r\n-9917 -9974\r\n-197 -9901\r\n", "output": "3 4\r\n"}, {"input": "3\r\n-1 1\r\n1 0\r\n-1 -1\r\n", "output": "1 3\r\n"}, {"input": "3\r\n1 1\r\n-10 -10\r\n-10 -9\r\n", "output": "3 2\r\n"}, {"input": "3\r\n1 0\r\n10000 -1\r\n-1 0\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9999 1\r\n9999 -1\r\n-10000 1\r\n-10000 -1\r\n", "output": "3 4\r\n"}, {"input": "3\r\n-5 1\r\n-5 -1\r\n1 0\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 0\r\n10000 1\r\n-1 0\r\n", "output": "1 2\r\n"}, {"input": "4\r\n-9990 9995\r\n9994 -9991\r\n-9999 -9992\r\n9993 9992\r\n", "output": "2 4\r\n"}, {"input": "8\r\n1 0\r\n1 1\r\n0 1\r\n-1 1\r\n-1 0\r\n-1 -1\r\n0 -1\r\n1 -2\r\n", "output": "7 8\r\n"}, {"input": "3\r\n-9930 9932\r\n9909 -9909\r\n-9932 -9931\r\n", "output": "3 2\r\n"}, {"input": "4\r\n9876 9977\r\n127 9938\r\n-9820 -9934\r\n-120 -9921\r\n", "output": "3 4\r\n"}, {"input": "3\r\n10000 -1\r\n-1 0\r\n0 -1\r\n", "output": "3 1\r\n"}, {"input": "4\r\n6427 -6285\r\n5386 -5267\r\n3898 7239\r\n3905 7252\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9811 9970\r\n155 9994\r\n-9826 -9977\r\n-159 -9986\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9851 9917\r\n74 9921\r\n-9855 -9916\r\n-77 -9984\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9826 9977\r\n159 9986\r\n-9811 -9970\r\n-155 -9994\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9849 9986\r\n148 9980\r\n-9800 -9999\r\n-116 -9927\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9822 9967\r\n111 9905\r\n-9943 -9986\r\n-163 -9953\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9959 9995\r\n113 9940\r\n-9965 -9931\r\n-148 -9945\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9851 9972\r\n153 9983\r\n-9866 -9926\r\n-183 -9946\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9816 -9979\r\n127 -9940\r\n-9876 9915\r\n-190 9978\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9887 -9917\r\n138 -9977\r\n-9826 9995\r\n-68 9971\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9936 -9965\r\n135 -9949\r\n-9928 9980\r\n-123 9908\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9981 -9985\r\n191 -9956\r\n-9893 9937\r\n-171 9962\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-9811 9970\r\n-155 9994\r\n9826 -9977\r\n159 -9986\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9808 9899\r\n179 9966\r\n-9870 -9961\r\n-179 -9950\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9815 -9936\r\n168 -9937\r\n-9896 9995\r\n-180 9969\r\n", "output": "2 1\r\n"}, {"input": "4\r\n1 1\r\n1 -1\r\n-100 1\r\n-100 -1\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9965 114\r\n87 9916\r\n-9957 -106\r\n-95 -9929\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9895 -9949\r\n188 -9978\r\n-9810 9935\r\n-151 9914\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-9957 106\r\n-95 9929\r\n9965 -114\r\n87 -9916\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-9862 9980\r\n-174 9917\r\n9845 -9967\r\n173 -9980\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9944 9926\r\n9927 9935\r\n-9961 -9929\r\n-9997 -9991\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9917 9909\r\n196 9925\r\n-9971 -9991\r\n-183 -9977\r\n", "output": "3 4\r\n"}]
| false |
stdio
|
import sys
import math
def read_vectors(input_path):
with open(input_path) as f:
n = int(f.readline())
vectors = []
for i in range(n):
x, y = map(int, f.readline().split())
vectors.append( (x, y, i+1) )
return vectors
def compute_angle(x, y):
return math.atan2(y, x) % (2 * math.pi)
def compute_non_oriented_angle(u, v):
ux, uy = u
vx, vy = v
dot = ux * vx + uy * vy
mag_u = math.hypot(ux, uy)
mag_v = math.hypot(vx, vy)
if mag_u == 0 or mag_v == 0:
return 0.0
cos_theta = dot / (mag_u * mag_v)
cos_theta = max(min(cos_theta, 1.0), -1.0)
return math.acos(cos_theta)
def find_min_angle(vectors):
sorted_vectors = sorted(vectors, key=lambda vec: compute_angle(vec[0], vec[1]))
n = len(sorted_vectors)
min_adjacent = math.pi
for i in range(n):
j = (i + 1) % n
u = sorted_vectors[i][0], sorted_vectors[i][1]
v = sorted_vectors[j][0], sorted_vectors[j][1]
theta = compute_non_oriented_angle(u, v)
if theta < min_adjacent:
min_adjacent = theta
angles = []
for vec in sorted_vectors:
x, y, idx = vec
angles.append( compute_angle(x, y) )
min_opposite = math.pi
for i in range(n):
theta_i = angles[i]
target = (theta_i + math.pi) % (2 * math.pi)
low = 0
high = n
while low < high:
mid = (low + high) // 2
if angles[mid] < target:
low = mid + 1
else:
high = mid
candidates = []
if low > 0:
candidates.append(low-1)
if low < n:
candidates.append(low)
candidates.append((low - 1) % n)
candidates = list(set(candidates))
for c in candidates:
if c == i:
continue
c = c % n
vec_c = sorted_vectors[c]
u = sorted_vectors[i][0], sorted_vectors[i][1]
v = vec_c[0], vec_c[1]
current_theta = compute_non_oriented_angle(u, v)
if current_theta < min_opposite:
min_opposite = current_theta
return min(min_adjacent, min_opposite)
def main(input_path, output_path, submission_output_path):
input_vectors = read_vectors(input_path)
with open(submission_output_path) as f:
line = f.readline().strip()
try:
a, b = map(int, line.split())
except:
print(0)
return
n = len(input_vectors)
if a < 1 or a > n or b < 1 or b > n or a == b:
print(0)
return
vec_a = None
vec_b = None
for vec in input_vectors:
if vec[2] == a:
vec_a = vec
if vec[2] == b:
vec_b = vec
if vec_a is None or vec_b is None:
print(0)
return
u = (vec_a[0], vec_a[1])
v = (vec_b[0], vec_b[1])
theta = compute_non_oriented_angle(u, v)
min_angle = find_min_angle(input_vectors)
epsilon = 1e-9
if abs(theta - min_angle) <= epsilon:
print(1)
else:
print(0)
if __name__ == "__main__":
input_path = sys.argv[1]
output_path = sys.argv[2]
submission_output_path = sys.argv[3]
main(input_path, output_path, submission_output_path)
| true |
858/E
|
858
|
E
|
Python 3
|
PRETESTS
| 0 | 46 | 0 |
30438694
|
n = int(input())
tasks = []
e = 0
for i in range(n):
s = input().split()
if s[0].isdigit():
s[0] = int(s[0])
a = [s[0], int(s[1])]
tasks.append(a)
if a[1]:
e += 1
tasks.sort(key=lambda x: -x[1])
newSet = set(range(1, e + 1))
goodSet = set()
for i in range(e):
if tasks[i][0] in newSet:
goodSet.add(tasks[i][0])
set1 = set()
for i in range(e):
set1.add(tasks[i][0])
set2 = set()
for i in range(e, n):
set2.add(tasks[i][0])
number = e + 1
move = []
for i in range(e, n):
if tasks[i][0] in set(range(1, e + 1)):
while number in set1 | set2:
number += 1
move.append((tasks[i][0], number))
tasks[i][0] = number
number += 1
k = 1
for i in range(e):
if tasks[i][0] not in goodSet:
while k in goodSet:
k += 1
move.append((tasks[i][0], k))
tasks[i][0] = k
k += 1
newSet = set(range(e + 1, n + 1))
goodSet = set()
for i in range(e, n):
if tasks[i][0] in newSet:
goodSet.add(tasks[i][0])
k = e + 1
for i in range(e, n):
if tasks[i][0] not in goodSet:
while k in goodSet:
k += 1
move.append((tasks[i][0], k))
tasks[i][0] = k
k += 1
print(len(move))
for x in move:
print('move', x[0], x[1])
| 165 | 295 | 27,136,000 |
230751905
|
n = int(input())
t = [1] + [0] * n
b, a = d = [], []
h, s = [], []
for i in range(n):
f, k = input().split()
d[int(k)].append(f)
m = len(a)
for i in a:
if i.isdigit() and i[0] != '0':
j = int(i)
if 0 < j <= m:
t[j] = 1
elif m < j <= n:
t[j] = -1
else:
s.append(i)
else:
s.append(i)
for i in b:
if i.isdigit() and i[0] != '0':
j = int(i)
if m < j <= n:
t[j] = 1
elif 0 < j <= m:
t[j] = -1
else:
s.append(i)
else:
s.append(i)
x = [j for j in range(1, m + 1) if t[j] < 0]
y = [j for j in range(m + 1, n + 1) if t[j] < 0]
u = [j for j in range(1, m + 1) if not t[j]]
v = [j for j in range(m + 1, n + 1) if not t[j]]
if not s and (x or y):
s = ['0']
if y:
i = y.pop()
v.append(i)
else:
i = x.pop()
u.append(i)
h.append(str(i) + ' 0')
t[i] = 0
while x or y:
if v and x:
i = x.pop()
j = v.pop()
t[j] = 1
h.append(str(i) + ' ' + str(j))
u.append(i)
else:
u, v, x, y = v, u, y, x
k = 1
for j in s:
while t[k] == 1: k += 1
h.append(j + ' ' + str(k))
k += 1
d = '\nmove '
print(str(len(h)) + d + d.join(h) if h else 0)
|
Технокубок 2018 - Отборочный Раунд 1
|
CF
| 2,017 | 2 | 256 |
Tests Renumeration
|
The All-Berland National Olympiad in Informatics has just ended! Now Vladimir wants to upload the contest from the Olympiad as a gym to a popular Codehorses website.
Unfortunately, the archive with Olympiad's data is a mess. For example, the files with tests are named arbitrary without any logic.
Vladimir wants to rename the files with tests so that their names are distinct integers starting from 1 without any gaps, namely, "1", "2", ..., "n', where n is the total number of tests.
Some of the files contain tests from statements (examples), while others contain regular tests. It is possible that there are no examples, and it is possible that all tests are examples. Vladimir wants to rename the files so that the examples are the first several tests, all all the next files contain regular tests only.
The only operation Vladimir can perform is the "move" command. Vladimir wants to write a script file, each of the lines in which is "move file_1 file_2", that means that the file "file_1" is to be renamed to "file_2". If there is a file "file_2" at the moment of this line being run, then this file is to be rewritten. After the line "move file_1 file_2" the file "file_1" doesn't exist, but there is a file "file_2" with content equal to the content of "file_1" before the "move" command.
Help Vladimir to write the script file with the minimum possible number of lines so that after this script is run:
- all examples are the first several tests having filenames "1", "2", ..., "e", where e is the total number of examples;
- all other files contain regular tests with filenames "e + 1", "e + 2", ..., "n", where n is the total number of all tests.
|
The first line contains single integer n (1 ≤ n ≤ 105) — the number of files with tests.
n lines follow, each describing a file with test. Each line has a form of "name_i type_i", where "name_i" is the filename, and "type_i" equals "1", if the i-th file contains an example test, and "0" if it contains a regular test. Filenames of each file are strings of digits and small English letters with length from 1 to 6 characters. The filenames are guaranteed to be distinct.
|
In the first line print the minimum number of lines in Vladimir's script file.
After that print the script file, each line should be "move file_1 file_2", where "file_1" is an existing at the moment of this line being run filename, and "file_2" — is a string of digits and small English letters with length from 1 to 6.
| null | null |
[{"input": "5\n01 0\n2 1\n2extra 0\n3 1\n99 0", "output": "4\nmove 3 1\nmove 01 5\nmove 2extra 4\nmove 99 3"}, {"input": "2\n1 0\n2 1", "output": "3\nmove 1 3\nmove 2 1\nmove 3 2"}, {"input": "5\n1 0\n11 1\n111 0\n1111 1\n11111 0", "output": "5\nmove 1 5\nmove 11 1\nmove 1111 2\nmove 111 4\nmove 11111 3"}]
| 2,200 |
["greedy", "implementation"]
| 165 |
[{"input": "5\r\n01 0\r\n2 1\r\n2extra 0\r\n3 1\r\n99 0\r\n", "output": "4\r\nmove 3 1\r\nmove 01 5\r\nmove 2extra 4\r\nmove 99 3\r\n"}, {"input": "2\r\n1 0\r\n2 1\r\n", "output": "3\r\nmove 1 dytuig\r\nmove 2 1\r\nmove dytuig 2\r\n"}, {"input": "5\r\n1 0\r\n11 1\r\n111 0\r\n1111 1\r\n11111 0\r\n", "output": "5\r\nmove 1 5\r\nmove 11 1\r\nmove 1111 2\r\nmove 111 4\r\nmove 11111 3\r\n"}, {"input": "4\r\nir7oz8 1\r\nvj4v5t 1\r\nkwkahb 1\r\nj5s8o1 0\r\n", "output": "4\r\nmove ir7oz8 1\r\nmove vj4v5t 2\r\nmove kwkahb 3\r\nmove j5s8o1 4\r\n"}, {"input": "4\r\n3 1\r\n1o0bp2 0\r\n9tn379 0\r\nv04v6j 1\r\n", "output": "4\r\nmove 3 1\r\nmove v04v6j 2\r\nmove 1o0bp2 4\r\nmove 9tn379 3\r\n"}, {"input": "4\r\n1 0\r\nsc7czx 0\r\nfr4033 1\r\n3 0\r\n", "output": "3\r\nmove 1 4\r\nmove fr4033 1\r\nmove sc7czx 2\r\n"}, {"input": "4\r\n4 0\r\n1 0\r\n2 0\r\nizfotg 1\r\n", "output": "2\r\nmove 1 3\r\nmove izfotg 1\r\n"}, {"input": "4\r\n2 0\r\n3 0\r\n1 1\r\n4 1\r\n", "output": "3\r\nmove 2 0b9r8j\r\nmove 4 2\r\nmove 0b9r8j 4\r\n"}, {"input": "5\r\npuusew 1\r\npvoy4h 0\r\nwdzx4r 0\r\n1z84cx 0\r\nozsuvd 0\r\n", "output": "5\r\nmove puusew 1\r\nmove pvoy4h 5\r\nmove wdzx4r 4\r\nmove 1z84cx 3\r\nmove ozsuvd 2\r\n"}, {"input": "5\r\n949pnr 1\r\n9sxhcr 0\r\n5 1\r\nx8srx3 1\r\ncl7ppd 1\r\n", "output": "5\r\nmove 5 1\r\nmove 949pnr 2\r\nmove x8srx3 3\r\nmove cl7ppd 4\r\nmove 9sxhcr 5\r\n"}, {"input": "5\r\n2 0\r\n1 0\r\np2gcxf 1\r\nwfyoiq 1\r\nzjw3vg 1\r\n", "output": "5\r\nmove 2 5\r\nmove 1 4\r\nmove p2gcxf 1\r\nmove wfyoiq 2\r\nmove zjw3vg 3\r\n"}, {"input": "5\r\nogvgi7 0\r\n3 1\r\n4 1\r\n1 1\r\nm5nhux 0\r\n", "output": "3\r\nmove 4 2\r\nmove ogvgi7 5\r\nmove m5nhux 4\r\n"}, {"input": "5\r\nt6kdte 1\r\n2 1\r\n4 1\r\n5 1\r\n3 1\r\n", "output": "1\r\nmove t6kdte 1\r\n"}, {"input": "5\r\n2 0\r\n3 1\r\n4 0\r\n1 1\r\n5 1\r\n", "output": "3\r\nmove 2 p6w7mu\r\nmove 5 2\r\nmove p6w7mu 5\r\n"}, {"input": "1\r\nsd84r7 1\r\n", "output": "1\r\nmove sd84r7 1\r\n"}, {"input": "1\r\n1 0\r\n", "output": "0\r\n"}, {"input": "2\r\n5xzjm4 0\r\njoa6mr 1\r\n", "output": "2\r\nmove joa6mr 1\r\nmove 5xzjm4 2\r\n"}, {"input": "2\r\n1 0\r\nxdkh5a 1\r\n", "output": "2\r\nmove 1 2\r\nmove xdkh5a 1\r\n"}, {"input": "2\r\n1 0\r\n2 0\r\n", "output": "0\r\n"}, {"input": "3\r\nz1nwrd 1\r\nt0xrja 0\r\n106qy1 0\r\n", "output": "3\r\nmove z1nwrd 1\r\nmove t0xrja 3\r\nmove 106qy1 2\r\n"}, {"input": "3\r\nt4hdos 0\r\ndhje0g 0\r\n3 0\r\n", "output": "2\r\nmove t4hdos 2\r\nmove dhje0g 1\r\n"}, {"input": "3\r\n3 0\r\n26mp5s 0\r\n1 1\r\n", "output": "1\r\nmove 26mp5s 2\r\n"}, {"input": "3\r\n2 1\r\n1 0\r\n3 0\r\n", "output": "3\r\nmove 2 1ntx05\r\nmove 1 2\r\nmove 1ntx05 1\r\n"}, {"input": "1\r\nprzvln 0\r\n", "output": "1\r\nmove przvln 1\r\n"}, {"input": "2\r\nkfsipl 0\r\n1jj1ol 0\r\n", "output": "2\r\nmove kfsipl 2\r\nmove 1jj1ol 1\r\n"}, {"input": "3\r\n2x7a4g 0\r\n27lqe6 0\r\nzfo3sp 0\r\n", "output": "3\r\nmove 2x7a4g 3\r\nmove 27lqe6 2\r\nmove zfo3sp 1\r\n"}, {"input": "1\r\nxzp9ni 1\r\n", "output": "1\r\nmove xzp9ni 1\r\n"}, {"input": "1\r\nabbdf7 1\r\n", "output": "1\r\nmove abbdf7 1\r\n"}, {"input": "2\r\ndbif39 1\r\ne8dkf8 0\r\n", "output": "2\r\nmove dbif39 1\r\nmove e8dkf8 2\r\n"}, {"input": "2\r\n2 0\r\njkwekx 1\r\n", "output": "1\r\nmove jkwekx 1\r\n"}, {"input": "3\r\nn3pmj8 0\r\n2alui6 0\r\ne7lf4u 1\r\n", "output": "3\r\nmove e7lf4u 1\r\nmove n3pmj8 3\r\nmove 2alui6 2\r\n"}, {"input": "3\r\ndr1lp8 0\r\n1 0\r\n6a2egk 1\r\n", "output": "3\r\nmove 1 3\r\nmove 6a2egk 1\r\nmove dr1lp8 2\r\n"}, {"input": "4\r\nyi9ta0 1\r\nmeljgm 0\r\nf7bqon 0\r\n5bbvun 0\r\n", "output": "4\r\nmove yi9ta0 1\r\nmove meljgm 4\r\nmove f7bqon 3\r\nmove 5bbvun 2\r\n"}, {"input": "4\r\n0la3gu 0\r\nzhrmyb 1\r\n3iprc0 0\r\n3 0\r\n", "output": "3\r\nmove zhrmyb 1\r\nmove 0la3gu 4\r\nmove 3iprc0 2\r\n"}, {"input": "1\r\n1 1\r\n", "output": "0\r\n"}, {"input": "1\r\n1 1\r\n", "output": "0\r\n"}, {"input": "2\r\n17dgbb 0\r\n2 1\r\n", "output": "2\r\nmove 2 1\r\nmove 17dgbb 2\r\n"}, {"input": "2\r\n1 0\r\n2 1\r\n", "output": "3\r\nmove 1 xrjgjv\r\nmove 2 1\r\nmove xrjgjv 2\r\n"}, {"input": "3\r\nscrn8k 0\r\n3 1\r\nycvm9s 0\r\n", "output": "3\r\nmove 3 1\r\nmove scrn8k 3\r\nmove ycvm9s 2\r\n"}, {"input": "3\r\nt0dfz3 0\r\n3 0\r\n1 1\r\n", "output": "1\r\nmove t0dfz3 2\r\n"}, {"input": "4\r\nkgw83p 0\r\np3p3ch 0\r\n4 1\r\n0te9lv 0\r\n", "output": "4\r\nmove 4 1\r\nmove kgw83p 4\r\nmove p3p3ch 3\r\nmove 0te9lv 2\r\n"}, {"input": "4\r\n3 1\r\nnj94jx 0\r\n3a5ad1 0\r\n1 0\r\n", "output": "4\r\nmove 1 4\r\nmove 3 1\r\nmove nj94jx 3\r\nmove 3a5ad1 2\r\n"}, {"input": "2\r\no9z069 1\r\n5hools 1\r\n", "output": "2\r\nmove o9z069 1\r\nmove 5hools 2\r\n"}, {"input": "2\r\nyzzyab 1\r\n728oq0 1\r\n", "output": "2\r\nmove yzzyab 1\r\nmove 728oq0 2\r\n"}, {"input": "2\r\nqy2kmc 1\r\nqb4crj 1\r\n", "output": "2\r\nmove qy2kmc 1\r\nmove qb4crj 2\r\n"}, {"input": "3\r\nunw560 1\r\n0iswxk 0\r\ndonjp9 1\r\n", "output": "3\r\nmove unw560 1\r\nmove donjp9 2\r\nmove 0iswxk 3\r\n"}, {"input": "3\r\n2 0\r\nuv8c54 1\r\n508bb0 1\r\n", "output": "3\r\nmove 2 3\r\nmove uv8c54 1\r\nmove 508bb0 2\r\n"}, {"input": "3\r\n9afh0z 1\r\n0qcaht 1\r\n3 0\r\n", "output": "2\r\nmove 9afh0z 1\r\nmove 0qcaht 2\r\n"}, {"input": "4\r\n2kk04q 0\r\nkdktvk 1\r\nc4i5k8 1\r\nawaock 0\r\n", "output": "4\r\nmove kdktvk 1\r\nmove c4i5k8 2\r\nmove 2kk04q 4\r\nmove awaock 3\r\n"}, {"input": "4\r\n2 0\r\nmqbjos 0\r\n6mhijg 1\r\n6wum8y 1\r\n", "output": "4\r\nmove 2 4\r\nmove 6mhijg 1\r\nmove 6wum8y 2\r\nmove mqbjos 3\r\n"}, {"input": "4\r\n4 0\r\npa613p 1\r\nuuizq7 1\r\n2 0\r\n", "output": "3\r\nmove 2 3\r\nmove pa613p 1\r\nmove uuizq7 2\r\n"}, {"input": "5\r\nw0g96a 1\r\nv99tdi 0\r\nmywrle 0\r\nweh22w 1\r\n9hywt4 0\r\n", "output": "5\r\nmove w0g96a 1\r\nmove weh22w 2\r\nmove v99tdi 5\r\nmove mywrle 4\r\nmove 9hywt4 3\r\n"}, {"input": "5\r\n5 0\r\n12qcjd 1\r\nuthzbz 0\r\nb3670z 0\r\nl2u93o 1\r\n", "output": "4\r\nmove 12qcjd 1\r\nmove l2u93o 2\r\nmove uthzbz 4\r\nmove b3670z 3\r\n"}, {"input": "5\r\n0jc7xb 1\r\n2 0\r\n1m7l9s 0\r\n9xzkau 1\r\n1 0\r\n", "output": "5\r\nmove 2 5\r\nmove 1 4\r\nmove 0jc7xb 1\r\nmove 9xzkau 2\r\nmove 1m7l9s 3\r\n"}, {"input": "2\r\n1 1\r\nvinxur 1\r\n", "output": "1\r\nmove vinxur 2\r\n"}, {"input": "2\r\n1qe46n 1\r\n1 1\r\n", "output": "1\r\nmove 1qe46n 2\r\n"}, {"input": "2\r\n1 1\r\ng5jlzp 1\r\n", "output": "1\r\nmove g5jlzp 2\r\n"}, {"input": "3\r\nc8p28p 1\r\n2 1\r\nvk4gdf 0\r\n", "output": "2\r\nmove c8p28p 1\r\nmove vk4gdf 3\r\n"}, {"input": "3\r\n2 1\r\n3 0\r\nhs9j9t 1\r\n", "output": "1\r\nmove hs9j9t 1\r\n"}, {"input": "3\r\n2 1\r\n1 0\r\nomitxh 1\r\n", "output": "2\r\nmove 1 3\r\nmove omitxh 1\r\n"}, {"input": "4\r\n4 1\r\nu9do88 1\r\n787at9 0\r\nfcud6k 0\r\n", "output": "4\r\nmove 4 1\r\nmove u9do88 2\r\nmove 787at9 4\r\nmove fcud6k 3\r\n"}, {"input": "4\r\n3 0\r\nqvw4ow 1\r\nne0ng9 0\r\n1 1\r\n", "output": "2\r\nmove qvw4ow 2\r\nmove ne0ng9 4\r\n"}, {"input": "4\r\ng6ugrm 1\r\n1 1\r\n3 0\r\n2 0\r\n", "output": "2\r\nmove 2 4\r\nmove g6ugrm 2\r\n"}, {"input": "5\r\n5 1\r\nz9zr7d 0\r\ne8rwo4 1\r\nrfpjp6 0\r\ngz6dhj 0\r\n", "output": "5\r\nmove 5 1\r\nmove e8rwo4 2\r\nmove z9zr7d 5\r\nmove rfpjp6 4\r\nmove gz6dhj 3\r\n"}, {"input": "5\r\n5sn77g 0\r\nsetddt 1\r\nbz16cb 0\r\n4 1\r\n2 0\r\n", "output": "5\r\nmove 4 1\r\nmove 2 5\r\nmove setddt 2\r\nmove 5sn77g 4\r\nmove bz16cb 3\r\n"}, {"input": "5\r\n1 1\r\nx2miqh 1\r\n3 0\r\n2 0\r\n1rq643 0\r\n", "output": "3\r\nmove 2 5\r\nmove x2miqh 2\r\nmove 1rq643 4\r\n"}, {"input": "2\r\n1 1\r\n2 1\r\n", "output": "0\r\n"}, {"input": "2\r\n1 1\r\n2 1\r\n", "output": "0\r\n"}, {"input": "2\r\n2 1\r\n1 1\r\n", "output": "0\r\n"}, {"input": "3\r\n3 1\r\nav5vex 0\r\n1 1\r\n", "output": "2\r\nmove 3 2\r\nmove av5vex 3\r\n"}, {"input": "3\r\n3 1\r\n1 0\r\n2 1\r\n", "output": "3\r\nmove 3 fopgrb\r\nmove 1 3\r\nmove fopgrb 1\r\n"}, {"input": "3\r\n3 1\r\n1 0\r\n2 1\r\n", "output": "3\r\nmove 3 wzgsm0\r\nmove 1 3\r\nmove wzgsm0 1\r\n"}, {"input": "4\r\ny9144q 0\r\n3 1\r\n2 1\r\ns0bdnf 0\r\n", "output": "3\r\nmove 3 1\r\nmove y9144q 4\r\nmove s0bdnf 3\r\n"}, {"input": "4\r\n4 1\r\n1 0\r\n3 1\r\nmod9zl 0\r\n", "output": "4\r\nmove 4 2\r\nmove 1 4\r\nmove 3 1\r\nmove mod9zl 3\r\n"}, {"input": "4\r\n4 1\r\n3 1\r\n1 0\r\n2 0\r\n", "output": "5\r\nmove 4 ow3q4a\r\nmove 1 4\r\nmove 3 1\r\nmove 2 3\r\nmove ow3q4a 2\r\n"}, {"input": "5\r\n1 1\r\nnoidnv 0\r\n3 1\r\nx3xiiz 0\r\n1lfa9v 0\r\n", "output": "4\r\nmove 3 2\r\nmove noidnv 5\r\nmove x3xiiz 4\r\nmove 1lfa9v 3\r\n"}, {"input": "5\r\n1 1\r\nvsyajx 0\r\n783b38 0\r\n4 0\r\n2 1\r\n", "output": "2\r\nmove vsyajx 5\r\nmove 783b38 3\r\n"}, {"input": "5\r\n3 1\r\n5 0\r\ncvfl8i 0\r\n4 1\r\n2 0\r\n", "output": "4\r\nmove 3 1\r\nmove 2 3\r\nmove 4 2\r\nmove cvfl8i 4\r\n"}, {"input": "3\r\nbxo0pe 1\r\nbt50pa 1\r\n2tx68t 1\r\n", "output": "3\r\nmove bxo0pe 1\r\nmove bt50pa 2\r\nmove 2tx68t 3\r\n"}, {"input": "3\r\nj9rnac 1\r\noetwfz 1\r\nd6n3ww 1\r\n", "output": "3\r\nmove j9rnac 1\r\nmove oetwfz 2\r\nmove d6n3ww 3\r\n"}, {"input": "3\r\naf2f6j 1\r\nmjni5l 1\r\njvyxgc 1\r\n", "output": "3\r\nmove af2f6j 1\r\nmove mjni5l 2\r\nmove jvyxgc 3\r\n"}, {"input": "3\r\nr2qlj2 1\r\nt8wf1y 1\r\nigids8 1\r\n", "output": "3\r\nmove r2qlj2 1\r\nmove t8wf1y 2\r\nmove igids8 3\r\n"}, {"input": "4\r\nuilh9a 0\r\n4lxxh9 1\r\nkqdpzy 1\r\nn1d7hd 1\r\n", "output": "4\r\nmove 4lxxh9 1\r\nmove kqdpzy 2\r\nmove n1d7hd 3\r\nmove uilh9a 4\r\n"}, {"input": "4\r\n3 0\r\niipymv 1\r\nvakd5b 1\r\n2ktczv 1\r\n", "output": "4\r\nmove 3 4\r\nmove iipymv 1\r\nmove vakd5b 2\r\nmove 2ktczv 3\r\n"}, {"input": "4\r\nq4b449 1\r\n3 0\r\ncjg1x2 1\r\ne878er 1\r\n", "output": "4\r\nmove 3 4\r\nmove q4b449 1\r\nmove cjg1x2 2\r\nmove e878er 3\r\n"}, {"input": "4\r\n9f4aoa 1\r\n4 0\r\nf4m1ec 1\r\nqyr2h6 1\r\n", "output": "3\r\nmove 9f4aoa 1\r\nmove f4m1ec 2\r\nmove qyr2h6 3\r\n"}, {"input": "5\r\n73s1nt 1\r\nsbngv2 0\r\n4n3qri 1\r\nbyhzp8 1\r\nadpjs4 0\r\n", "output": "5\r\nmove 73s1nt 1\r\nmove 4n3qri 2\r\nmove byhzp8 3\r\nmove sbngv2 5\r\nmove adpjs4 4\r\n"}, {"input": "5\r\n7ajg8o 1\r\np7cqxy 1\r\n3qrp34 0\r\nh93m07 1\r\n2 0\r\n", "output": "5\r\nmove 2 5\r\nmove 7ajg8o 1\r\nmove p7cqxy 2\r\nmove h93m07 3\r\nmove 3qrp34 4\r\n"}, {"input": "5\r\ny0wnwz 1\r\n5 0\r\n0totai 1\r\n1 0\r\nym8xwz 1\r\n", "output": "4\r\nmove 1 4\r\nmove y0wnwz 1\r\nmove 0totai 2\r\nmove ym8xwz 3\r\n"}, {"input": "5\r\n5 0\r\n4 0\r\n5nvzu4 1\r\nvkpzzk 1\r\nzamzcz 1\r\n", "output": "3\r\nmove 5nvzu4 1\r\nmove vkpzzk 2\r\nmove zamzcz 3\r\n"}, {"input": "6\r\np1wjw9 1\r\nueksby 0\r\nu1ixfc 1\r\nj3lk2e 1\r\n36iskv 0\r\n9imqi1 0\r\n", "output": "6\r\nmove p1wjw9 1\r\nmove u1ixfc 2\r\nmove j3lk2e 3\r\nmove ueksby 6\r\nmove 36iskv 5\r\nmove 9imqi1 4\r\n"}, {"input": "6\r\n6slonw 1\r\nptk9mc 1\r\n57a4nq 0\r\nhiq2f7 1\r\n2 0\r\nc0gtv3 0\r\n", "output": "6\r\nmove 2 6\r\nmove 6slonw 1\r\nmove ptk9mc 2\r\nmove hiq2f7 3\r\nmove 57a4nq 5\r\nmove c0gtv3 4\r\n"}, {"input": "6\r\n5 0\r\n2 0\r\ncbhvyf 1\r\nl1z5mg 0\r\nwkwhby 1\r\nx7fdh9 1\r\n", "output": "5\r\nmove 2 6\r\nmove cbhvyf 1\r\nmove wkwhby 2\r\nmove x7fdh9 3\r\nmove l1z5mg 4\r\n"}, {"input": "6\r\n1t68ks 1\r\npkbj1g 1\r\n5 0\r\n5pw8wm 1\r\n1 0\r\n4 0\r\n", "output": "4\r\nmove 1 6\r\nmove 1t68ks 1\r\nmove pkbj1g 2\r\nmove 5pw8wm 3\r\n"}, {"input": "3\r\n1 1\r\n7ph5fw 1\r\ntfxz1j 1\r\n", "output": "2\r\nmove 7ph5fw 2\r\nmove tfxz1j 3\r\n"}, {"input": "3\r\norwsz0 1\r\nmbt097 1\r\n3 1\r\n", "output": "2\r\nmove orwsz0 1\r\nmove mbt097 2\r\n"}, {"input": "3\r\n1 1\r\nzwfnx2 1\r\n7g8t6z 1\r\n", "output": "2\r\nmove zwfnx2 2\r\nmove 7g8t6z 3\r\n"}, {"input": "3\r\nqmf7iz 1\r\ndjwdce 1\r\n1 1\r\n", "output": "2\r\nmove qmf7iz 2\r\nmove djwdce 3\r\n"}, {"input": "4\r\n4i2i2a 0\r\n4 1\r\npf618n 1\r\nlx6nmh 1\r\n", "output": "4\r\nmove 4 1\r\nmove pf618n 2\r\nmove lx6nmh 3\r\nmove 4i2i2a 4\r\n"}, {"input": "4\r\nxpteku 1\r\n1 0\r\n4 1\r\n73xpqz 1\r\n", "output": "4\r\nmove 4 2\r\nmove 1 4\r\nmove xpteku 1\r\nmove 73xpqz 3\r\n"}, {"input": "4\r\n1wp56i 1\r\n2 1\r\n1 0\r\n6m76jb 1\r\n", "output": "3\r\nmove 1 4\r\nmove 1wp56i 1\r\nmove 6m76jb 3\r\n"}, {"input": "4\r\n3 1\r\nyumiqt 1\r\n1 0\r\nt19jus 1\r\n", "output": "3\r\nmove 1 4\r\nmove yumiqt 1\r\nmove t19jus 2\r\n"}, {"input": "5\r\nynagvf 1\r\n3 1\r\nojz4mm 1\r\ndovec3 0\r\nnc1jye 0\r\n", "output": "4\r\nmove ynagvf 1\r\nmove ojz4mm 2\r\nmove dovec3 5\r\nmove nc1jye 4\r\n"}, {"input": "5\r\n5 1\r\nwje9ts 1\r\nkytn5q 1\r\n7frk8z 0\r\n3 0\r\n", "output": "5\r\nmove 5 1\r\nmove 3 5\r\nmove wje9ts 2\r\nmove kytn5q 3\r\nmove 7frk8z 4\r\n"}, {"input": "5\r\n1 0\r\n4 1\r\n3 0\r\nlog9cm 1\r\nu5m0ls 1\r\n", "output": "5\r\nmove 4 2\r\nmove 1 5\r\nmove 3 4\r\nmove log9cm 1\r\nmove u5m0ls 3\r\n"}, {"input": "5\r\nh015vv 1\r\n3 1\r\n1 0\r\n9w2keb 1\r\n2 0\r\n", "output": "4\r\nmove 1 5\r\nmove 2 4\r\nmove h015vv 1\r\nmove 9w2keb 2\r\n"}, {"input": "6\r\n0zluka 0\r\nqp7q8l 1\r\nwglqu8 1\r\n9i7kta 0\r\nnwf8m3 0\r\n3 1\r\n", "output": "5\r\nmove qp7q8l 1\r\nmove wglqu8 2\r\nmove 0zluka 6\r\nmove 9i7kta 5\r\nmove nwf8m3 4\r\n"}, {"input": "6\r\n3 1\r\n1h3t85 1\r\n5 0\r\nrf2ikt 0\r\n3vhl6e 1\r\n5l3oka 0\r\n", "output": "4\r\nmove 1h3t85 1\r\nmove 3vhl6e 2\r\nmove rf2ikt 6\r\nmove 5l3oka 4\r\n"}, {"input": "6\r\n2 0\r\n3 0\r\nw9h0pv 1\r\n5 1\r\nq92z4i 0\r\n6qb4ia 1\r\n", "output": "6\r\nmove 5 1\r\nmove 2 6\r\nmove 3 5\r\nmove w9h0pv 2\r\nmove 6qb4ia 3\r\nmove q92z4i 4\r\n"}, {"input": "6\r\n4 1\r\n410jiy 1\r\n1 0\r\n6 0\r\nxc98l2 1\r\n5 0\r\n", "output": "4\r\nmove 4 2\r\nmove 1 4\r\nmove 410jiy 1\r\nmove xc98l2 3\r\n"}, {"input": "3\r\n1 1\r\nc9qyld 1\r\n3 1\r\n", "output": "1\r\nmove c9qyld 2\r\n"}, {"input": "3\r\ngdm5ri 1\r\n1 1\r\n2 1\r\n", "output": "1\r\nmove gdm5ri 3\r\n"}, {"input": "3\r\n3 1\r\n2 1\r\ni19lnk 1\r\n", "output": "1\r\nmove i19lnk 1\r\n"}, {"input": "3\r\ncxbbpd 1\r\n3 1\r\n1 1\r\n", "output": "1\r\nmove cxbbpd 2\r\n"}, {"input": "4\r\nwy6i6o 0\r\n1 1\r\n3 1\r\niy1dq6 1\r\n", "output": "2\r\nmove iy1dq6 2\r\nmove wy6i6o 4\r\n"}, {"input": "4\r\n4 1\r\nwgh8s0 1\r\n1 0\r\n2 1\r\n", "output": "3\r\nmove 4 3\r\nmove 1 4\r\nmove wgh8s0 1\r\n"}, {"input": "4\r\nhex0ur 1\r\n4 1\r\n3 0\r\n2 1\r\n", "output": "3\r\nmove 4 1\r\nmove 3 4\r\nmove hex0ur 3\r\n"}, {"input": "4\r\n4 1\r\n1 1\r\n3 0\r\n4soxj3 1\r\n", "output": "3\r\nmove 4 2\r\nmove 3 4\r\nmove 4soxj3 3\r\n"}, {"input": "5\r\n5sbtul 1\r\n2 1\r\n8i2duz 0\r\n5 1\r\n4b85z6 0\r\n", "output": "4\r\nmove 5 1\r\nmove 5sbtul 3\r\nmove 8i2duz 5\r\nmove 4b85z6 4\r\n"}, {"input": "5\r\n3 1\r\n4 0\r\nejo0a4 1\r\ngqzdbk 0\r\n1 1\r\n", "output": "2\r\nmove ejo0a4 2\r\nmove gqzdbk 5\r\n"}, {"input": "5\r\n2y4agr 1\r\n5 0\r\n3 0\r\n1 1\r\n4 1\r\n", "output": "3\r\nmove 4 2\r\nmove 3 4\r\nmove 2y4agr 3\r\n"}, {"input": "5\r\n2 0\r\n1 1\r\nq4hyeg 1\r\n5 0\r\n4 1\r\n", "output": "3\r\nmove 4 3\r\nmove 2 4\r\nmove q4hyeg 2\r\n"}, {"input": "6\r\n5 1\r\nrdm6fu 0\r\n4 1\r\noclx1h 0\r\n7l3kg1 1\r\nq25te0 0\r\n", "output": "6\r\nmove 5 1\r\nmove 4 2\r\nmove 7l3kg1 3\r\nmove rdm6fu 6\r\nmove oclx1h 5\r\nmove q25te0 4\r\n"}, {"input": "6\r\n1 0\r\np4tuyt 0\r\n5 1\r\n2 1\r\nwrrcmu 1\r\n3r4wqz 0\r\n", "output": "5\r\nmove 5 3\r\nmove 1 6\r\nmove wrrcmu 1\r\nmove p4tuyt 5\r\nmove 3r4wqz 4\r\n"}, {"input": "6\r\n5 1\r\n6 0\r\nxhfzge 0\r\n3 1\r\n1 0\r\n1n9mqv 1\r\n", "output": "4\r\nmove 5 2\r\nmove 1 5\r\nmove 1n9mqv 1\r\nmove xhfzge 4\r\n"}, {"input": "6\r\nhmpfsz 1\r\n6 0\r\n5 1\r\n4 0\r\n1 0\r\n3 1\r\n", "output": "3\r\nmove 5 2\r\nmove 1 5\r\nmove hmpfsz 1\r\n"}, {"input": "3\r\n1 1\r\n3 1\r\n2 1\r\n", "output": "0\r\n"}, {"input": "3\r\n2 1\r\n3 1\r\n1 1\r\n", "output": "0\r\n"}, {"input": "3\r\n2 1\r\n1 1\r\n3 1\r\n", "output": "0\r\n"}, {"input": "3\r\n1 1\r\n2 1\r\n3 1\r\n", "output": "0\r\n"}, {"input": "4\r\n3 1\r\n1 1\r\n4 1\r\nd1cks2 0\r\n", "output": "2\r\nmove 4 2\r\nmove d1cks2 4\r\n"}, {"input": "4\r\n4 0\r\n3 1\r\n1 1\r\n2 1\r\n", "output": "0\r\n"}, {"input": "4\r\n2 1\r\n4 1\r\n1 0\r\n3 1\r\n", "output": "3\r\nmove 4 e15gvb\r\nmove 1 4\r\nmove e15gvb 1\r\n"}, {"input": "4\r\n4 1\r\n1 1\r\n3 1\r\n2 0\r\n", "output": "3\r\nmove 4 7l41cc\r\nmove 2 4\r\nmove 7l41cc 2\r\n"}, {"input": "5\r\n4 1\r\nhvshea 0\r\naio11n 0\r\n2 1\r\n3 1\r\n", "output": "3\r\nmove 4 1\r\nmove hvshea 5\r\nmove aio11n 4\r\n"}, {"input": "5\r\n5 0\r\nts7a1c 0\r\n4 1\r\n1 1\r\n2 1\r\n", "output": "2\r\nmove 4 3\r\nmove ts7a1c 4\r\n"}, {"input": "5\r\n4 0\r\n3 1\r\n5 0\r\n2 1\r\n1 1\r\n", "output": "0\r\n"}, {"input": "5\r\n3 1\r\n5 0\r\n4 1\r\n1 1\r\n2 0\r\n", "output": "3\r\nmove 4 kmnhgt\r\nmove 2 4\r\nmove kmnhgt 2\r\n"}, {"input": "6\r\neik3kw 0\r\n5 1\r\nzoonoj 0\r\n2 1\r\n1 1\r\nivzfie 0\r\n", "output": "4\r\nmove 5 3\r\nmove eik3kw 6\r\nmove zoonoj 5\r\nmove ivzfie 4\r\n"}, {"input": "6\r\n7igwk9 0\r\n6 1\r\n5 1\r\ndx2yu0 0\r\n2 0\r\n1 1\r\n", "output": "5\r\nmove 6 3\r\nmove 2 6\r\nmove 5 2\r\nmove 7igwk9 5\r\nmove dx2yu0 4\r\n"}, {"input": "6\r\nc3py3h 0\r\n2 1\r\n4 0\r\n3 0\r\n1 1\r\n5 1\r\n", "output": "3\r\nmove 3 6\r\nmove 5 3\r\nmove c3py3h 5\r\n"}, {"input": "6\r\n1 1\r\n3 0\r\n2 1\r\n6 1\r\n4 0\r\n5 0\r\n", "output": "3\r\nmove 3 4r6zp7\r\nmove 6 3\r\nmove 4r6zp7 6\r\n"}, {"input": "20\r\nphp8vy 1\r\nkeeona 0\r\n8 0\r\nwzf4eb 0\r\n16 1\r\n9 0\r\nf2548d 0\r\n11 0\r\nyszsig 0\r\nyyf4q2 0\r\n1pon1p 1\r\njvpwuo 0\r\nd9stsx 0\r\ne14bkx 1\r\n5 0\r\n17 0\r\nsbklx4 0\r\nsfms2u 1\r\n6 0\r\n18 1\r\n", "output": "16\r\nmove 16 1\r\nmove 18 2\r\nmove 5 20\r\nmove 6 19\r\nmove php8vy 3\r\nmove 1pon1p 4\r\nmove e14bkx 5\r\nmove sfms2u 6\r\nmove keeona 18\r\nmove wzf4eb 16\r\nmove f2548d 15\r\nmove yszsig 14\r\nmove yyf4q2 13\r\nmove jvpwuo 12\r\nmove d9stsx 10\r\nmove sbklx4 7\r\n"}, {"input": "4\r\n3 1\r\n4 1\r\n1 0\r\n2 0\r\n", "output": "5\r\nmove 3 41nqph\r\nmove 1 3\r\nmove 4 1\r\nmove 2 4\r\nmove 41nqph 2\r\n"}, {"input": "1\r\n01 1\r\n", "output": "1\r\nmove 01 1\r\n"}, {"input": "2\r\n01 0\r\n02 1\r\n", "output": "2\r\nmove 02 1\r\nmove 01 2\r\n"}]
| false |
stdio
|
import sys
def main():
input_path = sys.argv[1]
output_path = sys.argv[2]
submission_path = sys.argv[3]
with open(input_path) as f:
n = int(f.readline())
files = []
type1_count = 0
for _ in range(n):
line = f.readline().strip()
name, typ = line.split()
files.append((name, typ))
if typ == '1':
type1_count += 1
e = type1_count
cnt = 0
valid_numbers = set()
for name, typ in files:
if name.isdigit() and (len(name) == 1 or name[0] != '0'):
num = int(name)
if 1 <= num <= n:
valid_numbers.add(num)
if typ == '1':
if not name.isdigit() or (len(name) > 1 and name[0] == '0'):
cnt += 1
continue
num = int(name)
if not (1 <= num <= e):
cnt += 1
else:
if not name.isdigit() or (len(name) > 1 and name[0] == '0'):
cnt += 1
continue
num = int(name)
if not (e + 1 <= num <= n):
cnt += 1
initial_free = n - len(valid_numbers)
minimal_steps = cnt + 1 if (initial_free == 0 and cnt > 0) else cnt
with open(submission_path) as f:
lines = f.read().splitlines()
if not lines:
print(0)
return
try:
k = int(lines[0])
except:
print(0)
return
if k != minimal_steps:
print(0)
return
moves = lines[1:]
if len(moves) != k:
print(0)
return
current_files = {name: typ for name, typ in files}
for move in moves:
parts = move.split()
if len(parts) != 3 or parts[0] != 'move':
print(0)
return
src, dst = parts[1], parts[2]
if src not in current_files:
print(0)
return
typ = current_files.pop(src)
current_files[dst] = typ
names = list(current_files.keys())
if len(names) != n:
print(0)
return
nums = []
for name in names:
if not name.isdigit() or (len(name) > 1 and name[0] == '0'):
print(0)
return
num = int(name)
if num < 1 or num > n:
print(0)
return
nums.append(num)
if sorted(nums) != list(range(1, n + 1)):
print(0)
return
for name, typ in current_files.items():
num = int(name)
if typ == '1' and num > e:
print(0)
return
if typ == '0' and num <= e:
print(0)
return
print(1)
if __name__ == "__main__":
main()
| true |
598/C
|
598
|
C
|
PyPy 3-64
|
TESTS
| 117 | 1,045 | 16,588,800 |
142613751
|
from math import atan2
arr = []
n = int(input())
for j in range(n):
x, y = [int(i) for i in input().split()]
arr += [(atan2(x, y), j)]
arr = sorted(arr)
gap = 10
for x, y in zip(arr, arr[1:] + [(arr[0][0] + 2*3.1415926, arr[0][1])]):
if abs(x[0] - y[0]) < gap:
gap = abs(x[0] - y[0])
ans = (x[1], y[1])
print(str(ans[0] + 1) + " " + str(ans[1] + 1))
| 163 | 1,699 | 26,009,600 |
154838623
|
import math
class Point:
def __init__(self, x, y):
self.x = x
self.y = y
def quad(self):
return self.y > 0 or (self.y == 0 and self.x > 0)
def len(self):
return self.x * self.x + self.y * self.y
def __lt__(self, other):
if self.quad() != other.quad():
return self.quad() < other.quad()
else:
return det(self, other) > 0
def __eq__(self, other):
return self.x == other.x and self.y == other.y
def det(a, b):
return a.x * b.y - a.y * b.x
def dot(a, b):
return a.x * b.x + a.y * b.y
n = int(input())
if n == 2:
print(1, 2)
exit(0)
v = []
for i in range(n):
x, y = list(map(int, input().split()))
v.append((Point(x, y), i + 1))
v.sort()
# for t in v:
# print(t[0].x, t[0].y, t[1])
def sgn(x):
if x == 0: return 0
if x > 0 : return 1
return -1
def check(p, i):
a, b, c, d = v[p][0], v[(p + 1) % len(v)][0], v[i][0], v[(i + 1) % len(v)][0]
if det(a, b) < 0:
a, b = b, a
if det(c, d) < 0:
c, d = d, c
if sgn(dot(a, b)) != sgn(dot(c, d)): return sgn(dot(c, d)) >= sgn(dot(a, b))
if sgn(dot(a, b)) == 0: return True
# print("??")
# print(dot(c, d) / math.sqrt(c.len()) / math.sqrt(d.len()), dot(a, b) / math.sqrt(a.len()) / math.sqrt(b.len()))
# print(dot(c, d) * dot(c, d) * a.len() * b.len(), dot(a, b) * dot(a, b) * c.len() * d.len())
if(sgn(dot(a, b)) > 0):
return dot(c, d) * dot(c, d) * a.len() * b.len() > dot(a, b) * dot(a, b) * c.len() * d.len()
else:
return dot(c, d) * dot(c, d) * a.len() * b.len() < dot(a, b) * dot(a, b) * c.len() * d.len()
p = 0
# print(check(0, 1))
for i in range(1, len(v)):
if check(p, i):
p = i
print(v[p][1], v[(p + 1) % len(v)][1])
|
Educational Codeforces Round 1
|
ICPC
| 2,015 | 2 | 256 |
Nearest vectors
|
You are given the set of vectors on the plane, each of them starting at the origin. Your task is to find a pair of vectors with the minimal non-oriented angle between them.
Non-oriented angle is non-negative value, minimal between clockwise and counterclockwise direction angles. Non-oriented angle is always between 0 and π. For example, opposite directions vectors have angle equals to π.
|
First line of the input contains a single integer n (2 ≤ n ≤ 100 000) — the number of vectors.
The i-th of the following n lines contains two integers xi and yi (|x|, |y| ≤ 10 000, x2 + y2 > 0) — the coordinates of the i-th vector. Vectors are numbered from 1 to n in order of appearing in the input. It is guaranteed that no two vectors in the input share the same direction (but they still can have opposite directions).
|
Print two integer numbers a and b (a ≠ b) — a pair of indices of vectors with the minimal non-oriented angle. You can print the numbers in any order. If there are many possible answers, print any.
| null | null |
[{"input": "4\n-1 0\n0 -1\n1 0\n1 1", "output": "3 4"}, {"input": "6\n-1 0\n0 -1\n1 0\n1 1\n-4 -5\n-4 -6", "output": "6 5"}]
| 2,300 |
["geometry", "sortings"]
| 163 |
[{"input": "4\r\n-1 0\r\n0 -1\r\n1 0\r\n1 1\r\n", "output": "3 4\r\n"}, {"input": "6\r\n-1 0\r\n0 -1\r\n1 0\r\n1 1\r\n-4 -5\r\n-4 -6\r\n", "output": "5 6\r\n"}, {"input": "10\r\n8 6\r\n-7 -3\r\n9 8\r\n7 10\r\n-3 -8\r\n3 7\r\n6 -8\r\n-9 8\r\n9 2\r\n6 7\r\n", "output": "1 3\r\n"}, {"input": "20\r\n-9 8\r\n-7 3\r\n0 10\r\n3 7\r\n6 -9\r\n6 8\r\n7 -6\r\n-6 10\r\n-10 3\r\n-8 -10\r\n10 -2\r\n1 -8\r\n-8 10\r\n10 10\r\n10 6\r\n-5 6\r\n5 -8\r\n5 -9\r\n-9 -1\r\n9 2\r\n", "output": "13 16\r\n"}, {"input": "2\r\n351 -4175\r\n-328 -657\r\n", "output": "2 1\r\n"}, {"input": "3\r\n620 -1189\r\n8101 -2770\r\n3347 3473\r\n", "output": "1 2\r\n"}, {"input": "4\r\n-7061 -5800\r\n-3471 -9470\r\n-7639 2529\r\n5657 -6522\r\n", "output": "1 2\r\n"}, {"input": "5\r\n-7519 -3395\r\n-32 -257\r\n-4827 -1889\r\n9545 -7037\r\n2767 583\r\n", "output": "3 1\r\n"}, {"input": "6\r\n-5120 -3251\r\n8269 -7984\r\n841 3396\r\n3136 -7551\r\n-1280 -3013\r\n-3263 -3278\r\n", "output": "1 6\r\n"}, {"input": "7\r\n-2722 6597\r\n-3303 200\r\n6508 -1021\r\n-1107 -1042\r\n6875 7616\r\n-3047 6749\r\n662 -1979\r\n", "output": "1 6\r\n"}, {"input": "8\r\n-36 749\r\n5126 943\r\n1165 533\r\n-1647 -5725\r\n5031 6532\r\n5956 8447\r\n2297 -2284\r\n1986 6937\r\n", "output": "5 6\r\n"}, {"input": "9\r\n-391 -1706\r\n995 -5756\r\n-5013 -154\r\n1121 3160\r\n-7111 8303\r\n-7303 -2414\r\n-7791 -935\r\n7576 -9361\r\n1072 203\r\n", "output": "3 7\r\n"}, {"input": "10\r\n-9920 -5477\r\n9691 -3200\r\n754 885\r\n-1895 1768\r\n-941 1588\r\n6293 -2631\r\n-2288 9129\r\n4067 696\r\n-6754 9869\r\n-5747 701\r\n", "output": "5 9\r\n"}, {"input": "2\r\n1 0\r\n-1 0\r\n", "output": "1 2\r\n"}, {"input": "2\r\n0 1\r\n0 -1\r\n", "output": "1 2\r\n"}, {"input": "2\r\n2131 -3249\r\n-2131 3249\r\n", "output": "2 1\r\n"}, {"input": "3\r\n-5 1\r\n-5 -1\r\n5 0\r\n", "output": "1 2\r\n"}, {"input": "3\r\n-100 1\r\n-100 -1\r\n0 100\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 10\r\n10 1\r\n10 -1\r\n", "output": "3 2\r\n"}, {"input": "3\r\n3 0\r\n0 3\r\n1 -3\r\n", "output": "3 1\r\n"}, {"input": "3\r\n1 1\r\n-1 0\r\n1 -1\r\n", "output": "3 1\r\n"}, {"input": "3\r\n-1 0\r\n10 -1\r\n1 0\r\n", "output": "2 3\r\n"}, {"input": "4\r\n1 10\r\n10 1\r\n-2 -2\r\n10 -1\r\n", "output": "4 2\r\n"}, {"input": "3\r\n-6 0\r\n6 1\r\n6 -1\r\n", "output": "3 2\r\n"}, {"input": "3\r\n114 1\r\n-514 0\r\n114 -1\r\n", "output": "3 1\r\n"}, {"input": "4\r\n-1 0\r\n0 -1\r\n-1 1\r\n1 0\r\n", "output": "3 1\r\n"}, {"input": "4\r\n2 1\r\n2 -1\r\n-1 1\r\n-1 -1\r\n", "output": "2 1\r\n"}, {"input": "3\r\n3 1\r\n3 -1\r\n0 3\r\n", "output": "2 1\r\n"}, {"input": "3\r\n1 1\r\n9000 1\r\n9000 -1\r\n", "output": "3 2\r\n"}, {"input": "3\r\n1 0\r\n-1 1\r\n-1 -1\r\n", "output": "2 3\r\n"}, {"input": "6\r\n1 1\r\n-1 -1\r\n0 20\r\n100 1\r\n-100 0\r\n100 -1\r\n", "output": "6 4\r\n"}, {"input": "4\r\n1 0\r\n0 1\r\n-1 0\r\n-13 -1\r\n", "output": "3 4\r\n"}, {"input": "3\r\n1 0\r\n-1 0\r\n1 -1\r\n", "output": "3 1\r\n"}, {"input": "3\r\n100 1\r\n-100 0\r\n100 -1\r\n", "output": "3 1\r\n"}, {"input": "3\r\n-100 1\r\n100 0\r\n-100 -1\r\n", "output": "1 3\r\n"}, {"input": "3\r\n1 100\r\n0 -100\r\n-1 100\r\n", "output": "1 3\r\n"}, {"input": "11\r\n-7945 386\r\n7504 -576\r\n-6020 -8277\r\n930 9737\r\n1682 474\r\n-8279 1197\r\n2790 2607\r\n-5514 -9601\r\n-3159 5939\r\n-1806 4207\r\n-9073 -2138\r\n", "output": "10 9\r\n"}, {"input": "3\r\n1 0\r\n10000 -1\r\n1 1\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-7125 -1643\r\n-1235 4071\r\n-75 -8717\r\n2553 9278\r\n", "output": "4 2\r\n"}, {"input": "5\r\n-6 0\r\n6 1\r\n6 -1\r\n0 6\r\n0 -6\r\n", "output": "3 2\r\n"}, {"input": "4\r\n5 5\r\n5 -5\r\n-555 1\r\n-555 -1\r\n", "output": "3 4\r\n"}, {"input": "4\r\n1 1\r\n-1 1\r\n-1 -1\r\n2 -1\r\n", "output": "4 1\r\n"}, {"input": "4\r\n-1 -100\r\n1 -100\r\n-100 -100\r\n100 -100\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 0\r\n1 -1\r\n-4 -6\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-1 -100\r\n1 -100\r\n100 -100\r\n-100 -100\r\n", "output": "1 2\r\n"}, {"input": "4\r\n-1 0\r\n0 -2\r\n-3 3\r\n4 0\r\n", "output": "3 1\r\n"}, {"input": "4\r\n-2 0\r\n0 -3\r\n-5 5\r\n4 0\r\n", "output": "3 1\r\n"}, {"input": "3\r\n1 -100\r\n0 100\r\n-1 -100\r\n", "output": "3 1\r\n"}, {"input": "5\r\n10000 2\r\n10000 -1\r\n10000 -5\r\n10000 -9\r\n10000 -13\r\n", "output": "2 1\r\n"}, {"input": "8\r\n-9580 8545\r\n-9379 -1139\r\n5824 -391\r\n-8722 2765\r\n-1357 -5547\r\n-7700 217\r\n9323 -7008\r\n957 -8356\r\n", "output": "6 2\r\n"}, {"input": "4\r\n5 5\r\n5 -5\r\n-500 1\r\n-500 -1\r\n", "output": "3 4\r\n"}, {"input": "3\r\n30 1\r\n30 -1\r\n0 30\r\n", "output": "2 1\r\n"}, {"input": "4\r\n3966 -1107\r\n8007 -5457\r\n-7753 4945\r\n-2209 -4221\r\n", "output": "2 1\r\n"}, {"input": "4\r\n1 9999\r\n0 1\r\n10000 0\r\n10000 -1\r\n", "output": "4 3\r\n"}, {"input": "3\r\n10000 1\r\n10000 -1\r\n-10000 0\r\n", "output": "2 1\r\n"}, {"input": "13\r\n1 2\r\n2 3\r\n3 4\r\n4 5\r\n5 6\r\n6 7\r\n7 8\r\n8 9\r\n9 10\r\n10 11\r\n11 12\r\n13 14\r\n12 13\r\n", "output": "12 13\r\n"}, {"input": "4\r\n2 1\r\n2 -1\r\n0 1\r\n-1 0\r\n", "output": "2 1\r\n"}, {"input": "4\r\n10 3\r\n10 -3\r\n-500 1\r\n-500 -1\r\n", "output": "3 4\r\n"}, {"input": "4\r\n1 10000\r\n-1 1\r\n10000 0\r\n10000 -1\r\n", "output": "4 3\r\n"}, {"input": "3\r\n0 1\r\n1 0\r\n1 -1\r\n", "output": "3 2\r\n"}, {"input": "3\r\n1 0\r\n0 1\r\n1 -1\r\n", "output": "3 1\r\n"}, {"input": "4\r\n1 1\r\n-1 1\r\n1 -2\r\n-1 -2\r\n", "output": "4 3\r\n"}, {"input": "4\r\n0 -1\r\n-1 0\r\n-1 1\r\n1 0\r\n", "output": "3 2\r\n"}, {"input": "3\r\n-100 1\r\n-100 -1\r\n1 1\r\n", "output": "1 2\r\n"}, {"input": "3\r\n-3 1\r\n-3 -1\r\n2 -3\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 -1\r\n1 0\r\n0 1\r\n", "output": "1 2\r\n"}, {"input": "5\r\n-5 1\r\n0 5\r\n4 1\r\n0 -4\r\n-5 -1\r\n", "output": "1 5\r\n"}, {"input": "4\r\n1 10000\r\n0 1\r\n10000 0\r\n9999 -1\r\n", "output": "1 2\r\n"}, {"input": "4\r\n2 3\r\n2 -3\r\n-3 2\r\n-3 -2\r\n", "output": "3 4\r\n"}, {"input": "3\r\n1 -3\r\n1 0\r\n0 1\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 0\r\n-1 0\r\n-1 -1\r\n", "output": "2 3\r\n"}, {"input": "4\r\n-2 1\r\n-2 -1\r\n1 1\r\n1 -1\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 -1\r\n-1 1\r\n-1 -2\r\n", "output": "3 1\r\n"}, {"input": "3\r\n1 0\r\n-1 -1\r\n1 -1\r\n", "output": "3 1\r\n"}, {"input": "3\r\n5 5\r\n-5 0\r\n5 -5\r\n", "output": "3 1\r\n"}, {"input": "4\r\n1 -2\r\n1 0\r\n-1 0\r\n10 -1\r\n", "output": "4 2\r\n"}, {"input": "3\r\n-1000 1\r\n-1000 -1\r\n1000 0\r\n", "output": "1 2\r\n"}, {"input": "6\r\n1 1\r\n1 -1\r\n-1 1\r\n-1 -1\r\n1 -10000\r\n-1 -10000\r\n", "output": "6 5\r\n"}, {"input": "3\r\n1 1\r\n-1 0\r\n0 -1\r\n", "output": "2 3\r\n"}, {"input": "4\r\n5000 1\r\n5000 -1\r\n-2 -1\r\n2 -1\r\n", "output": "2 1\r\n"}, {"input": "3\r\n1 0\r\n-1 1\r\n-1 -5\r\n", "output": "3 1\r\n"}, {"input": "3\r\n-5374 1323\r\n-4463 -8462\r\n6118 -7918\r\n", "output": "2 3\r\n"}, {"input": "4\r\n-6427 -6285\r\n-5386 -5267\r\n-3898 7239\r\n-3905 7252\r\n", "output": "4 3\r\n"}, {"input": "10\r\n-7 -3\r\n-2 8\r\n9 -9\r\n0 1\r\n4 5\r\n5 3\r\n-3 0\r\n10 2\r\n4 -1\r\n2 -10\r\n", "output": "4 2\r\n"}, {"input": "4\r\n9999 1\r\n9999 -1\r\n-9998 1\r\n-10000 -1\r\n", "output": "2 1\r\n"}, {"input": "4\r\n10000 9999\r\n9999 9998\r\n9998 9997\r\n9997 9996\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-6285 -6427\r\n-5267 -5386\r\n7239 -3898\r\n7252 -3905\r\n", "output": "3 4\r\n"}, {"input": "4\r\n-6427 6285\r\n-5386 5267\r\n3898 -7239\r\n3905 -7252\r\n", "output": "4 3\r\n"}, {"input": "4\r\n-6427 -6285\r\n-5386 -5267\r\n-3898 -7239\r\n-3905 -7252\r\n", "output": "3 4\r\n"}, {"input": "3\r\n0 1\r\n-1 -1\r\n1 -1\r\n", "output": "2 3\r\n"}, {"input": "4\r\n10000 1\r\n9998 -1\r\n-9999 1\r\n-9999 -1\r\n", "output": "3 4\r\n"}, {"input": "3\r\n100 0\r\n100 2\r\n100 -1\r\n", "output": "3 1\r\n"}, {"input": "3\r\n-1 1\r\n-1 -1\r\n1 0\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9844 9986\r\n181 9967\r\n-9812 -9925\r\n-194 -9900\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9800 9981\r\n61 9899\r\n-9926 -9932\r\n-149 -9926\r\n", "output": "3 4\r\n"}, {"input": "4\r\n-9901 9900\r\n-10000 9899\r\n9899 9801\r\n9899 9900\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9934 9989\r\n199 9949\r\n-9917 -9974\r\n-197 -9901\r\n", "output": "3 4\r\n"}, {"input": "3\r\n-1 1\r\n1 0\r\n-1 -1\r\n", "output": "1 3\r\n"}, {"input": "3\r\n1 1\r\n-10 -10\r\n-10 -9\r\n", "output": "3 2\r\n"}, {"input": "3\r\n1 0\r\n10000 -1\r\n-1 0\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9999 1\r\n9999 -1\r\n-10000 1\r\n-10000 -1\r\n", "output": "3 4\r\n"}, {"input": "3\r\n-5 1\r\n-5 -1\r\n1 0\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 0\r\n10000 1\r\n-1 0\r\n", "output": "1 2\r\n"}, {"input": "4\r\n-9990 9995\r\n9994 -9991\r\n-9999 -9992\r\n9993 9992\r\n", "output": "2 4\r\n"}, {"input": "8\r\n1 0\r\n1 1\r\n0 1\r\n-1 1\r\n-1 0\r\n-1 -1\r\n0 -1\r\n1 -2\r\n", "output": "7 8\r\n"}, {"input": "3\r\n-9930 9932\r\n9909 -9909\r\n-9932 -9931\r\n", "output": "3 2\r\n"}, {"input": "4\r\n9876 9977\r\n127 9938\r\n-9820 -9934\r\n-120 -9921\r\n", "output": "3 4\r\n"}, {"input": "3\r\n10000 -1\r\n-1 0\r\n0 -1\r\n", "output": "3 1\r\n"}, {"input": "4\r\n6427 -6285\r\n5386 -5267\r\n3898 7239\r\n3905 7252\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9811 9970\r\n155 9994\r\n-9826 -9977\r\n-159 -9986\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9851 9917\r\n74 9921\r\n-9855 -9916\r\n-77 -9984\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9826 9977\r\n159 9986\r\n-9811 -9970\r\n-155 -9994\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9849 9986\r\n148 9980\r\n-9800 -9999\r\n-116 -9927\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9822 9967\r\n111 9905\r\n-9943 -9986\r\n-163 -9953\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9959 9995\r\n113 9940\r\n-9965 -9931\r\n-148 -9945\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9851 9972\r\n153 9983\r\n-9866 -9926\r\n-183 -9946\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9816 -9979\r\n127 -9940\r\n-9876 9915\r\n-190 9978\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9887 -9917\r\n138 -9977\r\n-9826 9995\r\n-68 9971\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9936 -9965\r\n135 -9949\r\n-9928 9980\r\n-123 9908\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9981 -9985\r\n191 -9956\r\n-9893 9937\r\n-171 9962\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-9811 9970\r\n-155 9994\r\n9826 -9977\r\n159 -9986\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9808 9899\r\n179 9966\r\n-9870 -9961\r\n-179 -9950\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9815 -9936\r\n168 -9937\r\n-9896 9995\r\n-180 9969\r\n", "output": "2 1\r\n"}, {"input": "4\r\n1 1\r\n1 -1\r\n-100 1\r\n-100 -1\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9965 114\r\n87 9916\r\n-9957 -106\r\n-95 -9929\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9895 -9949\r\n188 -9978\r\n-9810 9935\r\n-151 9914\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-9957 106\r\n-95 9929\r\n9965 -114\r\n87 -9916\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-9862 9980\r\n-174 9917\r\n9845 -9967\r\n173 -9980\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9944 9926\r\n9927 9935\r\n-9961 -9929\r\n-9997 -9991\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9917 9909\r\n196 9925\r\n-9971 -9991\r\n-183 -9977\r\n", "output": "3 4\r\n"}]
| false |
stdio
|
import sys
import math
def read_vectors(input_path):
with open(input_path) as f:
n = int(f.readline())
vectors = []
for i in range(n):
x, y = map(int, f.readline().split())
vectors.append( (x, y, i+1) )
return vectors
def compute_angle(x, y):
return math.atan2(y, x) % (2 * math.pi)
def compute_non_oriented_angle(u, v):
ux, uy = u
vx, vy = v
dot = ux * vx + uy * vy
mag_u = math.hypot(ux, uy)
mag_v = math.hypot(vx, vy)
if mag_u == 0 or mag_v == 0:
return 0.0
cos_theta = dot / (mag_u * mag_v)
cos_theta = max(min(cos_theta, 1.0), -1.0)
return math.acos(cos_theta)
def find_min_angle(vectors):
sorted_vectors = sorted(vectors, key=lambda vec: compute_angle(vec[0], vec[1]))
n = len(sorted_vectors)
min_adjacent = math.pi
for i in range(n):
j = (i + 1) % n
u = sorted_vectors[i][0], sorted_vectors[i][1]
v = sorted_vectors[j][0], sorted_vectors[j][1]
theta = compute_non_oriented_angle(u, v)
if theta < min_adjacent:
min_adjacent = theta
angles = []
for vec in sorted_vectors:
x, y, idx = vec
angles.append( compute_angle(x, y) )
min_opposite = math.pi
for i in range(n):
theta_i = angles[i]
target = (theta_i + math.pi) % (2 * math.pi)
low = 0
high = n
while low < high:
mid = (low + high) // 2
if angles[mid] < target:
low = mid + 1
else:
high = mid
candidates = []
if low > 0:
candidates.append(low-1)
if low < n:
candidates.append(low)
candidates.append((low - 1) % n)
candidates = list(set(candidates))
for c in candidates:
if c == i:
continue
c = c % n
vec_c = sorted_vectors[c]
u = sorted_vectors[i][0], sorted_vectors[i][1]
v = vec_c[0], vec_c[1]
current_theta = compute_non_oriented_angle(u, v)
if current_theta < min_opposite:
min_opposite = current_theta
return min(min_adjacent, min_opposite)
def main(input_path, output_path, submission_output_path):
input_vectors = read_vectors(input_path)
with open(submission_output_path) as f:
line = f.readline().strip()
try:
a, b = map(int, line.split())
except:
print(0)
return
n = len(input_vectors)
if a < 1 or a > n or b < 1 or b > n or a == b:
print(0)
return
vec_a = None
vec_b = None
for vec in input_vectors:
if vec[2] == a:
vec_a = vec
if vec[2] == b:
vec_b = vec
if vec_a is None or vec_b is None:
print(0)
return
u = (vec_a[0], vec_a[1])
v = (vec_b[0], vec_b[1])
theta = compute_non_oriented_angle(u, v)
min_angle = find_min_angle(input_vectors)
epsilon = 1e-9
if abs(theta - min_angle) <= epsilon:
print(1)
else:
print(0)
if __name__ == "__main__":
input_path = sys.argv[1]
output_path = sys.argv[2]
submission_output_path = sys.argv[3]
main(input_path, output_path, submission_output_path)
| true |
598/C
|
598
|
C
|
PyPy 3
|
TESTS
| 113 | 483 | 10,547,200 |
168322502
|
import sys
readline=sys.stdin.readline
import math
class Vector2():
def __init__(self,x,y):
self.x=x
self.y=y
def __lt__(self,other):
if (other.y,other.x)<(0,0)<(self.y,self.x):
return True
if (self.y,self.x)<(0,0)<(other.y,other.x):
return False
return 0<self.x*other.y-self.y*other.x
def __str__(self):
return ("("+str(self.x)+", "+str(self.y)+")")
N=int(readline())
P=[]
dct={}
for i in range(1,N+1):
x,y=map(int,readline().split())
P.append((math.atan2(y,x),i))
P.sort()
c=10
idx=None
for i in range(N):
p,_=P[i]
pp,_=P[(i+1)%N]
cc=abs(p-pp)
cc=min(cc,math.pi*2-cc)
if c>cc:
idx=i
c=cc
print(P[idx][1],P[(idx+1)%N][1])
| 163 | 779 | 41,369,600 |
175306822
|
from sys import stdin
input=lambda :stdin.readline()[:-1]
def compare(a,b):
# 比較関数 (a<=b)
# 偏角ソート
ax, ay = a[:2]
bx, by = b[:2]
if ay < 0:
return by >= 0 or ax * by - ay * bx > 0
if ay == 0:
return ax >= 0 and (by > 0 or (by == 0 and bx < 0))
return by >= 0 and (ax * by - ay * bx) > 0
def merge(l, r):
new = []
ln = 0
rn = 0
while ln < len(l) and rn < len(r):
if compare(l[ln],r[rn]):
new.append(l[ln])
ln += 1
else:
new.append(r[rn])
rn += 1
for i in range(ln, len(l)):
new.append(l[i])
for i in range(rn, len(r)):
new.append(r[i])
return new
def MergeSort(l):
if len(l) == 0:
return []
if len(l) == 1:
return l
else:
a = l[:len(l)//2]
b = l[len(l)//2:]
return merge(MergeSort(a), MergeSort(b))
n=int(input())
xy=[]
for i in range(n):
x,y=map(int,input().split())
xy.append((x,y,i))
xy=MergeSort(xy)
def cos(i,j):
xi,yi=xy[i][:2]
xj,yj=xy[j][:2]
den=(xi*xi+yi*yi)*(xj*xj+yj*yj)
num=xi*xj+yi*yj
if num>=0:
return 1,num**2,den
else:
return -1,num**2,den
def comp(sgn1,num1,den1,sgn2,num2,den2):
# return 1>=2
if sgn1>sgn2:
return True
if sgn1<sgn2:
return False
if sgn1==1:
return num1*den2>=den1*num2
else:
return num1*den2<=den1*num2
sgn,num,den=-1,1,1
for i in range(n):
j=(i+1)%n
sgn1,num1,den1=cos(i,j)
if comp(sgn1,num1,den1,sgn,num,den):
ans1=xy[i][2]
ans2=xy[j][2]
sgn,num,den=sgn1,num1,den1
print(ans1+1,ans2+1)
|
Educational Codeforces Round 1
|
ICPC
| 2,015 | 2 | 256 |
Nearest vectors
|
You are given the set of vectors on the plane, each of them starting at the origin. Your task is to find a pair of vectors with the minimal non-oriented angle between them.
Non-oriented angle is non-negative value, minimal between clockwise and counterclockwise direction angles. Non-oriented angle is always between 0 and π. For example, opposite directions vectors have angle equals to π.
|
First line of the input contains a single integer n (2 ≤ n ≤ 100 000) — the number of vectors.
The i-th of the following n lines contains two integers xi and yi (|x|, |y| ≤ 10 000, x2 + y2 > 0) — the coordinates of the i-th vector. Vectors are numbered from 1 to n in order of appearing in the input. It is guaranteed that no two vectors in the input share the same direction (but they still can have opposite directions).
|
Print two integer numbers a and b (a ≠ b) — a pair of indices of vectors with the minimal non-oriented angle. You can print the numbers in any order. If there are many possible answers, print any.
| null | null |
[{"input": "4\n-1 0\n0 -1\n1 0\n1 1", "output": "3 4"}, {"input": "6\n-1 0\n0 -1\n1 0\n1 1\n-4 -5\n-4 -6", "output": "6 5"}]
| 2,300 |
["geometry", "sortings"]
| 163 |
[{"input": "4\r\n-1 0\r\n0 -1\r\n1 0\r\n1 1\r\n", "output": "3 4\r\n"}, {"input": "6\r\n-1 0\r\n0 -1\r\n1 0\r\n1 1\r\n-4 -5\r\n-4 -6\r\n", "output": "5 6\r\n"}, {"input": "10\r\n8 6\r\n-7 -3\r\n9 8\r\n7 10\r\n-3 -8\r\n3 7\r\n6 -8\r\n-9 8\r\n9 2\r\n6 7\r\n", "output": "1 3\r\n"}, {"input": "20\r\n-9 8\r\n-7 3\r\n0 10\r\n3 7\r\n6 -9\r\n6 8\r\n7 -6\r\n-6 10\r\n-10 3\r\n-8 -10\r\n10 -2\r\n1 -8\r\n-8 10\r\n10 10\r\n10 6\r\n-5 6\r\n5 -8\r\n5 -9\r\n-9 -1\r\n9 2\r\n", "output": "13 16\r\n"}, {"input": "2\r\n351 -4175\r\n-328 -657\r\n", "output": "2 1\r\n"}, {"input": "3\r\n620 -1189\r\n8101 -2770\r\n3347 3473\r\n", "output": "1 2\r\n"}, {"input": "4\r\n-7061 -5800\r\n-3471 -9470\r\n-7639 2529\r\n5657 -6522\r\n", "output": "1 2\r\n"}, {"input": "5\r\n-7519 -3395\r\n-32 -257\r\n-4827 -1889\r\n9545 -7037\r\n2767 583\r\n", "output": "3 1\r\n"}, {"input": "6\r\n-5120 -3251\r\n8269 -7984\r\n841 3396\r\n3136 -7551\r\n-1280 -3013\r\n-3263 -3278\r\n", "output": "1 6\r\n"}, {"input": "7\r\n-2722 6597\r\n-3303 200\r\n6508 -1021\r\n-1107 -1042\r\n6875 7616\r\n-3047 6749\r\n662 -1979\r\n", "output": "1 6\r\n"}, {"input": "8\r\n-36 749\r\n5126 943\r\n1165 533\r\n-1647 -5725\r\n5031 6532\r\n5956 8447\r\n2297 -2284\r\n1986 6937\r\n", "output": "5 6\r\n"}, {"input": "9\r\n-391 -1706\r\n995 -5756\r\n-5013 -154\r\n1121 3160\r\n-7111 8303\r\n-7303 -2414\r\n-7791 -935\r\n7576 -9361\r\n1072 203\r\n", "output": "3 7\r\n"}, {"input": "10\r\n-9920 -5477\r\n9691 -3200\r\n754 885\r\n-1895 1768\r\n-941 1588\r\n6293 -2631\r\n-2288 9129\r\n4067 696\r\n-6754 9869\r\n-5747 701\r\n", "output": "5 9\r\n"}, {"input": "2\r\n1 0\r\n-1 0\r\n", "output": "1 2\r\n"}, {"input": "2\r\n0 1\r\n0 -1\r\n", "output": "1 2\r\n"}, {"input": "2\r\n2131 -3249\r\n-2131 3249\r\n", "output": "2 1\r\n"}, {"input": "3\r\n-5 1\r\n-5 -1\r\n5 0\r\n", "output": "1 2\r\n"}, {"input": "3\r\n-100 1\r\n-100 -1\r\n0 100\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 10\r\n10 1\r\n10 -1\r\n", "output": "3 2\r\n"}, {"input": "3\r\n3 0\r\n0 3\r\n1 -3\r\n", "output": "3 1\r\n"}, {"input": "3\r\n1 1\r\n-1 0\r\n1 -1\r\n", "output": "3 1\r\n"}, {"input": "3\r\n-1 0\r\n10 -1\r\n1 0\r\n", "output": "2 3\r\n"}, {"input": "4\r\n1 10\r\n10 1\r\n-2 -2\r\n10 -1\r\n", "output": "4 2\r\n"}, {"input": "3\r\n-6 0\r\n6 1\r\n6 -1\r\n", "output": "3 2\r\n"}, {"input": "3\r\n114 1\r\n-514 0\r\n114 -1\r\n", "output": "3 1\r\n"}, {"input": "4\r\n-1 0\r\n0 -1\r\n-1 1\r\n1 0\r\n", "output": "3 1\r\n"}, {"input": "4\r\n2 1\r\n2 -1\r\n-1 1\r\n-1 -1\r\n", "output": "2 1\r\n"}, {"input": "3\r\n3 1\r\n3 -1\r\n0 3\r\n", "output": "2 1\r\n"}, {"input": "3\r\n1 1\r\n9000 1\r\n9000 -1\r\n", "output": "3 2\r\n"}, {"input": "3\r\n1 0\r\n-1 1\r\n-1 -1\r\n", "output": "2 3\r\n"}, {"input": "6\r\n1 1\r\n-1 -1\r\n0 20\r\n100 1\r\n-100 0\r\n100 -1\r\n", "output": "6 4\r\n"}, {"input": "4\r\n1 0\r\n0 1\r\n-1 0\r\n-13 -1\r\n", "output": "3 4\r\n"}, {"input": "3\r\n1 0\r\n-1 0\r\n1 -1\r\n", "output": "3 1\r\n"}, {"input": "3\r\n100 1\r\n-100 0\r\n100 -1\r\n", "output": "3 1\r\n"}, {"input": "3\r\n-100 1\r\n100 0\r\n-100 -1\r\n", "output": "1 3\r\n"}, {"input": "3\r\n1 100\r\n0 -100\r\n-1 100\r\n", "output": "1 3\r\n"}, {"input": "11\r\n-7945 386\r\n7504 -576\r\n-6020 -8277\r\n930 9737\r\n1682 474\r\n-8279 1197\r\n2790 2607\r\n-5514 -9601\r\n-3159 5939\r\n-1806 4207\r\n-9073 -2138\r\n", "output": "10 9\r\n"}, {"input": "3\r\n1 0\r\n10000 -1\r\n1 1\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-7125 -1643\r\n-1235 4071\r\n-75 -8717\r\n2553 9278\r\n", "output": "4 2\r\n"}, {"input": "5\r\n-6 0\r\n6 1\r\n6 -1\r\n0 6\r\n0 -6\r\n", "output": "3 2\r\n"}, {"input": "4\r\n5 5\r\n5 -5\r\n-555 1\r\n-555 -1\r\n", "output": "3 4\r\n"}, {"input": "4\r\n1 1\r\n-1 1\r\n-1 -1\r\n2 -1\r\n", "output": "4 1\r\n"}, {"input": "4\r\n-1 -100\r\n1 -100\r\n-100 -100\r\n100 -100\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 0\r\n1 -1\r\n-4 -6\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-1 -100\r\n1 -100\r\n100 -100\r\n-100 -100\r\n", "output": "1 2\r\n"}, {"input": "4\r\n-1 0\r\n0 -2\r\n-3 3\r\n4 0\r\n", "output": "3 1\r\n"}, {"input": "4\r\n-2 0\r\n0 -3\r\n-5 5\r\n4 0\r\n", "output": "3 1\r\n"}, {"input": "3\r\n1 -100\r\n0 100\r\n-1 -100\r\n", "output": "3 1\r\n"}, {"input": "5\r\n10000 2\r\n10000 -1\r\n10000 -5\r\n10000 -9\r\n10000 -13\r\n", "output": "2 1\r\n"}, {"input": "8\r\n-9580 8545\r\n-9379 -1139\r\n5824 -391\r\n-8722 2765\r\n-1357 -5547\r\n-7700 217\r\n9323 -7008\r\n957 -8356\r\n", "output": "6 2\r\n"}, {"input": "4\r\n5 5\r\n5 -5\r\n-500 1\r\n-500 -1\r\n", "output": "3 4\r\n"}, {"input": "3\r\n30 1\r\n30 -1\r\n0 30\r\n", "output": "2 1\r\n"}, {"input": "4\r\n3966 -1107\r\n8007 -5457\r\n-7753 4945\r\n-2209 -4221\r\n", "output": "2 1\r\n"}, {"input": "4\r\n1 9999\r\n0 1\r\n10000 0\r\n10000 -1\r\n", "output": "4 3\r\n"}, {"input": "3\r\n10000 1\r\n10000 -1\r\n-10000 0\r\n", "output": "2 1\r\n"}, {"input": "13\r\n1 2\r\n2 3\r\n3 4\r\n4 5\r\n5 6\r\n6 7\r\n7 8\r\n8 9\r\n9 10\r\n10 11\r\n11 12\r\n13 14\r\n12 13\r\n", "output": "12 13\r\n"}, {"input": "4\r\n2 1\r\n2 -1\r\n0 1\r\n-1 0\r\n", "output": "2 1\r\n"}, {"input": "4\r\n10 3\r\n10 -3\r\n-500 1\r\n-500 -1\r\n", "output": "3 4\r\n"}, {"input": "4\r\n1 10000\r\n-1 1\r\n10000 0\r\n10000 -1\r\n", "output": "4 3\r\n"}, {"input": "3\r\n0 1\r\n1 0\r\n1 -1\r\n", "output": "3 2\r\n"}, {"input": "3\r\n1 0\r\n0 1\r\n1 -1\r\n", "output": "3 1\r\n"}, {"input": "4\r\n1 1\r\n-1 1\r\n1 -2\r\n-1 -2\r\n", "output": "4 3\r\n"}, {"input": "4\r\n0 -1\r\n-1 0\r\n-1 1\r\n1 0\r\n", "output": "3 2\r\n"}, {"input": "3\r\n-100 1\r\n-100 -1\r\n1 1\r\n", "output": "1 2\r\n"}, {"input": "3\r\n-3 1\r\n-3 -1\r\n2 -3\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 -1\r\n1 0\r\n0 1\r\n", "output": "1 2\r\n"}, {"input": "5\r\n-5 1\r\n0 5\r\n4 1\r\n0 -4\r\n-5 -1\r\n", "output": "1 5\r\n"}, {"input": "4\r\n1 10000\r\n0 1\r\n10000 0\r\n9999 -1\r\n", "output": "1 2\r\n"}, {"input": "4\r\n2 3\r\n2 -3\r\n-3 2\r\n-3 -2\r\n", "output": "3 4\r\n"}, {"input": "3\r\n1 -3\r\n1 0\r\n0 1\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 0\r\n-1 0\r\n-1 -1\r\n", "output": "2 3\r\n"}, {"input": "4\r\n-2 1\r\n-2 -1\r\n1 1\r\n1 -1\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 -1\r\n-1 1\r\n-1 -2\r\n", "output": "3 1\r\n"}, {"input": "3\r\n1 0\r\n-1 -1\r\n1 -1\r\n", "output": "3 1\r\n"}, {"input": "3\r\n5 5\r\n-5 0\r\n5 -5\r\n", "output": "3 1\r\n"}, {"input": "4\r\n1 -2\r\n1 0\r\n-1 0\r\n10 -1\r\n", "output": "4 2\r\n"}, {"input": "3\r\n-1000 1\r\n-1000 -1\r\n1000 0\r\n", "output": "1 2\r\n"}, {"input": "6\r\n1 1\r\n1 -1\r\n-1 1\r\n-1 -1\r\n1 -10000\r\n-1 -10000\r\n", "output": "6 5\r\n"}, {"input": "3\r\n1 1\r\n-1 0\r\n0 -1\r\n", "output": "2 3\r\n"}, {"input": "4\r\n5000 1\r\n5000 -1\r\n-2 -1\r\n2 -1\r\n", "output": "2 1\r\n"}, {"input": "3\r\n1 0\r\n-1 1\r\n-1 -5\r\n", "output": "3 1\r\n"}, {"input": "3\r\n-5374 1323\r\n-4463 -8462\r\n6118 -7918\r\n", "output": "2 3\r\n"}, {"input": "4\r\n-6427 -6285\r\n-5386 -5267\r\n-3898 7239\r\n-3905 7252\r\n", "output": "4 3\r\n"}, {"input": "10\r\n-7 -3\r\n-2 8\r\n9 -9\r\n0 1\r\n4 5\r\n5 3\r\n-3 0\r\n10 2\r\n4 -1\r\n2 -10\r\n", "output": "4 2\r\n"}, {"input": "4\r\n9999 1\r\n9999 -1\r\n-9998 1\r\n-10000 -1\r\n", "output": "2 1\r\n"}, {"input": "4\r\n10000 9999\r\n9999 9998\r\n9998 9997\r\n9997 9996\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-6285 -6427\r\n-5267 -5386\r\n7239 -3898\r\n7252 -3905\r\n", "output": "3 4\r\n"}, {"input": "4\r\n-6427 6285\r\n-5386 5267\r\n3898 -7239\r\n3905 -7252\r\n", "output": "4 3\r\n"}, {"input": "4\r\n-6427 -6285\r\n-5386 -5267\r\n-3898 -7239\r\n-3905 -7252\r\n", "output": "3 4\r\n"}, {"input": "3\r\n0 1\r\n-1 -1\r\n1 -1\r\n", "output": "2 3\r\n"}, {"input": "4\r\n10000 1\r\n9998 -1\r\n-9999 1\r\n-9999 -1\r\n", "output": "3 4\r\n"}, {"input": "3\r\n100 0\r\n100 2\r\n100 -1\r\n", "output": "3 1\r\n"}, {"input": "3\r\n-1 1\r\n-1 -1\r\n1 0\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9844 9986\r\n181 9967\r\n-9812 -9925\r\n-194 -9900\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9800 9981\r\n61 9899\r\n-9926 -9932\r\n-149 -9926\r\n", "output": "3 4\r\n"}, {"input": "4\r\n-9901 9900\r\n-10000 9899\r\n9899 9801\r\n9899 9900\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9934 9989\r\n199 9949\r\n-9917 -9974\r\n-197 -9901\r\n", "output": "3 4\r\n"}, {"input": "3\r\n-1 1\r\n1 0\r\n-1 -1\r\n", "output": "1 3\r\n"}, {"input": "3\r\n1 1\r\n-10 -10\r\n-10 -9\r\n", "output": "3 2\r\n"}, {"input": "3\r\n1 0\r\n10000 -1\r\n-1 0\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9999 1\r\n9999 -1\r\n-10000 1\r\n-10000 -1\r\n", "output": "3 4\r\n"}, {"input": "3\r\n-5 1\r\n-5 -1\r\n1 0\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 0\r\n10000 1\r\n-1 0\r\n", "output": "1 2\r\n"}, {"input": "4\r\n-9990 9995\r\n9994 -9991\r\n-9999 -9992\r\n9993 9992\r\n", "output": "2 4\r\n"}, {"input": "8\r\n1 0\r\n1 1\r\n0 1\r\n-1 1\r\n-1 0\r\n-1 -1\r\n0 -1\r\n1 -2\r\n", "output": "7 8\r\n"}, {"input": "3\r\n-9930 9932\r\n9909 -9909\r\n-9932 -9931\r\n", "output": "3 2\r\n"}, {"input": "4\r\n9876 9977\r\n127 9938\r\n-9820 -9934\r\n-120 -9921\r\n", "output": "3 4\r\n"}, {"input": "3\r\n10000 -1\r\n-1 0\r\n0 -1\r\n", "output": "3 1\r\n"}, {"input": "4\r\n6427 -6285\r\n5386 -5267\r\n3898 7239\r\n3905 7252\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9811 9970\r\n155 9994\r\n-9826 -9977\r\n-159 -9986\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9851 9917\r\n74 9921\r\n-9855 -9916\r\n-77 -9984\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9826 9977\r\n159 9986\r\n-9811 -9970\r\n-155 -9994\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9849 9986\r\n148 9980\r\n-9800 -9999\r\n-116 -9927\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9822 9967\r\n111 9905\r\n-9943 -9986\r\n-163 -9953\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9959 9995\r\n113 9940\r\n-9965 -9931\r\n-148 -9945\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9851 9972\r\n153 9983\r\n-9866 -9926\r\n-183 -9946\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9816 -9979\r\n127 -9940\r\n-9876 9915\r\n-190 9978\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9887 -9917\r\n138 -9977\r\n-9826 9995\r\n-68 9971\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9936 -9965\r\n135 -9949\r\n-9928 9980\r\n-123 9908\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9981 -9985\r\n191 -9956\r\n-9893 9937\r\n-171 9962\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-9811 9970\r\n-155 9994\r\n9826 -9977\r\n159 -9986\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9808 9899\r\n179 9966\r\n-9870 -9961\r\n-179 -9950\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9815 -9936\r\n168 -9937\r\n-9896 9995\r\n-180 9969\r\n", "output": "2 1\r\n"}, {"input": "4\r\n1 1\r\n1 -1\r\n-100 1\r\n-100 -1\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9965 114\r\n87 9916\r\n-9957 -106\r\n-95 -9929\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9895 -9949\r\n188 -9978\r\n-9810 9935\r\n-151 9914\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-9957 106\r\n-95 9929\r\n9965 -114\r\n87 -9916\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-9862 9980\r\n-174 9917\r\n9845 -9967\r\n173 -9980\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9944 9926\r\n9927 9935\r\n-9961 -9929\r\n-9997 -9991\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9917 9909\r\n196 9925\r\n-9971 -9991\r\n-183 -9977\r\n", "output": "3 4\r\n"}]
| false |
stdio
|
import sys
import math
def read_vectors(input_path):
with open(input_path) as f:
n = int(f.readline())
vectors = []
for i in range(n):
x, y = map(int, f.readline().split())
vectors.append( (x, y, i+1) )
return vectors
def compute_angle(x, y):
return math.atan2(y, x) % (2 * math.pi)
def compute_non_oriented_angle(u, v):
ux, uy = u
vx, vy = v
dot = ux * vx + uy * vy
mag_u = math.hypot(ux, uy)
mag_v = math.hypot(vx, vy)
if mag_u == 0 or mag_v == 0:
return 0.0
cos_theta = dot / (mag_u * mag_v)
cos_theta = max(min(cos_theta, 1.0), -1.0)
return math.acos(cos_theta)
def find_min_angle(vectors):
sorted_vectors = sorted(vectors, key=lambda vec: compute_angle(vec[0], vec[1]))
n = len(sorted_vectors)
min_adjacent = math.pi
for i in range(n):
j = (i + 1) % n
u = sorted_vectors[i][0], sorted_vectors[i][1]
v = sorted_vectors[j][0], sorted_vectors[j][1]
theta = compute_non_oriented_angle(u, v)
if theta < min_adjacent:
min_adjacent = theta
angles = []
for vec in sorted_vectors:
x, y, idx = vec
angles.append( compute_angle(x, y) )
min_opposite = math.pi
for i in range(n):
theta_i = angles[i]
target = (theta_i + math.pi) % (2 * math.pi)
low = 0
high = n
while low < high:
mid = (low + high) // 2
if angles[mid] < target:
low = mid + 1
else:
high = mid
candidates = []
if low > 0:
candidates.append(low-1)
if low < n:
candidates.append(low)
candidates.append((low - 1) % n)
candidates = list(set(candidates))
for c in candidates:
if c == i:
continue
c = c % n
vec_c = sorted_vectors[c]
u = sorted_vectors[i][0], sorted_vectors[i][1]
v = vec_c[0], vec_c[1]
current_theta = compute_non_oriented_angle(u, v)
if current_theta < min_opposite:
min_opposite = current_theta
return min(min_adjacent, min_opposite)
def main(input_path, output_path, submission_output_path):
input_vectors = read_vectors(input_path)
with open(submission_output_path) as f:
line = f.readline().strip()
try:
a, b = map(int, line.split())
except:
print(0)
return
n = len(input_vectors)
if a < 1 or a > n or b < 1 or b > n or a == b:
print(0)
return
vec_a = None
vec_b = None
for vec in input_vectors:
if vec[2] == a:
vec_a = vec
if vec[2] == b:
vec_b = vec
if vec_a is None or vec_b is None:
print(0)
return
u = (vec_a[0], vec_a[1])
v = (vec_b[0], vec_b[1])
theta = compute_non_oriented_angle(u, v)
min_angle = find_min_angle(input_vectors)
epsilon = 1e-9
if abs(theta - min_angle) <= epsilon:
print(1)
else:
print(0)
if __name__ == "__main__":
input_path = sys.argv[1]
output_path = sys.argv[2]
submission_output_path = sys.argv[3]
main(input_path, output_path, submission_output_path)
| true |
598/C
|
598
|
C
|
PyPy 3-64
|
TESTS
| 118 | 1,419 | 14,950,400 |
202054936
|
# https://codeforces.com/contest/598/problem/C
from math import atan2, pi
def diff(angle1, angle2):
delta = abs(angle1 - angle2)
return delta if delta <= pi else 2 * pi - delta
n = int(input())
vecs = []
for i in range(1, n + 1):
x, y = map(int, input().split())
angle = atan2(y, x)
if angle < 0:
angle += 2 * pi
vecs.append((angle, i))
vecs.sort()
j_min = 0
delta_min = diff(vecs[-1][0], vecs[0][0])
for j in range(1, n):
delta = diff(vecs[j][0], vecs[j - 1][0])
if delta < delta_min:
j_min = j
delta_min = delta
print(vecs[j_min][1], vecs[j_min - 1][1])
| 163 | 1,060 | 35,328,000 |
154855646
|
from math import atan2
s = lambda a, b: a[0] * b[0] + a[1] * b[1]
v = lambda a, b: a[0] * b[1] - a[1] * b[0]
p = []
for i in range(int(input())):
x, y = map(int, input().split())
p.append((atan2(x, y), (x, y), i + 1))
p.sort()
d = [(s(a, b), abs(v(a, b)), i, j) for (x, a, i), (y, b, j) in zip(p, p[1:] + p[:1])]
x = d[0]
for y in d:
if v(y[:2], x[:2]) > 0: x = y
print(x[2], x[3])
|
Educational Codeforces Round 1
|
ICPC
| 2,015 | 2 | 256 |
Nearest vectors
|
You are given the set of vectors on the plane, each of them starting at the origin. Your task is to find a pair of vectors with the minimal non-oriented angle between them.
Non-oriented angle is non-negative value, minimal between clockwise and counterclockwise direction angles. Non-oriented angle is always between 0 and π. For example, opposite directions vectors have angle equals to π.
|
First line of the input contains a single integer n (2 ≤ n ≤ 100 000) — the number of vectors.
The i-th of the following n lines contains two integers xi and yi (|x|, |y| ≤ 10 000, x2 + y2 > 0) — the coordinates of the i-th vector. Vectors are numbered from 1 to n in order of appearing in the input. It is guaranteed that no two vectors in the input share the same direction (but they still can have opposite directions).
|
Print two integer numbers a and b (a ≠ b) — a pair of indices of vectors with the minimal non-oriented angle. You can print the numbers in any order. If there are many possible answers, print any.
| null | null |
[{"input": "4\n-1 0\n0 -1\n1 0\n1 1", "output": "3 4"}, {"input": "6\n-1 0\n0 -1\n1 0\n1 1\n-4 -5\n-4 -6", "output": "6 5"}]
| 2,300 |
["geometry", "sortings"]
| 163 |
[{"input": "4\r\n-1 0\r\n0 -1\r\n1 0\r\n1 1\r\n", "output": "3 4\r\n"}, {"input": "6\r\n-1 0\r\n0 -1\r\n1 0\r\n1 1\r\n-4 -5\r\n-4 -6\r\n", "output": "5 6\r\n"}, {"input": "10\r\n8 6\r\n-7 -3\r\n9 8\r\n7 10\r\n-3 -8\r\n3 7\r\n6 -8\r\n-9 8\r\n9 2\r\n6 7\r\n", "output": "1 3\r\n"}, {"input": "20\r\n-9 8\r\n-7 3\r\n0 10\r\n3 7\r\n6 -9\r\n6 8\r\n7 -6\r\n-6 10\r\n-10 3\r\n-8 -10\r\n10 -2\r\n1 -8\r\n-8 10\r\n10 10\r\n10 6\r\n-5 6\r\n5 -8\r\n5 -9\r\n-9 -1\r\n9 2\r\n", "output": "13 16\r\n"}, {"input": "2\r\n351 -4175\r\n-328 -657\r\n", "output": "2 1\r\n"}, {"input": "3\r\n620 -1189\r\n8101 -2770\r\n3347 3473\r\n", "output": "1 2\r\n"}, {"input": "4\r\n-7061 -5800\r\n-3471 -9470\r\n-7639 2529\r\n5657 -6522\r\n", "output": "1 2\r\n"}, {"input": "5\r\n-7519 -3395\r\n-32 -257\r\n-4827 -1889\r\n9545 -7037\r\n2767 583\r\n", "output": "3 1\r\n"}, {"input": "6\r\n-5120 -3251\r\n8269 -7984\r\n841 3396\r\n3136 -7551\r\n-1280 -3013\r\n-3263 -3278\r\n", "output": "1 6\r\n"}, {"input": "7\r\n-2722 6597\r\n-3303 200\r\n6508 -1021\r\n-1107 -1042\r\n6875 7616\r\n-3047 6749\r\n662 -1979\r\n", "output": "1 6\r\n"}, {"input": "8\r\n-36 749\r\n5126 943\r\n1165 533\r\n-1647 -5725\r\n5031 6532\r\n5956 8447\r\n2297 -2284\r\n1986 6937\r\n", "output": "5 6\r\n"}, {"input": "9\r\n-391 -1706\r\n995 -5756\r\n-5013 -154\r\n1121 3160\r\n-7111 8303\r\n-7303 -2414\r\n-7791 -935\r\n7576 -9361\r\n1072 203\r\n", "output": "3 7\r\n"}, {"input": "10\r\n-9920 -5477\r\n9691 -3200\r\n754 885\r\n-1895 1768\r\n-941 1588\r\n6293 -2631\r\n-2288 9129\r\n4067 696\r\n-6754 9869\r\n-5747 701\r\n", "output": "5 9\r\n"}, {"input": "2\r\n1 0\r\n-1 0\r\n", "output": "1 2\r\n"}, {"input": "2\r\n0 1\r\n0 -1\r\n", "output": "1 2\r\n"}, {"input": "2\r\n2131 -3249\r\n-2131 3249\r\n", "output": "2 1\r\n"}, {"input": "3\r\n-5 1\r\n-5 -1\r\n5 0\r\n", "output": "1 2\r\n"}, {"input": "3\r\n-100 1\r\n-100 -1\r\n0 100\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 10\r\n10 1\r\n10 -1\r\n", "output": "3 2\r\n"}, {"input": "3\r\n3 0\r\n0 3\r\n1 -3\r\n", "output": "3 1\r\n"}, {"input": "3\r\n1 1\r\n-1 0\r\n1 -1\r\n", "output": "3 1\r\n"}, {"input": "3\r\n-1 0\r\n10 -1\r\n1 0\r\n", "output": "2 3\r\n"}, {"input": "4\r\n1 10\r\n10 1\r\n-2 -2\r\n10 -1\r\n", "output": "4 2\r\n"}, {"input": "3\r\n-6 0\r\n6 1\r\n6 -1\r\n", "output": "3 2\r\n"}, {"input": "3\r\n114 1\r\n-514 0\r\n114 -1\r\n", "output": "3 1\r\n"}, {"input": "4\r\n-1 0\r\n0 -1\r\n-1 1\r\n1 0\r\n", "output": "3 1\r\n"}, {"input": "4\r\n2 1\r\n2 -1\r\n-1 1\r\n-1 -1\r\n", "output": "2 1\r\n"}, {"input": "3\r\n3 1\r\n3 -1\r\n0 3\r\n", "output": "2 1\r\n"}, {"input": "3\r\n1 1\r\n9000 1\r\n9000 -1\r\n", "output": "3 2\r\n"}, {"input": "3\r\n1 0\r\n-1 1\r\n-1 -1\r\n", "output": "2 3\r\n"}, {"input": "6\r\n1 1\r\n-1 -1\r\n0 20\r\n100 1\r\n-100 0\r\n100 -1\r\n", "output": "6 4\r\n"}, {"input": "4\r\n1 0\r\n0 1\r\n-1 0\r\n-13 -1\r\n", "output": "3 4\r\n"}, {"input": "3\r\n1 0\r\n-1 0\r\n1 -1\r\n", "output": "3 1\r\n"}, {"input": "3\r\n100 1\r\n-100 0\r\n100 -1\r\n", "output": "3 1\r\n"}, {"input": "3\r\n-100 1\r\n100 0\r\n-100 -1\r\n", "output": "1 3\r\n"}, {"input": "3\r\n1 100\r\n0 -100\r\n-1 100\r\n", "output": "1 3\r\n"}, {"input": "11\r\n-7945 386\r\n7504 -576\r\n-6020 -8277\r\n930 9737\r\n1682 474\r\n-8279 1197\r\n2790 2607\r\n-5514 -9601\r\n-3159 5939\r\n-1806 4207\r\n-9073 -2138\r\n", "output": "10 9\r\n"}, {"input": "3\r\n1 0\r\n10000 -1\r\n1 1\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-7125 -1643\r\n-1235 4071\r\n-75 -8717\r\n2553 9278\r\n", "output": "4 2\r\n"}, {"input": "5\r\n-6 0\r\n6 1\r\n6 -1\r\n0 6\r\n0 -6\r\n", "output": "3 2\r\n"}, {"input": "4\r\n5 5\r\n5 -5\r\n-555 1\r\n-555 -1\r\n", "output": "3 4\r\n"}, {"input": "4\r\n1 1\r\n-1 1\r\n-1 -1\r\n2 -1\r\n", "output": "4 1\r\n"}, {"input": "4\r\n-1 -100\r\n1 -100\r\n-100 -100\r\n100 -100\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 0\r\n1 -1\r\n-4 -6\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-1 -100\r\n1 -100\r\n100 -100\r\n-100 -100\r\n", "output": "1 2\r\n"}, {"input": "4\r\n-1 0\r\n0 -2\r\n-3 3\r\n4 0\r\n", "output": "3 1\r\n"}, {"input": "4\r\n-2 0\r\n0 -3\r\n-5 5\r\n4 0\r\n", "output": "3 1\r\n"}, {"input": "3\r\n1 -100\r\n0 100\r\n-1 -100\r\n", "output": "3 1\r\n"}, {"input": "5\r\n10000 2\r\n10000 -1\r\n10000 -5\r\n10000 -9\r\n10000 -13\r\n", "output": "2 1\r\n"}, {"input": "8\r\n-9580 8545\r\n-9379 -1139\r\n5824 -391\r\n-8722 2765\r\n-1357 -5547\r\n-7700 217\r\n9323 -7008\r\n957 -8356\r\n", "output": "6 2\r\n"}, {"input": "4\r\n5 5\r\n5 -5\r\n-500 1\r\n-500 -1\r\n", "output": "3 4\r\n"}, {"input": "3\r\n30 1\r\n30 -1\r\n0 30\r\n", "output": "2 1\r\n"}, {"input": "4\r\n3966 -1107\r\n8007 -5457\r\n-7753 4945\r\n-2209 -4221\r\n", "output": "2 1\r\n"}, {"input": "4\r\n1 9999\r\n0 1\r\n10000 0\r\n10000 -1\r\n", "output": "4 3\r\n"}, {"input": "3\r\n10000 1\r\n10000 -1\r\n-10000 0\r\n", "output": "2 1\r\n"}, {"input": "13\r\n1 2\r\n2 3\r\n3 4\r\n4 5\r\n5 6\r\n6 7\r\n7 8\r\n8 9\r\n9 10\r\n10 11\r\n11 12\r\n13 14\r\n12 13\r\n", "output": "12 13\r\n"}, {"input": "4\r\n2 1\r\n2 -1\r\n0 1\r\n-1 0\r\n", "output": "2 1\r\n"}, {"input": "4\r\n10 3\r\n10 -3\r\n-500 1\r\n-500 -1\r\n", "output": "3 4\r\n"}, {"input": "4\r\n1 10000\r\n-1 1\r\n10000 0\r\n10000 -1\r\n", "output": "4 3\r\n"}, {"input": "3\r\n0 1\r\n1 0\r\n1 -1\r\n", "output": "3 2\r\n"}, {"input": "3\r\n1 0\r\n0 1\r\n1 -1\r\n", "output": "3 1\r\n"}, {"input": "4\r\n1 1\r\n-1 1\r\n1 -2\r\n-1 -2\r\n", "output": "4 3\r\n"}, {"input": "4\r\n0 -1\r\n-1 0\r\n-1 1\r\n1 0\r\n", "output": "3 2\r\n"}, {"input": "3\r\n-100 1\r\n-100 -1\r\n1 1\r\n", "output": "1 2\r\n"}, {"input": "3\r\n-3 1\r\n-3 -1\r\n2 -3\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 -1\r\n1 0\r\n0 1\r\n", "output": "1 2\r\n"}, {"input": "5\r\n-5 1\r\n0 5\r\n4 1\r\n0 -4\r\n-5 -1\r\n", "output": "1 5\r\n"}, {"input": "4\r\n1 10000\r\n0 1\r\n10000 0\r\n9999 -1\r\n", "output": "1 2\r\n"}, {"input": "4\r\n2 3\r\n2 -3\r\n-3 2\r\n-3 -2\r\n", "output": "3 4\r\n"}, {"input": "3\r\n1 -3\r\n1 0\r\n0 1\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 0\r\n-1 0\r\n-1 -1\r\n", "output": "2 3\r\n"}, {"input": "4\r\n-2 1\r\n-2 -1\r\n1 1\r\n1 -1\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 -1\r\n-1 1\r\n-1 -2\r\n", "output": "3 1\r\n"}, {"input": "3\r\n1 0\r\n-1 -1\r\n1 -1\r\n", "output": "3 1\r\n"}, {"input": "3\r\n5 5\r\n-5 0\r\n5 -5\r\n", "output": "3 1\r\n"}, {"input": "4\r\n1 -2\r\n1 0\r\n-1 0\r\n10 -1\r\n", "output": "4 2\r\n"}, {"input": "3\r\n-1000 1\r\n-1000 -1\r\n1000 0\r\n", "output": "1 2\r\n"}, {"input": "6\r\n1 1\r\n1 -1\r\n-1 1\r\n-1 -1\r\n1 -10000\r\n-1 -10000\r\n", "output": "6 5\r\n"}, {"input": "3\r\n1 1\r\n-1 0\r\n0 -1\r\n", "output": "2 3\r\n"}, {"input": "4\r\n5000 1\r\n5000 -1\r\n-2 -1\r\n2 -1\r\n", "output": "2 1\r\n"}, {"input": "3\r\n1 0\r\n-1 1\r\n-1 -5\r\n", "output": "3 1\r\n"}, {"input": "3\r\n-5374 1323\r\n-4463 -8462\r\n6118 -7918\r\n", "output": "2 3\r\n"}, {"input": "4\r\n-6427 -6285\r\n-5386 -5267\r\n-3898 7239\r\n-3905 7252\r\n", "output": "4 3\r\n"}, {"input": "10\r\n-7 -3\r\n-2 8\r\n9 -9\r\n0 1\r\n4 5\r\n5 3\r\n-3 0\r\n10 2\r\n4 -1\r\n2 -10\r\n", "output": "4 2\r\n"}, {"input": "4\r\n9999 1\r\n9999 -1\r\n-9998 1\r\n-10000 -1\r\n", "output": "2 1\r\n"}, {"input": "4\r\n10000 9999\r\n9999 9998\r\n9998 9997\r\n9997 9996\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-6285 -6427\r\n-5267 -5386\r\n7239 -3898\r\n7252 -3905\r\n", "output": "3 4\r\n"}, {"input": "4\r\n-6427 6285\r\n-5386 5267\r\n3898 -7239\r\n3905 -7252\r\n", "output": "4 3\r\n"}, {"input": "4\r\n-6427 -6285\r\n-5386 -5267\r\n-3898 -7239\r\n-3905 -7252\r\n", "output": "3 4\r\n"}, {"input": "3\r\n0 1\r\n-1 -1\r\n1 -1\r\n", "output": "2 3\r\n"}, {"input": "4\r\n10000 1\r\n9998 -1\r\n-9999 1\r\n-9999 -1\r\n", "output": "3 4\r\n"}, {"input": "3\r\n100 0\r\n100 2\r\n100 -1\r\n", "output": "3 1\r\n"}, {"input": "3\r\n-1 1\r\n-1 -1\r\n1 0\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9844 9986\r\n181 9967\r\n-9812 -9925\r\n-194 -9900\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9800 9981\r\n61 9899\r\n-9926 -9932\r\n-149 -9926\r\n", "output": "3 4\r\n"}, {"input": "4\r\n-9901 9900\r\n-10000 9899\r\n9899 9801\r\n9899 9900\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9934 9989\r\n199 9949\r\n-9917 -9974\r\n-197 -9901\r\n", "output": "3 4\r\n"}, {"input": "3\r\n-1 1\r\n1 0\r\n-1 -1\r\n", "output": "1 3\r\n"}, {"input": "3\r\n1 1\r\n-10 -10\r\n-10 -9\r\n", "output": "3 2\r\n"}, {"input": "3\r\n1 0\r\n10000 -1\r\n-1 0\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9999 1\r\n9999 -1\r\n-10000 1\r\n-10000 -1\r\n", "output": "3 4\r\n"}, {"input": "3\r\n-5 1\r\n-5 -1\r\n1 0\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 0\r\n10000 1\r\n-1 0\r\n", "output": "1 2\r\n"}, {"input": "4\r\n-9990 9995\r\n9994 -9991\r\n-9999 -9992\r\n9993 9992\r\n", "output": "2 4\r\n"}, {"input": "8\r\n1 0\r\n1 1\r\n0 1\r\n-1 1\r\n-1 0\r\n-1 -1\r\n0 -1\r\n1 -2\r\n", "output": "7 8\r\n"}, {"input": "3\r\n-9930 9932\r\n9909 -9909\r\n-9932 -9931\r\n", "output": "3 2\r\n"}, {"input": "4\r\n9876 9977\r\n127 9938\r\n-9820 -9934\r\n-120 -9921\r\n", "output": "3 4\r\n"}, {"input": "3\r\n10000 -1\r\n-1 0\r\n0 -1\r\n", "output": "3 1\r\n"}, {"input": "4\r\n6427 -6285\r\n5386 -5267\r\n3898 7239\r\n3905 7252\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9811 9970\r\n155 9994\r\n-9826 -9977\r\n-159 -9986\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9851 9917\r\n74 9921\r\n-9855 -9916\r\n-77 -9984\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9826 9977\r\n159 9986\r\n-9811 -9970\r\n-155 -9994\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9849 9986\r\n148 9980\r\n-9800 -9999\r\n-116 -9927\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9822 9967\r\n111 9905\r\n-9943 -9986\r\n-163 -9953\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9959 9995\r\n113 9940\r\n-9965 -9931\r\n-148 -9945\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9851 9972\r\n153 9983\r\n-9866 -9926\r\n-183 -9946\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9816 -9979\r\n127 -9940\r\n-9876 9915\r\n-190 9978\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9887 -9917\r\n138 -9977\r\n-9826 9995\r\n-68 9971\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9936 -9965\r\n135 -9949\r\n-9928 9980\r\n-123 9908\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9981 -9985\r\n191 -9956\r\n-9893 9937\r\n-171 9962\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-9811 9970\r\n-155 9994\r\n9826 -9977\r\n159 -9986\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9808 9899\r\n179 9966\r\n-9870 -9961\r\n-179 -9950\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9815 -9936\r\n168 -9937\r\n-9896 9995\r\n-180 9969\r\n", "output": "2 1\r\n"}, {"input": "4\r\n1 1\r\n1 -1\r\n-100 1\r\n-100 -1\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9965 114\r\n87 9916\r\n-9957 -106\r\n-95 -9929\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9895 -9949\r\n188 -9978\r\n-9810 9935\r\n-151 9914\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-9957 106\r\n-95 9929\r\n9965 -114\r\n87 -9916\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-9862 9980\r\n-174 9917\r\n9845 -9967\r\n173 -9980\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9944 9926\r\n9927 9935\r\n-9961 -9929\r\n-9997 -9991\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9917 9909\r\n196 9925\r\n-9971 -9991\r\n-183 -9977\r\n", "output": "3 4\r\n"}]
| false |
stdio
|
import sys
import math
def read_vectors(input_path):
with open(input_path) as f:
n = int(f.readline())
vectors = []
for i in range(n):
x, y = map(int, f.readline().split())
vectors.append( (x, y, i+1) )
return vectors
def compute_angle(x, y):
return math.atan2(y, x) % (2 * math.pi)
def compute_non_oriented_angle(u, v):
ux, uy = u
vx, vy = v
dot = ux * vx + uy * vy
mag_u = math.hypot(ux, uy)
mag_v = math.hypot(vx, vy)
if mag_u == 0 or mag_v == 0:
return 0.0
cos_theta = dot / (mag_u * mag_v)
cos_theta = max(min(cos_theta, 1.0), -1.0)
return math.acos(cos_theta)
def find_min_angle(vectors):
sorted_vectors = sorted(vectors, key=lambda vec: compute_angle(vec[0], vec[1]))
n = len(sorted_vectors)
min_adjacent = math.pi
for i in range(n):
j = (i + 1) % n
u = sorted_vectors[i][0], sorted_vectors[i][1]
v = sorted_vectors[j][0], sorted_vectors[j][1]
theta = compute_non_oriented_angle(u, v)
if theta < min_adjacent:
min_adjacent = theta
angles = []
for vec in sorted_vectors:
x, y, idx = vec
angles.append( compute_angle(x, y) )
min_opposite = math.pi
for i in range(n):
theta_i = angles[i]
target = (theta_i + math.pi) % (2 * math.pi)
low = 0
high = n
while low < high:
mid = (low + high) // 2
if angles[mid] < target:
low = mid + 1
else:
high = mid
candidates = []
if low > 0:
candidates.append(low-1)
if low < n:
candidates.append(low)
candidates.append((low - 1) % n)
candidates = list(set(candidates))
for c in candidates:
if c == i:
continue
c = c % n
vec_c = sorted_vectors[c]
u = sorted_vectors[i][0], sorted_vectors[i][1]
v = vec_c[0], vec_c[1]
current_theta = compute_non_oriented_angle(u, v)
if current_theta < min_opposite:
min_opposite = current_theta
return min(min_adjacent, min_opposite)
def main(input_path, output_path, submission_output_path):
input_vectors = read_vectors(input_path)
with open(submission_output_path) as f:
line = f.readline().strip()
try:
a, b = map(int, line.split())
except:
print(0)
return
n = len(input_vectors)
if a < 1 or a > n or b < 1 or b > n or a == b:
print(0)
return
vec_a = None
vec_b = None
for vec in input_vectors:
if vec[2] == a:
vec_a = vec
if vec[2] == b:
vec_b = vec
if vec_a is None or vec_b is None:
print(0)
return
u = (vec_a[0], vec_a[1])
v = (vec_b[0], vec_b[1])
theta = compute_non_oriented_angle(u, v)
min_angle = find_min_angle(input_vectors)
epsilon = 1e-9
if abs(theta - min_angle) <= epsilon:
print(1)
else:
print(0)
if __name__ == "__main__":
input_path = sys.argv[1]
output_path = sys.argv[2]
submission_output_path = sys.argv[3]
main(input_path, output_path, submission_output_path)
| true |
598/C
|
598
|
C
|
PyPy 3-64
|
TESTS
| 144 | 904 | 24,678,400 |
136345958
|
import math
def dot_product(ax, ay, bx, by):
return ax * bx + ay * by
def cross_product(ax, ay, bx, by):
return ax * by - ay * bx
n = int(input())
A = []
for i in range(n):
a, b = map(int, input().split())
A.append((a, b, i))
A.sort(key=lambda x: math.atan2(cross_product(x[0], x[1], 1, 0), dot_product(x[0], x[1], 1, 0)))
ans = (1000000000, -1, -1)
for i in range(n):
ans = min(ans, (abs(math.atan2(cross_product(A[i][0], A[i][1], A[(i + 1) % n][0], A[(i + 1) % n][1]), dot_product(A[i][0], A[i][1], A[(i + 1) % n][0], A[(i + 1) % n][1]))), A[i][2], A[(i + 1) % n][2]))
print(ans[1] + 1, ans[2] + 1)
| 163 | 1,153 | 20,992,000 |
112977689
|
from math import atan2
inner = lambda a, b: a[0] * b[0] + a[1] * b[1]
outer = lambda a, b: a[0] * b[1] - a[1] * b[0]
N = int(input())
vectors = []
for i in range(N):
x, y = map(int, input().split())
vectors.append((atan2(y, x), (x, y), i + 1))
vectors.sort()
diff = []
for i in range(N):
diff.append([inner(vectors[i][1], vectors[(i+1)%N][1]), abs(outer(vectors[i][1], vectors[(i+1)%N][1])), vectors[i][2], vectors[(i+1)%N][2]])
min_diff = diff[0]
for d in diff:
if outer(d[:2], min_diff[:2]) > 0: min_diff = d
print(min_diff[2], min_diff[3])
|
Educational Codeforces Round 1
|
ICPC
| 2,015 | 2 | 256 |
Nearest vectors
|
You are given the set of vectors on the plane, each of them starting at the origin. Your task is to find a pair of vectors with the minimal non-oriented angle between them.
Non-oriented angle is non-negative value, minimal between clockwise and counterclockwise direction angles. Non-oriented angle is always between 0 and π. For example, opposite directions vectors have angle equals to π.
|
First line of the input contains a single integer n (2 ≤ n ≤ 100 000) — the number of vectors.
The i-th of the following n lines contains two integers xi and yi (|x|, |y| ≤ 10 000, x2 + y2 > 0) — the coordinates of the i-th vector. Vectors are numbered from 1 to n in order of appearing in the input. It is guaranteed that no two vectors in the input share the same direction (but they still can have opposite directions).
|
Print two integer numbers a and b (a ≠ b) — a pair of indices of vectors with the minimal non-oriented angle. You can print the numbers in any order. If there are many possible answers, print any.
| null | null |
[{"input": "4\n-1 0\n0 -1\n1 0\n1 1", "output": "3 4"}, {"input": "6\n-1 0\n0 -1\n1 0\n1 1\n-4 -5\n-4 -6", "output": "6 5"}]
| 2,300 |
["geometry", "sortings"]
| 163 |
[{"input": "4\r\n-1 0\r\n0 -1\r\n1 0\r\n1 1\r\n", "output": "3 4\r\n"}, {"input": "6\r\n-1 0\r\n0 -1\r\n1 0\r\n1 1\r\n-4 -5\r\n-4 -6\r\n", "output": "5 6\r\n"}, {"input": "10\r\n8 6\r\n-7 -3\r\n9 8\r\n7 10\r\n-3 -8\r\n3 7\r\n6 -8\r\n-9 8\r\n9 2\r\n6 7\r\n", "output": "1 3\r\n"}, {"input": "20\r\n-9 8\r\n-7 3\r\n0 10\r\n3 7\r\n6 -9\r\n6 8\r\n7 -6\r\n-6 10\r\n-10 3\r\n-8 -10\r\n10 -2\r\n1 -8\r\n-8 10\r\n10 10\r\n10 6\r\n-5 6\r\n5 -8\r\n5 -9\r\n-9 -1\r\n9 2\r\n", "output": "13 16\r\n"}, {"input": "2\r\n351 -4175\r\n-328 -657\r\n", "output": "2 1\r\n"}, {"input": "3\r\n620 -1189\r\n8101 -2770\r\n3347 3473\r\n", "output": "1 2\r\n"}, {"input": "4\r\n-7061 -5800\r\n-3471 -9470\r\n-7639 2529\r\n5657 -6522\r\n", "output": "1 2\r\n"}, {"input": "5\r\n-7519 -3395\r\n-32 -257\r\n-4827 -1889\r\n9545 -7037\r\n2767 583\r\n", "output": "3 1\r\n"}, {"input": "6\r\n-5120 -3251\r\n8269 -7984\r\n841 3396\r\n3136 -7551\r\n-1280 -3013\r\n-3263 -3278\r\n", "output": "1 6\r\n"}, {"input": "7\r\n-2722 6597\r\n-3303 200\r\n6508 -1021\r\n-1107 -1042\r\n6875 7616\r\n-3047 6749\r\n662 -1979\r\n", "output": "1 6\r\n"}, {"input": "8\r\n-36 749\r\n5126 943\r\n1165 533\r\n-1647 -5725\r\n5031 6532\r\n5956 8447\r\n2297 -2284\r\n1986 6937\r\n", "output": "5 6\r\n"}, {"input": "9\r\n-391 -1706\r\n995 -5756\r\n-5013 -154\r\n1121 3160\r\n-7111 8303\r\n-7303 -2414\r\n-7791 -935\r\n7576 -9361\r\n1072 203\r\n", "output": "3 7\r\n"}, {"input": "10\r\n-9920 -5477\r\n9691 -3200\r\n754 885\r\n-1895 1768\r\n-941 1588\r\n6293 -2631\r\n-2288 9129\r\n4067 696\r\n-6754 9869\r\n-5747 701\r\n", "output": "5 9\r\n"}, {"input": "2\r\n1 0\r\n-1 0\r\n", "output": "1 2\r\n"}, {"input": "2\r\n0 1\r\n0 -1\r\n", "output": "1 2\r\n"}, {"input": "2\r\n2131 -3249\r\n-2131 3249\r\n", "output": "2 1\r\n"}, {"input": "3\r\n-5 1\r\n-5 -1\r\n5 0\r\n", "output": "1 2\r\n"}, {"input": "3\r\n-100 1\r\n-100 -1\r\n0 100\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 10\r\n10 1\r\n10 -1\r\n", "output": "3 2\r\n"}, {"input": "3\r\n3 0\r\n0 3\r\n1 -3\r\n", "output": "3 1\r\n"}, {"input": "3\r\n1 1\r\n-1 0\r\n1 -1\r\n", "output": "3 1\r\n"}, {"input": "3\r\n-1 0\r\n10 -1\r\n1 0\r\n", "output": "2 3\r\n"}, {"input": "4\r\n1 10\r\n10 1\r\n-2 -2\r\n10 -1\r\n", "output": "4 2\r\n"}, {"input": "3\r\n-6 0\r\n6 1\r\n6 -1\r\n", "output": "3 2\r\n"}, {"input": "3\r\n114 1\r\n-514 0\r\n114 -1\r\n", "output": "3 1\r\n"}, {"input": "4\r\n-1 0\r\n0 -1\r\n-1 1\r\n1 0\r\n", "output": "3 1\r\n"}, {"input": "4\r\n2 1\r\n2 -1\r\n-1 1\r\n-1 -1\r\n", "output": "2 1\r\n"}, {"input": "3\r\n3 1\r\n3 -1\r\n0 3\r\n", "output": "2 1\r\n"}, {"input": "3\r\n1 1\r\n9000 1\r\n9000 -1\r\n", "output": "3 2\r\n"}, {"input": "3\r\n1 0\r\n-1 1\r\n-1 -1\r\n", "output": "2 3\r\n"}, {"input": "6\r\n1 1\r\n-1 -1\r\n0 20\r\n100 1\r\n-100 0\r\n100 -1\r\n", "output": "6 4\r\n"}, {"input": "4\r\n1 0\r\n0 1\r\n-1 0\r\n-13 -1\r\n", "output": "3 4\r\n"}, {"input": "3\r\n1 0\r\n-1 0\r\n1 -1\r\n", "output": "3 1\r\n"}, {"input": "3\r\n100 1\r\n-100 0\r\n100 -1\r\n", "output": "3 1\r\n"}, {"input": "3\r\n-100 1\r\n100 0\r\n-100 -1\r\n", "output": "1 3\r\n"}, {"input": "3\r\n1 100\r\n0 -100\r\n-1 100\r\n", "output": "1 3\r\n"}, {"input": "11\r\n-7945 386\r\n7504 -576\r\n-6020 -8277\r\n930 9737\r\n1682 474\r\n-8279 1197\r\n2790 2607\r\n-5514 -9601\r\n-3159 5939\r\n-1806 4207\r\n-9073 -2138\r\n", "output": "10 9\r\n"}, {"input": "3\r\n1 0\r\n10000 -1\r\n1 1\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-7125 -1643\r\n-1235 4071\r\n-75 -8717\r\n2553 9278\r\n", "output": "4 2\r\n"}, {"input": "5\r\n-6 0\r\n6 1\r\n6 -1\r\n0 6\r\n0 -6\r\n", "output": "3 2\r\n"}, {"input": "4\r\n5 5\r\n5 -5\r\n-555 1\r\n-555 -1\r\n", "output": "3 4\r\n"}, {"input": "4\r\n1 1\r\n-1 1\r\n-1 -1\r\n2 -1\r\n", "output": "4 1\r\n"}, {"input": "4\r\n-1 -100\r\n1 -100\r\n-100 -100\r\n100 -100\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 0\r\n1 -1\r\n-4 -6\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-1 -100\r\n1 -100\r\n100 -100\r\n-100 -100\r\n", "output": "1 2\r\n"}, {"input": "4\r\n-1 0\r\n0 -2\r\n-3 3\r\n4 0\r\n", "output": "3 1\r\n"}, {"input": "4\r\n-2 0\r\n0 -3\r\n-5 5\r\n4 0\r\n", "output": "3 1\r\n"}, {"input": "3\r\n1 -100\r\n0 100\r\n-1 -100\r\n", "output": "3 1\r\n"}, {"input": "5\r\n10000 2\r\n10000 -1\r\n10000 -5\r\n10000 -9\r\n10000 -13\r\n", "output": "2 1\r\n"}, {"input": "8\r\n-9580 8545\r\n-9379 -1139\r\n5824 -391\r\n-8722 2765\r\n-1357 -5547\r\n-7700 217\r\n9323 -7008\r\n957 -8356\r\n", "output": "6 2\r\n"}, {"input": "4\r\n5 5\r\n5 -5\r\n-500 1\r\n-500 -1\r\n", "output": "3 4\r\n"}, {"input": "3\r\n30 1\r\n30 -1\r\n0 30\r\n", "output": "2 1\r\n"}, {"input": "4\r\n3966 -1107\r\n8007 -5457\r\n-7753 4945\r\n-2209 -4221\r\n", "output": "2 1\r\n"}, {"input": "4\r\n1 9999\r\n0 1\r\n10000 0\r\n10000 -1\r\n", "output": "4 3\r\n"}, {"input": "3\r\n10000 1\r\n10000 -1\r\n-10000 0\r\n", "output": "2 1\r\n"}, {"input": "13\r\n1 2\r\n2 3\r\n3 4\r\n4 5\r\n5 6\r\n6 7\r\n7 8\r\n8 9\r\n9 10\r\n10 11\r\n11 12\r\n13 14\r\n12 13\r\n", "output": "12 13\r\n"}, {"input": "4\r\n2 1\r\n2 -1\r\n0 1\r\n-1 0\r\n", "output": "2 1\r\n"}, {"input": "4\r\n10 3\r\n10 -3\r\n-500 1\r\n-500 -1\r\n", "output": "3 4\r\n"}, {"input": "4\r\n1 10000\r\n-1 1\r\n10000 0\r\n10000 -1\r\n", "output": "4 3\r\n"}, {"input": "3\r\n0 1\r\n1 0\r\n1 -1\r\n", "output": "3 2\r\n"}, {"input": "3\r\n1 0\r\n0 1\r\n1 -1\r\n", "output": "3 1\r\n"}, {"input": "4\r\n1 1\r\n-1 1\r\n1 -2\r\n-1 -2\r\n", "output": "4 3\r\n"}, {"input": "4\r\n0 -1\r\n-1 0\r\n-1 1\r\n1 0\r\n", "output": "3 2\r\n"}, {"input": "3\r\n-100 1\r\n-100 -1\r\n1 1\r\n", "output": "1 2\r\n"}, {"input": "3\r\n-3 1\r\n-3 -1\r\n2 -3\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 -1\r\n1 0\r\n0 1\r\n", "output": "1 2\r\n"}, {"input": "5\r\n-5 1\r\n0 5\r\n4 1\r\n0 -4\r\n-5 -1\r\n", "output": "1 5\r\n"}, {"input": "4\r\n1 10000\r\n0 1\r\n10000 0\r\n9999 -1\r\n", "output": "1 2\r\n"}, {"input": "4\r\n2 3\r\n2 -3\r\n-3 2\r\n-3 -2\r\n", "output": "3 4\r\n"}, {"input": "3\r\n1 -3\r\n1 0\r\n0 1\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 0\r\n-1 0\r\n-1 -1\r\n", "output": "2 3\r\n"}, {"input": "4\r\n-2 1\r\n-2 -1\r\n1 1\r\n1 -1\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 -1\r\n-1 1\r\n-1 -2\r\n", "output": "3 1\r\n"}, {"input": "3\r\n1 0\r\n-1 -1\r\n1 -1\r\n", "output": "3 1\r\n"}, {"input": "3\r\n5 5\r\n-5 0\r\n5 -5\r\n", "output": "3 1\r\n"}, {"input": "4\r\n1 -2\r\n1 0\r\n-1 0\r\n10 -1\r\n", "output": "4 2\r\n"}, {"input": "3\r\n-1000 1\r\n-1000 -1\r\n1000 0\r\n", "output": "1 2\r\n"}, {"input": "6\r\n1 1\r\n1 -1\r\n-1 1\r\n-1 -1\r\n1 -10000\r\n-1 -10000\r\n", "output": "6 5\r\n"}, {"input": "3\r\n1 1\r\n-1 0\r\n0 -1\r\n", "output": "2 3\r\n"}, {"input": "4\r\n5000 1\r\n5000 -1\r\n-2 -1\r\n2 -1\r\n", "output": "2 1\r\n"}, {"input": "3\r\n1 0\r\n-1 1\r\n-1 -5\r\n", "output": "3 1\r\n"}, {"input": "3\r\n-5374 1323\r\n-4463 -8462\r\n6118 -7918\r\n", "output": "2 3\r\n"}, {"input": "4\r\n-6427 -6285\r\n-5386 -5267\r\n-3898 7239\r\n-3905 7252\r\n", "output": "4 3\r\n"}, {"input": "10\r\n-7 -3\r\n-2 8\r\n9 -9\r\n0 1\r\n4 5\r\n5 3\r\n-3 0\r\n10 2\r\n4 -1\r\n2 -10\r\n", "output": "4 2\r\n"}, {"input": "4\r\n9999 1\r\n9999 -1\r\n-9998 1\r\n-10000 -1\r\n", "output": "2 1\r\n"}, {"input": "4\r\n10000 9999\r\n9999 9998\r\n9998 9997\r\n9997 9996\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-6285 -6427\r\n-5267 -5386\r\n7239 -3898\r\n7252 -3905\r\n", "output": "3 4\r\n"}, {"input": "4\r\n-6427 6285\r\n-5386 5267\r\n3898 -7239\r\n3905 -7252\r\n", "output": "4 3\r\n"}, {"input": "4\r\n-6427 -6285\r\n-5386 -5267\r\n-3898 -7239\r\n-3905 -7252\r\n", "output": "3 4\r\n"}, {"input": "3\r\n0 1\r\n-1 -1\r\n1 -1\r\n", "output": "2 3\r\n"}, {"input": "4\r\n10000 1\r\n9998 -1\r\n-9999 1\r\n-9999 -1\r\n", "output": "3 4\r\n"}, {"input": "3\r\n100 0\r\n100 2\r\n100 -1\r\n", "output": "3 1\r\n"}, {"input": "3\r\n-1 1\r\n-1 -1\r\n1 0\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9844 9986\r\n181 9967\r\n-9812 -9925\r\n-194 -9900\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9800 9981\r\n61 9899\r\n-9926 -9932\r\n-149 -9926\r\n", "output": "3 4\r\n"}, {"input": "4\r\n-9901 9900\r\n-10000 9899\r\n9899 9801\r\n9899 9900\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9934 9989\r\n199 9949\r\n-9917 -9974\r\n-197 -9901\r\n", "output": "3 4\r\n"}, {"input": "3\r\n-1 1\r\n1 0\r\n-1 -1\r\n", "output": "1 3\r\n"}, {"input": "3\r\n1 1\r\n-10 -10\r\n-10 -9\r\n", "output": "3 2\r\n"}, {"input": "3\r\n1 0\r\n10000 -1\r\n-1 0\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9999 1\r\n9999 -1\r\n-10000 1\r\n-10000 -1\r\n", "output": "3 4\r\n"}, {"input": "3\r\n-5 1\r\n-5 -1\r\n1 0\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 0\r\n10000 1\r\n-1 0\r\n", "output": "1 2\r\n"}, {"input": "4\r\n-9990 9995\r\n9994 -9991\r\n-9999 -9992\r\n9993 9992\r\n", "output": "2 4\r\n"}, {"input": "8\r\n1 0\r\n1 1\r\n0 1\r\n-1 1\r\n-1 0\r\n-1 -1\r\n0 -1\r\n1 -2\r\n", "output": "7 8\r\n"}, {"input": "3\r\n-9930 9932\r\n9909 -9909\r\n-9932 -9931\r\n", "output": "3 2\r\n"}, {"input": "4\r\n9876 9977\r\n127 9938\r\n-9820 -9934\r\n-120 -9921\r\n", "output": "3 4\r\n"}, {"input": "3\r\n10000 -1\r\n-1 0\r\n0 -1\r\n", "output": "3 1\r\n"}, {"input": "4\r\n6427 -6285\r\n5386 -5267\r\n3898 7239\r\n3905 7252\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9811 9970\r\n155 9994\r\n-9826 -9977\r\n-159 -9986\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9851 9917\r\n74 9921\r\n-9855 -9916\r\n-77 -9984\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9826 9977\r\n159 9986\r\n-9811 -9970\r\n-155 -9994\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9849 9986\r\n148 9980\r\n-9800 -9999\r\n-116 -9927\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9822 9967\r\n111 9905\r\n-9943 -9986\r\n-163 -9953\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9959 9995\r\n113 9940\r\n-9965 -9931\r\n-148 -9945\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9851 9972\r\n153 9983\r\n-9866 -9926\r\n-183 -9946\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9816 -9979\r\n127 -9940\r\n-9876 9915\r\n-190 9978\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9887 -9917\r\n138 -9977\r\n-9826 9995\r\n-68 9971\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9936 -9965\r\n135 -9949\r\n-9928 9980\r\n-123 9908\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9981 -9985\r\n191 -9956\r\n-9893 9937\r\n-171 9962\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-9811 9970\r\n-155 9994\r\n9826 -9977\r\n159 -9986\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9808 9899\r\n179 9966\r\n-9870 -9961\r\n-179 -9950\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9815 -9936\r\n168 -9937\r\n-9896 9995\r\n-180 9969\r\n", "output": "2 1\r\n"}, {"input": "4\r\n1 1\r\n1 -1\r\n-100 1\r\n-100 -1\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9965 114\r\n87 9916\r\n-9957 -106\r\n-95 -9929\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9895 -9949\r\n188 -9978\r\n-9810 9935\r\n-151 9914\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-9957 106\r\n-95 9929\r\n9965 -114\r\n87 -9916\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-9862 9980\r\n-174 9917\r\n9845 -9967\r\n173 -9980\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9944 9926\r\n9927 9935\r\n-9961 -9929\r\n-9997 -9991\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9917 9909\r\n196 9925\r\n-9971 -9991\r\n-183 -9977\r\n", "output": "3 4\r\n"}]
| false |
stdio
|
import sys
import math
def read_vectors(input_path):
with open(input_path) as f:
n = int(f.readline())
vectors = []
for i in range(n):
x, y = map(int, f.readline().split())
vectors.append( (x, y, i+1) )
return vectors
def compute_angle(x, y):
return math.atan2(y, x) % (2 * math.pi)
def compute_non_oriented_angle(u, v):
ux, uy = u
vx, vy = v
dot = ux * vx + uy * vy
mag_u = math.hypot(ux, uy)
mag_v = math.hypot(vx, vy)
if mag_u == 0 or mag_v == 0:
return 0.0
cos_theta = dot / (mag_u * mag_v)
cos_theta = max(min(cos_theta, 1.0), -1.0)
return math.acos(cos_theta)
def find_min_angle(vectors):
sorted_vectors = sorted(vectors, key=lambda vec: compute_angle(vec[0], vec[1]))
n = len(sorted_vectors)
min_adjacent = math.pi
for i in range(n):
j = (i + 1) % n
u = sorted_vectors[i][0], sorted_vectors[i][1]
v = sorted_vectors[j][0], sorted_vectors[j][1]
theta = compute_non_oriented_angle(u, v)
if theta < min_adjacent:
min_adjacent = theta
angles = []
for vec in sorted_vectors:
x, y, idx = vec
angles.append( compute_angle(x, y) )
min_opposite = math.pi
for i in range(n):
theta_i = angles[i]
target = (theta_i + math.pi) % (2 * math.pi)
low = 0
high = n
while low < high:
mid = (low + high) // 2
if angles[mid] < target:
low = mid + 1
else:
high = mid
candidates = []
if low > 0:
candidates.append(low-1)
if low < n:
candidates.append(low)
candidates.append((low - 1) % n)
candidates = list(set(candidates))
for c in candidates:
if c == i:
continue
c = c % n
vec_c = sorted_vectors[c]
u = sorted_vectors[i][0], sorted_vectors[i][1]
v = vec_c[0], vec_c[1]
current_theta = compute_non_oriented_angle(u, v)
if current_theta < min_opposite:
min_opposite = current_theta
return min(min_adjacent, min_opposite)
def main(input_path, output_path, submission_output_path):
input_vectors = read_vectors(input_path)
with open(submission_output_path) as f:
line = f.readline().strip()
try:
a, b = map(int, line.split())
except:
print(0)
return
n = len(input_vectors)
if a < 1 or a > n or b < 1 or b > n or a == b:
print(0)
return
vec_a = None
vec_b = None
for vec in input_vectors:
if vec[2] == a:
vec_a = vec
if vec[2] == b:
vec_b = vec
if vec_a is None or vec_b is None:
print(0)
return
u = (vec_a[0], vec_a[1])
v = (vec_b[0], vec_b[1])
theta = compute_non_oriented_angle(u, v)
min_angle = find_min_angle(input_vectors)
epsilon = 1e-9
if abs(theta - min_angle) <= epsilon:
print(1)
else:
print(0)
if __name__ == "__main__":
input_path = sys.argv[1]
output_path = sys.argv[2]
submission_output_path = sys.argv[3]
main(input_path, output_path, submission_output_path)
| true |
598/C
|
598
|
C
|
PyPy 3
|
TESTS
| 113 | 389 | 10,035,200 |
205154019
|
import math
import sys, os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
n = int(input())
z = []
for i in range(n):
x, y = map(int, input().split())
u = math.degrees(math.atan2(y, x))
z.append((u, i + 1))
z.sort()
mi = 360
for i in range(n):
x1, u = z[i]
x2, v = z[(i + 1) % n]
if x2 < x1:
x2 += 360
if mi > x2 - x1:
mi = x2 - x1
ans = [u, v]
sys.stdout.write(" ".join(map(str, ans)))
| 163 | 1,185 | 29,696,000 |
197816661
|
from functools import cmp_to_key
def is_top(vector):
return vector[1] > 0 or vector[1] == 0 and vector[0] > 0
def cross(first, second):
return first[0] * second[1] - second[0] * first[1]
def dot(first, second):
return first[0]*second[0] + first[1]*second[1]
def polar_cmp(first, second):
if is_top(first) != is_top(second):
return -is_top(first) + is_top(second)
return -cross(first, second)
def angle_less(a1, b1, a2, b2):
first = (dot(a1, b1), abs(cross(a1, b1)))
second = (dot(a2, b2), abs(cross(a2, b2)))
return polar_cmp(first, second) < 0
def main():
vectors = []
n = int(input())
for j in range(n):
vectors.append(tuple((int(i) for i in input().split())) + (j + 1, ))
vectors.sort(key=cmp_to_key(polar_cmp))
best_first = vectors[-1]
best_second = vectors[0]
for i in range(n-1):
if angle_less(vectors[i], vectors[i+1], best_first, best_second):
best_first = vectors[i]
best_second = vectors[i+1]
print(best_first[-1], best_second[-1])
if __name__ == '__main__':
main()
|
Educational Codeforces Round 1
|
ICPC
| 2,015 | 2 | 256 |
Nearest vectors
|
You are given the set of vectors on the plane, each of them starting at the origin. Your task is to find a pair of vectors with the minimal non-oriented angle between them.
Non-oriented angle is non-negative value, minimal between clockwise and counterclockwise direction angles. Non-oriented angle is always between 0 and π. For example, opposite directions vectors have angle equals to π.
|
First line of the input contains a single integer n (2 ≤ n ≤ 100 000) — the number of vectors.
The i-th of the following n lines contains two integers xi and yi (|x|, |y| ≤ 10 000, x2 + y2 > 0) — the coordinates of the i-th vector. Vectors are numbered from 1 to n in order of appearing in the input. It is guaranteed that no two vectors in the input share the same direction (but they still can have opposite directions).
|
Print two integer numbers a and b (a ≠ b) — a pair of indices of vectors with the minimal non-oriented angle. You can print the numbers in any order. If there are many possible answers, print any.
| null | null |
[{"input": "4\n-1 0\n0 -1\n1 0\n1 1", "output": "3 4"}, {"input": "6\n-1 0\n0 -1\n1 0\n1 1\n-4 -5\n-4 -6", "output": "6 5"}]
| 2,300 |
["geometry", "sortings"]
| 163 |
[{"input": "4\r\n-1 0\r\n0 -1\r\n1 0\r\n1 1\r\n", "output": "3 4\r\n"}, {"input": "6\r\n-1 0\r\n0 -1\r\n1 0\r\n1 1\r\n-4 -5\r\n-4 -6\r\n", "output": "5 6\r\n"}, {"input": "10\r\n8 6\r\n-7 -3\r\n9 8\r\n7 10\r\n-3 -8\r\n3 7\r\n6 -8\r\n-9 8\r\n9 2\r\n6 7\r\n", "output": "1 3\r\n"}, {"input": "20\r\n-9 8\r\n-7 3\r\n0 10\r\n3 7\r\n6 -9\r\n6 8\r\n7 -6\r\n-6 10\r\n-10 3\r\n-8 -10\r\n10 -2\r\n1 -8\r\n-8 10\r\n10 10\r\n10 6\r\n-5 6\r\n5 -8\r\n5 -9\r\n-9 -1\r\n9 2\r\n", "output": "13 16\r\n"}, {"input": "2\r\n351 -4175\r\n-328 -657\r\n", "output": "2 1\r\n"}, {"input": "3\r\n620 -1189\r\n8101 -2770\r\n3347 3473\r\n", "output": "1 2\r\n"}, {"input": "4\r\n-7061 -5800\r\n-3471 -9470\r\n-7639 2529\r\n5657 -6522\r\n", "output": "1 2\r\n"}, {"input": "5\r\n-7519 -3395\r\n-32 -257\r\n-4827 -1889\r\n9545 -7037\r\n2767 583\r\n", "output": "3 1\r\n"}, {"input": "6\r\n-5120 -3251\r\n8269 -7984\r\n841 3396\r\n3136 -7551\r\n-1280 -3013\r\n-3263 -3278\r\n", "output": "1 6\r\n"}, {"input": "7\r\n-2722 6597\r\n-3303 200\r\n6508 -1021\r\n-1107 -1042\r\n6875 7616\r\n-3047 6749\r\n662 -1979\r\n", "output": "1 6\r\n"}, {"input": "8\r\n-36 749\r\n5126 943\r\n1165 533\r\n-1647 -5725\r\n5031 6532\r\n5956 8447\r\n2297 -2284\r\n1986 6937\r\n", "output": "5 6\r\n"}, {"input": "9\r\n-391 -1706\r\n995 -5756\r\n-5013 -154\r\n1121 3160\r\n-7111 8303\r\n-7303 -2414\r\n-7791 -935\r\n7576 -9361\r\n1072 203\r\n", "output": "3 7\r\n"}, {"input": "10\r\n-9920 -5477\r\n9691 -3200\r\n754 885\r\n-1895 1768\r\n-941 1588\r\n6293 -2631\r\n-2288 9129\r\n4067 696\r\n-6754 9869\r\n-5747 701\r\n", "output": "5 9\r\n"}, {"input": "2\r\n1 0\r\n-1 0\r\n", "output": "1 2\r\n"}, {"input": "2\r\n0 1\r\n0 -1\r\n", "output": "1 2\r\n"}, {"input": "2\r\n2131 -3249\r\n-2131 3249\r\n", "output": "2 1\r\n"}, {"input": "3\r\n-5 1\r\n-5 -1\r\n5 0\r\n", "output": "1 2\r\n"}, {"input": "3\r\n-100 1\r\n-100 -1\r\n0 100\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 10\r\n10 1\r\n10 -1\r\n", "output": "3 2\r\n"}, {"input": "3\r\n3 0\r\n0 3\r\n1 -3\r\n", "output": "3 1\r\n"}, {"input": "3\r\n1 1\r\n-1 0\r\n1 -1\r\n", "output": "3 1\r\n"}, {"input": "3\r\n-1 0\r\n10 -1\r\n1 0\r\n", "output": "2 3\r\n"}, {"input": "4\r\n1 10\r\n10 1\r\n-2 -2\r\n10 -1\r\n", "output": "4 2\r\n"}, {"input": "3\r\n-6 0\r\n6 1\r\n6 -1\r\n", "output": "3 2\r\n"}, {"input": "3\r\n114 1\r\n-514 0\r\n114 -1\r\n", "output": "3 1\r\n"}, {"input": "4\r\n-1 0\r\n0 -1\r\n-1 1\r\n1 0\r\n", "output": "3 1\r\n"}, {"input": "4\r\n2 1\r\n2 -1\r\n-1 1\r\n-1 -1\r\n", "output": "2 1\r\n"}, {"input": "3\r\n3 1\r\n3 -1\r\n0 3\r\n", "output": "2 1\r\n"}, {"input": "3\r\n1 1\r\n9000 1\r\n9000 -1\r\n", "output": "3 2\r\n"}, {"input": "3\r\n1 0\r\n-1 1\r\n-1 -1\r\n", "output": "2 3\r\n"}, {"input": "6\r\n1 1\r\n-1 -1\r\n0 20\r\n100 1\r\n-100 0\r\n100 -1\r\n", "output": "6 4\r\n"}, {"input": "4\r\n1 0\r\n0 1\r\n-1 0\r\n-13 -1\r\n", "output": "3 4\r\n"}, {"input": "3\r\n1 0\r\n-1 0\r\n1 -1\r\n", "output": "3 1\r\n"}, {"input": "3\r\n100 1\r\n-100 0\r\n100 -1\r\n", "output": "3 1\r\n"}, {"input": "3\r\n-100 1\r\n100 0\r\n-100 -1\r\n", "output": "1 3\r\n"}, {"input": "3\r\n1 100\r\n0 -100\r\n-1 100\r\n", "output": "1 3\r\n"}, {"input": "11\r\n-7945 386\r\n7504 -576\r\n-6020 -8277\r\n930 9737\r\n1682 474\r\n-8279 1197\r\n2790 2607\r\n-5514 -9601\r\n-3159 5939\r\n-1806 4207\r\n-9073 -2138\r\n", "output": "10 9\r\n"}, {"input": "3\r\n1 0\r\n10000 -1\r\n1 1\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-7125 -1643\r\n-1235 4071\r\n-75 -8717\r\n2553 9278\r\n", "output": "4 2\r\n"}, {"input": "5\r\n-6 0\r\n6 1\r\n6 -1\r\n0 6\r\n0 -6\r\n", "output": "3 2\r\n"}, {"input": "4\r\n5 5\r\n5 -5\r\n-555 1\r\n-555 -1\r\n", "output": "3 4\r\n"}, {"input": "4\r\n1 1\r\n-1 1\r\n-1 -1\r\n2 -1\r\n", "output": "4 1\r\n"}, {"input": "4\r\n-1 -100\r\n1 -100\r\n-100 -100\r\n100 -100\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 0\r\n1 -1\r\n-4 -6\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-1 -100\r\n1 -100\r\n100 -100\r\n-100 -100\r\n", "output": "1 2\r\n"}, {"input": "4\r\n-1 0\r\n0 -2\r\n-3 3\r\n4 0\r\n", "output": "3 1\r\n"}, {"input": "4\r\n-2 0\r\n0 -3\r\n-5 5\r\n4 0\r\n", "output": "3 1\r\n"}, {"input": "3\r\n1 -100\r\n0 100\r\n-1 -100\r\n", "output": "3 1\r\n"}, {"input": "5\r\n10000 2\r\n10000 -1\r\n10000 -5\r\n10000 -9\r\n10000 -13\r\n", "output": "2 1\r\n"}, {"input": "8\r\n-9580 8545\r\n-9379 -1139\r\n5824 -391\r\n-8722 2765\r\n-1357 -5547\r\n-7700 217\r\n9323 -7008\r\n957 -8356\r\n", "output": "6 2\r\n"}, {"input": "4\r\n5 5\r\n5 -5\r\n-500 1\r\n-500 -1\r\n", "output": "3 4\r\n"}, {"input": "3\r\n30 1\r\n30 -1\r\n0 30\r\n", "output": "2 1\r\n"}, {"input": "4\r\n3966 -1107\r\n8007 -5457\r\n-7753 4945\r\n-2209 -4221\r\n", "output": "2 1\r\n"}, {"input": "4\r\n1 9999\r\n0 1\r\n10000 0\r\n10000 -1\r\n", "output": "4 3\r\n"}, {"input": "3\r\n10000 1\r\n10000 -1\r\n-10000 0\r\n", "output": "2 1\r\n"}, {"input": "13\r\n1 2\r\n2 3\r\n3 4\r\n4 5\r\n5 6\r\n6 7\r\n7 8\r\n8 9\r\n9 10\r\n10 11\r\n11 12\r\n13 14\r\n12 13\r\n", "output": "12 13\r\n"}, {"input": "4\r\n2 1\r\n2 -1\r\n0 1\r\n-1 0\r\n", "output": "2 1\r\n"}, {"input": "4\r\n10 3\r\n10 -3\r\n-500 1\r\n-500 -1\r\n", "output": "3 4\r\n"}, {"input": "4\r\n1 10000\r\n-1 1\r\n10000 0\r\n10000 -1\r\n", "output": "4 3\r\n"}, {"input": "3\r\n0 1\r\n1 0\r\n1 -1\r\n", "output": "3 2\r\n"}, {"input": "3\r\n1 0\r\n0 1\r\n1 -1\r\n", "output": "3 1\r\n"}, {"input": "4\r\n1 1\r\n-1 1\r\n1 -2\r\n-1 -2\r\n", "output": "4 3\r\n"}, {"input": "4\r\n0 -1\r\n-1 0\r\n-1 1\r\n1 0\r\n", "output": "3 2\r\n"}, {"input": "3\r\n-100 1\r\n-100 -1\r\n1 1\r\n", "output": "1 2\r\n"}, {"input": "3\r\n-3 1\r\n-3 -1\r\n2 -3\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 -1\r\n1 0\r\n0 1\r\n", "output": "1 2\r\n"}, {"input": "5\r\n-5 1\r\n0 5\r\n4 1\r\n0 -4\r\n-5 -1\r\n", "output": "1 5\r\n"}, {"input": "4\r\n1 10000\r\n0 1\r\n10000 0\r\n9999 -1\r\n", "output": "1 2\r\n"}, {"input": "4\r\n2 3\r\n2 -3\r\n-3 2\r\n-3 -2\r\n", "output": "3 4\r\n"}, {"input": "3\r\n1 -3\r\n1 0\r\n0 1\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 0\r\n-1 0\r\n-1 -1\r\n", "output": "2 3\r\n"}, {"input": "4\r\n-2 1\r\n-2 -1\r\n1 1\r\n1 -1\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 -1\r\n-1 1\r\n-1 -2\r\n", "output": "3 1\r\n"}, {"input": "3\r\n1 0\r\n-1 -1\r\n1 -1\r\n", "output": "3 1\r\n"}, {"input": "3\r\n5 5\r\n-5 0\r\n5 -5\r\n", "output": "3 1\r\n"}, {"input": "4\r\n1 -2\r\n1 0\r\n-1 0\r\n10 -1\r\n", "output": "4 2\r\n"}, {"input": "3\r\n-1000 1\r\n-1000 -1\r\n1000 0\r\n", "output": "1 2\r\n"}, {"input": "6\r\n1 1\r\n1 -1\r\n-1 1\r\n-1 -1\r\n1 -10000\r\n-1 -10000\r\n", "output": "6 5\r\n"}, {"input": "3\r\n1 1\r\n-1 0\r\n0 -1\r\n", "output": "2 3\r\n"}, {"input": "4\r\n5000 1\r\n5000 -1\r\n-2 -1\r\n2 -1\r\n", "output": "2 1\r\n"}, {"input": "3\r\n1 0\r\n-1 1\r\n-1 -5\r\n", "output": "3 1\r\n"}, {"input": "3\r\n-5374 1323\r\n-4463 -8462\r\n6118 -7918\r\n", "output": "2 3\r\n"}, {"input": "4\r\n-6427 -6285\r\n-5386 -5267\r\n-3898 7239\r\n-3905 7252\r\n", "output": "4 3\r\n"}, {"input": "10\r\n-7 -3\r\n-2 8\r\n9 -9\r\n0 1\r\n4 5\r\n5 3\r\n-3 0\r\n10 2\r\n4 -1\r\n2 -10\r\n", "output": "4 2\r\n"}, {"input": "4\r\n9999 1\r\n9999 -1\r\n-9998 1\r\n-10000 -1\r\n", "output": "2 1\r\n"}, {"input": "4\r\n10000 9999\r\n9999 9998\r\n9998 9997\r\n9997 9996\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-6285 -6427\r\n-5267 -5386\r\n7239 -3898\r\n7252 -3905\r\n", "output": "3 4\r\n"}, {"input": "4\r\n-6427 6285\r\n-5386 5267\r\n3898 -7239\r\n3905 -7252\r\n", "output": "4 3\r\n"}, {"input": "4\r\n-6427 -6285\r\n-5386 -5267\r\n-3898 -7239\r\n-3905 -7252\r\n", "output": "3 4\r\n"}, {"input": "3\r\n0 1\r\n-1 -1\r\n1 -1\r\n", "output": "2 3\r\n"}, {"input": "4\r\n10000 1\r\n9998 -1\r\n-9999 1\r\n-9999 -1\r\n", "output": "3 4\r\n"}, {"input": "3\r\n100 0\r\n100 2\r\n100 -1\r\n", "output": "3 1\r\n"}, {"input": "3\r\n-1 1\r\n-1 -1\r\n1 0\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9844 9986\r\n181 9967\r\n-9812 -9925\r\n-194 -9900\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9800 9981\r\n61 9899\r\n-9926 -9932\r\n-149 -9926\r\n", "output": "3 4\r\n"}, {"input": "4\r\n-9901 9900\r\n-10000 9899\r\n9899 9801\r\n9899 9900\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9934 9989\r\n199 9949\r\n-9917 -9974\r\n-197 -9901\r\n", "output": "3 4\r\n"}, {"input": "3\r\n-1 1\r\n1 0\r\n-1 -1\r\n", "output": "1 3\r\n"}, {"input": "3\r\n1 1\r\n-10 -10\r\n-10 -9\r\n", "output": "3 2\r\n"}, {"input": "3\r\n1 0\r\n10000 -1\r\n-1 0\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9999 1\r\n9999 -1\r\n-10000 1\r\n-10000 -1\r\n", "output": "3 4\r\n"}, {"input": "3\r\n-5 1\r\n-5 -1\r\n1 0\r\n", "output": "1 2\r\n"}, {"input": "3\r\n1 0\r\n10000 1\r\n-1 0\r\n", "output": "1 2\r\n"}, {"input": "4\r\n-9990 9995\r\n9994 -9991\r\n-9999 -9992\r\n9993 9992\r\n", "output": "2 4\r\n"}, {"input": "8\r\n1 0\r\n1 1\r\n0 1\r\n-1 1\r\n-1 0\r\n-1 -1\r\n0 -1\r\n1 -2\r\n", "output": "7 8\r\n"}, {"input": "3\r\n-9930 9932\r\n9909 -9909\r\n-9932 -9931\r\n", "output": "3 2\r\n"}, {"input": "4\r\n9876 9977\r\n127 9938\r\n-9820 -9934\r\n-120 -9921\r\n", "output": "3 4\r\n"}, {"input": "3\r\n10000 -1\r\n-1 0\r\n0 -1\r\n", "output": "3 1\r\n"}, {"input": "4\r\n6427 -6285\r\n5386 -5267\r\n3898 7239\r\n3905 7252\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9811 9970\r\n155 9994\r\n-9826 -9977\r\n-159 -9986\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9851 9917\r\n74 9921\r\n-9855 -9916\r\n-77 -9984\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9826 9977\r\n159 9986\r\n-9811 -9970\r\n-155 -9994\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9849 9986\r\n148 9980\r\n-9800 -9999\r\n-116 -9927\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9822 9967\r\n111 9905\r\n-9943 -9986\r\n-163 -9953\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9959 9995\r\n113 9940\r\n-9965 -9931\r\n-148 -9945\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9851 9972\r\n153 9983\r\n-9866 -9926\r\n-183 -9946\r\n", "output": "1 2\r\n"}, {"input": "4\r\n9816 -9979\r\n127 -9940\r\n-9876 9915\r\n-190 9978\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9887 -9917\r\n138 -9977\r\n-9826 9995\r\n-68 9971\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9936 -9965\r\n135 -9949\r\n-9928 9980\r\n-123 9908\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9981 -9985\r\n191 -9956\r\n-9893 9937\r\n-171 9962\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-9811 9970\r\n-155 9994\r\n9826 -9977\r\n159 -9986\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9808 9899\r\n179 9966\r\n-9870 -9961\r\n-179 -9950\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9815 -9936\r\n168 -9937\r\n-9896 9995\r\n-180 9969\r\n", "output": "2 1\r\n"}, {"input": "4\r\n1 1\r\n1 -1\r\n-100 1\r\n-100 -1\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9965 114\r\n87 9916\r\n-9957 -106\r\n-95 -9929\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9895 -9949\r\n188 -9978\r\n-9810 9935\r\n-151 9914\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-9957 106\r\n-95 9929\r\n9965 -114\r\n87 -9916\r\n", "output": "2 1\r\n"}, {"input": "4\r\n-9862 9980\r\n-174 9917\r\n9845 -9967\r\n173 -9980\r\n", "output": "2 1\r\n"}, {"input": "4\r\n9944 9926\r\n9927 9935\r\n-9961 -9929\r\n-9997 -9991\r\n", "output": "3 4\r\n"}, {"input": "4\r\n9917 9909\r\n196 9925\r\n-9971 -9991\r\n-183 -9977\r\n", "output": "3 4\r\n"}]
| false |
stdio
|
import sys
import math
def read_vectors(input_path):
with open(input_path) as f:
n = int(f.readline())
vectors = []
for i in range(n):
x, y = map(int, f.readline().split())
vectors.append( (x, y, i+1) )
return vectors
def compute_angle(x, y):
return math.atan2(y, x) % (2 * math.pi)
def compute_non_oriented_angle(u, v):
ux, uy = u
vx, vy = v
dot = ux * vx + uy * vy
mag_u = math.hypot(ux, uy)
mag_v = math.hypot(vx, vy)
if mag_u == 0 or mag_v == 0:
return 0.0
cos_theta = dot / (mag_u * mag_v)
cos_theta = max(min(cos_theta, 1.0), -1.0)
return math.acos(cos_theta)
def find_min_angle(vectors):
sorted_vectors = sorted(vectors, key=lambda vec: compute_angle(vec[0], vec[1]))
n = len(sorted_vectors)
min_adjacent = math.pi
for i in range(n):
j = (i + 1) % n
u = sorted_vectors[i][0], sorted_vectors[i][1]
v = sorted_vectors[j][0], sorted_vectors[j][1]
theta = compute_non_oriented_angle(u, v)
if theta < min_adjacent:
min_adjacent = theta
angles = []
for vec in sorted_vectors:
x, y, idx = vec
angles.append( compute_angle(x, y) )
min_opposite = math.pi
for i in range(n):
theta_i = angles[i]
target = (theta_i + math.pi) % (2 * math.pi)
low = 0
high = n
while low < high:
mid = (low + high) // 2
if angles[mid] < target:
low = mid + 1
else:
high = mid
candidates = []
if low > 0:
candidates.append(low-1)
if low < n:
candidates.append(low)
candidates.append((low - 1) % n)
candidates = list(set(candidates))
for c in candidates:
if c == i:
continue
c = c % n
vec_c = sorted_vectors[c]
u = sorted_vectors[i][0], sorted_vectors[i][1]
v = vec_c[0], vec_c[1]
current_theta = compute_non_oriented_angle(u, v)
if current_theta < min_opposite:
min_opposite = current_theta
return min(min_adjacent, min_opposite)
def main(input_path, output_path, submission_output_path):
input_vectors = read_vectors(input_path)
with open(submission_output_path) as f:
line = f.readline().strip()
try:
a, b = map(int, line.split())
except:
print(0)
return
n = len(input_vectors)
if a < 1 or a > n or b < 1 or b > n or a == b:
print(0)
return
vec_a = None
vec_b = None
for vec in input_vectors:
if vec[2] == a:
vec_a = vec
if vec[2] == b:
vec_b = vec
if vec_a is None or vec_b is None:
print(0)
return
u = (vec_a[0], vec_a[1])
v = (vec_b[0], vec_b[1])
theta = compute_non_oriented_angle(u, v)
min_angle = find_min_angle(input_vectors)
epsilon = 1e-9
if abs(theta - min_angle) <= epsilon:
print(1)
else:
print(0)
if __name__ == "__main__":
input_path = sys.argv[1]
output_path = sys.argv[2]
submission_output_path = sys.argv[3]
main(input_path, output_path, submission_output_path)
| true |
837/B
|
837
|
B
|
Python 3
|
TESTS
| 79 | 124 | 307,200 |
56131685
|
altura, largura = map(int, input().split())
band = [input() for i in range(altura)]
new_bandeira = [''.join(coluna) for coluna in zip(*band)]
def confere(bandeira, altura):
flag = True
for linha in bandeira:
cor = linha[0]
if cor * len(linha) != linha:
flag = False
break
dicionario = {}
for linha in bandeira:
if linha not in dicionario:
dicionario[linha] = 0
dicionario[linha] += 1
for d in dicionario:
if dicionario[d] != altura/3:
flag = False
ir = []
ib = []
ig = []
for i, linha in enumerate(bandeira):
if linha[0] == 'R':
ir.append(i)
if linha[0] == 'B':
ib.append(i)
if linha[0] == 'G':
ig.append(i)
if flag:
if len(ir) == 2:
if not(ir[1] - ir[0] == ib[1] - ib[0] == ig[1] - ig[0]):
flag = False
if len(ir) > 2:
dif = ir[1] - ir[0]
for i in range(1, len(ir)):
if (ir[i] - ir[i-1]) != dif:
flag = False
if (ib[i] - ib[i-1]) != dif:
flag = False
if (ig[i] - ig[i-1]) != dif:
flag = False
if flag:
return True
else:
return False
if confere(band, altura) or confere(new_bandeira, largura):
print('YES')
else:
print('NO')
| 153 | 62 | 4,608,000 |
29234268
|
#! /usr/bin/python3
import sys
def verifyFlag(flagList, row, column):
if row%3 != 0:
return False
q = row // 3 #since there are 3 equal parts
u = [flagList[(0 * q)], flagList[(1 * q)], flagList[(2 * q)]]
us = set(u) #removes duplicates
patternToMatch = set()
for color in ['R', 'G', 'B']:
patternToMatch.add(color*column)
if us != patternToMatch:
return False
for i,row in enumerate(flagList):
if row != u[i//q]:
return False
return True
def main():
n, m = map(int,sys.stdin.readline().split())
#get the horizontal columns
a = []
for i in range(n):
a.append(sys.stdin.readline().rstrip())
#get the vertical columns
b = []
for i in range(m):
temp = ''
for j in range(n):
temp += a[j][i]
b.append(temp)
rv1 = verifyFlag(a,n,m)
rv2 = verifyFlag(b,m,n)
if rv1 or rv2:
print('YES')
else:
print('NO')
main()
|
Educational Codeforces Round 26
|
ICPC
| 2,017 | 1 | 256 |
Flag of Berland
|
The flag of Berland is such rectangular field n × m that satisfies following conditions:
- Flag consists of three colors which correspond to letters 'R', 'G' and 'B'.
- Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color.
- Each color should be used in exactly one stripe.
You are given a field n × m, consisting of characters 'R', 'G' and 'B'. Output "YES" (without quotes) if this field corresponds to correct flag of Berland. Otherwise, print "NO" (without quotes).
|
The first line contains two integer numbers n and m (1 ≤ n, m ≤ 100) — the sizes of the field.
Each of the following n lines consisting of m characters 'R', 'G' and 'B' — the description of the field.
|
Print "YES" (without quotes) if the given field corresponds to correct flag of Berland . Otherwise, print "NO" (without quotes).
| null |
The field in the third example doesn't have three parralel stripes.
Rows of the field in the fourth example are parralel to each other and to borders. But they have different heights — 2, 1 and 1.
|
[{"input": "6 5\nRRRRR\nRRRRR\nBBBBB\nBBBBB\nGGGGG\nGGGGG", "output": "YES"}, {"input": "4 3\nBRG\nBRG\nBRG\nBRG", "output": "YES"}, {"input": "6 7\nRRRGGGG\nRRRGGGG\nRRRGGGG\nRRRBBBB\nRRRBBBB\nRRRBBBB", "output": "NO"}, {"input": "4 4\nRRRR\nRRRR\nBBBB\nGGGG", "output": "NO"}]
| 1,600 |
["brute force", "implementation"]
| 153 |
[{"input": "6 5\r\nRRRRR\r\nRRRRR\r\nBBBBB\r\nBBBBB\r\nGGGGG\r\nGGGGG\r\n", "output": "YES\r\n"}, {"input": "4 3\r\nBRG\r\nBRG\r\nBRG\r\nBRG\r\n", "output": "YES\r\n"}, {"input": "6 7\r\nRRRGGGG\r\nRRRGGGG\r\nRRRGGGG\r\nRRRBBBB\r\nRRRBBBB\r\nRRRBBBB\r\n", "output": "NO\r\n"}, {"input": "4 4\r\nRRRR\r\nRRRR\r\nBBBB\r\nGGGG\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nGRB\r\n", "output": "YES\r\n"}, {"input": "3 1\r\nR\r\nG\r\nB\r\n", "output": "YES\r\n"}, {"input": "4 3\r\nRGB\r\nGRB\r\nGRB\r\nGRB\r\n", "output": "NO\r\n"}, {"input": "4 6\r\nGGRRBB\r\nGGRRBB\r\nGGRRBB\r\nRRGGBB\r\n", "output": "NO\r\n"}, {"input": "100 3\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nGRB\r\n", "output": "NO\r\n"}, {"input": "3 100\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\nRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRG\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nR\r\nR\r\nB\r\n", "output": "NO\r\n"}, {"input": "3 2\r\nRR\r\nBB\r\nRR\r\n", "output": "NO\r\n"}, {"input": "3 2\r\nRR\r\nBG\r\nBG\r\n", "output": "NO\r\n"}, {"input": "3 2\r\nBB\r\nRR\r\nBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nRRR\r\nRRR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nGGG\r\nGGG\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRGG\r\n", "output": "NO\r\n"}, {"input": "4 3\r\nRGR\r\nRGR\r\nRGR\r\nRGR\r\n", "output": "NO\r\n"}, {"input": "3 4\r\nRRGG\r\nRRGG\r\nBBBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nBRG\r\nBRG\r\nBRG\r\n", "output": "YES\r\n"}, {"input": "3 1\r\nR\r\nG\r\nR\r\n", "output": "NO\r\n"}, {"input": "5 3\r\nBBG\r\nBBG\r\nBBG\r\nBBG\r\nBBG\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nGGG\r\nRRR\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRGR\r\n", "output": "NO\r\n"}, {"input": "3 6\r\nRRBBGG\r\nRRBBGG\r\nRRBBGG\r\n", "output": "YES\r\n"}, {"input": "6 6\r\nRRBBGG\r\nRRBBGG\r\nRRBBGG\r\nRRBBGG\r\nRRBBGG\r\nRRBBGG\r\n", "output": "YES\r\n"}, {"input": "4 3\r\nRRR\r\nGGG\r\nBBB\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nBBB\r\nRRR\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nB\r\nR\r\nB\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nBGB\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nB\r\nB\r\nB\r\n", "output": "NO\r\n"}, {"input": "3 4\r\nRRRR\r\nBBBB\r\nRRRR\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRGGGBB\r\n", "output": "NO\r\n"}, {"input": "9 3\r\nBBB\r\nBBB\r\nBBB\r\nGGG\r\nGGG\r\nGRG\r\nRGR\r\nRRR\r\nRRR\r\n", "output": "NO\r\n"}, {"input": "4 4\r\nRGBB\r\nRGBB\r\nRGBB\r\nRGBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRBR\r\nRBR\r\nRBR\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRRRRBB\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRRRRRR\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRRGGGG\r\n", "output": "NO\r\n"}, {"input": "4 4\r\nRRRR\r\nRRRR\r\nRRRR\r\nRRRR\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nB\r\nG\r\nB\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nR\r\nR\r\nR\r\n", "output": "NO\r\n"}, {"input": "1 9\r\nRRRGGGBBB\r\n", "output": "YES\r\n"}, {"input": "1 3\r\nRRR\r\n", "output": "NO\r\n"}, {"input": "3 5\r\nRRRRR\r\nBBBBB\r\nBBBBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nGGG\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "1 1\r\nR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGR\r\nRGR\r\nRGR\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRBG\r\nGBR\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nRGB\r\nRGB\r\n", "output": "YES\r\n"}, {"input": "1 3\r\nBRB\r\n", "output": "NO\r\n"}, {"input": "2 1\r\nR\r\nB\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRBR\r\n", "output": "NO\r\n"}, {"input": "3 5\r\nRRGBB\r\nRRGBB\r\nRRGBB\r\n", "output": "NO\r\n"}, {"input": "5 3\r\nBBR\r\nBBR\r\nBBR\r\nBBR\r\nBBR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nRBG\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "1 2\r\nRB\r\n", "output": "NO\r\n"}, {"input": "4 3\r\nBBB\r\nBBB\r\nBBB\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "36 6\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\n", "output": "NO\r\n"}, {"input": "4 1\r\nR\r\nB\r\nG\r\nR\r\n", "output": "NO\r\n"}, {"input": "13 12\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\n", "output": "NO\r\n"}, {"input": "2 2\r\nRR\r\nRR\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nRRGGBB\r\nGRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\n", "output": "NO\r\n"}, {"input": "70 3\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\n", "output": "NO\r\n"}, {"input": "4 3\r\nBBG\r\nBBG\r\nBBG\r\nBBG\r\n", "output": "NO\r\n"}, {"input": "6 3\r\nBBB\r\nGGG\r\nRRR\r\nBRG\r\nBRG\r\nBRG\r\n", "output": "NO\r\n"}, {"input": "3 6\r\nRRBBGG\r\nRBBBGG\r\nRBBBGG\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nGGGGGG\r\nGGGGGG\r\nBBBBBB\r\nBBBBBB\r\nGGGGGG\r\nGGGGGG\r\n", "output": "NO\r\n"}, {"input": "6 1\r\nR\r\nB\r\nG\r\nR\r\nB\r\nG\r\n", "output": "NO\r\n"}, {"input": "6 5\r\nRRRRR\r\nBBBBB\r\nGGGGG\r\nRRRRR\r\nBBBBB\r\nGGGGG\r\n", "output": "NO\r\n"}, {"input": "6 3\r\nRRR\r\nGGG\r\nBBB\r\nRRR\r\nGGG\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "6 5\r\nRRRRR\r\nRRRRR\r\nRRRRR\r\nGGGGG\r\nGGGGG\r\nGGGGG\r\n", "output": "NO\r\n"}, {"input": "15 28\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\n", "output": "NO\r\n"}, {"input": "21 10\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nBBBBBBBBBB\r\nBBBBBBBBBB\r\nBBBBBGBBBB\r\nBBBBBBBBBB\r\nBBBBBBBBBB\r\nBBBBBBBBBB\r\nBBBBBBBBBB\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\n", "output": "NO\r\n"}, {"input": "3 2\r\nRR\r\nGB\r\nGB\r\n", "output": "NO\r\n"}, {"input": "3 2\r\nRG\r\nRG\r\nBB\r\n", "output": "NO\r\n"}, {"input": "6 5\r\nRRRRR\r\nRRRRR\r\nBBBBB\r\nBBBBB\r\nRRRRR\r\nRRRRR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nGBR\r\nBRG\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nBGR\r\nBGR\r\nBGR\r\n", "output": "YES\r\n"}, {"input": "6 6\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\n", "output": "YES\r\n"}, {"input": "4 2\r\nRR\r\nGG\r\nRR\r\nBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nRRR\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "8 6\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\n", "output": "NO\r\n"}, {"input": "3 4\r\nRRRR\r\nRRRR\r\nGGGG\r\n", "output": "NO\r\n"}, {"input": "3 4\r\nRRRR\r\nRRRR\r\nRRRR\r\n", "output": "NO\r\n"}, {"input": "6 1\r\nR\r\nR\r\nR\r\nR\r\nR\r\nR\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRRBBGG\r\n", "output": "YES\r\n"}, {"input": "1 6\r\nRGBRGB\r\n", "output": "NO\r\n"}, {"input": "3 4\r\nRRRR\r\nGGGG\r\nRRRR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRB\r\nGRG\r\nGBB\r\n", "output": "NO\r\n"}, {"input": "3 7\r\nRRGGBBB\r\nRRGGBBB\r\nRRGGBBB\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nG\r\nR\r\nR\r\n", "output": "NO\r\n"}, {"input": "2 3\r\nRGG\r\nRBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRG\r\nGGG\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nRBB\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGR\r\nRGB\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nB\r\nR\r\nR\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nGRR\r\n", "output": "NO\r\n"}, {"input": "4 4\r\nRRRR\r\nGGGG\r\nBBBB\r\nBBBB\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nGGR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nGGB\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGR\r\nGGG\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nRRRRRR\r\nGGGGGG\r\nGGGGGG\r\nGGGGGG\r\nBBBBBB\r\nBBBBBB\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nRRRRRR\r\nRRRRRR\r\nGGGGGG\r\nBBBBBB\r\nBBBBBB\r\nBBBBBB\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nG\r\nB\r\nR\r\n", "output": "YES\r\n"}, {"input": "3 3\r\nGGB\r\nRGB\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nGRR\r\nGGG\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nRRRRRR\r\nRRRRRR\r\nGGGGGG\r\nGGGGGG\r\nBBBBBB\r\nRRRRRR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nGBG\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "3 8\r\nRRGGBBBB\r\nRRGGBBBB\r\nRRGGBBBB\r\n", "output": "NO\r\n"}, {"input": "2 2\r\nRR\r\nGG\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nRGR\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRBG\r\n", "output": "YES\r\n"}, {"input": "2 6\r\nRRGGBB\r\nGGRRBB\r\n", "output": "NO\r\n"}, {"input": "6 2\r\nRR\r\nGG\r\nBB\r\nRR\r\nGG\r\nBB\r\n", "output": "NO\r\n"}, {"input": "1 5\r\nRRGGB\r\n", "output": "NO\r\n"}, {"input": "1 2\r\nRG\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRGBRBG\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRRRGGB\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRGB\r\n", "output": "YES\r\n"}, {"input": "4 3\r\nRRR\r\nBBR\r\nGBB\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "6 3\r\nRRR\r\nBBB\r\nBBB\r\nBBB\r\nGGG\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRBG\r\nRBG\r\nRBG\r\n", "output": "YES\r\n"}, {"input": "6 3\r\nRRR\r\nBBB\r\nGGG\r\nRRR\r\nBBB\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "1 4\r\nRGBB\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\n", "output": "NO\r\n"}, {"input": "6 5\r\nRRRRR\r\nRRRRR\r\nGGGGG\r\nGGGGG\r\nRRRRR\r\nRRRRR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nBRG\r\nGBR\r\n", "output": "NO\r\n"}, {"input": "6 10\r\nRRRRRRRRRR\r\nGGGGGGGGGG\r\nBBBBBBBBBB\r\nRRRRRRRRRR\r\nGGGGGGGGGG\r\nBBBBBBBBBB\r\n", "output": "NO\r\n"}, {"input": "20 6\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\n", "output": "YES\r\n"}, {"input": "4 1\r\nR\r\nG\r\nB\r\nR\r\n", "output": "NO\r\n"}, {"input": "1 4\r\nRGBR\r\n", "output": "NO\r\n"}, {"input": "2 4\r\nRGBB\r\nRRGB\r\n", "output": "NO\r\n"}]
| false |
stdio
| null | true |
807/A
|
807
|
A
|
Python 3
|
TESTS
| 28 | 46 | 0 |
188425791
|
def is_it_rated():
n = int(input())
before, after = list(), list()
for i in range(n):
b, a = map(int, input().split())
before.append(b)
after.append(a)
maybe = False
for i in range(n):
if before[i] != after[i]:
return "rated"
max_till = before[0]
for i in range(1,n):
if before[i] <= max_till:
max_till = before[i]
maybe = True
continue
else:
maybe = False
if maybe == True:
return "maybe"
return "unrated"
print(is_it_rated())
| 150 | 46 | 0 |
141227803
|
l=[];l1=[]
t=int(input())
for i in range(t):
a,b=map(int,input().split())
l.append(a);l1.append(b)
p=l
x=[i-j for (i,j) in zip(l,l1)]
y=sorted(p,reverse=True)
if x.count(0)!=t:
print("rated")
elif x.count(0)==t and y!=l:
print("unrated")
else:
print("maybe")
|
Codeforces Round 412 (rated, Div. 2, base on VK Cup 2017 Round 3)
|
CF
| 2,017 | 2 | 256 |
Is it rated?
|
Is it rated?
Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it.
Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before and after the round is known.
It's known that if at least one participant's rating has changed, then the round was rated for sure.
It's also known that if the round was rated and a participant with lower rating took a better place in the standings than a participant with higher rating, then at least one round participant's rating has changed.
In this problem, you should not make any other assumptions about the rating system.
Determine if the current round is rated, unrated, or it's impossible to determine whether it is rated of not.
|
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of round participants.
Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 4126) — the rating of the i-th participant before and after the round, respectively. The participants are listed in order from the top to the bottom of the standings.
|
If the round is rated for sure, print "rated". If the round is unrated for sure, print "unrated". If it's impossible to determine whether the round is rated or not, print "maybe".
| null |
In the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated.
In the second example, no one's rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, someone's rating would've changed for sure.
In the third example, no one's rating has changed, and the participants took places in non-increasing order of their rating. Therefore, it's impossible to determine whether the round is rated or not.
|
[{"input": "6\n3060 3060\n2194 2194\n2876 2903\n2624 2624\n3007 2991\n2884 2884", "output": "rated"}, {"input": "4\n1500 1500\n1300 1300\n1200 1200\n1400 1400", "output": "unrated"}, {"input": "5\n3123 3123\n2777 2777\n2246 2246\n2246 2246\n1699 1699", "output": "maybe"}]
| 900 |
["implementation", "sortings"]
| 150 |
[{"input": "6\r\n3060 3060\r\n2194 2194\r\n2876 2903\r\n2624 2624\r\n3007 2991\r\n2884 2884\r\n", "output": "rated\r\n"}, {"input": "4\r\n1500 1500\r\n1300 1300\r\n1200 1200\r\n1400 1400\r\n", "output": "unrated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n1699 1699\r\n", "output": "maybe\r\n"}, {"input": "2\r\n1 1\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "2\r\n4126 4126\r\n4126 4126\r\n", "output": "maybe\r\n"}, {"input": "10\r\n446 446\r\n1331 1331\r\n3594 3594\r\n1346 1902\r\n91 91\r\n3590 3590\r\n2437 2437\r\n4007 3871\r\n2797 699\r\n1423 1423\r\n", "output": "rated\r\n"}, {"input": "10\r\n4078 4078\r\n2876 2876\r\n1061 1061\r\n3721 3721\r\n143 143\r\n2992 2992\r\n3279 3279\r\n3389 3389\r\n1702 1702\r\n1110 1110\r\n", "output": "unrated\r\n"}, {"input": "10\r\n4078 4078\r\n3721 3721\r\n3389 3389\r\n3279 3279\r\n2992 2992\r\n2876 2876\r\n1702 1702\r\n1110 1110\r\n1061 1061\r\n143 143\r\n", "output": "maybe\r\n"}, {"input": "2\r\n3936 3936\r\n2967 2967\r\n", "output": "maybe\r\n"}, {"input": "2\r\n1 1\r\n2 2\r\n", "output": "unrated\r\n"}, {"input": "2\r\n2 2\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "2\r\n2 1\r\n1 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n2967 2967\r\n3936 3936\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1200 1200\r\n1200 1200\r\n1300 1300\r\n", "output": "unrated\r\n"}, {"input": "3\r\n3 3\r\n2 2\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "3\r\n1 1\r\n1 1\r\n2 2\r\n", "output": "unrated\r\n"}, {"input": "2\r\n3 2\r\n3 2\r\n", "output": "rated\r\n"}, {"input": "3\r\n5 5\r\n4 4\r\n3 4\r\n", "output": "rated\r\n"}, {"input": "3\r\n200 200\r\n200 200\r\n300 300\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1 1\r\n2 2\r\n3 3\r\n", "output": "unrated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2245 2245\r\n1699 1699\r\n", "output": "maybe\r\n"}, {"input": "2\r\n10 10\r\n8 8\r\n", "output": "maybe\r\n"}, {"input": "3\r\n1500 1500\r\n1500 1500\r\n1600 1600\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1500 1500\r\n1500 1500\r\n1700 1700\r\n", "output": "unrated\r\n"}, {"input": "4\r\n100 100\r\n100 100\r\n70 70\r\n80 80\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1 2\r\n2 1\r\n", "output": "rated\r\n"}, {"input": "3\r\n5 5\r\n4 3\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "3\r\n1600 1650\r\n1500 1550\r\n1400 1450\r\n", "output": "rated\r\n"}, {"input": "4\r\n2000 2000\r\n1500 1500\r\n1500 1500\r\n1700 1700\r\n", "output": "unrated\r\n"}, {"input": "4\r\n1500 1500\r\n1400 1400\r\n1400 1400\r\n1700 1700\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1600 1600\r\n1400 1400\r\n", "output": "maybe\r\n"}, {"input": "2\r\n3 1\r\n9 8\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 1\r\n1 1\r\n", "output": "rated\r\n"}, {"input": "4\r\n4123 4123\r\n4123 4123\r\n2670 2670\r\n3670 3670\r\n", "output": "unrated\r\n"}, {"input": "2\r\n2 2\r\n3 3\r\n", "output": "unrated\r\n"}, {"input": "2\r\n10 11\r\n5 4\r\n", "output": "rated\r\n"}, {"input": "2\r\n15 14\r\n13 12\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 1\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "3\r\n2670 2670\r\n3670 3670\r\n4106 4106\r\n", "output": "unrated\r\n"}, {"input": "3\r\n4 5\r\n3 3\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n10 9\r\n10 10\r\n", "output": "rated\r\n"}, {"input": "3\r\n1011 1011\r\n1011 999\r\n2200 2100\r\n", "output": "rated\r\n"}, {"input": "2\r\n3 3\r\n5 5\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1500 1500\r\n3000 2000\r\n", "output": "rated\r\n"}, {"input": "2\r\n5 6\r\n5 5\r\n", "output": "rated\r\n"}, {"input": "3\r\n2000 2000\r\n1500 1501\r\n500 500\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 3\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n3 3\r\n2 2\r\n", "output": "maybe\r\n"}, {"input": "2\r\n1 2\r\n1 1\r\n", "output": "rated\r\n"}, {"input": "4\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n1699 1699\r\n", "output": "maybe\r\n"}, {"input": "2\r\n15 14\r\n14 13\r\n", "output": "rated\r\n"}, {"input": "4\r\n3000 3000\r\n2900 2900\r\n3000 3000\r\n2900 2900\r\n", "output": "unrated\r\n"}, {"input": "6\r\n30 3060\r\n24 2194\r\n26 2903\r\n24 2624\r\n37 2991\r\n24 2884\r\n", "output": "rated\r\n"}, {"input": "2\r\n100 99\r\n100 100\r\n", "output": "rated\r\n"}, {"input": "4\r\n2 2\r\n1 1\r\n1 1\r\n2 2\r\n", "output": "unrated\r\n"}, {"input": "3\r\n100 101\r\n100 100\r\n100 100\r\n", "output": "rated\r\n"}, {"input": "4\r\n1000 1001\r\n900 900\r\n950 950\r\n890 890\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 3\r\n1 1\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 2\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "2\r\n3 2\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n3 2\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "2\r\n1 1\r\n2 2\r\n", "output": "unrated\r\n"}, {"input": "3\r\n3 2\r\n3 3\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "4\r\n1500 1501\r\n1300 1300\r\n1200 1200\r\n1400 1400\r\n", "output": "rated\r\n"}, {"input": "3\r\n1000 1000\r\n500 500\r\n400 300\r\n", "output": "rated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n3000 3000\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1 1\r\n2 3\r\n", "output": "rated\r\n"}, {"input": "2\r\n6 2\r\n6 2\r\n", "output": "rated\r\n"}, {"input": "5\r\n3123 3123\r\n1699 1699\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1500 1500\r\n1600 1600\r\n", "output": "unrated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2241 2241\r\n1699 1699\r\n", "output": "maybe\r\n"}, {"input": "2\r\n20 30\r\n10 5\r\n", "output": "rated\r\n"}, {"input": "3\r\n1 1\r\n2 2\r\n1 1\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1 2\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "5\r\n5 5\r\n4 4\r\n3 3\r\n2 2\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "2\r\n2 2\r\n2 1\r\n", "output": "rated\r\n"}, {"input": "2\r\n100 100\r\n90 89\r\n", "output": "rated\r\n"}, {"input": "2\r\n1000 900\r\n2000 2000\r\n", "output": "rated\r\n"}, {"input": "2\r\n50 10\r\n10 50\r\n", "output": "rated\r\n"}, {"input": "2\r\n200 200\r\n100 100\r\n", "output": "maybe\r\n"}, {"input": "3\r\n2 2\r\n2 2\r\n3 3\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1000 1000\r\n300 300\r\n100 100\r\n", "output": "maybe\r\n"}, {"input": "4\r\n2 2\r\n2 2\r\n3 3\r\n4 4\r\n", "output": "unrated\r\n"}, {"input": "2\r\n5 3\r\n6 3\r\n", "output": "rated\r\n"}, {"input": "2\r\n1200 1100\r\n1200 1000\r\n", "output": "rated\r\n"}, {"input": "2\r\n5 5\r\n4 4\r\n", "output": "maybe\r\n"}, {"input": "2\r\n5 5\r\n3 3\r\n", "output": "maybe\r\n"}, {"input": "5\r\n1500 1500\r\n1300 1300\r\n1200 1200\r\n1400 1400\r\n1100 1100\r\n", "output": "unrated\r\n"}, {"input": "5\r\n10 10\r\n9 9\r\n8 8\r\n7 7\r\n6 6\r\n", "output": "maybe\r\n"}, {"input": "3\r\n1000 1000\r\n300 300\r\n10 10\r\n", "output": "maybe\r\n"}, {"input": "5\r\n6 6\r\n5 5\r\n4 4\r\n3 3\r\n2 2\r\n", "output": "maybe\r\n"}, {"input": "2\r\n3 3\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "4\r\n2 2\r\n2 2\r\n2 2\r\n3 3\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1000 1000\r\n700 700\r\n", "output": "maybe\r\n"}, {"input": "2\r\n4 3\r\n5 3\r\n", "output": "rated\r\n"}, {"input": "2\r\n1000 1000\r\n1100 1100\r\n", "output": "unrated\r\n"}, {"input": "4\r\n5 5\r\n4 4\r\n3 3\r\n2 2\r\n", "output": "maybe\r\n"}, {"input": "3\r\n1 1\r\n2 3\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n1 2\r\n1 3\r\n", "output": "rated\r\n"}, {"input": "2\r\n3 3\r\n1 2\r\n", "output": "rated\r\n"}, {"input": "4\r\n1501 1500\r\n1300 1300\r\n1200 1200\r\n1400 1400\r\n", "output": "rated\r\n"}, {"input": "5\r\n1 1\r\n2 2\r\n3 3\r\n4 4\r\n5 5\r\n", "output": "unrated\r\n"}, {"input": "2\r\n10 10\r\n1 2\r\n", "output": "rated\r\n"}, {"input": "6\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n1699 1699\r\n1900 1900\r\n", "output": "unrated\r\n"}, {"input": "6\r\n3123 3123\r\n2777 2777\r\n3000 3000\r\n2246 2246\r\n2246 2246\r\n1699 1699\r\n", "output": "unrated\r\n"}, {"input": "2\r\n100 100\r\n110 110\r\n", "output": "unrated\r\n"}, {"input": "3\r\n3 3\r\n3 3\r\n4 4\r\n", "output": "unrated\r\n"}, {"input": "3\r\n3 3\r\n3 2\r\n4 4\r\n", "output": "rated\r\n"}, {"input": "3\r\n5 2\r\n4 4\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "4\r\n4 4\r\n3 3\r\n2 2\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "2\r\n1 1\r\n3 2\r\n", "output": "rated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n2699 2699\r\n", "output": "unrated\r\n"}, {"input": "3\r\n3 3\r\n3 3\r\n3 4\r\n", "output": "rated\r\n"}, {"input": "3\r\n1 2\r\n2 2\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "3\r\n1 2\r\n1 2\r\n1 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 1\r\n2 1\r\n", "output": "rated\r\n"}, {"input": "2\r\n1 2\r\n3 4\r\n", "output": "rated\r\n"}, {"input": "2\r\n3 2\r\n2 3\r\n", "output": "rated\r\n"}, {"input": "3\r\n1500 1500\r\n1600 1600\r\n1600 1600\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1 1\r\n3 3\r\n4 4\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1 1\r\n2 2\r\n2 2\r\n", "output": "unrated\r\n"}, {"input": "2\r\n10 12\r\n8 8\r\n", "output": "rated\r\n"}, {"input": "5\r\n1200 1200\r\n1500 1500\r\n1500 1500\r\n1500 1500\r\n1500 1500\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1 2\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "3\r\n1500 1400\r\n1200 1200\r\n1100 1100\r\n", "output": "rated\r\n"}, {"input": "2\r\n10 12\r\n10 10\r\n", "output": "rated\r\n"}, {"input": "3\r\n1500 1500\r\n1400 1400\r\n1300 1300\r\n", "output": "maybe\r\n"}, {"input": "3\r\n3 3\r\n4 4\r\n5 5\r\n", "output": "unrated\r\n"}, {"input": "3\r\n2 6\r\n3 5\r\n4 4\r\n", "output": "rated\r\n"}, {"input": "2\r\n5 6\r\n4 6\r\n", "output": "rated\r\n"}, {"input": "4\r\n10 10\r\n10 10\r\n7 7\r\n8 8\r\n", "output": "unrated\r\n"}, {"input": "2\r\n4 4\r\n3 3\r\n", "output": "maybe\r\n"}]
| false |
stdio
| null | true |
807/A
|
807
|
A
|
Python 3
|
TESTS
| 28 | 46 | 0 |
145144892
|
n=int(input())
a,b=0,0
counter=0
List=[]
for i in range(n):
a,b=map(int,input().split())
if a!=b:
counter+=1
List.append([a,b])
if counter!=0:
print("rated")
else:
minValue=min(List)
if minValue !=List[len(List)-1]:
print("unrated")
else:
print("maybe")
| 150 | 46 | 0 |
144055840
|
w=int(input())
l=[]
flag=0
for i in range(w):
t=list(map(int,input().split()))
if t[0]!=t[1]:
flag=1
else:
l.append(t[0])
if flag!=1:
y=list(l)
y.sort(reverse=True)
if y==l:
print('maybe')
else:
print('unrated')
else:
print('rated')
|
Codeforces Round 412 (rated, Div. 2, base on VK Cup 2017 Round 3)
|
CF
| 2,017 | 2 | 256 |
Is it rated?
|
Is it rated?
Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it.
Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before and after the round is known.
It's known that if at least one participant's rating has changed, then the round was rated for sure.
It's also known that if the round was rated and a participant with lower rating took a better place in the standings than a participant with higher rating, then at least one round participant's rating has changed.
In this problem, you should not make any other assumptions about the rating system.
Determine if the current round is rated, unrated, or it's impossible to determine whether it is rated of not.
|
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of round participants.
Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 4126) — the rating of the i-th participant before and after the round, respectively. The participants are listed in order from the top to the bottom of the standings.
|
If the round is rated for sure, print "rated". If the round is unrated for sure, print "unrated". If it's impossible to determine whether the round is rated or not, print "maybe".
| null |
In the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated.
In the second example, no one's rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, someone's rating would've changed for sure.
In the third example, no one's rating has changed, and the participants took places in non-increasing order of their rating. Therefore, it's impossible to determine whether the round is rated or not.
|
[{"input": "6\n3060 3060\n2194 2194\n2876 2903\n2624 2624\n3007 2991\n2884 2884", "output": "rated"}, {"input": "4\n1500 1500\n1300 1300\n1200 1200\n1400 1400", "output": "unrated"}, {"input": "5\n3123 3123\n2777 2777\n2246 2246\n2246 2246\n1699 1699", "output": "maybe"}]
| 900 |
["implementation", "sortings"]
| 150 |
[{"input": "6\r\n3060 3060\r\n2194 2194\r\n2876 2903\r\n2624 2624\r\n3007 2991\r\n2884 2884\r\n", "output": "rated\r\n"}, {"input": "4\r\n1500 1500\r\n1300 1300\r\n1200 1200\r\n1400 1400\r\n", "output": "unrated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n1699 1699\r\n", "output": "maybe\r\n"}, {"input": "2\r\n1 1\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "2\r\n4126 4126\r\n4126 4126\r\n", "output": "maybe\r\n"}, {"input": "10\r\n446 446\r\n1331 1331\r\n3594 3594\r\n1346 1902\r\n91 91\r\n3590 3590\r\n2437 2437\r\n4007 3871\r\n2797 699\r\n1423 1423\r\n", "output": "rated\r\n"}, {"input": "10\r\n4078 4078\r\n2876 2876\r\n1061 1061\r\n3721 3721\r\n143 143\r\n2992 2992\r\n3279 3279\r\n3389 3389\r\n1702 1702\r\n1110 1110\r\n", "output": "unrated\r\n"}, {"input": "10\r\n4078 4078\r\n3721 3721\r\n3389 3389\r\n3279 3279\r\n2992 2992\r\n2876 2876\r\n1702 1702\r\n1110 1110\r\n1061 1061\r\n143 143\r\n", "output": "maybe\r\n"}, {"input": "2\r\n3936 3936\r\n2967 2967\r\n", "output": "maybe\r\n"}, {"input": "2\r\n1 1\r\n2 2\r\n", "output": "unrated\r\n"}, {"input": "2\r\n2 2\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "2\r\n2 1\r\n1 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n2967 2967\r\n3936 3936\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1200 1200\r\n1200 1200\r\n1300 1300\r\n", "output": "unrated\r\n"}, {"input": "3\r\n3 3\r\n2 2\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "3\r\n1 1\r\n1 1\r\n2 2\r\n", "output": "unrated\r\n"}, {"input": "2\r\n3 2\r\n3 2\r\n", "output": "rated\r\n"}, {"input": "3\r\n5 5\r\n4 4\r\n3 4\r\n", "output": "rated\r\n"}, {"input": "3\r\n200 200\r\n200 200\r\n300 300\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1 1\r\n2 2\r\n3 3\r\n", "output": "unrated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2245 2245\r\n1699 1699\r\n", "output": "maybe\r\n"}, {"input": "2\r\n10 10\r\n8 8\r\n", "output": "maybe\r\n"}, {"input": "3\r\n1500 1500\r\n1500 1500\r\n1600 1600\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1500 1500\r\n1500 1500\r\n1700 1700\r\n", "output": "unrated\r\n"}, {"input": "4\r\n100 100\r\n100 100\r\n70 70\r\n80 80\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1 2\r\n2 1\r\n", "output": "rated\r\n"}, {"input": "3\r\n5 5\r\n4 3\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "3\r\n1600 1650\r\n1500 1550\r\n1400 1450\r\n", "output": "rated\r\n"}, {"input": "4\r\n2000 2000\r\n1500 1500\r\n1500 1500\r\n1700 1700\r\n", "output": "unrated\r\n"}, {"input": "4\r\n1500 1500\r\n1400 1400\r\n1400 1400\r\n1700 1700\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1600 1600\r\n1400 1400\r\n", "output": "maybe\r\n"}, {"input": "2\r\n3 1\r\n9 8\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 1\r\n1 1\r\n", "output": "rated\r\n"}, {"input": "4\r\n4123 4123\r\n4123 4123\r\n2670 2670\r\n3670 3670\r\n", "output": "unrated\r\n"}, {"input": "2\r\n2 2\r\n3 3\r\n", "output": "unrated\r\n"}, {"input": "2\r\n10 11\r\n5 4\r\n", "output": "rated\r\n"}, {"input": "2\r\n15 14\r\n13 12\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 1\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "3\r\n2670 2670\r\n3670 3670\r\n4106 4106\r\n", "output": "unrated\r\n"}, {"input": "3\r\n4 5\r\n3 3\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n10 9\r\n10 10\r\n", "output": "rated\r\n"}, {"input": "3\r\n1011 1011\r\n1011 999\r\n2200 2100\r\n", "output": "rated\r\n"}, {"input": "2\r\n3 3\r\n5 5\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1500 1500\r\n3000 2000\r\n", "output": "rated\r\n"}, {"input": "2\r\n5 6\r\n5 5\r\n", "output": "rated\r\n"}, {"input": "3\r\n2000 2000\r\n1500 1501\r\n500 500\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 3\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n3 3\r\n2 2\r\n", "output": "maybe\r\n"}, {"input": "2\r\n1 2\r\n1 1\r\n", "output": "rated\r\n"}, {"input": "4\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n1699 1699\r\n", "output": "maybe\r\n"}, {"input": "2\r\n15 14\r\n14 13\r\n", "output": "rated\r\n"}, {"input": "4\r\n3000 3000\r\n2900 2900\r\n3000 3000\r\n2900 2900\r\n", "output": "unrated\r\n"}, {"input": "6\r\n30 3060\r\n24 2194\r\n26 2903\r\n24 2624\r\n37 2991\r\n24 2884\r\n", "output": "rated\r\n"}, {"input": "2\r\n100 99\r\n100 100\r\n", "output": "rated\r\n"}, {"input": "4\r\n2 2\r\n1 1\r\n1 1\r\n2 2\r\n", "output": "unrated\r\n"}, {"input": "3\r\n100 101\r\n100 100\r\n100 100\r\n", "output": "rated\r\n"}, {"input": "4\r\n1000 1001\r\n900 900\r\n950 950\r\n890 890\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 3\r\n1 1\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 2\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "2\r\n3 2\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n3 2\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "2\r\n1 1\r\n2 2\r\n", "output": "unrated\r\n"}, {"input": "3\r\n3 2\r\n3 3\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "4\r\n1500 1501\r\n1300 1300\r\n1200 1200\r\n1400 1400\r\n", "output": "rated\r\n"}, {"input": "3\r\n1000 1000\r\n500 500\r\n400 300\r\n", "output": "rated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n3000 3000\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1 1\r\n2 3\r\n", "output": "rated\r\n"}, {"input": "2\r\n6 2\r\n6 2\r\n", "output": "rated\r\n"}, {"input": "5\r\n3123 3123\r\n1699 1699\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1500 1500\r\n1600 1600\r\n", "output": "unrated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2241 2241\r\n1699 1699\r\n", "output": "maybe\r\n"}, {"input": "2\r\n20 30\r\n10 5\r\n", "output": "rated\r\n"}, {"input": "3\r\n1 1\r\n2 2\r\n1 1\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1 2\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "5\r\n5 5\r\n4 4\r\n3 3\r\n2 2\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "2\r\n2 2\r\n2 1\r\n", "output": "rated\r\n"}, {"input": "2\r\n100 100\r\n90 89\r\n", "output": "rated\r\n"}, {"input": "2\r\n1000 900\r\n2000 2000\r\n", "output": "rated\r\n"}, {"input": "2\r\n50 10\r\n10 50\r\n", "output": "rated\r\n"}, {"input": "2\r\n200 200\r\n100 100\r\n", "output": "maybe\r\n"}, {"input": "3\r\n2 2\r\n2 2\r\n3 3\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1000 1000\r\n300 300\r\n100 100\r\n", "output": "maybe\r\n"}, {"input": "4\r\n2 2\r\n2 2\r\n3 3\r\n4 4\r\n", "output": "unrated\r\n"}, {"input": "2\r\n5 3\r\n6 3\r\n", "output": "rated\r\n"}, {"input": "2\r\n1200 1100\r\n1200 1000\r\n", "output": "rated\r\n"}, {"input": "2\r\n5 5\r\n4 4\r\n", "output": "maybe\r\n"}, {"input": "2\r\n5 5\r\n3 3\r\n", "output": "maybe\r\n"}, {"input": "5\r\n1500 1500\r\n1300 1300\r\n1200 1200\r\n1400 1400\r\n1100 1100\r\n", "output": "unrated\r\n"}, {"input": "5\r\n10 10\r\n9 9\r\n8 8\r\n7 7\r\n6 6\r\n", "output": "maybe\r\n"}, {"input": "3\r\n1000 1000\r\n300 300\r\n10 10\r\n", "output": "maybe\r\n"}, {"input": "5\r\n6 6\r\n5 5\r\n4 4\r\n3 3\r\n2 2\r\n", "output": "maybe\r\n"}, {"input": "2\r\n3 3\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "4\r\n2 2\r\n2 2\r\n2 2\r\n3 3\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1000 1000\r\n700 700\r\n", "output": "maybe\r\n"}, {"input": "2\r\n4 3\r\n5 3\r\n", "output": "rated\r\n"}, {"input": "2\r\n1000 1000\r\n1100 1100\r\n", "output": "unrated\r\n"}, {"input": "4\r\n5 5\r\n4 4\r\n3 3\r\n2 2\r\n", "output": "maybe\r\n"}, {"input": "3\r\n1 1\r\n2 3\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n1 2\r\n1 3\r\n", "output": "rated\r\n"}, {"input": "2\r\n3 3\r\n1 2\r\n", "output": "rated\r\n"}, {"input": "4\r\n1501 1500\r\n1300 1300\r\n1200 1200\r\n1400 1400\r\n", "output": "rated\r\n"}, {"input": "5\r\n1 1\r\n2 2\r\n3 3\r\n4 4\r\n5 5\r\n", "output": "unrated\r\n"}, {"input": "2\r\n10 10\r\n1 2\r\n", "output": "rated\r\n"}, {"input": "6\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n1699 1699\r\n1900 1900\r\n", "output": "unrated\r\n"}, {"input": "6\r\n3123 3123\r\n2777 2777\r\n3000 3000\r\n2246 2246\r\n2246 2246\r\n1699 1699\r\n", "output": "unrated\r\n"}, {"input": "2\r\n100 100\r\n110 110\r\n", "output": "unrated\r\n"}, {"input": "3\r\n3 3\r\n3 3\r\n4 4\r\n", "output": "unrated\r\n"}, {"input": "3\r\n3 3\r\n3 2\r\n4 4\r\n", "output": "rated\r\n"}, {"input": "3\r\n5 2\r\n4 4\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "4\r\n4 4\r\n3 3\r\n2 2\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "2\r\n1 1\r\n3 2\r\n", "output": "rated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n2699 2699\r\n", "output": "unrated\r\n"}, {"input": "3\r\n3 3\r\n3 3\r\n3 4\r\n", "output": "rated\r\n"}, {"input": "3\r\n1 2\r\n2 2\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "3\r\n1 2\r\n1 2\r\n1 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 1\r\n2 1\r\n", "output": "rated\r\n"}, {"input": "2\r\n1 2\r\n3 4\r\n", "output": "rated\r\n"}, {"input": "2\r\n3 2\r\n2 3\r\n", "output": "rated\r\n"}, {"input": "3\r\n1500 1500\r\n1600 1600\r\n1600 1600\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1 1\r\n3 3\r\n4 4\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1 1\r\n2 2\r\n2 2\r\n", "output": "unrated\r\n"}, {"input": "2\r\n10 12\r\n8 8\r\n", "output": "rated\r\n"}, {"input": "5\r\n1200 1200\r\n1500 1500\r\n1500 1500\r\n1500 1500\r\n1500 1500\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1 2\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "3\r\n1500 1400\r\n1200 1200\r\n1100 1100\r\n", "output": "rated\r\n"}, {"input": "2\r\n10 12\r\n10 10\r\n", "output": "rated\r\n"}, {"input": "3\r\n1500 1500\r\n1400 1400\r\n1300 1300\r\n", "output": "maybe\r\n"}, {"input": "3\r\n3 3\r\n4 4\r\n5 5\r\n", "output": "unrated\r\n"}, {"input": "3\r\n2 6\r\n3 5\r\n4 4\r\n", "output": "rated\r\n"}, {"input": "2\r\n5 6\r\n4 6\r\n", "output": "rated\r\n"}, {"input": "4\r\n10 10\r\n10 10\r\n7 7\r\n8 8\r\n", "output": "unrated\r\n"}, {"input": "2\r\n4 4\r\n3 3\r\n", "output": "maybe\r\n"}]
| false |
stdio
| null | true |
837/B
|
837
|
B
|
PyPy 3
|
TESTS
| 24 | 186 | 4,403,200 |
118945367
|
import sys
#import random
from bisect import bisect_left as lb
from collections import deque
#sys.setrecursionlimit(10**8)
from queue import PriorityQueue as pq
from math import *
input_ = lambda: sys.stdin.readline().strip("\r\n")
ii = lambda : int(input_())
il = lambda : list(map(int, input_().split()))
ilf = lambda : list(map(float, input_().split()))
ip = lambda : input_()
fi = lambda : float(input_())
ap = lambda ab,bc,cd : ab[bc].append(cd)
li = lambda : list(input_())
pr = lambda x : print(x)
prinT = lambda x : print(x)
f = lambda : sys.stdout.flush()
inv =lambda x:pow(x,mod-2,mod)
mod = 10**9 + 7
n,m = il()
a = []
for i in range (n) :
a.append(list(ip()))
if (n%3 != 0 and m%3 != 0) :
print("NO")
exit(0)
if (n%3 == 0) :
x = n//3
d = {}
for k in range (3) :
i = 0 + x*k
ch = a[i][0]
if (d.get(ch)) :
print("NO")
exit(0)
for i1 in range (x) :
for j in range (m) :
if (ch != a[i1+i][j]) :
print("NO")
exit(0)
d[ch] = 1
print("YES")
exit(0)
if (m%3 == 0) :
x = m//3
d = {}
for k in range (3) :
i = 0 + x*k
ch = a[0][i]
if (d.get(ch)) :
print("NO")
exit(0)
for i1 in range (x) :
for j in range (n) :
if (ch != a[j][i1+i]) :
print("NO")
exit(0)
d[ch] = 1
print("YES")
exit(0)
| 153 | 62 | 4,915,200 |
29161993
|
import sys
def main():
n, m = map(int, sys.stdin.readline().split())
if n % 3 != 0 and m % 3 != 0:
print("NO")
return
f = []
for i in range(n):
f.append(sys.stdin.readline())
ok = True
if f[0][0] == f[n - 1][0]: # vertical
if m % 3 != 0:
ok = False
else:
sz = int(m / 3)
if f[0][0] == f[0][sz] or f[0][0] == f[0][2 * sz] or f[0][2 * sz] == f[0][sz]:
ok = False
else:
for k in range(3):
c = f[0][k * sz]
for i in range(n):
for j in range(k * sz, (k + 1) * sz):
if c != f[i][j]:
ok = False
break
if not ok:
break
if not ok:
break
else: # horizontal
if n % 3 != 0:
ok = False
else:
sz = int(n / 3)
if f[0][0] == f[sz][0] or f[0][0] == f[2 * sz][0] or f[2 * sz][0] == f[sz][0]:
ok = False
else:
for k in range(3):
c = f[k * sz][0]
for i in range(k * sz, (k + 1) * sz):
for j in range(m):
if c != f[i][j]:
ok = False
break
if not ok:
break
if not ok:
break
if ok:
print("YES")
else:
print("NO")
main()
|
Educational Codeforces Round 26
|
ICPC
| 2,017 | 1 | 256 |
Flag of Berland
|
The flag of Berland is such rectangular field n × m that satisfies following conditions:
- Flag consists of three colors which correspond to letters 'R', 'G' and 'B'.
- Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color.
- Each color should be used in exactly one stripe.
You are given a field n × m, consisting of characters 'R', 'G' and 'B'. Output "YES" (without quotes) if this field corresponds to correct flag of Berland. Otherwise, print "NO" (without quotes).
|
The first line contains two integer numbers n and m (1 ≤ n, m ≤ 100) — the sizes of the field.
Each of the following n lines consisting of m characters 'R', 'G' and 'B' — the description of the field.
|
Print "YES" (without quotes) if the given field corresponds to correct flag of Berland . Otherwise, print "NO" (without quotes).
| null |
The field in the third example doesn't have three parralel stripes.
Rows of the field in the fourth example are parralel to each other and to borders. But they have different heights — 2, 1 and 1.
|
[{"input": "6 5\nRRRRR\nRRRRR\nBBBBB\nBBBBB\nGGGGG\nGGGGG", "output": "YES"}, {"input": "4 3\nBRG\nBRG\nBRG\nBRG", "output": "YES"}, {"input": "6 7\nRRRGGGG\nRRRGGGG\nRRRGGGG\nRRRBBBB\nRRRBBBB\nRRRBBBB", "output": "NO"}, {"input": "4 4\nRRRR\nRRRR\nBBBB\nGGGG", "output": "NO"}]
| 1,600 |
["brute force", "implementation"]
| 153 |
[{"input": "6 5\r\nRRRRR\r\nRRRRR\r\nBBBBB\r\nBBBBB\r\nGGGGG\r\nGGGGG\r\n", "output": "YES\r\n"}, {"input": "4 3\r\nBRG\r\nBRG\r\nBRG\r\nBRG\r\n", "output": "YES\r\n"}, {"input": "6 7\r\nRRRGGGG\r\nRRRGGGG\r\nRRRGGGG\r\nRRRBBBB\r\nRRRBBBB\r\nRRRBBBB\r\n", "output": "NO\r\n"}, {"input": "4 4\r\nRRRR\r\nRRRR\r\nBBBB\r\nGGGG\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nGRB\r\n", "output": "YES\r\n"}, {"input": "3 1\r\nR\r\nG\r\nB\r\n", "output": "YES\r\n"}, {"input": "4 3\r\nRGB\r\nGRB\r\nGRB\r\nGRB\r\n", "output": "NO\r\n"}, {"input": "4 6\r\nGGRRBB\r\nGGRRBB\r\nGGRRBB\r\nRRGGBB\r\n", "output": "NO\r\n"}, {"input": "100 3\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nGRB\r\n", "output": "NO\r\n"}, {"input": "3 100\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\nRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRG\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nR\r\nR\r\nB\r\n", "output": "NO\r\n"}, {"input": "3 2\r\nRR\r\nBB\r\nRR\r\n", "output": "NO\r\n"}, {"input": "3 2\r\nRR\r\nBG\r\nBG\r\n", "output": "NO\r\n"}, {"input": "3 2\r\nBB\r\nRR\r\nBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nRRR\r\nRRR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nGGG\r\nGGG\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRGG\r\n", "output": "NO\r\n"}, {"input": "4 3\r\nRGR\r\nRGR\r\nRGR\r\nRGR\r\n", "output": "NO\r\n"}, {"input": "3 4\r\nRRGG\r\nRRGG\r\nBBBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nBRG\r\nBRG\r\nBRG\r\n", "output": "YES\r\n"}, {"input": "3 1\r\nR\r\nG\r\nR\r\n", "output": "NO\r\n"}, {"input": "5 3\r\nBBG\r\nBBG\r\nBBG\r\nBBG\r\nBBG\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nGGG\r\nRRR\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRGR\r\n", "output": "NO\r\n"}, {"input": "3 6\r\nRRBBGG\r\nRRBBGG\r\nRRBBGG\r\n", "output": "YES\r\n"}, {"input": "6 6\r\nRRBBGG\r\nRRBBGG\r\nRRBBGG\r\nRRBBGG\r\nRRBBGG\r\nRRBBGG\r\n", "output": "YES\r\n"}, {"input": "4 3\r\nRRR\r\nGGG\r\nBBB\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nBBB\r\nRRR\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nB\r\nR\r\nB\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nBGB\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nB\r\nB\r\nB\r\n", "output": "NO\r\n"}, {"input": "3 4\r\nRRRR\r\nBBBB\r\nRRRR\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRGGGBB\r\n", "output": "NO\r\n"}, {"input": "9 3\r\nBBB\r\nBBB\r\nBBB\r\nGGG\r\nGGG\r\nGRG\r\nRGR\r\nRRR\r\nRRR\r\n", "output": "NO\r\n"}, {"input": "4 4\r\nRGBB\r\nRGBB\r\nRGBB\r\nRGBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRBR\r\nRBR\r\nRBR\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRRRRBB\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRRRRRR\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRRGGGG\r\n", "output": "NO\r\n"}, {"input": "4 4\r\nRRRR\r\nRRRR\r\nRRRR\r\nRRRR\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nB\r\nG\r\nB\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nR\r\nR\r\nR\r\n", "output": "NO\r\n"}, {"input": "1 9\r\nRRRGGGBBB\r\n", "output": "YES\r\n"}, {"input": "1 3\r\nRRR\r\n", "output": "NO\r\n"}, {"input": "3 5\r\nRRRRR\r\nBBBBB\r\nBBBBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nGGG\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "1 1\r\nR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGR\r\nRGR\r\nRGR\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRBG\r\nGBR\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nRGB\r\nRGB\r\n", "output": "YES\r\n"}, {"input": "1 3\r\nBRB\r\n", "output": "NO\r\n"}, {"input": "2 1\r\nR\r\nB\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRBR\r\n", "output": "NO\r\n"}, {"input": "3 5\r\nRRGBB\r\nRRGBB\r\nRRGBB\r\n", "output": "NO\r\n"}, {"input": "5 3\r\nBBR\r\nBBR\r\nBBR\r\nBBR\r\nBBR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nRBG\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "1 2\r\nRB\r\n", "output": "NO\r\n"}, {"input": "4 3\r\nBBB\r\nBBB\r\nBBB\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "36 6\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\n", "output": "NO\r\n"}, {"input": "4 1\r\nR\r\nB\r\nG\r\nR\r\n", "output": "NO\r\n"}, {"input": "13 12\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\n", "output": "NO\r\n"}, {"input": "2 2\r\nRR\r\nRR\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nRRGGBB\r\nGRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\n", "output": "NO\r\n"}, {"input": "70 3\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\n", "output": "NO\r\n"}, {"input": "4 3\r\nBBG\r\nBBG\r\nBBG\r\nBBG\r\n", "output": "NO\r\n"}, {"input": "6 3\r\nBBB\r\nGGG\r\nRRR\r\nBRG\r\nBRG\r\nBRG\r\n", "output": "NO\r\n"}, {"input": "3 6\r\nRRBBGG\r\nRBBBGG\r\nRBBBGG\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nGGGGGG\r\nGGGGGG\r\nBBBBBB\r\nBBBBBB\r\nGGGGGG\r\nGGGGGG\r\n", "output": "NO\r\n"}, {"input": "6 1\r\nR\r\nB\r\nG\r\nR\r\nB\r\nG\r\n", "output": "NO\r\n"}, {"input": "6 5\r\nRRRRR\r\nBBBBB\r\nGGGGG\r\nRRRRR\r\nBBBBB\r\nGGGGG\r\n", "output": "NO\r\n"}, {"input": "6 3\r\nRRR\r\nGGG\r\nBBB\r\nRRR\r\nGGG\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "6 5\r\nRRRRR\r\nRRRRR\r\nRRRRR\r\nGGGGG\r\nGGGGG\r\nGGGGG\r\n", "output": "NO\r\n"}, {"input": "15 28\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\n", "output": "NO\r\n"}, {"input": "21 10\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nBBBBBBBBBB\r\nBBBBBBBBBB\r\nBBBBBGBBBB\r\nBBBBBBBBBB\r\nBBBBBBBBBB\r\nBBBBBBBBBB\r\nBBBBBBBBBB\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\n", "output": "NO\r\n"}, {"input": "3 2\r\nRR\r\nGB\r\nGB\r\n", "output": "NO\r\n"}, {"input": "3 2\r\nRG\r\nRG\r\nBB\r\n", "output": "NO\r\n"}, {"input": "6 5\r\nRRRRR\r\nRRRRR\r\nBBBBB\r\nBBBBB\r\nRRRRR\r\nRRRRR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nGBR\r\nBRG\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nBGR\r\nBGR\r\nBGR\r\n", "output": "YES\r\n"}, {"input": "6 6\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\n", "output": "YES\r\n"}, {"input": "4 2\r\nRR\r\nGG\r\nRR\r\nBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nRRR\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "8 6\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\n", "output": "NO\r\n"}, {"input": "3 4\r\nRRRR\r\nRRRR\r\nGGGG\r\n", "output": "NO\r\n"}, {"input": "3 4\r\nRRRR\r\nRRRR\r\nRRRR\r\n", "output": "NO\r\n"}, {"input": "6 1\r\nR\r\nR\r\nR\r\nR\r\nR\r\nR\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRRBBGG\r\n", "output": "YES\r\n"}, {"input": "1 6\r\nRGBRGB\r\n", "output": "NO\r\n"}, {"input": "3 4\r\nRRRR\r\nGGGG\r\nRRRR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRB\r\nGRG\r\nGBB\r\n", "output": "NO\r\n"}, {"input": "3 7\r\nRRGGBBB\r\nRRGGBBB\r\nRRGGBBB\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nG\r\nR\r\nR\r\n", "output": "NO\r\n"}, {"input": "2 3\r\nRGG\r\nRBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRG\r\nGGG\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nRBB\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGR\r\nRGB\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nB\r\nR\r\nR\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nGRR\r\n", "output": "NO\r\n"}, {"input": "4 4\r\nRRRR\r\nGGGG\r\nBBBB\r\nBBBB\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nGGR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nGGB\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGR\r\nGGG\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nRRRRRR\r\nGGGGGG\r\nGGGGGG\r\nGGGGGG\r\nBBBBBB\r\nBBBBBB\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nRRRRRR\r\nRRRRRR\r\nGGGGGG\r\nBBBBBB\r\nBBBBBB\r\nBBBBBB\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nG\r\nB\r\nR\r\n", "output": "YES\r\n"}, {"input": "3 3\r\nGGB\r\nRGB\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nGRR\r\nGGG\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nRRRRRR\r\nRRRRRR\r\nGGGGGG\r\nGGGGGG\r\nBBBBBB\r\nRRRRRR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nGBG\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "3 8\r\nRRGGBBBB\r\nRRGGBBBB\r\nRRGGBBBB\r\n", "output": "NO\r\n"}, {"input": "2 2\r\nRR\r\nGG\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nRGR\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRBG\r\n", "output": "YES\r\n"}, {"input": "2 6\r\nRRGGBB\r\nGGRRBB\r\n", "output": "NO\r\n"}, {"input": "6 2\r\nRR\r\nGG\r\nBB\r\nRR\r\nGG\r\nBB\r\n", "output": "NO\r\n"}, {"input": "1 5\r\nRRGGB\r\n", "output": "NO\r\n"}, {"input": "1 2\r\nRG\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRGBRBG\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRRRGGB\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRGB\r\n", "output": "YES\r\n"}, {"input": "4 3\r\nRRR\r\nBBR\r\nGBB\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "6 3\r\nRRR\r\nBBB\r\nBBB\r\nBBB\r\nGGG\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRBG\r\nRBG\r\nRBG\r\n", "output": "YES\r\n"}, {"input": "6 3\r\nRRR\r\nBBB\r\nGGG\r\nRRR\r\nBBB\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "1 4\r\nRGBB\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\n", "output": "NO\r\n"}, {"input": "6 5\r\nRRRRR\r\nRRRRR\r\nGGGGG\r\nGGGGG\r\nRRRRR\r\nRRRRR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nBRG\r\nGBR\r\n", "output": "NO\r\n"}, {"input": "6 10\r\nRRRRRRRRRR\r\nGGGGGGGGGG\r\nBBBBBBBBBB\r\nRRRRRRRRRR\r\nGGGGGGGGGG\r\nBBBBBBBBBB\r\n", "output": "NO\r\n"}, {"input": "20 6\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\n", "output": "YES\r\n"}, {"input": "4 1\r\nR\r\nG\r\nB\r\nR\r\n", "output": "NO\r\n"}, {"input": "1 4\r\nRGBR\r\n", "output": "NO\r\n"}, {"input": "2 4\r\nRGBB\r\nRRGB\r\n", "output": "NO\r\n"}]
| false |
stdio
| null | true |
837/B
|
837
|
B
|
Python 3
|
TESTS
| 24 | 61 | 4,915,200 |
29167831
|
n, m = map(int, input().split())
f = []
for i in range(n):
f.append(input()) #flag
rf1 = [] #real flag
rez = True
if (n % 3 == 0) or (m % 3 == 0):
if n % 3 == 0:
for i in range(n // 3):
rf1.append('R' * m)
for i in range(n // 3):
rf1.append('B' * m)
for i in range(n // 3):
rf1.append('G' * m)
rf2 = []
for i in range(n // 3):
rf2.append('R' * m)
for i in range(n // 3):
rf2.append('G' * m)
for i in range(n // 3):
rf2.append('B' * m)
rf3 = []
for i in range(n // 3):
rf3.append('B' * m)
for i in range(n // 3):
rf3.append('R' * m)
for i in range(n // 3):
rf3.append('G' * m)
rf4 = []
for i in range(n // 3):
rf4.append('B' * m)
for i in range(n // 3):
rf4.append('G' * m)
for i in range(n // 3):
rf4.append('R' * m)
rf5 = []
for i in range(n // 3):
rf5.append('G' * m)
for i in range(n // 3):
rf5.append('R' * m)
for i in range(n // 3):
rf5.append('B' * m)
rf6 = []
for i in range(n // 3):
rf6.append('G' * m)
for i in range(n // 3):
rf6.append('B' * m)
for i in range(n // 3):
rf6.append('R' * m)
if (rf1 != f) and (rf2 != f) and (rf3 != f) and (rf4 != f) and (rf5 != f) and (rf6 != f):
rez = False
else:
for i in range(n):
polosa = 'R' * (m // 3) + 'B' * (m // 3) + 'G' * (m // 3)
rf1. append(polosa)
rf2 = []
for i in range(n):
polosa = 'R' * (m // 3) + 'G' * (m // 3) + 'B' * (m // 3)
rf2. append(polosa)
rf3 = []
for i in range(n):
polosa = 'B' * (m // 3) + 'R' * (m // 3) + 'G' * (m // 3)
rf3. append(polosa)
rf4 = []
for i in range(n):
polosa = 'B' * (m // 3) + 'G' * (m // 3) + 'R' * (m // 3)
rf4. append(polosa)
rf5 = []
for i in range(n):
polosa = 'G' * (m // 3) + 'R' * (m // 3) + 'B' * (m // 3)
rf5. append(polosa)
rf6 = []
for i in range(n):
polosa = 'G' * (m // 3) + 'B' * (m // 3) + 'R' * (m // 3)
rf6. append(polosa)
if (rf1 != f) and (rf2 != f) and (rf3 != f) and (rf4 != f) and (rf5 != f) and (rf6 != f):
rez = False
else:
rez = False
if rez:
print('YES')
else:
print('NO')
| 153 | 62 | 4,915,200 |
29162004
|
n, m = map(int, input().split())
flag = []
def letterwidth(i):
res = flag[i][0]
for item in flag[i]:
if item != res:
return None
return res
def letterheight(i):
res = flag[0][i]
for j in range(n):
if flag[j][i] != res:
return None
return res
for i in range(n):
flag.append(input())
result = False
if(n % 3 == 0 and not result):
w = n // 3
letters = []
for i in range(n):
curres = letterwidth(i)
letters.append(curres)
if curres is None:
break
if(letters.count(None) == 0):
answers = []
counter = 0
for i in range(3):
res = letters[counter]
answers.append(res)
counter += 1
for j in range(w - 1):
if(letters[counter] != res):
letters.append(None)
break
counter += 1
if(letters.count(None) > 0):
break
if(letters.count(None) == 0):
if(len(answers) == len(set(answers))):
result = True
if(m % 3 == 0 and not result):
w = m // 3
letters = []
for i in range(m):
curres = letterheight(i)
letters.append(curres)
if curres is None:
break
if(letters.count(None) == 0):
answers = []
counter = 0
for i in range(3):
res = letters[counter]
answers.append(res)
counter += 1
for j in range(w - 1):
if(letters[counter] != res):
letters.append(None)
break
counter += 1
if(letters.count(None) > 0):
break
if(letters.count(None) == 0):
if(len(answers) == len(set(answers))):
result = True
if(result):
print("YES")
else:
print("NO")
|
Educational Codeforces Round 26
|
ICPC
| 2,017 | 1 | 256 |
Flag of Berland
|
The flag of Berland is such rectangular field n × m that satisfies following conditions:
- Flag consists of three colors which correspond to letters 'R', 'G' and 'B'.
- Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color.
- Each color should be used in exactly one stripe.
You are given a field n × m, consisting of characters 'R', 'G' and 'B'. Output "YES" (without quotes) if this field corresponds to correct flag of Berland. Otherwise, print "NO" (without quotes).
|
The first line contains two integer numbers n and m (1 ≤ n, m ≤ 100) — the sizes of the field.
Each of the following n lines consisting of m characters 'R', 'G' and 'B' — the description of the field.
|
Print "YES" (without quotes) if the given field corresponds to correct flag of Berland . Otherwise, print "NO" (without quotes).
| null |
The field in the third example doesn't have three parralel stripes.
Rows of the field in the fourth example are parralel to each other and to borders. But they have different heights — 2, 1 and 1.
|
[{"input": "6 5\nRRRRR\nRRRRR\nBBBBB\nBBBBB\nGGGGG\nGGGGG", "output": "YES"}, {"input": "4 3\nBRG\nBRG\nBRG\nBRG", "output": "YES"}, {"input": "6 7\nRRRGGGG\nRRRGGGG\nRRRGGGG\nRRRBBBB\nRRRBBBB\nRRRBBBB", "output": "NO"}, {"input": "4 4\nRRRR\nRRRR\nBBBB\nGGGG", "output": "NO"}]
| 1,600 |
["brute force", "implementation"]
| 153 |
[{"input": "6 5\r\nRRRRR\r\nRRRRR\r\nBBBBB\r\nBBBBB\r\nGGGGG\r\nGGGGG\r\n", "output": "YES\r\n"}, {"input": "4 3\r\nBRG\r\nBRG\r\nBRG\r\nBRG\r\n", "output": "YES\r\n"}, {"input": "6 7\r\nRRRGGGG\r\nRRRGGGG\r\nRRRGGGG\r\nRRRBBBB\r\nRRRBBBB\r\nRRRBBBB\r\n", "output": "NO\r\n"}, {"input": "4 4\r\nRRRR\r\nRRRR\r\nBBBB\r\nGGGG\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nGRB\r\n", "output": "YES\r\n"}, {"input": "3 1\r\nR\r\nG\r\nB\r\n", "output": "YES\r\n"}, {"input": "4 3\r\nRGB\r\nGRB\r\nGRB\r\nGRB\r\n", "output": "NO\r\n"}, {"input": "4 6\r\nGGRRBB\r\nGGRRBB\r\nGGRRBB\r\nRRGGBB\r\n", "output": "NO\r\n"}, {"input": "100 3\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nGRB\r\n", "output": "NO\r\n"}, {"input": "3 100\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\nRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRG\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nR\r\nR\r\nB\r\n", "output": "NO\r\n"}, {"input": "3 2\r\nRR\r\nBB\r\nRR\r\n", "output": "NO\r\n"}, {"input": "3 2\r\nRR\r\nBG\r\nBG\r\n", "output": "NO\r\n"}, {"input": "3 2\r\nBB\r\nRR\r\nBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nRRR\r\nRRR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nGGG\r\nGGG\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRGG\r\n", "output": "NO\r\n"}, {"input": "4 3\r\nRGR\r\nRGR\r\nRGR\r\nRGR\r\n", "output": "NO\r\n"}, {"input": "3 4\r\nRRGG\r\nRRGG\r\nBBBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nBRG\r\nBRG\r\nBRG\r\n", "output": "YES\r\n"}, {"input": "3 1\r\nR\r\nG\r\nR\r\n", "output": "NO\r\n"}, {"input": "5 3\r\nBBG\r\nBBG\r\nBBG\r\nBBG\r\nBBG\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nGGG\r\nRRR\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRGR\r\n", "output": "NO\r\n"}, {"input": "3 6\r\nRRBBGG\r\nRRBBGG\r\nRRBBGG\r\n", "output": "YES\r\n"}, {"input": "6 6\r\nRRBBGG\r\nRRBBGG\r\nRRBBGG\r\nRRBBGG\r\nRRBBGG\r\nRRBBGG\r\n", "output": "YES\r\n"}, {"input": "4 3\r\nRRR\r\nGGG\r\nBBB\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nBBB\r\nRRR\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nB\r\nR\r\nB\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nBGB\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nB\r\nB\r\nB\r\n", "output": "NO\r\n"}, {"input": "3 4\r\nRRRR\r\nBBBB\r\nRRRR\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRGGGBB\r\n", "output": "NO\r\n"}, {"input": "9 3\r\nBBB\r\nBBB\r\nBBB\r\nGGG\r\nGGG\r\nGRG\r\nRGR\r\nRRR\r\nRRR\r\n", "output": "NO\r\n"}, {"input": "4 4\r\nRGBB\r\nRGBB\r\nRGBB\r\nRGBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRBR\r\nRBR\r\nRBR\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRRRRBB\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRRRRRR\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRRGGGG\r\n", "output": "NO\r\n"}, {"input": "4 4\r\nRRRR\r\nRRRR\r\nRRRR\r\nRRRR\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nB\r\nG\r\nB\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nR\r\nR\r\nR\r\n", "output": "NO\r\n"}, {"input": "1 9\r\nRRRGGGBBB\r\n", "output": "YES\r\n"}, {"input": "1 3\r\nRRR\r\n", "output": "NO\r\n"}, {"input": "3 5\r\nRRRRR\r\nBBBBB\r\nBBBBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nGGG\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "1 1\r\nR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGR\r\nRGR\r\nRGR\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRBG\r\nGBR\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nRGB\r\nRGB\r\n", "output": "YES\r\n"}, {"input": "1 3\r\nBRB\r\n", "output": "NO\r\n"}, {"input": "2 1\r\nR\r\nB\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRBR\r\n", "output": "NO\r\n"}, {"input": "3 5\r\nRRGBB\r\nRRGBB\r\nRRGBB\r\n", "output": "NO\r\n"}, {"input": "5 3\r\nBBR\r\nBBR\r\nBBR\r\nBBR\r\nBBR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nRBG\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "1 2\r\nRB\r\n", "output": "NO\r\n"}, {"input": "4 3\r\nBBB\r\nBBB\r\nBBB\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "36 6\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\n", "output": "NO\r\n"}, {"input": "4 1\r\nR\r\nB\r\nG\r\nR\r\n", "output": "NO\r\n"}, {"input": "13 12\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\n", "output": "NO\r\n"}, {"input": "2 2\r\nRR\r\nRR\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nRRGGBB\r\nGRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\n", "output": "NO\r\n"}, {"input": "70 3\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\n", "output": "NO\r\n"}, {"input": "4 3\r\nBBG\r\nBBG\r\nBBG\r\nBBG\r\n", "output": "NO\r\n"}, {"input": "6 3\r\nBBB\r\nGGG\r\nRRR\r\nBRG\r\nBRG\r\nBRG\r\n", "output": "NO\r\n"}, {"input": "3 6\r\nRRBBGG\r\nRBBBGG\r\nRBBBGG\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nGGGGGG\r\nGGGGGG\r\nBBBBBB\r\nBBBBBB\r\nGGGGGG\r\nGGGGGG\r\n", "output": "NO\r\n"}, {"input": "6 1\r\nR\r\nB\r\nG\r\nR\r\nB\r\nG\r\n", "output": "NO\r\n"}, {"input": "6 5\r\nRRRRR\r\nBBBBB\r\nGGGGG\r\nRRRRR\r\nBBBBB\r\nGGGGG\r\n", "output": "NO\r\n"}, {"input": "6 3\r\nRRR\r\nGGG\r\nBBB\r\nRRR\r\nGGG\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "6 5\r\nRRRRR\r\nRRRRR\r\nRRRRR\r\nGGGGG\r\nGGGGG\r\nGGGGG\r\n", "output": "NO\r\n"}, {"input": "15 28\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\n", "output": "NO\r\n"}, {"input": "21 10\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nBBBBBBBBBB\r\nBBBBBBBBBB\r\nBBBBBGBBBB\r\nBBBBBBBBBB\r\nBBBBBBBBBB\r\nBBBBBBBBBB\r\nBBBBBBBBBB\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\n", "output": "NO\r\n"}, {"input": "3 2\r\nRR\r\nGB\r\nGB\r\n", "output": "NO\r\n"}, {"input": "3 2\r\nRG\r\nRG\r\nBB\r\n", "output": "NO\r\n"}, {"input": "6 5\r\nRRRRR\r\nRRRRR\r\nBBBBB\r\nBBBBB\r\nRRRRR\r\nRRRRR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nGBR\r\nBRG\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nBGR\r\nBGR\r\nBGR\r\n", "output": "YES\r\n"}, {"input": "6 6\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\n", "output": "YES\r\n"}, {"input": "4 2\r\nRR\r\nGG\r\nRR\r\nBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nRRR\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "8 6\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\n", "output": "NO\r\n"}, {"input": "3 4\r\nRRRR\r\nRRRR\r\nGGGG\r\n", "output": "NO\r\n"}, {"input": "3 4\r\nRRRR\r\nRRRR\r\nRRRR\r\n", "output": "NO\r\n"}, {"input": "6 1\r\nR\r\nR\r\nR\r\nR\r\nR\r\nR\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRRBBGG\r\n", "output": "YES\r\n"}, {"input": "1 6\r\nRGBRGB\r\n", "output": "NO\r\n"}, {"input": "3 4\r\nRRRR\r\nGGGG\r\nRRRR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRB\r\nGRG\r\nGBB\r\n", "output": "NO\r\n"}, {"input": "3 7\r\nRRGGBBB\r\nRRGGBBB\r\nRRGGBBB\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nG\r\nR\r\nR\r\n", "output": "NO\r\n"}, {"input": "2 3\r\nRGG\r\nRBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRG\r\nGGG\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nRBB\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGR\r\nRGB\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nB\r\nR\r\nR\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nGRR\r\n", "output": "NO\r\n"}, {"input": "4 4\r\nRRRR\r\nGGGG\r\nBBBB\r\nBBBB\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nGGR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nGGB\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGR\r\nGGG\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nRRRRRR\r\nGGGGGG\r\nGGGGGG\r\nGGGGGG\r\nBBBBBB\r\nBBBBBB\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nRRRRRR\r\nRRRRRR\r\nGGGGGG\r\nBBBBBB\r\nBBBBBB\r\nBBBBBB\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nG\r\nB\r\nR\r\n", "output": "YES\r\n"}, {"input": "3 3\r\nGGB\r\nRGB\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nGRR\r\nGGG\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nRRRRRR\r\nRRRRRR\r\nGGGGGG\r\nGGGGGG\r\nBBBBBB\r\nRRRRRR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nGBG\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "3 8\r\nRRGGBBBB\r\nRRGGBBBB\r\nRRGGBBBB\r\n", "output": "NO\r\n"}, {"input": "2 2\r\nRR\r\nGG\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nRGR\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRBG\r\n", "output": "YES\r\n"}, {"input": "2 6\r\nRRGGBB\r\nGGRRBB\r\n", "output": "NO\r\n"}, {"input": "6 2\r\nRR\r\nGG\r\nBB\r\nRR\r\nGG\r\nBB\r\n", "output": "NO\r\n"}, {"input": "1 5\r\nRRGGB\r\n", "output": "NO\r\n"}, {"input": "1 2\r\nRG\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRGBRBG\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRRRGGB\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRGB\r\n", "output": "YES\r\n"}, {"input": "4 3\r\nRRR\r\nBBR\r\nGBB\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "6 3\r\nRRR\r\nBBB\r\nBBB\r\nBBB\r\nGGG\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRBG\r\nRBG\r\nRBG\r\n", "output": "YES\r\n"}, {"input": "6 3\r\nRRR\r\nBBB\r\nGGG\r\nRRR\r\nBBB\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "1 4\r\nRGBB\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\n", "output": "NO\r\n"}, {"input": "6 5\r\nRRRRR\r\nRRRRR\r\nGGGGG\r\nGGGGG\r\nRRRRR\r\nRRRRR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nBRG\r\nGBR\r\n", "output": "NO\r\n"}, {"input": "6 10\r\nRRRRRRRRRR\r\nGGGGGGGGGG\r\nBBBBBBBBBB\r\nRRRRRRRRRR\r\nGGGGGGGGGG\r\nBBBBBBBBBB\r\n", "output": "NO\r\n"}, {"input": "20 6\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\n", "output": "YES\r\n"}, {"input": "4 1\r\nR\r\nG\r\nB\r\nR\r\n", "output": "NO\r\n"}, {"input": "1 4\r\nRGBR\r\n", "output": "NO\r\n"}, {"input": "2 4\r\nRGBB\r\nRRGB\r\n", "output": "NO\r\n"}]
| false |
stdio
| null | true |
807/A
|
807
|
A
|
Python 3
|
TESTS
| 21 | 46 | 0 |
225697559
|
n=int(input())
before_round=[]
after_round=[]
sum_before=0
sum_after=0
for i in range(n):
before,after=map(int,input().split())
sum_before+=before
sum_after+=after
before_round.append(before)
after_round.append(after)
if(sum_before!=sum_after):
print("rated")
else:
if(before_round!=sorted(before_round,reverse=True) and after_round!=sorted(after_round,reverse=True)):
print("unrated")
else:
print("maybe")
| 150 | 46 | 0 |
144294915
|
a = []
b = []
for i in range(int(input())):
input2 = list(map(int,input().split()))
if input2[0] < input2[1]:
a.append(input2[0])
b.append(input2[1])
break
else:
a.append(input2[0])
b.append(input2[1])
if a != b:
print("rated")
else:
a.sort()
a = a[::-1]
if a == b:
print("maybe")
else:
print("unrated")
|
Codeforces Round 412 (rated, Div. 2, base on VK Cup 2017 Round 3)
|
CF
| 2,017 | 2 | 256 |
Is it rated?
|
Is it rated?
Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it.
Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before and after the round is known.
It's known that if at least one participant's rating has changed, then the round was rated for sure.
It's also known that if the round was rated and a participant with lower rating took a better place in the standings than a participant with higher rating, then at least one round participant's rating has changed.
In this problem, you should not make any other assumptions about the rating system.
Determine if the current round is rated, unrated, or it's impossible to determine whether it is rated of not.
|
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of round participants.
Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 4126) — the rating of the i-th participant before and after the round, respectively. The participants are listed in order from the top to the bottom of the standings.
|
If the round is rated for sure, print "rated". If the round is unrated for sure, print "unrated". If it's impossible to determine whether the round is rated or not, print "maybe".
| null |
In the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated.
In the second example, no one's rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, someone's rating would've changed for sure.
In the third example, no one's rating has changed, and the participants took places in non-increasing order of their rating. Therefore, it's impossible to determine whether the round is rated or not.
|
[{"input": "6\n3060 3060\n2194 2194\n2876 2903\n2624 2624\n3007 2991\n2884 2884", "output": "rated"}, {"input": "4\n1500 1500\n1300 1300\n1200 1200\n1400 1400", "output": "unrated"}, {"input": "5\n3123 3123\n2777 2777\n2246 2246\n2246 2246\n1699 1699", "output": "maybe"}]
| 900 |
["implementation", "sortings"]
| 150 |
[{"input": "6\r\n3060 3060\r\n2194 2194\r\n2876 2903\r\n2624 2624\r\n3007 2991\r\n2884 2884\r\n", "output": "rated\r\n"}, {"input": "4\r\n1500 1500\r\n1300 1300\r\n1200 1200\r\n1400 1400\r\n", "output": "unrated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n1699 1699\r\n", "output": "maybe\r\n"}, {"input": "2\r\n1 1\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "2\r\n4126 4126\r\n4126 4126\r\n", "output": "maybe\r\n"}, {"input": "10\r\n446 446\r\n1331 1331\r\n3594 3594\r\n1346 1902\r\n91 91\r\n3590 3590\r\n2437 2437\r\n4007 3871\r\n2797 699\r\n1423 1423\r\n", "output": "rated\r\n"}, {"input": "10\r\n4078 4078\r\n2876 2876\r\n1061 1061\r\n3721 3721\r\n143 143\r\n2992 2992\r\n3279 3279\r\n3389 3389\r\n1702 1702\r\n1110 1110\r\n", "output": "unrated\r\n"}, {"input": "10\r\n4078 4078\r\n3721 3721\r\n3389 3389\r\n3279 3279\r\n2992 2992\r\n2876 2876\r\n1702 1702\r\n1110 1110\r\n1061 1061\r\n143 143\r\n", "output": "maybe\r\n"}, {"input": "2\r\n3936 3936\r\n2967 2967\r\n", "output": "maybe\r\n"}, {"input": "2\r\n1 1\r\n2 2\r\n", "output": "unrated\r\n"}, {"input": "2\r\n2 2\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "2\r\n2 1\r\n1 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n2967 2967\r\n3936 3936\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1200 1200\r\n1200 1200\r\n1300 1300\r\n", "output": "unrated\r\n"}, {"input": "3\r\n3 3\r\n2 2\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "3\r\n1 1\r\n1 1\r\n2 2\r\n", "output": "unrated\r\n"}, {"input": "2\r\n3 2\r\n3 2\r\n", "output": "rated\r\n"}, {"input": "3\r\n5 5\r\n4 4\r\n3 4\r\n", "output": "rated\r\n"}, {"input": "3\r\n200 200\r\n200 200\r\n300 300\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1 1\r\n2 2\r\n3 3\r\n", "output": "unrated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2245 2245\r\n1699 1699\r\n", "output": "maybe\r\n"}, {"input": "2\r\n10 10\r\n8 8\r\n", "output": "maybe\r\n"}, {"input": "3\r\n1500 1500\r\n1500 1500\r\n1600 1600\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1500 1500\r\n1500 1500\r\n1700 1700\r\n", "output": "unrated\r\n"}, {"input": "4\r\n100 100\r\n100 100\r\n70 70\r\n80 80\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1 2\r\n2 1\r\n", "output": "rated\r\n"}, {"input": "3\r\n5 5\r\n4 3\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "3\r\n1600 1650\r\n1500 1550\r\n1400 1450\r\n", "output": "rated\r\n"}, {"input": "4\r\n2000 2000\r\n1500 1500\r\n1500 1500\r\n1700 1700\r\n", "output": "unrated\r\n"}, {"input": "4\r\n1500 1500\r\n1400 1400\r\n1400 1400\r\n1700 1700\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1600 1600\r\n1400 1400\r\n", "output": "maybe\r\n"}, {"input": "2\r\n3 1\r\n9 8\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 1\r\n1 1\r\n", "output": "rated\r\n"}, {"input": "4\r\n4123 4123\r\n4123 4123\r\n2670 2670\r\n3670 3670\r\n", "output": "unrated\r\n"}, {"input": "2\r\n2 2\r\n3 3\r\n", "output": "unrated\r\n"}, {"input": "2\r\n10 11\r\n5 4\r\n", "output": "rated\r\n"}, {"input": "2\r\n15 14\r\n13 12\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 1\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "3\r\n2670 2670\r\n3670 3670\r\n4106 4106\r\n", "output": "unrated\r\n"}, {"input": "3\r\n4 5\r\n3 3\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n10 9\r\n10 10\r\n", "output": "rated\r\n"}, {"input": "3\r\n1011 1011\r\n1011 999\r\n2200 2100\r\n", "output": "rated\r\n"}, {"input": "2\r\n3 3\r\n5 5\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1500 1500\r\n3000 2000\r\n", "output": "rated\r\n"}, {"input": "2\r\n5 6\r\n5 5\r\n", "output": "rated\r\n"}, {"input": "3\r\n2000 2000\r\n1500 1501\r\n500 500\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 3\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n3 3\r\n2 2\r\n", "output": "maybe\r\n"}, {"input": "2\r\n1 2\r\n1 1\r\n", "output": "rated\r\n"}, {"input": "4\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n1699 1699\r\n", "output": "maybe\r\n"}, {"input": "2\r\n15 14\r\n14 13\r\n", "output": "rated\r\n"}, {"input": "4\r\n3000 3000\r\n2900 2900\r\n3000 3000\r\n2900 2900\r\n", "output": "unrated\r\n"}, {"input": "6\r\n30 3060\r\n24 2194\r\n26 2903\r\n24 2624\r\n37 2991\r\n24 2884\r\n", "output": "rated\r\n"}, {"input": "2\r\n100 99\r\n100 100\r\n", "output": "rated\r\n"}, {"input": "4\r\n2 2\r\n1 1\r\n1 1\r\n2 2\r\n", "output": "unrated\r\n"}, {"input": "3\r\n100 101\r\n100 100\r\n100 100\r\n", "output": "rated\r\n"}, {"input": "4\r\n1000 1001\r\n900 900\r\n950 950\r\n890 890\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 3\r\n1 1\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 2\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "2\r\n3 2\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n3 2\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "2\r\n1 1\r\n2 2\r\n", "output": "unrated\r\n"}, {"input": "3\r\n3 2\r\n3 3\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "4\r\n1500 1501\r\n1300 1300\r\n1200 1200\r\n1400 1400\r\n", "output": "rated\r\n"}, {"input": "3\r\n1000 1000\r\n500 500\r\n400 300\r\n", "output": "rated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n3000 3000\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1 1\r\n2 3\r\n", "output": "rated\r\n"}, {"input": "2\r\n6 2\r\n6 2\r\n", "output": "rated\r\n"}, {"input": "5\r\n3123 3123\r\n1699 1699\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1500 1500\r\n1600 1600\r\n", "output": "unrated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2241 2241\r\n1699 1699\r\n", "output": "maybe\r\n"}, {"input": "2\r\n20 30\r\n10 5\r\n", "output": "rated\r\n"}, {"input": "3\r\n1 1\r\n2 2\r\n1 1\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1 2\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "5\r\n5 5\r\n4 4\r\n3 3\r\n2 2\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "2\r\n2 2\r\n2 1\r\n", "output": "rated\r\n"}, {"input": "2\r\n100 100\r\n90 89\r\n", "output": "rated\r\n"}, {"input": "2\r\n1000 900\r\n2000 2000\r\n", "output": "rated\r\n"}, {"input": "2\r\n50 10\r\n10 50\r\n", "output": "rated\r\n"}, {"input": "2\r\n200 200\r\n100 100\r\n", "output": "maybe\r\n"}, {"input": "3\r\n2 2\r\n2 2\r\n3 3\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1000 1000\r\n300 300\r\n100 100\r\n", "output": "maybe\r\n"}, {"input": "4\r\n2 2\r\n2 2\r\n3 3\r\n4 4\r\n", "output": "unrated\r\n"}, {"input": "2\r\n5 3\r\n6 3\r\n", "output": "rated\r\n"}, {"input": "2\r\n1200 1100\r\n1200 1000\r\n", "output": "rated\r\n"}, {"input": "2\r\n5 5\r\n4 4\r\n", "output": "maybe\r\n"}, {"input": "2\r\n5 5\r\n3 3\r\n", "output": "maybe\r\n"}, {"input": "5\r\n1500 1500\r\n1300 1300\r\n1200 1200\r\n1400 1400\r\n1100 1100\r\n", "output": "unrated\r\n"}, {"input": "5\r\n10 10\r\n9 9\r\n8 8\r\n7 7\r\n6 6\r\n", "output": "maybe\r\n"}, {"input": "3\r\n1000 1000\r\n300 300\r\n10 10\r\n", "output": "maybe\r\n"}, {"input": "5\r\n6 6\r\n5 5\r\n4 4\r\n3 3\r\n2 2\r\n", "output": "maybe\r\n"}, {"input": "2\r\n3 3\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "4\r\n2 2\r\n2 2\r\n2 2\r\n3 3\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1000 1000\r\n700 700\r\n", "output": "maybe\r\n"}, {"input": "2\r\n4 3\r\n5 3\r\n", "output": "rated\r\n"}, {"input": "2\r\n1000 1000\r\n1100 1100\r\n", "output": "unrated\r\n"}, {"input": "4\r\n5 5\r\n4 4\r\n3 3\r\n2 2\r\n", "output": "maybe\r\n"}, {"input": "3\r\n1 1\r\n2 3\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n1 2\r\n1 3\r\n", "output": "rated\r\n"}, {"input": "2\r\n3 3\r\n1 2\r\n", "output": "rated\r\n"}, {"input": "4\r\n1501 1500\r\n1300 1300\r\n1200 1200\r\n1400 1400\r\n", "output": "rated\r\n"}, {"input": "5\r\n1 1\r\n2 2\r\n3 3\r\n4 4\r\n5 5\r\n", "output": "unrated\r\n"}, {"input": "2\r\n10 10\r\n1 2\r\n", "output": "rated\r\n"}, {"input": "6\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n1699 1699\r\n1900 1900\r\n", "output": "unrated\r\n"}, {"input": "6\r\n3123 3123\r\n2777 2777\r\n3000 3000\r\n2246 2246\r\n2246 2246\r\n1699 1699\r\n", "output": "unrated\r\n"}, {"input": "2\r\n100 100\r\n110 110\r\n", "output": "unrated\r\n"}, {"input": "3\r\n3 3\r\n3 3\r\n4 4\r\n", "output": "unrated\r\n"}, {"input": "3\r\n3 3\r\n3 2\r\n4 4\r\n", "output": "rated\r\n"}, {"input": "3\r\n5 2\r\n4 4\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "4\r\n4 4\r\n3 3\r\n2 2\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "2\r\n1 1\r\n3 2\r\n", "output": "rated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n2699 2699\r\n", "output": "unrated\r\n"}, {"input": "3\r\n3 3\r\n3 3\r\n3 4\r\n", "output": "rated\r\n"}, {"input": "3\r\n1 2\r\n2 2\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "3\r\n1 2\r\n1 2\r\n1 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 1\r\n2 1\r\n", "output": "rated\r\n"}, {"input": "2\r\n1 2\r\n3 4\r\n", "output": "rated\r\n"}, {"input": "2\r\n3 2\r\n2 3\r\n", "output": "rated\r\n"}, {"input": "3\r\n1500 1500\r\n1600 1600\r\n1600 1600\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1 1\r\n3 3\r\n4 4\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1 1\r\n2 2\r\n2 2\r\n", "output": "unrated\r\n"}, {"input": "2\r\n10 12\r\n8 8\r\n", "output": "rated\r\n"}, {"input": "5\r\n1200 1200\r\n1500 1500\r\n1500 1500\r\n1500 1500\r\n1500 1500\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1 2\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "3\r\n1500 1400\r\n1200 1200\r\n1100 1100\r\n", "output": "rated\r\n"}, {"input": "2\r\n10 12\r\n10 10\r\n", "output": "rated\r\n"}, {"input": "3\r\n1500 1500\r\n1400 1400\r\n1300 1300\r\n", "output": "maybe\r\n"}, {"input": "3\r\n3 3\r\n4 4\r\n5 5\r\n", "output": "unrated\r\n"}, {"input": "3\r\n2 6\r\n3 5\r\n4 4\r\n", "output": "rated\r\n"}, {"input": "2\r\n5 6\r\n4 6\r\n", "output": "rated\r\n"}, {"input": "4\r\n10 10\r\n10 10\r\n7 7\r\n8 8\r\n", "output": "unrated\r\n"}, {"input": "2\r\n4 4\r\n3 3\r\n", "output": "maybe\r\n"}]
| false |
stdio
| null | true |
837/B
|
837
|
B
|
Python 3
|
TESTS
| 62 | 62 | 4,915,200 |
29204655
|
N, M = map(int, input().split())
flag = [input() for n in range(N)]
def get_rect_of_color(color):
rect_points = []
for i, row in enumerate(flag):
first = True
tmp = [None] * 4
for j, char in enumerate(row):
if char == color:
if first:
first = False
tmp[0], tmp[1] = i, j
tmp[2], tmp[3] = i, j
if tmp[0] is not None:
rect_points += [tmp]
return rect_points
def get_bounding_rect(rect):
# pprint(rect)
dn = abs(rect[0][0] - rect[0][2])
dm = abs(rect[0][1] - rect[0][3])
last_row = rect[0]
for row in rect:
last_row = row
x1, y1, x2, y2 = row
if x1 is None:
continue
if abs(x2 - x1) != dn or\
abs(y2 - y1) != dm:
raise Exception()
return (
(rect[0][0], rect[0][1]),
(last_row[2], last_row[3]),
)
try:
R = get_bounding_rect(get_rect_of_color('R'))
G = get_bounding_rect(get_rect_of_color('G'))
B = get_bounding_rect(get_rect_of_color('B'))
Rh = abs(R[1][0] - R[0][0])
Bh = abs(B[1][0] - B[0][0])
Gh = abs(G[1][0] - G[0][0])
Rw = abs(R[1][1] - R[0][1])
Bw = abs(B[1][1] - B[0][1])
Gw = abs(G[1][1] - G[0][1])
# print(Rh, Bh, Gh)
# print(Rw, Bw, Gw)
if len(set([Rw, Bw, Gw])) != 1 or len(set([Rh, Bh, Gh])) != 1:
print('NO')
else:
print('YES')
except Exception:
print('NO')
| 153 | 62 | 4,915,200 |
29164140
|
a, b = map(int, input().split())
rows = [list(input()) for x in range(a)]
columns = [[x[y] for x in rows] for y in range(b)]
def check(l):
line = []
for x in l:
p = x[0]
for y in x:
if y != p:
break
else:
line.append(p)
continue
return [False, line]
else:
return [True, line]
def colors(c, l):
p = c[1][0]
n = 0
colors = []
for x in c[1]:
if x != p:
colors.append([p, n])
p = x
n = 1
else:
n += 1
colors.append([p, n])
if len(colors) == 3 and l % 3 == 0:
m = l // 3
letters = ["R", "G", "B"]
for x in colors:
p, q = x[0], x[1]
if x[0] in letters and q == m:
letters.remove(x[0])
else:
return False
break
else:
return True
else:
return False
condition = False
if a % 3 == 0 or b % 3 == 0:
c, d = check(rows), check(columns)
if c[0]:
condition = colors(c, a)
if not condition and d[0]:
condition = colors(d, b)
if condition:
print("YES")
else:
print("NO")
|
Educational Codeforces Round 26
|
ICPC
| 2,017 | 1 | 256 |
Flag of Berland
|
The flag of Berland is such rectangular field n × m that satisfies following conditions:
- Flag consists of three colors which correspond to letters 'R', 'G' and 'B'.
- Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color.
- Each color should be used in exactly one stripe.
You are given a field n × m, consisting of characters 'R', 'G' and 'B'. Output "YES" (without quotes) if this field corresponds to correct flag of Berland. Otherwise, print "NO" (without quotes).
|
The first line contains two integer numbers n and m (1 ≤ n, m ≤ 100) — the sizes of the field.
Each of the following n lines consisting of m characters 'R', 'G' and 'B' — the description of the field.
|
Print "YES" (without quotes) if the given field corresponds to correct flag of Berland . Otherwise, print "NO" (without quotes).
| null |
The field in the third example doesn't have three parralel stripes.
Rows of the field in the fourth example are parralel to each other and to borders. But they have different heights — 2, 1 and 1.
|
[{"input": "6 5\nRRRRR\nRRRRR\nBBBBB\nBBBBB\nGGGGG\nGGGGG", "output": "YES"}, {"input": "4 3\nBRG\nBRG\nBRG\nBRG", "output": "YES"}, {"input": "6 7\nRRRGGGG\nRRRGGGG\nRRRGGGG\nRRRBBBB\nRRRBBBB\nRRRBBBB", "output": "NO"}, {"input": "4 4\nRRRR\nRRRR\nBBBB\nGGGG", "output": "NO"}]
| 1,600 |
["brute force", "implementation"]
| 153 |
[{"input": "6 5\r\nRRRRR\r\nRRRRR\r\nBBBBB\r\nBBBBB\r\nGGGGG\r\nGGGGG\r\n", "output": "YES\r\n"}, {"input": "4 3\r\nBRG\r\nBRG\r\nBRG\r\nBRG\r\n", "output": "YES\r\n"}, {"input": "6 7\r\nRRRGGGG\r\nRRRGGGG\r\nRRRGGGG\r\nRRRBBBB\r\nRRRBBBB\r\nRRRBBBB\r\n", "output": "NO\r\n"}, {"input": "4 4\r\nRRRR\r\nRRRR\r\nBBBB\r\nGGGG\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nGRB\r\n", "output": "YES\r\n"}, {"input": "3 1\r\nR\r\nG\r\nB\r\n", "output": "YES\r\n"}, {"input": "4 3\r\nRGB\r\nGRB\r\nGRB\r\nGRB\r\n", "output": "NO\r\n"}, {"input": "4 6\r\nGGRRBB\r\nGGRRBB\r\nGGRRBB\r\nRRGGBB\r\n", "output": "NO\r\n"}, {"input": "100 3\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nGRB\r\n", "output": "NO\r\n"}, {"input": "3 100\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\nRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRG\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nR\r\nR\r\nB\r\n", "output": "NO\r\n"}, {"input": "3 2\r\nRR\r\nBB\r\nRR\r\n", "output": "NO\r\n"}, {"input": "3 2\r\nRR\r\nBG\r\nBG\r\n", "output": "NO\r\n"}, {"input": "3 2\r\nBB\r\nRR\r\nBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nRRR\r\nRRR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nGGG\r\nGGG\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRGG\r\n", "output": "NO\r\n"}, {"input": "4 3\r\nRGR\r\nRGR\r\nRGR\r\nRGR\r\n", "output": "NO\r\n"}, {"input": "3 4\r\nRRGG\r\nRRGG\r\nBBBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nBRG\r\nBRG\r\nBRG\r\n", "output": "YES\r\n"}, {"input": "3 1\r\nR\r\nG\r\nR\r\n", "output": "NO\r\n"}, {"input": "5 3\r\nBBG\r\nBBG\r\nBBG\r\nBBG\r\nBBG\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nGGG\r\nRRR\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRGR\r\n", "output": "NO\r\n"}, {"input": "3 6\r\nRRBBGG\r\nRRBBGG\r\nRRBBGG\r\n", "output": "YES\r\n"}, {"input": "6 6\r\nRRBBGG\r\nRRBBGG\r\nRRBBGG\r\nRRBBGG\r\nRRBBGG\r\nRRBBGG\r\n", "output": "YES\r\n"}, {"input": "4 3\r\nRRR\r\nGGG\r\nBBB\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nBBB\r\nRRR\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nB\r\nR\r\nB\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nBGB\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nB\r\nB\r\nB\r\n", "output": "NO\r\n"}, {"input": "3 4\r\nRRRR\r\nBBBB\r\nRRRR\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRGGGBB\r\n", "output": "NO\r\n"}, {"input": "9 3\r\nBBB\r\nBBB\r\nBBB\r\nGGG\r\nGGG\r\nGRG\r\nRGR\r\nRRR\r\nRRR\r\n", "output": "NO\r\n"}, {"input": "4 4\r\nRGBB\r\nRGBB\r\nRGBB\r\nRGBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRBR\r\nRBR\r\nRBR\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRRRRBB\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRRRRRR\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRRGGGG\r\n", "output": "NO\r\n"}, {"input": "4 4\r\nRRRR\r\nRRRR\r\nRRRR\r\nRRRR\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nB\r\nG\r\nB\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nR\r\nR\r\nR\r\n", "output": "NO\r\n"}, {"input": "1 9\r\nRRRGGGBBB\r\n", "output": "YES\r\n"}, {"input": "1 3\r\nRRR\r\n", "output": "NO\r\n"}, {"input": "3 5\r\nRRRRR\r\nBBBBB\r\nBBBBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nGGG\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "1 1\r\nR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGR\r\nRGR\r\nRGR\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRBG\r\nGBR\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nRGB\r\nRGB\r\n", "output": "YES\r\n"}, {"input": "1 3\r\nBRB\r\n", "output": "NO\r\n"}, {"input": "2 1\r\nR\r\nB\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRBR\r\n", "output": "NO\r\n"}, {"input": "3 5\r\nRRGBB\r\nRRGBB\r\nRRGBB\r\n", "output": "NO\r\n"}, {"input": "5 3\r\nBBR\r\nBBR\r\nBBR\r\nBBR\r\nBBR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nRBG\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "1 2\r\nRB\r\n", "output": "NO\r\n"}, {"input": "4 3\r\nBBB\r\nBBB\r\nBBB\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "36 6\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\n", "output": "NO\r\n"}, {"input": "4 1\r\nR\r\nB\r\nG\r\nR\r\n", "output": "NO\r\n"}, {"input": "13 12\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\n", "output": "NO\r\n"}, {"input": "2 2\r\nRR\r\nRR\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nRRGGBB\r\nGRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\n", "output": "NO\r\n"}, {"input": "70 3\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\n", "output": "NO\r\n"}, {"input": "4 3\r\nBBG\r\nBBG\r\nBBG\r\nBBG\r\n", "output": "NO\r\n"}, {"input": "6 3\r\nBBB\r\nGGG\r\nRRR\r\nBRG\r\nBRG\r\nBRG\r\n", "output": "NO\r\n"}, {"input": "3 6\r\nRRBBGG\r\nRBBBGG\r\nRBBBGG\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nGGGGGG\r\nGGGGGG\r\nBBBBBB\r\nBBBBBB\r\nGGGGGG\r\nGGGGGG\r\n", "output": "NO\r\n"}, {"input": "6 1\r\nR\r\nB\r\nG\r\nR\r\nB\r\nG\r\n", "output": "NO\r\n"}, {"input": "6 5\r\nRRRRR\r\nBBBBB\r\nGGGGG\r\nRRRRR\r\nBBBBB\r\nGGGGG\r\n", "output": "NO\r\n"}, {"input": "6 3\r\nRRR\r\nGGG\r\nBBB\r\nRRR\r\nGGG\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "6 5\r\nRRRRR\r\nRRRRR\r\nRRRRR\r\nGGGGG\r\nGGGGG\r\nGGGGG\r\n", "output": "NO\r\n"}, {"input": "15 28\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\n", "output": "NO\r\n"}, {"input": "21 10\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nBBBBBBBBBB\r\nBBBBBBBBBB\r\nBBBBBGBBBB\r\nBBBBBBBBBB\r\nBBBBBBBBBB\r\nBBBBBBBBBB\r\nBBBBBBBBBB\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\n", "output": "NO\r\n"}, {"input": "3 2\r\nRR\r\nGB\r\nGB\r\n", "output": "NO\r\n"}, {"input": "3 2\r\nRG\r\nRG\r\nBB\r\n", "output": "NO\r\n"}, {"input": "6 5\r\nRRRRR\r\nRRRRR\r\nBBBBB\r\nBBBBB\r\nRRRRR\r\nRRRRR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nGBR\r\nBRG\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nBGR\r\nBGR\r\nBGR\r\n", "output": "YES\r\n"}, {"input": "6 6\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\n", "output": "YES\r\n"}, {"input": "4 2\r\nRR\r\nGG\r\nRR\r\nBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nRRR\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "8 6\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\n", "output": "NO\r\n"}, {"input": "3 4\r\nRRRR\r\nRRRR\r\nGGGG\r\n", "output": "NO\r\n"}, {"input": "3 4\r\nRRRR\r\nRRRR\r\nRRRR\r\n", "output": "NO\r\n"}, {"input": "6 1\r\nR\r\nR\r\nR\r\nR\r\nR\r\nR\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRRBBGG\r\n", "output": "YES\r\n"}, {"input": "1 6\r\nRGBRGB\r\n", "output": "NO\r\n"}, {"input": "3 4\r\nRRRR\r\nGGGG\r\nRRRR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRB\r\nGRG\r\nGBB\r\n", "output": "NO\r\n"}, {"input": "3 7\r\nRRGGBBB\r\nRRGGBBB\r\nRRGGBBB\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nG\r\nR\r\nR\r\n", "output": "NO\r\n"}, {"input": "2 3\r\nRGG\r\nRBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRG\r\nGGG\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nRBB\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGR\r\nRGB\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nB\r\nR\r\nR\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nGRR\r\n", "output": "NO\r\n"}, {"input": "4 4\r\nRRRR\r\nGGGG\r\nBBBB\r\nBBBB\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nGGR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nGGB\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGR\r\nGGG\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nRRRRRR\r\nGGGGGG\r\nGGGGGG\r\nGGGGGG\r\nBBBBBB\r\nBBBBBB\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nRRRRRR\r\nRRRRRR\r\nGGGGGG\r\nBBBBBB\r\nBBBBBB\r\nBBBBBB\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nG\r\nB\r\nR\r\n", "output": "YES\r\n"}, {"input": "3 3\r\nGGB\r\nRGB\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nGRR\r\nGGG\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nRRRRRR\r\nRRRRRR\r\nGGGGGG\r\nGGGGGG\r\nBBBBBB\r\nRRRRRR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nGBG\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "3 8\r\nRRGGBBBB\r\nRRGGBBBB\r\nRRGGBBBB\r\n", "output": "NO\r\n"}, {"input": "2 2\r\nRR\r\nGG\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nRGR\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRBG\r\n", "output": "YES\r\n"}, {"input": "2 6\r\nRRGGBB\r\nGGRRBB\r\n", "output": "NO\r\n"}, {"input": "6 2\r\nRR\r\nGG\r\nBB\r\nRR\r\nGG\r\nBB\r\n", "output": "NO\r\n"}, {"input": "1 5\r\nRRGGB\r\n", "output": "NO\r\n"}, {"input": "1 2\r\nRG\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRGBRBG\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRRRGGB\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRGB\r\n", "output": "YES\r\n"}, {"input": "4 3\r\nRRR\r\nBBR\r\nGBB\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "6 3\r\nRRR\r\nBBB\r\nBBB\r\nBBB\r\nGGG\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRBG\r\nRBG\r\nRBG\r\n", "output": "YES\r\n"}, {"input": "6 3\r\nRRR\r\nBBB\r\nGGG\r\nRRR\r\nBBB\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "1 4\r\nRGBB\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\n", "output": "NO\r\n"}, {"input": "6 5\r\nRRRRR\r\nRRRRR\r\nGGGGG\r\nGGGGG\r\nRRRRR\r\nRRRRR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nBRG\r\nGBR\r\n", "output": "NO\r\n"}, {"input": "6 10\r\nRRRRRRRRRR\r\nGGGGGGGGGG\r\nBBBBBBBBBB\r\nRRRRRRRRRR\r\nGGGGGGGGGG\r\nBBBBBBBBBB\r\n", "output": "NO\r\n"}, {"input": "20 6\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\n", "output": "YES\r\n"}, {"input": "4 1\r\nR\r\nG\r\nB\r\nR\r\n", "output": "NO\r\n"}, {"input": "1 4\r\nRGBR\r\n", "output": "NO\r\n"}, {"input": "2 4\r\nRGBB\r\nRRGB\r\n", "output": "NO\r\n"}]
| false |
stdio
| null | true |
837/B
|
837
|
B
|
Python 3
|
TESTS
| 24 | 62 | 4,915,200 |
29273806
|
'''input
4 4
RRRR
RRRR
BBBB
GGGG
'''
n, m = map(int, input().split())
if (n*m) % 3 != 0:
print("NO")
else:
f = [input() for _ in range(n)]
if n % 3 == 0:
for x in f:
if len(set(x)) != 1:
print("NO")
break
else:
if any(len(set(f[(n*(i-1))//3:(n*i)//3])) != 1 for i in range(1, 3)):
print("NO")
elif len(set([f[0], f[n//3], f[(2*n)//3]])) != 3:
print("NO")
else:
print("YES")
elif m % 3 == 0:
c = []
for x in range(m):
s = ""
for y in range(n):
s += f[y][x]
c.append(s)
for x in c:
if len(set(x)) != 1:
print("NO")
break
else:
if any(len(set(c[(m*(i-1))//3:(m*i)//3])) != 1 for i in range(1, 3)):
print("NO")
elif len(set([c[0], c[m//3], c[(2*m)//3]])) != 3:
print("NO")
else:
print("YES")
| 153 | 62 | 4,915,200 |
29165939
|
def check(n, m, fl, count):
global flag, tr_flag
if count == 3:
return 'NO'
num = n // 3
is_ok = set()
for k in range(0, n, num):
new_check = set()
for i in range(k, k + num):
new_check = new_check | set(fl[i])
if len(new_check) != 1:
flag, tr_flag = tr_flag, flag
if m % 3 == 0:
return check(m, n, flag, count + 1)
else:
return 'NO'
now = list(new_check)[0]
if now in is_ok:
flag, tr_flag = tr_flag, flag
if m % 3 == 0:
return check(m, n, flag, count + 1)
else:
return 'NO'
is_ok.add(now)
return 'YES'
def main():
global n, m, flag, tr_flag
if n % 3 != 0 and m % 3 != 0:
return 'NO'
if n % 3 == 0:
return check(n, m, flag, 0)
else:
return check(m, n, tr_flag, 0)
n, m = map(int, input().split())
flag = []
for i in range(n):
string = list(input())
flag.append(string)
tr_flag = list(map(list, zip(*flag)))
answer = main()
print(answer)
|
Educational Codeforces Round 26
|
ICPC
| 2,017 | 1 | 256 |
Flag of Berland
|
The flag of Berland is such rectangular field n × m that satisfies following conditions:
- Flag consists of three colors which correspond to letters 'R', 'G' and 'B'.
- Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color.
- Each color should be used in exactly one stripe.
You are given a field n × m, consisting of characters 'R', 'G' and 'B'. Output "YES" (without quotes) if this field corresponds to correct flag of Berland. Otherwise, print "NO" (without quotes).
|
The first line contains two integer numbers n and m (1 ≤ n, m ≤ 100) — the sizes of the field.
Each of the following n lines consisting of m characters 'R', 'G' and 'B' — the description of the field.
|
Print "YES" (without quotes) if the given field corresponds to correct flag of Berland . Otherwise, print "NO" (without quotes).
| null |
The field in the third example doesn't have three parralel stripes.
Rows of the field in the fourth example are parralel to each other and to borders. But they have different heights — 2, 1 and 1.
|
[{"input": "6 5\nRRRRR\nRRRRR\nBBBBB\nBBBBB\nGGGGG\nGGGGG", "output": "YES"}, {"input": "4 3\nBRG\nBRG\nBRG\nBRG", "output": "YES"}, {"input": "6 7\nRRRGGGG\nRRRGGGG\nRRRGGGG\nRRRBBBB\nRRRBBBB\nRRRBBBB", "output": "NO"}, {"input": "4 4\nRRRR\nRRRR\nBBBB\nGGGG", "output": "NO"}]
| 1,600 |
["brute force", "implementation"]
| 153 |
[{"input": "6 5\r\nRRRRR\r\nRRRRR\r\nBBBBB\r\nBBBBB\r\nGGGGG\r\nGGGGG\r\n", "output": "YES\r\n"}, {"input": "4 3\r\nBRG\r\nBRG\r\nBRG\r\nBRG\r\n", "output": "YES\r\n"}, {"input": "6 7\r\nRRRGGGG\r\nRRRGGGG\r\nRRRGGGG\r\nRRRBBBB\r\nRRRBBBB\r\nRRRBBBB\r\n", "output": "NO\r\n"}, {"input": "4 4\r\nRRRR\r\nRRRR\r\nBBBB\r\nGGGG\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nGRB\r\n", "output": "YES\r\n"}, {"input": "3 1\r\nR\r\nG\r\nB\r\n", "output": "YES\r\n"}, {"input": "4 3\r\nRGB\r\nGRB\r\nGRB\r\nGRB\r\n", "output": "NO\r\n"}, {"input": "4 6\r\nGGRRBB\r\nGGRRBB\r\nGGRRBB\r\nRRGGBB\r\n", "output": "NO\r\n"}, {"input": "100 3\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nRGB\r\nGRB\r\n", "output": "NO\r\n"}, {"input": "3 100\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\nRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRG\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nR\r\nR\r\nB\r\n", "output": "NO\r\n"}, {"input": "3 2\r\nRR\r\nBB\r\nRR\r\n", "output": "NO\r\n"}, {"input": "3 2\r\nRR\r\nBG\r\nBG\r\n", "output": "NO\r\n"}, {"input": "3 2\r\nBB\r\nRR\r\nBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nRRR\r\nRRR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nGGG\r\nGGG\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRGG\r\n", "output": "NO\r\n"}, {"input": "4 3\r\nRGR\r\nRGR\r\nRGR\r\nRGR\r\n", "output": "NO\r\n"}, {"input": "3 4\r\nRRGG\r\nRRGG\r\nBBBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nBRG\r\nBRG\r\nBRG\r\n", "output": "YES\r\n"}, {"input": "3 1\r\nR\r\nG\r\nR\r\n", "output": "NO\r\n"}, {"input": "5 3\r\nBBG\r\nBBG\r\nBBG\r\nBBG\r\nBBG\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nGGG\r\nRRR\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRGR\r\n", "output": "NO\r\n"}, {"input": "3 6\r\nRRBBGG\r\nRRBBGG\r\nRRBBGG\r\n", "output": "YES\r\n"}, {"input": "6 6\r\nRRBBGG\r\nRRBBGG\r\nRRBBGG\r\nRRBBGG\r\nRRBBGG\r\nRRBBGG\r\n", "output": "YES\r\n"}, {"input": "4 3\r\nRRR\r\nGGG\r\nBBB\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nBBB\r\nRRR\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nB\r\nR\r\nB\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nBGB\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nB\r\nB\r\nB\r\n", "output": "NO\r\n"}, {"input": "3 4\r\nRRRR\r\nBBBB\r\nRRRR\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRGGGBB\r\n", "output": "NO\r\n"}, {"input": "9 3\r\nBBB\r\nBBB\r\nBBB\r\nGGG\r\nGGG\r\nGRG\r\nRGR\r\nRRR\r\nRRR\r\n", "output": "NO\r\n"}, {"input": "4 4\r\nRGBB\r\nRGBB\r\nRGBB\r\nRGBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRBR\r\nRBR\r\nRBR\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRRRRBB\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRRRRRR\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRRGGGG\r\n", "output": "NO\r\n"}, {"input": "4 4\r\nRRRR\r\nRRRR\r\nRRRR\r\nRRRR\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nB\r\nG\r\nB\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nR\r\nR\r\nR\r\n", "output": "NO\r\n"}, {"input": "1 9\r\nRRRGGGBBB\r\n", "output": "YES\r\n"}, {"input": "1 3\r\nRRR\r\n", "output": "NO\r\n"}, {"input": "3 5\r\nRRRRR\r\nBBBBB\r\nBBBBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nGGG\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "1 1\r\nR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGR\r\nRGR\r\nRGR\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRBG\r\nGBR\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nRGB\r\nRGB\r\n", "output": "YES\r\n"}, {"input": "1 3\r\nBRB\r\n", "output": "NO\r\n"}, {"input": "2 1\r\nR\r\nB\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRBR\r\n", "output": "NO\r\n"}, {"input": "3 5\r\nRRGBB\r\nRRGBB\r\nRRGBB\r\n", "output": "NO\r\n"}, {"input": "5 3\r\nBBR\r\nBBR\r\nBBR\r\nBBR\r\nBBR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nRBG\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "1 2\r\nRB\r\n", "output": "NO\r\n"}, {"input": "4 3\r\nBBB\r\nBBB\r\nBBB\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "36 6\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\nBBRRRR\r\n", "output": "NO\r\n"}, {"input": "4 1\r\nR\r\nB\r\nG\r\nR\r\n", "output": "NO\r\n"}, {"input": "13 12\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\nRRRRGGGGRRRR\r\n", "output": "NO\r\n"}, {"input": "2 2\r\nRR\r\nRR\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nRRGGBB\r\nGRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\n", "output": "NO\r\n"}, {"input": "70 3\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\nBGG\r\n", "output": "NO\r\n"}, {"input": "4 3\r\nBBG\r\nBBG\r\nBBG\r\nBBG\r\n", "output": "NO\r\n"}, {"input": "6 3\r\nBBB\r\nGGG\r\nRRR\r\nBRG\r\nBRG\r\nBRG\r\n", "output": "NO\r\n"}, {"input": "3 6\r\nRRBBGG\r\nRBBBGG\r\nRBBBGG\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nGGGGGG\r\nGGGGGG\r\nBBBBBB\r\nBBBBBB\r\nGGGGGG\r\nGGGGGG\r\n", "output": "NO\r\n"}, {"input": "6 1\r\nR\r\nB\r\nG\r\nR\r\nB\r\nG\r\n", "output": "NO\r\n"}, {"input": "6 5\r\nRRRRR\r\nBBBBB\r\nGGGGG\r\nRRRRR\r\nBBBBB\r\nGGGGG\r\n", "output": "NO\r\n"}, {"input": "6 3\r\nRRR\r\nGGG\r\nBBB\r\nRRR\r\nGGG\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "6 5\r\nRRRRR\r\nRRRRR\r\nRRRRR\r\nGGGGG\r\nGGGGG\r\nGGGGG\r\n", "output": "NO\r\n"}, {"input": "15 28\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\nGGGGGGGGGGGGGGGGGGGGGGGGGGGG\r\n", "output": "NO\r\n"}, {"input": "21 10\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nRRRRRRRRRR\r\nBBBBBBBBBB\r\nBBBBBBBBBB\r\nBBBBBGBBBB\r\nBBBBBBBBBB\r\nBBBBBBBBBB\r\nBBBBBBBBBB\r\nBBBBBBBBBB\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\nGGGGGGGGGG\r\n", "output": "NO\r\n"}, {"input": "3 2\r\nRR\r\nGB\r\nGB\r\n", "output": "NO\r\n"}, {"input": "3 2\r\nRG\r\nRG\r\nBB\r\n", "output": "NO\r\n"}, {"input": "6 5\r\nRRRRR\r\nRRRRR\r\nBBBBB\r\nBBBBB\r\nRRRRR\r\nRRRRR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nGBR\r\nBRG\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nBGR\r\nBGR\r\nBGR\r\n", "output": "YES\r\n"}, {"input": "6 6\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\n", "output": "YES\r\n"}, {"input": "4 2\r\nRR\r\nGG\r\nRR\r\nBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nRRR\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "8 6\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\n", "output": "NO\r\n"}, {"input": "3 4\r\nRRRR\r\nRRRR\r\nGGGG\r\n", "output": "NO\r\n"}, {"input": "3 4\r\nRRRR\r\nRRRR\r\nRRRR\r\n", "output": "NO\r\n"}, {"input": "6 1\r\nR\r\nR\r\nR\r\nR\r\nR\r\nR\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRRBBGG\r\n", "output": "YES\r\n"}, {"input": "1 6\r\nRGBRGB\r\n", "output": "NO\r\n"}, {"input": "3 4\r\nRRRR\r\nGGGG\r\nRRRR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRB\r\nGRG\r\nGBB\r\n", "output": "NO\r\n"}, {"input": "3 7\r\nRRGGBBB\r\nRRGGBBB\r\nRRGGBBB\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nG\r\nR\r\nR\r\n", "output": "NO\r\n"}, {"input": "2 3\r\nRGG\r\nRBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRG\r\nGGG\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nRBB\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGR\r\nRGB\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nB\r\nR\r\nR\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nGRR\r\n", "output": "NO\r\n"}, {"input": "4 4\r\nRRRR\r\nGGGG\r\nBBBB\r\nBBBB\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nGGR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nGGB\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGR\r\nGGG\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nRRRRRR\r\nGGGGGG\r\nGGGGGG\r\nGGGGGG\r\nBBBBBB\r\nBBBBBB\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nRRRRRR\r\nRRRRRR\r\nGGGGGG\r\nBBBBBB\r\nBBBBBB\r\nBBBBBB\r\n", "output": "NO\r\n"}, {"input": "3 1\r\nG\r\nB\r\nR\r\n", "output": "YES\r\n"}, {"input": "3 3\r\nGGB\r\nRGB\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nGRR\r\nGGG\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nRRRRRR\r\nRRRRRR\r\nGGGGGG\r\nGGGGGG\r\nBBBBBB\r\nRRRRRR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRRR\r\nGBG\r\nBBB\r\n", "output": "NO\r\n"}, {"input": "3 8\r\nRRGGBBBB\r\nRRGGBBBB\r\nRRGGBBBB\r\n", "output": "NO\r\n"}, {"input": "2 2\r\nRR\r\nGG\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nRGR\r\nRGB\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRBG\r\n", "output": "YES\r\n"}, {"input": "2 6\r\nRRGGBB\r\nGGRRBB\r\n", "output": "NO\r\n"}, {"input": "6 2\r\nRR\r\nGG\r\nBB\r\nRR\r\nGG\r\nBB\r\n", "output": "NO\r\n"}, {"input": "1 5\r\nRRGGB\r\n", "output": "NO\r\n"}, {"input": "1 2\r\nRG\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRGBRBG\r\n", "output": "NO\r\n"}, {"input": "1 6\r\nRRRGGB\r\n", "output": "NO\r\n"}, {"input": "1 3\r\nRGB\r\n", "output": "YES\r\n"}, {"input": "4 3\r\nRRR\r\nBBR\r\nGBB\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "6 3\r\nRRR\r\nBBB\r\nBBB\r\nBBB\r\nGGG\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRBG\r\nRBG\r\nRBG\r\n", "output": "YES\r\n"}, {"input": "6 3\r\nRRR\r\nBBB\r\nGGG\r\nRRR\r\nBBB\r\nGGG\r\n", "output": "NO\r\n"}, {"input": "1 4\r\nRGBB\r\n", "output": "NO\r\n"}, {"input": "6 6\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\nRRRRRR\r\n", "output": "NO\r\n"}, {"input": "6 5\r\nRRRRR\r\nRRRRR\r\nGGGGG\r\nGGGGG\r\nRRRRR\r\nRRRRR\r\n", "output": "NO\r\n"}, {"input": "3 3\r\nRGB\r\nBRG\r\nGBR\r\n", "output": "NO\r\n"}, {"input": "6 10\r\nRRRRRRRRRR\r\nGGGGGGGGGG\r\nBBBBBBBBBB\r\nRRRRRRRRRR\r\nGGGGGGGGGG\r\nBBBBBBBBBB\r\n", "output": "NO\r\n"}, {"input": "20 6\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\nRRGGBB\r\n", "output": "YES\r\n"}, {"input": "4 1\r\nR\r\nG\r\nB\r\nR\r\n", "output": "NO\r\n"}, {"input": "1 4\r\nRGBR\r\n", "output": "NO\r\n"}, {"input": "2 4\r\nRGBB\r\nRRGB\r\n", "output": "NO\r\n"}]
| false |
stdio
| null | true |
99/B
|
99
|
B
|
PyPy 3
|
TESTS
| 136 | 139 | 1,433,600 |
110947011
|
n = int(input())
d = {}
for i in range(n):
s = int(input())
if s in d:
d[s] += [i + 1]
else:
d[s] = [i + 1]
if len(d) == 1:
print("Exemplary pages.")
exit()
mx = max(d)
mn = min(d)
if len(d) > 3 or len(d[mx]) != 1 or len(d[mn]) != 1:
print("Unrecoverable configuration.")
exit()
if (mx - mn) % 2:
print("Unrecoverable configuration.")
exit()
print((mx - mn) // 2, ' ml. from cup #', *d[mn], ' to cup #', *d[mx], '.', sep='')
| 200 | 46 | 0 |
136745255
|
n=int(input())
a=[0]*n
for i in range(n):
a[i]=int(input())
avg=sum(a)
if avg%n!=0:
print('Unrecoverable configuration.')
exit(0)
avg=avg//n
x=[]
for i in range(n):
if a[i]!=avg:
x.append(i)
if len(x)==0:
print('Exemplary pages.')
elif len(x)==2:
if (a[x[0]]+a[x[1]])//2==avg:
d=abs(a[x[0]]-a[x[1]])//2
if a[x[0]]>a[x[1]]:
print(str(d)+' ml. from cup #'+str(x[1]+1)+' to cup #'+str(x[0]+1)+'.')
else:
print(str(d)+' ml. from cup #'+str(x[0]+1)+' to cup #'+str(x[1]+1)+'.')
else:
print('Unrecoverable configuration.')
else:
print('Unrecoverable configuration.')
|
Codeforces Beta Round 78 (Div. 2 Only)
|
CF
| 2,011 | 0.5 | 256 |
Help Chef Gerasim
|
In a far away kingdom young pages help to set the table for the King. As they are terribly mischievous, one needs to keep an eye on the control whether they have set everything correctly. This time the royal chef Gerasim had the impression that the pages have played a prank again: they had poured the juice from one cup to another. Now Gerasim wants to check his hypothesis. The good thing is that chef Gerasim always pour the same number of milliliters of juice to all cups in the royal kitchen. Having thoroughly measured the juice in each cup, Gerasim asked you to write a program that will determine from which cup juice was poured to which one; otherwise, the program should determine that this time the pages set the table diligently.
To simplify your task we shall consider the cups to be bottomless so that the juice never overfills a cup and pours out, however much it can be. Besides, by some strange reason in a far away kingdom one can only pour to a cup or from one cup to another an integer number of milliliters of juice.
|
The first line contains integer n — the number of cups on the royal table (1 ≤ n ≤ 1000). Next n lines contain volumes of juice in each cup — non-negative integers, not exceeding 104.
|
If the pages didn't pour the juice, print "Exemplary pages." (without the quotes). If you can determine the volume of juice poured during exactly one juice pouring, print "v ml. from cup #a to cup #b." (without the quotes), where v represents the volume of poured juice, a represents the number of the cup from which the juice was poured (the cups are numbered with consecutive positive integers starting from one in the order in which the cups are described in the input data), b represents the number of the cup into which the juice was poured. Finally, if the given juice's volumes cannot be obtained using no more than one pouring (for example, the pages poured the juice from one cup to another more than once or the royal kitchen maids poured the juice into the cups incorrectly), print "Unrecoverable configuration." (without the quotes).
| null | null |
[{"input": "5\n270\n250\n250\n230\n250", "output": "20 ml. from cup #4 to cup #1."}, {"input": "5\n250\n250\n250\n250\n250", "output": "Exemplary pages."}, {"input": "5\n270\n250\n249\n230\n250", "output": "Unrecoverable configuration."}]
| 1,300 |
["implementation", "sortings"]
| 200 |
[{"input": "5\r\n270\r\n250\r\n250\r\n230\r\n250\r\n", "output": "20 ml. from cup #4 to cup #1.\r\n"}, {"input": "5\r\n250\r\n250\r\n250\r\n250\r\n250\r\n", "output": "Exemplary pages.\r\n"}, {"input": "5\r\n270\r\n250\r\n249\r\n230\r\n250\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n200\r\n190\r\n210\r\n200\r\n", "output": "10 ml. from cup #2 to cup #3.\r\n"}, {"input": "4\r\n1\r\n2\r\n3\r\n4\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "1\r\n0\r\n", "output": "Exemplary pages.\r\n"}, {"input": "2\r\n0\r\n0\r\n", "output": "Exemplary pages.\r\n"}, {"input": "2\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "2\r\n0\r\n2\r\n", "output": "1 ml. from cup #1 to cup #2.\r\n"}, {"input": "2\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "2\r\n1\r\n1\r\n", "output": "Exemplary pages.\r\n"}, {"input": "2\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "2\r\n2\r\n0\r\n", "output": "1 ml. from cup #2 to cup #1.\r\n"}, {"input": "2\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "2\r\n2\r\n2\r\n", "output": "Exemplary pages.\r\n"}, {"input": "3\r\n0\r\n0\r\n0\r\n", "output": "Exemplary pages.\r\n"}, {"input": "3\r\n0\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n0\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n0\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n0\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n0\r\n1\r\n2\r\n", "output": "1 ml. from cup #1 to cup #3.\r\n"}, {"input": "3\r\n0\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n0\r\n2\r\n1\r\n", "output": "1 ml. from cup #1 to cup #2.\r\n"}, {"input": "3\r\n0\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n0\r\n2\r\n", "output": "1 ml. from cup #2 to cup #3.\r\n"}, {"input": "3\r\n1\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n1\r\n1\r\n", "output": "Exemplary pages.\r\n"}, {"input": "3\r\n1\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n2\r\n0\r\n", "output": "1 ml. from cup #3 to cup #2.\r\n"}, {"input": "3\r\n1\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n0\r\n1\r\n", "output": "1 ml. from cup #2 to cup #1.\r\n"}, {"input": "3\r\n2\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n1\r\n0\r\n", "output": "1 ml. from cup #3 to cup #1.\r\n"}, {"input": "3\r\n2\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n2\r\n2\r\n", "output": "Exemplary pages.\r\n"}, {"input": "4\r\n0\r\n0\r\n0\r\n0\r\n", "output": "Exemplary pages.\r\n"}, {"input": "4\r\n0\r\n0\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n1\r\n2\r\n", "output": "1 ml. from cup #1 to cup #4.\r\n"}, {"input": "4\r\n0\r\n1\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n2\r\n1\r\n", "output": "1 ml. from cup #1 to cup #3.\r\n"}, {"input": "4\r\n0\r\n1\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n1\r\n1\r\n", "output": "1 ml. from cup #1 to cup #2.\r\n"}, {"input": "4\r\n0\r\n2\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n1\r\n2\r\n", "output": "1 ml. from cup #2 to cup #4.\r\n"}, {"input": "4\r\n1\r\n0\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n2\r\n1\r\n", "output": "1 ml. from cup #2 to cup #3.\r\n"}, {"input": "4\r\n1\r\n0\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n0\r\n2\r\n", "output": "1 ml. from cup #3 to cup #4.\r\n"}, {"input": "4\r\n1\r\n1\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n1\r\n1\r\n", "output": "Exemplary pages.\r\n"}, {"input": "4\r\n1\r\n1\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n2\r\n0\r\n", "output": "1 ml. from cup #4 to cup #3.\r\n"}, {"input": "4\r\n1\r\n1\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n0\r\n1\r\n", "output": "1 ml. from cup #3 to cup #2.\r\n"}, {"input": "4\r\n1\r\n2\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n1\r\n0\r\n", "output": "1 ml. from cup #4 to cup #2.\r\n"}, {"input": "4\r\n1\r\n2\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n1\r\n1\r\n", "output": "1 ml. from cup #2 to cup #1.\r\n"}, {"input": "4\r\n2\r\n0\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n0\r\n1\r\n", "output": "1 ml. from cup #3 to cup #1.\r\n"}, {"input": "4\r\n2\r\n1\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n1\r\n0\r\n", "output": "1 ml. from cup #4 to cup #1.\r\n"}, {"input": "4\r\n2\r\n1\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n2\r\n2\r\n", "output": "Exemplary pages.\r\n"}, {"input": "27\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n2626\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n8572\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n", "output": "2973 ml. from cup #11 to cup #17.\r\n"}, {"input": "19\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n82\r\n5001\r\n9919\r\n5001\r\n5001\r\n", "output": "Unrecoverable configuration.\r\n"}]
| false |
stdio
| null | true |
99/B
|
99
|
B
|
Python 3
|
TESTS
| 136 | 77 | 512,000 |
111230120
|
from operator import itemgetter
import functools as ft
if __name__ == '__main__':
n = int(input())
s = lambda v, a, b: "%s ml. from cup #%s to cup #%s." % (v, a, b)
a, d, ans = list(), dict(), ["Exemplary pages.", "Unrecoverable configuration."]
for i in range(n):
k = int(input())
a.append(k)
d[k] = d.get(k, 0) + 1
d = sorted(d.items(), key=itemgetter(1))
k = [x[0] for x in d if x[1] == 1]
if len(d) == 1:
print(ans[0])
elif (len(d) == 2 or len(d) == 3) and len(k) > 0:
t = ft.reduce(lambda x, y: x + y, k)
mx, mn = max(k), min(k)
if len(k) == 2 and t % 2 == 0:
print(s(abs(mx - mn) // 2, a.index(mn) + 1, a.index(mx) + 1))
elif len(k) == 3 and t // 3 == t - (mx + mn) and t - (mx + mn) == 2 * (mx + mn) - t:
print(s(t - (mx + mn), a.index(mn) + 1, a.index(mx) + 1))
else:
print(ans[1])
else:
print(ans[1])
| 200 | 46 | 0 |
144160247
|
n = int(input())
a = []
for i in range(n):
a.append(int(input()))
if(sum(a)%n != 0):
print("Unrecoverable configuration.")
else:
k = sum(a)//n
res = []
flag = 0
for i in range(n):
if(a[i] != k):
flag = 1
res.append([a[i],i])
if(flag == 0):
print("Exemplary pages.")
else:
if(len(res) == 2):
res.sort()
print(str(res[1][0]-k) + " ml. from cup #" + str(res[0][1]+1) + " to cup #" +str(res[1][1]+1) + ".")
else:
print("Unrecoverable configuration.")
|
Codeforces Beta Round 78 (Div. 2 Only)
|
CF
| 2,011 | 0.5 | 256 |
Help Chef Gerasim
|
In a far away kingdom young pages help to set the table for the King. As they are terribly mischievous, one needs to keep an eye on the control whether they have set everything correctly. This time the royal chef Gerasim had the impression that the pages have played a prank again: they had poured the juice from one cup to another. Now Gerasim wants to check his hypothesis. The good thing is that chef Gerasim always pour the same number of milliliters of juice to all cups in the royal kitchen. Having thoroughly measured the juice in each cup, Gerasim asked you to write a program that will determine from which cup juice was poured to which one; otherwise, the program should determine that this time the pages set the table diligently.
To simplify your task we shall consider the cups to be bottomless so that the juice never overfills a cup and pours out, however much it can be. Besides, by some strange reason in a far away kingdom one can only pour to a cup or from one cup to another an integer number of milliliters of juice.
|
The first line contains integer n — the number of cups on the royal table (1 ≤ n ≤ 1000). Next n lines contain volumes of juice in each cup — non-negative integers, not exceeding 104.
|
If the pages didn't pour the juice, print "Exemplary pages." (without the quotes). If you can determine the volume of juice poured during exactly one juice pouring, print "v ml. from cup #a to cup #b." (without the quotes), where v represents the volume of poured juice, a represents the number of the cup from which the juice was poured (the cups are numbered with consecutive positive integers starting from one in the order in which the cups are described in the input data), b represents the number of the cup into which the juice was poured. Finally, if the given juice's volumes cannot be obtained using no more than one pouring (for example, the pages poured the juice from one cup to another more than once or the royal kitchen maids poured the juice into the cups incorrectly), print "Unrecoverable configuration." (without the quotes).
| null | null |
[{"input": "5\n270\n250\n250\n230\n250", "output": "20 ml. from cup #4 to cup #1."}, {"input": "5\n250\n250\n250\n250\n250", "output": "Exemplary pages."}, {"input": "5\n270\n250\n249\n230\n250", "output": "Unrecoverable configuration."}]
| 1,300 |
["implementation", "sortings"]
| 200 |
[{"input": "5\r\n270\r\n250\r\n250\r\n230\r\n250\r\n", "output": "20 ml. from cup #4 to cup #1.\r\n"}, {"input": "5\r\n250\r\n250\r\n250\r\n250\r\n250\r\n", "output": "Exemplary pages.\r\n"}, {"input": "5\r\n270\r\n250\r\n249\r\n230\r\n250\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n200\r\n190\r\n210\r\n200\r\n", "output": "10 ml. from cup #2 to cup #3.\r\n"}, {"input": "4\r\n1\r\n2\r\n3\r\n4\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "1\r\n0\r\n", "output": "Exemplary pages.\r\n"}, {"input": "2\r\n0\r\n0\r\n", "output": "Exemplary pages.\r\n"}, {"input": "2\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "2\r\n0\r\n2\r\n", "output": "1 ml. from cup #1 to cup #2.\r\n"}, {"input": "2\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "2\r\n1\r\n1\r\n", "output": "Exemplary pages.\r\n"}, {"input": "2\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "2\r\n2\r\n0\r\n", "output": "1 ml. from cup #2 to cup #1.\r\n"}, {"input": "2\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "2\r\n2\r\n2\r\n", "output": "Exemplary pages.\r\n"}, {"input": "3\r\n0\r\n0\r\n0\r\n", "output": "Exemplary pages.\r\n"}, {"input": "3\r\n0\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n0\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n0\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n0\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n0\r\n1\r\n2\r\n", "output": "1 ml. from cup #1 to cup #3.\r\n"}, {"input": "3\r\n0\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n0\r\n2\r\n1\r\n", "output": "1 ml. from cup #1 to cup #2.\r\n"}, {"input": "3\r\n0\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n0\r\n2\r\n", "output": "1 ml. from cup #2 to cup #3.\r\n"}, {"input": "3\r\n1\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n1\r\n1\r\n", "output": "Exemplary pages.\r\n"}, {"input": "3\r\n1\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n2\r\n0\r\n", "output": "1 ml. from cup #3 to cup #2.\r\n"}, {"input": "3\r\n1\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n0\r\n1\r\n", "output": "1 ml. from cup #2 to cup #1.\r\n"}, {"input": "3\r\n2\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n1\r\n0\r\n", "output": "1 ml. from cup #3 to cup #1.\r\n"}, {"input": "3\r\n2\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n2\r\n2\r\n", "output": "Exemplary pages.\r\n"}, {"input": "4\r\n0\r\n0\r\n0\r\n0\r\n", "output": "Exemplary pages.\r\n"}, {"input": "4\r\n0\r\n0\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n1\r\n2\r\n", "output": "1 ml. from cup #1 to cup #4.\r\n"}, {"input": "4\r\n0\r\n1\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n2\r\n1\r\n", "output": "1 ml. from cup #1 to cup #3.\r\n"}, {"input": "4\r\n0\r\n1\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n1\r\n1\r\n", "output": "1 ml. from cup #1 to cup #2.\r\n"}, {"input": "4\r\n0\r\n2\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n1\r\n2\r\n", "output": "1 ml. from cup #2 to cup #4.\r\n"}, {"input": "4\r\n1\r\n0\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n2\r\n1\r\n", "output": "1 ml. from cup #2 to cup #3.\r\n"}, {"input": "4\r\n1\r\n0\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n0\r\n2\r\n", "output": "1 ml. from cup #3 to cup #4.\r\n"}, {"input": "4\r\n1\r\n1\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n1\r\n1\r\n", "output": "Exemplary pages.\r\n"}, {"input": "4\r\n1\r\n1\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n2\r\n0\r\n", "output": "1 ml. from cup #4 to cup #3.\r\n"}, {"input": "4\r\n1\r\n1\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n0\r\n1\r\n", "output": "1 ml. from cup #3 to cup #2.\r\n"}, {"input": "4\r\n1\r\n2\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n1\r\n0\r\n", "output": "1 ml. from cup #4 to cup #2.\r\n"}, {"input": "4\r\n1\r\n2\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n1\r\n1\r\n", "output": "1 ml. from cup #2 to cup #1.\r\n"}, {"input": "4\r\n2\r\n0\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n0\r\n1\r\n", "output": "1 ml. from cup #3 to cup #1.\r\n"}, {"input": "4\r\n2\r\n1\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n1\r\n0\r\n", "output": "1 ml. from cup #4 to cup #1.\r\n"}, {"input": "4\r\n2\r\n1\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n2\r\n2\r\n", "output": "Exemplary pages.\r\n"}, {"input": "27\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n2626\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n8572\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n", "output": "2973 ml. from cup #11 to cup #17.\r\n"}, {"input": "19\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n82\r\n5001\r\n9919\r\n5001\r\n5001\r\n", "output": "Unrecoverable configuration.\r\n"}]
| false |
stdio
| null | true |
807/A
|
807
|
A
|
Python 3
|
TESTS
| 34 | 62 | 307,200 |
106524131
|
n=int(input())
a=[0]*n
flag=-1
for i in range(n):
if flag==1:continue
p, q=[int(y) for y in input().split()]
a[i]=p-q
if i==0:
temp1 = p
temp2 = a[i]
else:
if temp2!=a[i]:
flag=1
elif temp1<p:
flag=0
else:
temp1=p
if flag==1:print('rated')
elif flag==0:print('unrated')
elif flag==-1:print('maybe')
| 150 | 46 | 0 |
145145439
|
n=int(input())
a,b=0,0
counter=0
List=[]
for i in range(n):
a,b=map(int,input().split())
if a!=b:
counter+=1
List.append([a,b])
if counter!=0:
List.clear()
print("rated")
else :
check=False
for i in range(1,len(List)):
if List[i][0]>List[i-1][0]:
print("unrated")
check=True
break
if not check:
print("maybe")
|
Codeforces Round 412 (rated, Div. 2, base on VK Cup 2017 Round 3)
|
CF
| 2,017 | 2 | 256 |
Is it rated?
|
Is it rated?
Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it.
Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before and after the round is known.
It's known that if at least one participant's rating has changed, then the round was rated for sure.
It's also known that if the round was rated and a participant with lower rating took a better place in the standings than a participant with higher rating, then at least one round participant's rating has changed.
In this problem, you should not make any other assumptions about the rating system.
Determine if the current round is rated, unrated, or it's impossible to determine whether it is rated of not.
|
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of round participants.
Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 4126) — the rating of the i-th participant before and after the round, respectively. The participants are listed in order from the top to the bottom of the standings.
|
If the round is rated for sure, print "rated". If the round is unrated for sure, print "unrated". If it's impossible to determine whether the round is rated or not, print "maybe".
| null |
In the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated.
In the second example, no one's rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, someone's rating would've changed for sure.
In the third example, no one's rating has changed, and the participants took places in non-increasing order of their rating. Therefore, it's impossible to determine whether the round is rated or not.
|
[{"input": "6\n3060 3060\n2194 2194\n2876 2903\n2624 2624\n3007 2991\n2884 2884", "output": "rated"}, {"input": "4\n1500 1500\n1300 1300\n1200 1200\n1400 1400", "output": "unrated"}, {"input": "5\n3123 3123\n2777 2777\n2246 2246\n2246 2246\n1699 1699", "output": "maybe"}]
| 900 |
["implementation", "sortings"]
| 150 |
[{"input": "6\r\n3060 3060\r\n2194 2194\r\n2876 2903\r\n2624 2624\r\n3007 2991\r\n2884 2884\r\n", "output": "rated\r\n"}, {"input": "4\r\n1500 1500\r\n1300 1300\r\n1200 1200\r\n1400 1400\r\n", "output": "unrated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n1699 1699\r\n", "output": "maybe\r\n"}, {"input": "2\r\n1 1\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "2\r\n4126 4126\r\n4126 4126\r\n", "output": "maybe\r\n"}, {"input": "10\r\n446 446\r\n1331 1331\r\n3594 3594\r\n1346 1902\r\n91 91\r\n3590 3590\r\n2437 2437\r\n4007 3871\r\n2797 699\r\n1423 1423\r\n", "output": "rated\r\n"}, {"input": "10\r\n4078 4078\r\n2876 2876\r\n1061 1061\r\n3721 3721\r\n143 143\r\n2992 2992\r\n3279 3279\r\n3389 3389\r\n1702 1702\r\n1110 1110\r\n", "output": "unrated\r\n"}, {"input": "10\r\n4078 4078\r\n3721 3721\r\n3389 3389\r\n3279 3279\r\n2992 2992\r\n2876 2876\r\n1702 1702\r\n1110 1110\r\n1061 1061\r\n143 143\r\n", "output": "maybe\r\n"}, {"input": "2\r\n3936 3936\r\n2967 2967\r\n", "output": "maybe\r\n"}, {"input": "2\r\n1 1\r\n2 2\r\n", "output": "unrated\r\n"}, {"input": "2\r\n2 2\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "2\r\n2 1\r\n1 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n2967 2967\r\n3936 3936\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1200 1200\r\n1200 1200\r\n1300 1300\r\n", "output": "unrated\r\n"}, {"input": "3\r\n3 3\r\n2 2\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "3\r\n1 1\r\n1 1\r\n2 2\r\n", "output": "unrated\r\n"}, {"input": "2\r\n3 2\r\n3 2\r\n", "output": "rated\r\n"}, {"input": "3\r\n5 5\r\n4 4\r\n3 4\r\n", "output": "rated\r\n"}, {"input": "3\r\n200 200\r\n200 200\r\n300 300\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1 1\r\n2 2\r\n3 3\r\n", "output": "unrated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2245 2245\r\n1699 1699\r\n", "output": "maybe\r\n"}, {"input": "2\r\n10 10\r\n8 8\r\n", "output": "maybe\r\n"}, {"input": "3\r\n1500 1500\r\n1500 1500\r\n1600 1600\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1500 1500\r\n1500 1500\r\n1700 1700\r\n", "output": "unrated\r\n"}, {"input": "4\r\n100 100\r\n100 100\r\n70 70\r\n80 80\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1 2\r\n2 1\r\n", "output": "rated\r\n"}, {"input": "3\r\n5 5\r\n4 3\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "3\r\n1600 1650\r\n1500 1550\r\n1400 1450\r\n", "output": "rated\r\n"}, {"input": "4\r\n2000 2000\r\n1500 1500\r\n1500 1500\r\n1700 1700\r\n", "output": "unrated\r\n"}, {"input": "4\r\n1500 1500\r\n1400 1400\r\n1400 1400\r\n1700 1700\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1600 1600\r\n1400 1400\r\n", "output": "maybe\r\n"}, {"input": "2\r\n3 1\r\n9 8\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 1\r\n1 1\r\n", "output": "rated\r\n"}, {"input": "4\r\n4123 4123\r\n4123 4123\r\n2670 2670\r\n3670 3670\r\n", "output": "unrated\r\n"}, {"input": "2\r\n2 2\r\n3 3\r\n", "output": "unrated\r\n"}, {"input": "2\r\n10 11\r\n5 4\r\n", "output": "rated\r\n"}, {"input": "2\r\n15 14\r\n13 12\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 1\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "3\r\n2670 2670\r\n3670 3670\r\n4106 4106\r\n", "output": "unrated\r\n"}, {"input": "3\r\n4 5\r\n3 3\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n10 9\r\n10 10\r\n", "output": "rated\r\n"}, {"input": "3\r\n1011 1011\r\n1011 999\r\n2200 2100\r\n", "output": "rated\r\n"}, {"input": "2\r\n3 3\r\n5 5\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1500 1500\r\n3000 2000\r\n", "output": "rated\r\n"}, {"input": "2\r\n5 6\r\n5 5\r\n", "output": "rated\r\n"}, {"input": "3\r\n2000 2000\r\n1500 1501\r\n500 500\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 3\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n3 3\r\n2 2\r\n", "output": "maybe\r\n"}, {"input": "2\r\n1 2\r\n1 1\r\n", "output": "rated\r\n"}, {"input": "4\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n1699 1699\r\n", "output": "maybe\r\n"}, {"input": "2\r\n15 14\r\n14 13\r\n", "output": "rated\r\n"}, {"input": "4\r\n3000 3000\r\n2900 2900\r\n3000 3000\r\n2900 2900\r\n", "output": "unrated\r\n"}, {"input": "6\r\n30 3060\r\n24 2194\r\n26 2903\r\n24 2624\r\n37 2991\r\n24 2884\r\n", "output": "rated\r\n"}, {"input": "2\r\n100 99\r\n100 100\r\n", "output": "rated\r\n"}, {"input": "4\r\n2 2\r\n1 1\r\n1 1\r\n2 2\r\n", "output": "unrated\r\n"}, {"input": "3\r\n100 101\r\n100 100\r\n100 100\r\n", "output": "rated\r\n"}, {"input": "4\r\n1000 1001\r\n900 900\r\n950 950\r\n890 890\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 3\r\n1 1\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 2\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "2\r\n3 2\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n3 2\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "2\r\n1 1\r\n2 2\r\n", "output": "unrated\r\n"}, {"input": "3\r\n3 2\r\n3 3\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "4\r\n1500 1501\r\n1300 1300\r\n1200 1200\r\n1400 1400\r\n", "output": "rated\r\n"}, {"input": "3\r\n1000 1000\r\n500 500\r\n400 300\r\n", "output": "rated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n3000 3000\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1 1\r\n2 3\r\n", "output": "rated\r\n"}, {"input": "2\r\n6 2\r\n6 2\r\n", "output": "rated\r\n"}, {"input": "5\r\n3123 3123\r\n1699 1699\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1500 1500\r\n1600 1600\r\n", "output": "unrated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2241 2241\r\n1699 1699\r\n", "output": "maybe\r\n"}, {"input": "2\r\n20 30\r\n10 5\r\n", "output": "rated\r\n"}, {"input": "3\r\n1 1\r\n2 2\r\n1 1\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1 2\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "5\r\n5 5\r\n4 4\r\n3 3\r\n2 2\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "2\r\n2 2\r\n2 1\r\n", "output": "rated\r\n"}, {"input": "2\r\n100 100\r\n90 89\r\n", "output": "rated\r\n"}, {"input": "2\r\n1000 900\r\n2000 2000\r\n", "output": "rated\r\n"}, {"input": "2\r\n50 10\r\n10 50\r\n", "output": "rated\r\n"}, {"input": "2\r\n200 200\r\n100 100\r\n", "output": "maybe\r\n"}, {"input": "3\r\n2 2\r\n2 2\r\n3 3\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1000 1000\r\n300 300\r\n100 100\r\n", "output": "maybe\r\n"}, {"input": "4\r\n2 2\r\n2 2\r\n3 3\r\n4 4\r\n", "output": "unrated\r\n"}, {"input": "2\r\n5 3\r\n6 3\r\n", "output": "rated\r\n"}, {"input": "2\r\n1200 1100\r\n1200 1000\r\n", "output": "rated\r\n"}, {"input": "2\r\n5 5\r\n4 4\r\n", "output": "maybe\r\n"}, {"input": "2\r\n5 5\r\n3 3\r\n", "output": "maybe\r\n"}, {"input": "5\r\n1500 1500\r\n1300 1300\r\n1200 1200\r\n1400 1400\r\n1100 1100\r\n", "output": "unrated\r\n"}, {"input": "5\r\n10 10\r\n9 9\r\n8 8\r\n7 7\r\n6 6\r\n", "output": "maybe\r\n"}, {"input": "3\r\n1000 1000\r\n300 300\r\n10 10\r\n", "output": "maybe\r\n"}, {"input": "5\r\n6 6\r\n5 5\r\n4 4\r\n3 3\r\n2 2\r\n", "output": "maybe\r\n"}, {"input": "2\r\n3 3\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "4\r\n2 2\r\n2 2\r\n2 2\r\n3 3\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1000 1000\r\n700 700\r\n", "output": "maybe\r\n"}, {"input": "2\r\n4 3\r\n5 3\r\n", "output": "rated\r\n"}, {"input": "2\r\n1000 1000\r\n1100 1100\r\n", "output": "unrated\r\n"}, {"input": "4\r\n5 5\r\n4 4\r\n3 3\r\n2 2\r\n", "output": "maybe\r\n"}, {"input": "3\r\n1 1\r\n2 3\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n1 2\r\n1 3\r\n", "output": "rated\r\n"}, {"input": "2\r\n3 3\r\n1 2\r\n", "output": "rated\r\n"}, {"input": "4\r\n1501 1500\r\n1300 1300\r\n1200 1200\r\n1400 1400\r\n", "output": "rated\r\n"}, {"input": "5\r\n1 1\r\n2 2\r\n3 3\r\n4 4\r\n5 5\r\n", "output": "unrated\r\n"}, {"input": "2\r\n10 10\r\n1 2\r\n", "output": "rated\r\n"}, {"input": "6\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n1699 1699\r\n1900 1900\r\n", "output": "unrated\r\n"}, {"input": "6\r\n3123 3123\r\n2777 2777\r\n3000 3000\r\n2246 2246\r\n2246 2246\r\n1699 1699\r\n", "output": "unrated\r\n"}, {"input": "2\r\n100 100\r\n110 110\r\n", "output": "unrated\r\n"}, {"input": "3\r\n3 3\r\n3 3\r\n4 4\r\n", "output": "unrated\r\n"}, {"input": "3\r\n3 3\r\n3 2\r\n4 4\r\n", "output": "rated\r\n"}, {"input": "3\r\n5 2\r\n4 4\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "4\r\n4 4\r\n3 3\r\n2 2\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "2\r\n1 1\r\n3 2\r\n", "output": "rated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n2699 2699\r\n", "output": "unrated\r\n"}, {"input": "3\r\n3 3\r\n3 3\r\n3 4\r\n", "output": "rated\r\n"}, {"input": "3\r\n1 2\r\n2 2\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "3\r\n1 2\r\n1 2\r\n1 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 1\r\n2 1\r\n", "output": "rated\r\n"}, {"input": "2\r\n1 2\r\n3 4\r\n", "output": "rated\r\n"}, {"input": "2\r\n3 2\r\n2 3\r\n", "output": "rated\r\n"}, {"input": "3\r\n1500 1500\r\n1600 1600\r\n1600 1600\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1 1\r\n3 3\r\n4 4\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1 1\r\n2 2\r\n2 2\r\n", "output": "unrated\r\n"}, {"input": "2\r\n10 12\r\n8 8\r\n", "output": "rated\r\n"}, {"input": "5\r\n1200 1200\r\n1500 1500\r\n1500 1500\r\n1500 1500\r\n1500 1500\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1 2\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "3\r\n1500 1400\r\n1200 1200\r\n1100 1100\r\n", "output": "rated\r\n"}, {"input": "2\r\n10 12\r\n10 10\r\n", "output": "rated\r\n"}, {"input": "3\r\n1500 1500\r\n1400 1400\r\n1300 1300\r\n", "output": "maybe\r\n"}, {"input": "3\r\n3 3\r\n4 4\r\n5 5\r\n", "output": "unrated\r\n"}, {"input": "3\r\n2 6\r\n3 5\r\n4 4\r\n", "output": "rated\r\n"}, {"input": "2\r\n5 6\r\n4 6\r\n", "output": "rated\r\n"}, {"input": "4\r\n10 10\r\n10 10\r\n7 7\r\n8 8\r\n", "output": "unrated\r\n"}, {"input": "2\r\n4 4\r\n3 3\r\n", "output": "maybe\r\n"}]
| false |
stdio
| null | true |
792/C
|
792
|
C
|
Python 3
|
TESTS
| 32 | 202 | 1,740,800 |
89772717
|
# i dont understand this either
def countremove(n, mod):
res = 0
for i in range(len(n)):
if mod[len(n)-1-i] == 3:
continue
if n[i] == '0':
res += 1
else:
break
return res
n = input()
mod = [int(x)%3 for x in n][::-1]
excess = sum(mod) % 3
ones = mod.count(1)
twos = mod.count(2)
if excess == 1:
remove1, remove2 = 104206969, 104206969
if ones > 0:
mod[mod.index(1)] = 3
remove1 = countremove(n, mod) + 1
mod[mod.index(3)] = 1
if twos > 1:
mod[mod.index(2)] = 3
mod[mod.index(2)] = 3
remove2 = countremove(n, mod) + 2
mod[mod.index(3)] = 2
mod[mod.index(3)] = 2
if remove1 < remove2:
mod[mod.index(1)] = 3
else:
mod[mod.index(2)] = 3
mod[mod.index(2)] = 3
elif excess == 2:
remove1, remove2 = 104206969, 104206969
if twos > 0:
mod[mod.index(2)] = 3
remove1 = countremove(n, mod) + 1
mod[mod.index(3)] = 2
if ones > 1:
mod[mod.index(1)] = 3
mod[mod.index(1)] = 3
remove2 = countremove(n, mod) + 2
mod[mod.index(3)] = 1
mod[mod.index(3)] = 1
if remove1 < remove2:
mod[mod.index(2)] = 3
else:
mod[mod.index(1)] = 3
mod[mod.index(1)] = 3
excess = sum(mod) % 3
ans = ''
for i in range(len(n)-1, -1, -1):
if mod[i] != 3: ans += n[len(n)-1-i]
remove0s = 0
for i in range(len(ans)):
if ans[i] != '0':
remove0s = i
break
if remove0s > 0:
ans = ans[remove0s:]
if excess != 0 or ans == '':
ans = '-1'
print(ans)
| 162 | 124 | 6,860,800 |
105961030
|
import sys
n = list(input(""))
l = [int(c)%3 for c in n][::-1]
d = sum(l)%3
if (len(n) == 1):
if (n == ['3']):
print(3)
else:
print(-1)
sys.exit(0)
def li(x):
global n
del n[len(n)-1-l.index(x)]
del l[l.index(x)]
def cond(x):
x = x.lstrip('0')
if (len(x) == 0): return "0"
return x
if (d == 0):
pass
elif (d in l):
if (l.index(d) == len(l)-1 and int(n[1])==0 and l.count(3-d) >= 2):
li(3-d); li(3-d)
else:
li(d)
else:
li(3-d); li(3-d)
if (len(n) > 0):
q=cond("".join(n))
print(q)
else:
print(-1)
|
Educational Codeforces Round 18
|
ICPC
| 2,017 | 1 | 256 |
Divide by Three
|
A positive integer number n is written on a blackboard. It consists of not more than 105 digits. You have to transform it into a beautiful number by erasing some of the digits, and you want to erase as few digits as possible.
The number is called beautiful if it consists of at least one digit, doesn't have leading zeroes and is a multiple of 3. For example, 0, 99, 10110 are beautiful numbers, and 00, 03, 122 are not.
Write a program which for the given n will find a beautiful number such that n can be transformed into this number by erasing as few digits as possible. You can erase an arbitraty set of digits. For example, they don't have to go one after another in the number n.
If it's impossible to obtain a beautiful number, print -1. If there are multiple answers, print any of them.
|
The first line of input contains n — a positive integer number without leading zeroes (1 ≤ n < 10100000).
|
Print one number — any beautiful number obtained by erasing as few as possible digits. If there is no answer, print - 1.
| null |
In the first example it is enough to erase only the first digit to obtain a multiple of 3. But if we erase the first digit, then we obtain a number with a leading zero. So the minimum number of digits to be erased is two.
|
[{"input": "1033", "output": "33"}, {"input": "10", "output": "0"}, {"input": "11", "output": "-1"}]
| 2,000 |
["dp", "greedy", "math", "number theory"]
| 162 |
[{"input": "1033\r\n", "output": "33\r\n"}, {"input": "10\r\n", "output": "0\r\n"}, {"input": "11\r\n", "output": "-1\r\n"}, {"input": "3\r\n", "output": "3\r\n"}, {"input": "1\r\n", "output": "-1\r\n"}, {"input": "117\r\n", "output": "117\r\n"}, {"input": "518\r\n", "output": "18\r\n"}, {"input": "327\r\n", "output": "327\r\n"}, {"input": "270461\r\n", "output": "70461\r\n"}, {"input": "609209\r\n", "output": "60909\r\n"}, {"input": "110930\r\n", "output": "930\r\n"}, {"input": "37616145150713688775\r\n", "output": "3616145150713688775\r\n"}, {"input": "98509135612114839419\r\n", "output": "9509135612114839419\r\n"}, {"input": "41674994051436988162\r\n", "output": "1674994051436988162\r\n"}, {"input": "82547062721736129804\r\n", "output": "82547062721736129804\r\n"}, {"input": "4902501252475186372406731932548506197390793597574544727433297197476846519276598727359617092494798814\r\n", "output": "490501252475186372406731932548506197390793597574544727433297197476846519276598727359617092494798814\r\n"}, {"input": "1291007209605301446874998623691572528836214969878676835460982410817526074579818247646933326771899122\r\n", "output": "1291007209605301446874998623691572528836214969878676835460982410817526074579818247646933326771899122\r\n"}, {"input": "5388306043547446322173224045662327678394712363272776811399689704247387317165308057863239568137902157\r\n", "output": "538830603547446322173224045662327678394712363272776811399689704247387317165308057863239568137902157\r\n"}, {"input": "20000111\r\n", "output": "200001\r\n"}, {"input": "100222\r\n", "output": "1002\r\n"}, {"input": "202\r\n", "output": "0\r\n"}, {"input": "100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000033\r\n", "output": "33\r\n"}, {"input": "101\r\n", "output": "0\r\n"}, {"input": "1000000222\r\n", "output": "10000002\r\n"}, {"input": "1001\r\n", "output": "0\r\n"}, {"input": "205\r\n", "output": "0\r\n"}, {"input": "102211\r\n", "output": "10221\r\n"}, {"input": "100000002022\r\n", "output": "1000000002\r\n"}, {"input": "20203\r\n", "output": "3\r\n"}, {"input": "1002001\r\n", "output": "100200\r\n"}, {"input": "10002223\r\n", "output": "100023\r\n"}, {"input": "1002223\r\n", "output": "10023\r\n"}, {"input": "100000231\r\n", "output": "10000023\r\n"}, {"input": "220\r\n", "output": "0\r\n"}, {"input": "322\r\n", "output": "3\r\n"}, {"input": "100000222\r\n", "output": "1000002\r\n"}, {"input": "10033\r\n", "output": "33\r\n"}, {"input": "2003302\r\n", "output": "330\r\n"}, {"input": "10011001\r\n", "output": "1001001\r\n"}, {"input": "20000000011001111\r\n", "output": "200000000001111\r\n"}, {"input": "100000000\r\n", "output": "0\r\n"}, {"input": "1000\r\n", "output": "0\r\n"}, {"input": "200000000000000000000000000008\r\n", "output": "0\r\n"}, {"input": "1000000000000222\r\n", "output": "10000000000002\r\n"}, {"input": "100000000000000000222\r\n", "output": "1000000000000000002\r\n"}, {"input": "29512\r\n", "output": "2952\r\n"}, {"input": "88888888888888\r\n", "output": "888888888888\r\n"}, {"input": "100000000000222\r\n", "output": "1000000000002\r\n"}, {"input": "11000000\r\n", "output": "0\r\n"}, {"input": "2200\r\n", "output": "0\r\n"}, {"input": "10000555\r\n", "output": "100005\r\n"}, {"input": "1000222\r\n", "output": "10002\r\n"}, {"input": "10021\r\n", "output": "1002\r\n"}, {"input": "223\r\n", "output": "3\r\n"}, {"input": "1013\r\n", "output": "3\r\n"}, {"input": "100020001\r\n", "output": "10002000\r\n"}, {"input": "20000000000000000000932\r\n", "output": "93\r\n"}, {"input": "1010\r\n", "output": "0\r\n"}, {"input": "2000000002222\r\n", "output": "20000000022\r\n"}, {"input": "10213\r\n", "output": "1023\r\n"}, {"input": "109111\r\n", "output": "10911\r\n"}, {"input": "1010101010\r\n", "output": "10001010\r\n"}, {"input": "300055\r\n", "output": "3000\r\n"}, {"input": "200200\r\n", "output": "0\r\n"}, {"input": "202222\r\n", "output": "2022\r\n"}, {"input": "4000888\r\n", "output": "40008\r\n"}, {"input": "200000111\r\n", "output": "2000001\r\n"}, {"input": "2000000111\r\n", "output": "20000001\r\n"}, {"input": "1000000\r\n", "output": "0\r\n"}, {"input": "1003301\r\n", "output": "330\r\n"}, {"input": "100001\r\n", "output": "0\r\n"}, {"input": "40000000000000000000888\r\n", "output": "400000000000000000008\r\n"}, {"input": "100000\r\n", "output": "0\r\n"}, {"input": "4000000888\r\n", "output": "40000008\r\n"}, {"input": "334733\r\n", "output": "3333\r\n"}, {"input": "1000002220\r\n", "output": "10000020\r\n"}, {"input": "100321\r\n", "output": "10032\r\n"}, {"input": "101111\r\n", "output": "1011\r\n"}, {"input": "100000000222\r\n", "output": "1000000002\r\n"}, {"input": "10001\r\n", "output": "0\r\n"}, {"input": "7\r\n", "output": "-1\r\n"}, {"input": "2000000000111\r\n", "output": "20000000001\r\n"}, {"input": "100000001\r\n", "output": "0\r\n"}, {"input": "10000000000222\r\n", "output": "100000000002\r\n"}, {"input": "200000000000000111\r\n", "output": "2000000000000001\r\n"}, {"input": "404044\r\n", "output": "40044\r\n"}, {"input": "30202\r\n", "output": "300\r\n"}, {"input": "20000000000000000111\r\n", "output": "200000000000000001\r\n"}, {"input": "707\r\n", "output": "0\r\n"}, {"input": "20000300000000003000050000003\r\n", "output": "30000000000300000000003\r\n"}, {"input": "400000888\r\n", "output": "4000008\r\n"}, {"input": "2888\r\n", "output": "888\r\n"}, {"input": "200111\r\n", "output": "2001\r\n"}, {"input": "10000000888\r\n", "output": "100000008\r\n"}, {"input": "40000888\r\n", "output": "400008\r\n"}, {"input": "40404044\r\n", "output": "400044\r\n"}, {"input": "5500000000\r\n", "output": "0\r\n"}, {"input": "100012\r\n", "output": "10002\r\n"}, {"input": "1000007\r\n", "output": "0\r\n"}, {"input": "200093\r\n", "output": "93\r\n"}, {"input": "10000000222\r\n", "output": "100000002\r\n"}, {"input": "20000000002\r\n", "output": "0\r\n"}, {"input": "74333\r\n", "output": "333\r\n"}, {"input": "200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\r\n", "output": "0\r\n"}, {"input": "10000000111\r\n", "output": "1000000011\r\n"}, {"input": "100007\r\n", "output": "0\r\n"}, {"input": "20000006711\r\n", "output": "200000061\r\n"}, {"input": "8059\r\n", "output": "9\r\n"}, {"input": "8008\r\n", "output": "0\r\n"}, {"input": "88\r\n", "output": "-1\r\n"}, {"input": "2002\r\n", "output": "0\r\n"}, {"input": "2000111\r\n", "output": "20001\r\n"}, {"input": "100000000100000002\r\n", "output": "10000000000000002\r\n"}, {"input": "1000000000000000000000000000000000\r\n", "output": "0\r\n"}, {"input": "10000000000000000222\r\n", "output": "100000000000000002\r\n"}, {"input": "1000001\r\n", "output": "0\r\n"}, {"input": "200000000000111\r\n", "output": "2000000000001\r\n"}, {"input": "2000000002\r\n", "output": "0\r\n"}, {"input": "2010000100001\r\n", "output": "10000100001\r\n"}, {"input": "200330\r\n", "output": "330\r\n"}, {"input": "10000222\r\n", "output": "100002\r\n"}, {"input": "2005\r\n", "output": "0\r\n"}, {"input": "100000000000822\r\n", "output": "1000000000002\r\n"}, {"input": "10000000000000000000000\r\n", "output": "0\r\n"}, {"input": "7046\r\n", "output": "6\r\n"}, {"input": "4000117\r\n", "output": "400017\r\n"}, {"input": "971\r\n", "output": "9\r\n"}, {"input": "404\r\n", "output": "0\r\n"}, {"input": "5\r\n", "output": "-1\r\n"}, {"input": "164\r\n", "output": "6\r\n"}, {"input": "140\r\n", "output": "0\r\n"}, {"input": "74\r\n", "output": "-1\r\n"}, {"input": "2058232\r\n", "output": "20232\r\n"}, {"input": "4\r\n", "output": "-1\r\n"}, {"input": "20206\r\n", "output": "6\r\n"}, {"input": "103310\r\n", "output": "330\r\n"}, {"input": "100\r\n", "output": "0\r\n"}, {"input": "417179\r\n", "output": "7179\r\n"}, {"input": "70558\r\n", "output": "558\r\n"}, {"input": "298\r\n", "output": "9\r\n"}, {"input": "7003\r\n", "output": "3\r\n"}, {"input": "2212\r\n", "output": "222\r\n"}, {"input": "1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001\r\n", "output": "0\r\n"}, {"input": "2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002\r\n", "output": "0\r\n"}, {"input": "1002200\r\n", "output": "100200\r\n"}, {"input": "1222\r\n", "output": "222\r\n"}, {"input": "101200100\r\n", "output": "10100100\r\n"}, {"input": "1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003\r\n", "output": "3\r\n"}, {"input": "20020201\r\n", "output": "2002020\r\n"}, {"input": "12122\r\n", "output": "1122\r\n"}, {"input": "20200\r\n", "output": "0\r\n"}, {"input": "2\r\n", "output": "-1\r\n"}, {"input": "1000000000000258\r\n", "output": "10000000000008\r\n"}]
| false |
stdio
|
import sys
def is_subsequence(s, t):
t_iter = iter(t)
try:
for c in s:
while next(t_iter) != c:
pass
return True
except StopIteration:
return False
def is_beautiful(s):
if not s:
return False
if s[0] == '0' and len(s) > 1:
return False
total = sum(int(c) for c in s)
return total % 3 == 0
def compute_max_length(n):
sum_digits = sum(int(c) for c in n)
sum_mod3 = sum_digits % 3
has_zero = '0' in n
if sum_mod3 == 0:
if n[0] != '0':
return len(n)
first_non_zero = next((i for i, c in enumerate(n) if c != '0'), None)
if first_non_zero is None:
return 1
return len(n) - first_non_zero
else:
candidates = []
for i, c in enumerate(n):
if int(c) % 3 == sum_mod3:
new_n = n[:i] + n[i+1:]
if not new_n:
continue
first_non_zero = next((j for j, ch in enumerate(new_n) if ch != '0'), None)
if first_non_zero is None:
candidates.append(1)
else:
candidates.append(len(new_n) - first_non_zero)
target_mod = (3 - sum_mod3) % 3
mod_digits = [i for i, c in enumerate(n) if int(c) % 3 == target_mod]
if len(mod_digits) >= 2:
i, j = mod_digits[-2], mod_digits[-1]
new_n = n[:i] + n[i+1:j] + n[j+1:]
if new_n:
first_non_zero = next((k for k, ch in enumerate(new_n) if ch != '0'), None)
if first_non_zero is None:
candidates.append(1)
else:
candidates.append(len(new_n) - first_non_zero)
if has_zero:
candidates.append(1)
return max(candidates) if candidates else 0
def main(input_path, output_path, submission_path):
with open(input_path, 'r') as f:
n = f.read().strip()
with open(submission_path, 'r') as f:
submission = f.read().strip()
if submission == '-1':
max_len = compute_max_length(n)
print(100 if max_len == 0 else 0)
else:
if not is_subsequence(submission, n) or not is_beautiful(submission):
print(0)
return
max_len = compute_max_length(n)
print(100 if len(submission) == max_len else 0)
if __name__ == '__main__':
input_path, output_path, submission_path = sys.argv[1], sys.argv[2], sys.argv[3]
main(input_path, output_path, submission_path)
| true |
99/B
|
99
|
B
|
PyPy 3
|
TESTS
| 8 | 77 | 307,200 |
149628016
|
from collections import defaultdict
import sys, os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
n = int(input())
x = [int(input()) for _ in range(n)]
cnt = defaultdict(lambda : 0)
for i in x:
cnt[i] += 1
c = list(cnt.keys())
c.sort()
if len(c) == 1:
ans = "Exemplary pages."
elif len(c) == 3 and cnt[c[0]] == cnt[c[2]] == 1 and c[0] + c[2] == 2 * c[1]:
ans = str(c[1] - c[0]) + " ml. from cup #" + str(x.index(c[0]) + 1) + " to cup #" + str(x.index(c[2]) + 1) + "."
else:
ans = "Unrecoverable configuration."
print(ans)
| 200 | 77 | 307,200 |
106310001
|
n=int(input())
ar=[int(input()) for i in range(n)]
if(len(set(ar))==1):
print("Exemplary pages.")
quit()
mn=min(ar)
mx=max(ar)
mni=ar.index(mn)
mxi=ar.index(mx)
vl=(mx-mn)//2
ar[mni]+=vl
ar[mxi]-=vl
if(len(set(ar))==1):
print(str(vl)+" ml. from cup #"+str(mni+1)+" to cup #"+str(mxi+1)+".")
quit()
else:
print("Unrecoverable configuration.")
quit()
|
Codeforces Beta Round 78 (Div. 2 Only)
|
CF
| 2,011 | 0.5 | 256 |
Help Chef Gerasim
|
In a far away kingdom young pages help to set the table for the King. As they are terribly mischievous, one needs to keep an eye on the control whether they have set everything correctly. This time the royal chef Gerasim had the impression that the pages have played a prank again: they had poured the juice from one cup to another. Now Gerasim wants to check his hypothesis. The good thing is that chef Gerasim always pour the same number of milliliters of juice to all cups in the royal kitchen. Having thoroughly measured the juice in each cup, Gerasim asked you to write a program that will determine from which cup juice was poured to which one; otherwise, the program should determine that this time the pages set the table diligently.
To simplify your task we shall consider the cups to be bottomless so that the juice never overfills a cup and pours out, however much it can be. Besides, by some strange reason in a far away kingdom one can only pour to a cup or from one cup to another an integer number of milliliters of juice.
|
The first line contains integer n — the number of cups on the royal table (1 ≤ n ≤ 1000). Next n lines contain volumes of juice in each cup — non-negative integers, not exceeding 104.
|
If the pages didn't pour the juice, print "Exemplary pages." (without the quotes). If you can determine the volume of juice poured during exactly one juice pouring, print "v ml. from cup #a to cup #b." (without the quotes), where v represents the volume of poured juice, a represents the number of the cup from which the juice was poured (the cups are numbered with consecutive positive integers starting from one in the order in which the cups are described in the input data), b represents the number of the cup into which the juice was poured. Finally, if the given juice's volumes cannot be obtained using no more than one pouring (for example, the pages poured the juice from one cup to another more than once or the royal kitchen maids poured the juice into the cups incorrectly), print "Unrecoverable configuration." (without the quotes).
| null | null |
[{"input": "5\n270\n250\n250\n230\n250", "output": "20 ml. from cup #4 to cup #1."}, {"input": "5\n250\n250\n250\n250\n250", "output": "Exemplary pages."}, {"input": "5\n270\n250\n249\n230\n250", "output": "Unrecoverable configuration."}]
| 1,300 |
["implementation", "sortings"]
| 200 |
[{"input": "5\r\n270\r\n250\r\n250\r\n230\r\n250\r\n", "output": "20 ml. from cup #4 to cup #1.\r\n"}, {"input": "5\r\n250\r\n250\r\n250\r\n250\r\n250\r\n", "output": "Exemplary pages.\r\n"}, {"input": "5\r\n270\r\n250\r\n249\r\n230\r\n250\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n200\r\n190\r\n210\r\n200\r\n", "output": "10 ml. from cup #2 to cup #3.\r\n"}, {"input": "4\r\n1\r\n2\r\n3\r\n4\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "1\r\n0\r\n", "output": "Exemplary pages.\r\n"}, {"input": "2\r\n0\r\n0\r\n", "output": "Exemplary pages.\r\n"}, {"input": "2\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "2\r\n0\r\n2\r\n", "output": "1 ml. from cup #1 to cup #2.\r\n"}, {"input": "2\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "2\r\n1\r\n1\r\n", "output": "Exemplary pages.\r\n"}, {"input": "2\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "2\r\n2\r\n0\r\n", "output": "1 ml. from cup #2 to cup #1.\r\n"}, {"input": "2\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "2\r\n2\r\n2\r\n", "output": "Exemplary pages.\r\n"}, {"input": "3\r\n0\r\n0\r\n0\r\n", "output": "Exemplary pages.\r\n"}, {"input": "3\r\n0\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n0\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n0\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n0\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n0\r\n1\r\n2\r\n", "output": "1 ml. from cup #1 to cup #3.\r\n"}, {"input": "3\r\n0\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n0\r\n2\r\n1\r\n", "output": "1 ml. from cup #1 to cup #2.\r\n"}, {"input": "3\r\n0\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n0\r\n2\r\n", "output": "1 ml. from cup #2 to cup #3.\r\n"}, {"input": "3\r\n1\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n1\r\n1\r\n", "output": "Exemplary pages.\r\n"}, {"input": "3\r\n1\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n2\r\n0\r\n", "output": "1 ml. from cup #3 to cup #2.\r\n"}, {"input": "3\r\n1\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n0\r\n1\r\n", "output": "1 ml. from cup #2 to cup #1.\r\n"}, {"input": "3\r\n2\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n1\r\n0\r\n", "output": "1 ml. from cup #3 to cup #1.\r\n"}, {"input": "3\r\n2\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n2\r\n2\r\n", "output": "Exemplary pages.\r\n"}, {"input": "4\r\n0\r\n0\r\n0\r\n0\r\n", "output": "Exemplary pages.\r\n"}, {"input": "4\r\n0\r\n0\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n1\r\n2\r\n", "output": "1 ml. from cup #1 to cup #4.\r\n"}, {"input": "4\r\n0\r\n1\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n2\r\n1\r\n", "output": "1 ml. from cup #1 to cup #3.\r\n"}, {"input": "4\r\n0\r\n1\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n1\r\n1\r\n", "output": "1 ml. from cup #1 to cup #2.\r\n"}, {"input": "4\r\n0\r\n2\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n1\r\n2\r\n", "output": "1 ml. from cup #2 to cup #4.\r\n"}, {"input": "4\r\n1\r\n0\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n2\r\n1\r\n", "output": "1 ml. from cup #2 to cup #3.\r\n"}, {"input": "4\r\n1\r\n0\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n0\r\n2\r\n", "output": "1 ml. from cup #3 to cup #4.\r\n"}, {"input": "4\r\n1\r\n1\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n1\r\n1\r\n", "output": "Exemplary pages.\r\n"}, {"input": "4\r\n1\r\n1\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n2\r\n0\r\n", "output": "1 ml. from cup #4 to cup #3.\r\n"}, {"input": "4\r\n1\r\n1\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n0\r\n1\r\n", "output": "1 ml. from cup #3 to cup #2.\r\n"}, {"input": "4\r\n1\r\n2\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n1\r\n0\r\n", "output": "1 ml. from cup #4 to cup #2.\r\n"}, {"input": "4\r\n1\r\n2\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n1\r\n1\r\n", "output": "1 ml. from cup #2 to cup #1.\r\n"}, {"input": "4\r\n2\r\n0\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n0\r\n1\r\n", "output": "1 ml. from cup #3 to cup #1.\r\n"}, {"input": "4\r\n2\r\n1\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n1\r\n0\r\n", "output": "1 ml. from cup #4 to cup #1.\r\n"}, {"input": "4\r\n2\r\n1\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n2\r\n2\r\n", "output": "Exemplary pages.\r\n"}, {"input": "27\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n2626\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n8572\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n", "output": "2973 ml. from cup #11 to cup #17.\r\n"}, {"input": "19\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n82\r\n5001\r\n9919\r\n5001\r\n5001\r\n", "output": "Unrecoverable configuration.\r\n"}]
| false |
stdio
| null | true |
99/B
|
99
|
B
|
Python 3
|
TESTS
| 8 | 46 | 0 |
146841297
|
l=[]
n=int(input())
for z in range(n):
l.append(int(input()))
ma,mi=max(l),min(l)
um=-1
for i in range(min(n,3)):
if l.count(l[i])==n-2 and l[i] not in (ma,mi):
um=l[i]
break
if l.count(l[0])==n:
print("Exemplary pages.")
elif um>-1 and (ma-mi)%2==0:
print((ma-mi)//2,"ml. from cup #"+str(l.index(mi)+1)+" to cup #"+str(l.index(ma)+1)+".")
else:
print("Unrecoverable configuration.")
| 200 | 92 | 6,963,200 |
128839381
|
def help_chef():
count = int(input())
volumes = []
total = 0
for _ in range(count):
volume = int(input())
volumes.append(volume)
total += volume
if total % count != 0:
print("Unrecoverable configuration.")
elif len(set(volumes)) == 1:
print("Exemplary pages.")
else:
diffs = []
vol = None
source = target = None
average = total//count
for volume in volumes:
diff = volume - average
diffs.append(diff)
for index, diff in enumerate(diffs):
if diff > 0:
if target is None:
target = index+1
vol = diff
else:
print("Unrecoverable configuration.")
break
elif diff < 0:
if source is None:
source = index+1
else:
print("Unrecoverable configuration.")
break
else:
print("{} ml. from cup #{} to cup #{}.".format(vol, source, target))
help_chef()
|
Codeforces Beta Round 78 (Div. 2 Only)
|
CF
| 2,011 | 0.5 | 256 |
Help Chef Gerasim
|
In a far away kingdom young pages help to set the table for the King. As they are terribly mischievous, one needs to keep an eye on the control whether they have set everything correctly. This time the royal chef Gerasim had the impression that the pages have played a prank again: they had poured the juice from one cup to another. Now Gerasim wants to check his hypothesis. The good thing is that chef Gerasim always pour the same number of milliliters of juice to all cups in the royal kitchen. Having thoroughly measured the juice in each cup, Gerasim asked you to write a program that will determine from which cup juice was poured to which one; otherwise, the program should determine that this time the pages set the table diligently.
To simplify your task we shall consider the cups to be bottomless so that the juice never overfills a cup and pours out, however much it can be. Besides, by some strange reason in a far away kingdom one can only pour to a cup or from one cup to another an integer number of milliliters of juice.
|
The first line contains integer n — the number of cups on the royal table (1 ≤ n ≤ 1000). Next n lines contain volumes of juice in each cup — non-negative integers, not exceeding 104.
|
If the pages didn't pour the juice, print "Exemplary pages." (without the quotes). If you can determine the volume of juice poured during exactly one juice pouring, print "v ml. from cup #a to cup #b." (without the quotes), where v represents the volume of poured juice, a represents the number of the cup from which the juice was poured (the cups are numbered with consecutive positive integers starting from one in the order in which the cups are described in the input data), b represents the number of the cup into which the juice was poured. Finally, if the given juice's volumes cannot be obtained using no more than one pouring (for example, the pages poured the juice from one cup to another more than once or the royal kitchen maids poured the juice into the cups incorrectly), print "Unrecoverable configuration." (without the quotes).
| null | null |
[{"input": "5\n270\n250\n250\n230\n250", "output": "20 ml. from cup #4 to cup #1."}, {"input": "5\n250\n250\n250\n250\n250", "output": "Exemplary pages."}, {"input": "5\n270\n250\n249\n230\n250", "output": "Unrecoverable configuration."}]
| 1,300 |
["implementation", "sortings"]
| 200 |
[{"input": "5\r\n270\r\n250\r\n250\r\n230\r\n250\r\n", "output": "20 ml. from cup #4 to cup #1.\r\n"}, {"input": "5\r\n250\r\n250\r\n250\r\n250\r\n250\r\n", "output": "Exemplary pages.\r\n"}, {"input": "5\r\n270\r\n250\r\n249\r\n230\r\n250\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n200\r\n190\r\n210\r\n200\r\n", "output": "10 ml. from cup #2 to cup #3.\r\n"}, {"input": "4\r\n1\r\n2\r\n3\r\n4\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "1\r\n0\r\n", "output": "Exemplary pages.\r\n"}, {"input": "2\r\n0\r\n0\r\n", "output": "Exemplary pages.\r\n"}, {"input": "2\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "2\r\n0\r\n2\r\n", "output": "1 ml. from cup #1 to cup #2.\r\n"}, {"input": "2\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "2\r\n1\r\n1\r\n", "output": "Exemplary pages.\r\n"}, {"input": "2\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "2\r\n2\r\n0\r\n", "output": "1 ml. from cup #2 to cup #1.\r\n"}, {"input": "2\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "2\r\n2\r\n2\r\n", "output": "Exemplary pages.\r\n"}, {"input": "3\r\n0\r\n0\r\n0\r\n", "output": "Exemplary pages.\r\n"}, {"input": "3\r\n0\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n0\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n0\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n0\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n0\r\n1\r\n2\r\n", "output": "1 ml. from cup #1 to cup #3.\r\n"}, {"input": "3\r\n0\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n0\r\n2\r\n1\r\n", "output": "1 ml. from cup #1 to cup #2.\r\n"}, {"input": "3\r\n0\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n0\r\n2\r\n", "output": "1 ml. from cup #2 to cup #3.\r\n"}, {"input": "3\r\n1\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n1\r\n1\r\n", "output": "Exemplary pages.\r\n"}, {"input": "3\r\n1\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n2\r\n0\r\n", "output": "1 ml. from cup #3 to cup #2.\r\n"}, {"input": "3\r\n1\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n0\r\n1\r\n", "output": "1 ml. from cup #2 to cup #1.\r\n"}, {"input": "3\r\n2\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n1\r\n0\r\n", "output": "1 ml. from cup #3 to cup #1.\r\n"}, {"input": "3\r\n2\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n2\r\n2\r\n", "output": "Exemplary pages.\r\n"}, {"input": "4\r\n0\r\n0\r\n0\r\n0\r\n", "output": "Exemplary pages.\r\n"}, {"input": "4\r\n0\r\n0\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n1\r\n2\r\n", "output": "1 ml. from cup #1 to cup #4.\r\n"}, {"input": "4\r\n0\r\n1\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n2\r\n1\r\n", "output": "1 ml. from cup #1 to cup #3.\r\n"}, {"input": "4\r\n0\r\n1\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n1\r\n1\r\n", "output": "1 ml. from cup #1 to cup #2.\r\n"}, {"input": "4\r\n0\r\n2\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n1\r\n2\r\n", "output": "1 ml. from cup #2 to cup #4.\r\n"}, {"input": "4\r\n1\r\n0\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n2\r\n1\r\n", "output": "1 ml. from cup #2 to cup #3.\r\n"}, {"input": "4\r\n1\r\n0\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n0\r\n2\r\n", "output": "1 ml. from cup #3 to cup #4.\r\n"}, {"input": "4\r\n1\r\n1\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n1\r\n1\r\n", "output": "Exemplary pages.\r\n"}, {"input": "4\r\n1\r\n1\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n2\r\n0\r\n", "output": "1 ml. from cup #4 to cup #3.\r\n"}, {"input": "4\r\n1\r\n1\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n0\r\n1\r\n", "output": "1 ml. from cup #3 to cup #2.\r\n"}, {"input": "4\r\n1\r\n2\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n1\r\n0\r\n", "output": "1 ml. from cup #4 to cup #2.\r\n"}, {"input": "4\r\n1\r\n2\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n1\r\n1\r\n", "output": "1 ml. from cup #2 to cup #1.\r\n"}, {"input": "4\r\n2\r\n0\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n0\r\n1\r\n", "output": "1 ml. from cup #3 to cup #1.\r\n"}, {"input": "4\r\n2\r\n1\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n1\r\n0\r\n", "output": "1 ml. from cup #4 to cup #1.\r\n"}, {"input": "4\r\n2\r\n1\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n2\r\n2\r\n", "output": "Exemplary pages.\r\n"}, {"input": "27\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n2626\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n8572\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n", "output": "2973 ml. from cup #11 to cup #17.\r\n"}, {"input": "19\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n82\r\n5001\r\n9919\r\n5001\r\n5001\r\n", "output": "Unrecoverable configuration.\r\n"}]
| false |
stdio
| null | true |
99/B
|
99
|
B
|
Python 3
|
TESTS
| 8 | 46 | 0 |
151407236
|
n=int(input())
s=[]
for i in range(n):
s.append(int(input()))
x=list(set(s))
if len(x)==1:
print("Exemplary pages.")
elif len(x)==3:
x.sort()
if s.count(x[0])==1 and s.count(x[2])==1 and (x[0]+x[2])/2==sum(s)/len(s):
print(f"{x[1]-x[0]} ml. from cup #{s.index(min(x))+1} to cup #{s.index(max(x))+1}.")
else:
print("Unrecoverable configuration.")
else:
print("Unrecoverable configuration.")
| 200 | 109 | 307,200 |
93070393
|
n=int(input())
l=[]
for i in range(n):
l.append(int(input()))
a=set(l)
if(len(a)==1):
print("Exemplary pages.")
else:
m=min(l)
n=max(l)
r=(n-m)//2
q=l.index(n)
w=l.index(m)
l[q]-=r
l[w]+=r
b=set(l)
if(len(b)==1):
print(str(r)+" ml. from cup #"+str(w+1)+" to cup #"+str(q+1)+".")
else:
print("Unrecoverable configuration.")
|
Codeforces Beta Round 78 (Div. 2 Only)
|
CF
| 2,011 | 0.5 | 256 |
Help Chef Gerasim
|
In a far away kingdom young pages help to set the table for the King. As they are terribly mischievous, one needs to keep an eye on the control whether they have set everything correctly. This time the royal chef Gerasim had the impression that the pages have played a prank again: they had poured the juice from one cup to another. Now Gerasim wants to check his hypothesis. The good thing is that chef Gerasim always pour the same number of milliliters of juice to all cups in the royal kitchen. Having thoroughly measured the juice in each cup, Gerasim asked you to write a program that will determine from which cup juice was poured to which one; otherwise, the program should determine that this time the pages set the table diligently.
To simplify your task we shall consider the cups to be bottomless so that the juice never overfills a cup and pours out, however much it can be. Besides, by some strange reason in a far away kingdom one can only pour to a cup or from one cup to another an integer number of milliliters of juice.
|
The first line contains integer n — the number of cups on the royal table (1 ≤ n ≤ 1000). Next n lines contain volumes of juice in each cup — non-negative integers, not exceeding 104.
|
If the pages didn't pour the juice, print "Exemplary pages." (without the quotes). If you can determine the volume of juice poured during exactly one juice pouring, print "v ml. from cup #a to cup #b." (without the quotes), where v represents the volume of poured juice, a represents the number of the cup from which the juice was poured (the cups are numbered with consecutive positive integers starting from one in the order in which the cups are described in the input data), b represents the number of the cup into which the juice was poured. Finally, if the given juice's volumes cannot be obtained using no more than one pouring (for example, the pages poured the juice from one cup to another more than once or the royal kitchen maids poured the juice into the cups incorrectly), print "Unrecoverable configuration." (without the quotes).
| null | null |
[{"input": "5\n270\n250\n250\n230\n250", "output": "20 ml. from cup #4 to cup #1."}, {"input": "5\n250\n250\n250\n250\n250", "output": "Exemplary pages."}, {"input": "5\n270\n250\n249\n230\n250", "output": "Unrecoverable configuration."}]
| 1,300 |
["implementation", "sortings"]
| 200 |
[{"input": "5\r\n270\r\n250\r\n250\r\n230\r\n250\r\n", "output": "20 ml. from cup #4 to cup #1.\r\n"}, {"input": "5\r\n250\r\n250\r\n250\r\n250\r\n250\r\n", "output": "Exemplary pages.\r\n"}, {"input": "5\r\n270\r\n250\r\n249\r\n230\r\n250\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n200\r\n190\r\n210\r\n200\r\n", "output": "10 ml. from cup #2 to cup #3.\r\n"}, {"input": "4\r\n1\r\n2\r\n3\r\n4\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "1\r\n0\r\n", "output": "Exemplary pages.\r\n"}, {"input": "2\r\n0\r\n0\r\n", "output": "Exemplary pages.\r\n"}, {"input": "2\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "2\r\n0\r\n2\r\n", "output": "1 ml. from cup #1 to cup #2.\r\n"}, {"input": "2\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "2\r\n1\r\n1\r\n", "output": "Exemplary pages.\r\n"}, {"input": "2\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "2\r\n2\r\n0\r\n", "output": "1 ml. from cup #2 to cup #1.\r\n"}, {"input": "2\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "2\r\n2\r\n2\r\n", "output": "Exemplary pages.\r\n"}, {"input": "3\r\n0\r\n0\r\n0\r\n", "output": "Exemplary pages.\r\n"}, {"input": "3\r\n0\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n0\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n0\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n0\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n0\r\n1\r\n2\r\n", "output": "1 ml. from cup #1 to cup #3.\r\n"}, {"input": "3\r\n0\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n0\r\n2\r\n1\r\n", "output": "1 ml. from cup #1 to cup #2.\r\n"}, {"input": "3\r\n0\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n0\r\n2\r\n", "output": "1 ml. from cup #2 to cup #3.\r\n"}, {"input": "3\r\n1\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n1\r\n1\r\n", "output": "Exemplary pages.\r\n"}, {"input": "3\r\n1\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n2\r\n0\r\n", "output": "1 ml. from cup #3 to cup #2.\r\n"}, {"input": "3\r\n1\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n0\r\n1\r\n", "output": "1 ml. from cup #2 to cup #1.\r\n"}, {"input": "3\r\n2\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n1\r\n0\r\n", "output": "1 ml. from cup #3 to cup #1.\r\n"}, {"input": "3\r\n2\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n2\r\n2\r\n", "output": "Exemplary pages.\r\n"}, {"input": "4\r\n0\r\n0\r\n0\r\n0\r\n", "output": "Exemplary pages.\r\n"}, {"input": "4\r\n0\r\n0\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n1\r\n2\r\n", "output": "1 ml. from cup #1 to cup #4.\r\n"}, {"input": "4\r\n0\r\n1\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n2\r\n1\r\n", "output": "1 ml. from cup #1 to cup #3.\r\n"}, {"input": "4\r\n0\r\n1\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n1\r\n1\r\n", "output": "1 ml. from cup #1 to cup #2.\r\n"}, {"input": "4\r\n0\r\n2\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n1\r\n2\r\n", "output": "1 ml. from cup #2 to cup #4.\r\n"}, {"input": "4\r\n1\r\n0\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n2\r\n1\r\n", "output": "1 ml. from cup #2 to cup #3.\r\n"}, {"input": "4\r\n1\r\n0\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n0\r\n2\r\n", "output": "1 ml. from cup #3 to cup #4.\r\n"}, {"input": "4\r\n1\r\n1\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n1\r\n1\r\n", "output": "Exemplary pages.\r\n"}, {"input": "4\r\n1\r\n1\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n2\r\n0\r\n", "output": "1 ml. from cup #4 to cup #3.\r\n"}, {"input": "4\r\n1\r\n1\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n0\r\n1\r\n", "output": "1 ml. from cup #3 to cup #2.\r\n"}, {"input": "4\r\n1\r\n2\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n1\r\n0\r\n", "output": "1 ml. from cup #4 to cup #2.\r\n"}, {"input": "4\r\n1\r\n2\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n1\r\n1\r\n", "output": "1 ml. from cup #2 to cup #1.\r\n"}, {"input": "4\r\n2\r\n0\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n0\r\n1\r\n", "output": "1 ml. from cup #3 to cup #1.\r\n"}, {"input": "4\r\n2\r\n1\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n1\r\n0\r\n", "output": "1 ml. from cup #4 to cup #1.\r\n"}, {"input": "4\r\n2\r\n1\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n2\r\n2\r\n", "output": "Exemplary pages.\r\n"}, {"input": "27\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n2626\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n8572\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n", "output": "2973 ml. from cup #11 to cup #17.\r\n"}, {"input": "19\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n82\r\n5001\r\n9919\r\n5001\r\n5001\r\n", "output": "Unrecoverable configuration.\r\n"}]
| false |
stdio
| null | true |
99/B
|
99
|
B
|
Python 3
|
TESTS
| 8 | 31 | 0 |
151408789
|
n = int(input())
list = [0 for j in range(n)]
list2 = [0 for J in range(n)]
list3 = [0 for K in range(4)]
for i in range(n):
list[i] = int(input())
list1 = sorted(list)
result = 0
x = S = 0
num = int(list1[n // 2])
for j in range(n):
if int(list[j]) != num:
result += 1
list2[j] = num - int(list[j])
if result == 0:
print("Exemplary pages.")
elif result == 2:
for m in range(n):
if int(list2[m]) != 0:
S += 1
list3[S*2-2]=int(list2[m])
list3[S*2-1]=m+1
if int(list3[0])+int(list3[2])==0:
if int(list3[0])>0:
print("{} ml. from cup #{} to cup #{}.".format(int(list3[0]),int(list3[1]),int(list3[3])))
else:
print("{} ml. from cup #{} to cup #{}.".format(int(list3[2]), int(list3[3]), int(list3[1])))
else:
print("Unrecoverable configuration.")
else:
print("Unrecoverable configuration.")
| 200 | 109 | 1,433,600 |
106359561
|
n=int(input())
s=[]
for i in range(n):
s.append(int(input()))
x=list(set(s))
x.sort()
if len(x)==1:
print('Exemplary pages.')
elif len(s)==2 and sum(x)%2==0:
print('{} ml. from cup #{} to cup #{}.'.format((x[1]-x[0])//2,s.index(x[0])+1,s.index(x[1])+1))
elif len(x)==3 and s.count(x[0])==1 and s.count(x[2])==1 and x[1]-x[0]==x[2]-x[1]:
v=x[1]-x[0]
q=s.index(x[0])+1
k=s.index(x[2])+1
print('{} ml. from cup #{} to cup #{}.'.format(v,q,k))
else:
print('Unrecoverable configuration.')
|
Codeforces Beta Round 78 (Div. 2 Only)
|
CF
| 2,011 | 0.5 | 256 |
Help Chef Gerasim
|
In a far away kingdom young pages help to set the table for the King. As they are terribly mischievous, one needs to keep an eye on the control whether they have set everything correctly. This time the royal chef Gerasim had the impression that the pages have played a prank again: they had poured the juice from one cup to another. Now Gerasim wants to check his hypothesis. The good thing is that chef Gerasim always pour the same number of milliliters of juice to all cups in the royal kitchen. Having thoroughly measured the juice in each cup, Gerasim asked you to write a program that will determine from which cup juice was poured to which one; otherwise, the program should determine that this time the pages set the table diligently.
To simplify your task we shall consider the cups to be bottomless so that the juice never overfills a cup and pours out, however much it can be. Besides, by some strange reason in a far away kingdom one can only pour to a cup or from one cup to another an integer number of milliliters of juice.
|
The first line contains integer n — the number of cups on the royal table (1 ≤ n ≤ 1000). Next n lines contain volumes of juice in each cup — non-negative integers, not exceeding 104.
|
If the pages didn't pour the juice, print "Exemplary pages." (without the quotes). If you can determine the volume of juice poured during exactly one juice pouring, print "v ml. from cup #a to cup #b." (without the quotes), where v represents the volume of poured juice, a represents the number of the cup from which the juice was poured (the cups are numbered with consecutive positive integers starting from one in the order in which the cups are described in the input data), b represents the number of the cup into which the juice was poured. Finally, if the given juice's volumes cannot be obtained using no more than one pouring (for example, the pages poured the juice from one cup to another more than once or the royal kitchen maids poured the juice into the cups incorrectly), print "Unrecoverable configuration." (without the quotes).
| null | null |
[{"input": "5\n270\n250\n250\n230\n250", "output": "20 ml. from cup #4 to cup #1."}, {"input": "5\n250\n250\n250\n250\n250", "output": "Exemplary pages."}, {"input": "5\n270\n250\n249\n230\n250", "output": "Unrecoverable configuration."}]
| 1,300 |
["implementation", "sortings"]
| 200 |
[{"input": "5\r\n270\r\n250\r\n250\r\n230\r\n250\r\n", "output": "20 ml. from cup #4 to cup #1.\r\n"}, {"input": "5\r\n250\r\n250\r\n250\r\n250\r\n250\r\n", "output": "Exemplary pages.\r\n"}, {"input": "5\r\n270\r\n250\r\n249\r\n230\r\n250\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n200\r\n190\r\n210\r\n200\r\n", "output": "10 ml. from cup #2 to cup #3.\r\n"}, {"input": "4\r\n1\r\n2\r\n3\r\n4\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "1\r\n0\r\n", "output": "Exemplary pages.\r\n"}, {"input": "2\r\n0\r\n0\r\n", "output": "Exemplary pages.\r\n"}, {"input": "2\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "2\r\n0\r\n2\r\n", "output": "1 ml. from cup #1 to cup #2.\r\n"}, {"input": "2\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "2\r\n1\r\n1\r\n", "output": "Exemplary pages.\r\n"}, {"input": "2\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "2\r\n2\r\n0\r\n", "output": "1 ml. from cup #2 to cup #1.\r\n"}, {"input": "2\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "2\r\n2\r\n2\r\n", "output": "Exemplary pages.\r\n"}, {"input": "3\r\n0\r\n0\r\n0\r\n", "output": "Exemplary pages.\r\n"}, {"input": "3\r\n0\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n0\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n0\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n0\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n0\r\n1\r\n2\r\n", "output": "1 ml. from cup #1 to cup #3.\r\n"}, {"input": "3\r\n0\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n0\r\n2\r\n1\r\n", "output": "1 ml. from cup #1 to cup #2.\r\n"}, {"input": "3\r\n0\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n0\r\n2\r\n", "output": "1 ml. from cup #2 to cup #3.\r\n"}, {"input": "3\r\n1\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n1\r\n1\r\n", "output": "Exemplary pages.\r\n"}, {"input": "3\r\n1\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n2\r\n0\r\n", "output": "1 ml. from cup #3 to cup #2.\r\n"}, {"input": "3\r\n1\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n0\r\n1\r\n", "output": "1 ml. from cup #2 to cup #1.\r\n"}, {"input": "3\r\n2\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n1\r\n0\r\n", "output": "1 ml. from cup #3 to cup #1.\r\n"}, {"input": "3\r\n2\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n2\r\n2\r\n", "output": "Exemplary pages.\r\n"}, {"input": "4\r\n0\r\n0\r\n0\r\n0\r\n", "output": "Exemplary pages.\r\n"}, {"input": "4\r\n0\r\n0\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n1\r\n2\r\n", "output": "1 ml. from cup #1 to cup #4.\r\n"}, {"input": "4\r\n0\r\n1\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n2\r\n1\r\n", "output": "1 ml. from cup #1 to cup #3.\r\n"}, {"input": "4\r\n0\r\n1\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n1\r\n1\r\n", "output": "1 ml. from cup #1 to cup #2.\r\n"}, {"input": "4\r\n0\r\n2\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n1\r\n2\r\n", "output": "1 ml. from cup #2 to cup #4.\r\n"}, {"input": "4\r\n1\r\n0\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n2\r\n1\r\n", "output": "1 ml. from cup #2 to cup #3.\r\n"}, {"input": "4\r\n1\r\n0\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n0\r\n2\r\n", "output": "1 ml. from cup #3 to cup #4.\r\n"}, {"input": "4\r\n1\r\n1\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n1\r\n1\r\n", "output": "Exemplary pages.\r\n"}, {"input": "4\r\n1\r\n1\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n2\r\n0\r\n", "output": "1 ml. from cup #4 to cup #3.\r\n"}, {"input": "4\r\n1\r\n1\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n0\r\n1\r\n", "output": "1 ml. from cup #3 to cup #2.\r\n"}, {"input": "4\r\n1\r\n2\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n1\r\n0\r\n", "output": "1 ml. from cup #4 to cup #2.\r\n"}, {"input": "4\r\n1\r\n2\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n1\r\n1\r\n", "output": "1 ml. from cup #2 to cup #1.\r\n"}, {"input": "4\r\n2\r\n0\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n0\r\n1\r\n", "output": "1 ml. from cup #3 to cup #1.\r\n"}, {"input": "4\r\n2\r\n1\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n1\r\n0\r\n", "output": "1 ml. from cup #4 to cup #1.\r\n"}, {"input": "4\r\n2\r\n1\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n2\r\n2\r\n", "output": "Exemplary pages.\r\n"}, {"input": "27\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n2626\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n8572\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n", "output": "2973 ml. from cup #11 to cup #17.\r\n"}, {"input": "19\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n82\r\n5001\r\n9919\r\n5001\r\n5001\r\n", "output": "Unrecoverable configuration.\r\n"}]
| false |
stdio
| null | true |
807/A
|
807
|
A
|
Python 3
|
TESTS
| 35 | 46 | 0 |
173044894
|
l1=[]
l2=[]
for _ in range(int(input())):
a,b=map(int,input().split())
l1.append(a)
l2.append(b)
cnt=0
c=0
c2=0
for i in range(len(l1)-1):
if l1[i]!=l2[i]: cnt+=1
elif l1[i]<l1[i+1]: c+=1
else: c2+=1
if cnt!=0: print('rated')
elif c!=0: print('unrated')
else: print('maybe')
| 150 | 46 | 0 |
145487418
|
n = int(input())
p = {1:"rated", 2:"unrated", 3:"maybe"}
d = []
t = 2
noninc = True
for i in range(n):
a,b = map(int, input().split())
if a == b and t != 1:
if len(d) > 0 and noninc:
if d[-1] >= a:
t = 3
else:
noninc = False
t = 2
d.append(a)
else:
t = 1
print(p[t])
|
Codeforces Round 412 (rated, Div. 2, base on VK Cup 2017 Round 3)
|
CF
| 2,017 | 2 | 256 |
Is it rated?
|
Is it rated?
Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it.
Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before and after the round is known.
It's known that if at least one participant's rating has changed, then the round was rated for sure.
It's also known that if the round was rated and a participant with lower rating took a better place in the standings than a participant with higher rating, then at least one round participant's rating has changed.
In this problem, you should not make any other assumptions about the rating system.
Determine if the current round is rated, unrated, or it's impossible to determine whether it is rated of not.
|
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of round participants.
Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 4126) — the rating of the i-th participant before and after the round, respectively. The participants are listed in order from the top to the bottom of the standings.
|
If the round is rated for sure, print "rated". If the round is unrated for sure, print "unrated". If it's impossible to determine whether the round is rated or not, print "maybe".
| null |
In the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated.
In the second example, no one's rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, someone's rating would've changed for sure.
In the third example, no one's rating has changed, and the participants took places in non-increasing order of their rating. Therefore, it's impossible to determine whether the round is rated or not.
|
[{"input": "6\n3060 3060\n2194 2194\n2876 2903\n2624 2624\n3007 2991\n2884 2884", "output": "rated"}, {"input": "4\n1500 1500\n1300 1300\n1200 1200\n1400 1400", "output": "unrated"}, {"input": "5\n3123 3123\n2777 2777\n2246 2246\n2246 2246\n1699 1699", "output": "maybe"}]
| 900 |
["implementation", "sortings"]
| 150 |
[{"input": "6\r\n3060 3060\r\n2194 2194\r\n2876 2903\r\n2624 2624\r\n3007 2991\r\n2884 2884\r\n", "output": "rated\r\n"}, {"input": "4\r\n1500 1500\r\n1300 1300\r\n1200 1200\r\n1400 1400\r\n", "output": "unrated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n1699 1699\r\n", "output": "maybe\r\n"}, {"input": "2\r\n1 1\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "2\r\n4126 4126\r\n4126 4126\r\n", "output": "maybe\r\n"}, {"input": "10\r\n446 446\r\n1331 1331\r\n3594 3594\r\n1346 1902\r\n91 91\r\n3590 3590\r\n2437 2437\r\n4007 3871\r\n2797 699\r\n1423 1423\r\n", "output": "rated\r\n"}, {"input": "10\r\n4078 4078\r\n2876 2876\r\n1061 1061\r\n3721 3721\r\n143 143\r\n2992 2992\r\n3279 3279\r\n3389 3389\r\n1702 1702\r\n1110 1110\r\n", "output": "unrated\r\n"}, {"input": "10\r\n4078 4078\r\n3721 3721\r\n3389 3389\r\n3279 3279\r\n2992 2992\r\n2876 2876\r\n1702 1702\r\n1110 1110\r\n1061 1061\r\n143 143\r\n", "output": "maybe\r\n"}, {"input": "2\r\n3936 3936\r\n2967 2967\r\n", "output": "maybe\r\n"}, {"input": "2\r\n1 1\r\n2 2\r\n", "output": "unrated\r\n"}, {"input": "2\r\n2 2\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "2\r\n2 1\r\n1 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n2967 2967\r\n3936 3936\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1200 1200\r\n1200 1200\r\n1300 1300\r\n", "output": "unrated\r\n"}, {"input": "3\r\n3 3\r\n2 2\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "3\r\n1 1\r\n1 1\r\n2 2\r\n", "output": "unrated\r\n"}, {"input": "2\r\n3 2\r\n3 2\r\n", "output": "rated\r\n"}, {"input": "3\r\n5 5\r\n4 4\r\n3 4\r\n", "output": "rated\r\n"}, {"input": "3\r\n200 200\r\n200 200\r\n300 300\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1 1\r\n2 2\r\n3 3\r\n", "output": "unrated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2245 2245\r\n1699 1699\r\n", "output": "maybe\r\n"}, {"input": "2\r\n10 10\r\n8 8\r\n", "output": "maybe\r\n"}, {"input": "3\r\n1500 1500\r\n1500 1500\r\n1600 1600\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1500 1500\r\n1500 1500\r\n1700 1700\r\n", "output": "unrated\r\n"}, {"input": "4\r\n100 100\r\n100 100\r\n70 70\r\n80 80\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1 2\r\n2 1\r\n", "output": "rated\r\n"}, {"input": "3\r\n5 5\r\n4 3\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "3\r\n1600 1650\r\n1500 1550\r\n1400 1450\r\n", "output": "rated\r\n"}, {"input": "4\r\n2000 2000\r\n1500 1500\r\n1500 1500\r\n1700 1700\r\n", "output": "unrated\r\n"}, {"input": "4\r\n1500 1500\r\n1400 1400\r\n1400 1400\r\n1700 1700\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1600 1600\r\n1400 1400\r\n", "output": "maybe\r\n"}, {"input": "2\r\n3 1\r\n9 8\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 1\r\n1 1\r\n", "output": "rated\r\n"}, {"input": "4\r\n4123 4123\r\n4123 4123\r\n2670 2670\r\n3670 3670\r\n", "output": "unrated\r\n"}, {"input": "2\r\n2 2\r\n3 3\r\n", "output": "unrated\r\n"}, {"input": "2\r\n10 11\r\n5 4\r\n", "output": "rated\r\n"}, {"input": "2\r\n15 14\r\n13 12\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 1\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "3\r\n2670 2670\r\n3670 3670\r\n4106 4106\r\n", "output": "unrated\r\n"}, {"input": "3\r\n4 5\r\n3 3\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n10 9\r\n10 10\r\n", "output": "rated\r\n"}, {"input": "3\r\n1011 1011\r\n1011 999\r\n2200 2100\r\n", "output": "rated\r\n"}, {"input": "2\r\n3 3\r\n5 5\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1500 1500\r\n3000 2000\r\n", "output": "rated\r\n"}, {"input": "2\r\n5 6\r\n5 5\r\n", "output": "rated\r\n"}, {"input": "3\r\n2000 2000\r\n1500 1501\r\n500 500\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 3\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n3 3\r\n2 2\r\n", "output": "maybe\r\n"}, {"input": "2\r\n1 2\r\n1 1\r\n", "output": "rated\r\n"}, {"input": "4\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n1699 1699\r\n", "output": "maybe\r\n"}, {"input": "2\r\n15 14\r\n14 13\r\n", "output": "rated\r\n"}, {"input": "4\r\n3000 3000\r\n2900 2900\r\n3000 3000\r\n2900 2900\r\n", "output": "unrated\r\n"}, {"input": "6\r\n30 3060\r\n24 2194\r\n26 2903\r\n24 2624\r\n37 2991\r\n24 2884\r\n", "output": "rated\r\n"}, {"input": "2\r\n100 99\r\n100 100\r\n", "output": "rated\r\n"}, {"input": "4\r\n2 2\r\n1 1\r\n1 1\r\n2 2\r\n", "output": "unrated\r\n"}, {"input": "3\r\n100 101\r\n100 100\r\n100 100\r\n", "output": "rated\r\n"}, {"input": "4\r\n1000 1001\r\n900 900\r\n950 950\r\n890 890\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 3\r\n1 1\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 2\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "2\r\n3 2\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n3 2\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "2\r\n1 1\r\n2 2\r\n", "output": "unrated\r\n"}, {"input": "3\r\n3 2\r\n3 3\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "4\r\n1500 1501\r\n1300 1300\r\n1200 1200\r\n1400 1400\r\n", "output": "rated\r\n"}, {"input": "3\r\n1000 1000\r\n500 500\r\n400 300\r\n", "output": "rated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n3000 3000\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1 1\r\n2 3\r\n", "output": "rated\r\n"}, {"input": "2\r\n6 2\r\n6 2\r\n", "output": "rated\r\n"}, {"input": "5\r\n3123 3123\r\n1699 1699\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1500 1500\r\n1600 1600\r\n", "output": "unrated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2241 2241\r\n1699 1699\r\n", "output": "maybe\r\n"}, {"input": "2\r\n20 30\r\n10 5\r\n", "output": "rated\r\n"}, {"input": "3\r\n1 1\r\n2 2\r\n1 1\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1 2\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "5\r\n5 5\r\n4 4\r\n3 3\r\n2 2\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "2\r\n2 2\r\n2 1\r\n", "output": "rated\r\n"}, {"input": "2\r\n100 100\r\n90 89\r\n", "output": "rated\r\n"}, {"input": "2\r\n1000 900\r\n2000 2000\r\n", "output": "rated\r\n"}, {"input": "2\r\n50 10\r\n10 50\r\n", "output": "rated\r\n"}, {"input": "2\r\n200 200\r\n100 100\r\n", "output": "maybe\r\n"}, {"input": "3\r\n2 2\r\n2 2\r\n3 3\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1000 1000\r\n300 300\r\n100 100\r\n", "output": "maybe\r\n"}, {"input": "4\r\n2 2\r\n2 2\r\n3 3\r\n4 4\r\n", "output": "unrated\r\n"}, {"input": "2\r\n5 3\r\n6 3\r\n", "output": "rated\r\n"}, {"input": "2\r\n1200 1100\r\n1200 1000\r\n", "output": "rated\r\n"}, {"input": "2\r\n5 5\r\n4 4\r\n", "output": "maybe\r\n"}, {"input": "2\r\n5 5\r\n3 3\r\n", "output": "maybe\r\n"}, {"input": "5\r\n1500 1500\r\n1300 1300\r\n1200 1200\r\n1400 1400\r\n1100 1100\r\n", "output": "unrated\r\n"}, {"input": "5\r\n10 10\r\n9 9\r\n8 8\r\n7 7\r\n6 6\r\n", "output": "maybe\r\n"}, {"input": "3\r\n1000 1000\r\n300 300\r\n10 10\r\n", "output": "maybe\r\n"}, {"input": "5\r\n6 6\r\n5 5\r\n4 4\r\n3 3\r\n2 2\r\n", "output": "maybe\r\n"}, {"input": "2\r\n3 3\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "4\r\n2 2\r\n2 2\r\n2 2\r\n3 3\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1000 1000\r\n700 700\r\n", "output": "maybe\r\n"}, {"input": "2\r\n4 3\r\n5 3\r\n", "output": "rated\r\n"}, {"input": "2\r\n1000 1000\r\n1100 1100\r\n", "output": "unrated\r\n"}, {"input": "4\r\n5 5\r\n4 4\r\n3 3\r\n2 2\r\n", "output": "maybe\r\n"}, {"input": "3\r\n1 1\r\n2 3\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n1 2\r\n1 3\r\n", "output": "rated\r\n"}, {"input": "2\r\n3 3\r\n1 2\r\n", "output": "rated\r\n"}, {"input": "4\r\n1501 1500\r\n1300 1300\r\n1200 1200\r\n1400 1400\r\n", "output": "rated\r\n"}, {"input": "5\r\n1 1\r\n2 2\r\n3 3\r\n4 4\r\n5 5\r\n", "output": "unrated\r\n"}, {"input": "2\r\n10 10\r\n1 2\r\n", "output": "rated\r\n"}, {"input": "6\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n1699 1699\r\n1900 1900\r\n", "output": "unrated\r\n"}, {"input": "6\r\n3123 3123\r\n2777 2777\r\n3000 3000\r\n2246 2246\r\n2246 2246\r\n1699 1699\r\n", "output": "unrated\r\n"}, {"input": "2\r\n100 100\r\n110 110\r\n", "output": "unrated\r\n"}, {"input": "3\r\n3 3\r\n3 3\r\n4 4\r\n", "output": "unrated\r\n"}, {"input": "3\r\n3 3\r\n3 2\r\n4 4\r\n", "output": "rated\r\n"}, {"input": "3\r\n5 2\r\n4 4\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "4\r\n4 4\r\n3 3\r\n2 2\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "2\r\n1 1\r\n3 2\r\n", "output": "rated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n2699 2699\r\n", "output": "unrated\r\n"}, {"input": "3\r\n3 3\r\n3 3\r\n3 4\r\n", "output": "rated\r\n"}, {"input": "3\r\n1 2\r\n2 2\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "3\r\n1 2\r\n1 2\r\n1 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 1\r\n2 1\r\n", "output": "rated\r\n"}, {"input": "2\r\n1 2\r\n3 4\r\n", "output": "rated\r\n"}, {"input": "2\r\n3 2\r\n2 3\r\n", "output": "rated\r\n"}, {"input": "3\r\n1500 1500\r\n1600 1600\r\n1600 1600\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1 1\r\n3 3\r\n4 4\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1 1\r\n2 2\r\n2 2\r\n", "output": "unrated\r\n"}, {"input": "2\r\n10 12\r\n8 8\r\n", "output": "rated\r\n"}, {"input": "5\r\n1200 1200\r\n1500 1500\r\n1500 1500\r\n1500 1500\r\n1500 1500\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1 2\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "3\r\n1500 1400\r\n1200 1200\r\n1100 1100\r\n", "output": "rated\r\n"}, {"input": "2\r\n10 12\r\n10 10\r\n", "output": "rated\r\n"}, {"input": "3\r\n1500 1500\r\n1400 1400\r\n1300 1300\r\n", "output": "maybe\r\n"}, {"input": "3\r\n3 3\r\n4 4\r\n5 5\r\n", "output": "unrated\r\n"}, {"input": "3\r\n2 6\r\n3 5\r\n4 4\r\n", "output": "rated\r\n"}, {"input": "2\r\n5 6\r\n4 6\r\n", "output": "rated\r\n"}, {"input": "4\r\n10 10\r\n10 10\r\n7 7\r\n8 8\r\n", "output": "unrated\r\n"}, {"input": "2\r\n4 4\r\n3 3\r\n", "output": "maybe\r\n"}]
| false |
stdio
| null | true |
807/A
|
807
|
A
|
Python 3
|
TESTS
| 35 | 61 | 0 |
173533502
|
a=int(input())
arr=[]
for i in range(a):
sub=list(map(int,input().split()))
arr.append(sub)
c=0
j=0
for i in range(a-1):
if arr[i][0]>arr[i][1] or arr[i][0]<arr[i][1]:
c=c+1
if arr[i][0]<arr[i+1][0]:
j=j+1
if c>0:
print('rated')
elif j>0:
print('unrated')
else:
print('maybe')
| 150 | 46 | 0 |
145885952
|
n = int(input())
f,l=0,[]
for i in range(n):
h,k = map(int,input().split())
l.append(h)
if h!=k:
f=1
l1 = list(l)
l.sort(reverse=True)
if f==0 :
print(['unrated','maybe'][l1==l])
else:
print("rated")
|
Codeforces Round 412 (rated, Div. 2, base on VK Cup 2017 Round 3)
|
CF
| 2,017 | 2 | 256 |
Is it rated?
|
Is it rated?
Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it.
Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before and after the round is known.
It's known that if at least one participant's rating has changed, then the round was rated for sure.
It's also known that if the round was rated and a participant with lower rating took a better place in the standings than a participant with higher rating, then at least one round participant's rating has changed.
In this problem, you should not make any other assumptions about the rating system.
Determine if the current round is rated, unrated, or it's impossible to determine whether it is rated of not.
|
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of round participants.
Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 4126) — the rating of the i-th participant before and after the round, respectively. The participants are listed in order from the top to the bottom of the standings.
|
If the round is rated for sure, print "rated". If the round is unrated for sure, print "unrated". If it's impossible to determine whether the round is rated or not, print "maybe".
| null |
In the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated.
In the second example, no one's rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, someone's rating would've changed for sure.
In the third example, no one's rating has changed, and the participants took places in non-increasing order of their rating. Therefore, it's impossible to determine whether the round is rated or not.
|
[{"input": "6\n3060 3060\n2194 2194\n2876 2903\n2624 2624\n3007 2991\n2884 2884", "output": "rated"}, {"input": "4\n1500 1500\n1300 1300\n1200 1200\n1400 1400", "output": "unrated"}, {"input": "5\n3123 3123\n2777 2777\n2246 2246\n2246 2246\n1699 1699", "output": "maybe"}]
| 900 |
["implementation", "sortings"]
| 150 |
[{"input": "6\r\n3060 3060\r\n2194 2194\r\n2876 2903\r\n2624 2624\r\n3007 2991\r\n2884 2884\r\n", "output": "rated\r\n"}, {"input": "4\r\n1500 1500\r\n1300 1300\r\n1200 1200\r\n1400 1400\r\n", "output": "unrated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n1699 1699\r\n", "output": "maybe\r\n"}, {"input": "2\r\n1 1\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "2\r\n4126 4126\r\n4126 4126\r\n", "output": "maybe\r\n"}, {"input": "10\r\n446 446\r\n1331 1331\r\n3594 3594\r\n1346 1902\r\n91 91\r\n3590 3590\r\n2437 2437\r\n4007 3871\r\n2797 699\r\n1423 1423\r\n", "output": "rated\r\n"}, {"input": "10\r\n4078 4078\r\n2876 2876\r\n1061 1061\r\n3721 3721\r\n143 143\r\n2992 2992\r\n3279 3279\r\n3389 3389\r\n1702 1702\r\n1110 1110\r\n", "output": "unrated\r\n"}, {"input": "10\r\n4078 4078\r\n3721 3721\r\n3389 3389\r\n3279 3279\r\n2992 2992\r\n2876 2876\r\n1702 1702\r\n1110 1110\r\n1061 1061\r\n143 143\r\n", "output": "maybe\r\n"}, {"input": "2\r\n3936 3936\r\n2967 2967\r\n", "output": "maybe\r\n"}, {"input": "2\r\n1 1\r\n2 2\r\n", "output": "unrated\r\n"}, {"input": "2\r\n2 2\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "2\r\n2 1\r\n1 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n2967 2967\r\n3936 3936\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1200 1200\r\n1200 1200\r\n1300 1300\r\n", "output": "unrated\r\n"}, {"input": "3\r\n3 3\r\n2 2\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "3\r\n1 1\r\n1 1\r\n2 2\r\n", "output": "unrated\r\n"}, {"input": "2\r\n3 2\r\n3 2\r\n", "output": "rated\r\n"}, {"input": "3\r\n5 5\r\n4 4\r\n3 4\r\n", "output": "rated\r\n"}, {"input": "3\r\n200 200\r\n200 200\r\n300 300\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1 1\r\n2 2\r\n3 3\r\n", "output": "unrated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2245 2245\r\n1699 1699\r\n", "output": "maybe\r\n"}, {"input": "2\r\n10 10\r\n8 8\r\n", "output": "maybe\r\n"}, {"input": "3\r\n1500 1500\r\n1500 1500\r\n1600 1600\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1500 1500\r\n1500 1500\r\n1700 1700\r\n", "output": "unrated\r\n"}, {"input": "4\r\n100 100\r\n100 100\r\n70 70\r\n80 80\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1 2\r\n2 1\r\n", "output": "rated\r\n"}, {"input": "3\r\n5 5\r\n4 3\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "3\r\n1600 1650\r\n1500 1550\r\n1400 1450\r\n", "output": "rated\r\n"}, {"input": "4\r\n2000 2000\r\n1500 1500\r\n1500 1500\r\n1700 1700\r\n", "output": "unrated\r\n"}, {"input": "4\r\n1500 1500\r\n1400 1400\r\n1400 1400\r\n1700 1700\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1600 1600\r\n1400 1400\r\n", "output": "maybe\r\n"}, {"input": "2\r\n3 1\r\n9 8\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 1\r\n1 1\r\n", "output": "rated\r\n"}, {"input": "4\r\n4123 4123\r\n4123 4123\r\n2670 2670\r\n3670 3670\r\n", "output": "unrated\r\n"}, {"input": "2\r\n2 2\r\n3 3\r\n", "output": "unrated\r\n"}, {"input": "2\r\n10 11\r\n5 4\r\n", "output": "rated\r\n"}, {"input": "2\r\n15 14\r\n13 12\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 1\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "3\r\n2670 2670\r\n3670 3670\r\n4106 4106\r\n", "output": "unrated\r\n"}, {"input": "3\r\n4 5\r\n3 3\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n10 9\r\n10 10\r\n", "output": "rated\r\n"}, {"input": "3\r\n1011 1011\r\n1011 999\r\n2200 2100\r\n", "output": "rated\r\n"}, {"input": "2\r\n3 3\r\n5 5\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1500 1500\r\n3000 2000\r\n", "output": "rated\r\n"}, {"input": "2\r\n5 6\r\n5 5\r\n", "output": "rated\r\n"}, {"input": "3\r\n2000 2000\r\n1500 1501\r\n500 500\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 3\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n3 3\r\n2 2\r\n", "output": "maybe\r\n"}, {"input": "2\r\n1 2\r\n1 1\r\n", "output": "rated\r\n"}, {"input": "4\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n1699 1699\r\n", "output": "maybe\r\n"}, {"input": "2\r\n15 14\r\n14 13\r\n", "output": "rated\r\n"}, {"input": "4\r\n3000 3000\r\n2900 2900\r\n3000 3000\r\n2900 2900\r\n", "output": "unrated\r\n"}, {"input": "6\r\n30 3060\r\n24 2194\r\n26 2903\r\n24 2624\r\n37 2991\r\n24 2884\r\n", "output": "rated\r\n"}, {"input": "2\r\n100 99\r\n100 100\r\n", "output": "rated\r\n"}, {"input": "4\r\n2 2\r\n1 1\r\n1 1\r\n2 2\r\n", "output": "unrated\r\n"}, {"input": "3\r\n100 101\r\n100 100\r\n100 100\r\n", "output": "rated\r\n"}, {"input": "4\r\n1000 1001\r\n900 900\r\n950 950\r\n890 890\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 3\r\n1 1\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 2\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "2\r\n3 2\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n3 2\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "2\r\n1 1\r\n2 2\r\n", "output": "unrated\r\n"}, {"input": "3\r\n3 2\r\n3 3\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "4\r\n1500 1501\r\n1300 1300\r\n1200 1200\r\n1400 1400\r\n", "output": "rated\r\n"}, {"input": "3\r\n1000 1000\r\n500 500\r\n400 300\r\n", "output": "rated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n3000 3000\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1 1\r\n2 3\r\n", "output": "rated\r\n"}, {"input": "2\r\n6 2\r\n6 2\r\n", "output": "rated\r\n"}, {"input": "5\r\n3123 3123\r\n1699 1699\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1500 1500\r\n1600 1600\r\n", "output": "unrated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2241 2241\r\n1699 1699\r\n", "output": "maybe\r\n"}, {"input": "2\r\n20 30\r\n10 5\r\n", "output": "rated\r\n"}, {"input": "3\r\n1 1\r\n2 2\r\n1 1\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1 2\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "5\r\n5 5\r\n4 4\r\n3 3\r\n2 2\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "2\r\n2 2\r\n2 1\r\n", "output": "rated\r\n"}, {"input": "2\r\n100 100\r\n90 89\r\n", "output": "rated\r\n"}, {"input": "2\r\n1000 900\r\n2000 2000\r\n", "output": "rated\r\n"}, {"input": "2\r\n50 10\r\n10 50\r\n", "output": "rated\r\n"}, {"input": "2\r\n200 200\r\n100 100\r\n", "output": "maybe\r\n"}, {"input": "3\r\n2 2\r\n2 2\r\n3 3\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1000 1000\r\n300 300\r\n100 100\r\n", "output": "maybe\r\n"}, {"input": "4\r\n2 2\r\n2 2\r\n3 3\r\n4 4\r\n", "output": "unrated\r\n"}, {"input": "2\r\n5 3\r\n6 3\r\n", "output": "rated\r\n"}, {"input": "2\r\n1200 1100\r\n1200 1000\r\n", "output": "rated\r\n"}, {"input": "2\r\n5 5\r\n4 4\r\n", "output": "maybe\r\n"}, {"input": "2\r\n5 5\r\n3 3\r\n", "output": "maybe\r\n"}, {"input": "5\r\n1500 1500\r\n1300 1300\r\n1200 1200\r\n1400 1400\r\n1100 1100\r\n", "output": "unrated\r\n"}, {"input": "5\r\n10 10\r\n9 9\r\n8 8\r\n7 7\r\n6 6\r\n", "output": "maybe\r\n"}, {"input": "3\r\n1000 1000\r\n300 300\r\n10 10\r\n", "output": "maybe\r\n"}, {"input": "5\r\n6 6\r\n5 5\r\n4 4\r\n3 3\r\n2 2\r\n", "output": "maybe\r\n"}, {"input": "2\r\n3 3\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "4\r\n2 2\r\n2 2\r\n2 2\r\n3 3\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1000 1000\r\n700 700\r\n", "output": "maybe\r\n"}, {"input": "2\r\n4 3\r\n5 3\r\n", "output": "rated\r\n"}, {"input": "2\r\n1000 1000\r\n1100 1100\r\n", "output": "unrated\r\n"}, {"input": "4\r\n5 5\r\n4 4\r\n3 3\r\n2 2\r\n", "output": "maybe\r\n"}, {"input": "3\r\n1 1\r\n2 3\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n1 2\r\n1 3\r\n", "output": "rated\r\n"}, {"input": "2\r\n3 3\r\n1 2\r\n", "output": "rated\r\n"}, {"input": "4\r\n1501 1500\r\n1300 1300\r\n1200 1200\r\n1400 1400\r\n", "output": "rated\r\n"}, {"input": "5\r\n1 1\r\n2 2\r\n3 3\r\n4 4\r\n5 5\r\n", "output": "unrated\r\n"}, {"input": "2\r\n10 10\r\n1 2\r\n", "output": "rated\r\n"}, {"input": "6\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n1699 1699\r\n1900 1900\r\n", "output": "unrated\r\n"}, {"input": "6\r\n3123 3123\r\n2777 2777\r\n3000 3000\r\n2246 2246\r\n2246 2246\r\n1699 1699\r\n", "output": "unrated\r\n"}, {"input": "2\r\n100 100\r\n110 110\r\n", "output": "unrated\r\n"}, {"input": "3\r\n3 3\r\n3 3\r\n4 4\r\n", "output": "unrated\r\n"}, {"input": "3\r\n3 3\r\n3 2\r\n4 4\r\n", "output": "rated\r\n"}, {"input": "3\r\n5 2\r\n4 4\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "4\r\n4 4\r\n3 3\r\n2 2\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "2\r\n1 1\r\n3 2\r\n", "output": "rated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n2699 2699\r\n", "output": "unrated\r\n"}, {"input": "3\r\n3 3\r\n3 3\r\n3 4\r\n", "output": "rated\r\n"}, {"input": "3\r\n1 2\r\n2 2\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "3\r\n1 2\r\n1 2\r\n1 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 1\r\n2 1\r\n", "output": "rated\r\n"}, {"input": "2\r\n1 2\r\n3 4\r\n", "output": "rated\r\n"}, {"input": "2\r\n3 2\r\n2 3\r\n", "output": "rated\r\n"}, {"input": "3\r\n1500 1500\r\n1600 1600\r\n1600 1600\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1 1\r\n3 3\r\n4 4\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1 1\r\n2 2\r\n2 2\r\n", "output": "unrated\r\n"}, {"input": "2\r\n10 12\r\n8 8\r\n", "output": "rated\r\n"}, {"input": "5\r\n1200 1200\r\n1500 1500\r\n1500 1500\r\n1500 1500\r\n1500 1500\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1 2\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "3\r\n1500 1400\r\n1200 1200\r\n1100 1100\r\n", "output": "rated\r\n"}, {"input": "2\r\n10 12\r\n10 10\r\n", "output": "rated\r\n"}, {"input": "3\r\n1500 1500\r\n1400 1400\r\n1300 1300\r\n", "output": "maybe\r\n"}, {"input": "3\r\n3 3\r\n4 4\r\n5 5\r\n", "output": "unrated\r\n"}, {"input": "3\r\n2 6\r\n3 5\r\n4 4\r\n", "output": "rated\r\n"}, {"input": "2\r\n5 6\r\n4 6\r\n", "output": "rated\r\n"}, {"input": "4\r\n10 10\r\n10 10\r\n7 7\r\n8 8\r\n", "output": "unrated\r\n"}, {"input": "2\r\n4 4\r\n3 3\r\n", "output": "maybe\r\n"}]
| false |
stdio
| null | true |
792/C
|
792
|
C
|
Python 3
|
TESTS
| 27 | 93 | 7,372,800 |
26228548
|
s = list(input())
def db3(n,sm):
new = n.copy()
sm %= 3
if sm==0:
return ''.join(new)
else:
if sm==2:
for j in range(1,len(new)):
if int(new[j])%3==2:
new[j] = ''
return ''.join(new)
for j in range(1,len(new)):
if int(new[j])%3==1:
new[j]=''
sm-=1
if sm==0:
return ''.join(new)
if '0' in new:
return '0'
else:
return ''
a = 3
i = 0
l = []
Sm = sum([int(x) for x in s])
val = 0
while a and i<len(s):
if s[i]!='0':
l.append(db3(s[i:],Sm-val))
a -= 1
val += int(s[i])
i += 1
ans = max(l,key=len)
if ans:
print(ans)
else:
print(-1)
| 162 | 140 | 5,529,600 |
25861795
|
s = input()
def rm(s,m):
if s == None or len(s) == 1:
return None
i = len(s) - 1
while i >= 0:
if int(s[i]) % 3 == m:
break
i -= 1
if i == -1:
return None
else:
if i == 0:
k = i+1
while k < len(s) and s[k] == "0":
k += 1
if k == len(s):
return "0"
else:
return s[k:]
elif i == len(s)-1:
return s[:i]
else:
return s[:i] + s[i+1:]
def ans(s):
s_sum = 0
i = 0
while i<len(s):
s_sum += int(s[i])
s_sum = s_sum % 3
i += 1
if s_sum == 0:
return s
elif s_sum == 1:
s1 = rm(s,1)
s2 = rm(rm(s,2),2)
if s1 == None and s2 == None:
return -1
elif s1 == None:
return s2
elif s2 == None:
return s1
else:
if len(s1) > len(s2):
return s1
else:
return s2
elif s_sum == 2:
s1 = rm(s,2)
s2 = rm(rm(s,1),1)
if s1 == None and s2 == None:
return -1
elif s1 == None:
return s2
elif s2 == None:
return s1
else:
if len(s1) > len(s2):
return s1
else:
return s2
t = ans(s)
if t == None:
print(-1)
else:
print(t)
|
Educational Codeforces Round 18
|
ICPC
| 2,017 | 1 | 256 |
Divide by Three
|
A positive integer number n is written on a blackboard. It consists of not more than 105 digits. You have to transform it into a beautiful number by erasing some of the digits, and you want to erase as few digits as possible.
The number is called beautiful if it consists of at least one digit, doesn't have leading zeroes and is a multiple of 3. For example, 0, 99, 10110 are beautiful numbers, and 00, 03, 122 are not.
Write a program which for the given n will find a beautiful number such that n can be transformed into this number by erasing as few digits as possible. You can erase an arbitraty set of digits. For example, they don't have to go one after another in the number n.
If it's impossible to obtain a beautiful number, print -1. If there are multiple answers, print any of them.
|
The first line of input contains n — a positive integer number without leading zeroes (1 ≤ n < 10100000).
|
Print one number — any beautiful number obtained by erasing as few as possible digits. If there is no answer, print - 1.
| null |
In the first example it is enough to erase only the first digit to obtain a multiple of 3. But if we erase the first digit, then we obtain a number with a leading zero. So the minimum number of digits to be erased is two.
|
[{"input": "1033", "output": "33"}, {"input": "10", "output": "0"}, {"input": "11", "output": "-1"}]
| 2,000 |
["dp", "greedy", "math", "number theory"]
| 162 |
[{"input": "1033\r\n", "output": "33\r\n"}, {"input": "10\r\n", "output": "0\r\n"}, {"input": "11\r\n", "output": "-1\r\n"}, {"input": "3\r\n", "output": "3\r\n"}, {"input": "1\r\n", "output": "-1\r\n"}, {"input": "117\r\n", "output": "117\r\n"}, {"input": "518\r\n", "output": "18\r\n"}, {"input": "327\r\n", "output": "327\r\n"}, {"input": "270461\r\n", "output": "70461\r\n"}, {"input": "609209\r\n", "output": "60909\r\n"}, {"input": "110930\r\n", "output": "930\r\n"}, {"input": "37616145150713688775\r\n", "output": "3616145150713688775\r\n"}, {"input": "98509135612114839419\r\n", "output": "9509135612114839419\r\n"}, {"input": "41674994051436988162\r\n", "output": "1674994051436988162\r\n"}, {"input": "82547062721736129804\r\n", "output": "82547062721736129804\r\n"}, {"input": "4902501252475186372406731932548506197390793597574544727433297197476846519276598727359617092494798814\r\n", "output": "490501252475186372406731932548506197390793597574544727433297197476846519276598727359617092494798814\r\n"}, {"input": "1291007209605301446874998623691572528836214969878676835460982410817526074579818247646933326771899122\r\n", "output": "1291007209605301446874998623691572528836214969878676835460982410817526074579818247646933326771899122\r\n"}, {"input": "5388306043547446322173224045662327678394712363272776811399689704247387317165308057863239568137902157\r\n", "output": "538830603547446322173224045662327678394712363272776811399689704247387317165308057863239568137902157\r\n"}, {"input": "20000111\r\n", "output": "200001\r\n"}, {"input": "100222\r\n", "output": "1002\r\n"}, {"input": "202\r\n", "output": "0\r\n"}, {"input": "100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000033\r\n", "output": "33\r\n"}, {"input": "101\r\n", "output": "0\r\n"}, {"input": "1000000222\r\n", "output": "10000002\r\n"}, {"input": "1001\r\n", "output": "0\r\n"}, {"input": "205\r\n", "output": "0\r\n"}, {"input": "102211\r\n", "output": "10221\r\n"}, {"input": "100000002022\r\n", "output": "1000000002\r\n"}, {"input": "20203\r\n", "output": "3\r\n"}, {"input": "1002001\r\n", "output": "100200\r\n"}, {"input": "10002223\r\n", "output": "100023\r\n"}, {"input": "1002223\r\n", "output": "10023\r\n"}, {"input": "100000231\r\n", "output": "10000023\r\n"}, {"input": "220\r\n", "output": "0\r\n"}, {"input": "322\r\n", "output": "3\r\n"}, {"input": "100000222\r\n", "output": "1000002\r\n"}, {"input": "10033\r\n", "output": "33\r\n"}, {"input": "2003302\r\n", "output": "330\r\n"}, {"input": "10011001\r\n", "output": "1001001\r\n"}, {"input": "20000000011001111\r\n", "output": "200000000001111\r\n"}, {"input": "100000000\r\n", "output": "0\r\n"}, {"input": "1000\r\n", "output": "0\r\n"}, {"input": "200000000000000000000000000008\r\n", "output": "0\r\n"}, {"input": "1000000000000222\r\n", "output": "10000000000002\r\n"}, {"input": "100000000000000000222\r\n", "output": "1000000000000000002\r\n"}, {"input": "29512\r\n", "output": "2952\r\n"}, {"input": "88888888888888\r\n", "output": "888888888888\r\n"}, {"input": "100000000000222\r\n", "output": "1000000000002\r\n"}, {"input": "11000000\r\n", "output": "0\r\n"}, {"input": "2200\r\n", "output": "0\r\n"}, {"input": "10000555\r\n", "output": "100005\r\n"}, {"input": "1000222\r\n", "output": "10002\r\n"}, {"input": "10021\r\n", "output": "1002\r\n"}, {"input": "223\r\n", "output": "3\r\n"}, {"input": "1013\r\n", "output": "3\r\n"}, {"input": "100020001\r\n", "output": "10002000\r\n"}, {"input": "20000000000000000000932\r\n", "output": "93\r\n"}, {"input": "1010\r\n", "output": "0\r\n"}, {"input": "2000000002222\r\n", "output": "20000000022\r\n"}, {"input": "10213\r\n", "output": "1023\r\n"}, {"input": "109111\r\n", "output": "10911\r\n"}, {"input": "1010101010\r\n", "output": "10001010\r\n"}, {"input": "300055\r\n", "output": "3000\r\n"}, {"input": "200200\r\n", "output": "0\r\n"}, {"input": "202222\r\n", "output": "2022\r\n"}, {"input": "4000888\r\n", "output": "40008\r\n"}, {"input": "200000111\r\n", "output": "2000001\r\n"}, {"input": "2000000111\r\n", "output": "20000001\r\n"}, {"input": "1000000\r\n", "output": "0\r\n"}, {"input": "1003301\r\n", "output": "330\r\n"}, {"input": "100001\r\n", "output": "0\r\n"}, {"input": "40000000000000000000888\r\n", "output": "400000000000000000008\r\n"}, {"input": "100000\r\n", "output": "0\r\n"}, {"input": "4000000888\r\n", "output": "40000008\r\n"}, {"input": "334733\r\n", "output": "3333\r\n"}, {"input": "1000002220\r\n", "output": "10000020\r\n"}, {"input": "100321\r\n", "output": "10032\r\n"}, {"input": "101111\r\n", "output": "1011\r\n"}, {"input": "100000000222\r\n", "output": "1000000002\r\n"}, {"input": "10001\r\n", "output": "0\r\n"}, {"input": "7\r\n", "output": "-1\r\n"}, {"input": "2000000000111\r\n", "output": "20000000001\r\n"}, {"input": "100000001\r\n", "output": "0\r\n"}, {"input": "10000000000222\r\n", "output": "100000000002\r\n"}, {"input": "200000000000000111\r\n", "output": "2000000000000001\r\n"}, {"input": "404044\r\n", "output": "40044\r\n"}, {"input": "30202\r\n", "output": "300\r\n"}, {"input": "20000000000000000111\r\n", "output": "200000000000000001\r\n"}, {"input": "707\r\n", "output": "0\r\n"}, {"input": "20000300000000003000050000003\r\n", "output": "30000000000300000000003\r\n"}, {"input": "400000888\r\n", "output": "4000008\r\n"}, {"input": "2888\r\n", "output": "888\r\n"}, {"input": "200111\r\n", "output": "2001\r\n"}, {"input": "10000000888\r\n", "output": "100000008\r\n"}, {"input": "40000888\r\n", "output": "400008\r\n"}, {"input": "40404044\r\n", "output": "400044\r\n"}, {"input": "5500000000\r\n", "output": "0\r\n"}, {"input": "100012\r\n", "output": "10002\r\n"}, {"input": "1000007\r\n", "output": "0\r\n"}, {"input": "200093\r\n", "output": "93\r\n"}, {"input": "10000000222\r\n", "output": "100000002\r\n"}, {"input": "20000000002\r\n", "output": "0\r\n"}, {"input": "74333\r\n", "output": "333\r\n"}, {"input": "200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\r\n", "output": "0\r\n"}, {"input": "10000000111\r\n", "output": "1000000011\r\n"}, {"input": "100007\r\n", "output": "0\r\n"}, {"input": "20000006711\r\n", "output": "200000061\r\n"}, {"input": "8059\r\n", "output": "9\r\n"}, {"input": "8008\r\n", "output": "0\r\n"}, {"input": "88\r\n", "output": "-1\r\n"}, {"input": "2002\r\n", "output": "0\r\n"}, {"input": "2000111\r\n", "output": "20001\r\n"}, {"input": "100000000100000002\r\n", "output": "10000000000000002\r\n"}, {"input": "1000000000000000000000000000000000\r\n", "output": "0\r\n"}, {"input": "10000000000000000222\r\n", "output": "100000000000000002\r\n"}, {"input": "1000001\r\n", "output": "0\r\n"}, {"input": "200000000000111\r\n", "output": "2000000000001\r\n"}, {"input": "2000000002\r\n", "output": "0\r\n"}, {"input": "2010000100001\r\n", "output": "10000100001\r\n"}, {"input": "200330\r\n", "output": "330\r\n"}, {"input": "10000222\r\n", "output": "100002\r\n"}, {"input": "2005\r\n", "output": "0\r\n"}, {"input": "100000000000822\r\n", "output": "1000000000002\r\n"}, {"input": "10000000000000000000000\r\n", "output": "0\r\n"}, {"input": "7046\r\n", "output": "6\r\n"}, {"input": "4000117\r\n", "output": "400017\r\n"}, {"input": "971\r\n", "output": "9\r\n"}, {"input": "404\r\n", "output": "0\r\n"}, {"input": "5\r\n", "output": "-1\r\n"}, {"input": "164\r\n", "output": "6\r\n"}, {"input": "140\r\n", "output": "0\r\n"}, {"input": "74\r\n", "output": "-1\r\n"}, {"input": "2058232\r\n", "output": "20232\r\n"}, {"input": "4\r\n", "output": "-1\r\n"}, {"input": "20206\r\n", "output": "6\r\n"}, {"input": "103310\r\n", "output": "330\r\n"}, {"input": "100\r\n", "output": "0\r\n"}, {"input": "417179\r\n", "output": "7179\r\n"}, {"input": "70558\r\n", "output": "558\r\n"}, {"input": "298\r\n", "output": "9\r\n"}, {"input": "7003\r\n", "output": "3\r\n"}, {"input": "2212\r\n", "output": "222\r\n"}, {"input": "1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001\r\n", "output": "0\r\n"}, {"input": "2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002\r\n", "output": "0\r\n"}, {"input": "1002200\r\n", "output": "100200\r\n"}, {"input": "1222\r\n", "output": "222\r\n"}, {"input": "101200100\r\n", "output": "10100100\r\n"}, {"input": "1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003\r\n", "output": "3\r\n"}, {"input": "20020201\r\n", "output": "2002020\r\n"}, {"input": "12122\r\n", "output": "1122\r\n"}, {"input": "20200\r\n", "output": "0\r\n"}, {"input": "2\r\n", "output": "-1\r\n"}, {"input": "1000000000000258\r\n", "output": "10000000000008\r\n"}]
| false |
stdio
|
import sys
def is_subsequence(s, t):
t_iter = iter(t)
try:
for c in s:
while next(t_iter) != c:
pass
return True
except StopIteration:
return False
def is_beautiful(s):
if not s:
return False
if s[0] == '0' and len(s) > 1:
return False
total = sum(int(c) for c in s)
return total % 3 == 0
def compute_max_length(n):
sum_digits = sum(int(c) for c in n)
sum_mod3 = sum_digits % 3
has_zero = '0' in n
if sum_mod3 == 0:
if n[0] != '0':
return len(n)
first_non_zero = next((i for i, c in enumerate(n) if c != '0'), None)
if first_non_zero is None:
return 1
return len(n) - first_non_zero
else:
candidates = []
for i, c in enumerate(n):
if int(c) % 3 == sum_mod3:
new_n = n[:i] + n[i+1:]
if not new_n:
continue
first_non_zero = next((j for j, ch in enumerate(new_n) if ch != '0'), None)
if first_non_zero is None:
candidates.append(1)
else:
candidates.append(len(new_n) - first_non_zero)
target_mod = (3 - sum_mod3) % 3
mod_digits = [i for i, c in enumerate(n) if int(c) % 3 == target_mod]
if len(mod_digits) >= 2:
i, j = mod_digits[-2], mod_digits[-1]
new_n = n[:i] + n[i+1:j] + n[j+1:]
if new_n:
first_non_zero = next((k for k, ch in enumerate(new_n) if ch != '0'), None)
if first_non_zero is None:
candidates.append(1)
else:
candidates.append(len(new_n) - first_non_zero)
if has_zero:
candidates.append(1)
return max(candidates) if candidates else 0
def main(input_path, output_path, submission_path):
with open(input_path, 'r') as f:
n = f.read().strip()
with open(submission_path, 'r') as f:
submission = f.read().strip()
if submission == '-1':
max_len = compute_max_length(n)
print(100 if max_len == 0 else 0)
else:
if not is_subsequence(submission, n) or not is_beautiful(submission):
print(0)
return
max_len = compute_max_length(n)
print(100 if len(submission) == max_len else 0)
if __name__ == '__main__':
input_path, output_path, submission_path = sys.argv[1], sys.argv[2], sys.argv[3]
main(input_path, output_path, submission_path)
| true |
807/A
|
807
|
A
|
Python 3
|
TESTS
| 35 | 109 | 6,963,200 |
84974838
|
n = int(input())
ls = []
res = ''
for i in range(n):
ls.append(list(map(int,input().split())))
for i in range(n-1):
if ls[i][0]!=ls[i][1]:
res = "rated"
break
if res != 'rated':
for i in range(n-1):
if ls[i][1]<ls[i+1][1]:
res = "unrated"
break
else:
res = "maybe"
print(res)
| 150 | 46 | 0 |
146642324
|
n = int(input())
f_r = 0
f_u = 0
before_list = []
after_list = []
for i in range(n):
before, after = map(int, input().split())
if before != after:
f_r = 1
elif len(before_list) and before > before_list[-1]:
f_u = 1
before_list.append(before)
after_list.append(after)
if f_r:
print("rated")
elif f_u:
print("unrated")
else:
print("maybe")
|
Codeforces Round 412 (rated, Div. 2, base on VK Cup 2017 Round 3)
|
CF
| 2,017 | 2 | 256 |
Is it rated?
|
Is it rated?
Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it.
Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before and after the round is known.
It's known that if at least one participant's rating has changed, then the round was rated for sure.
It's also known that if the round was rated and a participant with lower rating took a better place in the standings than a participant with higher rating, then at least one round participant's rating has changed.
In this problem, you should not make any other assumptions about the rating system.
Determine if the current round is rated, unrated, or it's impossible to determine whether it is rated of not.
|
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of round participants.
Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 4126) — the rating of the i-th participant before and after the round, respectively. The participants are listed in order from the top to the bottom of the standings.
|
If the round is rated for sure, print "rated". If the round is unrated for sure, print "unrated". If it's impossible to determine whether the round is rated or not, print "maybe".
| null |
In the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated.
In the second example, no one's rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, someone's rating would've changed for sure.
In the third example, no one's rating has changed, and the participants took places in non-increasing order of their rating. Therefore, it's impossible to determine whether the round is rated or not.
|
[{"input": "6\n3060 3060\n2194 2194\n2876 2903\n2624 2624\n3007 2991\n2884 2884", "output": "rated"}, {"input": "4\n1500 1500\n1300 1300\n1200 1200\n1400 1400", "output": "unrated"}, {"input": "5\n3123 3123\n2777 2777\n2246 2246\n2246 2246\n1699 1699", "output": "maybe"}]
| 900 |
["implementation", "sortings"]
| 150 |
[{"input": "6\r\n3060 3060\r\n2194 2194\r\n2876 2903\r\n2624 2624\r\n3007 2991\r\n2884 2884\r\n", "output": "rated\r\n"}, {"input": "4\r\n1500 1500\r\n1300 1300\r\n1200 1200\r\n1400 1400\r\n", "output": "unrated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n1699 1699\r\n", "output": "maybe\r\n"}, {"input": "2\r\n1 1\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "2\r\n4126 4126\r\n4126 4126\r\n", "output": "maybe\r\n"}, {"input": "10\r\n446 446\r\n1331 1331\r\n3594 3594\r\n1346 1902\r\n91 91\r\n3590 3590\r\n2437 2437\r\n4007 3871\r\n2797 699\r\n1423 1423\r\n", "output": "rated\r\n"}, {"input": "10\r\n4078 4078\r\n2876 2876\r\n1061 1061\r\n3721 3721\r\n143 143\r\n2992 2992\r\n3279 3279\r\n3389 3389\r\n1702 1702\r\n1110 1110\r\n", "output": "unrated\r\n"}, {"input": "10\r\n4078 4078\r\n3721 3721\r\n3389 3389\r\n3279 3279\r\n2992 2992\r\n2876 2876\r\n1702 1702\r\n1110 1110\r\n1061 1061\r\n143 143\r\n", "output": "maybe\r\n"}, {"input": "2\r\n3936 3936\r\n2967 2967\r\n", "output": "maybe\r\n"}, {"input": "2\r\n1 1\r\n2 2\r\n", "output": "unrated\r\n"}, {"input": "2\r\n2 2\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "2\r\n2 1\r\n1 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n2967 2967\r\n3936 3936\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1200 1200\r\n1200 1200\r\n1300 1300\r\n", "output": "unrated\r\n"}, {"input": "3\r\n3 3\r\n2 2\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "3\r\n1 1\r\n1 1\r\n2 2\r\n", "output": "unrated\r\n"}, {"input": "2\r\n3 2\r\n3 2\r\n", "output": "rated\r\n"}, {"input": "3\r\n5 5\r\n4 4\r\n3 4\r\n", "output": "rated\r\n"}, {"input": "3\r\n200 200\r\n200 200\r\n300 300\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1 1\r\n2 2\r\n3 3\r\n", "output": "unrated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2245 2245\r\n1699 1699\r\n", "output": "maybe\r\n"}, {"input": "2\r\n10 10\r\n8 8\r\n", "output": "maybe\r\n"}, {"input": "3\r\n1500 1500\r\n1500 1500\r\n1600 1600\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1500 1500\r\n1500 1500\r\n1700 1700\r\n", "output": "unrated\r\n"}, {"input": "4\r\n100 100\r\n100 100\r\n70 70\r\n80 80\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1 2\r\n2 1\r\n", "output": "rated\r\n"}, {"input": "3\r\n5 5\r\n4 3\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "3\r\n1600 1650\r\n1500 1550\r\n1400 1450\r\n", "output": "rated\r\n"}, {"input": "4\r\n2000 2000\r\n1500 1500\r\n1500 1500\r\n1700 1700\r\n", "output": "unrated\r\n"}, {"input": "4\r\n1500 1500\r\n1400 1400\r\n1400 1400\r\n1700 1700\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1600 1600\r\n1400 1400\r\n", "output": "maybe\r\n"}, {"input": "2\r\n3 1\r\n9 8\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 1\r\n1 1\r\n", "output": "rated\r\n"}, {"input": "4\r\n4123 4123\r\n4123 4123\r\n2670 2670\r\n3670 3670\r\n", "output": "unrated\r\n"}, {"input": "2\r\n2 2\r\n3 3\r\n", "output": "unrated\r\n"}, {"input": "2\r\n10 11\r\n5 4\r\n", "output": "rated\r\n"}, {"input": "2\r\n15 14\r\n13 12\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 1\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "3\r\n2670 2670\r\n3670 3670\r\n4106 4106\r\n", "output": "unrated\r\n"}, {"input": "3\r\n4 5\r\n3 3\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n10 9\r\n10 10\r\n", "output": "rated\r\n"}, {"input": "3\r\n1011 1011\r\n1011 999\r\n2200 2100\r\n", "output": "rated\r\n"}, {"input": "2\r\n3 3\r\n5 5\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1500 1500\r\n3000 2000\r\n", "output": "rated\r\n"}, {"input": "2\r\n5 6\r\n5 5\r\n", "output": "rated\r\n"}, {"input": "3\r\n2000 2000\r\n1500 1501\r\n500 500\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 3\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n3 3\r\n2 2\r\n", "output": "maybe\r\n"}, {"input": "2\r\n1 2\r\n1 1\r\n", "output": "rated\r\n"}, {"input": "4\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n1699 1699\r\n", "output": "maybe\r\n"}, {"input": "2\r\n15 14\r\n14 13\r\n", "output": "rated\r\n"}, {"input": "4\r\n3000 3000\r\n2900 2900\r\n3000 3000\r\n2900 2900\r\n", "output": "unrated\r\n"}, {"input": "6\r\n30 3060\r\n24 2194\r\n26 2903\r\n24 2624\r\n37 2991\r\n24 2884\r\n", "output": "rated\r\n"}, {"input": "2\r\n100 99\r\n100 100\r\n", "output": "rated\r\n"}, {"input": "4\r\n2 2\r\n1 1\r\n1 1\r\n2 2\r\n", "output": "unrated\r\n"}, {"input": "3\r\n100 101\r\n100 100\r\n100 100\r\n", "output": "rated\r\n"}, {"input": "4\r\n1000 1001\r\n900 900\r\n950 950\r\n890 890\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 3\r\n1 1\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 2\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "2\r\n3 2\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n3 2\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "2\r\n1 1\r\n2 2\r\n", "output": "unrated\r\n"}, {"input": "3\r\n3 2\r\n3 3\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "4\r\n1500 1501\r\n1300 1300\r\n1200 1200\r\n1400 1400\r\n", "output": "rated\r\n"}, {"input": "3\r\n1000 1000\r\n500 500\r\n400 300\r\n", "output": "rated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n3000 3000\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1 1\r\n2 3\r\n", "output": "rated\r\n"}, {"input": "2\r\n6 2\r\n6 2\r\n", "output": "rated\r\n"}, {"input": "5\r\n3123 3123\r\n1699 1699\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1500 1500\r\n1600 1600\r\n", "output": "unrated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2241 2241\r\n1699 1699\r\n", "output": "maybe\r\n"}, {"input": "2\r\n20 30\r\n10 5\r\n", "output": "rated\r\n"}, {"input": "3\r\n1 1\r\n2 2\r\n1 1\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1 2\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "5\r\n5 5\r\n4 4\r\n3 3\r\n2 2\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "2\r\n2 2\r\n2 1\r\n", "output": "rated\r\n"}, {"input": "2\r\n100 100\r\n90 89\r\n", "output": "rated\r\n"}, {"input": "2\r\n1000 900\r\n2000 2000\r\n", "output": "rated\r\n"}, {"input": "2\r\n50 10\r\n10 50\r\n", "output": "rated\r\n"}, {"input": "2\r\n200 200\r\n100 100\r\n", "output": "maybe\r\n"}, {"input": "3\r\n2 2\r\n2 2\r\n3 3\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1000 1000\r\n300 300\r\n100 100\r\n", "output": "maybe\r\n"}, {"input": "4\r\n2 2\r\n2 2\r\n3 3\r\n4 4\r\n", "output": "unrated\r\n"}, {"input": "2\r\n5 3\r\n6 3\r\n", "output": "rated\r\n"}, {"input": "2\r\n1200 1100\r\n1200 1000\r\n", "output": "rated\r\n"}, {"input": "2\r\n5 5\r\n4 4\r\n", "output": "maybe\r\n"}, {"input": "2\r\n5 5\r\n3 3\r\n", "output": "maybe\r\n"}, {"input": "5\r\n1500 1500\r\n1300 1300\r\n1200 1200\r\n1400 1400\r\n1100 1100\r\n", "output": "unrated\r\n"}, {"input": "5\r\n10 10\r\n9 9\r\n8 8\r\n7 7\r\n6 6\r\n", "output": "maybe\r\n"}, {"input": "3\r\n1000 1000\r\n300 300\r\n10 10\r\n", "output": "maybe\r\n"}, {"input": "5\r\n6 6\r\n5 5\r\n4 4\r\n3 3\r\n2 2\r\n", "output": "maybe\r\n"}, {"input": "2\r\n3 3\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "4\r\n2 2\r\n2 2\r\n2 2\r\n3 3\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1000 1000\r\n700 700\r\n", "output": "maybe\r\n"}, {"input": "2\r\n4 3\r\n5 3\r\n", "output": "rated\r\n"}, {"input": "2\r\n1000 1000\r\n1100 1100\r\n", "output": "unrated\r\n"}, {"input": "4\r\n5 5\r\n4 4\r\n3 3\r\n2 2\r\n", "output": "maybe\r\n"}, {"input": "3\r\n1 1\r\n2 3\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n1 2\r\n1 3\r\n", "output": "rated\r\n"}, {"input": "2\r\n3 3\r\n1 2\r\n", "output": "rated\r\n"}, {"input": "4\r\n1501 1500\r\n1300 1300\r\n1200 1200\r\n1400 1400\r\n", "output": "rated\r\n"}, {"input": "5\r\n1 1\r\n2 2\r\n3 3\r\n4 4\r\n5 5\r\n", "output": "unrated\r\n"}, {"input": "2\r\n10 10\r\n1 2\r\n", "output": "rated\r\n"}, {"input": "6\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n1699 1699\r\n1900 1900\r\n", "output": "unrated\r\n"}, {"input": "6\r\n3123 3123\r\n2777 2777\r\n3000 3000\r\n2246 2246\r\n2246 2246\r\n1699 1699\r\n", "output": "unrated\r\n"}, {"input": "2\r\n100 100\r\n110 110\r\n", "output": "unrated\r\n"}, {"input": "3\r\n3 3\r\n3 3\r\n4 4\r\n", "output": "unrated\r\n"}, {"input": "3\r\n3 3\r\n3 2\r\n4 4\r\n", "output": "rated\r\n"}, {"input": "3\r\n5 2\r\n4 4\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "4\r\n4 4\r\n3 3\r\n2 2\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "2\r\n1 1\r\n3 2\r\n", "output": "rated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n2699 2699\r\n", "output": "unrated\r\n"}, {"input": "3\r\n3 3\r\n3 3\r\n3 4\r\n", "output": "rated\r\n"}, {"input": "3\r\n1 2\r\n2 2\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "3\r\n1 2\r\n1 2\r\n1 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 1\r\n2 1\r\n", "output": "rated\r\n"}, {"input": "2\r\n1 2\r\n3 4\r\n", "output": "rated\r\n"}, {"input": "2\r\n3 2\r\n2 3\r\n", "output": "rated\r\n"}, {"input": "3\r\n1500 1500\r\n1600 1600\r\n1600 1600\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1 1\r\n3 3\r\n4 4\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1 1\r\n2 2\r\n2 2\r\n", "output": "unrated\r\n"}, {"input": "2\r\n10 12\r\n8 8\r\n", "output": "rated\r\n"}, {"input": "5\r\n1200 1200\r\n1500 1500\r\n1500 1500\r\n1500 1500\r\n1500 1500\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1 2\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "3\r\n1500 1400\r\n1200 1200\r\n1100 1100\r\n", "output": "rated\r\n"}, {"input": "2\r\n10 12\r\n10 10\r\n", "output": "rated\r\n"}, {"input": "3\r\n1500 1500\r\n1400 1400\r\n1300 1300\r\n", "output": "maybe\r\n"}, {"input": "3\r\n3 3\r\n4 4\r\n5 5\r\n", "output": "unrated\r\n"}, {"input": "3\r\n2 6\r\n3 5\r\n4 4\r\n", "output": "rated\r\n"}, {"input": "2\r\n5 6\r\n4 6\r\n", "output": "rated\r\n"}, {"input": "4\r\n10 10\r\n10 10\r\n7 7\r\n8 8\r\n", "output": "unrated\r\n"}, {"input": "2\r\n4 4\r\n3 3\r\n", "output": "maybe\r\n"}]
| false |
stdio
| null | true |
807/A
|
807
|
A
|
Python 3
|
TESTS
| 35 | 109 | 6,963,200 |
86453139
|
a=int(input())
n1=[]
m1=[]
for i in range(a):
n,m=map(int, input().split())
n1.append(n)
m1.append(m)
ans=0
cnt=1
i=0
while i<(a-1):
if n1[i]!=m1[i]:
ans=1
print("rated")
break
elif n1[i]>=n1[i+1]:
cnt+=1
i=i+1
if cnt!=a and ans==0:
print('unrated')
elif cnt==a and ans==0:
print('maybe')
| 150 | 46 | 0 |
146977522
|
n =int(input())
l=[]
res='maybe'
for x in range(n):
b,a=map(int,input().split())
l.append([b,a])
if a!=b:
res='rated'
if res!='rated' :
c=0
while c<len(l)-1 :
if l[c][0]<l[c+1][0] :
res='unrated'
break
c+=1
print(res)
|
Codeforces Round 412 (rated, Div. 2, base on VK Cup 2017 Round 3)
|
CF
| 2,017 | 2 | 256 |
Is it rated?
|
Is it rated?
Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it.
Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before and after the round is known.
It's known that if at least one participant's rating has changed, then the round was rated for sure.
It's also known that if the round was rated and a participant with lower rating took a better place in the standings than a participant with higher rating, then at least one round participant's rating has changed.
In this problem, you should not make any other assumptions about the rating system.
Determine if the current round is rated, unrated, or it's impossible to determine whether it is rated of not.
|
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of round participants.
Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 4126) — the rating of the i-th participant before and after the round, respectively. The participants are listed in order from the top to the bottom of the standings.
|
If the round is rated for sure, print "rated". If the round is unrated for sure, print "unrated". If it's impossible to determine whether the round is rated or not, print "maybe".
| null |
In the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated.
In the second example, no one's rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, someone's rating would've changed for sure.
In the third example, no one's rating has changed, and the participants took places in non-increasing order of their rating. Therefore, it's impossible to determine whether the round is rated or not.
|
[{"input": "6\n3060 3060\n2194 2194\n2876 2903\n2624 2624\n3007 2991\n2884 2884", "output": "rated"}, {"input": "4\n1500 1500\n1300 1300\n1200 1200\n1400 1400", "output": "unrated"}, {"input": "5\n3123 3123\n2777 2777\n2246 2246\n2246 2246\n1699 1699", "output": "maybe"}]
| 900 |
["implementation", "sortings"]
| 150 |
[{"input": "6\r\n3060 3060\r\n2194 2194\r\n2876 2903\r\n2624 2624\r\n3007 2991\r\n2884 2884\r\n", "output": "rated\r\n"}, {"input": "4\r\n1500 1500\r\n1300 1300\r\n1200 1200\r\n1400 1400\r\n", "output": "unrated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n1699 1699\r\n", "output": "maybe\r\n"}, {"input": "2\r\n1 1\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "2\r\n4126 4126\r\n4126 4126\r\n", "output": "maybe\r\n"}, {"input": "10\r\n446 446\r\n1331 1331\r\n3594 3594\r\n1346 1902\r\n91 91\r\n3590 3590\r\n2437 2437\r\n4007 3871\r\n2797 699\r\n1423 1423\r\n", "output": "rated\r\n"}, {"input": "10\r\n4078 4078\r\n2876 2876\r\n1061 1061\r\n3721 3721\r\n143 143\r\n2992 2992\r\n3279 3279\r\n3389 3389\r\n1702 1702\r\n1110 1110\r\n", "output": "unrated\r\n"}, {"input": "10\r\n4078 4078\r\n3721 3721\r\n3389 3389\r\n3279 3279\r\n2992 2992\r\n2876 2876\r\n1702 1702\r\n1110 1110\r\n1061 1061\r\n143 143\r\n", "output": "maybe\r\n"}, {"input": "2\r\n3936 3936\r\n2967 2967\r\n", "output": "maybe\r\n"}, {"input": "2\r\n1 1\r\n2 2\r\n", "output": "unrated\r\n"}, {"input": "2\r\n2 2\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "2\r\n2 1\r\n1 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n2967 2967\r\n3936 3936\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1200 1200\r\n1200 1200\r\n1300 1300\r\n", "output": "unrated\r\n"}, {"input": "3\r\n3 3\r\n2 2\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "3\r\n1 1\r\n1 1\r\n2 2\r\n", "output": "unrated\r\n"}, {"input": "2\r\n3 2\r\n3 2\r\n", "output": "rated\r\n"}, {"input": "3\r\n5 5\r\n4 4\r\n3 4\r\n", "output": "rated\r\n"}, {"input": "3\r\n200 200\r\n200 200\r\n300 300\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1 1\r\n2 2\r\n3 3\r\n", "output": "unrated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2245 2245\r\n1699 1699\r\n", "output": "maybe\r\n"}, {"input": "2\r\n10 10\r\n8 8\r\n", "output": "maybe\r\n"}, {"input": "3\r\n1500 1500\r\n1500 1500\r\n1600 1600\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1500 1500\r\n1500 1500\r\n1700 1700\r\n", "output": "unrated\r\n"}, {"input": "4\r\n100 100\r\n100 100\r\n70 70\r\n80 80\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1 2\r\n2 1\r\n", "output": "rated\r\n"}, {"input": "3\r\n5 5\r\n4 3\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "3\r\n1600 1650\r\n1500 1550\r\n1400 1450\r\n", "output": "rated\r\n"}, {"input": "4\r\n2000 2000\r\n1500 1500\r\n1500 1500\r\n1700 1700\r\n", "output": "unrated\r\n"}, {"input": "4\r\n1500 1500\r\n1400 1400\r\n1400 1400\r\n1700 1700\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1600 1600\r\n1400 1400\r\n", "output": "maybe\r\n"}, {"input": "2\r\n3 1\r\n9 8\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 1\r\n1 1\r\n", "output": "rated\r\n"}, {"input": "4\r\n4123 4123\r\n4123 4123\r\n2670 2670\r\n3670 3670\r\n", "output": "unrated\r\n"}, {"input": "2\r\n2 2\r\n3 3\r\n", "output": "unrated\r\n"}, {"input": "2\r\n10 11\r\n5 4\r\n", "output": "rated\r\n"}, {"input": "2\r\n15 14\r\n13 12\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 1\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "3\r\n2670 2670\r\n3670 3670\r\n4106 4106\r\n", "output": "unrated\r\n"}, {"input": "3\r\n4 5\r\n3 3\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n10 9\r\n10 10\r\n", "output": "rated\r\n"}, {"input": "3\r\n1011 1011\r\n1011 999\r\n2200 2100\r\n", "output": "rated\r\n"}, {"input": "2\r\n3 3\r\n5 5\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1500 1500\r\n3000 2000\r\n", "output": "rated\r\n"}, {"input": "2\r\n5 6\r\n5 5\r\n", "output": "rated\r\n"}, {"input": "3\r\n2000 2000\r\n1500 1501\r\n500 500\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 3\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n3 3\r\n2 2\r\n", "output": "maybe\r\n"}, {"input": "2\r\n1 2\r\n1 1\r\n", "output": "rated\r\n"}, {"input": "4\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n1699 1699\r\n", "output": "maybe\r\n"}, {"input": "2\r\n15 14\r\n14 13\r\n", "output": "rated\r\n"}, {"input": "4\r\n3000 3000\r\n2900 2900\r\n3000 3000\r\n2900 2900\r\n", "output": "unrated\r\n"}, {"input": "6\r\n30 3060\r\n24 2194\r\n26 2903\r\n24 2624\r\n37 2991\r\n24 2884\r\n", "output": "rated\r\n"}, {"input": "2\r\n100 99\r\n100 100\r\n", "output": "rated\r\n"}, {"input": "4\r\n2 2\r\n1 1\r\n1 1\r\n2 2\r\n", "output": "unrated\r\n"}, {"input": "3\r\n100 101\r\n100 100\r\n100 100\r\n", "output": "rated\r\n"}, {"input": "4\r\n1000 1001\r\n900 900\r\n950 950\r\n890 890\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 3\r\n1 1\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 2\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "2\r\n3 2\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n3 2\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "2\r\n1 1\r\n2 2\r\n", "output": "unrated\r\n"}, {"input": "3\r\n3 2\r\n3 3\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "4\r\n1500 1501\r\n1300 1300\r\n1200 1200\r\n1400 1400\r\n", "output": "rated\r\n"}, {"input": "3\r\n1000 1000\r\n500 500\r\n400 300\r\n", "output": "rated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n3000 3000\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1 1\r\n2 3\r\n", "output": "rated\r\n"}, {"input": "2\r\n6 2\r\n6 2\r\n", "output": "rated\r\n"}, {"input": "5\r\n3123 3123\r\n1699 1699\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1500 1500\r\n1600 1600\r\n", "output": "unrated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2241 2241\r\n1699 1699\r\n", "output": "maybe\r\n"}, {"input": "2\r\n20 30\r\n10 5\r\n", "output": "rated\r\n"}, {"input": "3\r\n1 1\r\n2 2\r\n1 1\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1 2\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "5\r\n5 5\r\n4 4\r\n3 3\r\n2 2\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "2\r\n2 2\r\n2 1\r\n", "output": "rated\r\n"}, {"input": "2\r\n100 100\r\n90 89\r\n", "output": "rated\r\n"}, {"input": "2\r\n1000 900\r\n2000 2000\r\n", "output": "rated\r\n"}, {"input": "2\r\n50 10\r\n10 50\r\n", "output": "rated\r\n"}, {"input": "2\r\n200 200\r\n100 100\r\n", "output": "maybe\r\n"}, {"input": "3\r\n2 2\r\n2 2\r\n3 3\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1000 1000\r\n300 300\r\n100 100\r\n", "output": "maybe\r\n"}, {"input": "4\r\n2 2\r\n2 2\r\n3 3\r\n4 4\r\n", "output": "unrated\r\n"}, {"input": "2\r\n5 3\r\n6 3\r\n", "output": "rated\r\n"}, {"input": "2\r\n1200 1100\r\n1200 1000\r\n", "output": "rated\r\n"}, {"input": "2\r\n5 5\r\n4 4\r\n", "output": "maybe\r\n"}, {"input": "2\r\n5 5\r\n3 3\r\n", "output": "maybe\r\n"}, {"input": "5\r\n1500 1500\r\n1300 1300\r\n1200 1200\r\n1400 1400\r\n1100 1100\r\n", "output": "unrated\r\n"}, {"input": "5\r\n10 10\r\n9 9\r\n8 8\r\n7 7\r\n6 6\r\n", "output": "maybe\r\n"}, {"input": "3\r\n1000 1000\r\n300 300\r\n10 10\r\n", "output": "maybe\r\n"}, {"input": "5\r\n6 6\r\n5 5\r\n4 4\r\n3 3\r\n2 2\r\n", "output": "maybe\r\n"}, {"input": "2\r\n3 3\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "4\r\n2 2\r\n2 2\r\n2 2\r\n3 3\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1000 1000\r\n700 700\r\n", "output": "maybe\r\n"}, {"input": "2\r\n4 3\r\n5 3\r\n", "output": "rated\r\n"}, {"input": "2\r\n1000 1000\r\n1100 1100\r\n", "output": "unrated\r\n"}, {"input": "4\r\n5 5\r\n4 4\r\n3 3\r\n2 2\r\n", "output": "maybe\r\n"}, {"input": "3\r\n1 1\r\n2 3\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n1 2\r\n1 3\r\n", "output": "rated\r\n"}, {"input": "2\r\n3 3\r\n1 2\r\n", "output": "rated\r\n"}, {"input": "4\r\n1501 1500\r\n1300 1300\r\n1200 1200\r\n1400 1400\r\n", "output": "rated\r\n"}, {"input": "5\r\n1 1\r\n2 2\r\n3 3\r\n4 4\r\n5 5\r\n", "output": "unrated\r\n"}, {"input": "2\r\n10 10\r\n1 2\r\n", "output": "rated\r\n"}, {"input": "6\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n1699 1699\r\n1900 1900\r\n", "output": "unrated\r\n"}, {"input": "6\r\n3123 3123\r\n2777 2777\r\n3000 3000\r\n2246 2246\r\n2246 2246\r\n1699 1699\r\n", "output": "unrated\r\n"}, {"input": "2\r\n100 100\r\n110 110\r\n", "output": "unrated\r\n"}, {"input": "3\r\n3 3\r\n3 3\r\n4 4\r\n", "output": "unrated\r\n"}, {"input": "3\r\n3 3\r\n3 2\r\n4 4\r\n", "output": "rated\r\n"}, {"input": "3\r\n5 2\r\n4 4\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "4\r\n4 4\r\n3 3\r\n2 2\r\n1 1\r\n", "output": "maybe\r\n"}, {"input": "2\r\n1 1\r\n3 2\r\n", "output": "rated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n2699 2699\r\n", "output": "unrated\r\n"}, {"input": "3\r\n3 3\r\n3 3\r\n3 4\r\n", "output": "rated\r\n"}, {"input": "3\r\n1 2\r\n2 2\r\n3 3\r\n", "output": "rated\r\n"}, {"input": "3\r\n1 2\r\n1 2\r\n1 2\r\n", "output": "rated\r\n"}, {"input": "2\r\n2 1\r\n2 1\r\n", "output": "rated\r\n"}, {"input": "2\r\n1 2\r\n3 4\r\n", "output": "rated\r\n"}, {"input": "2\r\n3 2\r\n2 3\r\n", "output": "rated\r\n"}, {"input": "3\r\n1500 1500\r\n1600 1600\r\n1600 1600\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1 1\r\n3 3\r\n4 4\r\n", "output": "unrated\r\n"}, {"input": "3\r\n1 1\r\n2 2\r\n2 2\r\n", "output": "unrated\r\n"}, {"input": "2\r\n10 12\r\n8 8\r\n", "output": "rated\r\n"}, {"input": "5\r\n1200 1200\r\n1500 1500\r\n1500 1500\r\n1500 1500\r\n1500 1500\r\n", "output": "unrated\r\n"}, {"input": "2\r\n1 2\r\n2 2\r\n", "output": "rated\r\n"}, {"input": "3\r\n1500 1400\r\n1200 1200\r\n1100 1100\r\n", "output": "rated\r\n"}, {"input": "2\r\n10 12\r\n10 10\r\n", "output": "rated\r\n"}, {"input": "3\r\n1500 1500\r\n1400 1400\r\n1300 1300\r\n", "output": "maybe\r\n"}, {"input": "3\r\n3 3\r\n4 4\r\n5 5\r\n", "output": "unrated\r\n"}, {"input": "3\r\n2 6\r\n3 5\r\n4 4\r\n", "output": "rated\r\n"}, {"input": "2\r\n5 6\r\n4 6\r\n", "output": "rated\r\n"}, {"input": "4\r\n10 10\r\n10 10\r\n7 7\r\n8 8\r\n", "output": "unrated\r\n"}, {"input": "2\r\n4 4\r\n3 3\r\n", "output": "maybe\r\n"}]
| false |
stdio
| null | true |
99/B
|
99
|
B
|
PyPy 3-64
|
TESTS
| 62 | 62 | 0 |
228951081
|
n = int(input())
volumes = [int(input()) for _ in range(n)]
total_volume = sum(volumes)
if total_volume % n == 0:
target_volume = total_volume // n
pour_from = None
pour_to = None
for i, volume in enumerate(volumes):
diff = target_volume - volume
if diff > 0:
if pour_from is None:
pour_from = i + 1
else:
print("Unrecoverable configuration.")
break
elif diff < 0:
if pour_to is None:
pour_to = i + 1
else:
print("Unrecoverable configuration.")
break
if pour_from is not None and pour_to is not None:
print(f"{abs(volumes[pour_to - 1] - target_volume)} ml. from cup #{pour_from} to cup #{pour_to}.")
elif pour_from is None and pour_to is None:
print("Exemplary pages.")
else:
print("Unrecoverable configuration.")
| 200 | 124 | 307,200 |
73945356
|
n = int(input())
a = []
sum = 0
for i in range(n):
x = int(input())
sum += x
a.append(x)
ave = sum / n
if int(ave) == ave:
ave = int(ave)
b = set()
cnt = 0
for i in range(n):
if abs(ave - a[i])!=0:
b.add(abs(ave - a[i]))
t = ave - a[i]
if t > 0:
A = i + 1
else:
B = i + 1
cnt += 1
if len(b) == 1 and cnt == 2:
print(str(abs(t)) + " ml. from cup #" + str(A) +" to cup #" + str(B) + ".")
elif len(b) == 0:
print("Exemplary pages.")
else:
print("Unrecoverable configuration.")
else:
print('Unrecoverable configuration.')
|
Codeforces Beta Round 78 (Div. 2 Only)
|
CF
| 2,011 | 0.5 | 256 |
Help Chef Gerasim
|
In a far away kingdom young pages help to set the table for the King. As they are terribly mischievous, one needs to keep an eye on the control whether they have set everything correctly. This time the royal chef Gerasim had the impression that the pages have played a prank again: they had poured the juice from one cup to another. Now Gerasim wants to check his hypothesis. The good thing is that chef Gerasim always pour the same number of milliliters of juice to all cups in the royal kitchen. Having thoroughly measured the juice in each cup, Gerasim asked you to write a program that will determine from which cup juice was poured to which one; otherwise, the program should determine that this time the pages set the table diligently.
To simplify your task we shall consider the cups to be bottomless so that the juice never overfills a cup and pours out, however much it can be. Besides, by some strange reason in a far away kingdom one can only pour to a cup or from one cup to another an integer number of milliliters of juice.
|
The first line contains integer n — the number of cups on the royal table (1 ≤ n ≤ 1000). Next n lines contain volumes of juice in each cup — non-negative integers, not exceeding 104.
|
If the pages didn't pour the juice, print "Exemplary pages." (without the quotes). If you can determine the volume of juice poured during exactly one juice pouring, print "v ml. from cup #a to cup #b." (without the quotes), where v represents the volume of poured juice, a represents the number of the cup from which the juice was poured (the cups are numbered with consecutive positive integers starting from one in the order in which the cups are described in the input data), b represents the number of the cup into which the juice was poured. Finally, if the given juice's volumes cannot be obtained using no more than one pouring (for example, the pages poured the juice from one cup to another more than once or the royal kitchen maids poured the juice into the cups incorrectly), print "Unrecoverable configuration." (without the quotes).
| null | null |
[{"input": "5\n270\n250\n250\n230\n250", "output": "20 ml. from cup #4 to cup #1."}, {"input": "5\n250\n250\n250\n250\n250", "output": "Exemplary pages."}, {"input": "5\n270\n250\n249\n230\n250", "output": "Unrecoverable configuration."}]
| 1,300 |
["implementation", "sortings"]
| 200 |
[{"input": "5\r\n270\r\n250\r\n250\r\n230\r\n250\r\n", "output": "20 ml. from cup #4 to cup #1.\r\n"}, {"input": "5\r\n250\r\n250\r\n250\r\n250\r\n250\r\n", "output": "Exemplary pages.\r\n"}, {"input": "5\r\n270\r\n250\r\n249\r\n230\r\n250\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n200\r\n190\r\n210\r\n200\r\n", "output": "10 ml. from cup #2 to cup #3.\r\n"}, {"input": "4\r\n1\r\n2\r\n3\r\n4\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "1\r\n0\r\n", "output": "Exemplary pages.\r\n"}, {"input": "2\r\n0\r\n0\r\n", "output": "Exemplary pages.\r\n"}, {"input": "2\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "2\r\n0\r\n2\r\n", "output": "1 ml. from cup #1 to cup #2.\r\n"}, {"input": "2\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "2\r\n1\r\n1\r\n", "output": "Exemplary pages.\r\n"}, {"input": "2\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "2\r\n2\r\n0\r\n", "output": "1 ml. from cup #2 to cup #1.\r\n"}, {"input": "2\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "2\r\n2\r\n2\r\n", "output": "Exemplary pages.\r\n"}, {"input": "3\r\n0\r\n0\r\n0\r\n", "output": "Exemplary pages.\r\n"}, {"input": "3\r\n0\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n0\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n0\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n0\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n0\r\n1\r\n2\r\n", "output": "1 ml. from cup #1 to cup #3.\r\n"}, {"input": "3\r\n0\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n0\r\n2\r\n1\r\n", "output": "1 ml. from cup #1 to cup #2.\r\n"}, {"input": "3\r\n0\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n0\r\n2\r\n", "output": "1 ml. from cup #2 to cup #3.\r\n"}, {"input": "3\r\n1\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n1\r\n1\r\n", "output": "Exemplary pages.\r\n"}, {"input": "3\r\n1\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n2\r\n0\r\n", "output": "1 ml. from cup #3 to cup #2.\r\n"}, {"input": "3\r\n1\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n0\r\n1\r\n", "output": "1 ml. from cup #2 to cup #1.\r\n"}, {"input": "3\r\n2\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n1\r\n0\r\n", "output": "1 ml. from cup #3 to cup #1.\r\n"}, {"input": "3\r\n2\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n2\r\n2\r\n", "output": "Exemplary pages.\r\n"}, {"input": "4\r\n0\r\n0\r\n0\r\n0\r\n", "output": "Exemplary pages.\r\n"}, {"input": "4\r\n0\r\n0\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n1\r\n2\r\n", "output": "1 ml. from cup #1 to cup #4.\r\n"}, {"input": "4\r\n0\r\n1\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n2\r\n1\r\n", "output": "1 ml. from cup #1 to cup #3.\r\n"}, {"input": "4\r\n0\r\n1\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n1\r\n1\r\n", "output": "1 ml. from cup #1 to cup #2.\r\n"}, {"input": "4\r\n0\r\n2\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n1\r\n2\r\n", "output": "1 ml. from cup #2 to cup #4.\r\n"}, {"input": "4\r\n1\r\n0\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n2\r\n1\r\n", "output": "1 ml. from cup #2 to cup #3.\r\n"}, {"input": "4\r\n1\r\n0\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n0\r\n2\r\n", "output": "1 ml. from cup #3 to cup #4.\r\n"}, {"input": "4\r\n1\r\n1\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n1\r\n1\r\n", "output": "Exemplary pages.\r\n"}, {"input": "4\r\n1\r\n1\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n2\r\n0\r\n", "output": "1 ml. from cup #4 to cup #3.\r\n"}, {"input": "4\r\n1\r\n1\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n0\r\n1\r\n", "output": "1 ml. from cup #3 to cup #2.\r\n"}, {"input": "4\r\n1\r\n2\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n1\r\n0\r\n", "output": "1 ml. from cup #4 to cup #2.\r\n"}, {"input": "4\r\n1\r\n2\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n1\r\n1\r\n", "output": "1 ml. from cup #2 to cup #1.\r\n"}, {"input": "4\r\n2\r\n0\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n0\r\n1\r\n", "output": "1 ml. from cup #3 to cup #1.\r\n"}, {"input": "4\r\n2\r\n1\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n1\r\n0\r\n", "output": "1 ml. from cup #4 to cup #1.\r\n"}, {"input": "4\r\n2\r\n1\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n2\r\n2\r\n", "output": "Exemplary pages.\r\n"}, {"input": "27\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n2626\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n8572\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n", "output": "2973 ml. from cup #11 to cup #17.\r\n"}, {"input": "19\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n82\r\n5001\r\n9919\r\n5001\r\n5001\r\n", "output": "Unrecoverable configuration.\r\n"}]
| false |
stdio
| null | true |
858/E
|
858
|
E
|
PyPy 3
|
TESTS
| 0 | 61 | 0 |
155070236
|
import sys
input = sys.stdin.buffer.readline
def process(A):
"""
6 options:
1. test is already type 1
and from 1 <= x <= m1
no moves needed.
2. test is type 1
and from m1+1 <= x <= m1+m2
move needed but NOTE
3. test is type 1
and neither.
move needed.
4. test is already type 0
and from m1+1 <= x <= m1+m2
no moves needed.
5. test is already type 0
and from 1 <= x <= m1
move needed but NOTE
6. test is type 0
and neither
move needed.
b+c = m1-a
e+f = m2-d
b <= m2-d
e <= m1-a
"""
tests = [[], []]
answer = []
for a, b in A:
tests[int(b)].append(a)
m1 = len(tests[1])
m2 = len(tests[0])
seen = [0 for i in range(m1+m2+1)]
new1 = []
bad1 = []
for x in tests[1]:
try:
x = int(x)
if 1 <= x <= m1 and seen[x]==0:
seen[x] = 1
elif m1+1 <= x <= m1+m2 and seen[x]==0:
seen[x] = 2
bad1.append(x)
else:
new1.append(x)
except:
new1.append(x)
new2 = []
bad2 = []
for x in tests[0]:
try:
x = int(x)
if m1+1 <= x <= m1+m2 and seen[x]==0:
seen[x] = 1
elif 1 <= x <= m1 and seen[x]==0:
seen[x] = 2
bad2.append(x)
else:
new2.append(x)
except:
new2.append(x)
maybe1 = []
maybe2 = []
for i in range(1, m1+1):
if seen[i]==0:
maybe1.append(i)
for i in range(m1+1, m1+m2+1):
if seen[i]==0:
maybe2.append(i)
while len(new1) > 0 or len(new2) > 0 or len(bad1) > 0 or len(bad2) > 0:
change = False
while (len(bad1) > 0 or len(new1) > 0) and len(maybe1) > 0:
i1 = maybe1.pop()
if True:
if len(new1) > 0:
x = new1.pop()
answer.append(f'move {x} {i1}\n')
change = True
elif len(bad1) > 0:
x = bad1.pop()
answer.append(f'move {x} {i1}\n')
maybe2.append(x)
change = True
while (len(bad2) > 0 or len(new2) > 0) and len(maybe2) > 0:
i1 = maybe2.pop()
if True:
if len(new2) > 0:
x = new2.pop()
answer.append(f'move {x} {i1}\n')
seen[i1] = 1
change = True
elif len(bad2) > 0:
x = bad2.pop()
answer.append(f'move {x} {i1}\n')
seen[i1] = 1
maybe1.append(x)
change = True
if not change:
if len(bad1) > 0:
x = bad1.pop()
answer.append(f'move {x} other\n')
new1.append('other')
maybe2.append(x)
seen[x] = 0
else:
x = bad2.pop()
answer.append(f'move {x} other\n')
new2.append('other')
maybe1.append(x)
seen[x]= 0
# print(seen, new1, new2, bad1, bad2)
sys.stdout.write(f'{len(answer)}\n')
for x in answer:
sys.stdout.write(x)
n = int(input())
A = []
for i in range(n):
a, b = input().decode().rstrip().split()
A.append([a, b])
process(A)
| 165 | 295 | 27,136,000 |
230751905
|
n = int(input())
t = [1] + [0] * n
b, a = d = [], []
h, s = [], []
for i in range(n):
f, k = input().split()
d[int(k)].append(f)
m = len(a)
for i in a:
if i.isdigit() and i[0] != '0':
j = int(i)
if 0 < j <= m:
t[j] = 1
elif m < j <= n:
t[j] = -1
else:
s.append(i)
else:
s.append(i)
for i in b:
if i.isdigit() and i[0] != '0':
j = int(i)
if m < j <= n:
t[j] = 1
elif 0 < j <= m:
t[j] = -1
else:
s.append(i)
else:
s.append(i)
x = [j for j in range(1, m + 1) if t[j] < 0]
y = [j for j in range(m + 1, n + 1) if t[j] < 0]
u = [j for j in range(1, m + 1) if not t[j]]
v = [j for j in range(m + 1, n + 1) if not t[j]]
if not s and (x or y):
s = ['0']
if y:
i = y.pop()
v.append(i)
else:
i = x.pop()
u.append(i)
h.append(str(i) + ' 0')
t[i] = 0
while x or y:
if v and x:
i = x.pop()
j = v.pop()
t[j] = 1
h.append(str(i) + ' ' + str(j))
u.append(i)
else:
u, v, x, y = v, u, y, x
k = 1
for j in s:
while t[k] == 1: k += 1
h.append(j + ' ' + str(k))
k += 1
d = '\nmove '
print(str(len(h)) + d + d.join(h) if h else 0)
|
Технокубок 2018 - Отборочный Раунд 1
|
CF
| 2,017 | 2 | 256 |
Tests Renumeration
|
The All-Berland National Olympiad in Informatics has just ended! Now Vladimir wants to upload the contest from the Olympiad as a gym to a popular Codehorses website.
Unfortunately, the archive with Olympiad's data is a mess. For example, the files with tests are named arbitrary without any logic.
Vladimir wants to rename the files with tests so that their names are distinct integers starting from 1 without any gaps, namely, "1", "2", ..., "n', where n is the total number of tests.
Some of the files contain tests from statements (examples), while others contain regular tests. It is possible that there are no examples, and it is possible that all tests are examples. Vladimir wants to rename the files so that the examples are the first several tests, all all the next files contain regular tests only.
The only operation Vladimir can perform is the "move" command. Vladimir wants to write a script file, each of the lines in which is "move file_1 file_2", that means that the file "file_1" is to be renamed to "file_2". If there is a file "file_2" at the moment of this line being run, then this file is to be rewritten. After the line "move file_1 file_2" the file "file_1" doesn't exist, but there is a file "file_2" with content equal to the content of "file_1" before the "move" command.
Help Vladimir to write the script file with the minimum possible number of lines so that after this script is run:
- all examples are the first several tests having filenames "1", "2", ..., "e", where e is the total number of examples;
- all other files contain regular tests with filenames "e + 1", "e + 2", ..., "n", where n is the total number of all tests.
|
The first line contains single integer n (1 ≤ n ≤ 105) — the number of files with tests.
n lines follow, each describing a file with test. Each line has a form of "name_i type_i", where "name_i" is the filename, and "type_i" equals "1", if the i-th file contains an example test, and "0" if it contains a regular test. Filenames of each file are strings of digits and small English letters with length from 1 to 6 characters. The filenames are guaranteed to be distinct.
|
In the first line print the minimum number of lines in Vladimir's script file.
After that print the script file, each line should be "move file_1 file_2", where "file_1" is an existing at the moment of this line being run filename, and "file_2" — is a string of digits and small English letters with length from 1 to 6.
| null | null |
[{"input": "5\n01 0\n2 1\n2extra 0\n3 1\n99 0", "output": "4\nmove 3 1\nmove 01 5\nmove 2extra 4\nmove 99 3"}, {"input": "2\n1 0\n2 1", "output": "3\nmove 1 3\nmove 2 1\nmove 3 2"}, {"input": "5\n1 0\n11 1\n111 0\n1111 1\n11111 0", "output": "5\nmove 1 5\nmove 11 1\nmove 1111 2\nmove 111 4\nmove 11111 3"}]
| 2,200 |
["greedy", "implementation"]
| 165 |
[{"input": "5\r\n01 0\r\n2 1\r\n2extra 0\r\n3 1\r\n99 0\r\n", "output": "4\r\nmove 3 1\r\nmove 01 5\r\nmove 2extra 4\r\nmove 99 3\r\n"}, {"input": "2\r\n1 0\r\n2 1\r\n", "output": "3\r\nmove 1 dytuig\r\nmove 2 1\r\nmove dytuig 2\r\n"}, {"input": "5\r\n1 0\r\n11 1\r\n111 0\r\n1111 1\r\n11111 0\r\n", "output": "5\r\nmove 1 5\r\nmove 11 1\r\nmove 1111 2\r\nmove 111 4\r\nmove 11111 3\r\n"}, {"input": "4\r\nir7oz8 1\r\nvj4v5t 1\r\nkwkahb 1\r\nj5s8o1 0\r\n", "output": "4\r\nmove ir7oz8 1\r\nmove vj4v5t 2\r\nmove kwkahb 3\r\nmove j5s8o1 4\r\n"}, {"input": "4\r\n3 1\r\n1o0bp2 0\r\n9tn379 0\r\nv04v6j 1\r\n", "output": "4\r\nmove 3 1\r\nmove v04v6j 2\r\nmove 1o0bp2 4\r\nmove 9tn379 3\r\n"}, {"input": "4\r\n1 0\r\nsc7czx 0\r\nfr4033 1\r\n3 0\r\n", "output": "3\r\nmove 1 4\r\nmove fr4033 1\r\nmove sc7czx 2\r\n"}, {"input": "4\r\n4 0\r\n1 0\r\n2 0\r\nizfotg 1\r\n", "output": "2\r\nmove 1 3\r\nmove izfotg 1\r\n"}, {"input": "4\r\n2 0\r\n3 0\r\n1 1\r\n4 1\r\n", "output": "3\r\nmove 2 0b9r8j\r\nmove 4 2\r\nmove 0b9r8j 4\r\n"}, {"input": "5\r\npuusew 1\r\npvoy4h 0\r\nwdzx4r 0\r\n1z84cx 0\r\nozsuvd 0\r\n", "output": "5\r\nmove puusew 1\r\nmove pvoy4h 5\r\nmove wdzx4r 4\r\nmove 1z84cx 3\r\nmove ozsuvd 2\r\n"}, {"input": "5\r\n949pnr 1\r\n9sxhcr 0\r\n5 1\r\nx8srx3 1\r\ncl7ppd 1\r\n", "output": "5\r\nmove 5 1\r\nmove 949pnr 2\r\nmove x8srx3 3\r\nmove cl7ppd 4\r\nmove 9sxhcr 5\r\n"}, {"input": "5\r\n2 0\r\n1 0\r\np2gcxf 1\r\nwfyoiq 1\r\nzjw3vg 1\r\n", "output": "5\r\nmove 2 5\r\nmove 1 4\r\nmove p2gcxf 1\r\nmove wfyoiq 2\r\nmove zjw3vg 3\r\n"}, {"input": "5\r\nogvgi7 0\r\n3 1\r\n4 1\r\n1 1\r\nm5nhux 0\r\n", "output": "3\r\nmove 4 2\r\nmove ogvgi7 5\r\nmove m5nhux 4\r\n"}, {"input": "5\r\nt6kdte 1\r\n2 1\r\n4 1\r\n5 1\r\n3 1\r\n", "output": "1\r\nmove t6kdte 1\r\n"}, {"input": "5\r\n2 0\r\n3 1\r\n4 0\r\n1 1\r\n5 1\r\n", "output": "3\r\nmove 2 p6w7mu\r\nmove 5 2\r\nmove p6w7mu 5\r\n"}, {"input": "1\r\nsd84r7 1\r\n", "output": "1\r\nmove sd84r7 1\r\n"}, {"input": "1\r\n1 0\r\n", "output": "0\r\n"}, {"input": "2\r\n5xzjm4 0\r\njoa6mr 1\r\n", "output": "2\r\nmove joa6mr 1\r\nmove 5xzjm4 2\r\n"}, {"input": "2\r\n1 0\r\nxdkh5a 1\r\n", "output": "2\r\nmove 1 2\r\nmove xdkh5a 1\r\n"}, {"input": "2\r\n1 0\r\n2 0\r\n", "output": "0\r\n"}, {"input": "3\r\nz1nwrd 1\r\nt0xrja 0\r\n106qy1 0\r\n", "output": "3\r\nmove z1nwrd 1\r\nmove t0xrja 3\r\nmove 106qy1 2\r\n"}, {"input": "3\r\nt4hdos 0\r\ndhje0g 0\r\n3 0\r\n", "output": "2\r\nmove t4hdos 2\r\nmove dhje0g 1\r\n"}, {"input": "3\r\n3 0\r\n26mp5s 0\r\n1 1\r\n", "output": "1\r\nmove 26mp5s 2\r\n"}, {"input": "3\r\n2 1\r\n1 0\r\n3 0\r\n", "output": "3\r\nmove 2 1ntx05\r\nmove 1 2\r\nmove 1ntx05 1\r\n"}, {"input": "1\r\nprzvln 0\r\n", "output": "1\r\nmove przvln 1\r\n"}, {"input": "2\r\nkfsipl 0\r\n1jj1ol 0\r\n", "output": "2\r\nmove kfsipl 2\r\nmove 1jj1ol 1\r\n"}, {"input": "3\r\n2x7a4g 0\r\n27lqe6 0\r\nzfo3sp 0\r\n", "output": "3\r\nmove 2x7a4g 3\r\nmove 27lqe6 2\r\nmove zfo3sp 1\r\n"}, {"input": "1\r\nxzp9ni 1\r\n", "output": "1\r\nmove xzp9ni 1\r\n"}, {"input": "1\r\nabbdf7 1\r\n", "output": "1\r\nmove abbdf7 1\r\n"}, {"input": "2\r\ndbif39 1\r\ne8dkf8 0\r\n", "output": "2\r\nmove dbif39 1\r\nmove e8dkf8 2\r\n"}, {"input": "2\r\n2 0\r\njkwekx 1\r\n", "output": "1\r\nmove jkwekx 1\r\n"}, {"input": "3\r\nn3pmj8 0\r\n2alui6 0\r\ne7lf4u 1\r\n", "output": "3\r\nmove e7lf4u 1\r\nmove n3pmj8 3\r\nmove 2alui6 2\r\n"}, {"input": "3\r\ndr1lp8 0\r\n1 0\r\n6a2egk 1\r\n", "output": "3\r\nmove 1 3\r\nmove 6a2egk 1\r\nmove dr1lp8 2\r\n"}, {"input": "4\r\nyi9ta0 1\r\nmeljgm 0\r\nf7bqon 0\r\n5bbvun 0\r\n", "output": "4\r\nmove yi9ta0 1\r\nmove meljgm 4\r\nmove f7bqon 3\r\nmove 5bbvun 2\r\n"}, {"input": "4\r\n0la3gu 0\r\nzhrmyb 1\r\n3iprc0 0\r\n3 0\r\n", "output": "3\r\nmove zhrmyb 1\r\nmove 0la3gu 4\r\nmove 3iprc0 2\r\n"}, {"input": "1\r\n1 1\r\n", "output": "0\r\n"}, {"input": "1\r\n1 1\r\n", "output": "0\r\n"}, {"input": "2\r\n17dgbb 0\r\n2 1\r\n", "output": "2\r\nmove 2 1\r\nmove 17dgbb 2\r\n"}, {"input": "2\r\n1 0\r\n2 1\r\n", "output": "3\r\nmove 1 xrjgjv\r\nmove 2 1\r\nmove xrjgjv 2\r\n"}, {"input": "3\r\nscrn8k 0\r\n3 1\r\nycvm9s 0\r\n", "output": "3\r\nmove 3 1\r\nmove scrn8k 3\r\nmove ycvm9s 2\r\n"}, {"input": "3\r\nt0dfz3 0\r\n3 0\r\n1 1\r\n", "output": "1\r\nmove t0dfz3 2\r\n"}, {"input": "4\r\nkgw83p 0\r\np3p3ch 0\r\n4 1\r\n0te9lv 0\r\n", "output": "4\r\nmove 4 1\r\nmove kgw83p 4\r\nmove p3p3ch 3\r\nmove 0te9lv 2\r\n"}, {"input": "4\r\n3 1\r\nnj94jx 0\r\n3a5ad1 0\r\n1 0\r\n", "output": "4\r\nmove 1 4\r\nmove 3 1\r\nmove nj94jx 3\r\nmove 3a5ad1 2\r\n"}, {"input": "2\r\no9z069 1\r\n5hools 1\r\n", "output": "2\r\nmove o9z069 1\r\nmove 5hools 2\r\n"}, {"input": "2\r\nyzzyab 1\r\n728oq0 1\r\n", "output": "2\r\nmove yzzyab 1\r\nmove 728oq0 2\r\n"}, {"input": "2\r\nqy2kmc 1\r\nqb4crj 1\r\n", "output": "2\r\nmove qy2kmc 1\r\nmove qb4crj 2\r\n"}, {"input": "3\r\nunw560 1\r\n0iswxk 0\r\ndonjp9 1\r\n", "output": "3\r\nmove unw560 1\r\nmove donjp9 2\r\nmove 0iswxk 3\r\n"}, {"input": "3\r\n2 0\r\nuv8c54 1\r\n508bb0 1\r\n", "output": "3\r\nmove 2 3\r\nmove uv8c54 1\r\nmove 508bb0 2\r\n"}, {"input": "3\r\n9afh0z 1\r\n0qcaht 1\r\n3 0\r\n", "output": "2\r\nmove 9afh0z 1\r\nmove 0qcaht 2\r\n"}, {"input": "4\r\n2kk04q 0\r\nkdktvk 1\r\nc4i5k8 1\r\nawaock 0\r\n", "output": "4\r\nmove kdktvk 1\r\nmove c4i5k8 2\r\nmove 2kk04q 4\r\nmove awaock 3\r\n"}, {"input": "4\r\n2 0\r\nmqbjos 0\r\n6mhijg 1\r\n6wum8y 1\r\n", "output": "4\r\nmove 2 4\r\nmove 6mhijg 1\r\nmove 6wum8y 2\r\nmove mqbjos 3\r\n"}, {"input": "4\r\n4 0\r\npa613p 1\r\nuuizq7 1\r\n2 0\r\n", "output": "3\r\nmove 2 3\r\nmove pa613p 1\r\nmove uuizq7 2\r\n"}, {"input": "5\r\nw0g96a 1\r\nv99tdi 0\r\nmywrle 0\r\nweh22w 1\r\n9hywt4 0\r\n", "output": "5\r\nmove w0g96a 1\r\nmove weh22w 2\r\nmove v99tdi 5\r\nmove mywrle 4\r\nmove 9hywt4 3\r\n"}, {"input": "5\r\n5 0\r\n12qcjd 1\r\nuthzbz 0\r\nb3670z 0\r\nl2u93o 1\r\n", "output": "4\r\nmove 12qcjd 1\r\nmove l2u93o 2\r\nmove uthzbz 4\r\nmove b3670z 3\r\n"}, {"input": "5\r\n0jc7xb 1\r\n2 0\r\n1m7l9s 0\r\n9xzkau 1\r\n1 0\r\n", "output": "5\r\nmove 2 5\r\nmove 1 4\r\nmove 0jc7xb 1\r\nmove 9xzkau 2\r\nmove 1m7l9s 3\r\n"}, {"input": "2\r\n1 1\r\nvinxur 1\r\n", "output": "1\r\nmove vinxur 2\r\n"}, {"input": "2\r\n1qe46n 1\r\n1 1\r\n", "output": "1\r\nmove 1qe46n 2\r\n"}, {"input": "2\r\n1 1\r\ng5jlzp 1\r\n", "output": "1\r\nmove g5jlzp 2\r\n"}, {"input": "3\r\nc8p28p 1\r\n2 1\r\nvk4gdf 0\r\n", "output": "2\r\nmove c8p28p 1\r\nmove vk4gdf 3\r\n"}, {"input": "3\r\n2 1\r\n3 0\r\nhs9j9t 1\r\n", "output": "1\r\nmove hs9j9t 1\r\n"}, {"input": "3\r\n2 1\r\n1 0\r\nomitxh 1\r\n", "output": "2\r\nmove 1 3\r\nmove omitxh 1\r\n"}, {"input": "4\r\n4 1\r\nu9do88 1\r\n787at9 0\r\nfcud6k 0\r\n", "output": "4\r\nmove 4 1\r\nmove u9do88 2\r\nmove 787at9 4\r\nmove fcud6k 3\r\n"}, {"input": "4\r\n3 0\r\nqvw4ow 1\r\nne0ng9 0\r\n1 1\r\n", "output": "2\r\nmove qvw4ow 2\r\nmove ne0ng9 4\r\n"}, {"input": "4\r\ng6ugrm 1\r\n1 1\r\n3 0\r\n2 0\r\n", "output": "2\r\nmove 2 4\r\nmove g6ugrm 2\r\n"}, {"input": "5\r\n5 1\r\nz9zr7d 0\r\ne8rwo4 1\r\nrfpjp6 0\r\ngz6dhj 0\r\n", "output": "5\r\nmove 5 1\r\nmove e8rwo4 2\r\nmove z9zr7d 5\r\nmove rfpjp6 4\r\nmove gz6dhj 3\r\n"}, {"input": "5\r\n5sn77g 0\r\nsetddt 1\r\nbz16cb 0\r\n4 1\r\n2 0\r\n", "output": "5\r\nmove 4 1\r\nmove 2 5\r\nmove setddt 2\r\nmove 5sn77g 4\r\nmove bz16cb 3\r\n"}, {"input": "5\r\n1 1\r\nx2miqh 1\r\n3 0\r\n2 0\r\n1rq643 0\r\n", "output": "3\r\nmove 2 5\r\nmove x2miqh 2\r\nmove 1rq643 4\r\n"}, {"input": "2\r\n1 1\r\n2 1\r\n", "output": "0\r\n"}, {"input": "2\r\n1 1\r\n2 1\r\n", "output": "0\r\n"}, {"input": "2\r\n2 1\r\n1 1\r\n", "output": "0\r\n"}, {"input": "3\r\n3 1\r\nav5vex 0\r\n1 1\r\n", "output": "2\r\nmove 3 2\r\nmove av5vex 3\r\n"}, {"input": "3\r\n3 1\r\n1 0\r\n2 1\r\n", "output": "3\r\nmove 3 fopgrb\r\nmove 1 3\r\nmove fopgrb 1\r\n"}, {"input": "3\r\n3 1\r\n1 0\r\n2 1\r\n", "output": "3\r\nmove 3 wzgsm0\r\nmove 1 3\r\nmove wzgsm0 1\r\n"}, {"input": "4\r\ny9144q 0\r\n3 1\r\n2 1\r\ns0bdnf 0\r\n", "output": "3\r\nmove 3 1\r\nmove y9144q 4\r\nmove s0bdnf 3\r\n"}, {"input": "4\r\n4 1\r\n1 0\r\n3 1\r\nmod9zl 0\r\n", "output": "4\r\nmove 4 2\r\nmove 1 4\r\nmove 3 1\r\nmove mod9zl 3\r\n"}, {"input": "4\r\n4 1\r\n3 1\r\n1 0\r\n2 0\r\n", "output": "5\r\nmove 4 ow3q4a\r\nmove 1 4\r\nmove 3 1\r\nmove 2 3\r\nmove ow3q4a 2\r\n"}, {"input": "5\r\n1 1\r\nnoidnv 0\r\n3 1\r\nx3xiiz 0\r\n1lfa9v 0\r\n", "output": "4\r\nmove 3 2\r\nmove noidnv 5\r\nmove x3xiiz 4\r\nmove 1lfa9v 3\r\n"}, {"input": "5\r\n1 1\r\nvsyajx 0\r\n783b38 0\r\n4 0\r\n2 1\r\n", "output": "2\r\nmove vsyajx 5\r\nmove 783b38 3\r\n"}, {"input": "5\r\n3 1\r\n5 0\r\ncvfl8i 0\r\n4 1\r\n2 0\r\n", "output": "4\r\nmove 3 1\r\nmove 2 3\r\nmove 4 2\r\nmove cvfl8i 4\r\n"}, {"input": "3\r\nbxo0pe 1\r\nbt50pa 1\r\n2tx68t 1\r\n", "output": "3\r\nmove bxo0pe 1\r\nmove bt50pa 2\r\nmove 2tx68t 3\r\n"}, {"input": "3\r\nj9rnac 1\r\noetwfz 1\r\nd6n3ww 1\r\n", "output": "3\r\nmove j9rnac 1\r\nmove oetwfz 2\r\nmove d6n3ww 3\r\n"}, {"input": "3\r\naf2f6j 1\r\nmjni5l 1\r\njvyxgc 1\r\n", "output": "3\r\nmove af2f6j 1\r\nmove mjni5l 2\r\nmove jvyxgc 3\r\n"}, {"input": "3\r\nr2qlj2 1\r\nt8wf1y 1\r\nigids8 1\r\n", "output": "3\r\nmove r2qlj2 1\r\nmove t8wf1y 2\r\nmove igids8 3\r\n"}, {"input": "4\r\nuilh9a 0\r\n4lxxh9 1\r\nkqdpzy 1\r\nn1d7hd 1\r\n", "output": "4\r\nmove 4lxxh9 1\r\nmove kqdpzy 2\r\nmove n1d7hd 3\r\nmove uilh9a 4\r\n"}, {"input": "4\r\n3 0\r\niipymv 1\r\nvakd5b 1\r\n2ktczv 1\r\n", "output": "4\r\nmove 3 4\r\nmove iipymv 1\r\nmove vakd5b 2\r\nmove 2ktczv 3\r\n"}, {"input": "4\r\nq4b449 1\r\n3 0\r\ncjg1x2 1\r\ne878er 1\r\n", "output": "4\r\nmove 3 4\r\nmove q4b449 1\r\nmove cjg1x2 2\r\nmove e878er 3\r\n"}, {"input": "4\r\n9f4aoa 1\r\n4 0\r\nf4m1ec 1\r\nqyr2h6 1\r\n", "output": "3\r\nmove 9f4aoa 1\r\nmove f4m1ec 2\r\nmove qyr2h6 3\r\n"}, {"input": "5\r\n73s1nt 1\r\nsbngv2 0\r\n4n3qri 1\r\nbyhzp8 1\r\nadpjs4 0\r\n", "output": "5\r\nmove 73s1nt 1\r\nmove 4n3qri 2\r\nmove byhzp8 3\r\nmove sbngv2 5\r\nmove adpjs4 4\r\n"}, {"input": "5\r\n7ajg8o 1\r\np7cqxy 1\r\n3qrp34 0\r\nh93m07 1\r\n2 0\r\n", "output": "5\r\nmove 2 5\r\nmove 7ajg8o 1\r\nmove p7cqxy 2\r\nmove h93m07 3\r\nmove 3qrp34 4\r\n"}, {"input": "5\r\ny0wnwz 1\r\n5 0\r\n0totai 1\r\n1 0\r\nym8xwz 1\r\n", "output": "4\r\nmove 1 4\r\nmove y0wnwz 1\r\nmove 0totai 2\r\nmove ym8xwz 3\r\n"}, {"input": "5\r\n5 0\r\n4 0\r\n5nvzu4 1\r\nvkpzzk 1\r\nzamzcz 1\r\n", "output": "3\r\nmove 5nvzu4 1\r\nmove vkpzzk 2\r\nmove zamzcz 3\r\n"}, {"input": "6\r\np1wjw9 1\r\nueksby 0\r\nu1ixfc 1\r\nj3lk2e 1\r\n36iskv 0\r\n9imqi1 0\r\n", "output": "6\r\nmove p1wjw9 1\r\nmove u1ixfc 2\r\nmove j3lk2e 3\r\nmove ueksby 6\r\nmove 36iskv 5\r\nmove 9imqi1 4\r\n"}, {"input": "6\r\n6slonw 1\r\nptk9mc 1\r\n57a4nq 0\r\nhiq2f7 1\r\n2 0\r\nc0gtv3 0\r\n", "output": "6\r\nmove 2 6\r\nmove 6slonw 1\r\nmove ptk9mc 2\r\nmove hiq2f7 3\r\nmove 57a4nq 5\r\nmove c0gtv3 4\r\n"}, {"input": "6\r\n5 0\r\n2 0\r\ncbhvyf 1\r\nl1z5mg 0\r\nwkwhby 1\r\nx7fdh9 1\r\n", "output": "5\r\nmove 2 6\r\nmove cbhvyf 1\r\nmove wkwhby 2\r\nmove x7fdh9 3\r\nmove l1z5mg 4\r\n"}, {"input": "6\r\n1t68ks 1\r\npkbj1g 1\r\n5 0\r\n5pw8wm 1\r\n1 0\r\n4 0\r\n", "output": "4\r\nmove 1 6\r\nmove 1t68ks 1\r\nmove pkbj1g 2\r\nmove 5pw8wm 3\r\n"}, {"input": "3\r\n1 1\r\n7ph5fw 1\r\ntfxz1j 1\r\n", "output": "2\r\nmove 7ph5fw 2\r\nmove tfxz1j 3\r\n"}, {"input": "3\r\norwsz0 1\r\nmbt097 1\r\n3 1\r\n", "output": "2\r\nmove orwsz0 1\r\nmove mbt097 2\r\n"}, {"input": "3\r\n1 1\r\nzwfnx2 1\r\n7g8t6z 1\r\n", "output": "2\r\nmove zwfnx2 2\r\nmove 7g8t6z 3\r\n"}, {"input": "3\r\nqmf7iz 1\r\ndjwdce 1\r\n1 1\r\n", "output": "2\r\nmove qmf7iz 2\r\nmove djwdce 3\r\n"}, {"input": "4\r\n4i2i2a 0\r\n4 1\r\npf618n 1\r\nlx6nmh 1\r\n", "output": "4\r\nmove 4 1\r\nmove pf618n 2\r\nmove lx6nmh 3\r\nmove 4i2i2a 4\r\n"}, {"input": "4\r\nxpteku 1\r\n1 0\r\n4 1\r\n73xpqz 1\r\n", "output": "4\r\nmove 4 2\r\nmove 1 4\r\nmove xpteku 1\r\nmove 73xpqz 3\r\n"}, {"input": "4\r\n1wp56i 1\r\n2 1\r\n1 0\r\n6m76jb 1\r\n", "output": "3\r\nmove 1 4\r\nmove 1wp56i 1\r\nmove 6m76jb 3\r\n"}, {"input": "4\r\n3 1\r\nyumiqt 1\r\n1 0\r\nt19jus 1\r\n", "output": "3\r\nmove 1 4\r\nmove yumiqt 1\r\nmove t19jus 2\r\n"}, {"input": "5\r\nynagvf 1\r\n3 1\r\nojz4mm 1\r\ndovec3 0\r\nnc1jye 0\r\n", "output": "4\r\nmove ynagvf 1\r\nmove ojz4mm 2\r\nmove dovec3 5\r\nmove nc1jye 4\r\n"}, {"input": "5\r\n5 1\r\nwje9ts 1\r\nkytn5q 1\r\n7frk8z 0\r\n3 0\r\n", "output": "5\r\nmove 5 1\r\nmove 3 5\r\nmove wje9ts 2\r\nmove kytn5q 3\r\nmove 7frk8z 4\r\n"}, {"input": "5\r\n1 0\r\n4 1\r\n3 0\r\nlog9cm 1\r\nu5m0ls 1\r\n", "output": "5\r\nmove 4 2\r\nmove 1 5\r\nmove 3 4\r\nmove log9cm 1\r\nmove u5m0ls 3\r\n"}, {"input": "5\r\nh015vv 1\r\n3 1\r\n1 0\r\n9w2keb 1\r\n2 0\r\n", "output": "4\r\nmove 1 5\r\nmove 2 4\r\nmove h015vv 1\r\nmove 9w2keb 2\r\n"}, {"input": "6\r\n0zluka 0\r\nqp7q8l 1\r\nwglqu8 1\r\n9i7kta 0\r\nnwf8m3 0\r\n3 1\r\n", "output": "5\r\nmove qp7q8l 1\r\nmove wglqu8 2\r\nmove 0zluka 6\r\nmove 9i7kta 5\r\nmove nwf8m3 4\r\n"}, {"input": "6\r\n3 1\r\n1h3t85 1\r\n5 0\r\nrf2ikt 0\r\n3vhl6e 1\r\n5l3oka 0\r\n", "output": "4\r\nmove 1h3t85 1\r\nmove 3vhl6e 2\r\nmove rf2ikt 6\r\nmove 5l3oka 4\r\n"}, {"input": "6\r\n2 0\r\n3 0\r\nw9h0pv 1\r\n5 1\r\nq92z4i 0\r\n6qb4ia 1\r\n", "output": "6\r\nmove 5 1\r\nmove 2 6\r\nmove 3 5\r\nmove w9h0pv 2\r\nmove 6qb4ia 3\r\nmove q92z4i 4\r\n"}, {"input": "6\r\n4 1\r\n410jiy 1\r\n1 0\r\n6 0\r\nxc98l2 1\r\n5 0\r\n", "output": "4\r\nmove 4 2\r\nmove 1 4\r\nmove 410jiy 1\r\nmove xc98l2 3\r\n"}, {"input": "3\r\n1 1\r\nc9qyld 1\r\n3 1\r\n", "output": "1\r\nmove c9qyld 2\r\n"}, {"input": "3\r\ngdm5ri 1\r\n1 1\r\n2 1\r\n", "output": "1\r\nmove gdm5ri 3\r\n"}, {"input": "3\r\n3 1\r\n2 1\r\ni19lnk 1\r\n", "output": "1\r\nmove i19lnk 1\r\n"}, {"input": "3\r\ncxbbpd 1\r\n3 1\r\n1 1\r\n", "output": "1\r\nmove cxbbpd 2\r\n"}, {"input": "4\r\nwy6i6o 0\r\n1 1\r\n3 1\r\niy1dq6 1\r\n", "output": "2\r\nmove iy1dq6 2\r\nmove wy6i6o 4\r\n"}, {"input": "4\r\n4 1\r\nwgh8s0 1\r\n1 0\r\n2 1\r\n", "output": "3\r\nmove 4 3\r\nmove 1 4\r\nmove wgh8s0 1\r\n"}, {"input": "4\r\nhex0ur 1\r\n4 1\r\n3 0\r\n2 1\r\n", "output": "3\r\nmove 4 1\r\nmove 3 4\r\nmove hex0ur 3\r\n"}, {"input": "4\r\n4 1\r\n1 1\r\n3 0\r\n4soxj3 1\r\n", "output": "3\r\nmove 4 2\r\nmove 3 4\r\nmove 4soxj3 3\r\n"}, {"input": "5\r\n5sbtul 1\r\n2 1\r\n8i2duz 0\r\n5 1\r\n4b85z6 0\r\n", "output": "4\r\nmove 5 1\r\nmove 5sbtul 3\r\nmove 8i2duz 5\r\nmove 4b85z6 4\r\n"}, {"input": "5\r\n3 1\r\n4 0\r\nejo0a4 1\r\ngqzdbk 0\r\n1 1\r\n", "output": "2\r\nmove ejo0a4 2\r\nmove gqzdbk 5\r\n"}, {"input": "5\r\n2y4agr 1\r\n5 0\r\n3 0\r\n1 1\r\n4 1\r\n", "output": "3\r\nmove 4 2\r\nmove 3 4\r\nmove 2y4agr 3\r\n"}, {"input": "5\r\n2 0\r\n1 1\r\nq4hyeg 1\r\n5 0\r\n4 1\r\n", "output": "3\r\nmove 4 3\r\nmove 2 4\r\nmove q4hyeg 2\r\n"}, {"input": "6\r\n5 1\r\nrdm6fu 0\r\n4 1\r\noclx1h 0\r\n7l3kg1 1\r\nq25te0 0\r\n", "output": "6\r\nmove 5 1\r\nmove 4 2\r\nmove 7l3kg1 3\r\nmove rdm6fu 6\r\nmove oclx1h 5\r\nmove q25te0 4\r\n"}, {"input": "6\r\n1 0\r\np4tuyt 0\r\n5 1\r\n2 1\r\nwrrcmu 1\r\n3r4wqz 0\r\n", "output": "5\r\nmove 5 3\r\nmove 1 6\r\nmove wrrcmu 1\r\nmove p4tuyt 5\r\nmove 3r4wqz 4\r\n"}, {"input": "6\r\n5 1\r\n6 0\r\nxhfzge 0\r\n3 1\r\n1 0\r\n1n9mqv 1\r\n", "output": "4\r\nmove 5 2\r\nmove 1 5\r\nmove 1n9mqv 1\r\nmove xhfzge 4\r\n"}, {"input": "6\r\nhmpfsz 1\r\n6 0\r\n5 1\r\n4 0\r\n1 0\r\n3 1\r\n", "output": "3\r\nmove 5 2\r\nmove 1 5\r\nmove hmpfsz 1\r\n"}, {"input": "3\r\n1 1\r\n3 1\r\n2 1\r\n", "output": "0\r\n"}, {"input": "3\r\n2 1\r\n3 1\r\n1 1\r\n", "output": "0\r\n"}, {"input": "3\r\n2 1\r\n1 1\r\n3 1\r\n", "output": "0\r\n"}, {"input": "3\r\n1 1\r\n2 1\r\n3 1\r\n", "output": "0\r\n"}, {"input": "4\r\n3 1\r\n1 1\r\n4 1\r\nd1cks2 0\r\n", "output": "2\r\nmove 4 2\r\nmove d1cks2 4\r\n"}, {"input": "4\r\n4 0\r\n3 1\r\n1 1\r\n2 1\r\n", "output": "0\r\n"}, {"input": "4\r\n2 1\r\n4 1\r\n1 0\r\n3 1\r\n", "output": "3\r\nmove 4 e15gvb\r\nmove 1 4\r\nmove e15gvb 1\r\n"}, {"input": "4\r\n4 1\r\n1 1\r\n3 1\r\n2 0\r\n", "output": "3\r\nmove 4 7l41cc\r\nmove 2 4\r\nmove 7l41cc 2\r\n"}, {"input": "5\r\n4 1\r\nhvshea 0\r\naio11n 0\r\n2 1\r\n3 1\r\n", "output": "3\r\nmove 4 1\r\nmove hvshea 5\r\nmove aio11n 4\r\n"}, {"input": "5\r\n5 0\r\nts7a1c 0\r\n4 1\r\n1 1\r\n2 1\r\n", "output": "2\r\nmove 4 3\r\nmove ts7a1c 4\r\n"}, {"input": "5\r\n4 0\r\n3 1\r\n5 0\r\n2 1\r\n1 1\r\n", "output": "0\r\n"}, {"input": "5\r\n3 1\r\n5 0\r\n4 1\r\n1 1\r\n2 0\r\n", "output": "3\r\nmove 4 kmnhgt\r\nmove 2 4\r\nmove kmnhgt 2\r\n"}, {"input": "6\r\neik3kw 0\r\n5 1\r\nzoonoj 0\r\n2 1\r\n1 1\r\nivzfie 0\r\n", "output": "4\r\nmove 5 3\r\nmove eik3kw 6\r\nmove zoonoj 5\r\nmove ivzfie 4\r\n"}, {"input": "6\r\n7igwk9 0\r\n6 1\r\n5 1\r\ndx2yu0 0\r\n2 0\r\n1 1\r\n", "output": "5\r\nmove 6 3\r\nmove 2 6\r\nmove 5 2\r\nmove 7igwk9 5\r\nmove dx2yu0 4\r\n"}, {"input": "6\r\nc3py3h 0\r\n2 1\r\n4 0\r\n3 0\r\n1 1\r\n5 1\r\n", "output": "3\r\nmove 3 6\r\nmove 5 3\r\nmove c3py3h 5\r\n"}, {"input": "6\r\n1 1\r\n3 0\r\n2 1\r\n6 1\r\n4 0\r\n5 0\r\n", "output": "3\r\nmove 3 4r6zp7\r\nmove 6 3\r\nmove 4r6zp7 6\r\n"}, {"input": "20\r\nphp8vy 1\r\nkeeona 0\r\n8 0\r\nwzf4eb 0\r\n16 1\r\n9 0\r\nf2548d 0\r\n11 0\r\nyszsig 0\r\nyyf4q2 0\r\n1pon1p 1\r\njvpwuo 0\r\nd9stsx 0\r\ne14bkx 1\r\n5 0\r\n17 0\r\nsbklx4 0\r\nsfms2u 1\r\n6 0\r\n18 1\r\n", "output": "16\r\nmove 16 1\r\nmove 18 2\r\nmove 5 20\r\nmove 6 19\r\nmove php8vy 3\r\nmove 1pon1p 4\r\nmove e14bkx 5\r\nmove sfms2u 6\r\nmove keeona 18\r\nmove wzf4eb 16\r\nmove f2548d 15\r\nmove yszsig 14\r\nmove yyf4q2 13\r\nmove jvpwuo 12\r\nmove d9stsx 10\r\nmove sbklx4 7\r\n"}, {"input": "4\r\n3 1\r\n4 1\r\n1 0\r\n2 0\r\n", "output": "5\r\nmove 3 41nqph\r\nmove 1 3\r\nmove 4 1\r\nmove 2 4\r\nmove 41nqph 2\r\n"}, {"input": "1\r\n01 1\r\n", "output": "1\r\nmove 01 1\r\n"}, {"input": "2\r\n01 0\r\n02 1\r\n", "output": "2\r\nmove 02 1\r\nmove 01 2\r\n"}]
| false |
stdio
|
import sys
def main():
input_path = sys.argv[1]
output_path = sys.argv[2]
submission_path = sys.argv[3]
with open(input_path) as f:
n = int(f.readline())
files = []
type1_count = 0
for _ in range(n):
line = f.readline().strip()
name, typ = line.split()
files.append((name, typ))
if typ == '1':
type1_count += 1
e = type1_count
cnt = 0
valid_numbers = set()
for name, typ in files:
if name.isdigit() and (len(name) == 1 or name[0] != '0'):
num = int(name)
if 1 <= num <= n:
valid_numbers.add(num)
if typ == '1':
if not name.isdigit() or (len(name) > 1 and name[0] == '0'):
cnt += 1
continue
num = int(name)
if not (1 <= num <= e):
cnt += 1
else:
if not name.isdigit() or (len(name) > 1 and name[0] == '0'):
cnt += 1
continue
num = int(name)
if not (e + 1 <= num <= n):
cnt += 1
initial_free = n - len(valid_numbers)
minimal_steps = cnt + 1 if (initial_free == 0 and cnt > 0) else cnt
with open(submission_path) as f:
lines = f.read().splitlines()
if not lines:
print(0)
return
try:
k = int(lines[0])
except:
print(0)
return
if k != minimal_steps:
print(0)
return
moves = lines[1:]
if len(moves) != k:
print(0)
return
current_files = {name: typ for name, typ in files}
for move in moves:
parts = move.split()
if len(parts) != 3 or parts[0] != 'move':
print(0)
return
src, dst = parts[1], parts[2]
if src not in current_files:
print(0)
return
typ = current_files.pop(src)
current_files[dst] = typ
names = list(current_files.keys())
if len(names) != n:
print(0)
return
nums = []
for name in names:
if not name.isdigit() or (len(name) > 1 and name[0] == '0'):
print(0)
return
num = int(name)
if num < 1 or num > n:
print(0)
return
nums.append(num)
if sorted(nums) != list(range(1, n + 1)):
print(0)
return
for name, typ in current_files.items():
num = int(name)
if typ == '1' and num > e:
print(0)
return
if typ == '0' and num <= e:
print(0)
return
print(1)
if __name__ == "__main__":
main()
| true |
792/C
|
792
|
C
|
Python 3
|
TESTS
| 28 | 93 | 5,734,400 |
25896525
|
def sumstr(s):
sums = 0
for i in range(len(s)):
sums += int(s[i])
return sums
def mod3(s):
sums = sumstr(s)
return sums % 3
def onlyzeros(s):
i = 0
while i < len(s):
if s[i] != '0':
return False
i += 1
return True
def lastin(s, s1):
maxf = -1
#d = '-'
for d in s1:
f = s.find(d)
if f > maxf:
maxf = f
return maxf
def del1(s, s1):
if s[0] == '-':
return '-'
maxf = lastin(s, s1)
if maxf != -1:
#found digit
if maxf != 0:
#not first or can del first
ret = s[:maxf]
if maxf + 1 < len(s):
ret = ret + s[maxf + 1:]
return ret
elif len(s) > 1 and s[1] != '0':
return s[1:]
elif len(s) == 1:
return '-'
else:
ind = 1
while ind < len(s) and s[ind] == '0':
ind += 1
if ind == len(s):
return '0'
else:
return s[ind:]
else:
return '-'
s = input()
m3 = mod3(s)
if m3 == 0:
print(s)
elif m3 == 1:
var1 = del1(s, '147')
var2 = del1(del1(s, '258'), '258')
l1 = len(var1)
l2 = len(var2)
if l1 > l2:
#not -
#print('v1')
print(var1)
elif l2 > l1:
#print('v2')
print(var2)
else:
#eq
if var1[0] != '-':
print(var1)
elif var2[0] != '-':
print(var2)
else:
print(-1)
elif m3 == 2:
var1 = del1(s, '258')
var2 = del1(del1(s, '147'), '147')
l1 = len(var1)
l2 = len(var2)
if l1 > l2:
#not -
print(var1)
elif l2 > l1:
print(var2)
else:
#eq
if var1[0] != '-':
print(var1)
elif var2[0] != '-':
print(var2)
else:
print(-1)
| 162 | 140 | 28,262,400 |
32921730
|
def f(t):
i, n = 0, len(t) - 1
while i < n and t[i] == '0': i += 1
return t[i:]
t = input()
n = len(t) - 1
p = [int(q) % 3 for q in t][::-1]
s = sum(p) % 3
if s == 0:
print(t)
exit()
u = v = ''
if s in p:
i = n - p.index(s)
u = f(t[:i] + t[i + 1:])
s = 3 - s
if p.count(s) > 1:
i = n - p.index(s)
j = n - p.index(s, n - i + 1)
v = f(t[:j] + t[j + 1:i] + t[i + 1:])
t = u if len(u) > len(v) else v
print(t if t else -1)
|
Educational Codeforces Round 18
|
ICPC
| 2,017 | 1 | 256 |
Divide by Three
|
A positive integer number n is written on a blackboard. It consists of not more than 105 digits. You have to transform it into a beautiful number by erasing some of the digits, and you want to erase as few digits as possible.
The number is called beautiful if it consists of at least one digit, doesn't have leading zeroes and is a multiple of 3. For example, 0, 99, 10110 are beautiful numbers, and 00, 03, 122 are not.
Write a program which for the given n will find a beautiful number such that n can be transformed into this number by erasing as few digits as possible. You can erase an arbitraty set of digits. For example, they don't have to go one after another in the number n.
If it's impossible to obtain a beautiful number, print -1. If there are multiple answers, print any of them.
|
The first line of input contains n — a positive integer number without leading zeroes (1 ≤ n < 10100000).
|
Print one number — any beautiful number obtained by erasing as few as possible digits. If there is no answer, print - 1.
| null |
In the first example it is enough to erase only the first digit to obtain a multiple of 3. But if we erase the first digit, then we obtain a number with a leading zero. So the minimum number of digits to be erased is two.
|
[{"input": "1033", "output": "33"}, {"input": "10", "output": "0"}, {"input": "11", "output": "-1"}]
| 2,000 |
["dp", "greedy", "math", "number theory"]
| 162 |
[{"input": "1033\r\n", "output": "33\r\n"}, {"input": "10\r\n", "output": "0\r\n"}, {"input": "11\r\n", "output": "-1\r\n"}, {"input": "3\r\n", "output": "3\r\n"}, {"input": "1\r\n", "output": "-1\r\n"}, {"input": "117\r\n", "output": "117\r\n"}, {"input": "518\r\n", "output": "18\r\n"}, {"input": "327\r\n", "output": "327\r\n"}, {"input": "270461\r\n", "output": "70461\r\n"}, {"input": "609209\r\n", "output": "60909\r\n"}, {"input": "110930\r\n", "output": "930\r\n"}, {"input": "37616145150713688775\r\n", "output": "3616145150713688775\r\n"}, {"input": "98509135612114839419\r\n", "output": "9509135612114839419\r\n"}, {"input": "41674994051436988162\r\n", "output": "1674994051436988162\r\n"}, {"input": "82547062721736129804\r\n", "output": "82547062721736129804\r\n"}, {"input": "4902501252475186372406731932548506197390793597574544727433297197476846519276598727359617092494798814\r\n", "output": "490501252475186372406731932548506197390793597574544727433297197476846519276598727359617092494798814\r\n"}, {"input": "1291007209605301446874998623691572528836214969878676835460982410817526074579818247646933326771899122\r\n", "output": "1291007209605301446874998623691572528836214969878676835460982410817526074579818247646933326771899122\r\n"}, {"input": "5388306043547446322173224045662327678394712363272776811399689704247387317165308057863239568137902157\r\n", "output": "538830603547446322173224045662327678394712363272776811399689704247387317165308057863239568137902157\r\n"}, {"input": "20000111\r\n", "output": "200001\r\n"}, {"input": "100222\r\n", "output": "1002\r\n"}, {"input": "202\r\n", "output": "0\r\n"}, {"input": "100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000033\r\n", "output": "33\r\n"}, {"input": "101\r\n", "output": "0\r\n"}, {"input": "1000000222\r\n", "output": "10000002\r\n"}, {"input": "1001\r\n", "output": "0\r\n"}, {"input": "205\r\n", "output": "0\r\n"}, {"input": "102211\r\n", "output": "10221\r\n"}, {"input": "100000002022\r\n", "output": "1000000002\r\n"}, {"input": "20203\r\n", "output": "3\r\n"}, {"input": "1002001\r\n", "output": "100200\r\n"}, {"input": "10002223\r\n", "output": "100023\r\n"}, {"input": "1002223\r\n", "output": "10023\r\n"}, {"input": "100000231\r\n", "output": "10000023\r\n"}, {"input": "220\r\n", "output": "0\r\n"}, {"input": "322\r\n", "output": "3\r\n"}, {"input": "100000222\r\n", "output": "1000002\r\n"}, {"input": "10033\r\n", "output": "33\r\n"}, {"input": "2003302\r\n", "output": "330\r\n"}, {"input": "10011001\r\n", "output": "1001001\r\n"}, {"input": "20000000011001111\r\n", "output": "200000000001111\r\n"}, {"input": "100000000\r\n", "output": "0\r\n"}, {"input": "1000\r\n", "output": "0\r\n"}, {"input": "200000000000000000000000000008\r\n", "output": "0\r\n"}, {"input": "1000000000000222\r\n", "output": "10000000000002\r\n"}, {"input": "100000000000000000222\r\n", "output": "1000000000000000002\r\n"}, {"input": "29512\r\n", "output": "2952\r\n"}, {"input": "88888888888888\r\n", "output": "888888888888\r\n"}, {"input": "100000000000222\r\n", "output": "1000000000002\r\n"}, {"input": "11000000\r\n", "output": "0\r\n"}, {"input": "2200\r\n", "output": "0\r\n"}, {"input": "10000555\r\n", "output": "100005\r\n"}, {"input": "1000222\r\n", "output": "10002\r\n"}, {"input": "10021\r\n", "output": "1002\r\n"}, {"input": "223\r\n", "output": "3\r\n"}, {"input": "1013\r\n", "output": "3\r\n"}, {"input": "100020001\r\n", "output": "10002000\r\n"}, {"input": "20000000000000000000932\r\n", "output": "93\r\n"}, {"input": "1010\r\n", "output": "0\r\n"}, {"input": "2000000002222\r\n", "output": "20000000022\r\n"}, {"input": "10213\r\n", "output": "1023\r\n"}, {"input": "109111\r\n", "output": "10911\r\n"}, {"input": "1010101010\r\n", "output": "10001010\r\n"}, {"input": "300055\r\n", "output": "3000\r\n"}, {"input": "200200\r\n", "output": "0\r\n"}, {"input": "202222\r\n", "output": "2022\r\n"}, {"input": "4000888\r\n", "output": "40008\r\n"}, {"input": "200000111\r\n", "output": "2000001\r\n"}, {"input": "2000000111\r\n", "output": "20000001\r\n"}, {"input": "1000000\r\n", "output": "0\r\n"}, {"input": "1003301\r\n", "output": "330\r\n"}, {"input": "100001\r\n", "output": "0\r\n"}, {"input": "40000000000000000000888\r\n", "output": "400000000000000000008\r\n"}, {"input": "100000\r\n", "output": "0\r\n"}, {"input": "4000000888\r\n", "output": "40000008\r\n"}, {"input": "334733\r\n", "output": "3333\r\n"}, {"input": "1000002220\r\n", "output": "10000020\r\n"}, {"input": "100321\r\n", "output": "10032\r\n"}, {"input": "101111\r\n", "output": "1011\r\n"}, {"input": "100000000222\r\n", "output": "1000000002\r\n"}, {"input": "10001\r\n", "output": "0\r\n"}, {"input": "7\r\n", "output": "-1\r\n"}, {"input": "2000000000111\r\n", "output": "20000000001\r\n"}, {"input": "100000001\r\n", "output": "0\r\n"}, {"input": "10000000000222\r\n", "output": "100000000002\r\n"}, {"input": "200000000000000111\r\n", "output": "2000000000000001\r\n"}, {"input": "404044\r\n", "output": "40044\r\n"}, {"input": "30202\r\n", "output": "300\r\n"}, {"input": "20000000000000000111\r\n", "output": "200000000000000001\r\n"}, {"input": "707\r\n", "output": "0\r\n"}, {"input": "20000300000000003000050000003\r\n", "output": "30000000000300000000003\r\n"}, {"input": "400000888\r\n", "output": "4000008\r\n"}, {"input": "2888\r\n", "output": "888\r\n"}, {"input": "200111\r\n", "output": "2001\r\n"}, {"input": "10000000888\r\n", "output": "100000008\r\n"}, {"input": "40000888\r\n", "output": "400008\r\n"}, {"input": "40404044\r\n", "output": "400044\r\n"}, {"input": "5500000000\r\n", "output": "0\r\n"}, {"input": "100012\r\n", "output": "10002\r\n"}, {"input": "1000007\r\n", "output": "0\r\n"}, {"input": "200093\r\n", "output": "93\r\n"}, {"input": "10000000222\r\n", "output": "100000002\r\n"}, {"input": "20000000002\r\n", "output": "0\r\n"}, {"input": "74333\r\n", "output": "333\r\n"}, {"input": "200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\r\n", "output": "0\r\n"}, {"input": "10000000111\r\n", "output": "1000000011\r\n"}, {"input": "100007\r\n", "output": "0\r\n"}, {"input": "20000006711\r\n", "output": "200000061\r\n"}, {"input": "8059\r\n", "output": "9\r\n"}, {"input": "8008\r\n", "output": "0\r\n"}, {"input": "88\r\n", "output": "-1\r\n"}, {"input": "2002\r\n", "output": "0\r\n"}, {"input": "2000111\r\n", "output": "20001\r\n"}, {"input": "100000000100000002\r\n", "output": "10000000000000002\r\n"}, {"input": "1000000000000000000000000000000000\r\n", "output": "0\r\n"}, {"input": "10000000000000000222\r\n", "output": "100000000000000002\r\n"}, {"input": "1000001\r\n", "output": "0\r\n"}, {"input": "200000000000111\r\n", "output": "2000000000001\r\n"}, {"input": "2000000002\r\n", "output": "0\r\n"}, {"input": "2010000100001\r\n", "output": "10000100001\r\n"}, {"input": "200330\r\n", "output": "330\r\n"}, {"input": "10000222\r\n", "output": "100002\r\n"}, {"input": "2005\r\n", "output": "0\r\n"}, {"input": "100000000000822\r\n", "output": "1000000000002\r\n"}, {"input": "10000000000000000000000\r\n", "output": "0\r\n"}, {"input": "7046\r\n", "output": "6\r\n"}, {"input": "4000117\r\n", "output": "400017\r\n"}, {"input": "971\r\n", "output": "9\r\n"}, {"input": "404\r\n", "output": "0\r\n"}, {"input": "5\r\n", "output": "-1\r\n"}, {"input": "164\r\n", "output": "6\r\n"}, {"input": "140\r\n", "output": "0\r\n"}, {"input": "74\r\n", "output": "-1\r\n"}, {"input": "2058232\r\n", "output": "20232\r\n"}, {"input": "4\r\n", "output": "-1\r\n"}, {"input": "20206\r\n", "output": "6\r\n"}, {"input": "103310\r\n", "output": "330\r\n"}, {"input": "100\r\n", "output": "0\r\n"}, {"input": "417179\r\n", "output": "7179\r\n"}, {"input": "70558\r\n", "output": "558\r\n"}, {"input": "298\r\n", "output": "9\r\n"}, {"input": "7003\r\n", "output": "3\r\n"}, {"input": "2212\r\n", "output": "222\r\n"}, {"input": "1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001\r\n", "output": "0\r\n"}, {"input": "2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002\r\n", "output": "0\r\n"}, {"input": "1002200\r\n", "output": "100200\r\n"}, {"input": "1222\r\n", "output": "222\r\n"}, {"input": "101200100\r\n", "output": "10100100\r\n"}, {"input": "1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003\r\n", "output": "3\r\n"}, {"input": "20020201\r\n", "output": "2002020\r\n"}, {"input": "12122\r\n", "output": "1122\r\n"}, {"input": "20200\r\n", "output": "0\r\n"}, {"input": "2\r\n", "output": "-1\r\n"}, {"input": "1000000000000258\r\n", "output": "10000000000008\r\n"}]
| false |
stdio
|
import sys
def is_subsequence(s, t):
t_iter = iter(t)
try:
for c in s:
while next(t_iter) != c:
pass
return True
except StopIteration:
return False
def is_beautiful(s):
if not s:
return False
if s[0] == '0' and len(s) > 1:
return False
total = sum(int(c) for c in s)
return total % 3 == 0
def compute_max_length(n):
sum_digits = sum(int(c) for c in n)
sum_mod3 = sum_digits % 3
has_zero = '0' in n
if sum_mod3 == 0:
if n[0] != '0':
return len(n)
first_non_zero = next((i for i, c in enumerate(n) if c != '0'), None)
if first_non_zero is None:
return 1
return len(n) - first_non_zero
else:
candidates = []
for i, c in enumerate(n):
if int(c) % 3 == sum_mod3:
new_n = n[:i] + n[i+1:]
if not new_n:
continue
first_non_zero = next((j for j, ch in enumerate(new_n) if ch != '0'), None)
if first_non_zero is None:
candidates.append(1)
else:
candidates.append(len(new_n) - first_non_zero)
target_mod = (3 - sum_mod3) % 3
mod_digits = [i for i, c in enumerate(n) if int(c) % 3 == target_mod]
if len(mod_digits) >= 2:
i, j = mod_digits[-2], mod_digits[-1]
new_n = n[:i] + n[i+1:j] + n[j+1:]
if new_n:
first_non_zero = next((k for k, ch in enumerate(new_n) if ch != '0'), None)
if first_non_zero is None:
candidates.append(1)
else:
candidates.append(len(new_n) - first_non_zero)
if has_zero:
candidates.append(1)
return max(candidates) if candidates else 0
def main(input_path, output_path, submission_path):
with open(input_path, 'r') as f:
n = f.read().strip()
with open(submission_path, 'r') as f:
submission = f.read().strip()
if submission == '-1':
max_len = compute_max_length(n)
print(100 if max_len == 0 else 0)
else:
if not is_subsequence(submission, n) or not is_beautiful(submission):
print(0)
return
max_len = compute_max_length(n)
print(100 if len(submission) == max_len else 0)
if __name__ == '__main__':
input_path, output_path, submission_path = sys.argv[1], sys.argv[2], sys.argv[3]
main(input_path, output_path, submission_path)
| true |
750/B
|
750
|
B
|
PyPy 3-64
|
TESTS
| 28 | 62 | 0 |
197427400
|
n = int(input())
dis=[]
direc = []
for j in range(n):
a,s = map(str,input().split())
dis.append(int(a))
direc.append(s)
if(direc[0]!='South'):
print('NO')
else:
lenght=0
flag=0
for k in range(n):
if(lenght<=20000):
if(direc[k]=='South'):
lenght = lenght + dis[k]
if(direc[k]=='North'):
lenght = lenght - dis[k]
if(lenght==0 or abs(lenght)%20000 == 0):
if(k<=n-2):
if(direc[k+1]=='East' or direc[k+1]=='West'):
print('NO')
flag=1
break
elif(lenght>20000):
print('NO')
flag=1
break
if(flag==0):
if(lenght==0 or lenght%40000 == 0):
print('YES')
else:
print('NO')
| 140 | 46 | 0 |
213825326
|
n = int(input())
k1 = 0
k2 = 0
for i in range(n):
s = input().split()
a = int(s[0])
b = s[1]
if k1 == 0 and b != 'South':
k2 = 1
if k1 == 20000 and b != 'North':
k2 = 1
if b =='South':
k1 += a
if b == 'North':
k1 -= a
if k1 > 20000 or k1 < 0:
k2 = 1
if k1 == 0 and k2 != 1:
print('YES')
else:
print('NO')
|
Good Bye 2016
|
CF
| 2,016 | 2 | 256 |
New Year and North Pole
|
In this problem we assume the Earth to be a completely round ball and its surface a perfect sphere. The length of the equator and any meridian is considered to be exactly 40 000 kilometers. Thus, travelling from North Pole to South Pole or vice versa takes exactly 20 000 kilometers.
Limak, a polar bear, lives on the North Pole. Close to the New Year, he helps somebody with delivering packages all around the world. Instead of coordinates of places to visit, Limak got a description how he should move, assuming that he starts from the North Pole. The description consists of n parts. In the i-th part of his journey, Limak should move ti kilometers in the direction represented by a string diri that is one of: "North", "South", "West", "East".
Limak isn’t sure whether the description is valid. You must help him to check the following conditions:
- If at any moment of time (before any of the instructions or while performing one of them) Limak is on the North Pole, he can move only to the South.
- If at any moment of time (before any of the instructions or while performing one of them) Limak is on the South Pole, he can move only to the North.
- The journey must end on the North Pole.
Check if the above conditions are satisfied and print "YES" or "NO" on a single line.
|
The first line of the input contains a single integer n (1 ≤ n ≤ 50).
The i-th of next n lines contains an integer ti and a string diri (1 ≤ ti ≤ 106, $${ dir } _ { i } \in \{ \mathrm { N o r t h, ~ S o u t h, ~ W e s t, ~ E a s t } \}$$) — the length and the direction of the i-th part of the journey, according to the description Limak got.
|
Print "YES" if the description satisfies the three conditions, otherwise print "NO", both without the quotes.
| null |
Drawings below show how Limak's journey would look like in first two samples. In the second sample the answer is "NO" because he doesn't end on the North Pole.
|
[{"input": "5\n7500 South\n10000 East\n3500 North\n4444 West\n4000 North", "output": "YES"}, {"input": "2\n15000 South\n4000 East", "output": "NO"}, {"input": "5\n20000 South\n1000 North\n1000000 West\n9000 North\n10000 North", "output": "YES"}, {"input": "3\n20000 South\n10 East\n20000 North", "output": "NO"}, {"input": "2\n1000 North\n1000 South", "output": "NO"}, {"input": "4\n50 South\n50 North\n15000 South\n15000 North", "output": "YES"}]
| 1,300 |
["geometry", "implementation"]
| 140 |
[{"input": "5\r\n7500 South\r\n10000 East\r\n3500 North\r\n4444 West\r\n4000 North\r\n", "output": "YES\r\n"}, {"input": "2\r\n15000 South\r\n4000 East\r\n", "output": "NO\r\n"}, {"input": "5\r\n20000 South\r\n1000 North\r\n1000000 West\r\n9000 North\r\n10000 North\r\n", "output": "YES\r\n"}, {"input": "3\r\n20000 South\r\n10 East\r\n20000 North\r\n", "output": "NO\r\n"}, {"input": "2\r\n1000 North\r\n1000 South\r\n", "output": "NO\r\n"}, {"input": "4\r\n50 South\r\n50 North\r\n15000 South\r\n15000 North\r\n", "output": "YES\r\n"}, {"input": "1\r\n1 South\r\n", "output": "NO\r\n"}, {"input": "1\r\n1 East\r\n", "output": "NO\r\n"}, {"input": "2\r\n1000000 South\r\n1000000 North\r\n", "output": "NO\r\n"}, {"input": "1\r\n149 South\r\n", "output": "NO\r\n"}, {"input": "1\r\n16277 East\r\n", "output": "NO\r\n"}, {"input": "1\r\n19701 South\r\n", "output": "NO\r\n"}, {"input": "1\r\n3125 South\r\n", "output": "NO\r\n"}, {"input": "1\r\n6549 South\r\n", "output": "NO\r\n"}, {"input": "1\r\n2677 South\r\n", "output": "NO\r\n"}, {"input": "1\r\n6101 South\r\n", "output": "NO\r\n"}, {"input": "1\r\n9525 South\r\n", "output": "NO\r\n"}, {"input": "1\r\n5653 South\r\n", "output": "NO\r\n"}, {"input": "2\r\n15072 South\r\n15072 North\r\n", "output": "YES\r\n"}, {"input": "2\r\n11200 South\r\n11200 North\r\n", "output": "YES\r\n"}, {"input": "2\r\n14624 South\r\n14624 North\r\n", "output": "YES\r\n"}, {"input": "2\r\n18048 South\r\n15452 West\r\n", "output": "NO\r\n"}, {"input": "2\r\n1472 West\r\n4930 North\r\n", "output": "NO\r\n"}, {"input": "2\r\n17600 South\r\n17600 North\r\n", "output": "YES\r\n"}, {"input": "2\r\n8320 East\r\n16589 East\r\n", "output": "NO\r\n"}, {"input": "2\r\n4448 South\r\n4448 North\r\n", "output": "YES\r\n"}, {"input": "2\r\n576 South\r\n576 North\r\n", "output": "YES\r\n"}, {"input": "3\r\n14186 South\r\n2291 West\r\n14186 North\r\n", "output": "YES\r\n"}, {"input": "3\r\n10314 South\r\n15961 North\r\n5647 South\r\n", "output": "NO\r\n"}, {"input": "3\r\n1035 East\r\n18143 South\r\n18143 North\r\n", "output": "NO\r\n"}, {"input": "3\r\n17163 South\r\n7620 East\r\n17163 North\r\n", "output": "YES\r\n"}, {"input": "3\r\n587 South\r\n17098 North\r\n16511 South\r\n", "output": "NO\r\n"}, {"input": "3\r\n16715 North\r\n6576 West\r\n12132 South\r\n", "output": "NO\r\n"}, {"input": "3\r\n7435 South\r\n245 North\r\n7190 North\r\n", "output": "YES\r\n"}, {"input": "3\r\n3563 South\r\n2427 South\r\n5990 North\r\n", "output": "YES\r\n"}, {"input": "3\r\n6987 South\r\n11904 East\r\n19951 East\r\n", "output": "NO\r\n"}, {"input": "4\r\n13301 South\r\n5948 East\r\n9265 East\r\n6891 North\r\n", "output": "NO\r\n"}, {"input": "4\r\n16725 South\r\n8129 South\r\n19530 West\r\n24854 North\r\n", "output": "NO\r\n"}, {"input": "4\r\n149 South\r\n17607 West\r\n18306 South\r\n18455 North\r\n", "output": "YES\r\n"}, {"input": "4\r\n16277 South\r\n19789 North\r\n4379 South\r\n867 North\r\n", "output": "NO\r\n"}, {"input": "4\r\n19701 South\r\n13458 South\r\n3156 North\r\n30003 North\r\n", "output": "NO\r\n"}, {"input": "4\r\n3125 South\r\n15640 East\r\n6125 East\r\n19535 South\r\n", "output": "NO\r\n"}, {"input": "4\r\n6549 East\r\n5118 North\r\n12198 East\r\n5118 South\r\n", "output": "NO\r\n"}, {"input": "4\r\n2677 East\r\n1891 West\r\n10974 West\r\n7511 North\r\n", "output": "NO\r\n"}, {"input": "4\r\n6102 South\r\n8265 East\r\n13943 South\r\n20045 North\r\n", "output": "NO\r\n"}, {"input": "5\r\n12416 South\r\n18116 North\r\n10553 West\r\n18435 West\r\n5700 South\r\n", "output": "NO\r\n"}, {"input": "5\r\n15840 South\r\n7594 South\r\n13522 South\r\n2423 South\r\n3334 West\r\n", "output": "NO\r\n"}, {"input": "5\r\n19264 East\r\n13968 East\r\n19595 North\r\n19115 North\r\n38710 South\r\n", "output": "NO\r\n"}, {"input": "5\r\n15392 South\r\n3445 North\r\n18372 East\r\n10399 North\r\n4403 South\r\n", "output": "NO\r\n"}, {"input": "5\r\n18816 South\r\n5627 West\r\n14045 East\r\n7091 East\r\n18816 North\r\n", "output": "YES\r\n"}, {"input": "5\r\n2240 South\r\n15104 North\r\n118 West\r\n11079 East\r\n12864 South\r\n", "output": "NO\r\n"}, {"input": "5\r\n5664 South\r\n1478 South\r\n18894 South\r\n2363 West\r\n26036 North\r\n", "output": "NO\r\n"}, {"input": "5\r\n1792 South\r\n10956 East\r\n9159 South\r\n19055 West\r\n10951 North\r\n", "output": "YES\r\n"}, {"input": "5\r\n12512 South\r\n13137 North\r\n7936 North\r\n7235 South\r\n1326 South\r\n", "output": "NO\r\n"}, {"input": "6\r\n14635 North\r\n14477 South\r\n17250 North\r\n14170 East\r\n15166 South\r\n2242 South\r\n", "output": "NO\r\n"}, {"input": "6\r\n10763 North\r\n3954 West\r\n7515 North\r\n18158 West\r\n6644 South\r\n11634 South\r\n", "output": "NO\r\n"}, {"input": "6\r\n14187 South\r\n13432 North\r\n6292 East\r\n14850 West\r\n10827 South\r\n9639 East\r\n", "output": "NO\r\n"}, {"input": "6\r\n10315 South\r\n15614 South\r\n5069 West\r\n6134 South\r\n7713 North\r\n24350 North\r\n", "output": "NO\r\n"}, {"input": "6\r\n1035 South\r\n9283 East\r\n15333 South\r\n2826 South\r\n19191 North\r\n3 North\r\n", "output": "YES\r\n"}, {"input": "6\r\n17163 West\r\n11465 North\r\n14110 South\r\n6814 North\r\n3373 East\r\n4169 South\r\n", "output": "NO\r\n"}, {"input": "6\r\n587 South\r\n942 West\r\n183 North\r\n18098 North\r\n260 East\r\n17694 South\r\n", "output": "NO\r\n"}, {"input": "6\r\n16715 West\r\n3124 East\r\n3152 East\r\n14790 East\r\n11738 West\r\n11461 East\r\n", "output": "NO\r\n"}, {"input": "6\r\n7435 South\r\n12602 South\r\n1929 East\r\n6074 East\r\n15920 West\r\n20037 North\r\n", "output": "NO\r\n"}, {"input": "7\r\n13750 South\r\n6645 South\r\n18539 East\r\n5713 North\r\n1580 North\r\n10012 West\r\n13102 North\r\n", "output": "NO\r\n"}, {"input": "7\r\n9878 West\r\n8827 East\r\n1508 West\r\n9702 North\r\n5763 North\r\n9755 North\r\n10034 South\r\n", "output": "NO\r\n"}, {"input": "7\r\n13302 West\r\n2496 North\r\n284 West\r\n6394 East\r\n9945 North\r\n12603 West\r\n12275 North\r\n", "output": "NO\r\n"}, {"input": "7\r\n16726 East\r\n19270 West\r\n6357 South\r\n17678 East\r\n14127 East\r\n12347 South\r\n6005 East\r\n", "output": "NO\r\n"}, {"input": "7\r\n150 South\r\n1452 North\r\n9326 North\r\n1666 West\r\n18309 East\r\n19386 East\r\n8246 West\r\n", "output": "NO\r\n"}, {"input": "7\r\n16278 South\r\n10929 South\r\n8103 East\r\n18358 West\r\n2492 West\r\n11834 South\r\n39041 North\r\n", "output": "NO\r\n"}, {"input": "7\r\n19702 South\r\n13111 East\r\n6880 East\r\n9642 South\r\n6674 West\r\n18874 East\r\n1112 North\r\n", "output": "NO\r\n"}, {"input": "7\r\n3126 South\r\n6780 North\r\n9848 West\r\n6334 North\r\n10856 West\r\n14425 West\r\n10649 East\r\n", "output": "NO\r\n"}, {"input": "7\r\n6550 South\r\n8962 West\r\n15921 South\r\n17618 North\r\n15038 South\r\n1465 North\r\n18426 North\r\n", "output": "NO\r\n"}, {"input": "8\r\n12864 South\r\n3005 West\r\n16723 West\r\n17257 West\r\n12187 East\r\n12976 South\r\n1598 North\r\n24242 North\r\n", "output": "NO\r\n"}, {"input": "8\r\n8992 South\r\n12483 North\r\n15500 South\r\n1245 South\r\n9073 East\r\n12719 East\r\n3839 East\r\n7130 South\r\n", "output": "NO\r\n"}, {"input": "8\r\n12416 North\r\n14665 South\r\n14277 North\r\n2129 South\r\n13255 East\r\n19759 South\r\n10272 West\r\n9860 North\r\n", "output": "NO\r\n"}, {"input": "8\r\n15840 South\r\n4142 East\r\n17246 North\r\n13413 North\r\n4733 West\r\n15311 North\r\n12514 South\r\n17616 South\r\n", "output": "NO\r\n"}, {"input": "8\r\n19264 South\r\n10516 North\r\n3319 East\r\n17401 East\r\n1620 West\r\n2350 West\r\n6243 North\r\n2505 North\r\n", "output": "YES\r\n"}, {"input": "8\r\n15392 South\r\n7290 West\r\n2096 West\r\n14093 East\r\n5802 South\r\n2094 North\r\n8484 East\r\n19100 North\r\n", "output": "NO\r\n"}, {"input": "8\r\n6113 South\r\n16767 East\r\n5064 South\r\n5377 West\r\n17280 South\r\n1838 West\r\n2213 West\r\n28457 North\r\n", "output": "NO\r\n"}, {"input": "8\r\n2241 West\r\n18949 South\r\n11137 South\r\n2069 West\r\n14166 South\r\n1581 South\r\n4455 South\r\n50288 North\r\n", "output": "NO\r\n"}, {"input": "8\r\n5665 South\r\n8426 East\r\n9914 North\r\n13353 South\r\n18349 North\r\n4429 East\r\n18184 North\r\n27429 South\r\n", "output": "NO\r\n"}, {"input": "9\r\n11979 South\r\n2470 East\r\n10716 North\r\n12992 East\r\n15497 West\r\n15940 North\r\n8107 West\r\n18934 East\r\n6993 South\r\n", "output": "NO\r\n"}, {"input": "9\r\n8107 South\r\n4652 North\r\n9493 North\r\n16980 West\r\n12383 West\r\n2980 West\r\n17644 South\r\n11043 West\r\n11447 North\r\n", "output": "NO\r\n"}, {"input": "9\r\n18827 South\r\n18321 West\r\n8270 East\r\n968 West\r\n16565 West\r\n15427 North\r\n4077 North\r\n18960 North\r\n19006 West\r\n", "output": "NO\r\n"}, {"input": "9\r\n14955 West\r\n503 North\r\n18535 West\r\n4956 South\r\n8044 South\r\n2467 East\r\n13615 East\r\n6877 East\r\n3460 North\r\n", "output": "NO\r\n"}, {"input": "9\r\n18379 South\r\n9980 South\r\n17311 West\r\n8944 South\r\n4930 South\r\n18019 South\r\n48 West\r\n14794 South\r\n75046 North\r\n", "output": "NO\r\n"}, {"input": "9\r\n14507 East\r\n12162 East\r\n16088 South\r\n5636 North\r\n9112 North\r\n5058 East\r\n9585 South\r\n2712 East\r\n10925 North\r\n", "output": "NO\r\n"}, {"input": "9\r\n5227 East\r\n8936 North\r\n6353 North\r\n16920 North\r\n591 North\r\n4802 South\r\n8722 North\r\n3333 West\r\n36720 South\r\n", "output": "NO\r\n"}, {"input": "9\r\n1355 North\r\n15309 West\r\n17834 North\r\n13612 East\r\n17477 North\r\n4546 North\r\n18260 East\r\n15442 North\r\n56654 South\r\n", "output": "NO\r\n"}, {"input": "9\r\n4779 South\r\n4787 East\r\n3907 East\r\n4896 East\r\n1659 East\r\n4289 West\r\n4693 West\r\n3359 East\r\n4779 North\r\n", "output": "YES\r\n"}, {"input": "1\r\n80000 South\r\n", "output": "NO\r\n"}, {"input": "2\r\n40000 South\r\n20000 North\r\n", "output": "NO\r\n"}, {"input": "1\r\n40000 South\r\n", "output": "NO\r\n"}, {"input": "2\r\n20001 South\r\n20001 North\r\n", "output": "NO\r\n"}, {"input": "4\r\n10000 South\r\n20000 South\r\n10000 North\r\n20000 North\r\n", "output": "NO\r\n"}, {"input": "3\r\n10 South\r\n20 North\r\n10 North\r\n", "output": "NO\r\n"}, {"input": "3\r\n1000 South\r\n1001 North\r\n1 North\r\n", "output": "NO\r\n"}, {"input": "2\r\n20000 South\r\n20000 West\r\n", "output": "NO\r\n"}, {"input": "3\r\n10000 South\r\n20000 South\r\n10000 North\r\n", "output": "NO\r\n"}, {"input": "2\r\n1 East\r\n1 North\r\n", "output": "NO\r\n"}, {"input": "2\r\n20000 West\r\n20000 West\r\n", "output": "NO\r\n"}, {"input": "2\r\n80000 South\r\n20000 North\r\n", "output": "NO\r\n"}, {"input": "2\r\n19999 South\r\n20001 South\r\n", "output": "NO\r\n"}, {"input": "3\r\n500 South\r\n1000 North\r\n500 North\r\n", "output": "NO\r\n"}, {"input": "1\r\n400000 South\r\n", "output": "NO\r\n"}, {"input": "2\r\n40000 South\r\n80000 North\r\n", "output": "NO\r\n"}, {"input": "2\r\n100 West\r\n100 North\r\n", "output": "NO\r\n"}, {"input": "2\r\n40000 South\r\n40000 North\r\n", "output": "NO\r\n"}, {"input": "2\r\n30000 South\r\n10000 North\r\n", "output": "NO\r\n"}, {"input": "2\r\n20000 South\r\n40000 North\r\n", "output": "NO\r\n"}, {"input": "10\r\n20000 South\r\n20000 North\r\n20000 South\r\n20000 North\r\n20000 South\r\n20000 North\r\n20000 South\r\n20000 North\r\n20000 South\r\n20000 North\r\n", "output": "YES\r\n"}, {"input": "2\r\n40001 South\r\n40001 North\r\n", "output": "NO\r\n"}, {"input": "2\r\n40001 South\r\n1 North\r\n", "output": "NO\r\n"}, {"input": "2\r\n50000 South\r\n50000 North\r\n", "output": "NO\r\n"}, {"input": "2\r\n30000 South\r\n30000 South\r\n", "output": "NO\r\n"}, {"input": "2\r\n10000 South\r\n50000 North\r\n", "output": "NO\r\n"}, {"input": "4\r\n15000 South\r\n15000 South\r\n15000 North\r\n15000 North\r\n", "output": "NO\r\n"}, {"input": "3\r\n50 South\r\n100 North\r\n50 North\r\n", "output": "NO\r\n"}, {"input": "2\r\n20001 South\r\n1 North\r\n", "output": "NO\r\n"}, {"input": "3\r\n5 South\r\n6 North\r\n1 South\r\n", "output": "NO\r\n"}, {"input": "1\r\n20000 South\r\n", "output": "NO\r\n"}, {"input": "4\r\n1 South\r\n20000 South\r\n1 North\r\n20000 North\r\n", "output": "NO\r\n"}, {"input": "2\r\n30000 South\r\n30000 North\r\n", "output": "NO\r\n"}, {"input": "3\r\n1 South\r\n2 North\r\n1 South\r\n", "output": "NO\r\n"}, {"input": "2\r\n60000 South\r\n60000 North\r\n", "output": "NO\r\n"}, {"input": "2\r\n50000 South\r\n10000 North\r\n", "output": "NO\r\n"}, {"input": "1\r\n5 North\r\n", "output": "NO\r\n"}, {"input": "2\r\n20010 South\r\n19990 North\r\n", "output": "NO\r\n"}, {"input": "3\r\n20000 South\r\n1 South\r\n20000 North\r\n", "output": "NO\r\n"}, {"input": "3\r\n1 South\r\n2 North\r\n39999 North\r\n", "output": "NO\r\n"}, {"input": "3\r\n10 South\r\n20 North\r\n10 South\r\n", "output": "NO\r\n"}, {"input": "3\r\n1 South\r\n2 North\r\n1 North\r\n", "output": "NO\r\n"}, {"input": "3\r\n2000 South\r\n19000 South\r\n19000 South\r\n", "output": "NO\r\n"}, {"input": "6\r\n15000 South\r\n15000 South\r\n15000 South\r\n15000 North\r\n15000 North\r\n15000 North\r\n", "output": "NO\r\n"}, {"input": "3\r\n1 South\r\n1 North\r\n1 East\r\n", "output": "NO\r\n"}, {"input": "2\r\n1 West\r\n1 North\r\n", "output": "NO\r\n"}, {"input": "3\r\n1 South\r\n123456 West\r\n1 North\r\n", "output": "YES\r\n"}]
| false |
stdio
| null | true |
99/B
|
99
|
B
|
PyPy 3
|
TESTS
| 50 | 140 | 0 |
60445506
|
__author__ = 'Esfandiar'
n = int(input())
a = list()
for i in range(n):
a.append([int(input()),i+1])
a.sort()
j = a[0][0]
f = 1
s = j
for i in range(1,n):
if a[i][0] != j:
f = 0
s+=a[i][0]
if f == 1:
print('Exemplary pages.')
exit()
yy = s/n
if int(yy) != yy:
print('Unrecoverable configuration.')
exit()
yy = int(yy)
ind = n-1
for i in range(n):
if a[i][0] < yy:
print(yy-a[i][0],'ml. from cup #{} to cup #{}.'.format(a[i][1],a[ind][1]))
| 200 | 124 | 307,200 |
82599994
|
n=int(input())
x=[]
for i in range(n):
x.append(int(input()))
y=sorted(x)
z=sorted(x,reverse=True)
if y==z:print('Exemplary pages.')
else:
z=y.copy();t=[]
while(y[n-1]>0):
y[0]+=1;y[n-1]-=1
if y[0]==y[n-1]:break
y.sort();t=sorted(y,reverse=True)
if y==t:print('%d ml. from cup #%d to cup #%d.'%(y[0]-z[0],x.index(z[0])+1,x.index(z[n-1])+1))
else:print('Unrecoverable configuration.')
|
Codeforces Beta Round 78 (Div. 2 Only)
|
CF
| 2,011 | 0.5 | 256 |
Help Chef Gerasim
|
In a far away kingdom young pages help to set the table for the King. As they are terribly mischievous, one needs to keep an eye on the control whether they have set everything correctly. This time the royal chef Gerasim had the impression that the pages have played a prank again: they had poured the juice from one cup to another. Now Gerasim wants to check his hypothesis. The good thing is that chef Gerasim always pour the same number of milliliters of juice to all cups in the royal kitchen. Having thoroughly measured the juice in each cup, Gerasim asked you to write a program that will determine from which cup juice was poured to which one; otherwise, the program should determine that this time the pages set the table diligently.
To simplify your task we shall consider the cups to be bottomless so that the juice never overfills a cup and pours out, however much it can be. Besides, by some strange reason in a far away kingdom one can only pour to a cup or from one cup to another an integer number of milliliters of juice.
|
The first line contains integer n — the number of cups on the royal table (1 ≤ n ≤ 1000). Next n lines contain volumes of juice in each cup — non-negative integers, not exceeding 104.
|
If the pages didn't pour the juice, print "Exemplary pages." (without the quotes). If you can determine the volume of juice poured during exactly one juice pouring, print "v ml. from cup #a to cup #b." (without the quotes), where v represents the volume of poured juice, a represents the number of the cup from which the juice was poured (the cups are numbered with consecutive positive integers starting from one in the order in which the cups are described in the input data), b represents the number of the cup into which the juice was poured. Finally, if the given juice's volumes cannot be obtained using no more than one pouring (for example, the pages poured the juice from one cup to another more than once or the royal kitchen maids poured the juice into the cups incorrectly), print "Unrecoverable configuration." (without the quotes).
| null | null |
[{"input": "5\n270\n250\n250\n230\n250", "output": "20 ml. from cup #4 to cup #1."}, {"input": "5\n250\n250\n250\n250\n250", "output": "Exemplary pages."}, {"input": "5\n270\n250\n249\n230\n250", "output": "Unrecoverable configuration."}]
| 1,300 |
["implementation", "sortings"]
| 200 |
[{"input": "5\r\n270\r\n250\r\n250\r\n230\r\n250\r\n", "output": "20 ml. from cup #4 to cup #1.\r\n"}, {"input": "5\r\n250\r\n250\r\n250\r\n250\r\n250\r\n", "output": "Exemplary pages.\r\n"}, {"input": "5\r\n270\r\n250\r\n249\r\n230\r\n250\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n200\r\n190\r\n210\r\n200\r\n", "output": "10 ml. from cup #2 to cup #3.\r\n"}, {"input": "4\r\n1\r\n2\r\n3\r\n4\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "1\r\n0\r\n", "output": "Exemplary pages.\r\n"}, {"input": "2\r\n0\r\n0\r\n", "output": "Exemplary pages.\r\n"}, {"input": "2\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "2\r\n0\r\n2\r\n", "output": "1 ml. from cup #1 to cup #2.\r\n"}, {"input": "2\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "2\r\n1\r\n1\r\n", "output": "Exemplary pages.\r\n"}, {"input": "2\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "2\r\n2\r\n0\r\n", "output": "1 ml. from cup #2 to cup #1.\r\n"}, {"input": "2\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "2\r\n2\r\n2\r\n", "output": "Exemplary pages.\r\n"}, {"input": "3\r\n0\r\n0\r\n0\r\n", "output": "Exemplary pages.\r\n"}, {"input": "3\r\n0\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n0\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n0\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n0\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n0\r\n1\r\n2\r\n", "output": "1 ml. from cup #1 to cup #3.\r\n"}, {"input": "3\r\n0\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n0\r\n2\r\n1\r\n", "output": "1 ml. from cup #1 to cup #2.\r\n"}, {"input": "3\r\n0\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n0\r\n2\r\n", "output": "1 ml. from cup #2 to cup #3.\r\n"}, {"input": "3\r\n1\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n1\r\n1\r\n", "output": "Exemplary pages.\r\n"}, {"input": "3\r\n1\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n2\r\n0\r\n", "output": "1 ml. from cup #3 to cup #2.\r\n"}, {"input": "3\r\n1\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n0\r\n1\r\n", "output": "1 ml. from cup #2 to cup #1.\r\n"}, {"input": "3\r\n2\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n1\r\n0\r\n", "output": "1 ml. from cup #3 to cup #1.\r\n"}, {"input": "3\r\n2\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n2\r\n2\r\n", "output": "Exemplary pages.\r\n"}, {"input": "4\r\n0\r\n0\r\n0\r\n0\r\n", "output": "Exemplary pages.\r\n"}, {"input": "4\r\n0\r\n0\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n1\r\n2\r\n", "output": "1 ml. from cup #1 to cup #4.\r\n"}, {"input": "4\r\n0\r\n1\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n2\r\n1\r\n", "output": "1 ml. from cup #1 to cup #3.\r\n"}, {"input": "4\r\n0\r\n1\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n1\r\n1\r\n", "output": "1 ml. from cup #1 to cup #2.\r\n"}, {"input": "4\r\n0\r\n2\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n1\r\n2\r\n", "output": "1 ml. from cup #2 to cup #4.\r\n"}, {"input": "4\r\n1\r\n0\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n2\r\n1\r\n", "output": "1 ml. from cup #2 to cup #3.\r\n"}, {"input": "4\r\n1\r\n0\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n0\r\n2\r\n", "output": "1 ml. from cup #3 to cup #4.\r\n"}, {"input": "4\r\n1\r\n1\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n1\r\n1\r\n", "output": "Exemplary pages.\r\n"}, {"input": "4\r\n1\r\n1\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n2\r\n0\r\n", "output": "1 ml. from cup #4 to cup #3.\r\n"}, {"input": "4\r\n1\r\n1\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n0\r\n1\r\n", "output": "1 ml. from cup #3 to cup #2.\r\n"}, {"input": "4\r\n1\r\n2\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n1\r\n0\r\n", "output": "1 ml. from cup #4 to cup #2.\r\n"}, {"input": "4\r\n1\r\n2\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n1\r\n1\r\n", "output": "1 ml. from cup #2 to cup #1.\r\n"}, {"input": "4\r\n2\r\n0\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n0\r\n1\r\n", "output": "1 ml. from cup #3 to cup #1.\r\n"}, {"input": "4\r\n2\r\n1\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n1\r\n0\r\n", "output": "1 ml. from cup #4 to cup #1.\r\n"}, {"input": "4\r\n2\r\n1\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n2\r\n2\r\n", "output": "Exemplary pages.\r\n"}, {"input": "27\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n2626\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n8572\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n", "output": "2973 ml. from cup #11 to cup #17.\r\n"}, {"input": "19\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n82\r\n5001\r\n9919\r\n5001\r\n5001\r\n", "output": "Unrecoverable configuration.\r\n"}]
| false |
stdio
| null | true |
792/C
|
792
|
C
|
Python 3
|
TESTS
| 28 | 139 | 11,673,600 |
25889964
|
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7
def LI(): return [int(x) 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 S(): return input()
def main():
a = [int(c) for c in S()]
t = sum(a) % 3
if t == 0:
return ''.join(map(str, a))
al = len(a)
ds = []
for i in range(al-1,-1,-1):
if a[i] % 3 == t:
ds.append(i)
if i != 0:
break
for j in range(1,al-1):
if a[j] != 0:
break
ds.append(j)
break
if not ds:
ds = list(range(al))
if len(ds) < 3 and len(ds) < al:
return ''.join(map(str, [a[i] for i in range(al) if i not in ds]))
ds2 = []
for i in range(al-1,-1,-1):
if a[i]*2 % 3 == t:
ds2.append(i)
if len(ds2) < 2:
continue
if i != 0:
break
for j in range(1,al-1):
if a[j] != 0 and j not in ds2:
break
ds2.append(j)
break
if len(ds2) < 2:
ds2 = list(range(al))
if len(ds) > len(ds2):
ds = ds2
if len(ds) == al:
return -1
return ''.join(map(str, [a[i] for i in range(al) if i not in ds]))
print(main())
| 162 | 171 | 6,041,600 |
57314819
|
def find(s):
if len(s)==1:
if int(s)%3==0:
return s
return -1
digit=[[] for i in range(3)]
zeros=[]
for i in range(len(s)):
digit[int(s[i])%3]+=[i]
if s[i]=="0":
zeros+=[i]
total=(len(digit[1])*1+len(digit[2])*2)%3
if total==0:
return s
if total==1:
##delete one 1
##delete two 2
s1=""
if len(digit[1])>=1:
p1=digit[1][-1]
s1=s[:p1]+s[p1+1:]
last_pos=len(s1)
for i in range(len(s1)):
if s1[i]!="0":
last_pos=i
break
if last_pos<len(s1):
s1=s1[last_pos:]
else:
if len(s1)>0:
if s1[-1]=="0":
s1="0"
s2=""
if len(digit[2])>=2:
p1=digit[2][-2]
p2=digit[2][-1]
s2=s[:p1]+s[p1+1:p2]+s[p2+1:]
last_pos=len(s2)
for i in range(len(s2)):
if s2[i]!="0":
last_pos=i
break
if last_pos<len(s2):
s2=s2[last_pos:]
else:
if len(s2)>0:
if s2[-1]=="0":
s2="0"
if s1=="" and s2=="":
return -1
elif s1=="":
return s2
elif s2=="":
return s1
else:
if len(s1)>len(s2):
return s1
return s2
if total==2:
##delete one 1
##delete two 2
digit[1],digit[2]=digit[2],digit[1]
##delete one 1
##delete two 2
s1=""
if len(digit[1])>=1:
p1=digit[1][-1]
s1=s[:p1]+s[p1+1:]
last_pos=len(s1)
for i in range(len(s1)):
if s1[i]!="0":
last_pos=i
break
if last_pos<len(s1):
s1=s1[last_pos:]
else:
if len(s1)>0:
if s1[-1]=="0":
s1="0"
s2=""
if len(digit[2])>=2:
p1=digit[2][-2]
p2=digit[2][-1]
s2=s[:p1]+s[p1+1:p2]+s[p2+1:]
last_pos=len(s2)
for i in range(len(s2)):
if s2[i]!="0":
last_pos=i
break
if last_pos<len(s2):
s2=s2[last_pos:]
else:
if len(s2)>0:
if s2[-1]=="0":
s2="0"
if s1=="" and s2=="":
return -1
elif s1=="":
return s2
elif s2=="":
return s1
else:
if len(s1)>len(s2):
return s1
return s2
print(find(input()))
|
Educational Codeforces Round 18
|
ICPC
| 2,017 | 1 | 256 |
Divide by Three
|
A positive integer number n is written on a blackboard. It consists of not more than 105 digits. You have to transform it into a beautiful number by erasing some of the digits, and you want to erase as few digits as possible.
The number is called beautiful if it consists of at least one digit, doesn't have leading zeroes and is a multiple of 3. For example, 0, 99, 10110 are beautiful numbers, and 00, 03, 122 are not.
Write a program which for the given n will find a beautiful number such that n can be transformed into this number by erasing as few digits as possible. You can erase an arbitraty set of digits. For example, they don't have to go one after another in the number n.
If it's impossible to obtain a beautiful number, print -1. If there are multiple answers, print any of them.
|
The first line of input contains n — a positive integer number without leading zeroes (1 ≤ n < 10100000).
|
Print one number — any beautiful number obtained by erasing as few as possible digits. If there is no answer, print - 1.
| null |
In the first example it is enough to erase only the first digit to obtain a multiple of 3. But if we erase the first digit, then we obtain a number with a leading zero. So the minimum number of digits to be erased is two.
|
[{"input": "1033", "output": "33"}, {"input": "10", "output": "0"}, {"input": "11", "output": "-1"}]
| 2,000 |
["dp", "greedy", "math", "number theory"]
| 162 |
[{"input": "1033\r\n", "output": "33\r\n"}, {"input": "10\r\n", "output": "0\r\n"}, {"input": "11\r\n", "output": "-1\r\n"}, {"input": "3\r\n", "output": "3\r\n"}, {"input": "1\r\n", "output": "-1\r\n"}, {"input": "117\r\n", "output": "117\r\n"}, {"input": "518\r\n", "output": "18\r\n"}, {"input": "327\r\n", "output": "327\r\n"}, {"input": "270461\r\n", "output": "70461\r\n"}, {"input": "609209\r\n", "output": "60909\r\n"}, {"input": "110930\r\n", "output": "930\r\n"}, {"input": "37616145150713688775\r\n", "output": "3616145150713688775\r\n"}, {"input": "98509135612114839419\r\n", "output": "9509135612114839419\r\n"}, {"input": "41674994051436988162\r\n", "output": "1674994051436988162\r\n"}, {"input": "82547062721736129804\r\n", "output": "82547062721736129804\r\n"}, {"input": "4902501252475186372406731932548506197390793597574544727433297197476846519276598727359617092494798814\r\n", "output": "490501252475186372406731932548506197390793597574544727433297197476846519276598727359617092494798814\r\n"}, {"input": "1291007209605301446874998623691572528836214969878676835460982410817526074579818247646933326771899122\r\n", "output": "1291007209605301446874998623691572528836214969878676835460982410817526074579818247646933326771899122\r\n"}, {"input": "5388306043547446322173224045662327678394712363272776811399689704247387317165308057863239568137902157\r\n", "output": "538830603547446322173224045662327678394712363272776811399689704247387317165308057863239568137902157\r\n"}, {"input": "20000111\r\n", "output": "200001\r\n"}, {"input": "100222\r\n", "output": "1002\r\n"}, {"input": "202\r\n", "output": "0\r\n"}, {"input": "100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000033\r\n", "output": "33\r\n"}, {"input": "101\r\n", "output": "0\r\n"}, {"input": "1000000222\r\n", "output": "10000002\r\n"}, {"input": "1001\r\n", "output": "0\r\n"}, {"input": "205\r\n", "output": "0\r\n"}, {"input": "102211\r\n", "output": "10221\r\n"}, {"input": "100000002022\r\n", "output": "1000000002\r\n"}, {"input": "20203\r\n", "output": "3\r\n"}, {"input": "1002001\r\n", "output": "100200\r\n"}, {"input": "10002223\r\n", "output": "100023\r\n"}, {"input": "1002223\r\n", "output": "10023\r\n"}, {"input": "100000231\r\n", "output": "10000023\r\n"}, {"input": "220\r\n", "output": "0\r\n"}, {"input": "322\r\n", "output": "3\r\n"}, {"input": "100000222\r\n", "output": "1000002\r\n"}, {"input": "10033\r\n", "output": "33\r\n"}, {"input": "2003302\r\n", "output": "330\r\n"}, {"input": "10011001\r\n", "output": "1001001\r\n"}, {"input": "20000000011001111\r\n", "output": "200000000001111\r\n"}, {"input": "100000000\r\n", "output": "0\r\n"}, {"input": "1000\r\n", "output": "0\r\n"}, {"input": "200000000000000000000000000008\r\n", "output": "0\r\n"}, {"input": "1000000000000222\r\n", "output": "10000000000002\r\n"}, {"input": "100000000000000000222\r\n", "output": "1000000000000000002\r\n"}, {"input": "29512\r\n", "output": "2952\r\n"}, {"input": "88888888888888\r\n", "output": "888888888888\r\n"}, {"input": "100000000000222\r\n", "output": "1000000000002\r\n"}, {"input": "11000000\r\n", "output": "0\r\n"}, {"input": "2200\r\n", "output": "0\r\n"}, {"input": "10000555\r\n", "output": "100005\r\n"}, {"input": "1000222\r\n", "output": "10002\r\n"}, {"input": "10021\r\n", "output": "1002\r\n"}, {"input": "223\r\n", "output": "3\r\n"}, {"input": "1013\r\n", "output": "3\r\n"}, {"input": "100020001\r\n", "output": "10002000\r\n"}, {"input": "20000000000000000000932\r\n", "output": "93\r\n"}, {"input": "1010\r\n", "output": "0\r\n"}, {"input": "2000000002222\r\n", "output": "20000000022\r\n"}, {"input": "10213\r\n", "output": "1023\r\n"}, {"input": "109111\r\n", "output": "10911\r\n"}, {"input": "1010101010\r\n", "output": "10001010\r\n"}, {"input": "300055\r\n", "output": "3000\r\n"}, {"input": "200200\r\n", "output": "0\r\n"}, {"input": "202222\r\n", "output": "2022\r\n"}, {"input": "4000888\r\n", "output": "40008\r\n"}, {"input": "200000111\r\n", "output": "2000001\r\n"}, {"input": "2000000111\r\n", "output": "20000001\r\n"}, {"input": "1000000\r\n", "output": "0\r\n"}, {"input": "1003301\r\n", "output": "330\r\n"}, {"input": "100001\r\n", "output": "0\r\n"}, {"input": "40000000000000000000888\r\n", "output": "400000000000000000008\r\n"}, {"input": "100000\r\n", "output": "0\r\n"}, {"input": "4000000888\r\n", "output": "40000008\r\n"}, {"input": "334733\r\n", "output": "3333\r\n"}, {"input": "1000002220\r\n", "output": "10000020\r\n"}, {"input": "100321\r\n", "output": "10032\r\n"}, {"input": "101111\r\n", "output": "1011\r\n"}, {"input": "100000000222\r\n", "output": "1000000002\r\n"}, {"input": "10001\r\n", "output": "0\r\n"}, {"input": "7\r\n", "output": "-1\r\n"}, {"input": "2000000000111\r\n", "output": "20000000001\r\n"}, {"input": "100000001\r\n", "output": "0\r\n"}, {"input": "10000000000222\r\n", "output": "100000000002\r\n"}, {"input": "200000000000000111\r\n", "output": "2000000000000001\r\n"}, {"input": "404044\r\n", "output": "40044\r\n"}, {"input": "30202\r\n", "output": "300\r\n"}, {"input": "20000000000000000111\r\n", "output": "200000000000000001\r\n"}, {"input": "707\r\n", "output": "0\r\n"}, {"input": "20000300000000003000050000003\r\n", "output": "30000000000300000000003\r\n"}, {"input": "400000888\r\n", "output": "4000008\r\n"}, {"input": "2888\r\n", "output": "888\r\n"}, {"input": "200111\r\n", "output": "2001\r\n"}, {"input": "10000000888\r\n", "output": "100000008\r\n"}, {"input": "40000888\r\n", "output": "400008\r\n"}, {"input": "40404044\r\n", "output": "400044\r\n"}, {"input": "5500000000\r\n", "output": "0\r\n"}, {"input": "100012\r\n", "output": "10002\r\n"}, {"input": "1000007\r\n", "output": "0\r\n"}, {"input": "200093\r\n", "output": "93\r\n"}, {"input": "10000000222\r\n", "output": "100000002\r\n"}, {"input": "20000000002\r\n", "output": "0\r\n"}, {"input": "74333\r\n", "output": "333\r\n"}, {"input": "200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\r\n", "output": "0\r\n"}, {"input": "10000000111\r\n", "output": "1000000011\r\n"}, {"input": "100007\r\n", "output": "0\r\n"}, {"input": "20000006711\r\n", "output": "200000061\r\n"}, {"input": "8059\r\n", "output": "9\r\n"}, {"input": "8008\r\n", "output": "0\r\n"}, {"input": "88\r\n", "output": "-1\r\n"}, {"input": "2002\r\n", "output": "0\r\n"}, {"input": "2000111\r\n", "output": "20001\r\n"}, {"input": "100000000100000002\r\n", "output": "10000000000000002\r\n"}, {"input": "1000000000000000000000000000000000\r\n", "output": "0\r\n"}, {"input": "10000000000000000222\r\n", "output": "100000000000000002\r\n"}, {"input": "1000001\r\n", "output": "0\r\n"}, {"input": "200000000000111\r\n", "output": "2000000000001\r\n"}, {"input": "2000000002\r\n", "output": "0\r\n"}, {"input": "2010000100001\r\n", "output": "10000100001\r\n"}, {"input": "200330\r\n", "output": "330\r\n"}, {"input": "10000222\r\n", "output": "100002\r\n"}, {"input": "2005\r\n", "output": "0\r\n"}, {"input": "100000000000822\r\n", "output": "1000000000002\r\n"}, {"input": "10000000000000000000000\r\n", "output": "0\r\n"}, {"input": "7046\r\n", "output": "6\r\n"}, {"input": "4000117\r\n", "output": "400017\r\n"}, {"input": "971\r\n", "output": "9\r\n"}, {"input": "404\r\n", "output": "0\r\n"}, {"input": "5\r\n", "output": "-1\r\n"}, {"input": "164\r\n", "output": "6\r\n"}, {"input": "140\r\n", "output": "0\r\n"}, {"input": "74\r\n", "output": "-1\r\n"}, {"input": "2058232\r\n", "output": "20232\r\n"}, {"input": "4\r\n", "output": "-1\r\n"}, {"input": "20206\r\n", "output": "6\r\n"}, {"input": "103310\r\n", "output": "330\r\n"}, {"input": "100\r\n", "output": "0\r\n"}, {"input": "417179\r\n", "output": "7179\r\n"}, {"input": "70558\r\n", "output": "558\r\n"}, {"input": "298\r\n", "output": "9\r\n"}, {"input": "7003\r\n", "output": "3\r\n"}, {"input": "2212\r\n", "output": "222\r\n"}, {"input": "1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001\r\n", "output": "0\r\n"}, {"input": "2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002\r\n", "output": "0\r\n"}, {"input": "1002200\r\n", "output": "100200\r\n"}, {"input": "1222\r\n", "output": "222\r\n"}, {"input": "101200100\r\n", "output": "10100100\r\n"}, {"input": "1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003\r\n", "output": "3\r\n"}, {"input": "20020201\r\n", "output": "2002020\r\n"}, {"input": "12122\r\n", "output": "1122\r\n"}, {"input": "20200\r\n", "output": "0\r\n"}, {"input": "2\r\n", "output": "-1\r\n"}, {"input": "1000000000000258\r\n", "output": "10000000000008\r\n"}]
| false |
stdio
|
import sys
def is_subsequence(s, t):
t_iter = iter(t)
try:
for c in s:
while next(t_iter) != c:
pass
return True
except StopIteration:
return False
def is_beautiful(s):
if not s:
return False
if s[0] == '0' and len(s) > 1:
return False
total = sum(int(c) for c in s)
return total % 3 == 0
def compute_max_length(n):
sum_digits = sum(int(c) for c in n)
sum_mod3 = sum_digits % 3
has_zero = '0' in n
if sum_mod3 == 0:
if n[0] != '0':
return len(n)
first_non_zero = next((i for i, c in enumerate(n) if c != '0'), None)
if first_non_zero is None:
return 1
return len(n) - first_non_zero
else:
candidates = []
for i, c in enumerate(n):
if int(c) % 3 == sum_mod3:
new_n = n[:i] + n[i+1:]
if not new_n:
continue
first_non_zero = next((j for j, ch in enumerate(new_n) if ch != '0'), None)
if first_non_zero is None:
candidates.append(1)
else:
candidates.append(len(new_n) - first_non_zero)
target_mod = (3 - sum_mod3) % 3
mod_digits = [i for i, c in enumerate(n) if int(c) % 3 == target_mod]
if len(mod_digits) >= 2:
i, j = mod_digits[-2], mod_digits[-1]
new_n = n[:i] + n[i+1:j] + n[j+1:]
if new_n:
first_non_zero = next((k for k, ch in enumerate(new_n) if ch != '0'), None)
if first_non_zero is None:
candidates.append(1)
else:
candidates.append(len(new_n) - first_non_zero)
if has_zero:
candidates.append(1)
return max(candidates) if candidates else 0
def main(input_path, output_path, submission_path):
with open(input_path, 'r') as f:
n = f.read().strip()
with open(submission_path, 'r') as f:
submission = f.read().strip()
if submission == '-1':
max_len = compute_max_length(n)
print(100 if max_len == 0 else 0)
else:
if not is_subsequence(submission, n) or not is_beautiful(submission):
print(0)
return
max_len = compute_max_length(n)
print(100 if len(submission) == max_len else 0)
if __name__ == '__main__':
input_path, output_path, submission_path = sys.argv[1], sys.argv[2], sys.argv[3]
main(input_path, output_path, submission_path)
| true |
99/B
|
99
|
B
|
Python 3
|
TESTS
| 8 | 31 | 0 |
167498988
|
n = int(input())
s = list()
s1 = set()
for _ in range(n):
enter = int(input())
s.append(enter)
s1.add(enter)
if len(s1) == 1:
print("Exemplary pages.")
elif len(s1) == 3:
s1 = list(s1)
for i in range(3):
if s.count(s1[i]) > 1:
x = s1[(i + 1) % 3]
y = s1[(i - 1) % 3]
if y > x:
x, y = y, x
if x - s1[i] == s1[i] - y:
print(f"{x - s1[i]} ml. from cup #{s.index(y) + 1} to cup #{s.index(x) + 1}.")
else:
print("Unrecoverable configuration.")
else:
print("Unrecoverable configuration.")
| 200 | 124 | 307,200 |
90197114
|
n=int(input())
a=[]
for i in range(1,n+1): a.append(int(input()))
mina,maxa=min(a),max(a)
minai,maxai=a.index(mina),a.index(maxa)
if (maxa-mina)%2!=0:
print("Unrecoverable configuration.")
elif mina==maxa:
print("Exemplary pages.")
else:
mid=(maxa-mina)//2
a[maxai]-=mid
a[minai]+=mid
if len(set(a))==1:
print(str(mid)+' ml. from cup #'+str(minai+1)+' to cup #'+str(maxai+1)+'.')
else:
print("Unrecoverable configuration.")
|
Codeforces Beta Round 78 (Div. 2 Only)
|
CF
| 2,011 | 0.5 | 256 |
Help Chef Gerasim
|
In a far away kingdom young pages help to set the table for the King. As they are terribly mischievous, one needs to keep an eye on the control whether they have set everything correctly. This time the royal chef Gerasim had the impression that the pages have played a prank again: they had poured the juice from one cup to another. Now Gerasim wants to check his hypothesis. The good thing is that chef Gerasim always pour the same number of milliliters of juice to all cups in the royal kitchen. Having thoroughly measured the juice in each cup, Gerasim asked you to write a program that will determine from which cup juice was poured to which one; otherwise, the program should determine that this time the pages set the table diligently.
To simplify your task we shall consider the cups to be bottomless so that the juice never overfills a cup and pours out, however much it can be. Besides, by some strange reason in a far away kingdom one can only pour to a cup or from one cup to another an integer number of milliliters of juice.
|
The first line contains integer n — the number of cups on the royal table (1 ≤ n ≤ 1000). Next n lines contain volumes of juice in each cup — non-negative integers, not exceeding 104.
|
If the pages didn't pour the juice, print "Exemplary pages." (without the quotes). If you can determine the volume of juice poured during exactly one juice pouring, print "v ml. from cup #a to cup #b." (without the quotes), where v represents the volume of poured juice, a represents the number of the cup from which the juice was poured (the cups are numbered with consecutive positive integers starting from one in the order in which the cups are described in the input data), b represents the number of the cup into which the juice was poured. Finally, if the given juice's volumes cannot be obtained using no more than one pouring (for example, the pages poured the juice from one cup to another more than once or the royal kitchen maids poured the juice into the cups incorrectly), print "Unrecoverable configuration." (without the quotes).
| null | null |
[{"input": "5\n270\n250\n250\n230\n250", "output": "20 ml. from cup #4 to cup #1."}, {"input": "5\n250\n250\n250\n250\n250", "output": "Exemplary pages."}, {"input": "5\n270\n250\n249\n230\n250", "output": "Unrecoverable configuration."}]
| 1,300 |
["implementation", "sortings"]
| 200 |
[{"input": "5\r\n270\r\n250\r\n250\r\n230\r\n250\r\n", "output": "20 ml. from cup #4 to cup #1.\r\n"}, {"input": "5\r\n250\r\n250\r\n250\r\n250\r\n250\r\n", "output": "Exemplary pages.\r\n"}, {"input": "5\r\n270\r\n250\r\n249\r\n230\r\n250\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n200\r\n190\r\n210\r\n200\r\n", "output": "10 ml. from cup #2 to cup #3.\r\n"}, {"input": "4\r\n1\r\n2\r\n3\r\n4\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "1\r\n0\r\n", "output": "Exemplary pages.\r\n"}, {"input": "2\r\n0\r\n0\r\n", "output": "Exemplary pages.\r\n"}, {"input": "2\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "2\r\n0\r\n2\r\n", "output": "1 ml. from cup #1 to cup #2.\r\n"}, {"input": "2\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "2\r\n1\r\n1\r\n", "output": "Exemplary pages.\r\n"}, {"input": "2\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "2\r\n2\r\n0\r\n", "output": "1 ml. from cup #2 to cup #1.\r\n"}, {"input": "2\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "2\r\n2\r\n2\r\n", "output": "Exemplary pages.\r\n"}, {"input": "3\r\n0\r\n0\r\n0\r\n", "output": "Exemplary pages.\r\n"}, {"input": "3\r\n0\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n0\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n0\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n0\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n0\r\n1\r\n2\r\n", "output": "1 ml. from cup #1 to cup #3.\r\n"}, {"input": "3\r\n0\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n0\r\n2\r\n1\r\n", "output": "1 ml. from cup #1 to cup #2.\r\n"}, {"input": "3\r\n0\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n0\r\n2\r\n", "output": "1 ml. from cup #2 to cup #3.\r\n"}, {"input": "3\r\n1\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n1\r\n1\r\n", "output": "Exemplary pages.\r\n"}, {"input": "3\r\n1\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n2\r\n0\r\n", "output": "1 ml. from cup #3 to cup #2.\r\n"}, {"input": "3\r\n1\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n0\r\n1\r\n", "output": "1 ml. from cup #2 to cup #1.\r\n"}, {"input": "3\r\n2\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n1\r\n0\r\n", "output": "1 ml. from cup #3 to cup #1.\r\n"}, {"input": "3\r\n2\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n2\r\n2\r\n", "output": "Exemplary pages.\r\n"}, {"input": "4\r\n0\r\n0\r\n0\r\n0\r\n", "output": "Exemplary pages.\r\n"}, {"input": "4\r\n0\r\n0\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n1\r\n2\r\n", "output": "1 ml. from cup #1 to cup #4.\r\n"}, {"input": "4\r\n0\r\n1\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n2\r\n1\r\n", "output": "1 ml. from cup #1 to cup #3.\r\n"}, {"input": "4\r\n0\r\n1\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n1\r\n1\r\n", "output": "1 ml. from cup #1 to cup #2.\r\n"}, {"input": "4\r\n0\r\n2\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n1\r\n2\r\n", "output": "1 ml. from cup #2 to cup #4.\r\n"}, {"input": "4\r\n1\r\n0\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n2\r\n1\r\n", "output": "1 ml. from cup #2 to cup #3.\r\n"}, {"input": "4\r\n1\r\n0\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n0\r\n2\r\n", "output": "1 ml. from cup #3 to cup #4.\r\n"}, {"input": "4\r\n1\r\n1\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n1\r\n1\r\n", "output": "Exemplary pages.\r\n"}, {"input": "4\r\n1\r\n1\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n2\r\n0\r\n", "output": "1 ml. from cup #4 to cup #3.\r\n"}, {"input": "4\r\n1\r\n1\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n0\r\n1\r\n", "output": "1 ml. from cup #3 to cup #2.\r\n"}, {"input": "4\r\n1\r\n2\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n1\r\n0\r\n", "output": "1 ml. from cup #4 to cup #2.\r\n"}, {"input": "4\r\n1\r\n2\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n1\r\n1\r\n", "output": "1 ml. from cup #2 to cup #1.\r\n"}, {"input": "4\r\n2\r\n0\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n0\r\n1\r\n", "output": "1 ml. from cup #3 to cup #1.\r\n"}, {"input": "4\r\n2\r\n1\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n1\r\n0\r\n", "output": "1 ml. from cup #4 to cup #1.\r\n"}, {"input": "4\r\n2\r\n1\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n2\r\n2\r\n", "output": "Exemplary pages.\r\n"}, {"input": "27\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n2626\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n8572\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n", "output": "2973 ml. from cup #11 to cup #17.\r\n"}, {"input": "19\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n82\r\n5001\r\n9919\r\n5001\r\n5001\r\n", "output": "Unrecoverable configuration.\r\n"}]
| false |
stdio
| null | true |
818/E
|
818
|
E
|
PyPy 3
|
TESTS
| 13 | 93 | 1,843,200 |
106262915
|
n,k=map(int,input().split())
l=list(map(int,input().split()))
ans=0
last=0
now=1
for i in range(len(l)):
now=now*l[i]
while now%k==0 and last<=i:
ans+=n-i
now/=l[last]
last+=1
print(ans)
| 135 | 77 | 13,414,400 |
170114604
|
R,G=lambda:map(int,input().split()),range
n,k=R();a=[0]+[*R()];z,l,p=0,1,1
for r in G(1,n+1):
p=p*a[r]%k
if p==0:
p=1;i=r
while p*a[i]%k:p=p*a[i]%k;i-=1
z+=(n-r+1)*(i-l+1);l=i+1
print(z)
|
Educational Codeforces Round 24
|
ICPC
| 2,017 | 2 | 256 |
Card Game Again
|
Vova again tries to play some computer card game.
The rules of deck creation in this game are simple. Vova is given an existing deck of n cards and a magic number k. The order of the cards in the deck is fixed. Each card has a number written on it; number ai is written on the i-th card in the deck.
After receiving the deck and the magic number, Vova removes x (possibly x = 0) cards from the top of the deck, y (possibly y = 0) cards from the bottom of the deck, and the rest of the deck is his new deck (Vova has to leave at least one card in the deck after removing cards). So Vova's new deck actually contains cards x + 1, x + 2, ... n - y - 1, n - y from the original deck.
Vova's new deck is considered valid iff the product of all numbers written on the cards in his new deck is divisible by k. So Vova received a deck (possibly not a valid one) and a number k, and now he wonders, how many ways are there to choose x and y so the deck he will get after removing x cards from the top and y cards from the bottom is valid?
|
The first line contains two integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ 109).
The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the numbers written on the cards.
|
Print the number of ways to choose x and y so the resulting deck is valid.
| null |
In the first example the possible values of x and y are:
1. x = 0, y = 0;
2. x = 1, y = 0;
3. x = 2, y = 0;
4. x = 0, y = 1.
|
[{"input": "3 4\n6 2 8", "output": "4"}, {"input": "3 6\n9 1 14", "output": "1"}]
| 1,900 |
["binary search", "data structures", "number theory", "two pointers"]
| 135 |
[{"input": "3 4\r\n6 2 8\r\n", "output": "4\r\n"}, {"input": "3 6\r\n9 1 14\r\n", "output": "1\r\n"}, {"input": "5 1\r\n1 3 1 3 1\r\n", "output": "15\r\n"}, {"input": "5 1\r\n5 5 5 5 5\r\n", "output": "15\r\n"}, {"input": "5 1\r\n5 4 4 4 4\r\n", "output": "15\r\n"}, {"input": "100 1\r\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\r\n", "output": "5050\r\n"}, {"input": "100 1\r\n3 3 2 1 1 2 1 2 3 4 1 5 2 4 5 1 1 3 2 3 4 2 1 3 4 4 5 5 1 5 2 5 3 3 1 1 1 3 2 2 3 4 4 4 4 3 1 3 5 3 3 3 3 2 3 2 2 3 3 1 2 4 3 2 2 5 3 1 5 2 2 5 1 2 1 1 5 1 5 2 4 5 3 4 2 5 4 2 2 5 5 5 3 3 5 3 4 3 3 1\r\n", "output": "5050\r\n"}, {"input": "100 5\r\n4 4 3 2 4 4 1 2 2 1 5 3 2 5 5 3 2 3 4 5 2 2 3 4 2 4 3 1 2 3 5 5 1 3 3 5 2 3 3 4 1 3 1 5 4 4 2 1 5 1 4 4 1 5 1 1 5 5 5 4 1 3 1 2 3 2 4 5 5 1 3 4 3 3 1 2 2 4 1 5 1 1 2 4 4 4 5 5 5 3 4 3 3 3 3 2 1 1 5 5\r\n", "output": "4713\r\n"}, {"input": "100 6\r\n4 4 1 1 1 1 3 3 5 5 4 2 2 4 3 4 4 5 5 4 5 1 3 1 5 4 5 1 2 5 5 2 2 4 2 4 4 2 5 5 3 3 1 3 3 5 2 3 1 4 1 4 4 1 5 5 1 2 3 2 3 3 5 3 4 2 3 4 3 1 5 3 5 5 3 5 4 4 3 1 1 2 1 2 1 3 2 4 3 2 1 4 3 1 1 5 1 5 4 3\r\n", "output": "4580\r\n"}, {"input": "100 72\r\n8 8 7 9 6 1 4 5 3 7 5 10 5 4 1 3 4 1 3 1 6 6 4 5 4 5 6 1 10 7 9 1 6 10 6 6 9 3 3 4 5 9 4 9 8 1 5 9 3 7 1 8 5 2 1 1 7 7 7 6 6 4 2 9 10 2 8 3 1 1 4 8 5 9 7 10 9 4 2 3 7 7 6 7 8 5 1 3 8 5 1 8 9 10 3 7 1 8 10 5\r\n", "output": "4549\r\n"}, {"input": "100 72\r\n3 2 1 3 3 3 4 3 5 5 2 5 1 2 2 2 1 4 1 5 1 4 5 4 3 1 4 3 4 4 1 4 4 3 4 1 4 4 5 2 2 3 3 5 4 5 4 2 4 3 1 1 1 4 5 5 3 1 5 3 4 4 5 3 5 1 4 3 2 2 1 4 2 1 3 2 4 2 1 4 4 1 3 4 4 4 1 5 5 2 5 2 3 1 5 1 1 1 2 3\r\n", "output": "4123\r\n"}, {"input": "2 999634589\r\n31607 31627\r\n", "output": "1\r\n"}, {"input": "1 1\r\n1\r\n", "output": "1\r\n"}, {"input": "1 2\r\n1\r\n", "output": "0\r\n"}, {"input": "1 3\r\n1\r\n", "output": "0\r\n"}, {"input": "1 4\r\n1\r\n", "output": "0\r\n"}, {"input": "1 5\r\n3\r\n", "output": "0\r\n"}, {"input": "1 6\r\n4\r\n", "output": "0\r\n"}, {"input": "1 7\r\n2\r\n", "output": "0\r\n"}, {"input": "1 8\r\n3\r\n", "output": "0\r\n"}, {"input": "1 9\r\n5\r\n", "output": "0\r\n"}, {"input": "1 10\r\n3\r\n", "output": "0\r\n"}, {"input": "2 1\r\n1 1\r\n", "output": "3\r\n"}, {"input": "2 2\r\n2 2\r\n", "output": "3\r\n"}, {"input": "2 3\r\n1 2\r\n", "output": "0\r\n"}, {"input": "2 4\r\n1 2\r\n", "output": "0\r\n"}, {"input": "2 5\r\n1 1\r\n", "output": "0\r\n"}, {"input": "2 6\r\n2 1\r\n", "output": "0\r\n"}, {"input": "2 7\r\n1 4\r\n", "output": "0\r\n"}, {"input": "2 8\r\n5 3\r\n", "output": "0\r\n"}, {"input": "2 9\r\n2 2\r\n", "output": "0\r\n"}, {"input": "2 10\r\n6 1\r\n", "output": "0\r\n"}, {"input": "3 1\r\n1 1 1\r\n", "output": "6\r\n"}, {"input": "3 2\r\n2 2 1\r\n", "output": "5\r\n"}, {"input": "3 3\r\n2 1 2\r\n", "output": "0\r\n"}, {"input": "3 4\r\n2 2 2\r\n", "output": "3\r\n"}, {"input": "3 5\r\n1 1 2\r\n", "output": "0\r\n"}, {"input": "3 6\r\n4 3 2\r\n", "output": "3\r\n"}, {"input": "3 7\r\n3 4 1\r\n", "output": "0\r\n"}, {"input": "3 8\r\n5 1 4\r\n", "output": "0\r\n"}, {"input": "3 9\r\n3 2 1\r\n", "output": "0\r\n"}, {"input": "3 10\r\n6 5 5\r\n", "output": "2\r\n"}, {"input": "4 1\r\n1 1 1 1\r\n", "output": "10\r\n"}, {"input": "4 2\r\n2 2 1 2\r\n", "output": "9\r\n"}, {"input": "4 3\r\n2 1 1 1\r\n", "output": "0\r\n"}, {"input": "4 4\r\n2 2 1 1\r\n", "output": "3\r\n"}, {"input": "4 5\r\n2 3 2 1\r\n", "output": "0\r\n"}, {"input": "4 6\r\n1 1 3 3\r\n", "output": "0\r\n"}, {"input": "4 7\r\n1 1 2 2\r\n", "output": "0\r\n"}, {"input": "4 8\r\n5 4 5 5\r\n", "output": "0\r\n"}, {"input": "4 9\r\n1 1 4 2\r\n", "output": "0\r\n"}, {"input": "4 10\r\n2 6 2 1\r\n", "output": "0\r\n"}, {"input": "5 1\r\n1 1 1 1 1\r\n", "output": "15\r\n"}, {"input": "5 2\r\n2 2 1 2 1\r\n", "output": "13\r\n"}, {"input": "5 3\r\n2 1 1 2 1\r\n", "output": "0\r\n"}, {"input": "5 4\r\n2 2 1 3 1\r\n", "output": "4\r\n"}, {"input": "5 5\r\n2 3 1 1 3\r\n", "output": "0\r\n"}, {"input": "5 6\r\n3 4 3 4 3\r\n", "output": "10\r\n"}, {"input": "5 7\r\n3 1 3 2 4\r\n", "output": "0\r\n"}, {"input": "5 8\r\n2 2 3 3 1\r\n", "output": "0\r\n"}, {"input": "5 9\r\n3 1 3 3 4\r\n", "output": "7\r\n"}, {"input": "5 10\r\n3 6 6 1 5\r\n", "output": "3\r\n"}, {"input": "6 1\r\n1 1 1 1 1 1\r\n", "output": "21\r\n"}, {"input": "6 2\r\n1 2 2 1 1 1\r\n", "output": "14\r\n"}, {"input": "6 3\r\n2 2 2 2 1 2\r\n", "output": "0\r\n"}, {"input": "6 4\r\n1 3 3 3 3 2\r\n", "output": "0\r\n"}, {"input": "6 5\r\n2 3 3 2 1 2\r\n", "output": "0\r\n"}, {"input": "6 6\r\n1 2 4 1 4 4\r\n", "output": "0\r\n"}, {"input": "6 7\r\n2 2 4 3 2 1\r\n", "output": "0\r\n"}, {"input": "6 8\r\n3 2 3 5 5 3\r\n", "output": "0\r\n"}, {"input": "6 9\r\n1 4 1 2 1 1\r\n", "output": "0\r\n"}, {"input": "6 10\r\n1 2 5 6 6 6\r\n", "output": "11\r\n"}, {"input": "7 1\r\n1 1 1 1 1 1 1\r\n", "output": "28\r\n"}, {"input": "7 2\r\n1 1 2 2 2 2 1\r\n", "output": "24\r\n"}, {"input": "7 3\r\n2 2 1 1 2 2 2\r\n", "output": "0\r\n"}, {"input": "7 4\r\n3 2 1 2 1 1 1\r\n", "output": "8\r\n"}, {"input": "7 5\r\n2 3 3 3 2 3 2\r\n", "output": "0\r\n"}, {"input": "7 6\r\n3 4 4 1 4 3 2\r\n", "output": "15\r\n"}, {"input": "7 7\r\n4 2 4 4 1 4 4\r\n", "output": "0\r\n"}, {"input": "7 8\r\n4 4 2 4 2 5 3\r\n", "output": "18\r\n"}, {"input": "7 9\r\n2 1 3 4 4 5 4\r\n", "output": "0\r\n"}, {"input": "7 10\r\n6 3 3 5 3 6 1\r\n", "output": "10\r\n"}, {"input": "8 1\r\n1 1 1 1 1 1 1 1\r\n", "output": "36\r\n"}, {"input": "8 2\r\n1 1 1 1 1 1 1 2\r\n", "output": "8\r\n"}, {"input": "8 3\r\n1 1 2 2 1 1 2 2\r\n", "output": "0\r\n"}, {"input": "8 4\r\n2 3 2 3 3 3 2 3\r\n", "output": "10\r\n"}, {"input": "8 5\r\n1 3 1 2 2 2 1 3\r\n", "output": "0\r\n"}, {"input": "8 6\r\n4 2 4 2 1 2 1 4\r\n", "output": "0\r\n"}, {"input": "8 7\r\n2 2 1 4 4 4 2 2\r\n", "output": "0\r\n"}, {"input": "8 8\r\n5 2 1 2 4 2 2 4\r\n", "output": "21\r\n"}, {"input": "8 9\r\n4 4 2 2 5 5 4 1\r\n", "output": "0\r\n"}, {"input": "8 10\r\n2 1 4 4 3 4 4 6\r\n", "output": "0\r\n"}, {"input": "9 1\r\n1 1 1 1 1 1 1 1 1\r\n", "output": "45\r\n"}, {"input": "9 2\r\n1 1 1 2 1 1 2 2 2\r\n", "output": "36\r\n"}, {"input": "9 3\r\n1 1 1 2 2 1 1 2 1\r\n", "output": "0\r\n"}, {"input": "9 4\r\n1 1 2 1 2 1 1 1 1\r\n", "output": "15\r\n"}, {"input": "9 5\r\n3 2 3 2 3 1 1 3 2\r\n", "output": "0\r\n"}, {"input": "9 6\r\n2 1 1 3 2 4 1 2 2\r\n", "output": "21\r\n"}, {"input": "9 7\r\n4 3 2 1 2 3 3 4 4\r\n", "output": "0\r\n"}, {"input": "9 8\r\n5 5 2 1 3 1 3 1 3\r\n", "output": "0\r\n"}, {"input": "9 9\r\n2 4 1 4 4 3 3 4 1\r\n", "output": "18\r\n"}, {"input": "9 10\r\n4 3 2 5 2 2 2 2 6\r\n", "output": "23\r\n"}, {"input": "10 1\r\n1 1 1 1 1 1 1 1 1 1\r\n", "output": "55\r\n"}, {"input": "10 2\r\n2 2 2 2 2 2 2 1 2 1\r\n", "output": "53\r\n"}, {"input": "10 3\r\n2 2 1 1 2 2 2 2 1 2\r\n", "output": "0\r\n"}, {"input": "10 4\r\n1 1 2 3 3 1 2 2 2 3\r\n", "output": "26\r\n"}, {"input": "10 5\r\n3 3 2 2 3 1 1 1 3 1\r\n", "output": "0\r\n"}, {"input": "10 6\r\n4 4 4 3 2 1 1 1 2 4\r\n", "output": "27\r\n"}, {"input": "10 7\r\n4 2 2 2 3 3 2 4 4 3\r\n", "output": "0\r\n"}, {"input": "10 8\r\n5 4 1 4 3 2 1 2 3 3\r\n", "output": "24\r\n"}, {"input": "10 9\r\n1 2 3 4 5 2 3 5 5 4\r\n", "output": "12\r\n"}, {"input": "10 10\r\n5 3 2 5 1 2 5 1 5 1\r\n", "output": "35\r\n"}, {"input": "1 1000000000\r\n1\r\n", "output": "0\r\n"}, {"input": "1 1000000000\r\n1000000000\r\n", "output": "1\r\n"}, {"input": "1 100000000\r\n1000000000\r\n", "output": "1\r\n"}, {"input": "1 1\r\n1000000000\r\n", "output": "1\r\n"}]
| false |
stdio
| null | true |
99/B
|
99
|
B
|
PyPy 3-64
|
TESTS
| 39 | 77 | 614,400 |
149230725
|
import math,sys;input=sys.stdin.readline;S=lambda:input().rstrip();I=lambda:int(S());M=lambda:map(int,S().split());L=lambda:list(M());mod1=1000000007;mod2=998244353
from collections import defaultdict
arr = []
sm = 0
n = I()
for _ in range(n):
t = I()
sm+=t
arr.append(t)
each = sm//n
over_under = [0]*(n)
for i in range(n):
if arr[i]>each:
over_under[i] = arr[i]-each
elif arr[i]<each:
over_under[i] = arr[i]-each
found = defaultdict()
ans = []
for i in range(n):
if over_under[i]==0:
continue
if over_under[i]>0 or over_under[i]<0:
if -1*over_under[i] in found:
if over_under[i]>0:
ans.append([over_under[i],i+1, found[-1*over_under[i]] +1])
else:
ans.append([-1*over_under[i],found[-1*over_under[i]]+1,i+1])
found.pop(-1*over_under[i])
else:
found[over_under[i]] = i
if len(ans)==0 and len(found)==0:
print("Exemplary pages.")
elif len(found)==0 and len(ans)!=0:
for x,y,z in ans:
print(x, "ml.", "from cup #" + str(z) , "to cup #"+ str(y)+".")
else:
print("Unrecoverable configuration.")
| 200 | 124 | 307,200 |
103664743
|
n = int(input())
a = []
sum = 0
for i in range(n):
a.append(int(input()))
sum+=a[i]
c = sum//n
fro = 0
to = 0
cou = 0
for i in range(n):
if c<a[i]:
to = i+1
cou+=1
elif c>a[i]:
fro = i+1
cou+=1
amt = (a[to-1]-a[fro-1])//2
a[to-1]-=amt
a[fro-1]+=amt
if fro == to:
print("Exemplary pages.")
else:
c = a[0]
flag = 0
for i in range(n):
if c != a[i]:
flag = 1
break
if flag:
print("Unrecoverable configuration.")
else:
s=str(amt)+" ml. from cup #"+str(fro)+ " to cup #"+str(to)+"."
print(s)
|
Codeforces Beta Round 78 (Div. 2 Only)
|
CF
| 2,011 | 0.5 | 256 |
Help Chef Gerasim
|
In a far away kingdom young pages help to set the table for the King. As they are terribly mischievous, one needs to keep an eye on the control whether they have set everything correctly. This time the royal chef Gerasim had the impression that the pages have played a prank again: they had poured the juice from one cup to another. Now Gerasim wants to check his hypothesis. The good thing is that chef Gerasim always pour the same number of milliliters of juice to all cups in the royal kitchen. Having thoroughly measured the juice in each cup, Gerasim asked you to write a program that will determine from which cup juice was poured to which one; otherwise, the program should determine that this time the pages set the table diligently.
To simplify your task we shall consider the cups to be bottomless so that the juice never overfills a cup and pours out, however much it can be. Besides, by some strange reason in a far away kingdom one can only pour to a cup or from one cup to another an integer number of milliliters of juice.
|
The first line contains integer n — the number of cups on the royal table (1 ≤ n ≤ 1000). Next n lines contain volumes of juice in each cup — non-negative integers, not exceeding 104.
|
If the pages didn't pour the juice, print "Exemplary pages." (without the quotes). If you can determine the volume of juice poured during exactly one juice pouring, print "v ml. from cup #a to cup #b." (without the quotes), where v represents the volume of poured juice, a represents the number of the cup from which the juice was poured (the cups are numbered with consecutive positive integers starting from one in the order in which the cups are described in the input data), b represents the number of the cup into which the juice was poured. Finally, if the given juice's volumes cannot be obtained using no more than one pouring (for example, the pages poured the juice from one cup to another more than once or the royal kitchen maids poured the juice into the cups incorrectly), print "Unrecoverable configuration." (without the quotes).
| null | null |
[{"input": "5\n270\n250\n250\n230\n250", "output": "20 ml. from cup #4 to cup #1."}, {"input": "5\n250\n250\n250\n250\n250", "output": "Exemplary pages."}, {"input": "5\n270\n250\n249\n230\n250", "output": "Unrecoverable configuration."}]
| 1,300 |
["implementation", "sortings"]
| 200 |
[{"input": "5\r\n270\r\n250\r\n250\r\n230\r\n250\r\n", "output": "20 ml. from cup #4 to cup #1.\r\n"}, {"input": "5\r\n250\r\n250\r\n250\r\n250\r\n250\r\n", "output": "Exemplary pages.\r\n"}, {"input": "5\r\n270\r\n250\r\n249\r\n230\r\n250\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n200\r\n190\r\n210\r\n200\r\n", "output": "10 ml. from cup #2 to cup #3.\r\n"}, {"input": "4\r\n1\r\n2\r\n3\r\n4\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "1\r\n0\r\n", "output": "Exemplary pages.\r\n"}, {"input": "2\r\n0\r\n0\r\n", "output": "Exemplary pages.\r\n"}, {"input": "2\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "2\r\n0\r\n2\r\n", "output": "1 ml. from cup #1 to cup #2.\r\n"}, {"input": "2\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "2\r\n1\r\n1\r\n", "output": "Exemplary pages.\r\n"}, {"input": "2\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "2\r\n2\r\n0\r\n", "output": "1 ml. from cup #2 to cup #1.\r\n"}, {"input": "2\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "2\r\n2\r\n2\r\n", "output": "Exemplary pages.\r\n"}, {"input": "3\r\n0\r\n0\r\n0\r\n", "output": "Exemplary pages.\r\n"}, {"input": "3\r\n0\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n0\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n0\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n0\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n0\r\n1\r\n2\r\n", "output": "1 ml. from cup #1 to cup #3.\r\n"}, {"input": "3\r\n0\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n0\r\n2\r\n1\r\n", "output": "1 ml. from cup #1 to cup #2.\r\n"}, {"input": "3\r\n0\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n0\r\n2\r\n", "output": "1 ml. from cup #2 to cup #3.\r\n"}, {"input": "3\r\n1\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n1\r\n1\r\n", "output": "Exemplary pages.\r\n"}, {"input": "3\r\n1\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n2\r\n0\r\n", "output": "1 ml. from cup #3 to cup #2.\r\n"}, {"input": "3\r\n1\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n1\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n0\r\n1\r\n", "output": "1 ml. from cup #2 to cup #1.\r\n"}, {"input": "3\r\n2\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n1\r\n0\r\n", "output": "1 ml. from cup #3 to cup #1.\r\n"}, {"input": "3\r\n2\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "3\r\n2\r\n2\r\n2\r\n", "output": "Exemplary pages.\r\n"}, {"input": "4\r\n0\r\n0\r\n0\r\n0\r\n", "output": "Exemplary pages.\r\n"}, {"input": "4\r\n0\r\n0\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n0\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n1\r\n2\r\n", "output": "1 ml. from cup #1 to cup #4.\r\n"}, {"input": "4\r\n0\r\n1\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n1\r\n2\r\n1\r\n", "output": "1 ml. from cup #1 to cup #3.\r\n"}, {"input": "4\r\n0\r\n1\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n1\r\n1\r\n", "output": "1 ml. from cup #1 to cup #2.\r\n"}, {"input": "4\r\n0\r\n2\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n0\r\n2\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n1\r\n2\r\n", "output": "1 ml. from cup #2 to cup #4.\r\n"}, {"input": "4\r\n1\r\n0\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n0\r\n2\r\n1\r\n", "output": "1 ml. from cup #2 to cup #3.\r\n"}, {"input": "4\r\n1\r\n0\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n0\r\n2\r\n", "output": "1 ml. from cup #3 to cup #4.\r\n"}, {"input": "4\r\n1\r\n1\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n1\r\n1\r\n", "output": "Exemplary pages.\r\n"}, {"input": "4\r\n1\r\n1\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n2\r\n0\r\n", "output": "1 ml. from cup #4 to cup #3.\r\n"}, {"input": "4\r\n1\r\n1\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n1\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n0\r\n1\r\n", "output": "1 ml. from cup #3 to cup #2.\r\n"}, {"input": "4\r\n1\r\n2\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n1\r\n0\r\n", "output": "1 ml. from cup #4 to cup #2.\r\n"}, {"input": "4\r\n1\r\n2\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n1\r\n2\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n1\r\n1\r\n", "output": "1 ml. from cup #2 to cup #1.\r\n"}, {"input": "4\r\n2\r\n0\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n0\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n0\r\n1\r\n", "output": "1 ml. from cup #3 to cup #1.\r\n"}, {"input": "4\r\n2\r\n1\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n1\r\n0\r\n", "output": "1 ml. from cup #4 to cup #1.\r\n"}, {"input": "4\r\n2\r\n1\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n1\r\n2\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n0\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n0\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n0\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n1\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n1\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n1\r\n2\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n2\r\n0\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n2\r\n1\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n2\r\n2\r\n2\r\n2\r\n", "output": "Exemplary pages.\r\n"}, {"input": "27\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n2626\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n8572\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n5599\r\n", "output": "2973 ml. from cup #11 to cup #17.\r\n"}, {"input": "19\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n5001\r\n82\r\n5001\r\n9919\r\n5001\r\n5001\r\n", "output": "Unrecoverable configuration.\r\n"}]
| false |
stdio
| null | true |
99/A
|
99
|
A
|
Python 3
|
TESTS
| 134 | 154 | 6,963,200 |
124043707
|
n = input()
num = n.split(".")
the_num = int(num[0])
dec_part = int(num[1])
p = (len(num[1]))
the_dec_part = int(num[1])/pow(10, p)
if(the_num%10 == 9):
print('GOTO Vasilisa.')
elif(the_num%10 != 9 and the_dec_part<0.5):
print(the_num)
elif(the_num%10 != 9 and the_dec_part>=0.5):
print(the_num+1)
| 150 | 92 | 0 |
4701450
|
t = input()
k = t.find('.')
if k < 0: print(int(t))
elif t[k - 1] == '9': print('GOTO Vasilisa.')
else: print(int(t[:k]) + int(t[k + 1] > '4'))
|
Codeforces Beta Round 78 (Div. 2 Only)
|
CF
| 2,011 | 2 | 256 |
Help Far Away Kingdom
|
In a far away kingdom lived the King, the Prince, the Shoemaker, the Dressmaker and many other citizens. They lived happily until great trouble came into the Kingdom. The ACMers settled there.
Most damage those strange creatures inflicted upon the kingdom was that they loved high precision numbers. As a result, the Kingdom healers had already had three appointments with the merchants who were asked to sell, say, exactly 0.273549107 beer barrels. To deal with the problem somehow, the King issued an order obliging rounding up all numbers to the closest integer to simplify calculations. Specifically, the order went like this:
- If a number's integer part does not end with digit 9 and its fractional part is strictly less than 0.5, then the rounded up number coincides with the number’s integer part.
- If a number's integer part does not end with digit 9 and its fractional part is not less than 0.5, the rounded up number is obtained if we add 1 to the last digit of the number’s integer part.
- If the number’s integer part ends with digit 9, to round up the numbers one should go to Vasilisa the Wise. In the whole Kingdom she is the only one who can perform the tricky operation of carrying into the next position.
Merchants found the algorithm very sophisticated and they asked you (the ACMers) to help them. Can you write a program that would perform the rounding according to the King’s order?
|
The first line contains a single number to round up — the integer part (a non-empty set of decimal digits that do not start with 0 — with the exception of a case when the set consists of a single digit — in this case 0 can go first), then follows character «.» (a dot), and then follows the fractional part (any non-empty set of decimal digits). The number's length does not exceed 1000 characters, including the dot. There are no other characters in the input data.
|
If the last number of the integer part is not equal to 9, print the rounded-up number without leading zeroes. Otherwise, print the message "GOTO Vasilisa." (without the quotes).
| null | null |
[{"input": "0.0", "output": "0"}, {"input": "1.49", "output": "1"}, {"input": "1.50", "output": "2"}, {"input": "2.71828182845904523536", "output": "3"}, {"input": "3.14159265358979323846", "output": "3"}, {"input": "12345678901234567890.1", "output": "12345678901234567890"}, {"input": "123456789123456789.999", "output": "GOTO Vasilisa."}]
| 800 |
["strings"]
| 150 |
[{"input": "0.0\r\n", "output": "0"}, {"input": "1.49\r\n", "output": "1"}, {"input": "1.50\r\n", "output": "2"}, {"input": "2.71828182845904523536\r\n", "output": "3"}, {"input": "3.14159265358979323846\r\n", "output": "3"}, {"input": "12345678901234567890.1\r\n", "output": "12345678901234567890"}, {"input": "123456789123456789.999\r\n", "output": "GOTO Vasilisa."}, {"input": "12345678901234567890.9\r\n", "output": "12345678901234567891"}, {"input": "123456789123456788.999\r\n", "output": "123456789123456789"}, {"input": "9.000\r\n", "output": "GOTO Vasilisa."}, {"input": "0.1\r\n", "output": "0"}, {"input": "0.2\r\n", "output": "0"}, {"input": "0.3\r\n", "output": "0"}, {"input": "0.4\r\n", "output": "0"}, {"input": "0.5\r\n", "output": "1"}, {"input": "0.6\r\n", "output": "1"}, {"input": "0.7\r\n", "output": "1"}, {"input": "0.8\r\n", "output": "1"}, {"input": "0.9\r\n", "output": "1"}, {"input": "1.0\r\n", "output": "1"}, {"input": "1.1\r\n", "output": "1"}, {"input": "1.2\r\n", "output": "1"}, {"input": "1.3\r\n", "output": "1"}, {"input": "1.4\r\n", "output": "1"}, {"input": "1.5\r\n", "output": "2"}, {"input": "1.6\r\n", "output": "2"}, {"input": "1.7\r\n", "output": "2"}, {"input": "1.8\r\n", "output": "2"}, {"input": "1.9\r\n", "output": "2"}, {"input": "2.0\r\n", "output": "2"}, {"input": "2.1\r\n", "output": "2"}, {"input": "2.2\r\n", "output": "2"}, {"input": "2.3\r\n", "output": "2"}, {"input": "2.4\r\n", "output": "2"}, {"input": "2.5\r\n", "output": "3"}, {"input": "2.6\r\n", "output": "3"}, {"input": "2.7\r\n", "output": "3"}, {"input": "2.8\r\n", "output": "3"}, {"input": "2.9\r\n", "output": "3"}, {"input": "3.0\r\n", "output": "3"}, {"input": "3.1\r\n", "output": "3"}, {"input": "3.2\r\n", "output": "3"}, {"input": "3.3\r\n", "output": "3"}, {"input": "3.4\r\n", "output": "3"}, {"input": "3.5\r\n", "output": "4"}, {"input": "3.6\r\n", "output": "4"}, {"input": "3.7\r\n", "output": "4"}, {"input": "3.8\r\n", "output": "4"}, {"input": "3.9\r\n", "output": "4"}, {"input": "4.0\r\n", "output": "4"}, {"input": "4.1\r\n", "output": "4"}, {"input": "4.2\r\n", "output": "4"}, {"input": "4.3\r\n", "output": "4"}, {"input": "4.4\r\n", "output": "4"}, {"input": "4.5\r\n", "output": "5"}, {"input": "4.6\r\n", "output": "5"}, {"input": "4.7\r\n", "output": "5"}, {"input": "4.8\r\n", "output": "5"}, {"input": "4.9\r\n", "output": "5"}, {"input": "5.0\r\n", "output": "5"}, {"input": "5.1\r\n", "output": "5"}, {"input": "5.2\r\n", "output": "5"}, {"input": "5.3\r\n", "output": "5"}, {"input": "5.4\r\n", "output": "5"}, {"input": "5.5\r\n", "output": "6"}, {"input": "5.6\r\n", "output": "6"}, {"input": "5.7\r\n", "output": "6"}, {"input": "5.8\r\n", "output": "6"}, {"input": "5.9\r\n", "output": "6"}, {"input": "6.0\r\n", "output": "6"}, {"input": "6.1\r\n", "output": "6"}, {"input": "6.2\r\n", "output": "6"}, {"input": "6.3\r\n", "output": "6"}, {"input": "6.4\r\n", "output": "6"}, {"input": "6.5\r\n", "output": "7"}, {"input": "6.6\r\n", "output": "7"}, {"input": "6.7\r\n", "output": "7"}, {"input": "6.8\r\n", "output": "7"}, {"input": "6.9\r\n", "output": "7"}, {"input": "7.0\r\n", "output": "7"}, {"input": "7.1\r\n", "output": "7"}, {"input": "7.2\r\n", "output": "7"}, {"input": "7.3\r\n", "output": "7"}, {"input": "7.4\r\n", "output": "7"}, {"input": "7.5\r\n", "output": "8"}, {"input": "7.6\r\n", "output": "8"}, {"input": "7.7\r\n", "output": "8"}, {"input": "7.8\r\n", "output": "8"}, {"input": "7.9\r\n", "output": "8"}, {"input": "8.0\r\n", "output": "8"}, {"input": "8.1\r\n", "output": "8"}, {"input": "8.2\r\n", "output": "8"}, {"input": "8.3\r\n", "output": "8"}, {"input": "8.4\r\n", "output": "8"}, {"input": "8.5\r\n", "output": "9"}, {"input": "8.6\r\n", "output": "9"}, {"input": "8.7\r\n", "output": "9"}, {"input": "8.8\r\n", "output": "9"}, {"input": "8.9\r\n", "output": "9"}, {"input": "9.0\r\n", "output": "GOTO Vasilisa."}, {"input": "9.1\r\n", "output": "GOTO Vasilisa."}, {"input": "9.2\r\n", "output": "GOTO Vasilisa."}, {"input": "9.3\r\n", "output": "GOTO Vasilisa."}, {"input": "9.4\r\n", "output": "GOTO Vasilisa."}, {"input": "9.5\r\n", "output": "GOTO Vasilisa."}, {"input": "9.6\r\n", "output": "GOTO Vasilisa."}, {"input": "9.7\r\n", "output": "GOTO Vasilisa."}, {"input": "9.8\r\n", "output": "GOTO Vasilisa."}, {"input": "9.9\r\n", "output": "GOTO Vasilisa."}, {"input": "7536521504744364134984603189602839063535643888645969434165019366202558753840519.4999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\r\n", "output": "GOTO Vasilisa."}, {"input": "646188694587964249318078225173.5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\r\n", "output": "646188694587964249318078225174"}, {"input": "7017472758334494297677068672222822550374695787171163207025095950296957261530.50\r\n", "output": "7017472758334494297677068672222822550374695787171163207025095950296957261531"}, {"input": "41203422675619090661099806687619.49999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\r\n", "output": "GOTO Vasilisa."}]
| false |
stdio
| null | true |
99/A
|
99
|
A
|
Python 3
|
TESTS
| 134 | 124 | 0 |
116240399
|
def f(s):
i=s.index(".")
if s[i-1]=="9":
return "GOTO Vasilisa."
if float(s[i:])<0.5:
return s[:i]
else:
return int(s[:i])+1
s=input()
print(f(s))
| 150 | 92 | 0 |
136128059
|
a = input()
for i in range(len(a)):
if a[i] == "." and a[i-1] == "9":
print("GOTO Vasilisa.")
break
if a[i] == "." and a[i+1] >= "5":
print(int(a[:i])+1)
break
if a[i] == "." and a[i+1] <= "5":
print(a[:i])
break
|
Codeforces Beta Round 78 (Div. 2 Only)
|
CF
| 2,011 | 2 | 256 |
Help Far Away Kingdom
|
In a far away kingdom lived the King, the Prince, the Shoemaker, the Dressmaker and many other citizens. They lived happily until great trouble came into the Kingdom. The ACMers settled there.
Most damage those strange creatures inflicted upon the kingdom was that they loved high precision numbers. As a result, the Kingdom healers had already had three appointments with the merchants who were asked to sell, say, exactly 0.273549107 beer barrels. To deal with the problem somehow, the King issued an order obliging rounding up all numbers to the closest integer to simplify calculations. Specifically, the order went like this:
- If a number's integer part does not end with digit 9 and its fractional part is strictly less than 0.5, then the rounded up number coincides with the number’s integer part.
- If a number's integer part does not end with digit 9 and its fractional part is not less than 0.5, the rounded up number is obtained if we add 1 to the last digit of the number’s integer part.
- If the number’s integer part ends with digit 9, to round up the numbers one should go to Vasilisa the Wise. In the whole Kingdom she is the only one who can perform the tricky operation of carrying into the next position.
Merchants found the algorithm very sophisticated and they asked you (the ACMers) to help them. Can you write a program that would perform the rounding according to the King’s order?
|
The first line contains a single number to round up — the integer part (a non-empty set of decimal digits that do not start with 0 — with the exception of a case when the set consists of a single digit — in this case 0 can go first), then follows character «.» (a dot), and then follows the fractional part (any non-empty set of decimal digits). The number's length does not exceed 1000 characters, including the dot. There are no other characters in the input data.
|
If the last number of the integer part is not equal to 9, print the rounded-up number without leading zeroes. Otherwise, print the message "GOTO Vasilisa." (without the quotes).
| null | null |
[{"input": "0.0", "output": "0"}, {"input": "1.49", "output": "1"}, {"input": "1.50", "output": "2"}, {"input": "2.71828182845904523536", "output": "3"}, {"input": "3.14159265358979323846", "output": "3"}, {"input": "12345678901234567890.1", "output": "12345678901234567890"}, {"input": "123456789123456789.999", "output": "GOTO Vasilisa."}]
| 800 |
["strings"]
| 150 |
[{"input": "0.0\r\n", "output": "0"}, {"input": "1.49\r\n", "output": "1"}, {"input": "1.50\r\n", "output": "2"}, {"input": "2.71828182845904523536\r\n", "output": "3"}, {"input": "3.14159265358979323846\r\n", "output": "3"}, {"input": "12345678901234567890.1\r\n", "output": "12345678901234567890"}, {"input": "123456789123456789.999\r\n", "output": "GOTO Vasilisa."}, {"input": "12345678901234567890.9\r\n", "output": "12345678901234567891"}, {"input": "123456789123456788.999\r\n", "output": "123456789123456789"}, {"input": "9.000\r\n", "output": "GOTO Vasilisa."}, {"input": "0.1\r\n", "output": "0"}, {"input": "0.2\r\n", "output": "0"}, {"input": "0.3\r\n", "output": "0"}, {"input": "0.4\r\n", "output": "0"}, {"input": "0.5\r\n", "output": "1"}, {"input": "0.6\r\n", "output": "1"}, {"input": "0.7\r\n", "output": "1"}, {"input": "0.8\r\n", "output": "1"}, {"input": "0.9\r\n", "output": "1"}, {"input": "1.0\r\n", "output": "1"}, {"input": "1.1\r\n", "output": "1"}, {"input": "1.2\r\n", "output": "1"}, {"input": "1.3\r\n", "output": "1"}, {"input": "1.4\r\n", "output": "1"}, {"input": "1.5\r\n", "output": "2"}, {"input": "1.6\r\n", "output": "2"}, {"input": "1.7\r\n", "output": "2"}, {"input": "1.8\r\n", "output": "2"}, {"input": "1.9\r\n", "output": "2"}, {"input": "2.0\r\n", "output": "2"}, {"input": "2.1\r\n", "output": "2"}, {"input": "2.2\r\n", "output": "2"}, {"input": "2.3\r\n", "output": "2"}, {"input": "2.4\r\n", "output": "2"}, {"input": "2.5\r\n", "output": "3"}, {"input": "2.6\r\n", "output": "3"}, {"input": "2.7\r\n", "output": "3"}, {"input": "2.8\r\n", "output": "3"}, {"input": "2.9\r\n", "output": "3"}, {"input": "3.0\r\n", "output": "3"}, {"input": "3.1\r\n", "output": "3"}, {"input": "3.2\r\n", "output": "3"}, {"input": "3.3\r\n", "output": "3"}, {"input": "3.4\r\n", "output": "3"}, {"input": "3.5\r\n", "output": "4"}, {"input": "3.6\r\n", "output": "4"}, {"input": "3.7\r\n", "output": "4"}, {"input": "3.8\r\n", "output": "4"}, {"input": "3.9\r\n", "output": "4"}, {"input": "4.0\r\n", "output": "4"}, {"input": "4.1\r\n", "output": "4"}, {"input": "4.2\r\n", "output": "4"}, {"input": "4.3\r\n", "output": "4"}, {"input": "4.4\r\n", "output": "4"}, {"input": "4.5\r\n", "output": "5"}, {"input": "4.6\r\n", "output": "5"}, {"input": "4.7\r\n", "output": "5"}, {"input": "4.8\r\n", "output": "5"}, {"input": "4.9\r\n", "output": "5"}, {"input": "5.0\r\n", "output": "5"}, {"input": "5.1\r\n", "output": "5"}, {"input": "5.2\r\n", "output": "5"}, {"input": "5.3\r\n", "output": "5"}, {"input": "5.4\r\n", "output": "5"}, {"input": "5.5\r\n", "output": "6"}, {"input": "5.6\r\n", "output": "6"}, {"input": "5.7\r\n", "output": "6"}, {"input": "5.8\r\n", "output": "6"}, {"input": "5.9\r\n", "output": "6"}, {"input": "6.0\r\n", "output": "6"}, {"input": "6.1\r\n", "output": "6"}, {"input": "6.2\r\n", "output": "6"}, {"input": "6.3\r\n", "output": "6"}, {"input": "6.4\r\n", "output": "6"}, {"input": "6.5\r\n", "output": "7"}, {"input": "6.6\r\n", "output": "7"}, {"input": "6.7\r\n", "output": "7"}, {"input": "6.8\r\n", "output": "7"}, {"input": "6.9\r\n", "output": "7"}, {"input": "7.0\r\n", "output": "7"}, {"input": "7.1\r\n", "output": "7"}, {"input": "7.2\r\n", "output": "7"}, {"input": "7.3\r\n", "output": "7"}, {"input": "7.4\r\n", "output": "7"}, {"input": "7.5\r\n", "output": "8"}, {"input": "7.6\r\n", "output": "8"}, {"input": "7.7\r\n", "output": "8"}, {"input": "7.8\r\n", "output": "8"}, {"input": "7.9\r\n", "output": "8"}, {"input": "8.0\r\n", "output": "8"}, {"input": "8.1\r\n", "output": "8"}, {"input": "8.2\r\n", "output": "8"}, {"input": "8.3\r\n", "output": "8"}, {"input": "8.4\r\n", "output": "8"}, {"input": "8.5\r\n", "output": "9"}, {"input": "8.6\r\n", "output": "9"}, {"input": "8.7\r\n", "output": "9"}, {"input": "8.8\r\n", "output": "9"}, {"input": "8.9\r\n", "output": "9"}, {"input": "9.0\r\n", "output": "GOTO Vasilisa."}, {"input": "9.1\r\n", "output": "GOTO Vasilisa."}, {"input": "9.2\r\n", "output": "GOTO Vasilisa."}, {"input": "9.3\r\n", "output": "GOTO Vasilisa."}, {"input": "9.4\r\n", "output": "GOTO Vasilisa."}, {"input": "9.5\r\n", "output": "GOTO Vasilisa."}, {"input": "9.6\r\n", "output": "GOTO Vasilisa."}, {"input": "9.7\r\n", "output": "GOTO Vasilisa."}, {"input": "9.8\r\n", "output": "GOTO Vasilisa."}, {"input": "9.9\r\n", "output": "GOTO Vasilisa."}, {"input": "7536521504744364134984603189602839063535643888645969434165019366202558753840519.4999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\r\n", "output": "GOTO Vasilisa."}, {"input": "646188694587964249318078225173.5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\r\n", "output": "646188694587964249318078225174"}, {"input": "7017472758334494297677068672222822550374695787171163207025095950296957261530.50\r\n", "output": "7017472758334494297677068672222822550374695787171163207025095950296957261531"}, {"input": "41203422675619090661099806687619.49999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\r\n", "output": "GOTO Vasilisa."}]
| false |
stdio
| null | true |
99/A
|
99
|
A
|
PyPy 3-64
|
TESTS
| 134 | 124 | 0 |
195444322
|
s = input()
pos = s.find('.')
i = int(s[0:pos])
dec = float(s[pos::])
if(i%10 != 9) and(dec<0.5):
print(i)
elif(i%10 != 9) and(dec>=0.5):
print(i+1)
else:
print("GOTO Vasilisa.")
| 150 | 92 | 0 |
139120426
|
m,n= input().split(".")
if m[-1]=="9":
print("GOTO Vasilisa.")
else:
l=n[0]>"4"
print(int(m)+l)
|
Codeforces Beta Round 78 (Div. 2 Only)
|
CF
| 2,011 | 2 | 256 |
Help Far Away Kingdom
|
In a far away kingdom lived the King, the Prince, the Shoemaker, the Dressmaker and many other citizens. They lived happily until great trouble came into the Kingdom. The ACMers settled there.
Most damage those strange creatures inflicted upon the kingdom was that they loved high precision numbers. As a result, the Kingdom healers had already had three appointments with the merchants who were asked to sell, say, exactly 0.273549107 beer barrels. To deal with the problem somehow, the King issued an order obliging rounding up all numbers to the closest integer to simplify calculations. Specifically, the order went like this:
- If a number's integer part does not end with digit 9 and its fractional part is strictly less than 0.5, then the rounded up number coincides with the number’s integer part.
- If a number's integer part does not end with digit 9 and its fractional part is not less than 0.5, the rounded up number is obtained if we add 1 to the last digit of the number’s integer part.
- If the number’s integer part ends with digit 9, to round up the numbers one should go to Vasilisa the Wise. In the whole Kingdom she is the only one who can perform the tricky operation of carrying into the next position.
Merchants found the algorithm very sophisticated and they asked you (the ACMers) to help them. Can you write a program that would perform the rounding according to the King’s order?
|
The first line contains a single number to round up — the integer part (a non-empty set of decimal digits that do not start with 0 — with the exception of a case when the set consists of a single digit — in this case 0 can go first), then follows character «.» (a dot), and then follows the fractional part (any non-empty set of decimal digits). The number's length does not exceed 1000 characters, including the dot. There are no other characters in the input data.
|
If the last number of the integer part is not equal to 9, print the rounded-up number without leading zeroes. Otherwise, print the message "GOTO Vasilisa." (without the quotes).
| null | null |
[{"input": "0.0", "output": "0"}, {"input": "1.49", "output": "1"}, {"input": "1.50", "output": "2"}, {"input": "2.71828182845904523536", "output": "3"}, {"input": "3.14159265358979323846", "output": "3"}, {"input": "12345678901234567890.1", "output": "12345678901234567890"}, {"input": "123456789123456789.999", "output": "GOTO Vasilisa."}]
| 800 |
["strings"]
| 150 |
[{"input": "0.0\r\n", "output": "0"}, {"input": "1.49\r\n", "output": "1"}, {"input": "1.50\r\n", "output": "2"}, {"input": "2.71828182845904523536\r\n", "output": "3"}, {"input": "3.14159265358979323846\r\n", "output": "3"}, {"input": "12345678901234567890.1\r\n", "output": "12345678901234567890"}, {"input": "123456789123456789.999\r\n", "output": "GOTO Vasilisa."}, {"input": "12345678901234567890.9\r\n", "output": "12345678901234567891"}, {"input": "123456789123456788.999\r\n", "output": "123456789123456789"}, {"input": "9.000\r\n", "output": "GOTO Vasilisa."}, {"input": "0.1\r\n", "output": "0"}, {"input": "0.2\r\n", "output": "0"}, {"input": "0.3\r\n", "output": "0"}, {"input": "0.4\r\n", "output": "0"}, {"input": "0.5\r\n", "output": "1"}, {"input": "0.6\r\n", "output": "1"}, {"input": "0.7\r\n", "output": "1"}, {"input": "0.8\r\n", "output": "1"}, {"input": "0.9\r\n", "output": "1"}, {"input": "1.0\r\n", "output": "1"}, {"input": "1.1\r\n", "output": "1"}, {"input": "1.2\r\n", "output": "1"}, {"input": "1.3\r\n", "output": "1"}, {"input": "1.4\r\n", "output": "1"}, {"input": "1.5\r\n", "output": "2"}, {"input": "1.6\r\n", "output": "2"}, {"input": "1.7\r\n", "output": "2"}, {"input": "1.8\r\n", "output": "2"}, {"input": "1.9\r\n", "output": "2"}, {"input": "2.0\r\n", "output": "2"}, {"input": "2.1\r\n", "output": "2"}, {"input": "2.2\r\n", "output": "2"}, {"input": "2.3\r\n", "output": "2"}, {"input": "2.4\r\n", "output": "2"}, {"input": "2.5\r\n", "output": "3"}, {"input": "2.6\r\n", "output": "3"}, {"input": "2.7\r\n", "output": "3"}, {"input": "2.8\r\n", "output": "3"}, {"input": "2.9\r\n", "output": "3"}, {"input": "3.0\r\n", "output": "3"}, {"input": "3.1\r\n", "output": "3"}, {"input": "3.2\r\n", "output": "3"}, {"input": "3.3\r\n", "output": "3"}, {"input": "3.4\r\n", "output": "3"}, {"input": "3.5\r\n", "output": "4"}, {"input": "3.6\r\n", "output": "4"}, {"input": "3.7\r\n", "output": "4"}, {"input": "3.8\r\n", "output": "4"}, {"input": "3.9\r\n", "output": "4"}, {"input": "4.0\r\n", "output": "4"}, {"input": "4.1\r\n", "output": "4"}, {"input": "4.2\r\n", "output": "4"}, {"input": "4.3\r\n", "output": "4"}, {"input": "4.4\r\n", "output": "4"}, {"input": "4.5\r\n", "output": "5"}, {"input": "4.6\r\n", "output": "5"}, {"input": "4.7\r\n", "output": "5"}, {"input": "4.8\r\n", "output": "5"}, {"input": "4.9\r\n", "output": "5"}, {"input": "5.0\r\n", "output": "5"}, {"input": "5.1\r\n", "output": "5"}, {"input": "5.2\r\n", "output": "5"}, {"input": "5.3\r\n", "output": "5"}, {"input": "5.4\r\n", "output": "5"}, {"input": "5.5\r\n", "output": "6"}, {"input": "5.6\r\n", "output": "6"}, {"input": "5.7\r\n", "output": "6"}, {"input": "5.8\r\n", "output": "6"}, {"input": "5.9\r\n", "output": "6"}, {"input": "6.0\r\n", "output": "6"}, {"input": "6.1\r\n", "output": "6"}, {"input": "6.2\r\n", "output": "6"}, {"input": "6.3\r\n", "output": "6"}, {"input": "6.4\r\n", "output": "6"}, {"input": "6.5\r\n", "output": "7"}, {"input": "6.6\r\n", "output": "7"}, {"input": "6.7\r\n", "output": "7"}, {"input": "6.8\r\n", "output": "7"}, {"input": "6.9\r\n", "output": "7"}, {"input": "7.0\r\n", "output": "7"}, {"input": "7.1\r\n", "output": "7"}, {"input": "7.2\r\n", "output": "7"}, {"input": "7.3\r\n", "output": "7"}, {"input": "7.4\r\n", "output": "7"}, {"input": "7.5\r\n", "output": "8"}, {"input": "7.6\r\n", "output": "8"}, {"input": "7.7\r\n", "output": "8"}, {"input": "7.8\r\n", "output": "8"}, {"input": "7.9\r\n", "output": "8"}, {"input": "8.0\r\n", "output": "8"}, {"input": "8.1\r\n", "output": "8"}, {"input": "8.2\r\n", "output": "8"}, {"input": "8.3\r\n", "output": "8"}, {"input": "8.4\r\n", "output": "8"}, {"input": "8.5\r\n", "output": "9"}, {"input": "8.6\r\n", "output": "9"}, {"input": "8.7\r\n", "output": "9"}, {"input": "8.8\r\n", "output": "9"}, {"input": "8.9\r\n", "output": "9"}, {"input": "9.0\r\n", "output": "GOTO Vasilisa."}, {"input": "9.1\r\n", "output": "GOTO Vasilisa."}, {"input": "9.2\r\n", "output": "GOTO Vasilisa."}, {"input": "9.3\r\n", "output": "GOTO Vasilisa."}, {"input": "9.4\r\n", "output": "GOTO Vasilisa."}, {"input": "9.5\r\n", "output": "GOTO Vasilisa."}, {"input": "9.6\r\n", "output": "GOTO Vasilisa."}, {"input": "9.7\r\n", "output": "GOTO Vasilisa."}, {"input": "9.8\r\n", "output": "GOTO Vasilisa."}, {"input": "9.9\r\n", "output": "GOTO Vasilisa."}, {"input": "7536521504744364134984603189602839063535643888645969434165019366202558753840519.4999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\r\n", "output": "GOTO Vasilisa."}, {"input": "646188694587964249318078225173.5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\r\n", "output": "646188694587964249318078225174"}, {"input": "7017472758334494297677068672222822550374695787171163207025095950296957261530.50\r\n", "output": "7017472758334494297677068672222822550374695787171163207025095950296957261531"}, {"input": "41203422675619090661099806687619.49999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\r\n", "output": "GOTO Vasilisa."}]
| false |
stdio
| null | true |
99/A
|
99
|
A
|
Python 3
|
TESTS
| 134 | 122 | 0 |
186991953
|
n = input()
if '.' not in n:
print(n)
exit()
else:
m = n.split('.')
if m[0][-1] == "9":
print("GOTO Vasilisa.")
exit()
elif float("0." + m[1]) < 0.5:
print(int(m[0]))
elif float("0." + m[1]) >= 0.5:
print(int(m[0]) + 1)
| 150 | 92 | 0 |
142060203
|
i, j=map(str,input().split("."))
print(["GOTO Vasilisa.", int(i)+(j[0]>'4')][i[-1]<'9'])
# Sun Jan 09 2022 08:29:38 GMT+0000 (Coordinated Universal Time)
|
Codeforces Beta Round 78 (Div. 2 Only)
|
CF
| 2,011 | 2 | 256 |
Help Far Away Kingdom
|
In a far away kingdom lived the King, the Prince, the Shoemaker, the Dressmaker and many other citizens. They lived happily until great trouble came into the Kingdom. The ACMers settled there.
Most damage those strange creatures inflicted upon the kingdom was that they loved high precision numbers. As a result, the Kingdom healers had already had three appointments with the merchants who were asked to sell, say, exactly 0.273549107 beer barrels. To deal with the problem somehow, the King issued an order obliging rounding up all numbers to the closest integer to simplify calculations. Specifically, the order went like this:
- If a number's integer part does not end with digit 9 and its fractional part is strictly less than 0.5, then the rounded up number coincides with the number’s integer part.
- If a number's integer part does not end with digit 9 and its fractional part is not less than 0.5, the rounded up number is obtained if we add 1 to the last digit of the number’s integer part.
- If the number’s integer part ends with digit 9, to round up the numbers one should go to Vasilisa the Wise. In the whole Kingdom she is the only one who can perform the tricky operation of carrying into the next position.
Merchants found the algorithm very sophisticated and they asked you (the ACMers) to help them. Can you write a program that would perform the rounding according to the King’s order?
|
The first line contains a single number to round up — the integer part (a non-empty set of decimal digits that do not start with 0 — with the exception of a case when the set consists of a single digit — in this case 0 can go first), then follows character «.» (a dot), and then follows the fractional part (any non-empty set of decimal digits). The number's length does not exceed 1000 characters, including the dot. There are no other characters in the input data.
|
If the last number of the integer part is not equal to 9, print the rounded-up number without leading zeroes. Otherwise, print the message "GOTO Vasilisa." (without the quotes).
| null | null |
[{"input": "0.0", "output": "0"}, {"input": "1.49", "output": "1"}, {"input": "1.50", "output": "2"}, {"input": "2.71828182845904523536", "output": "3"}, {"input": "3.14159265358979323846", "output": "3"}, {"input": "12345678901234567890.1", "output": "12345678901234567890"}, {"input": "123456789123456789.999", "output": "GOTO Vasilisa."}]
| 800 |
["strings"]
| 150 |
[{"input": "0.0\r\n", "output": "0"}, {"input": "1.49\r\n", "output": "1"}, {"input": "1.50\r\n", "output": "2"}, {"input": "2.71828182845904523536\r\n", "output": "3"}, {"input": "3.14159265358979323846\r\n", "output": "3"}, {"input": "12345678901234567890.1\r\n", "output": "12345678901234567890"}, {"input": "123456789123456789.999\r\n", "output": "GOTO Vasilisa."}, {"input": "12345678901234567890.9\r\n", "output": "12345678901234567891"}, {"input": "123456789123456788.999\r\n", "output": "123456789123456789"}, {"input": "9.000\r\n", "output": "GOTO Vasilisa."}, {"input": "0.1\r\n", "output": "0"}, {"input": "0.2\r\n", "output": "0"}, {"input": "0.3\r\n", "output": "0"}, {"input": "0.4\r\n", "output": "0"}, {"input": "0.5\r\n", "output": "1"}, {"input": "0.6\r\n", "output": "1"}, {"input": "0.7\r\n", "output": "1"}, {"input": "0.8\r\n", "output": "1"}, {"input": "0.9\r\n", "output": "1"}, {"input": "1.0\r\n", "output": "1"}, {"input": "1.1\r\n", "output": "1"}, {"input": "1.2\r\n", "output": "1"}, {"input": "1.3\r\n", "output": "1"}, {"input": "1.4\r\n", "output": "1"}, {"input": "1.5\r\n", "output": "2"}, {"input": "1.6\r\n", "output": "2"}, {"input": "1.7\r\n", "output": "2"}, {"input": "1.8\r\n", "output": "2"}, {"input": "1.9\r\n", "output": "2"}, {"input": "2.0\r\n", "output": "2"}, {"input": "2.1\r\n", "output": "2"}, {"input": "2.2\r\n", "output": "2"}, {"input": "2.3\r\n", "output": "2"}, {"input": "2.4\r\n", "output": "2"}, {"input": "2.5\r\n", "output": "3"}, {"input": "2.6\r\n", "output": "3"}, {"input": "2.7\r\n", "output": "3"}, {"input": "2.8\r\n", "output": "3"}, {"input": "2.9\r\n", "output": "3"}, {"input": "3.0\r\n", "output": "3"}, {"input": "3.1\r\n", "output": "3"}, {"input": "3.2\r\n", "output": "3"}, {"input": "3.3\r\n", "output": "3"}, {"input": "3.4\r\n", "output": "3"}, {"input": "3.5\r\n", "output": "4"}, {"input": "3.6\r\n", "output": "4"}, {"input": "3.7\r\n", "output": "4"}, {"input": "3.8\r\n", "output": "4"}, {"input": "3.9\r\n", "output": "4"}, {"input": "4.0\r\n", "output": "4"}, {"input": "4.1\r\n", "output": "4"}, {"input": "4.2\r\n", "output": "4"}, {"input": "4.3\r\n", "output": "4"}, {"input": "4.4\r\n", "output": "4"}, {"input": "4.5\r\n", "output": "5"}, {"input": "4.6\r\n", "output": "5"}, {"input": "4.7\r\n", "output": "5"}, {"input": "4.8\r\n", "output": "5"}, {"input": "4.9\r\n", "output": "5"}, {"input": "5.0\r\n", "output": "5"}, {"input": "5.1\r\n", "output": "5"}, {"input": "5.2\r\n", "output": "5"}, {"input": "5.3\r\n", "output": "5"}, {"input": "5.4\r\n", "output": "5"}, {"input": "5.5\r\n", "output": "6"}, {"input": "5.6\r\n", "output": "6"}, {"input": "5.7\r\n", "output": "6"}, {"input": "5.8\r\n", "output": "6"}, {"input": "5.9\r\n", "output": "6"}, {"input": "6.0\r\n", "output": "6"}, {"input": "6.1\r\n", "output": "6"}, {"input": "6.2\r\n", "output": "6"}, {"input": "6.3\r\n", "output": "6"}, {"input": "6.4\r\n", "output": "6"}, {"input": "6.5\r\n", "output": "7"}, {"input": "6.6\r\n", "output": "7"}, {"input": "6.7\r\n", "output": "7"}, {"input": "6.8\r\n", "output": "7"}, {"input": "6.9\r\n", "output": "7"}, {"input": "7.0\r\n", "output": "7"}, {"input": "7.1\r\n", "output": "7"}, {"input": "7.2\r\n", "output": "7"}, {"input": "7.3\r\n", "output": "7"}, {"input": "7.4\r\n", "output": "7"}, {"input": "7.5\r\n", "output": "8"}, {"input": "7.6\r\n", "output": "8"}, {"input": "7.7\r\n", "output": "8"}, {"input": "7.8\r\n", "output": "8"}, {"input": "7.9\r\n", "output": "8"}, {"input": "8.0\r\n", "output": "8"}, {"input": "8.1\r\n", "output": "8"}, {"input": "8.2\r\n", "output": "8"}, {"input": "8.3\r\n", "output": "8"}, {"input": "8.4\r\n", "output": "8"}, {"input": "8.5\r\n", "output": "9"}, {"input": "8.6\r\n", "output": "9"}, {"input": "8.7\r\n", "output": "9"}, {"input": "8.8\r\n", "output": "9"}, {"input": "8.9\r\n", "output": "9"}, {"input": "9.0\r\n", "output": "GOTO Vasilisa."}, {"input": "9.1\r\n", "output": "GOTO Vasilisa."}, {"input": "9.2\r\n", "output": "GOTO Vasilisa."}, {"input": "9.3\r\n", "output": "GOTO Vasilisa."}, {"input": "9.4\r\n", "output": "GOTO Vasilisa."}, {"input": "9.5\r\n", "output": "GOTO Vasilisa."}, {"input": "9.6\r\n", "output": "GOTO Vasilisa."}, {"input": "9.7\r\n", "output": "GOTO Vasilisa."}, {"input": "9.8\r\n", "output": "GOTO Vasilisa."}, {"input": "9.9\r\n", "output": "GOTO Vasilisa."}, {"input": "7536521504744364134984603189602839063535643888645969434165019366202558753840519.4999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\r\n", "output": "GOTO Vasilisa."}, {"input": "646188694587964249318078225173.5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\r\n", "output": "646188694587964249318078225174"}, {"input": "7017472758334494297677068672222822550374695787171163207025095950296957261530.50\r\n", "output": "7017472758334494297677068672222822550374695787171163207025095950296957261531"}, {"input": "41203422675619090661099806687619.49999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\r\n", "output": "GOTO Vasilisa."}]
| false |
stdio
| null | true |
99/A
|
99
|
A
|
Python 3
|
TESTS
| 134 | 92 | 307,200 |
4816627
|
number = input()
int_part = ''
i=0
while number[i] != '.':
int_part += number[i]
i=i+1
fraction_part = number[i:]
if int_part[-1] != '9' and float(fraction_part) < 0.5:
round_no = int_part
elif int_part[-1] != '9' and float(fraction_part) >= 0.5:
round_no = int_part[0:-1] + str(int(int_part[-1])+1)
elif int_part[-1] == '9':
round_no = "GOTO Vasilisa."
print(round_no)
| 150 | 92 | 0 |
144267071
|
s = input()
if s[s.index(".")-1] == '9': print("GOTO Vasilisa.")
else:
if int(s[s.index(".")+1]) < 5:
print(s[:s.index(".")])
else:
print(int(s[:s.index(".")])+1)
|
Codeforces Beta Round 78 (Div. 2 Only)
|
CF
| 2,011 | 2 | 256 |
Help Far Away Kingdom
|
In a far away kingdom lived the King, the Prince, the Shoemaker, the Dressmaker and many other citizens. They lived happily until great trouble came into the Kingdom. The ACMers settled there.
Most damage those strange creatures inflicted upon the kingdom was that they loved high precision numbers. As a result, the Kingdom healers had already had three appointments with the merchants who were asked to sell, say, exactly 0.273549107 beer barrels. To deal with the problem somehow, the King issued an order obliging rounding up all numbers to the closest integer to simplify calculations. Specifically, the order went like this:
- If a number's integer part does not end with digit 9 and its fractional part is strictly less than 0.5, then the rounded up number coincides with the number’s integer part.
- If a number's integer part does not end with digit 9 and its fractional part is not less than 0.5, the rounded up number is obtained if we add 1 to the last digit of the number’s integer part.
- If the number’s integer part ends with digit 9, to round up the numbers one should go to Vasilisa the Wise. In the whole Kingdom she is the only one who can perform the tricky operation of carrying into the next position.
Merchants found the algorithm very sophisticated and they asked you (the ACMers) to help them. Can you write a program that would perform the rounding according to the King’s order?
|
The first line contains a single number to round up — the integer part (a non-empty set of decimal digits that do not start with 0 — with the exception of a case when the set consists of a single digit — in this case 0 can go first), then follows character «.» (a dot), and then follows the fractional part (any non-empty set of decimal digits). The number's length does not exceed 1000 characters, including the dot. There are no other characters in the input data.
|
If the last number of the integer part is not equal to 9, print the rounded-up number without leading zeroes. Otherwise, print the message "GOTO Vasilisa." (without the quotes).
| null | null |
[{"input": "0.0", "output": "0"}, {"input": "1.49", "output": "1"}, {"input": "1.50", "output": "2"}, {"input": "2.71828182845904523536", "output": "3"}, {"input": "3.14159265358979323846", "output": "3"}, {"input": "12345678901234567890.1", "output": "12345678901234567890"}, {"input": "123456789123456789.999", "output": "GOTO Vasilisa."}]
| 800 |
["strings"]
| 150 |
[{"input": "0.0\r\n", "output": "0"}, {"input": "1.49\r\n", "output": "1"}, {"input": "1.50\r\n", "output": "2"}, {"input": "2.71828182845904523536\r\n", "output": "3"}, {"input": "3.14159265358979323846\r\n", "output": "3"}, {"input": "12345678901234567890.1\r\n", "output": "12345678901234567890"}, {"input": "123456789123456789.999\r\n", "output": "GOTO Vasilisa."}, {"input": "12345678901234567890.9\r\n", "output": "12345678901234567891"}, {"input": "123456789123456788.999\r\n", "output": "123456789123456789"}, {"input": "9.000\r\n", "output": "GOTO Vasilisa."}, {"input": "0.1\r\n", "output": "0"}, {"input": "0.2\r\n", "output": "0"}, {"input": "0.3\r\n", "output": "0"}, {"input": "0.4\r\n", "output": "0"}, {"input": "0.5\r\n", "output": "1"}, {"input": "0.6\r\n", "output": "1"}, {"input": "0.7\r\n", "output": "1"}, {"input": "0.8\r\n", "output": "1"}, {"input": "0.9\r\n", "output": "1"}, {"input": "1.0\r\n", "output": "1"}, {"input": "1.1\r\n", "output": "1"}, {"input": "1.2\r\n", "output": "1"}, {"input": "1.3\r\n", "output": "1"}, {"input": "1.4\r\n", "output": "1"}, {"input": "1.5\r\n", "output": "2"}, {"input": "1.6\r\n", "output": "2"}, {"input": "1.7\r\n", "output": "2"}, {"input": "1.8\r\n", "output": "2"}, {"input": "1.9\r\n", "output": "2"}, {"input": "2.0\r\n", "output": "2"}, {"input": "2.1\r\n", "output": "2"}, {"input": "2.2\r\n", "output": "2"}, {"input": "2.3\r\n", "output": "2"}, {"input": "2.4\r\n", "output": "2"}, {"input": "2.5\r\n", "output": "3"}, {"input": "2.6\r\n", "output": "3"}, {"input": "2.7\r\n", "output": "3"}, {"input": "2.8\r\n", "output": "3"}, {"input": "2.9\r\n", "output": "3"}, {"input": "3.0\r\n", "output": "3"}, {"input": "3.1\r\n", "output": "3"}, {"input": "3.2\r\n", "output": "3"}, {"input": "3.3\r\n", "output": "3"}, {"input": "3.4\r\n", "output": "3"}, {"input": "3.5\r\n", "output": "4"}, {"input": "3.6\r\n", "output": "4"}, {"input": "3.7\r\n", "output": "4"}, {"input": "3.8\r\n", "output": "4"}, {"input": "3.9\r\n", "output": "4"}, {"input": "4.0\r\n", "output": "4"}, {"input": "4.1\r\n", "output": "4"}, {"input": "4.2\r\n", "output": "4"}, {"input": "4.3\r\n", "output": "4"}, {"input": "4.4\r\n", "output": "4"}, {"input": "4.5\r\n", "output": "5"}, {"input": "4.6\r\n", "output": "5"}, {"input": "4.7\r\n", "output": "5"}, {"input": "4.8\r\n", "output": "5"}, {"input": "4.9\r\n", "output": "5"}, {"input": "5.0\r\n", "output": "5"}, {"input": "5.1\r\n", "output": "5"}, {"input": "5.2\r\n", "output": "5"}, {"input": "5.3\r\n", "output": "5"}, {"input": "5.4\r\n", "output": "5"}, {"input": "5.5\r\n", "output": "6"}, {"input": "5.6\r\n", "output": "6"}, {"input": "5.7\r\n", "output": "6"}, {"input": "5.8\r\n", "output": "6"}, {"input": "5.9\r\n", "output": "6"}, {"input": "6.0\r\n", "output": "6"}, {"input": "6.1\r\n", "output": "6"}, {"input": "6.2\r\n", "output": "6"}, {"input": "6.3\r\n", "output": "6"}, {"input": "6.4\r\n", "output": "6"}, {"input": "6.5\r\n", "output": "7"}, {"input": "6.6\r\n", "output": "7"}, {"input": "6.7\r\n", "output": "7"}, {"input": "6.8\r\n", "output": "7"}, {"input": "6.9\r\n", "output": "7"}, {"input": "7.0\r\n", "output": "7"}, {"input": "7.1\r\n", "output": "7"}, {"input": "7.2\r\n", "output": "7"}, {"input": "7.3\r\n", "output": "7"}, {"input": "7.4\r\n", "output": "7"}, {"input": "7.5\r\n", "output": "8"}, {"input": "7.6\r\n", "output": "8"}, {"input": "7.7\r\n", "output": "8"}, {"input": "7.8\r\n", "output": "8"}, {"input": "7.9\r\n", "output": "8"}, {"input": "8.0\r\n", "output": "8"}, {"input": "8.1\r\n", "output": "8"}, {"input": "8.2\r\n", "output": "8"}, {"input": "8.3\r\n", "output": "8"}, {"input": "8.4\r\n", "output": "8"}, {"input": "8.5\r\n", "output": "9"}, {"input": "8.6\r\n", "output": "9"}, {"input": "8.7\r\n", "output": "9"}, {"input": "8.8\r\n", "output": "9"}, {"input": "8.9\r\n", "output": "9"}, {"input": "9.0\r\n", "output": "GOTO Vasilisa."}, {"input": "9.1\r\n", "output": "GOTO Vasilisa."}, {"input": "9.2\r\n", "output": "GOTO Vasilisa."}, {"input": "9.3\r\n", "output": "GOTO Vasilisa."}, {"input": "9.4\r\n", "output": "GOTO Vasilisa."}, {"input": "9.5\r\n", "output": "GOTO Vasilisa."}, {"input": "9.6\r\n", "output": "GOTO Vasilisa."}, {"input": "9.7\r\n", "output": "GOTO Vasilisa."}, {"input": "9.8\r\n", "output": "GOTO Vasilisa."}, {"input": "9.9\r\n", "output": "GOTO Vasilisa."}, {"input": "7536521504744364134984603189602839063535643888645969434165019366202558753840519.4999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\r\n", "output": "GOTO Vasilisa."}, {"input": "646188694587964249318078225173.5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\r\n", "output": "646188694587964249318078225174"}, {"input": "7017472758334494297677068672222822550374695787171163207025095950296957261530.50\r\n", "output": "7017472758334494297677068672222822550374695787171163207025095950296957261531"}, {"input": "41203422675619090661099806687619.49999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\r\n", "output": "GOTO Vasilisa."}]
| false |
stdio
| null | true |
99/A
|
99
|
A
|
Python 3
|
TESTS
| 134 | 92 | 0 |
225653365
|
x, y = map(str, input(). split("."))
if x[-1] == "9" or x == "9":
print("GOTO Vasilisa.")
elif float("0." + y) < 0.5:
print(int(x))
else:
print(int(x)+1)
| 150 | 92 | 0 |
145548415
|
s = input()
nuqta = s.index(".")
butun_qism = int(s[0:nuqta])
kasr_qism = int(s[nuqta+1:])
if(butun_qism%10 == 9):
print("GOTO Vasilisa.")
else:
if(int(s[nuqta+1]) >= 5):
print(butun_qism+1)
else:
print(butun_qism)
|
Codeforces Beta Round 78 (Div. 2 Only)
|
CF
| 2,011 | 2 | 256 |
Help Far Away Kingdom
|
In a far away kingdom lived the King, the Prince, the Shoemaker, the Dressmaker and many other citizens. They lived happily until great trouble came into the Kingdom. The ACMers settled there.
Most damage those strange creatures inflicted upon the kingdom was that they loved high precision numbers. As a result, the Kingdom healers had already had three appointments with the merchants who were asked to sell, say, exactly 0.273549107 beer barrels. To deal with the problem somehow, the King issued an order obliging rounding up all numbers to the closest integer to simplify calculations. Specifically, the order went like this:
- If a number's integer part does not end with digit 9 and its fractional part is strictly less than 0.5, then the rounded up number coincides with the number’s integer part.
- If a number's integer part does not end with digit 9 and its fractional part is not less than 0.5, the rounded up number is obtained if we add 1 to the last digit of the number’s integer part.
- If the number’s integer part ends with digit 9, to round up the numbers one should go to Vasilisa the Wise. In the whole Kingdom she is the only one who can perform the tricky operation of carrying into the next position.
Merchants found the algorithm very sophisticated and they asked you (the ACMers) to help them. Can you write a program that would perform the rounding according to the King’s order?
|
The first line contains a single number to round up — the integer part (a non-empty set of decimal digits that do not start with 0 — with the exception of a case when the set consists of a single digit — in this case 0 can go first), then follows character «.» (a dot), and then follows the fractional part (any non-empty set of decimal digits). The number's length does not exceed 1000 characters, including the dot. There are no other characters in the input data.
|
If the last number of the integer part is not equal to 9, print the rounded-up number without leading zeroes. Otherwise, print the message "GOTO Vasilisa." (without the quotes).
| null | null |
[{"input": "0.0", "output": "0"}, {"input": "1.49", "output": "1"}, {"input": "1.50", "output": "2"}, {"input": "2.71828182845904523536", "output": "3"}, {"input": "3.14159265358979323846", "output": "3"}, {"input": "12345678901234567890.1", "output": "12345678901234567890"}, {"input": "123456789123456789.999", "output": "GOTO Vasilisa."}]
| 800 |
["strings"]
| 150 |
[{"input": "0.0\r\n", "output": "0"}, {"input": "1.49\r\n", "output": "1"}, {"input": "1.50\r\n", "output": "2"}, {"input": "2.71828182845904523536\r\n", "output": "3"}, {"input": "3.14159265358979323846\r\n", "output": "3"}, {"input": "12345678901234567890.1\r\n", "output": "12345678901234567890"}, {"input": "123456789123456789.999\r\n", "output": "GOTO Vasilisa."}, {"input": "12345678901234567890.9\r\n", "output": "12345678901234567891"}, {"input": "123456789123456788.999\r\n", "output": "123456789123456789"}, {"input": "9.000\r\n", "output": "GOTO Vasilisa."}, {"input": "0.1\r\n", "output": "0"}, {"input": "0.2\r\n", "output": "0"}, {"input": "0.3\r\n", "output": "0"}, {"input": "0.4\r\n", "output": "0"}, {"input": "0.5\r\n", "output": "1"}, {"input": "0.6\r\n", "output": "1"}, {"input": "0.7\r\n", "output": "1"}, {"input": "0.8\r\n", "output": "1"}, {"input": "0.9\r\n", "output": "1"}, {"input": "1.0\r\n", "output": "1"}, {"input": "1.1\r\n", "output": "1"}, {"input": "1.2\r\n", "output": "1"}, {"input": "1.3\r\n", "output": "1"}, {"input": "1.4\r\n", "output": "1"}, {"input": "1.5\r\n", "output": "2"}, {"input": "1.6\r\n", "output": "2"}, {"input": "1.7\r\n", "output": "2"}, {"input": "1.8\r\n", "output": "2"}, {"input": "1.9\r\n", "output": "2"}, {"input": "2.0\r\n", "output": "2"}, {"input": "2.1\r\n", "output": "2"}, {"input": "2.2\r\n", "output": "2"}, {"input": "2.3\r\n", "output": "2"}, {"input": "2.4\r\n", "output": "2"}, {"input": "2.5\r\n", "output": "3"}, {"input": "2.6\r\n", "output": "3"}, {"input": "2.7\r\n", "output": "3"}, {"input": "2.8\r\n", "output": "3"}, {"input": "2.9\r\n", "output": "3"}, {"input": "3.0\r\n", "output": "3"}, {"input": "3.1\r\n", "output": "3"}, {"input": "3.2\r\n", "output": "3"}, {"input": "3.3\r\n", "output": "3"}, {"input": "3.4\r\n", "output": "3"}, {"input": "3.5\r\n", "output": "4"}, {"input": "3.6\r\n", "output": "4"}, {"input": "3.7\r\n", "output": "4"}, {"input": "3.8\r\n", "output": "4"}, {"input": "3.9\r\n", "output": "4"}, {"input": "4.0\r\n", "output": "4"}, {"input": "4.1\r\n", "output": "4"}, {"input": "4.2\r\n", "output": "4"}, {"input": "4.3\r\n", "output": "4"}, {"input": "4.4\r\n", "output": "4"}, {"input": "4.5\r\n", "output": "5"}, {"input": "4.6\r\n", "output": "5"}, {"input": "4.7\r\n", "output": "5"}, {"input": "4.8\r\n", "output": "5"}, {"input": "4.9\r\n", "output": "5"}, {"input": "5.0\r\n", "output": "5"}, {"input": "5.1\r\n", "output": "5"}, {"input": "5.2\r\n", "output": "5"}, {"input": "5.3\r\n", "output": "5"}, {"input": "5.4\r\n", "output": "5"}, {"input": "5.5\r\n", "output": "6"}, {"input": "5.6\r\n", "output": "6"}, {"input": "5.7\r\n", "output": "6"}, {"input": "5.8\r\n", "output": "6"}, {"input": "5.9\r\n", "output": "6"}, {"input": "6.0\r\n", "output": "6"}, {"input": "6.1\r\n", "output": "6"}, {"input": "6.2\r\n", "output": "6"}, {"input": "6.3\r\n", "output": "6"}, {"input": "6.4\r\n", "output": "6"}, {"input": "6.5\r\n", "output": "7"}, {"input": "6.6\r\n", "output": "7"}, {"input": "6.7\r\n", "output": "7"}, {"input": "6.8\r\n", "output": "7"}, {"input": "6.9\r\n", "output": "7"}, {"input": "7.0\r\n", "output": "7"}, {"input": "7.1\r\n", "output": "7"}, {"input": "7.2\r\n", "output": "7"}, {"input": "7.3\r\n", "output": "7"}, {"input": "7.4\r\n", "output": "7"}, {"input": "7.5\r\n", "output": "8"}, {"input": "7.6\r\n", "output": "8"}, {"input": "7.7\r\n", "output": "8"}, {"input": "7.8\r\n", "output": "8"}, {"input": "7.9\r\n", "output": "8"}, {"input": "8.0\r\n", "output": "8"}, {"input": "8.1\r\n", "output": "8"}, {"input": "8.2\r\n", "output": "8"}, {"input": "8.3\r\n", "output": "8"}, {"input": "8.4\r\n", "output": "8"}, {"input": "8.5\r\n", "output": "9"}, {"input": "8.6\r\n", "output": "9"}, {"input": "8.7\r\n", "output": "9"}, {"input": "8.8\r\n", "output": "9"}, {"input": "8.9\r\n", "output": "9"}, {"input": "9.0\r\n", "output": "GOTO Vasilisa."}, {"input": "9.1\r\n", "output": "GOTO Vasilisa."}, {"input": "9.2\r\n", "output": "GOTO Vasilisa."}, {"input": "9.3\r\n", "output": "GOTO Vasilisa."}, {"input": "9.4\r\n", "output": "GOTO Vasilisa."}, {"input": "9.5\r\n", "output": "GOTO Vasilisa."}, {"input": "9.6\r\n", "output": "GOTO Vasilisa."}, {"input": "9.7\r\n", "output": "GOTO Vasilisa."}, {"input": "9.8\r\n", "output": "GOTO Vasilisa."}, {"input": "9.9\r\n", "output": "GOTO Vasilisa."}, {"input": "7536521504744364134984603189602839063535643888645969434165019366202558753840519.4999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\r\n", "output": "GOTO Vasilisa."}, {"input": "646188694587964249318078225173.5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\r\n", "output": "646188694587964249318078225174"}, {"input": "7017472758334494297677068672222822550374695787171163207025095950296957261530.50\r\n", "output": "7017472758334494297677068672222822550374695787171163207025095950296957261531"}, {"input": "41203422675619090661099806687619.49999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\r\n", "output": "GOTO Vasilisa."}]
| false |
stdio
| null | true |
99/A
|
99
|
A
|
Python 3
|
TESTS
| 134 | 92 | 0 |
165454011
|
i, d = tuple(input().split("."))
if i[-1] == "9":
print("GOTO Vasilisa.")
elif float(f"0.{d}") < 0.5:
print(int(i))
elif float(f"0.{d}") >= 0.5:
print(int(i) + 1)
| 150 | 92 | 0 |
146844916
|
a = input()
if int(a[a.index(".")-1]) == 9:
print("GOTO Vasilisa.")
elif int(a[a.index(".")+1]) < 5:
print(int(a[:a.index(".")]))
else:
print(int(a[:a.index(".")])+1)
|
Codeforces Beta Round 78 (Div. 2 Only)
|
CF
| 2,011 | 2 | 256 |
Help Far Away Kingdom
|
In a far away kingdom lived the King, the Prince, the Shoemaker, the Dressmaker and many other citizens. They lived happily until great trouble came into the Kingdom. The ACMers settled there.
Most damage those strange creatures inflicted upon the kingdom was that they loved high precision numbers. As a result, the Kingdom healers had already had three appointments with the merchants who were asked to sell, say, exactly 0.273549107 beer barrels. To deal with the problem somehow, the King issued an order obliging rounding up all numbers to the closest integer to simplify calculations. Specifically, the order went like this:
- If a number's integer part does not end with digit 9 and its fractional part is strictly less than 0.5, then the rounded up number coincides with the number’s integer part.
- If a number's integer part does not end with digit 9 and its fractional part is not less than 0.5, the rounded up number is obtained if we add 1 to the last digit of the number’s integer part.
- If the number’s integer part ends with digit 9, to round up the numbers one should go to Vasilisa the Wise. In the whole Kingdom she is the only one who can perform the tricky operation of carrying into the next position.
Merchants found the algorithm very sophisticated and they asked you (the ACMers) to help them. Can you write a program that would perform the rounding according to the King’s order?
|
The first line contains a single number to round up — the integer part (a non-empty set of decimal digits that do not start with 0 — with the exception of a case when the set consists of a single digit — in this case 0 can go first), then follows character «.» (a dot), and then follows the fractional part (any non-empty set of decimal digits). The number's length does not exceed 1000 characters, including the dot. There are no other characters in the input data.
|
If the last number of the integer part is not equal to 9, print the rounded-up number without leading zeroes. Otherwise, print the message "GOTO Vasilisa." (without the quotes).
| null | null |
[{"input": "0.0", "output": "0"}, {"input": "1.49", "output": "1"}, {"input": "1.50", "output": "2"}, {"input": "2.71828182845904523536", "output": "3"}, {"input": "3.14159265358979323846", "output": "3"}, {"input": "12345678901234567890.1", "output": "12345678901234567890"}, {"input": "123456789123456789.999", "output": "GOTO Vasilisa."}]
| 800 |
["strings"]
| 150 |
[{"input": "0.0\r\n", "output": "0"}, {"input": "1.49\r\n", "output": "1"}, {"input": "1.50\r\n", "output": "2"}, {"input": "2.71828182845904523536\r\n", "output": "3"}, {"input": "3.14159265358979323846\r\n", "output": "3"}, {"input": "12345678901234567890.1\r\n", "output": "12345678901234567890"}, {"input": "123456789123456789.999\r\n", "output": "GOTO Vasilisa."}, {"input": "12345678901234567890.9\r\n", "output": "12345678901234567891"}, {"input": "123456789123456788.999\r\n", "output": "123456789123456789"}, {"input": "9.000\r\n", "output": "GOTO Vasilisa."}, {"input": "0.1\r\n", "output": "0"}, {"input": "0.2\r\n", "output": "0"}, {"input": "0.3\r\n", "output": "0"}, {"input": "0.4\r\n", "output": "0"}, {"input": "0.5\r\n", "output": "1"}, {"input": "0.6\r\n", "output": "1"}, {"input": "0.7\r\n", "output": "1"}, {"input": "0.8\r\n", "output": "1"}, {"input": "0.9\r\n", "output": "1"}, {"input": "1.0\r\n", "output": "1"}, {"input": "1.1\r\n", "output": "1"}, {"input": "1.2\r\n", "output": "1"}, {"input": "1.3\r\n", "output": "1"}, {"input": "1.4\r\n", "output": "1"}, {"input": "1.5\r\n", "output": "2"}, {"input": "1.6\r\n", "output": "2"}, {"input": "1.7\r\n", "output": "2"}, {"input": "1.8\r\n", "output": "2"}, {"input": "1.9\r\n", "output": "2"}, {"input": "2.0\r\n", "output": "2"}, {"input": "2.1\r\n", "output": "2"}, {"input": "2.2\r\n", "output": "2"}, {"input": "2.3\r\n", "output": "2"}, {"input": "2.4\r\n", "output": "2"}, {"input": "2.5\r\n", "output": "3"}, {"input": "2.6\r\n", "output": "3"}, {"input": "2.7\r\n", "output": "3"}, {"input": "2.8\r\n", "output": "3"}, {"input": "2.9\r\n", "output": "3"}, {"input": "3.0\r\n", "output": "3"}, {"input": "3.1\r\n", "output": "3"}, {"input": "3.2\r\n", "output": "3"}, {"input": "3.3\r\n", "output": "3"}, {"input": "3.4\r\n", "output": "3"}, {"input": "3.5\r\n", "output": "4"}, {"input": "3.6\r\n", "output": "4"}, {"input": "3.7\r\n", "output": "4"}, {"input": "3.8\r\n", "output": "4"}, {"input": "3.9\r\n", "output": "4"}, {"input": "4.0\r\n", "output": "4"}, {"input": "4.1\r\n", "output": "4"}, {"input": "4.2\r\n", "output": "4"}, {"input": "4.3\r\n", "output": "4"}, {"input": "4.4\r\n", "output": "4"}, {"input": "4.5\r\n", "output": "5"}, {"input": "4.6\r\n", "output": "5"}, {"input": "4.7\r\n", "output": "5"}, {"input": "4.8\r\n", "output": "5"}, {"input": "4.9\r\n", "output": "5"}, {"input": "5.0\r\n", "output": "5"}, {"input": "5.1\r\n", "output": "5"}, {"input": "5.2\r\n", "output": "5"}, {"input": "5.3\r\n", "output": "5"}, {"input": "5.4\r\n", "output": "5"}, {"input": "5.5\r\n", "output": "6"}, {"input": "5.6\r\n", "output": "6"}, {"input": "5.7\r\n", "output": "6"}, {"input": "5.8\r\n", "output": "6"}, {"input": "5.9\r\n", "output": "6"}, {"input": "6.0\r\n", "output": "6"}, {"input": "6.1\r\n", "output": "6"}, {"input": "6.2\r\n", "output": "6"}, {"input": "6.3\r\n", "output": "6"}, {"input": "6.4\r\n", "output": "6"}, {"input": "6.5\r\n", "output": "7"}, {"input": "6.6\r\n", "output": "7"}, {"input": "6.7\r\n", "output": "7"}, {"input": "6.8\r\n", "output": "7"}, {"input": "6.9\r\n", "output": "7"}, {"input": "7.0\r\n", "output": "7"}, {"input": "7.1\r\n", "output": "7"}, {"input": "7.2\r\n", "output": "7"}, {"input": "7.3\r\n", "output": "7"}, {"input": "7.4\r\n", "output": "7"}, {"input": "7.5\r\n", "output": "8"}, {"input": "7.6\r\n", "output": "8"}, {"input": "7.7\r\n", "output": "8"}, {"input": "7.8\r\n", "output": "8"}, {"input": "7.9\r\n", "output": "8"}, {"input": "8.0\r\n", "output": "8"}, {"input": "8.1\r\n", "output": "8"}, {"input": "8.2\r\n", "output": "8"}, {"input": "8.3\r\n", "output": "8"}, {"input": "8.4\r\n", "output": "8"}, {"input": "8.5\r\n", "output": "9"}, {"input": "8.6\r\n", "output": "9"}, {"input": "8.7\r\n", "output": "9"}, {"input": "8.8\r\n", "output": "9"}, {"input": "8.9\r\n", "output": "9"}, {"input": "9.0\r\n", "output": "GOTO Vasilisa."}, {"input": "9.1\r\n", "output": "GOTO Vasilisa."}, {"input": "9.2\r\n", "output": "GOTO Vasilisa."}, {"input": "9.3\r\n", "output": "GOTO Vasilisa."}, {"input": "9.4\r\n", "output": "GOTO Vasilisa."}, {"input": "9.5\r\n", "output": "GOTO Vasilisa."}, {"input": "9.6\r\n", "output": "GOTO Vasilisa."}, {"input": "9.7\r\n", "output": "GOTO Vasilisa."}, {"input": "9.8\r\n", "output": "GOTO Vasilisa."}, {"input": "9.9\r\n", "output": "GOTO Vasilisa."}, {"input": "7536521504744364134984603189602839063535643888645969434165019366202558753840519.4999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\r\n", "output": "GOTO Vasilisa."}, {"input": "646188694587964249318078225173.5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\r\n", "output": "646188694587964249318078225174"}, {"input": "7017472758334494297677068672222822550374695787171163207025095950296957261530.50\r\n", "output": "7017472758334494297677068672222822550374695787171163207025095950296957261531"}, {"input": "41203422675619090661099806687619.49999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\r\n", "output": "GOTO Vasilisa."}]
| false |
stdio
| null | true |
99/A
|
99
|
A
|
Python 3
|
TESTS
| 134 | 92 | 0 |
169353780
|
n=input()
if "." not in n:
print(int(n))
else:
p=n.index(".")
if n[p-1]=="9":
print("GOTO Vasilisa.")
else:
s=n[:p]
x="0."+n[p+1:]
if float(x)>=0.5:
print(int(s)+1)
else:
print(int(s))
| 150 | 92 | 0 |
149005367
|
s=list(input());r=s.index('.')
if s[r-1]=='9':print('GOTO Vasilisa.')
else:
if s[r+1]>='5':s[r-1]=str(int(s[r-1])+1)
print(''.join(s[:r]))
|
Codeforces Beta Round 78 (Div. 2 Only)
|
CF
| 2,011 | 2 | 256 |
Help Far Away Kingdom
|
In a far away kingdom lived the King, the Prince, the Shoemaker, the Dressmaker and many other citizens. They lived happily until great trouble came into the Kingdom. The ACMers settled there.
Most damage those strange creatures inflicted upon the kingdom was that they loved high precision numbers. As a result, the Kingdom healers had already had three appointments with the merchants who were asked to sell, say, exactly 0.273549107 beer barrels. To deal with the problem somehow, the King issued an order obliging rounding up all numbers to the closest integer to simplify calculations. Specifically, the order went like this:
- If a number's integer part does not end with digit 9 and its fractional part is strictly less than 0.5, then the rounded up number coincides with the number’s integer part.
- If a number's integer part does not end with digit 9 and its fractional part is not less than 0.5, the rounded up number is obtained if we add 1 to the last digit of the number’s integer part.
- If the number’s integer part ends with digit 9, to round up the numbers one should go to Vasilisa the Wise. In the whole Kingdom she is the only one who can perform the tricky operation of carrying into the next position.
Merchants found the algorithm very sophisticated and they asked you (the ACMers) to help them. Can you write a program that would perform the rounding according to the King’s order?
|
The first line contains a single number to round up — the integer part (a non-empty set of decimal digits that do not start with 0 — with the exception of a case when the set consists of a single digit — in this case 0 can go first), then follows character «.» (a dot), and then follows the fractional part (any non-empty set of decimal digits). The number's length does not exceed 1000 characters, including the dot. There are no other characters in the input data.
|
If the last number of the integer part is not equal to 9, print the rounded-up number without leading zeroes. Otherwise, print the message "GOTO Vasilisa." (without the quotes).
| null | null |
[{"input": "0.0", "output": "0"}, {"input": "1.49", "output": "1"}, {"input": "1.50", "output": "2"}, {"input": "2.71828182845904523536", "output": "3"}, {"input": "3.14159265358979323846", "output": "3"}, {"input": "12345678901234567890.1", "output": "12345678901234567890"}, {"input": "123456789123456789.999", "output": "GOTO Vasilisa."}]
| 800 |
["strings"]
| 150 |
[{"input": "0.0\r\n", "output": "0"}, {"input": "1.49\r\n", "output": "1"}, {"input": "1.50\r\n", "output": "2"}, {"input": "2.71828182845904523536\r\n", "output": "3"}, {"input": "3.14159265358979323846\r\n", "output": "3"}, {"input": "12345678901234567890.1\r\n", "output": "12345678901234567890"}, {"input": "123456789123456789.999\r\n", "output": "GOTO Vasilisa."}, {"input": "12345678901234567890.9\r\n", "output": "12345678901234567891"}, {"input": "123456789123456788.999\r\n", "output": "123456789123456789"}, {"input": "9.000\r\n", "output": "GOTO Vasilisa."}, {"input": "0.1\r\n", "output": "0"}, {"input": "0.2\r\n", "output": "0"}, {"input": "0.3\r\n", "output": "0"}, {"input": "0.4\r\n", "output": "0"}, {"input": "0.5\r\n", "output": "1"}, {"input": "0.6\r\n", "output": "1"}, {"input": "0.7\r\n", "output": "1"}, {"input": "0.8\r\n", "output": "1"}, {"input": "0.9\r\n", "output": "1"}, {"input": "1.0\r\n", "output": "1"}, {"input": "1.1\r\n", "output": "1"}, {"input": "1.2\r\n", "output": "1"}, {"input": "1.3\r\n", "output": "1"}, {"input": "1.4\r\n", "output": "1"}, {"input": "1.5\r\n", "output": "2"}, {"input": "1.6\r\n", "output": "2"}, {"input": "1.7\r\n", "output": "2"}, {"input": "1.8\r\n", "output": "2"}, {"input": "1.9\r\n", "output": "2"}, {"input": "2.0\r\n", "output": "2"}, {"input": "2.1\r\n", "output": "2"}, {"input": "2.2\r\n", "output": "2"}, {"input": "2.3\r\n", "output": "2"}, {"input": "2.4\r\n", "output": "2"}, {"input": "2.5\r\n", "output": "3"}, {"input": "2.6\r\n", "output": "3"}, {"input": "2.7\r\n", "output": "3"}, {"input": "2.8\r\n", "output": "3"}, {"input": "2.9\r\n", "output": "3"}, {"input": "3.0\r\n", "output": "3"}, {"input": "3.1\r\n", "output": "3"}, {"input": "3.2\r\n", "output": "3"}, {"input": "3.3\r\n", "output": "3"}, {"input": "3.4\r\n", "output": "3"}, {"input": "3.5\r\n", "output": "4"}, {"input": "3.6\r\n", "output": "4"}, {"input": "3.7\r\n", "output": "4"}, {"input": "3.8\r\n", "output": "4"}, {"input": "3.9\r\n", "output": "4"}, {"input": "4.0\r\n", "output": "4"}, {"input": "4.1\r\n", "output": "4"}, {"input": "4.2\r\n", "output": "4"}, {"input": "4.3\r\n", "output": "4"}, {"input": "4.4\r\n", "output": "4"}, {"input": "4.5\r\n", "output": "5"}, {"input": "4.6\r\n", "output": "5"}, {"input": "4.7\r\n", "output": "5"}, {"input": "4.8\r\n", "output": "5"}, {"input": "4.9\r\n", "output": "5"}, {"input": "5.0\r\n", "output": "5"}, {"input": "5.1\r\n", "output": "5"}, {"input": "5.2\r\n", "output": "5"}, {"input": "5.3\r\n", "output": "5"}, {"input": "5.4\r\n", "output": "5"}, {"input": "5.5\r\n", "output": "6"}, {"input": "5.6\r\n", "output": "6"}, {"input": "5.7\r\n", "output": "6"}, {"input": "5.8\r\n", "output": "6"}, {"input": "5.9\r\n", "output": "6"}, {"input": "6.0\r\n", "output": "6"}, {"input": "6.1\r\n", "output": "6"}, {"input": "6.2\r\n", "output": "6"}, {"input": "6.3\r\n", "output": "6"}, {"input": "6.4\r\n", "output": "6"}, {"input": "6.5\r\n", "output": "7"}, {"input": "6.6\r\n", "output": "7"}, {"input": "6.7\r\n", "output": "7"}, {"input": "6.8\r\n", "output": "7"}, {"input": "6.9\r\n", "output": "7"}, {"input": "7.0\r\n", "output": "7"}, {"input": "7.1\r\n", "output": "7"}, {"input": "7.2\r\n", "output": "7"}, {"input": "7.3\r\n", "output": "7"}, {"input": "7.4\r\n", "output": "7"}, {"input": "7.5\r\n", "output": "8"}, {"input": "7.6\r\n", "output": "8"}, {"input": "7.7\r\n", "output": "8"}, {"input": "7.8\r\n", "output": "8"}, {"input": "7.9\r\n", "output": "8"}, {"input": "8.0\r\n", "output": "8"}, {"input": "8.1\r\n", "output": "8"}, {"input": "8.2\r\n", "output": "8"}, {"input": "8.3\r\n", "output": "8"}, {"input": "8.4\r\n", "output": "8"}, {"input": "8.5\r\n", "output": "9"}, {"input": "8.6\r\n", "output": "9"}, {"input": "8.7\r\n", "output": "9"}, {"input": "8.8\r\n", "output": "9"}, {"input": "8.9\r\n", "output": "9"}, {"input": "9.0\r\n", "output": "GOTO Vasilisa."}, {"input": "9.1\r\n", "output": "GOTO Vasilisa."}, {"input": "9.2\r\n", "output": "GOTO Vasilisa."}, {"input": "9.3\r\n", "output": "GOTO Vasilisa."}, {"input": "9.4\r\n", "output": "GOTO Vasilisa."}, {"input": "9.5\r\n", "output": "GOTO Vasilisa."}, {"input": "9.6\r\n", "output": "GOTO Vasilisa."}, {"input": "9.7\r\n", "output": "GOTO Vasilisa."}, {"input": "9.8\r\n", "output": "GOTO Vasilisa."}, {"input": "9.9\r\n", "output": "GOTO Vasilisa."}, {"input": "7536521504744364134984603189602839063535643888645969434165019366202558753840519.4999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\r\n", "output": "GOTO Vasilisa."}, {"input": "646188694587964249318078225173.5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\r\n", "output": "646188694587964249318078225174"}, {"input": "7017472758334494297677068672222822550374695787171163207025095950296957261530.50\r\n", "output": "7017472758334494297677068672222822550374695787171163207025095950296957261531"}, {"input": "41203422675619090661099806687619.49999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\r\n", "output": "GOTO Vasilisa."}]
| false |
stdio
| null | true |
99/A
|
99
|
A
|
PyPy 3
|
TESTS
| 134 | 218 | 0 |
114531778
|
number = input()
integer, decimal = number.split('.')
if int(integer) % 10 == 9:
print('GOTO Vasilisa.')
else:
decimal = '0.' + decimal
if float(decimal) >= 0.5:
print(int(integer) + 1)
else:
print(int(integer))
| 150 | 92 | 0 |
160042145
|
number = input().split('.')
if int(number[1][0]) >= 5 and int(number[0][-1]) < 9:
print(int(number[0]) + 1)
elif int(number[1][0]) < 5 and int(number[0][-1]) < 9:
print(int(number[0]))
else:
print('GOTO Vasilisa.')
|
Codeforces Beta Round 78 (Div. 2 Only)
|
CF
| 2,011 | 2 | 256 |
Help Far Away Kingdom
|
In a far away kingdom lived the King, the Prince, the Shoemaker, the Dressmaker and many other citizens. They lived happily until great trouble came into the Kingdom. The ACMers settled there.
Most damage those strange creatures inflicted upon the kingdom was that they loved high precision numbers. As a result, the Kingdom healers had already had three appointments with the merchants who were asked to sell, say, exactly 0.273549107 beer barrels. To deal with the problem somehow, the King issued an order obliging rounding up all numbers to the closest integer to simplify calculations. Specifically, the order went like this:
- If a number's integer part does not end with digit 9 and its fractional part is strictly less than 0.5, then the rounded up number coincides with the number’s integer part.
- If a number's integer part does not end with digit 9 and its fractional part is not less than 0.5, the rounded up number is obtained if we add 1 to the last digit of the number’s integer part.
- If the number’s integer part ends with digit 9, to round up the numbers one should go to Vasilisa the Wise. In the whole Kingdom she is the only one who can perform the tricky operation of carrying into the next position.
Merchants found the algorithm very sophisticated and they asked you (the ACMers) to help them. Can you write a program that would perform the rounding according to the King’s order?
|
The first line contains a single number to round up — the integer part (a non-empty set of decimal digits that do not start with 0 — with the exception of a case when the set consists of a single digit — in this case 0 can go first), then follows character «.» (a dot), and then follows the fractional part (any non-empty set of decimal digits). The number's length does not exceed 1000 characters, including the dot. There are no other characters in the input data.
|
If the last number of the integer part is not equal to 9, print the rounded-up number without leading zeroes. Otherwise, print the message "GOTO Vasilisa." (without the quotes).
| null | null |
[{"input": "0.0", "output": "0"}, {"input": "1.49", "output": "1"}, {"input": "1.50", "output": "2"}, {"input": "2.71828182845904523536", "output": "3"}, {"input": "3.14159265358979323846", "output": "3"}, {"input": "12345678901234567890.1", "output": "12345678901234567890"}, {"input": "123456789123456789.999", "output": "GOTO Vasilisa."}]
| 800 |
["strings"]
| 150 |
[{"input": "0.0\r\n", "output": "0"}, {"input": "1.49\r\n", "output": "1"}, {"input": "1.50\r\n", "output": "2"}, {"input": "2.71828182845904523536\r\n", "output": "3"}, {"input": "3.14159265358979323846\r\n", "output": "3"}, {"input": "12345678901234567890.1\r\n", "output": "12345678901234567890"}, {"input": "123456789123456789.999\r\n", "output": "GOTO Vasilisa."}, {"input": "12345678901234567890.9\r\n", "output": "12345678901234567891"}, {"input": "123456789123456788.999\r\n", "output": "123456789123456789"}, {"input": "9.000\r\n", "output": "GOTO Vasilisa."}, {"input": "0.1\r\n", "output": "0"}, {"input": "0.2\r\n", "output": "0"}, {"input": "0.3\r\n", "output": "0"}, {"input": "0.4\r\n", "output": "0"}, {"input": "0.5\r\n", "output": "1"}, {"input": "0.6\r\n", "output": "1"}, {"input": "0.7\r\n", "output": "1"}, {"input": "0.8\r\n", "output": "1"}, {"input": "0.9\r\n", "output": "1"}, {"input": "1.0\r\n", "output": "1"}, {"input": "1.1\r\n", "output": "1"}, {"input": "1.2\r\n", "output": "1"}, {"input": "1.3\r\n", "output": "1"}, {"input": "1.4\r\n", "output": "1"}, {"input": "1.5\r\n", "output": "2"}, {"input": "1.6\r\n", "output": "2"}, {"input": "1.7\r\n", "output": "2"}, {"input": "1.8\r\n", "output": "2"}, {"input": "1.9\r\n", "output": "2"}, {"input": "2.0\r\n", "output": "2"}, {"input": "2.1\r\n", "output": "2"}, {"input": "2.2\r\n", "output": "2"}, {"input": "2.3\r\n", "output": "2"}, {"input": "2.4\r\n", "output": "2"}, {"input": "2.5\r\n", "output": "3"}, {"input": "2.6\r\n", "output": "3"}, {"input": "2.7\r\n", "output": "3"}, {"input": "2.8\r\n", "output": "3"}, {"input": "2.9\r\n", "output": "3"}, {"input": "3.0\r\n", "output": "3"}, {"input": "3.1\r\n", "output": "3"}, {"input": "3.2\r\n", "output": "3"}, {"input": "3.3\r\n", "output": "3"}, {"input": "3.4\r\n", "output": "3"}, {"input": "3.5\r\n", "output": "4"}, {"input": "3.6\r\n", "output": "4"}, {"input": "3.7\r\n", "output": "4"}, {"input": "3.8\r\n", "output": "4"}, {"input": "3.9\r\n", "output": "4"}, {"input": "4.0\r\n", "output": "4"}, {"input": "4.1\r\n", "output": "4"}, {"input": "4.2\r\n", "output": "4"}, {"input": "4.3\r\n", "output": "4"}, {"input": "4.4\r\n", "output": "4"}, {"input": "4.5\r\n", "output": "5"}, {"input": "4.6\r\n", "output": "5"}, {"input": "4.7\r\n", "output": "5"}, {"input": "4.8\r\n", "output": "5"}, {"input": "4.9\r\n", "output": "5"}, {"input": "5.0\r\n", "output": "5"}, {"input": "5.1\r\n", "output": "5"}, {"input": "5.2\r\n", "output": "5"}, {"input": "5.3\r\n", "output": "5"}, {"input": "5.4\r\n", "output": "5"}, {"input": "5.5\r\n", "output": "6"}, {"input": "5.6\r\n", "output": "6"}, {"input": "5.7\r\n", "output": "6"}, {"input": "5.8\r\n", "output": "6"}, {"input": "5.9\r\n", "output": "6"}, {"input": "6.0\r\n", "output": "6"}, {"input": "6.1\r\n", "output": "6"}, {"input": "6.2\r\n", "output": "6"}, {"input": "6.3\r\n", "output": "6"}, {"input": "6.4\r\n", "output": "6"}, {"input": "6.5\r\n", "output": "7"}, {"input": "6.6\r\n", "output": "7"}, {"input": "6.7\r\n", "output": "7"}, {"input": "6.8\r\n", "output": "7"}, {"input": "6.9\r\n", "output": "7"}, {"input": "7.0\r\n", "output": "7"}, {"input": "7.1\r\n", "output": "7"}, {"input": "7.2\r\n", "output": "7"}, {"input": "7.3\r\n", "output": "7"}, {"input": "7.4\r\n", "output": "7"}, {"input": "7.5\r\n", "output": "8"}, {"input": "7.6\r\n", "output": "8"}, {"input": "7.7\r\n", "output": "8"}, {"input": "7.8\r\n", "output": "8"}, {"input": "7.9\r\n", "output": "8"}, {"input": "8.0\r\n", "output": "8"}, {"input": "8.1\r\n", "output": "8"}, {"input": "8.2\r\n", "output": "8"}, {"input": "8.3\r\n", "output": "8"}, {"input": "8.4\r\n", "output": "8"}, {"input": "8.5\r\n", "output": "9"}, {"input": "8.6\r\n", "output": "9"}, {"input": "8.7\r\n", "output": "9"}, {"input": "8.8\r\n", "output": "9"}, {"input": "8.9\r\n", "output": "9"}, {"input": "9.0\r\n", "output": "GOTO Vasilisa."}, {"input": "9.1\r\n", "output": "GOTO Vasilisa."}, {"input": "9.2\r\n", "output": "GOTO Vasilisa."}, {"input": "9.3\r\n", "output": "GOTO Vasilisa."}, {"input": "9.4\r\n", "output": "GOTO Vasilisa."}, {"input": "9.5\r\n", "output": "GOTO Vasilisa."}, {"input": "9.6\r\n", "output": "GOTO Vasilisa."}, {"input": "9.7\r\n", "output": "GOTO Vasilisa."}, {"input": "9.8\r\n", "output": "GOTO Vasilisa."}, {"input": "9.9\r\n", "output": "GOTO Vasilisa."}, {"input": "7536521504744364134984603189602839063535643888645969434165019366202558753840519.4999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\r\n", "output": "GOTO Vasilisa."}, {"input": "646188694587964249318078225173.5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\r\n", "output": "646188694587964249318078225174"}, {"input": "7017472758334494297677068672222822550374695787171163207025095950296957261530.50\r\n", "output": "7017472758334494297677068672222822550374695787171163207025095950296957261531"}, {"input": "41203422675619090661099806687619.49999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\r\n", "output": "GOTO Vasilisa."}]
| false |
stdio
| null | true |
99/A
|
99
|
A
|
Python 3
|
TESTS
| 134 | 92 | 0 |
170905104
|
s=input()
k=s.split('.')
p=k[0]
p=p[::-1]
if p[0]=='9':
print('GOTO Vasilisa.')
else:
q='0.'+k[1]
if float(q)<0.5:
print(int(k[0]))
else:
print(int(k[0])+1)
| 150 | 92 | 0 |
165274022
|
n=input()
n=n.split('.')
if n[0][-1]=='9':
print("GOTO Vasilisa.")
elif n[1][0]<'5':
print(n[0])
else:
print(int(n[0])+1)
|
Codeforces Beta Round 78 (Div. 2 Only)
|
CF
| 2,011 | 2 | 256 |
Help Far Away Kingdom
|
In a far away kingdom lived the King, the Prince, the Shoemaker, the Dressmaker and many other citizens. They lived happily until great trouble came into the Kingdom. The ACMers settled there.
Most damage those strange creatures inflicted upon the kingdom was that they loved high precision numbers. As a result, the Kingdom healers had already had three appointments with the merchants who were asked to sell, say, exactly 0.273549107 beer barrels. To deal with the problem somehow, the King issued an order obliging rounding up all numbers to the closest integer to simplify calculations. Specifically, the order went like this:
- If a number's integer part does not end with digit 9 and its fractional part is strictly less than 0.5, then the rounded up number coincides with the number’s integer part.
- If a number's integer part does not end with digit 9 and its fractional part is not less than 0.5, the rounded up number is obtained if we add 1 to the last digit of the number’s integer part.
- If the number’s integer part ends with digit 9, to round up the numbers one should go to Vasilisa the Wise. In the whole Kingdom she is the only one who can perform the tricky operation of carrying into the next position.
Merchants found the algorithm very sophisticated and they asked you (the ACMers) to help them. Can you write a program that would perform the rounding according to the King’s order?
|
The first line contains a single number to round up — the integer part (a non-empty set of decimal digits that do not start with 0 — with the exception of a case when the set consists of a single digit — in this case 0 can go first), then follows character «.» (a dot), and then follows the fractional part (any non-empty set of decimal digits). The number's length does not exceed 1000 characters, including the dot. There are no other characters in the input data.
|
If the last number of the integer part is not equal to 9, print the rounded-up number without leading zeroes. Otherwise, print the message "GOTO Vasilisa." (without the quotes).
| null | null |
[{"input": "0.0", "output": "0"}, {"input": "1.49", "output": "1"}, {"input": "1.50", "output": "2"}, {"input": "2.71828182845904523536", "output": "3"}, {"input": "3.14159265358979323846", "output": "3"}, {"input": "12345678901234567890.1", "output": "12345678901234567890"}, {"input": "123456789123456789.999", "output": "GOTO Vasilisa."}]
| 800 |
["strings"]
| 150 |
[{"input": "0.0\r\n", "output": "0"}, {"input": "1.49\r\n", "output": "1"}, {"input": "1.50\r\n", "output": "2"}, {"input": "2.71828182845904523536\r\n", "output": "3"}, {"input": "3.14159265358979323846\r\n", "output": "3"}, {"input": "12345678901234567890.1\r\n", "output": "12345678901234567890"}, {"input": "123456789123456789.999\r\n", "output": "GOTO Vasilisa."}, {"input": "12345678901234567890.9\r\n", "output": "12345678901234567891"}, {"input": "123456789123456788.999\r\n", "output": "123456789123456789"}, {"input": "9.000\r\n", "output": "GOTO Vasilisa."}, {"input": "0.1\r\n", "output": "0"}, {"input": "0.2\r\n", "output": "0"}, {"input": "0.3\r\n", "output": "0"}, {"input": "0.4\r\n", "output": "0"}, {"input": "0.5\r\n", "output": "1"}, {"input": "0.6\r\n", "output": "1"}, {"input": "0.7\r\n", "output": "1"}, {"input": "0.8\r\n", "output": "1"}, {"input": "0.9\r\n", "output": "1"}, {"input": "1.0\r\n", "output": "1"}, {"input": "1.1\r\n", "output": "1"}, {"input": "1.2\r\n", "output": "1"}, {"input": "1.3\r\n", "output": "1"}, {"input": "1.4\r\n", "output": "1"}, {"input": "1.5\r\n", "output": "2"}, {"input": "1.6\r\n", "output": "2"}, {"input": "1.7\r\n", "output": "2"}, {"input": "1.8\r\n", "output": "2"}, {"input": "1.9\r\n", "output": "2"}, {"input": "2.0\r\n", "output": "2"}, {"input": "2.1\r\n", "output": "2"}, {"input": "2.2\r\n", "output": "2"}, {"input": "2.3\r\n", "output": "2"}, {"input": "2.4\r\n", "output": "2"}, {"input": "2.5\r\n", "output": "3"}, {"input": "2.6\r\n", "output": "3"}, {"input": "2.7\r\n", "output": "3"}, {"input": "2.8\r\n", "output": "3"}, {"input": "2.9\r\n", "output": "3"}, {"input": "3.0\r\n", "output": "3"}, {"input": "3.1\r\n", "output": "3"}, {"input": "3.2\r\n", "output": "3"}, {"input": "3.3\r\n", "output": "3"}, {"input": "3.4\r\n", "output": "3"}, {"input": "3.5\r\n", "output": "4"}, {"input": "3.6\r\n", "output": "4"}, {"input": "3.7\r\n", "output": "4"}, {"input": "3.8\r\n", "output": "4"}, {"input": "3.9\r\n", "output": "4"}, {"input": "4.0\r\n", "output": "4"}, {"input": "4.1\r\n", "output": "4"}, {"input": "4.2\r\n", "output": "4"}, {"input": "4.3\r\n", "output": "4"}, {"input": "4.4\r\n", "output": "4"}, {"input": "4.5\r\n", "output": "5"}, {"input": "4.6\r\n", "output": "5"}, {"input": "4.7\r\n", "output": "5"}, {"input": "4.8\r\n", "output": "5"}, {"input": "4.9\r\n", "output": "5"}, {"input": "5.0\r\n", "output": "5"}, {"input": "5.1\r\n", "output": "5"}, {"input": "5.2\r\n", "output": "5"}, {"input": "5.3\r\n", "output": "5"}, {"input": "5.4\r\n", "output": "5"}, {"input": "5.5\r\n", "output": "6"}, {"input": "5.6\r\n", "output": "6"}, {"input": "5.7\r\n", "output": "6"}, {"input": "5.8\r\n", "output": "6"}, {"input": "5.9\r\n", "output": "6"}, {"input": "6.0\r\n", "output": "6"}, {"input": "6.1\r\n", "output": "6"}, {"input": "6.2\r\n", "output": "6"}, {"input": "6.3\r\n", "output": "6"}, {"input": "6.4\r\n", "output": "6"}, {"input": "6.5\r\n", "output": "7"}, {"input": "6.6\r\n", "output": "7"}, {"input": "6.7\r\n", "output": "7"}, {"input": "6.8\r\n", "output": "7"}, {"input": "6.9\r\n", "output": "7"}, {"input": "7.0\r\n", "output": "7"}, {"input": "7.1\r\n", "output": "7"}, {"input": "7.2\r\n", "output": "7"}, {"input": "7.3\r\n", "output": "7"}, {"input": "7.4\r\n", "output": "7"}, {"input": "7.5\r\n", "output": "8"}, {"input": "7.6\r\n", "output": "8"}, {"input": "7.7\r\n", "output": "8"}, {"input": "7.8\r\n", "output": "8"}, {"input": "7.9\r\n", "output": "8"}, {"input": "8.0\r\n", "output": "8"}, {"input": "8.1\r\n", "output": "8"}, {"input": "8.2\r\n", "output": "8"}, {"input": "8.3\r\n", "output": "8"}, {"input": "8.4\r\n", "output": "8"}, {"input": "8.5\r\n", "output": "9"}, {"input": "8.6\r\n", "output": "9"}, {"input": "8.7\r\n", "output": "9"}, {"input": "8.8\r\n", "output": "9"}, {"input": "8.9\r\n", "output": "9"}, {"input": "9.0\r\n", "output": "GOTO Vasilisa."}, {"input": "9.1\r\n", "output": "GOTO Vasilisa."}, {"input": "9.2\r\n", "output": "GOTO Vasilisa."}, {"input": "9.3\r\n", "output": "GOTO Vasilisa."}, {"input": "9.4\r\n", "output": "GOTO Vasilisa."}, {"input": "9.5\r\n", "output": "GOTO Vasilisa."}, {"input": "9.6\r\n", "output": "GOTO Vasilisa."}, {"input": "9.7\r\n", "output": "GOTO Vasilisa."}, {"input": "9.8\r\n", "output": "GOTO Vasilisa."}, {"input": "9.9\r\n", "output": "GOTO Vasilisa."}, {"input": "7536521504744364134984603189602839063535643888645969434165019366202558753840519.4999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\r\n", "output": "GOTO Vasilisa."}, {"input": "646188694587964249318078225173.5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\r\n", "output": "646188694587964249318078225174"}, {"input": "7017472758334494297677068672222822550374695787171163207025095950296957261530.50\r\n", "output": "7017472758334494297677068672222822550374695787171163207025095950296957261531"}, {"input": "41203422675619090661099806687619.49999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\r\n", "output": "GOTO Vasilisa."}]
| false |
stdio
| null | true |
750/B
|
750
|
B
|
Python 3
|
TESTS
| 8 | 46 | 0 |
211954607
|
c=True
x=20000
n= int(input())
for i in range(n):
t,d=map(str,input().split())
if d != 'South' and i==0:
c=False
elif d != 'North' and i == (n-1):
c=False
else:
if d == 'South' and x != 0:
x-=int(t)
elif x==20000 and d=='North':
c=False
elif x != 20000 and d == 'North':
x+=int(t)
elif d != 'South' and d !='North' and x != 20000 and x != 0:
continue
elif d != 'South' and d !='North' and (x == 20000 or x == 0):
c=False
print('YES' if x==20000 and c else 'NO')
| 140 | 62 | 0 |
232602852
|
ll=[]
x=int(input())
n,s=20000,0
for _ in range(x):
i,j=input().split()
i=int(i)
if (n==20000 or s==20000) and (j=="West"or j=="East"):
print("NO")
exit()
elif (j=="South" and i+s>20000) or (j=="North" and i+n>20000):
print("NO")
exit()
else:
if j=="South":
n-=i
s+=i
elif j=="North":
n+=i
s-=i
print("YES") if n==20000 else print("NO")
|
Good Bye 2016
|
CF
| 2,016 | 2 | 256 |
New Year and North Pole
|
In this problem we assume the Earth to be a completely round ball and its surface a perfect sphere. The length of the equator and any meridian is considered to be exactly 40 000 kilometers. Thus, travelling from North Pole to South Pole or vice versa takes exactly 20 000 kilometers.
Limak, a polar bear, lives on the North Pole. Close to the New Year, he helps somebody with delivering packages all around the world. Instead of coordinates of places to visit, Limak got a description how he should move, assuming that he starts from the North Pole. The description consists of n parts. In the i-th part of his journey, Limak should move ti kilometers in the direction represented by a string diri that is one of: "North", "South", "West", "East".
Limak isn’t sure whether the description is valid. You must help him to check the following conditions:
- If at any moment of time (before any of the instructions or while performing one of them) Limak is on the North Pole, he can move only to the South.
- If at any moment of time (before any of the instructions or while performing one of them) Limak is on the South Pole, he can move only to the North.
- The journey must end on the North Pole.
Check if the above conditions are satisfied and print "YES" or "NO" on a single line.
|
The first line of the input contains a single integer n (1 ≤ n ≤ 50).
The i-th of next n lines contains an integer ti and a string diri (1 ≤ ti ≤ 106, $${ dir } _ { i } \in \{ \mathrm { N o r t h, ~ S o u t h, ~ W e s t, ~ E a s t } \}$$) — the length and the direction of the i-th part of the journey, according to the description Limak got.
|
Print "YES" if the description satisfies the three conditions, otherwise print "NO", both without the quotes.
| null |
Drawings below show how Limak's journey would look like in first two samples. In the second sample the answer is "NO" because he doesn't end on the North Pole.
|
[{"input": "5\n7500 South\n10000 East\n3500 North\n4444 West\n4000 North", "output": "YES"}, {"input": "2\n15000 South\n4000 East", "output": "NO"}, {"input": "5\n20000 South\n1000 North\n1000000 West\n9000 North\n10000 North", "output": "YES"}, {"input": "3\n20000 South\n10 East\n20000 North", "output": "NO"}, {"input": "2\n1000 North\n1000 South", "output": "NO"}, {"input": "4\n50 South\n50 North\n15000 South\n15000 North", "output": "YES"}]
| 1,300 |
["geometry", "implementation"]
| 140 |
[{"input": "5\r\n7500 South\r\n10000 East\r\n3500 North\r\n4444 West\r\n4000 North\r\n", "output": "YES\r\n"}, {"input": "2\r\n15000 South\r\n4000 East\r\n", "output": "NO\r\n"}, {"input": "5\r\n20000 South\r\n1000 North\r\n1000000 West\r\n9000 North\r\n10000 North\r\n", "output": "YES\r\n"}, {"input": "3\r\n20000 South\r\n10 East\r\n20000 North\r\n", "output": "NO\r\n"}, {"input": "2\r\n1000 North\r\n1000 South\r\n", "output": "NO\r\n"}, {"input": "4\r\n50 South\r\n50 North\r\n15000 South\r\n15000 North\r\n", "output": "YES\r\n"}, {"input": "1\r\n1 South\r\n", "output": "NO\r\n"}, {"input": "1\r\n1 East\r\n", "output": "NO\r\n"}, {"input": "2\r\n1000000 South\r\n1000000 North\r\n", "output": "NO\r\n"}, {"input": "1\r\n149 South\r\n", "output": "NO\r\n"}, {"input": "1\r\n16277 East\r\n", "output": "NO\r\n"}, {"input": "1\r\n19701 South\r\n", "output": "NO\r\n"}, {"input": "1\r\n3125 South\r\n", "output": "NO\r\n"}, {"input": "1\r\n6549 South\r\n", "output": "NO\r\n"}, {"input": "1\r\n2677 South\r\n", "output": "NO\r\n"}, {"input": "1\r\n6101 South\r\n", "output": "NO\r\n"}, {"input": "1\r\n9525 South\r\n", "output": "NO\r\n"}, {"input": "1\r\n5653 South\r\n", "output": "NO\r\n"}, {"input": "2\r\n15072 South\r\n15072 North\r\n", "output": "YES\r\n"}, {"input": "2\r\n11200 South\r\n11200 North\r\n", "output": "YES\r\n"}, {"input": "2\r\n14624 South\r\n14624 North\r\n", "output": "YES\r\n"}, {"input": "2\r\n18048 South\r\n15452 West\r\n", "output": "NO\r\n"}, {"input": "2\r\n1472 West\r\n4930 North\r\n", "output": "NO\r\n"}, {"input": "2\r\n17600 South\r\n17600 North\r\n", "output": "YES\r\n"}, {"input": "2\r\n8320 East\r\n16589 East\r\n", "output": "NO\r\n"}, {"input": "2\r\n4448 South\r\n4448 North\r\n", "output": "YES\r\n"}, {"input": "2\r\n576 South\r\n576 North\r\n", "output": "YES\r\n"}, {"input": "3\r\n14186 South\r\n2291 West\r\n14186 North\r\n", "output": "YES\r\n"}, {"input": "3\r\n10314 South\r\n15961 North\r\n5647 South\r\n", "output": "NO\r\n"}, {"input": "3\r\n1035 East\r\n18143 South\r\n18143 North\r\n", "output": "NO\r\n"}, {"input": "3\r\n17163 South\r\n7620 East\r\n17163 North\r\n", "output": "YES\r\n"}, {"input": "3\r\n587 South\r\n17098 North\r\n16511 South\r\n", "output": "NO\r\n"}, {"input": "3\r\n16715 North\r\n6576 West\r\n12132 South\r\n", "output": "NO\r\n"}, {"input": "3\r\n7435 South\r\n245 North\r\n7190 North\r\n", "output": "YES\r\n"}, {"input": "3\r\n3563 South\r\n2427 South\r\n5990 North\r\n", "output": "YES\r\n"}, {"input": "3\r\n6987 South\r\n11904 East\r\n19951 East\r\n", "output": "NO\r\n"}, {"input": "4\r\n13301 South\r\n5948 East\r\n9265 East\r\n6891 North\r\n", "output": "NO\r\n"}, {"input": "4\r\n16725 South\r\n8129 South\r\n19530 West\r\n24854 North\r\n", "output": "NO\r\n"}, {"input": "4\r\n149 South\r\n17607 West\r\n18306 South\r\n18455 North\r\n", "output": "YES\r\n"}, {"input": "4\r\n16277 South\r\n19789 North\r\n4379 South\r\n867 North\r\n", "output": "NO\r\n"}, {"input": "4\r\n19701 South\r\n13458 South\r\n3156 North\r\n30003 North\r\n", "output": "NO\r\n"}, {"input": "4\r\n3125 South\r\n15640 East\r\n6125 East\r\n19535 South\r\n", "output": "NO\r\n"}, {"input": "4\r\n6549 East\r\n5118 North\r\n12198 East\r\n5118 South\r\n", "output": "NO\r\n"}, {"input": "4\r\n2677 East\r\n1891 West\r\n10974 West\r\n7511 North\r\n", "output": "NO\r\n"}, {"input": "4\r\n6102 South\r\n8265 East\r\n13943 South\r\n20045 North\r\n", "output": "NO\r\n"}, {"input": "5\r\n12416 South\r\n18116 North\r\n10553 West\r\n18435 West\r\n5700 South\r\n", "output": "NO\r\n"}, {"input": "5\r\n15840 South\r\n7594 South\r\n13522 South\r\n2423 South\r\n3334 West\r\n", "output": "NO\r\n"}, {"input": "5\r\n19264 East\r\n13968 East\r\n19595 North\r\n19115 North\r\n38710 South\r\n", "output": "NO\r\n"}, {"input": "5\r\n15392 South\r\n3445 North\r\n18372 East\r\n10399 North\r\n4403 South\r\n", "output": "NO\r\n"}, {"input": "5\r\n18816 South\r\n5627 West\r\n14045 East\r\n7091 East\r\n18816 North\r\n", "output": "YES\r\n"}, {"input": "5\r\n2240 South\r\n15104 North\r\n118 West\r\n11079 East\r\n12864 South\r\n", "output": "NO\r\n"}, {"input": "5\r\n5664 South\r\n1478 South\r\n18894 South\r\n2363 West\r\n26036 North\r\n", "output": "NO\r\n"}, {"input": "5\r\n1792 South\r\n10956 East\r\n9159 South\r\n19055 West\r\n10951 North\r\n", "output": "YES\r\n"}, {"input": "5\r\n12512 South\r\n13137 North\r\n7936 North\r\n7235 South\r\n1326 South\r\n", "output": "NO\r\n"}, {"input": "6\r\n14635 North\r\n14477 South\r\n17250 North\r\n14170 East\r\n15166 South\r\n2242 South\r\n", "output": "NO\r\n"}, {"input": "6\r\n10763 North\r\n3954 West\r\n7515 North\r\n18158 West\r\n6644 South\r\n11634 South\r\n", "output": "NO\r\n"}, {"input": "6\r\n14187 South\r\n13432 North\r\n6292 East\r\n14850 West\r\n10827 South\r\n9639 East\r\n", "output": "NO\r\n"}, {"input": "6\r\n10315 South\r\n15614 South\r\n5069 West\r\n6134 South\r\n7713 North\r\n24350 North\r\n", "output": "NO\r\n"}, {"input": "6\r\n1035 South\r\n9283 East\r\n15333 South\r\n2826 South\r\n19191 North\r\n3 North\r\n", "output": "YES\r\n"}, {"input": "6\r\n17163 West\r\n11465 North\r\n14110 South\r\n6814 North\r\n3373 East\r\n4169 South\r\n", "output": "NO\r\n"}, {"input": "6\r\n587 South\r\n942 West\r\n183 North\r\n18098 North\r\n260 East\r\n17694 South\r\n", "output": "NO\r\n"}, {"input": "6\r\n16715 West\r\n3124 East\r\n3152 East\r\n14790 East\r\n11738 West\r\n11461 East\r\n", "output": "NO\r\n"}, {"input": "6\r\n7435 South\r\n12602 South\r\n1929 East\r\n6074 East\r\n15920 West\r\n20037 North\r\n", "output": "NO\r\n"}, {"input": "7\r\n13750 South\r\n6645 South\r\n18539 East\r\n5713 North\r\n1580 North\r\n10012 West\r\n13102 North\r\n", "output": "NO\r\n"}, {"input": "7\r\n9878 West\r\n8827 East\r\n1508 West\r\n9702 North\r\n5763 North\r\n9755 North\r\n10034 South\r\n", "output": "NO\r\n"}, {"input": "7\r\n13302 West\r\n2496 North\r\n284 West\r\n6394 East\r\n9945 North\r\n12603 West\r\n12275 North\r\n", "output": "NO\r\n"}, {"input": "7\r\n16726 East\r\n19270 West\r\n6357 South\r\n17678 East\r\n14127 East\r\n12347 South\r\n6005 East\r\n", "output": "NO\r\n"}, {"input": "7\r\n150 South\r\n1452 North\r\n9326 North\r\n1666 West\r\n18309 East\r\n19386 East\r\n8246 West\r\n", "output": "NO\r\n"}, {"input": "7\r\n16278 South\r\n10929 South\r\n8103 East\r\n18358 West\r\n2492 West\r\n11834 South\r\n39041 North\r\n", "output": "NO\r\n"}, {"input": "7\r\n19702 South\r\n13111 East\r\n6880 East\r\n9642 South\r\n6674 West\r\n18874 East\r\n1112 North\r\n", "output": "NO\r\n"}, {"input": "7\r\n3126 South\r\n6780 North\r\n9848 West\r\n6334 North\r\n10856 West\r\n14425 West\r\n10649 East\r\n", "output": "NO\r\n"}, {"input": "7\r\n6550 South\r\n8962 West\r\n15921 South\r\n17618 North\r\n15038 South\r\n1465 North\r\n18426 North\r\n", "output": "NO\r\n"}, {"input": "8\r\n12864 South\r\n3005 West\r\n16723 West\r\n17257 West\r\n12187 East\r\n12976 South\r\n1598 North\r\n24242 North\r\n", "output": "NO\r\n"}, {"input": "8\r\n8992 South\r\n12483 North\r\n15500 South\r\n1245 South\r\n9073 East\r\n12719 East\r\n3839 East\r\n7130 South\r\n", "output": "NO\r\n"}, {"input": "8\r\n12416 North\r\n14665 South\r\n14277 North\r\n2129 South\r\n13255 East\r\n19759 South\r\n10272 West\r\n9860 North\r\n", "output": "NO\r\n"}, {"input": "8\r\n15840 South\r\n4142 East\r\n17246 North\r\n13413 North\r\n4733 West\r\n15311 North\r\n12514 South\r\n17616 South\r\n", "output": "NO\r\n"}, {"input": "8\r\n19264 South\r\n10516 North\r\n3319 East\r\n17401 East\r\n1620 West\r\n2350 West\r\n6243 North\r\n2505 North\r\n", "output": "YES\r\n"}, {"input": "8\r\n15392 South\r\n7290 West\r\n2096 West\r\n14093 East\r\n5802 South\r\n2094 North\r\n8484 East\r\n19100 North\r\n", "output": "NO\r\n"}, {"input": "8\r\n6113 South\r\n16767 East\r\n5064 South\r\n5377 West\r\n17280 South\r\n1838 West\r\n2213 West\r\n28457 North\r\n", "output": "NO\r\n"}, {"input": "8\r\n2241 West\r\n18949 South\r\n11137 South\r\n2069 West\r\n14166 South\r\n1581 South\r\n4455 South\r\n50288 North\r\n", "output": "NO\r\n"}, {"input": "8\r\n5665 South\r\n8426 East\r\n9914 North\r\n13353 South\r\n18349 North\r\n4429 East\r\n18184 North\r\n27429 South\r\n", "output": "NO\r\n"}, {"input": "9\r\n11979 South\r\n2470 East\r\n10716 North\r\n12992 East\r\n15497 West\r\n15940 North\r\n8107 West\r\n18934 East\r\n6993 South\r\n", "output": "NO\r\n"}, {"input": "9\r\n8107 South\r\n4652 North\r\n9493 North\r\n16980 West\r\n12383 West\r\n2980 West\r\n17644 South\r\n11043 West\r\n11447 North\r\n", "output": "NO\r\n"}, {"input": "9\r\n18827 South\r\n18321 West\r\n8270 East\r\n968 West\r\n16565 West\r\n15427 North\r\n4077 North\r\n18960 North\r\n19006 West\r\n", "output": "NO\r\n"}, {"input": "9\r\n14955 West\r\n503 North\r\n18535 West\r\n4956 South\r\n8044 South\r\n2467 East\r\n13615 East\r\n6877 East\r\n3460 North\r\n", "output": "NO\r\n"}, {"input": "9\r\n18379 South\r\n9980 South\r\n17311 West\r\n8944 South\r\n4930 South\r\n18019 South\r\n48 West\r\n14794 South\r\n75046 North\r\n", "output": "NO\r\n"}, {"input": "9\r\n14507 East\r\n12162 East\r\n16088 South\r\n5636 North\r\n9112 North\r\n5058 East\r\n9585 South\r\n2712 East\r\n10925 North\r\n", "output": "NO\r\n"}, {"input": "9\r\n5227 East\r\n8936 North\r\n6353 North\r\n16920 North\r\n591 North\r\n4802 South\r\n8722 North\r\n3333 West\r\n36720 South\r\n", "output": "NO\r\n"}, {"input": "9\r\n1355 North\r\n15309 West\r\n17834 North\r\n13612 East\r\n17477 North\r\n4546 North\r\n18260 East\r\n15442 North\r\n56654 South\r\n", "output": "NO\r\n"}, {"input": "9\r\n4779 South\r\n4787 East\r\n3907 East\r\n4896 East\r\n1659 East\r\n4289 West\r\n4693 West\r\n3359 East\r\n4779 North\r\n", "output": "YES\r\n"}, {"input": "1\r\n80000 South\r\n", "output": "NO\r\n"}, {"input": "2\r\n40000 South\r\n20000 North\r\n", "output": "NO\r\n"}, {"input": "1\r\n40000 South\r\n", "output": "NO\r\n"}, {"input": "2\r\n20001 South\r\n20001 North\r\n", "output": "NO\r\n"}, {"input": "4\r\n10000 South\r\n20000 South\r\n10000 North\r\n20000 North\r\n", "output": "NO\r\n"}, {"input": "3\r\n10 South\r\n20 North\r\n10 North\r\n", "output": "NO\r\n"}, {"input": "3\r\n1000 South\r\n1001 North\r\n1 North\r\n", "output": "NO\r\n"}, {"input": "2\r\n20000 South\r\n20000 West\r\n", "output": "NO\r\n"}, {"input": "3\r\n10000 South\r\n20000 South\r\n10000 North\r\n", "output": "NO\r\n"}, {"input": "2\r\n1 East\r\n1 North\r\n", "output": "NO\r\n"}, {"input": "2\r\n20000 West\r\n20000 West\r\n", "output": "NO\r\n"}, {"input": "2\r\n80000 South\r\n20000 North\r\n", "output": "NO\r\n"}, {"input": "2\r\n19999 South\r\n20001 South\r\n", "output": "NO\r\n"}, {"input": "3\r\n500 South\r\n1000 North\r\n500 North\r\n", "output": "NO\r\n"}, {"input": "1\r\n400000 South\r\n", "output": "NO\r\n"}, {"input": "2\r\n40000 South\r\n80000 North\r\n", "output": "NO\r\n"}, {"input": "2\r\n100 West\r\n100 North\r\n", "output": "NO\r\n"}, {"input": "2\r\n40000 South\r\n40000 North\r\n", "output": "NO\r\n"}, {"input": "2\r\n30000 South\r\n10000 North\r\n", "output": "NO\r\n"}, {"input": "2\r\n20000 South\r\n40000 North\r\n", "output": "NO\r\n"}, {"input": "10\r\n20000 South\r\n20000 North\r\n20000 South\r\n20000 North\r\n20000 South\r\n20000 North\r\n20000 South\r\n20000 North\r\n20000 South\r\n20000 North\r\n", "output": "YES\r\n"}, {"input": "2\r\n40001 South\r\n40001 North\r\n", "output": "NO\r\n"}, {"input": "2\r\n40001 South\r\n1 North\r\n", "output": "NO\r\n"}, {"input": "2\r\n50000 South\r\n50000 North\r\n", "output": "NO\r\n"}, {"input": "2\r\n30000 South\r\n30000 South\r\n", "output": "NO\r\n"}, {"input": "2\r\n10000 South\r\n50000 North\r\n", "output": "NO\r\n"}, {"input": "4\r\n15000 South\r\n15000 South\r\n15000 North\r\n15000 North\r\n", "output": "NO\r\n"}, {"input": "3\r\n50 South\r\n100 North\r\n50 North\r\n", "output": "NO\r\n"}, {"input": "2\r\n20001 South\r\n1 North\r\n", "output": "NO\r\n"}, {"input": "3\r\n5 South\r\n6 North\r\n1 South\r\n", "output": "NO\r\n"}, {"input": "1\r\n20000 South\r\n", "output": "NO\r\n"}, {"input": "4\r\n1 South\r\n20000 South\r\n1 North\r\n20000 North\r\n", "output": "NO\r\n"}, {"input": "2\r\n30000 South\r\n30000 North\r\n", "output": "NO\r\n"}, {"input": "3\r\n1 South\r\n2 North\r\n1 South\r\n", "output": "NO\r\n"}, {"input": "2\r\n60000 South\r\n60000 North\r\n", "output": "NO\r\n"}, {"input": "2\r\n50000 South\r\n10000 North\r\n", "output": "NO\r\n"}, {"input": "1\r\n5 North\r\n", "output": "NO\r\n"}, {"input": "2\r\n20010 South\r\n19990 North\r\n", "output": "NO\r\n"}, {"input": "3\r\n20000 South\r\n1 South\r\n20000 North\r\n", "output": "NO\r\n"}, {"input": "3\r\n1 South\r\n2 North\r\n39999 North\r\n", "output": "NO\r\n"}, {"input": "3\r\n10 South\r\n20 North\r\n10 South\r\n", "output": "NO\r\n"}, {"input": "3\r\n1 South\r\n2 North\r\n1 North\r\n", "output": "NO\r\n"}, {"input": "3\r\n2000 South\r\n19000 South\r\n19000 South\r\n", "output": "NO\r\n"}, {"input": "6\r\n15000 South\r\n15000 South\r\n15000 South\r\n15000 North\r\n15000 North\r\n15000 North\r\n", "output": "NO\r\n"}, {"input": "3\r\n1 South\r\n1 North\r\n1 East\r\n", "output": "NO\r\n"}, {"input": "2\r\n1 West\r\n1 North\r\n", "output": "NO\r\n"}, {"input": "3\r\n1 South\r\n123456 West\r\n1 North\r\n", "output": "YES\r\n"}]
| false |
stdio
| null | true |
750/B
|
750
|
B
|
Python 3
|
TESTS
| 1 | 30 | 0 |
210218600
|
n = int(input())
journey_parts = []
for _ in range(n):
ti, diri = input().split()
journey_parts.append((int(ti), diri))
current_latitude = 0
for ti, diri in journey_parts:
if diri == "North":
current_latitude -= ti
elif diri == "South":
current_latitude += ti
if current_latitude < 0 or current_latitude > 20000:
print("NO")
exit()
print("YES")
| 140 | 62 | 4,608,000 |
23437510
|
import math
n = int(input())
fi = 0
theta = 0
flag = True
for n in range(n):
row = [x for x in input().split()]
dist = int(row[0])
napr = row[1]
if (fi == 0 and napr != 'South') or fi < 0:
flag = False
break
if (fi == 20000 and napr != 'North') or fi > 20000:
flag = False
break
if napr == 'South':
fi += dist
elif napr == 'North':
fi -= dist
if flag and fi == 0:
print('YES')
else:
print('NO')
|
Good Bye 2016
|
CF
| 2,016 | 2 | 256 |
New Year and North Pole
|
In this problem we assume the Earth to be a completely round ball and its surface a perfect sphere. The length of the equator and any meridian is considered to be exactly 40 000 kilometers. Thus, travelling from North Pole to South Pole or vice versa takes exactly 20 000 kilometers.
Limak, a polar bear, lives on the North Pole. Close to the New Year, he helps somebody with delivering packages all around the world. Instead of coordinates of places to visit, Limak got a description how he should move, assuming that he starts from the North Pole. The description consists of n parts. In the i-th part of his journey, Limak should move ti kilometers in the direction represented by a string diri that is one of: "North", "South", "West", "East".
Limak isn’t sure whether the description is valid. You must help him to check the following conditions:
- If at any moment of time (before any of the instructions or while performing one of them) Limak is on the North Pole, he can move only to the South.
- If at any moment of time (before any of the instructions or while performing one of them) Limak is on the South Pole, he can move only to the North.
- The journey must end on the North Pole.
Check if the above conditions are satisfied and print "YES" or "NO" on a single line.
|
The first line of the input contains a single integer n (1 ≤ n ≤ 50).
The i-th of next n lines contains an integer ti and a string diri (1 ≤ ti ≤ 106, $${ dir } _ { i } \in \{ \mathrm { N o r t h, ~ S o u t h, ~ W e s t, ~ E a s t } \}$$) — the length and the direction of the i-th part of the journey, according to the description Limak got.
|
Print "YES" if the description satisfies the three conditions, otherwise print "NO", both without the quotes.
| null |
Drawings below show how Limak's journey would look like in first two samples. In the second sample the answer is "NO" because he doesn't end on the North Pole.
|
[{"input": "5\n7500 South\n10000 East\n3500 North\n4444 West\n4000 North", "output": "YES"}, {"input": "2\n15000 South\n4000 East", "output": "NO"}, {"input": "5\n20000 South\n1000 North\n1000000 West\n9000 North\n10000 North", "output": "YES"}, {"input": "3\n20000 South\n10 East\n20000 North", "output": "NO"}, {"input": "2\n1000 North\n1000 South", "output": "NO"}, {"input": "4\n50 South\n50 North\n15000 South\n15000 North", "output": "YES"}]
| 1,300 |
["geometry", "implementation"]
| 140 |
[{"input": "5\r\n7500 South\r\n10000 East\r\n3500 North\r\n4444 West\r\n4000 North\r\n", "output": "YES\r\n"}, {"input": "2\r\n15000 South\r\n4000 East\r\n", "output": "NO\r\n"}, {"input": "5\r\n20000 South\r\n1000 North\r\n1000000 West\r\n9000 North\r\n10000 North\r\n", "output": "YES\r\n"}, {"input": "3\r\n20000 South\r\n10 East\r\n20000 North\r\n", "output": "NO\r\n"}, {"input": "2\r\n1000 North\r\n1000 South\r\n", "output": "NO\r\n"}, {"input": "4\r\n50 South\r\n50 North\r\n15000 South\r\n15000 North\r\n", "output": "YES\r\n"}, {"input": "1\r\n1 South\r\n", "output": "NO\r\n"}, {"input": "1\r\n1 East\r\n", "output": "NO\r\n"}, {"input": "2\r\n1000000 South\r\n1000000 North\r\n", "output": "NO\r\n"}, {"input": "1\r\n149 South\r\n", "output": "NO\r\n"}, {"input": "1\r\n16277 East\r\n", "output": "NO\r\n"}, {"input": "1\r\n19701 South\r\n", "output": "NO\r\n"}, {"input": "1\r\n3125 South\r\n", "output": "NO\r\n"}, {"input": "1\r\n6549 South\r\n", "output": "NO\r\n"}, {"input": "1\r\n2677 South\r\n", "output": "NO\r\n"}, {"input": "1\r\n6101 South\r\n", "output": "NO\r\n"}, {"input": "1\r\n9525 South\r\n", "output": "NO\r\n"}, {"input": "1\r\n5653 South\r\n", "output": "NO\r\n"}, {"input": "2\r\n15072 South\r\n15072 North\r\n", "output": "YES\r\n"}, {"input": "2\r\n11200 South\r\n11200 North\r\n", "output": "YES\r\n"}, {"input": "2\r\n14624 South\r\n14624 North\r\n", "output": "YES\r\n"}, {"input": "2\r\n18048 South\r\n15452 West\r\n", "output": "NO\r\n"}, {"input": "2\r\n1472 West\r\n4930 North\r\n", "output": "NO\r\n"}, {"input": "2\r\n17600 South\r\n17600 North\r\n", "output": "YES\r\n"}, {"input": "2\r\n8320 East\r\n16589 East\r\n", "output": "NO\r\n"}, {"input": "2\r\n4448 South\r\n4448 North\r\n", "output": "YES\r\n"}, {"input": "2\r\n576 South\r\n576 North\r\n", "output": "YES\r\n"}, {"input": "3\r\n14186 South\r\n2291 West\r\n14186 North\r\n", "output": "YES\r\n"}, {"input": "3\r\n10314 South\r\n15961 North\r\n5647 South\r\n", "output": "NO\r\n"}, {"input": "3\r\n1035 East\r\n18143 South\r\n18143 North\r\n", "output": "NO\r\n"}, {"input": "3\r\n17163 South\r\n7620 East\r\n17163 North\r\n", "output": "YES\r\n"}, {"input": "3\r\n587 South\r\n17098 North\r\n16511 South\r\n", "output": "NO\r\n"}, {"input": "3\r\n16715 North\r\n6576 West\r\n12132 South\r\n", "output": "NO\r\n"}, {"input": "3\r\n7435 South\r\n245 North\r\n7190 North\r\n", "output": "YES\r\n"}, {"input": "3\r\n3563 South\r\n2427 South\r\n5990 North\r\n", "output": "YES\r\n"}, {"input": "3\r\n6987 South\r\n11904 East\r\n19951 East\r\n", "output": "NO\r\n"}, {"input": "4\r\n13301 South\r\n5948 East\r\n9265 East\r\n6891 North\r\n", "output": "NO\r\n"}, {"input": "4\r\n16725 South\r\n8129 South\r\n19530 West\r\n24854 North\r\n", "output": "NO\r\n"}, {"input": "4\r\n149 South\r\n17607 West\r\n18306 South\r\n18455 North\r\n", "output": "YES\r\n"}, {"input": "4\r\n16277 South\r\n19789 North\r\n4379 South\r\n867 North\r\n", "output": "NO\r\n"}, {"input": "4\r\n19701 South\r\n13458 South\r\n3156 North\r\n30003 North\r\n", "output": "NO\r\n"}, {"input": "4\r\n3125 South\r\n15640 East\r\n6125 East\r\n19535 South\r\n", "output": "NO\r\n"}, {"input": "4\r\n6549 East\r\n5118 North\r\n12198 East\r\n5118 South\r\n", "output": "NO\r\n"}, {"input": "4\r\n2677 East\r\n1891 West\r\n10974 West\r\n7511 North\r\n", "output": "NO\r\n"}, {"input": "4\r\n6102 South\r\n8265 East\r\n13943 South\r\n20045 North\r\n", "output": "NO\r\n"}, {"input": "5\r\n12416 South\r\n18116 North\r\n10553 West\r\n18435 West\r\n5700 South\r\n", "output": "NO\r\n"}, {"input": "5\r\n15840 South\r\n7594 South\r\n13522 South\r\n2423 South\r\n3334 West\r\n", "output": "NO\r\n"}, {"input": "5\r\n19264 East\r\n13968 East\r\n19595 North\r\n19115 North\r\n38710 South\r\n", "output": "NO\r\n"}, {"input": "5\r\n15392 South\r\n3445 North\r\n18372 East\r\n10399 North\r\n4403 South\r\n", "output": "NO\r\n"}, {"input": "5\r\n18816 South\r\n5627 West\r\n14045 East\r\n7091 East\r\n18816 North\r\n", "output": "YES\r\n"}, {"input": "5\r\n2240 South\r\n15104 North\r\n118 West\r\n11079 East\r\n12864 South\r\n", "output": "NO\r\n"}, {"input": "5\r\n5664 South\r\n1478 South\r\n18894 South\r\n2363 West\r\n26036 North\r\n", "output": "NO\r\n"}, {"input": "5\r\n1792 South\r\n10956 East\r\n9159 South\r\n19055 West\r\n10951 North\r\n", "output": "YES\r\n"}, {"input": "5\r\n12512 South\r\n13137 North\r\n7936 North\r\n7235 South\r\n1326 South\r\n", "output": "NO\r\n"}, {"input": "6\r\n14635 North\r\n14477 South\r\n17250 North\r\n14170 East\r\n15166 South\r\n2242 South\r\n", "output": "NO\r\n"}, {"input": "6\r\n10763 North\r\n3954 West\r\n7515 North\r\n18158 West\r\n6644 South\r\n11634 South\r\n", "output": "NO\r\n"}, {"input": "6\r\n14187 South\r\n13432 North\r\n6292 East\r\n14850 West\r\n10827 South\r\n9639 East\r\n", "output": "NO\r\n"}, {"input": "6\r\n10315 South\r\n15614 South\r\n5069 West\r\n6134 South\r\n7713 North\r\n24350 North\r\n", "output": "NO\r\n"}, {"input": "6\r\n1035 South\r\n9283 East\r\n15333 South\r\n2826 South\r\n19191 North\r\n3 North\r\n", "output": "YES\r\n"}, {"input": "6\r\n17163 West\r\n11465 North\r\n14110 South\r\n6814 North\r\n3373 East\r\n4169 South\r\n", "output": "NO\r\n"}, {"input": "6\r\n587 South\r\n942 West\r\n183 North\r\n18098 North\r\n260 East\r\n17694 South\r\n", "output": "NO\r\n"}, {"input": "6\r\n16715 West\r\n3124 East\r\n3152 East\r\n14790 East\r\n11738 West\r\n11461 East\r\n", "output": "NO\r\n"}, {"input": "6\r\n7435 South\r\n12602 South\r\n1929 East\r\n6074 East\r\n15920 West\r\n20037 North\r\n", "output": "NO\r\n"}, {"input": "7\r\n13750 South\r\n6645 South\r\n18539 East\r\n5713 North\r\n1580 North\r\n10012 West\r\n13102 North\r\n", "output": "NO\r\n"}, {"input": "7\r\n9878 West\r\n8827 East\r\n1508 West\r\n9702 North\r\n5763 North\r\n9755 North\r\n10034 South\r\n", "output": "NO\r\n"}, {"input": "7\r\n13302 West\r\n2496 North\r\n284 West\r\n6394 East\r\n9945 North\r\n12603 West\r\n12275 North\r\n", "output": "NO\r\n"}, {"input": "7\r\n16726 East\r\n19270 West\r\n6357 South\r\n17678 East\r\n14127 East\r\n12347 South\r\n6005 East\r\n", "output": "NO\r\n"}, {"input": "7\r\n150 South\r\n1452 North\r\n9326 North\r\n1666 West\r\n18309 East\r\n19386 East\r\n8246 West\r\n", "output": "NO\r\n"}, {"input": "7\r\n16278 South\r\n10929 South\r\n8103 East\r\n18358 West\r\n2492 West\r\n11834 South\r\n39041 North\r\n", "output": "NO\r\n"}, {"input": "7\r\n19702 South\r\n13111 East\r\n6880 East\r\n9642 South\r\n6674 West\r\n18874 East\r\n1112 North\r\n", "output": "NO\r\n"}, {"input": "7\r\n3126 South\r\n6780 North\r\n9848 West\r\n6334 North\r\n10856 West\r\n14425 West\r\n10649 East\r\n", "output": "NO\r\n"}, {"input": "7\r\n6550 South\r\n8962 West\r\n15921 South\r\n17618 North\r\n15038 South\r\n1465 North\r\n18426 North\r\n", "output": "NO\r\n"}, {"input": "8\r\n12864 South\r\n3005 West\r\n16723 West\r\n17257 West\r\n12187 East\r\n12976 South\r\n1598 North\r\n24242 North\r\n", "output": "NO\r\n"}, {"input": "8\r\n8992 South\r\n12483 North\r\n15500 South\r\n1245 South\r\n9073 East\r\n12719 East\r\n3839 East\r\n7130 South\r\n", "output": "NO\r\n"}, {"input": "8\r\n12416 North\r\n14665 South\r\n14277 North\r\n2129 South\r\n13255 East\r\n19759 South\r\n10272 West\r\n9860 North\r\n", "output": "NO\r\n"}, {"input": "8\r\n15840 South\r\n4142 East\r\n17246 North\r\n13413 North\r\n4733 West\r\n15311 North\r\n12514 South\r\n17616 South\r\n", "output": "NO\r\n"}, {"input": "8\r\n19264 South\r\n10516 North\r\n3319 East\r\n17401 East\r\n1620 West\r\n2350 West\r\n6243 North\r\n2505 North\r\n", "output": "YES\r\n"}, {"input": "8\r\n15392 South\r\n7290 West\r\n2096 West\r\n14093 East\r\n5802 South\r\n2094 North\r\n8484 East\r\n19100 North\r\n", "output": "NO\r\n"}, {"input": "8\r\n6113 South\r\n16767 East\r\n5064 South\r\n5377 West\r\n17280 South\r\n1838 West\r\n2213 West\r\n28457 North\r\n", "output": "NO\r\n"}, {"input": "8\r\n2241 West\r\n18949 South\r\n11137 South\r\n2069 West\r\n14166 South\r\n1581 South\r\n4455 South\r\n50288 North\r\n", "output": "NO\r\n"}, {"input": "8\r\n5665 South\r\n8426 East\r\n9914 North\r\n13353 South\r\n18349 North\r\n4429 East\r\n18184 North\r\n27429 South\r\n", "output": "NO\r\n"}, {"input": "9\r\n11979 South\r\n2470 East\r\n10716 North\r\n12992 East\r\n15497 West\r\n15940 North\r\n8107 West\r\n18934 East\r\n6993 South\r\n", "output": "NO\r\n"}, {"input": "9\r\n8107 South\r\n4652 North\r\n9493 North\r\n16980 West\r\n12383 West\r\n2980 West\r\n17644 South\r\n11043 West\r\n11447 North\r\n", "output": "NO\r\n"}, {"input": "9\r\n18827 South\r\n18321 West\r\n8270 East\r\n968 West\r\n16565 West\r\n15427 North\r\n4077 North\r\n18960 North\r\n19006 West\r\n", "output": "NO\r\n"}, {"input": "9\r\n14955 West\r\n503 North\r\n18535 West\r\n4956 South\r\n8044 South\r\n2467 East\r\n13615 East\r\n6877 East\r\n3460 North\r\n", "output": "NO\r\n"}, {"input": "9\r\n18379 South\r\n9980 South\r\n17311 West\r\n8944 South\r\n4930 South\r\n18019 South\r\n48 West\r\n14794 South\r\n75046 North\r\n", "output": "NO\r\n"}, {"input": "9\r\n14507 East\r\n12162 East\r\n16088 South\r\n5636 North\r\n9112 North\r\n5058 East\r\n9585 South\r\n2712 East\r\n10925 North\r\n", "output": "NO\r\n"}, {"input": "9\r\n5227 East\r\n8936 North\r\n6353 North\r\n16920 North\r\n591 North\r\n4802 South\r\n8722 North\r\n3333 West\r\n36720 South\r\n", "output": "NO\r\n"}, {"input": "9\r\n1355 North\r\n15309 West\r\n17834 North\r\n13612 East\r\n17477 North\r\n4546 North\r\n18260 East\r\n15442 North\r\n56654 South\r\n", "output": "NO\r\n"}, {"input": "9\r\n4779 South\r\n4787 East\r\n3907 East\r\n4896 East\r\n1659 East\r\n4289 West\r\n4693 West\r\n3359 East\r\n4779 North\r\n", "output": "YES\r\n"}, {"input": "1\r\n80000 South\r\n", "output": "NO\r\n"}, {"input": "2\r\n40000 South\r\n20000 North\r\n", "output": "NO\r\n"}, {"input": "1\r\n40000 South\r\n", "output": "NO\r\n"}, {"input": "2\r\n20001 South\r\n20001 North\r\n", "output": "NO\r\n"}, {"input": "4\r\n10000 South\r\n20000 South\r\n10000 North\r\n20000 North\r\n", "output": "NO\r\n"}, {"input": "3\r\n10 South\r\n20 North\r\n10 North\r\n", "output": "NO\r\n"}, {"input": "3\r\n1000 South\r\n1001 North\r\n1 North\r\n", "output": "NO\r\n"}, {"input": "2\r\n20000 South\r\n20000 West\r\n", "output": "NO\r\n"}, {"input": "3\r\n10000 South\r\n20000 South\r\n10000 North\r\n", "output": "NO\r\n"}, {"input": "2\r\n1 East\r\n1 North\r\n", "output": "NO\r\n"}, {"input": "2\r\n20000 West\r\n20000 West\r\n", "output": "NO\r\n"}, {"input": "2\r\n80000 South\r\n20000 North\r\n", "output": "NO\r\n"}, {"input": "2\r\n19999 South\r\n20001 South\r\n", "output": "NO\r\n"}, {"input": "3\r\n500 South\r\n1000 North\r\n500 North\r\n", "output": "NO\r\n"}, {"input": "1\r\n400000 South\r\n", "output": "NO\r\n"}, {"input": "2\r\n40000 South\r\n80000 North\r\n", "output": "NO\r\n"}, {"input": "2\r\n100 West\r\n100 North\r\n", "output": "NO\r\n"}, {"input": "2\r\n40000 South\r\n40000 North\r\n", "output": "NO\r\n"}, {"input": "2\r\n30000 South\r\n10000 North\r\n", "output": "NO\r\n"}, {"input": "2\r\n20000 South\r\n40000 North\r\n", "output": "NO\r\n"}, {"input": "10\r\n20000 South\r\n20000 North\r\n20000 South\r\n20000 North\r\n20000 South\r\n20000 North\r\n20000 South\r\n20000 North\r\n20000 South\r\n20000 North\r\n", "output": "YES\r\n"}, {"input": "2\r\n40001 South\r\n40001 North\r\n", "output": "NO\r\n"}, {"input": "2\r\n40001 South\r\n1 North\r\n", "output": "NO\r\n"}, {"input": "2\r\n50000 South\r\n50000 North\r\n", "output": "NO\r\n"}, {"input": "2\r\n30000 South\r\n30000 South\r\n", "output": "NO\r\n"}, {"input": "2\r\n10000 South\r\n50000 North\r\n", "output": "NO\r\n"}, {"input": "4\r\n15000 South\r\n15000 South\r\n15000 North\r\n15000 North\r\n", "output": "NO\r\n"}, {"input": "3\r\n50 South\r\n100 North\r\n50 North\r\n", "output": "NO\r\n"}, {"input": "2\r\n20001 South\r\n1 North\r\n", "output": "NO\r\n"}, {"input": "3\r\n5 South\r\n6 North\r\n1 South\r\n", "output": "NO\r\n"}, {"input": "1\r\n20000 South\r\n", "output": "NO\r\n"}, {"input": "4\r\n1 South\r\n20000 South\r\n1 North\r\n20000 North\r\n", "output": "NO\r\n"}, {"input": "2\r\n30000 South\r\n30000 North\r\n", "output": "NO\r\n"}, {"input": "3\r\n1 South\r\n2 North\r\n1 South\r\n", "output": "NO\r\n"}, {"input": "2\r\n60000 South\r\n60000 North\r\n", "output": "NO\r\n"}, {"input": "2\r\n50000 South\r\n10000 North\r\n", "output": "NO\r\n"}, {"input": "1\r\n5 North\r\n", "output": "NO\r\n"}, {"input": "2\r\n20010 South\r\n19990 North\r\n", "output": "NO\r\n"}, {"input": "3\r\n20000 South\r\n1 South\r\n20000 North\r\n", "output": "NO\r\n"}, {"input": "3\r\n1 South\r\n2 North\r\n39999 North\r\n", "output": "NO\r\n"}, {"input": "3\r\n10 South\r\n20 North\r\n10 South\r\n", "output": "NO\r\n"}, {"input": "3\r\n1 South\r\n2 North\r\n1 North\r\n", "output": "NO\r\n"}, {"input": "3\r\n2000 South\r\n19000 South\r\n19000 South\r\n", "output": "NO\r\n"}, {"input": "6\r\n15000 South\r\n15000 South\r\n15000 South\r\n15000 North\r\n15000 North\r\n15000 North\r\n", "output": "NO\r\n"}, {"input": "3\r\n1 South\r\n1 North\r\n1 East\r\n", "output": "NO\r\n"}, {"input": "2\r\n1 West\r\n1 North\r\n", "output": "NO\r\n"}, {"input": "3\r\n1 South\r\n123456 West\r\n1 North\r\n", "output": "YES\r\n"}]
| false |
stdio
| null | true |
979/B
|
979
|
B
|
Python 3
|
TESTS
| 137 | 187 | 7,782,400 |
38270585
|
n = int(input())
s1 = input()
s2 = input()
s3 = input()
s = len(s1)
d1, d2, d3 = dict(), dict(), dict()
for i in s1:
if i not in d1:
d1[i] = 1
else:
d1[i] += 1
for i in s2:
if i not in d2:
d2[i] = 1
else:
d2[i] += 1
for i in s3:
if i not in d3:
d3[i] = 1
else:
d3[i] += 1
max1, max2, max3 = 0, 0, 0
for i in d1:
if d1[i] > max1:
max1 = d1[i]
for i in d2:
if d2[i] > max2:
max2 = d2[i]
for i in d3:
if d3[i] > max3:
max3 = d3[i]
a = []
a.append([s - max1, "Kuro"])
a.append([s - max2, "Shiro"])
a.append([s - max3, "Katie"])
a.sort()
#print(a)
if a[0][0] > n:
if a[0][0] < a[1][0]:
print(a[0][1])
else:
print("Draw")
else:
for j in a:
q = n - j[0]
if q < 0:
j[0] = 100000000
else:
if n == 1:
j[0] = q % 2
else:
j[0] = 0
a.sort()
#print(a)
if a[0][0] < a[1][0]:
print(a[0][1])
else:
print("Draw")
| 184 | 93 | 2,969,600 |
217007184
|
from collections import Counter
n = int(input())
total = [0] * 3
for i in range(3):
s = input()
a = Counter(s)
MAX = max(a.values())
if MAX == len(s) and n == 1:
MAX = len(s) - 1
else:
MAX += n
MAX = min(MAX, len(s))
total[i] = MAX
max = max(total)
if total.count(max) > 1:
print("Draw")
else:
if total[0] == max:
print("Kuro")
elif total[1] == max:
print("Shiro")
else:
print("Katie")# 1691074927.9507425
|
Codeforces Round 482 (Div. 2)
|
CF
| 2,018 | 1 | 256 |
Treasure Hunt
|
After the big birthday party, Katie still wanted Shiro to have some more fun. Later, she came up with a game called treasure hunt. Of course, she invited her best friends Kuro and Shiro to play with her.
The three friends are very smart so they passed all the challenges very quickly and finally reached the destination. But the treasure can only belong to one cat so they started to think of something which can determine who is worthy of the treasure. Instantly, Kuro came up with some ribbons.
A random colorful ribbon is given to each of the cats. Each color of the ribbon can be represented as an uppercase or lowercase Latin letter. Let's call a consecutive subsequence of colors that appears in the ribbon a subribbon. The beauty of a ribbon is defined as the maximum number of times one of its subribbon appears in the ribbon. The more the subribbon appears, the more beautiful is the ribbon. For example, the ribbon aaaaaaa has the beauty of $$$7$$$ because its subribbon a appears $$$7$$$ times, and the ribbon abcdabc has the beauty of $$$2$$$ because its subribbon abc appears twice.
The rules are simple. The game will have $$$n$$$ turns. Every turn, each of the cats must change strictly one color (at one position) in his/her ribbon to an arbitrary color which is different from the unchanged one. For example, a ribbon aaab can be changed into acab in one turn. The one having the most beautiful ribbon after $$$n$$$ turns wins the treasure.
Could you find out who is going to be the winner if they all play optimally?
|
The first line contains an integer $$$n$$$ ($$$0 \leq n \leq 10^{9}$$$) — the number of turns.
Next 3 lines contain 3 ribbons of Kuro, Shiro and Katie one per line, respectively. Each ribbon is a string which contains no more than $$$10^{5}$$$ uppercase and lowercase Latin letters and is not empty. It is guaranteed that the length of all ribbons are equal for the purpose of fairness. Note that uppercase and lowercase letters are considered different colors.
|
Print the name of the winner ("Kuro", "Shiro" or "Katie"). If there are at least two cats that share the maximum beauty, print "Draw".
| null |
In the first example, after $$$3$$$ turns, Kuro can change his ribbon into ooooo, which has the beauty of $$$5$$$, while reaching such beauty for Shiro and Katie is impossible (both Shiro and Katie can reach the beauty of at most $$$4$$$, for example by changing Shiro's ribbon into SSiSS and changing Katie's ribbon into Kaaaa). Therefore, the winner is Kuro.
In the fourth example, since the length of each of the string is $$$9$$$ and the number of turn is $$$15$$$, everyone can change their ribbons in some way to reach the maximal beauty of $$$9$$$ by changing their strings into zzzzzzzzz after 9 turns, and repeatedly change their strings into azzzzzzzz and then into zzzzzzzzz thrice. Therefore, the game ends in a draw.
|
[{"input": "3\nKuroo\nShiro\nKatie", "output": "Kuro"}, {"input": "7\ntreasurehunt\nthreefriends\nhiCodeforces", "output": "Shiro"}, {"input": "1\nabcabc\ncbabac\nababca", "output": "Katie"}, {"input": "15\nfoPaErcvJ\nmZaxowpbt\nmkuOlaHRE", "output": "Draw"}]
| 1,800 |
["greedy"]
| 184 |
[{"input": "3\r\nKuroo\r\nShiro\r\nKatie\r\n", "output": "Kuro\r\n"}, {"input": "7\r\ntreasurehunt\r\nthreefriends\r\nhiCodeforces\r\n", "output": "Shiro\r\n"}, {"input": "1\r\nabcabc\r\ncbabac\r\nababca\r\n", "output": "Katie\r\n"}, {"input": "15\r\nfoPaErcvJ\r\nmZaxowpbt\r\nmkuOlaHRE\r\n", "output": "Draw\r\n"}, {"input": "1\r\naaaaaaaaaa\r\nAAAAAAcAAA\r\nbbbbbbzzbb\r\n", "output": "Shiro\r\n"}, {"input": "60\r\nddcZYXYbZbcXYcZdYbddaddYaZYZdaZdZZdXaaYdaZZZaXZXXaaZbb\r\ndcdXcYbcaXYaXYcacYabYcbZYdacaYbYdXaccYXZZZdYbbYdcZZZbY\r\nXaZXbbdcXaadcYdYYcbZdcaXaYZabbXZZYbYbcXbaXabcXbXadbZYZ\r\n", "output": "Draw\r\n"}, {"input": "9174\r\nbzbbbzzzbbzzccczzccczzbzbzcbzbbzccbzcccbccczzbbcbbzbzzzcbczbzbzzbbbczbbcbzzzbcbzczbcczb\r\ndbzzzccdcdczzzzzcdczbbzcdzbcdbzzdczbzddcddbdbzzzczcczzbdcbbzccbzzzdzbzddcbzbdzdcczccbdb\r\nzdczddzcdddddczdczdczdcdzczddzczdzddczdcdcdzczczzdzccdccczczdzczczdzcdddzddzccddcczczzd\r\n", "output": "Draw\r\n"}, {"input": "727\r\nbaabbabbbababbbbaaaabaabbaabababaaababaaababbbbababbbbbbbbbbaaabaabbbbbbbbaaaabaabbaaabaabbabaa\r\nddcdcccccccdccdcdccdddcddcddcddddcdddcdcdccddcdddddccddcccdcdddcdcccdccccccdcdcdccccccdccccccdc\r\nfffeefeffeefeeeeffefffeeefffeefffefeefefeeeffefefefefefefffffffeeeeeffffeefeeeeffffeeeeeefeffef\r\n", "output": "Draw\r\n"}, {"input": "61\r\nbzqiqprzfwddqwctcrhnkqcsnbmcmfmrgaljwieajfouvuiunmfbrehxchupmsdpwilwu\r\njyxxujvxkwilikqeegzxlyiugflxqqbwbujzedqnlzucdnuipacatdhcozuvgktwvirhs\r\ntqiahohijwfcetyyjlkfhfvkhdgllxmhyyhhtlhltcdspusyhwpwqzyagtsbaswaobwub\r\n", "output": "Katie\r\n"}, {"input": "30\r\njAjcdwkvcTYSYBBLniJIIIiubKWnqeDtUiaXSIPfhDTOrCWBQetm\r\nPQPOTgqfBWzQvPNeEaUaPQGdUgldmOZsBtsIqZGGyXozntMpOsyY\r\nNPfvGxMqIULNWOmUrHJfsqORUHkzKQfecXsTzgFCmUtFmIBudCJr\r\n", "output": "Draw\r\n"}, {"input": "3\r\nabcabcabcabcdddabc\r\nzxytzytxxtytxyzxyt\r\nfgffghfghffgghghhh\r\n", "output": "Katie\r\n"}, {"input": "3\r\naaaaa\r\naaaaa\r\naaaab\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaaaaa\r\naaaabcd\r\nabcdefg\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaaaaa\r\naaabcde\r\nabcdefg\r\n", "output": "Kuro\r\n"}, {"input": "3\r\naaaaaaa\r\naaaabbb\r\nabcdefg\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaa\r\nbbb\r\nabc\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaaa\r\nabcde\r\nabcde\r\n", "output": "Kuro\r\n"}, {"input": "3\r\naaaaa\r\nqwert\r\nlkjhg\r\n", "output": "Kuro\r\n"}, {"input": "3\r\naaaaa\r\nbbbbb\r\naabcd\r\n", "output": "Draw\r\n"}, {"input": "3\r\nabcde\r\nfghij\r\nkkkkk\r\n", "output": "Katie\r\n"}, {"input": "4\r\naaaabcd\r\naaaabcd\r\naaaaaaa\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaabb\r\naabcde\r\nabcdef\r\n", "output": "Kuro\r\n"}, {"input": "2\r\naaab\r\nabcd\r\naaaa\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaaaa\r\naaaaaa\r\nabcdef\r\n", "output": "Draw\r\n"}, {"input": "1\r\nAAAAA\r\nBBBBB\r\nABCDE\r\n", "output": "Draw\r\n"}, {"input": "1\r\nabcde\r\naaaaa\r\naaaaa\r\n", "output": "Draw\r\n"}, {"input": "4\r\naaabbb\r\nabfcde\r\nabfcde\r\n", "output": "Kuro\r\n"}, {"input": "0\r\naaa\r\naab\r\nccd\r\n", "output": "Kuro\r\n"}, {"input": "3\r\naaaaa\r\naaaaa\r\naabbb\r\n", "output": "Draw\r\n"}, {"input": "3\r\nxxxxxx\r\nxxxooo\r\nabcdef\r\n", "output": "Draw\r\n"}, {"input": "2\r\noooo\r\naaac\r\nabcd\r\n", "output": "Draw\r\n"}, {"input": "1\r\naaaaaaa\r\naaabcde\r\nabcdefg\r\n", "output": "Kuro\r\n"}, {"input": "3\r\nooooo\r\naaabb\r\nabcde\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaaa\r\nqwert\r\nqwery\r\n", "output": "Kuro\r\n"}, {"input": "2\r\naaaaaa\r\nbbbbbb\r\naaaaab\r\n", "output": "Draw\r\n"}, {"input": "3\r\naabb\r\naabb\r\naabc\r\n", "output": "Draw\r\n"}, {"input": "2\r\naaa\r\naab\r\naab\r\n", "output": "Draw\r\n"}, {"input": "3\r\nbbbbcc\r\nbbbbbb\r\nsadfgh\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaaaacc\r\nxxxxkkkk\r\nxxxxkkkk\r\n", "output": "Kuro\r\n"}, {"input": "2\r\naaaac\r\nbbbbc\r\nccccc\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaaaaaaa\r\naaabbbbbb\r\nabcdewert\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaabc\r\naaaab\r\nabcde\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaaaaaa\r\naaaaaaab\r\naaaabbbb\r\n", "output": "Draw\r\n"}, {"input": "2\r\nabcdefg\r\nabccccc\r\nacccccc\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaaa\r\naabcd\r\nabcde\r\n", "output": "Draw\r\n"}, {"input": "4\r\naaabbb\r\nabcdef\r\nabcdef\r\n", "output": "Kuro\r\n"}, {"input": "4\r\naaabbb\r\naabdef\r\nabcdef\r\n", "output": "Draw\r\n"}, {"input": "3\r\nabba\r\nbbbb\r\naaaa\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaaa\r\nbbaaa\r\nabcde\r\n", "output": "Draw\r\n"}, {"input": "2\r\naaa\r\naaa\r\nabc\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaaa\r\nabcda\r\nabcde\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaaa\r\nabcde\r\nbcdef\r\n", "output": "Kuro\r\n"}, {"input": "3\r\naaabb\r\naabbc\r\nqwert\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaaaa\r\naabbcc\r\naabbcc\r\n", "output": "Kuro\r\n"}, {"input": "3\r\nAAAAAA\r\nAAAAAB\r\nABCDEF\r\n", "output": "Draw\r\n"}, {"input": "3\r\nabc\r\naac\r\nbbb\r\n", "output": "Draw\r\n"}, {"input": "2\r\naaaab\r\naabbc\r\naabbc\r\n", "output": "Kuro\r\n"}, {"input": "2\r\naaaaaab\r\naaaaabb\r\nabcdefg\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaaaaaaaaa\r\nbbbbbbbbaaa\r\nqwertyuiasd\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaa\r\nbbbb\r\naabb\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaabb\r\naaabcd\r\nabcdef\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaa\r\nabc\r\nbbb\r\n", "output": "Draw\r\n"}, {"input": "1\r\naa\r\nab\r\nbb\r\n", "output": "Shiro\r\n"}, {"input": "1\r\naacb\r\nabcd\r\naaaa\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaabb\r\naaabbb\r\nabcdef\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaa\r\naaaa\r\nabcd\r\n", "output": "Draw\r\n"}, {"input": "2\r\nabcd\r\nabcd\r\naaad\r\n", "output": "Katie\r\n"}, {"input": "3\r\naaa\r\nbbb\r\naab\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaaaa\r\naaaaab\r\naaaaaa\r\n", "output": "Draw\r\n"}, {"input": "2\r\naaab\r\nabcd\r\nabcd\r\n", "output": "Kuro\r\n"}, {"input": "3\r\nooooo\r\nShiro\r\nKatie\r\n", "output": "Kuro\r\n"}, {"input": "3\r\naaabb\r\naabcd\r\nabcde\r\n", "output": "Draw\r\n"}, {"input": "4\r\nabcd\r\nabcd\r\naaaa\r\n", "output": "Draw\r\n"}, {"input": "4\r\naaa\r\nbbb\r\naab\r\n", "output": "Draw\r\n"}, {"input": "2\r\nxxxx\r\nyyyx\r\nabcd\r\n", "output": "Draw\r\n"}, {"input": "3\r\nAAAAA\r\nAAAAB\r\nABCDE\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaacdc\r\naaaaabc\r\naaaaabc\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaaaa\r\naabcde\r\naabcde\r\n", "output": "Kuro\r\n"}, {"input": "3\r\naaabb\r\naaabb\r\naaaaa\r\n", "output": "Draw\r\n"}, {"input": "5\r\nabbbbb\r\ncbbbbb\r\nabcdef\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaaaaaaa\r\naaaaabbbb\r\naaaaabbbb\r\n", "output": "Kuro\r\n"}, {"input": "4\r\naaaaaab\r\naaabbbb\r\naaabbbb\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaabb\r\naaaabb\r\naaabbb\r\n", "output": "Draw\r\n"}, {"input": "2\r\naaaabb\r\naaaaab\r\nabcdef\r\n", "output": "Draw\r\n"}, {"input": "2\r\naaaaa\r\naaaae\r\nabcde\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaaaa\r\nbbbcde\r\nabcdef\r\n", "output": "Draw\r\n"}, {"input": "4\r\naaaabbb\r\naabcdef\r\naabcdef\r\n", "output": "Kuro\r\n"}, {"input": "2\r\naaaaa\r\naaaab\r\nabcde\r\n", "output": "Draw\r\n"}, {"input": "3\r\naabbbbb\r\naaabbbb\r\nabcdefg\r\n", "output": "Draw\r\n"}, {"input": "3\r\nabcde\r\naabcd\r\naaaaa\r\n", "output": "Draw\r\n"}, {"input": "5\r\naaabbcc\r\nabcdefg\r\nabcdefg\r\n", "output": "Kuro\r\n"}, {"input": "3\r\naabbb\r\nabcde\r\nabcde\r\n", "output": "Kuro\r\n"}, {"input": "0\r\nbbb\r\nabb\r\nqer\r\n", "output": "Kuro\r\n"}, {"input": "5\r\naabbbbb\r\naaaaaaa\r\nabcdefg\r\n", "output": "Draw\r\n"}, {"input": "2\r\naaaab\r\naaaab\r\naaabb\r\n", "output": "Draw\r\n"}, {"input": "2\r\naaaaaab\r\naaaabbb\r\naaaaccc\r\n", "output": "Kuro\r\n"}, {"input": "3\r\naaaaaaaaaaaa\r\naaaaaaaaaaab\r\naaaaaabbbbbb\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaabb\r\nabcde\r\naaaaa\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaaaac\r\naaaaebc\r\naaaaaac\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaaaa\r\naaabbb\r\nqwerty\r\n", "output": "Draw\r\n"}, {"input": "3\r\ncccca\r\nabcde\r\nabcde\r\n", "output": "Kuro\r\n"}, {"input": "100005\r\nAA\r\nBC\r\nCC\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaa\r\nbbbb\r\nccca\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaaa\r\nbcdef\r\nbcdef\r\n", "output": "Kuro\r\n"}, {"input": "2\r\naaab\r\naabb\r\nqwer\r\n", "output": "Draw\r\n"}, {"input": "3\r\nabcddd\r\nabcdef\r\nbbaaaa\r\n", "output": "Draw\r\n"}, {"input": "2\r\naaaa\r\naaaa\r\naabc\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaa\r\naaaa\r\naaab\r\n", "output": "Draw\r\n"}, {"input": "3\r\nabcddd\r\nabcdef\r\naaaaaa\r\n", "output": "Draw\r\n"}, {"input": "1\r\naaaa\r\nabcd\r\naaab\r\n", "output": "Katie\r\n"}]
| false |
stdio
| null | true |
979/B
|
979
|
B
|
Python 3
|
TESTS
| 98 | 124 | 8,601,600 |
38261709
|
from collections import Counter
names = ["Kuro", "Shiro", "Katie"]
def solve(s, n):
d = Counter(s)
if len(d) == 1 and n == 1:
return n - 1
m = max(d.values())
return min(m+n,len(s))
n = int(input())
p = []
for _ in range(3):
p.append(input())
l = sorted([ (solve(p[i],n),i) for i in range(len(p))])
if l[2][0] > l[1][0]:
print(names[l[2][1]])
else:
print("Draw")
| 184 | 93 | 4,505,600 |
176881870
|
import sys, os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
n = int(input())
x = [0] * 3
for i in range(3):
s = list(input().rstrip())
cnt = [0] * 130
for j in s:
cnt[j] += 1
m = max(cnt)
c = min(m + n, len(s))
if m == len(s) and n == 1:
c = m - 1
x[i] = c
ma = max(x)
ans = []
d = ["Kuro", "Shiro", "Katie"]
for i in range(3):
if ma == x[i]:
ans.append(d[i])
if len(ans) ^ 1:
ans = ["Draw"]
ans = ans[0]
print(ans)
|
Codeforces Round 482 (Div. 2)
|
CF
| 2,018 | 1 | 256 |
Treasure Hunt
|
After the big birthday party, Katie still wanted Shiro to have some more fun. Later, she came up with a game called treasure hunt. Of course, she invited her best friends Kuro and Shiro to play with her.
The three friends are very smart so they passed all the challenges very quickly and finally reached the destination. But the treasure can only belong to one cat so they started to think of something which can determine who is worthy of the treasure. Instantly, Kuro came up with some ribbons.
A random colorful ribbon is given to each of the cats. Each color of the ribbon can be represented as an uppercase or lowercase Latin letter. Let's call a consecutive subsequence of colors that appears in the ribbon a subribbon. The beauty of a ribbon is defined as the maximum number of times one of its subribbon appears in the ribbon. The more the subribbon appears, the more beautiful is the ribbon. For example, the ribbon aaaaaaa has the beauty of $$$7$$$ because its subribbon a appears $$$7$$$ times, and the ribbon abcdabc has the beauty of $$$2$$$ because its subribbon abc appears twice.
The rules are simple. The game will have $$$n$$$ turns. Every turn, each of the cats must change strictly one color (at one position) in his/her ribbon to an arbitrary color which is different from the unchanged one. For example, a ribbon aaab can be changed into acab in one turn. The one having the most beautiful ribbon after $$$n$$$ turns wins the treasure.
Could you find out who is going to be the winner if they all play optimally?
|
The first line contains an integer $$$n$$$ ($$$0 \leq n \leq 10^{9}$$$) — the number of turns.
Next 3 lines contain 3 ribbons of Kuro, Shiro and Katie one per line, respectively. Each ribbon is a string which contains no more than $$$10^{5}$$$ uppercase and lowercase Latin letters and is not empty. It is guaranteed that the length of all ribbons are equal for the purpose of fairness. Note that uppercase and lowercase letters are considered different colors.
|
Print the name of the winner ("Kuro", "Shiro" or "Katie"). If there are at least two cats that share the maximum beauty, print "Draw".
| null |
In the first example, after $$$3$$$ turns, Kuro can change his ribbon into ooooo, which has the beauty of $$$5$$$, while reaching such beauty for Shiro and Katie is impossible (both Shiro and Katie can reach the beauty of at most $$$4$$$, for example by changing Shiro's ribbon into SSiSS and changing Katie's ribbon into Kaaaa). Therefore, the winner is Kuro.
In the fourth example, since the length of each of the string is $$$9$$$ and the number of turn is $$$15$$$, everyone can change their ribbons in some way to reach the maximal beauty of $$$9$$$ by changing their strings into zzzzzzzzz after 9 turns, and repeatedly change their strings into azzzzzzzz and then into zzzzzzzzz thrice. Therefore, the game ends in a draw.
|
[{"input": "3\nKuroo\nShiro\nKatie", "output": "Kuro"}, {"input": "7\ntreasurehunt\nthreefriends\nhiCodeforces", "output": "Shiro"}, {"input": "1\nabcabc\ncbabac\nababca", "output": "Katie"}, {"input": "15\nfoPaErcvJ\nmZaxowpbt\nmkuOlaHRE", "output": "Draw"}]
| 1,800 |
["greedy"]
| 184 |
[{"input": "3\r\nKuroo\r\nShiro\r\nKatie\r\n", "output": "Kuro\r\n"}, {"input": "7\r\ntreasurehunt\r\nthreefriends\r\nhiCodeforces\r\n", "output": "Shiro\r\n"}, {"input": "1\r\nabcabc\r\ncbabac\r\nababca\r\n", "output": "Katie\r\n"}, {"input": "15\r\nfoPaErcvJ\r\nmZaxowpbt\r\nmkuOlaHRE\r\n", "output": "Draw\r\n"}, {"input": "1\r\naaaaaaaaaa\r\nAAAAAAcAAA\r\nbbbbbbzzbb\r\n", "output": "Shiro\r\n"}, {"input": "60\r\nddcZYXYbZbcXYcZdYbddaddYaZYZdaZdZZdXaaYdaZZZaXZXXaaZbb\r\ndcdXcYbcaXYaXYcacYabYcbZYdacaYbYdXaccYXZZZdYbbYdcZZZbY\r\nXaZXbbdcXaadcYdYYcbZdcaXaYZabbXZZYbYbcXbaXabcXbXadbZYZ\r\n", "output": "Draw\r\n"}, {"input": "9174\r\nbzbbbzzzbbzzccczzccczzbzbzcbzbbzccbzcccbccczzbbcbbzbzzzcbczbzbzzbbbczbbcbzzzbcbzczbcczb\r\ndbzzzccdcdczzzzzcdczbbzcdzbcdbzzdczbzddcddbdbzzzczcczzbdcbbzccbzzzdzbzddcbzbdzdcczccbdb\r\nzdczddzcdddddczdczdczdcdzczddzczdzddczdcdcdzczczzdzccdccczczdzczczdzcdddzddzccddcczczzd\r\n", "output": "Draw\r\n"}, {"input": "727\r\nbaabbabbbababbbbaaaabaabbaabababaaababaaababbbbababbbbbbbbbbaaabaabbbbbbbbaaaabaabbaaabaabbabaa\r\nddcdcccccccdccdcdccdddcddcddcddddcdddcdcdccddcdddddccddcccdcdddcdcccdccccccdcdcdccccccdccccccdc\r\nfffeefeffeefeeeeffefffeeefffeefffefeefefeeeffefefefefefefffffffeeeeeffffeefeeeeffffeeeeeefeffef\r\n", "output": "Draw\r\n"}, {"input": "61\r\nbzqiqprzfwddqwctcrhnkqcsnbmcmfmrgaljwieajfouvuiunmfbrehxchupmsdpwilwu\r\njyxxujvxkwilikqeegzxlyiugflxqqbwbujzedqnlzucdnuipacatdhcozuvgktwvirhs\r\ntqiahohijwfcetyyjlkfhfvkhdgllxmhyyhhtlhltcdspusyhwpwqzyagtsbaswaobwub\r\n", "output": "Katie\r\n"}, {"input": "30\r\njAjcdwkvcTYSYBBLniJIIIiubKWnqeDtUiaXSIPfhDTOrCWBQetm\r\nPQPOTgqfBWzQvPNeEaUaPQGdUgldmOZsBtsIqZGGyXozntMpOsyY\r\nNPfvGxMqIULNWOmUrHJfsqORUHkzKQfecXsTzgFCmUtFmIBudCJr\r\n", "output": "Draw\r\n"}, {"input": "3\r\nabcabcabcabcdddabc\r\nzxytzytxxtytxyzxyt\r\nfgffghfghffgghghhh\r\n", "output": "Katie\r\n"}, {"input": "3\r\naaaaa\r\naaaaa\r\naaaab\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaaaaa\r\naaaabcd\r\nabcdefg\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaaaaa\r\naaabcde\r\nabcdefg\r\n", "output": "Kuro\r\n"}, {"input": "3\r\naaaaaaa\r\naaaabbb\r\nabcdefg\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaa\r\nbbb\r\nabc\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaaa\r\nabcde\r\nabcde\r\n", "output": "Kuro\r\n"}, {"input": "3\r\naaaaa\r\nqwert\r\nlkjhg\r\n", "output": "Kuro\r\n"}, {"input": "3\r\naaaaa\r\nbbbbb\r\naabcd\r\n", "output": "Draw\r\n"}, {"input": "3\r\nabcde\r\nfghij\r\nkkkkk\r\n", "output": "Katie\r\n"}, {"input": "4\r\naaaabcd\r\naaaabcd\r\naaaaaaa\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaabb\r\naabcde\r\nabcdef\r\n", "output": "Kuro\r\n"}, {"input": "2\r\naaab\r\nabcd\r\naaaa\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaaaa\r\naaaaaa\r\nabcdef\r\n", "output": "Draw\r\n"}, {"input": "1\r\nAAAAA\r\nBBBBB\r\nABCDE\r\n", "output": "Draw\r\n"}, {"input": "1\r\nabcde\r\naaaaa\r\naaaaa\r\n", "output": "Draw\r\n"}, {"input": "4\r\naaabbb\r\nabfcde\r\nabfcde\r\n", "output": "Kuro\r\n"}, {"input": "0\r\naaa\r\naab\r\nccd\r\n", "output": "Kuro\r\n"}, {"input": "3\r\naaaaa\r\naaaaa\r\naabbb\r\n", "output": "Draw\r\n"}, {"input": "3\r\nxxxxxx\r\nxxxooo\r\nabcdef\r\n", "output": "Draw\r\n"}, {"input": "2\r\noooo\r\naaac\r\nabcd\r\n", "output": "Draw\r\n"}, {"input": "1\r\naaaaaaa\r\naaabcde\r\nabcdefg\r\n", "output": "Kuro\r\n"}, {"input": "3\r\nooooo\r\naaabb\r\nabcde\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaaa\r\nqwert\r\nqwery\r\n", "output": "Kuro\r\n"}, {"input": "2\r\naaaaaa\r\nbbbbbb\r\naaaaab\r\n", "output": "Draw\r\n"}, {"input": "3\r\naabb\r\naabb\r\naabc\r\n", "output": "Draw\r\n"}, {"input": "2\r\naaa\r\naab\r\naab\r\n", "output": "Draw\r\n"}, {"input": "3\r\nbbbbcc\r\nbbbbbb\r\nsadfgh\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaaaacc\r\nxxxxkkkk\r\nxxxxkkkk\r\n", "output": "Kuro\r\n"}, {"input": "2\r\naaaac\r\nbbbbc\r\nccccc\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaaaaaaa\r\naaabbbbbb\r\nabcdewert\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaabc\r\naaaab\r\nabcde\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaaaaaa\r\naaaaaaab\r\naaaabbbb\r\n", "output": "Draw\r\n"}, {"input": "2\r\nabcdefg\r\nabccccc\r\nacccccc\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaaa\r\naabcd\r\nabcde\r\n", "output": "Draw\r\n"}, {"input": "4\r\naaabbb\r\nabcdef\r\nabcdef\r\n", "output": "Kuro\r\n"}, {"input": "4\r\naaabbb\r\naabdef\r\nabcdef\r\n", "output": "Draw\r\n"}, {"input": "3\r\nabba\r\nbbbb\r\naaaa\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaaa\r\nbbaaa\r\nabcde\r\n", "output": "Draw\r\n"}, {"input": "2\r\naaa\r\naaa\r\nabc\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaaa\r\nabcda\r\nabcde\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaaa\r\nabcde\r\nbcdef\r\n", "output": "Kuro\r\n"}, {"input": "3\r\naaabb\r\naabbc\r\nqwert\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaaaa\r\naabbcc\r\naabbcc\r\n", "output": "Kuro\r\n"}, {"input": "3\r\nAAAAAA\r\nAAAAAB\r\nABCDEF\r\n", "output": "Draw\r\n"}, {"input": "3\r\nabc\r\naac\r\nbbb\r\n", "output": "Draw\r\n"}, {"input": "2\r\naaaab\r\naabbc\r\naabbc\r\n", "output": "Kuro\r\n"}, {"input": "2\r\naaaaaab\r\naaaaabb\r\nabcdefg\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaaaaaaaaa\r\nbbbbbbbbaaa\r\nqwertyuiasd\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaa\r\nbbbb\r\naabb\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaabb\r\naaabcd\r\nabcdef\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaa\r\nabc\r\nbbb\r\n", "output": "Draw\r\n"}, {"input": "1\r\naa\r\nab\r\nbb\r\n", "output": "Shiro\r\n"}, {"input": "1\r\naacb\r\nabcd\r\naaaa\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaabb\r\naaabbb\r\nabcdef\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaa\r\naaaa\r\nabcd\r\n", "output": "Draw\r\n"}, {"input": "2\r\nabcd\r\nabcd\r\naaad\r\n", "output": "Katie\r\n"}, {"input": "3\r\naaa\r\nbbb\r\naab\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaaaa\r\naaaaab\r\naaaaaa\r\n", "output": "Draw\r\n"}, {"input": "2\r\naaab\r\nabcd\r\nabcd\r\n", "output": "Kuro\r\n"}, {"input": "3\r\nooooo\r\nShiro\r\nKatie\r\n", "output": "Kuro\r\n"}, {"input": "3\r\naaabb\r\naabcd\r\nabcde\r\n", "output": "Draw\r\n"}, {"input": "4\r\nabcd\r\nabcd\r\naaaa\r\n", "output": "Draw\r\n"}, {"input": "4\r\naaa\r\nbbb\r\naab\r\n", "output": "Draw\r\n"}, {"input": "2\r\nxxxx\r\nyyyx\r\nabcd\r\n", "output": "Draw\r\n"}, {"input": "3\r\nAAAAA\r\nAAAAB\r\nABCDE\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaacdc\r\naaaaabc\r\naaaaabc\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaaaa\r\naabcde\r\naabcde\r\n", "output": "Kuro\r\n"}, {"input": "3\r\naaabb\r\naaabb\r\naaaaa\r\n", "output": "Draw\r\n"}, {"input": "5\r\nabbbbb\r\ncbbbbb\r\nabcdef\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaaaaaaa\r\naaaaabbbb\r\naaaaabbbb\r\n", "output": "Kuro\r\n"}, {"input": "4\r\naaaaaab\r\naaabbbb\r\naaabbbb\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaabb\r\naaaabb\r\naaabbb\r\n", "output": "Draw\r\n"}, {"input": "2\r\naaaabb\r\naaaaab\r\nabcdef\r\n", "output": "Draw\r\n"}, {"input": "2\r\naaaaa\r\naaaae\r\nabcde\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaaaa\r\nbbbcde\r\nabcdef\r\n", "output": "Draw\r\n"}, {"input": "4\r\naaaabbb\r\naabcdef\r\naabcdef\r\n", "output": "Kuro\r\n"}, {"input": "2\r\naaaaa\r\naaaab\r\nabcde\r\n", "output": "Draw\r\n"}, {"input": "3\r\naabbbbb\r\naaabbbb\r\nabcdefg\r\n", "output": "Draw\r\n"}, {"input": "3\r\nabcde\r\naabcd\r\naaaaa\r\n", "output": "Draw\r\n"}, {"input": "5\r\naaabbcc\r\nabcdefg\r\nabcdefg\r\n", "output": "Kuro\r\n"}, {"input": "3\r\naabbb\r\nabcde\r\nabcde\r\n", "output": "Kuro\r\n"}, {"input": "0\r\nbbb\r\nabb\r\nqer\r\n", "output": "Kuro\r\n"}, {"input": "5\r\naabbbbb\r\naaaaaaa\r\nabcdefg\r\n", "output": "Draw\r\n"}, {"input": "2\r\naaaab\r\naaaab\r\naaabb\r\n", "output": "Draw\r\n"}, {"input": "2\r\naaaaaab\r\naaaabbb\r\naaaaccc\r\n", "output": "Kuro\r\n"}, {"input": "3\r\naaaaaaaaaaaa\r\naaaaaaaaaaab\r\naaaaaabbbbbb\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaabb\r\nabcde\r\naaaaa\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaaaac\r\naaaaebc\r\naaaaaac\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaaaa\r\naaabbb\r\nqwerty\r\n", "output": "Draw\r\n"}, {"input": "3\r\ncccca\r\nabcde\r\nabcde\r\n", "output": "Kuro\r\n"}, {"input": "100005\r\nAA\r\nBC\r\nCC\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaa\r\nbbbb\r\nccca\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaaa\r\nbcdef\r\nbcdef\r\n", "output": "Kuro\r\n"}, {"input": "2\r\naaab\r\naabb\r\nqwer\r\n", "output": "Draw\r\n"}, {"input": "3\r\nabcddd\r\nabcdef\r\nbbaaaa\r\n", "output": "Draw\r\n"}, {"input": "2\r\naaaa\r\naaaa\r\naabc\r\n", "output": "Draw\r\n"}, {"input": "3\r\naaaa\r\naaaa\r\naaab\r\n", "output": "Draw\r\n"}, {"input": "3\r\nabcddd\r\nabcdef\r\naaaaaa\r\n", "output": "Draw\r\n"}, {"input": "1\r\naaaa\r\nabcd\r\naaab\r\n", "output": "Katie\r\n"}]
| false |
stdio
| null | true |
797/B
|
797
|
B
|
PyPy 3
|
TESTS
| 16 | 124 | 20,172,800 |
79682834
|
a=int(input())
z=list(map(int,input().split()))
oddp=[]
eve=[]
oddn=[]
for i in range(len(z)):
if(z[i]%2==0 and z[i]>0):
eve.append(z[i])
elif(z[i]%2==1):
if(z[i]>0):
oddp.append(z[i])
else:
oddn.append(z[i])
if(len(oddp)==0):
print(max(oddn)+sum(eve))
else:
if(len(oddp)%2==1):
print(sum(oddp)+sum(eve))
else:
oddp.sort()
if(len(oddn)==0):
print(sum(oddp)-oddp[0]+sum(eve))
else:
print(max(min(oddn)+sum(oddp),sum(oddp)-oddp[0])+sum(eve))
| 126 | 78 | 10,547,200 |
228848341
|
input()
total_sum, min_odd = 0, 10**4
for num in map(int, input().split()):
if num > 0:
total_sum += num
if num % 2 != 0:
min_odd = min(abs(num), min_odd)
if total_sum % 2 != 1:
total_sum -= min_odd
print(total_sum)
|
Educational Codeforces Round 19
|
ICPC
| 2,017 | 1 | 256 |
Odd sum
|
You are given sequence a1, a2, ..., an of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements.
You should write a program which finds sum of the best subsequence.
|
The first line contains integer number n (1 ≤ n ≤ 105).
The second line contains n integer numbers a1, a2, ..., an ( - 104 ≤ ai ≤ 104). The sequence contains at least one subsequence with odd sum.
|
Print sum of resulting subseqeuence.
| null |
In the first example sum of the second and the fourth elements is 3.
|
[{"input": "4\n-2 2 -3 1", "output": "3"}, {"input": "3\n2 -5 -3", "output": "-1"}]
| 1,400 |
["dp", "greedy", "implementation"]
| 126 |
[{"input": "4\r\n-2 2 -3 1\r\n", "output": "3\r\n"}, {"input": "3\r\n2 -5 -3\r\n", "output": "-1\r\n"}, {"input": "1\r\n1\r\n", "output": "1\r\n"}, {"input": "1\r\n-1\r\n", "output": "-1\r\n"}, {"input": "15\r\n-6004 4882 9052 413 6056 4306 9946 -4616 -6135 906 -1718 5252 -2866 9061 4046\r\n", "output": "53507\r\n"}, {"input": "2\r\n-5439 -6705\r\n", "output": "-5439\r\n"}, {"input": "2\r\n2850 6843\r\n", "output": "9693\r\n"}, {"input": "2\r\n144 9001\r\n", "output": "9145\r\n"}, {"input": "10\r\n7535 -819 2389 4933 5495 4887 -5181 -9355 7955 5757\r\n", "output": "38951\r\n"}, {"input": "10\r\n-9169 -1574 3580 -8579 -7177 -3216 7490 3470 3465 -1197\r\n", "output": "18005\r\n"}, {"input": "10\r\n941 7724 2220 -4704 -8374 -8249 7606 9502 612 -9097\r\n", "output": "28605\r\n"}, {"input": "10\r\n4836 -2331 -3456 2312 -1574 3134 -670 -204 512 -5504\r\n", "output": "8463\r\n"}, {"input": "10\r\n1184 5136 1654 3254 6576 6900 6468 327 179 7114\r\n", "output": "38613\r\n"}, {"input": "10\r\n-2152 -1776 -1810 -9046 -6090 -2324 -8716 -6103 -787 -812\r\n", "output": "-787\r\n"}, {"input": "3\r\n1 1 1\r\n", "output": "3\r\n"}, {"input": "5\r\n5 5 5 3 -1\r\n", "output": "17\r\n"}, {"input": "5\r\n-1 -2 5 3 0\r\n", "output": "7\r\n"}, {"input": "5\r\n-3 -2 5 -1 3\r\n", "output": "7\r\n"}, {"input": "3\r\n-2 2 -1\r\n", "output": "1\r\n"}, {"input": "5\r\n5 0 7 -2 3\r\n", "output": "15\r\n"}, {"input": "2\r\n-2 -5\r\n", "output": "-5\r\n"}, {"input": "3\r\n-1 -3 0\r\n", "output": "-1\r\n"}, {"input": "5\r\n2 -1 0 -3 -2\r\n", "output": "1\r\n"}, {"input": "4\r\n2 3 0 5\r\n", "output": "7\r\n"}, {"input": "5\r\n-5 3 -2 2 5\r\n", "output": "7\r\n"}, {"input": "59\r\n8593 5929 3016 -859 4366 -6842 8435 -3910 -2458 -8503 -3612 -9793 -5360 -9791 -362 -7180 727 -6245 -8869 -7316 8214 -7944 7098 3788 -5436 -6626 -1131 -2410 -5647 -7981 263 -5879 8786 709 6489 5316 -4039 4909 -4340 7979 -89 9844 -906 172 -7674 -3371 -6828 9505 3284 5895 3646 6680 -1255 3635 -9547 -5104 -1435 -7222 2244\r\n", "output": "129433\r\n"}, {"input": "17\r\n-6170 2363 6202 -9142 7889 779 2843 -5089 2313 -3952 1843 5171 462 -3673 5098 -2519 9565\r\n", "output": "43749\r\n"}, {"input": "26\r\n-8668 9705 1798 -1766 9644 3688 8654 -3077 -5462 2274 6739 2732 3635 -4745 -9144 -9175 -7488 -2010 1637 1118 8987 1597 -2873 -5153 -8062 146\r\n", "output": "60757\r\n"}, {"input": "51\r\n8237 -7239 -3545 -6059 -5110 4066 -4148 -7641 -5797 -994 963 1144 -2785 -8765 -1216 5410 1508 -6312 -6313 -680 -7657 4579 -6898 7379 2015 -5087 -5417 -6092 3819 -9101 989 -8380 9161 -7519 -9314 -3838 7160 5180 567 -1606 -3842 -9665 -2266 1296 -8417 -3976 7436 -2075 -441 -4565 3313\r\n", "output": "73781\r\n"}, {"input": "1\r\n-1\r\n", "output": "-1\r\n"}, {"input": "1\r\n1\r\n", "output": "1\r\n"}, {"input": "1\r\n-1\r\n", "output": "-1\r\n"}, {"input": "1\r\n1\r\n", "output": "1\r\n"}, {"input": "1\r\n1\r\n", "output": "1\r\n"}, {"input": "1\r\n-1\r\n", "output": "-1\r\n"}, {"input": "1\r\n-1\r\n", "output": "-1\r\n"}, {"input": "1\r\n1\r\n", "output": "1\r\n"}, {"input": "2\r\n-2 1\r\n", "output": "1\r\n"}, {"input": "2\r\n3 2\r\n", "output": "5\r\n"}, {"input": "2\r\n1 2\r\n", "output": "3\r\n"}, {"input": "2\r\n-1 1\r\n", "output": "1\r\n"}, {"input": "2\r\n0 -1\r\n", "output": "-1\r\n"}, {"input": "2\r\n2 1\r\n", "output": "3\r\n"}, {"input": "2\r\n3 0\r\n", "output": "3\r\n"}, {"input": "2\r\n0 -1\r\n", "output": "-1\r\n"}, {"input": "3\r\n-3 1 -1\r\n", "output": "1\r\n"}, {"input": "3\r\n3 -1 1\r\n", "output": "3\r\n"}, {"input": "3\r\n1 3 1\r\n", "output": "5\r\n"}, {"input": "3\r\n-1 0 1\r\n", "output": "1\r\n"}, {"input": "3\r\n-3 -3 -2\r\n", "output": "-3\r\n"}, {"input": "3\r\n3 -1 1\r\n", "output": "3\r\n"}, {"input": "3\r\n3 -1 1\r\n", "output": "3\r\n"}, {"input": "3\r\n-2 -2 1\r\n", "output": "1\r\n"}, {"input": "4\r\n0 -1 -3 -4\r\n", "output": "-1\r\n"}, {"input": "4\r\n5 3 2 1\r\n", "output": "11\r\n"}, {"input": "4\r\n-1 -2 4 -2\r\n", "output": "3\r\n"}, {"input": "4\r\n-1 -3 0 -3\r\n", "output": "-1\r\n"}, {"input": "4\r\n1 -4 -3 -4\r\n", "output": "1\r\n"}, {"input": "4\r\n5 3 3 4\r\n", "output": "15\r\n"}, {"input": "4\r\n-1 -3 -1 2\r\n", "output": "1\r\n"}, {"input": "4\r\n3 2 -1 -4\r\n", "output": "5\r\n"}, {"input": "5\r\n-5 -4 -3 -5 2\r\n", "output": "-1\r\n"}, {"input": "5\r\n5 5 1 2 -2\r\n", "output": "13\r\n"}, {"input": "5\r\n-2 -1 -5 -1 4\r\n", "output": "3\r\n"}, {"input": "5\r\n-5 -5 -4 4 0\r\n", "output": "-1\r\n"}, {"input": "5\r\n2 -3 -1 -4 -5\r\n", "output": "1\r\n"}, {"input": "5\r\n4 3 4 2 3\r\n", "output": "13\r\n"}, {"input": "5\r\n0 -2 -5 3 3\r\n", "output": "3\r\n"}, {"input": "5\r\n4 -2 -2 -3 0\r\n", "output": "1\r\n"}, {"input": "6\r\n6 7 -1 1 5 -1\r\n", "output": "19\r\n"}, {"input": "6\r\n-1 7 2 -3 -4 -5\r\n", "output": "9\r\n"}, {"input": "6\r\n0 -1 -3 -5 2 -6\r\n", "output": "1\r\n"}, {"input": "6\r\n4 -1 0 3 6 1\r\n", "output": "13\r\n"}, {"input": "6\r\n5 3 3 4 4 -3\r\n", "output": "19\r\n"}, {"input": "6\r\n0 -3 5 -4 5 -4\r\n", "output": "7\r\n"}, {"input": "6\r\n-5 -3 1 -1 -5 -3\r\n", "output": "1\r\n"}, {"input": "6\r\n-2 1 3 -2 7 4\r\n", "output": "15\r\n"}, {"input": "7\r\n0 7 6 2 7 0 6\r\n", "output": "21\r\n"}, {"input": "7\r\n6 -6 -1 -5 7 1 7\r\n", "output": "21\r\n"}, {"input": "7\r\n2 3 -5 0 -4 0 -4\r\n", "output": "5\r\n"}, {"input": "7\r\n-6 3 -3 -1 -6 -6 -5\r\n", "output": "3\r\n"}, {"input": "7\r\n7 6 3 2 4 2 0\r\n", "output": "21\r\n"}, {"input": "7\r\n-2 3 -3 4 4 0 -1\r\n", "output": "11\r\n"}, {"input": "7\r\n-5 -7 4 0 5 -3 -5\r\n", "output": "9\r\n"}, {"input": "7\r\n-3 -5 -4 1 3 -4 -7\r\n", "output": "3\r\n"}, {"input": "8\r\n5 2 4 5 7 -2 7 3\r\n", "output": "33\r\n"}, {"input": "8\r\n-8 -3 -1 3 -8 -4 -4 4\r\n", "output": "7\r\n"}, {"input": "8\r\n-6 -7 -7 -5 -4 -9 -2 -7\r\n", "output": "-5\r\n"}, {"input": "8\r\n8 7 6 8 3 4 8 -2\r\n", "output": "41\r\n"}, {"input": "8\r\n6 7 0 -6 6 5 4 7\r\n", "output": "35\r\n"}, {"input": "8\r\n0 -7 -5 -5 5 -1 -8 -7\r\n", "output": "5\r\n"}, {"input": "8\r\n1 -6 -5 7 -3 -4 2 -2\r\n", "output": "9\r\n"}, {"input": "8\r\n1 -8 -6 -6 -6 -7 -5 -1\r\n", "output": "1\r\n"}, {"input": "9\r\n-3 -1 4 4 8 -8 -5 9 -2\r\n", "output": "25\r\n"}, {"input": "9\r\n-9 -1 3 -2 -7 2 -9 -1 -4\r\n", "output": "5\r\n"}, {"input": "9\r\n-6 -9 -3 -8 -5 2 -6 0 -5\r\n", "output": "-1\r\n"}, {"input": "9\r\n5 4 3 3 6 7 8 5 9\r\n", "output": "47\r\n"}, {"input": "9\r\n5 3 9 1 5 2 -3 7 0\r\n", "output": "31\r\n"}, {"input": "9\r\n-3 -9 -1 -7 5 6 -4 -6 -6\r\n", "output": "11\r\n"}, {"input": "9\r\n-6 -5 6 -5 -2 0 1 2 -9\r\n", "output": "9\r\n"}, {"input": "9\r\n8 3 6 1 -3 5 2 9 1\r\n", "output": "35\r\n"}, {"input": "10\r\n-6 -4 -7 -1 -9 -10 -10 1 0 -3\r\n", "output": "1\r\n"}, {"input": "10\r\n-2 -10 -5 -6 -10 -3 -6 -3 -8 -8\r\n", "output": "-3\r\n"}, {"input": "10\r\n8 5 9 2 3 3 -6 1 -1 8\r\n", "output": "39\r\n"}, {"input": "10\r\n2 10 -7 6 -1 -1 7 -9 -4 -6\r\n", "output": "25\r\n"}, {"input": "10\r\n-10 -2 -2 -1 -10 -7 1 0 -4 -5\r\n", "output": "1\r\n"}, {"input": "10\r\n4 3 10 -2 -1 0 10 6 7 0\r\n", "output": "39\r\n"}, {"input": "10\r\n-2 6 6 5 0 10 6 7 -1 1\r\n", "output": "41\r\n"}, {"input": "10\r\n-10 2 8 -6 -1 -5 1 -10 -10 -1\r\n", "output": "11\r\n"}]
| false |
stdio
| null | true |
815/A
|
815
|
A
|
PyPy 3
|
TESTS
| 16 | 155 | 5,324,800 |
112037896
|
n, m = map(int, input().split())
g = [list(map(int, input().split())) for _ in range(n)]
a = [0] * n
b = [0] * m
a[0] = min(g[0])
if a[0] > 0:
for j in range(m):
g[0][j] -= a[0]
b[j] = g[0][j]
good = True
for i in range(n):
for j in range(m):
g[i][j] -= b[j]
if min(g[i]) < 0 or min(g[i]) != max(g[i]):
good = False
a[i] += min(g[i])
if not good:
print(-1)
else:
if n > m:
x = min(a)
for i in range(n):
a[i] -= x
for j in range(m):
b[j] += x
else:
x = min(b)
for j in range(m):
b[j] -= x
for i in range(n):
a[i] += x
num = sum(a) + sum(b)
print(num)
for i in range(n):
for _ in range(a[i]):
print('row {}'.format(i + 1))
for j in range(m):
for _ in range(b[j]):
print('col {}'.format(j + 1))
| 177 | 108 | 3,788,800 |
27849257
|
import sys
#sys.stdin=open("data.txt")
input=sys.stdin.readline
n,m=map(int,input().split())
realg=[list(map(int,input().split())) for _ in range(n)]
g=[[0]*m for _ in range(n)]
ans=[]
# get differences
f1=min([realg[0][i] for i in range(m)])
for i in range(m):
for _ in range(realg[0][i]-f1):
ans.append("col %d"%(i+1))
for j in range(n):
g[j][i]+=realg[0][i]-f1
f2=min([realg[i][0] for i in range(n)])
for i in range(n):
for _ in range(realg[i][0]-f2):
ans.append("row %d"%(i+1))
for j in range(m):
g[i][j]+=realg[i][0]-f2
# check
bad=0
floor=realg[0][0]-g[0][0]
for i in range(n):
for j in range(m):
if realg[i][j]-g[i][j]!=floor:
bad=1
if bad: print("-1")
else:
# get floor done
if n<m:
for i in range(n):
for j in range(floor): ans.append("row %d"%(i+1))
else:
for i in range(m):
for j in range(floor): ans.append("col %d"%(i+1))
print(len(ans))
print("\n".join(ans))
|
Codeforces Round 419 (Div. 1)
|
CF
| 2,017 | 2 | 512 |
Karen and Game
|
On the way to school, Karen became fixated on the puzzle game on her phone!
The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0.
One move consists of choosing one row or column, and adding 1 to all of the cells in that row or column.
To win the level, after all the moves, the number in the cell at the i-th row and j-th column should be equal to gi, j.
Karen is stuck on one level, and wants to know a way to beat this level using the minimum number of moves. Please, help her with this task!
|
The first line of input contains two integers, n and m (1 ≤ n, m ≤ 100), the number of rows and the number of columns in the grid, respectively.
The next n lines each contain m integers. In particular, the j-th integer in the i-th of these rows contains gi, j (0 ≤ gi, j ≤ 500).
|
If there is an error and it is actually not possible to beat the level, output a single integer -1.
Otherwise, on the first line, output a single integer k, the minimum number of moves necessary to beat the level.
The next k lines should each contain one of the following, describing the moves in the order they must be done:
- row x, (1 ≤ x ≤ n) describing a move of the form "choose the x-th row".
- col x, (1 ≤ x ≤ m) describing a move of the form "choose the x-th column".
If there are multiple optimal solutions, output any one of them.
| null |
In the first test case, Karen has a grid with 3 rows and 5 columns. She can perform the following 4 moves to beat the level:
In the second test case, Karen has a grid with 3 rows and 3 columns. It is clear that it is impossible to beat the level; performing any move will create three 1s on the grid, but it is required to only have one 1 in the center.
In the third test case, Karen has a grid with 3 rows and 3 columns. She can perform the following 3 moves to beat the level:
Note that this is not the only solution; another solution, among others, is col 1, col 2, col 3.
|
[{"input": "3 5\n2 2 2 3 2\n0 0 0 1 0\n1 1 1 2 1", "output": "4\nrow 1\nrow 1\ncol 4\nrow 3"}, {"input": "3 3\n0 0 0\n0 1 0\n0 0 0", "output": "-1"}, {"input": "3 3\n1 1 1\n1 1 1\n1 1 1", "output": "3\nrow 1\nrow 2\nrow 3"}]
| 1,700 |
["brute force", "greedy", "implementation"]
| 177 |
[{"input": "3 5\r\n2 2 2 3 2\r\n0 0 0 1 0\r\n1 1 1 2 1\r\n", "output": "4\r\nrow 1\r\nrow 1\r\ncol 4\r\nrow 3\r\n"}, {"input": "3 3\r\n0 0 0\r\n0 1 0\r\n0 0 0\r\n", "output": "-1\r\n"}, {"input": "3 3\r\n1 1 1\r\n1 1 1\r\n1 1 1\r\n", "output": "3\r\nrow 1\r\nrow 2\r\nrow 3\r\n"}, {"input": "3 5\r\n2 4 2 2 3\r\n0 2 0 0 1\r\n1 3 1 1 2\r\n", "output": "6\r\nrow 1\r\nrow 1\r\ncol 2\r\ncol 2\r\ncol 5\r\nrow 3\r\n"}, {"input": "3 5\r\n0 0 0 0 0\r\n0 0 0 0 0\r\n0 0 0 0 1\r\n", "output": "-1\r\n"}, {"input": "9 10\r\n14 5 6 4 8 9 4 14 14 13\r\n13 4 5 3 7 8 3 13 13 12\r\n16 7 8 6 10 11 6 16 16 15\r\n10 1 2 0 4 5 0 10 10 9\r\n11 2 3 1 5 6 1 11 11 10\r\n10 1 2 0 4 5 0 10 10 9\r\n12 3 4 2 6 7 2 12 12 11\r\n13 4 5 3 7 8 3 13 13 12\r\n13 4 5 3 7 8 3 13 13 12\r\n", "output": "73\nrow 1\nrow 1\nrow 1\nrow 1\nrow 2\nrow 2\nrow 2\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 5\nrow 7\nrow 7\nrow 8\nrow 8\nrow 8\nrow 9\nrow 9\nrow 9\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 2\ncol 3\ncol 3\ncol 5\ncol 5\ncol 5\ncol 5\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\n"}, {"input": "10 10\r\n30 30 30 33 30 33 30 33 30 33\r\n431 431 431 434 431 434 431 434 431 434\r\n19 19 19 22 19 22 19 22 19 22\r\n24 24 24 27 24 27 24 27 24 27\r\n5 5 5 8 5 8 5 8 5 8\r\n0 0 0 3 0 3 0 3 0 3\r\n0 0 0 3 0 3 0 3 0 3\r\n0 0 0 3 0 3 0 3 0 3\r\n0 0 0 3 0 3 0 3 0 3\r\n0 0 0 3 0 3 0 3 0 3\r\n", "output": "521\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\ncol 4\ncol 4\ncol 4\ncol 6\ncol 6\ncol 6\ncol 8\ncol 8\ncol 8\ncol 10\ncol 10\ncol 10\n"}, {"input": "1 1\r\n0\r\n", "output": "0\r\n"}, {"input": "1 1\r\n500\r\n", "output": "500\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\n"}, {"input": "10 10\r\n1 1 1 1 1 1 1 1 1 1\r\n1 1 1 1 1 1 1 1 1 1\r\n1 1 1 1 1 1 1 1 1 1\r\n1 1 1 1 1 1 1 1 1 1\r\n0 0 0 0 0 0 0 0 0 0\r\n1 1 1 1 1 1 1 1 1 1\r\n1 1 1 1 1 1 1 1 1 1\r\n1 1 1 1 1 1 1 1 1 1\r\n1 1 1 1 1 1 1 1 1 1\r\n1 1 1 1 1 1 1 1 1 1\r\n", "output": "9\r\nrow 1\r\nrow 2\r\nrow 3\r\nrow 4\r\nrow 6\r\nrow 7\r\nrow 8\r\nrow 9\r\nrow 10\r\n"}, {"input": "10 10\r\n1 1 1 1 1 1 0 1 1 1\r\n1 1 1 1 1 1 0 1 1 1\r\n1 1 1 1 1 1 0 1 1 1\r\n1 1 1 1 1 1 0 1 1 1\r\n1 1 1 1 1 1 0 1 1 1\r\n1 1 1 1 1 1 0 1 1 1\r\n1 1 1 1 1 1 0 1 1 1\r\n1 1 1 1 1 1 0 1 1 1\r\n1 1 1 1 1 1 0 1 1 1\r\n1 1 1 1 1 1 0 1 1 1\r\n", "output": "9\r\ncol 1\r\ncol 2\r\ncol 3\r\ncol 4\r\ncol 5\r\ncol 6\r\ncol 8\r\ncol 9\r\ncol 10\r\n"}, {"input": "10 11\r\n8 7 10 15 5 13 12 9 14 11 6\r\n6 5 8 13 3 11 10 7 12 9 4\r\n10 9 12 17 7 15 14 11 16 13 8\r\n9 8 11 16 6 14 13 10 15 12 7\r\n12 11 14 19 9 17 16 13 18 15 10\r\n14 13 16 21 11 19 18 15 20 17 12\r\n7 6 9 14 4 12 11 8 13 10 5\r\n5 4 7 12 2 10 9 6 11 8 3\r\n11 10 13 18 8 16 15 12 17 14 9\r\n13 12 15 20 10 18 17 14 19 16 11\r\n", "output": "120\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 2\nrow 2\nrow 2\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 7\nrow 7\nrow 7\nrow 7\nrow 8\nrow 8\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\ncol 1\ncol 1\ncol 1\ncol 2\ncol 2\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 8\ncol 8\ncol 8\ncol 8\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 11\n"}, {"input": "5 3\r\n2 2 2\r\n2 2 2\r\n2 2 2\r\n1 1 1\r\n2 2 2\r\n", "output": "7\r\ncol 1\r\ncol 2\r\ncol 3\r\nrow 1\r\nrow 2\r\nrow 3\r\nrow 5\r\n"}, {"input": "3 5\r\n2 2 2 1 2\r\n2 2 2 1 2\r\n2 2 2 1 2\r\n", "output": "7\r\nrow 1\r\nrow 2\r\nrow 3\r\ncol 1\r\ncol 2\r\ncol 3\r\ncol 5\r\n"}, {"input": "1 100\r\n396 314 350 362 287 349 266 289 297 305 235 226 256 385 302 304 253 192 298 238 360 366 163 340 247 395 318 260 252 281 178 188 252 379 212 187 354 232 225 159 290 335 387 234 383 215 356 182 323 280 195 209 263 215 322 262 334 157 189 214 195 386 220 209 177 193 368 174 270 329 388 237 260 343 230 173 254 371 327 266 193 178 161 209 335 310 323 323 353 172 368 307 329 234 363 264 334 266 305 209\r\n", "output": "11960\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 23\ncol 23\ncol 23\ncol 23\ncol 23\ncol 23\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 31\ncol 31\ncol 31\ncol 31\ncol 31\ncol 31\ncol 31\ncol 31\ncol 31\ncol 31\ncol 31\ncol 31\ncol 31\ncol 31\ncol 31\ncol 31\ncol 31\ncol 31\ncol 31\ncol 31\ncol 31\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 40\ncol 40\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 48\ncol 48\ncol 48\ncol 48\ncol 48\ncol 48\ncol 48\ncol 48\ncol 48\ncol 48\ncol 48\ncol 48\ncol 48\ncol 48\ncol 48\ncol 48\ncol 48\ncol 48\ncol 48\ncol 48\ncol 48\ncol 48\ncol 48\ncol 48\ncol 48\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 65\ncol 65\ncol 65\ncol 65\ncol 65\ncol 65\ncol 65\ncol 65\ncol 65\ncol 65\ncol 65\ncol 65\ncol 65\ncol 65\ncol 65\ncol 65\ncol 65\ncol 65\ncol 65\ncol 65\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 68\ncol 68\ncol 68\ncol 68\ncol 68\ncol 68\ncol 68\ncol 68\ncol 68\ncol 68\ncol 68\ncol 68\ncol 68\ncol 68\ncol 68\ncol 68\ncol 68\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 76\ncol 76\ncol 76\ncol 76\ncol 76\ncol 76\ncol 76\ncol 76\ncol 76\ncol 76\ncol 76\ncol 76\ncol 76\ncol 76\ncol 76\ncol 76\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 82\ncol 82\ncol 82\ncol 82\ncol 82\ncol 82\ncol 82\ncol 82\ncol 82\ncol 82\ncol 82\ncol 82\ncol 82\ncol 82\ncol 82\ncol 82\ncol 82\ncol 82\ncol 82\ncol 82\ncol 82\ncol 83\ncol 83\ncol 83\ncol 83\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 90\ncol 90\ncol 90\ncol 90\ncol 90\ncol 90\ncol 90\ncol 90\ncol 90\ncol 90\ncol 90\ncol 90\ncol 90\ncol 90\ncol 90\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\n"}, {"input": "100 1\r\n173\r\n164\r\n99\r\n114\r\n255\r\n223\r\n280\r\n235\r\n207\r\n190\r\n136\r\n204\r\n206\r\n282\r\n253\r\n335\r\n267\r\n184\r\n288\r\n299\r\n263\r\n243\r\n341\r\n111\r\n278\r\n111\r\n214\r\n133\r\n125\r\n245\r\n99\r\n144\r\n232\r\n203\r\n131\r\n204\r\n117\r\n315\r\n269\r\n206\r\n262\r\n125\r\n212\r\n95\r\n220\r\n243\r\n141\r\n163\r\n311\r\n171\r\n222\r\n266\r\n141\r\n314\r\n329\r\n138\r\n187\r\n342\r\n272\r\n181\r\n300\r\n261\r\n339\r\n110\r\n194\r\n187\r\n183\r\n129\r\n151\r\n187\r\n129\r\n185\r\n322\r\n167\r\n99\r\n340\r\n285\r\n99\r\n176\r\n175\r\n272\r\n126\r\n220\r\n164\r\n237\r\n214\r\n96\r\n162\r\n129\r\n141\r\n144\r\n135\r\n172\r\n191\r\n155\r\n333\r\n186\r\n324\r\n237\r\n318\r\n", "output": "11282\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 3\nrow 3\nrow 3\nrow 3\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 24\nrow 24\nrow 24\nrow 24\nrow 24\nrow 24\nrow 24\nrow 24\nrow 24\nrow 24\nrow 24\nrow 24\nrow 24\nrow 24\nrow 24\nrow 24\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 26\nrow 26\nrow 26\nrow 26\nrow 26\nrow 26\nrow 26\nrow 26\nrow 26\nrow 26\nrow 26\nrow 26\nrow 26\nrow 26\nrow 26\nrow 26\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 31\nrow 31\nrow 31\nrow 31\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 37\nrow 37\nrow 37\nrow 37\nrow 37\nrow 37\nrow 37\nrow 37\nrow 37\nrow 37\nrow 37\nrow 37\nrow 37\nrow 37\nrow 37\nrow 37\nrow 37\nrow 37\nrow 37\nrow 37\nrow 37\nrow 37\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 64\nrow 64\nrow 64\nrow 64\nrow 64\nrow 64\nrow 64\nrow 64\nrow 64\nrow 64\nrow 64\nrow 64\nrow 64\nrow 64\nrow 64\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 75\nrow 75\nrow 75\nrow 75\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 78\nrow 78\nrow 78\nrow 78\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 87\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\n"}, {"input": "1 100\r\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\r\n", "output": "0\r\n"}, {"input": "100 1\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n", "output": "0\r\n"}, {"input": "1 100\r\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\r\n", "output": "1\r\nrow 1\r\n"}, {"input": "100 1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n", "output": "1\r\ncol 1\r\n"}, {"input": "1 100\r\n500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500\r\n", "output": "500\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\n"}, {"input": "100 1\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n", "output": "500\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\n"}, {"input": "2 1\r\n1\r\n1\r\n", "output": "1\r\ncol 1\r\n"}, {"input": "4 3\r\n1 1 1\r\n1 1 1\r\n1 1 1\r\n1 1 1\r\n", "output": "3\r\ncol 1\r\ncol 2\r\ncol 3\r\n"}, {"input": "2 1\r\n2\r\n2\r\n", "output": "2\r\ncol 1\r\ncol 1\r\n"}, {"input": "3 2\r\n1 1\r\n1 1\r\n1 1\r\n", "output": "2\r\ncol 1\r\ncol 2\r\n"}, {"input": "2 1\r\n1\r\n2\r\n", "output": "2\r\ncol 1\r\nrow 2\r\n"}, {"input": "2 3\r\n1 1 1\r\n1 1 1\r\n", "output": "2\r\nrow 1\r\nrow 2\r\n"}, {"input": "1 2\r\n1 1\r\n", "output": "1\r\nrow 1\r\n"}, {"input": "5 1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n", "output": "1\r\ncol 1\r\n"}, {"input": "10 3\r\n101 201 301\r\n102 202 302\r\n103 203 303\r\n104 204 304\r\n105 205 305\r\n106 206 306\r\n107 207 307\r\n108 208 308\r\n109 209 309\r\n111 211 311\r\n", "output": "649\nrow 2\nrow 3\nrow 3\nrow 4\nrow 4\nrow 4\nrow 5\nrow 5\nrow 5\nrow 5\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\n"}, {"input": "2 1\r\n10\r\n10\r\n", "output": "10\r\ncol 1\r\ncol 1\r\ncol 1\r\ncol 1\r\ncol 1\r\ncol 1\r\ncol 1\r\ncol 1\r\ncol 1\r\ncol 1\r\n"}, {"input": "4 3\r\n2 2 2\r\n2 2 2\r\n2 2 2\r\n2 2 2\r\n", "output": "6\r\ncol 1\r\ncol 2\r\ncol 3\r\ncol 1\r\ncol 2\r\ncol 3\r\n"}, {"input": "3 1\r\n1\r\n1\r\n1\r\n", "output": "1\r\ncol 1\r\n"}, {"input": "8 2\r\n2 2\r\n2 2\r\n2 2\r\n2 2\r\n2 2\r\n2 2\r\n2 2\r\n2 2\r\n", "output": "4\r\ncol 1\r\ncol 2\r\ncol 1\r\ncol 2\r\n"}, {"input": "1 2\r\n2 2\r\n", "output": "2\r\nrow 1\r\nrow 1\r\n"}, {"input": "3 2\r\n2 3\r\n2 3\r\n2 3\r\n", "output": "5\r\ncol 1\r\ncol 2\r\ncol 1\r\ncol 2\r\ncol 2\r\n"}, {"input": "2 1\r\n3\r\n3\r\n", "output": "3\r\ncol 1\r\ncol 1\r\ncol 1\r\n"}, {"input": "6 2\r\n1 1\r\n1 1\r\n1 1\r\n1 1\r\n1 1\r\n1 1\r\n", "output": "2\r\ncol 1\r\ncol 2\r\n"}, {"input": "4 1\r\n1\r\n1\r\n1\r\n1\r\n", "output": "1\r\ncol 1\r\n"}, {"input": "2 5\r\n1 1 1 1 1\r\n1 1 1 1 1\r\n", "output": "2\r\nrow 1\r\nrow 2\r\n"}, {"input": "3 1\r\n500\r\n500\r\n500\r\n", "output": "500\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\n"}, {"input": "5 2\r\n1 1\r\n2 2\r\n2 2\r\n2 2\r\n2 2\r\n", "output": "6\r\ncol 1\r\ncol 2\r\nrow 2\r\nrow 3\r\nrow 4\r\nrow 5\r\n"}, {"input": "4 3\r\n3 3 3\r\n3 3 3\r\n3 3 3\r\n3 3 3\r\n", "output": "9\r\ncol 1\r\ncol 2\r\ncol 3\r\ncol 1\r\ncol 2\r\ncol 3\r\ncol 1\r\ncol 2\r\ncol 3\r\n"}, {"input": "5 2\r\n1 1\r\n1 1\r\n1 1\r\n1 1\r\n1 1\r\n", "output": "2\r\ncol 1\r\ncol 2\r\n"}, {"input": "1 4\r\n1 1 1 1\r\n", "output": "1\r\nrow 1\r\n"}, {"input": "3 1\r\n2\r\n3\r\n2\r\n", "output": "3\r\ncol 1\r\ncol 1\r\nrow 2\r\n"}, {"input": "1 5\r\n1 1 1 1 1\r\n", "output": "1\r\nrow 1\r\n"}, {"input": "2 4\r\n3 1 1 1\r\n3 1 1 1\r\n", "output": "4\r\nrow 1\r\nrow 2\r\ncol 1\r\ncol 1\r\n"}, {"input": "3 3\r\n1 1 1\r\n0 1 0\r\n0 0 0\r\n", "output": "-1\r\n"}, {"input": "3 2\r\n2 2\r\n1 1\r\n2 2\r\n", "output": "4\r\ncol 1\r\ncol 2\r\nrow 1\r\nrow 3\r\n"}, {"input": "2 1\r\n9\r\n9\r\n", "output": "9\r\ncol 1\r\ncol 1\r\ncol 1\r\ncol 1\r\ncol 1\r\ncol 1\r\ncol 1\r\ncol 1\r\ncol 1\r\n"}, {"input": "1 7\r\n3 3 3 3 3 3 3\r\n", "output": "3\r\nrow 1\r\nrow 1\r\nrow 1\r\n"}, {"input": "5 2\r\n3 3\r\n3 3\r\n3 3\r\n3 3\r\n3 3\r\n", "output": "6\r\ncol 1\r\ncol 2\r\ncol 1\r\ncol 2\r\ncol 1\r\ncol 2\r\n"}, {"input": "10 11\r\n250 198 192 182 85 239 295 91 318 216 249\r\n290 238 232 222 125 279 335 131 358 256 289\r\n409 357 351 341 244 398 454 250 477 375 408\r\n362 310 304 294 197 351 407 203 430 328 361\r\n352 300 294 284 187 341 397 193 420 318 351\r\n409 357 351 341 244 398 454 250 477 375 408\r\n209 157 151 141 44 198 254 50 277 175 208\r\n313 261 255 245 148 302 358 154 381 279 312\r\n171 119 113 103 6 160 216 12 239 137 170\r\n275 223 217 207 110 264 320 116 343 241 274\r\n", "output": "2770\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\n"}, {"input": "7 1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n", "output": "1\r\ncol 1\r\n"}, {"input": "5 3\r\n1 1 1\r\n1 1 1\r\n1 1 1\r\n1 1 1\r\n1 1 1\r\n", "output": "3\r\ncol 1\r\ncol 2\r\ncol 3\r\n"}, {"input": "5 3\r\n3 3 3\r\n3 3 3\r\n3 3 3\r\n3 3 3\r\n3 3 3\r\n", "output": "9\r\ncol 1\r\ncol 2\r\ncol 3\r\ncol 1\r\ncol 2\r\ncol 3\r\ncol 1\r\ncol 2\r\ncol 3\r\n"}, {"input": "2 1\r\n4\r\n5\r\n", "output": "5\r\ncol 1\r\ncol 1\r\ncol 1\r\ncol 1\r\nrow 2\r\n"}, {"input": "4 2\r\n3 3\r\n3 3\r\n3 3\r\n3 3\r\n", "output": "6\r\ncol 1\r\ncol 2\r\ncol 1\r\ncol 2\r\ncol 1\r\ncol 2\r\n"}, {"input": "6 3\r\n2 2 2\r\n1 1 1\r\n1 1 1\r\n1 1 1\r\n1 1 1\r\n1 1 1\r\n", "output": "4\r\ncol 1\r\ncol 2\r\ncol 3\r\nrow 1\r\n"}, {"input": "5 1\r\n1\r\n2\r\n3\r\n4\r\n5\r\n", "output": "11\r\ncol 1\r\nrow 2\r\nrow 3\r\nrow 3\r\nrow 4\r\nrow 4\r\nrow 4\r\nrow 5\r\nrow 5\r\nrow 5\r\nrow 5\r\n"}, {"input": "2 1\r\n1\r\n3\r\n", "output": "3\r\ncol 1\r\nrow 2\r\nrow 2\r\n"}, {"input": "3 2\r\n1 500\r\n1 500\r\n1 500\r\n", "output": "501\ncol 1\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\n"}, {"input": "10 1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n", "output": "1\r\ncol 1\r\n"}, {"input": "6 2\r\n2 2\r\n2 2\r\n2 2\r\n2 2\r\n2 2\r\n2 2\r\n", "output": "4\r\ncol 1\r\ncol 2\r\ncol 1\r\ncol 2\r\n"}, {"input": "3 5\r\n1 1 1 1 1\r\n1 1 1 1 1\r\n1 1 1 1 1\r\n", "output": "3\r\nrow 1\r\nrow 2\r\nrow 3\r\n"}, {"input": "2 3\r\n2 1 2\r\n2 1 2\r\n", "output": "4\r\nrow 1\r\nrow 2\r\ncol 1\r\ncol 3\r\n"}, {"input": "5 2\r\n2 2\r\n2 2\r\n2 2\r\n2 2\r\n2 2\r\n", "output": "4\r\ncol 1\r\ncol 2\r\ncol 1\r\ncol 2\r\n"}, {"input": "1 2\r\n1 3\r\n", "output": "3\r\nrow 1\r\ncol 2\r\ncol 2\r\n"}, {"input": "4 3\r\n2 2 2\r\n1 1 1\r\n1 1 1\r\n1 1 1\r\n", "output": "4\r\ncol 1\r\ncol 2\r\ncol 3\r\nrow 1\r\n"}, {"input": "3 2\r\n1 1\r\n2 2\r\n3 3\r\n", "output": "5\r\ncol 1\r\ncol 2\r\nrow 2\r\nrow 3\r\nrow 3\r\n"}, {"input": "4 2\r\n1 1\r\n1 1\r\n1 1\r\n1 1\r\n", "output": "2\r\ncol 1\r\ncol 2\r\n"}, {"input": "3 4\r\n1 1 1 1\r\n1 1 1 1\r\n1 1 1 1\r\n", "output": "3\r\nrow 1\r\nrow 2\r\nrow 3\r\n"}, {"input": "2 1\r\n2\r\n3\r\n", "output": "3\r\ncol 1\r\ncol 1\r\nrow 2\r\n"}, {"input": "5 3\r\n2 2 2\r\n2 2 2\r\n2 2 2\r\n2 2 2\r\n2 2 2\r\n", "output": "6\r\ncol 1\r\ncol 2\r\ncol 3\r\ncol 1\r\ncol 2\r\ncol 3\r\n"}, {"input": "3 2\r\n1 0\r\n2 1\r\n2 1\r\n", "output": "3\r\ncol 1\r\nrow 2\r\nrow 3\r\n"}, {"input": "3 2\r\n1 2\r\n2 3\r\n3 4\r\n", "output": "6\r\ncol 1\r\ncol 2\r\ncol 2\r\nrow 2\r\nrow 3\r\nrow 3\r\n"}, {"input": "3 3\r\n1 1 1\r\n1 2 1\r\n1 1 1\r\n", "output": "-1\r\n"}, {"input": "4 3\r\n2 1 1\r\n2 1 1\r\n2 1 1\r\n2 1 1\r\n", "output": "4\r\ncol 1\r\ncol 2\r\ncol 3\r\ncol 1\r\n"}, {"input": "4 1\r\n3\r\n3\r\n3\r\n3\r\n", "output": "3\r\ncol 1\r\ncol 1\r\ncol 1\r\n"}, {"input": "1 3\r\n2 3 2\r\n", "output": "3\r\nrow 1\r\nrow 1\r\ncol 2\r\n"}, {"input": "1 2\r\n1 2\r\n", "output": "2\r\nrow 1\r\ncol 2\r\n"}, {"input": "3 2\r\n2 2\r\n2 2\r\n2 2\r\n", "output": "4\r\ncol 1\r\ncol 2\r\ncol 1\r\ncol 2\r\n"}, {"input": "1 3\r\n1 1 1\r\n", "output": "1\r\nrow 1\r\n"}, {"input": "6 3\r\n1 1 1\r\n1 1 1\r\n1 1 1\r\n1 1 1\r\n1 1 1\r\n1 1 1\r\n", "output": "3\r\ncol 1\r\ncol 2\r\ncol 3\r\n"}, {"input": "3 1\r\n2\r\n2\r\n2\r\n", "output": "2\r\ncol 1\r\ncol 1\r\n"}, {"input": "3 1\r\n3\r\n3\r\n3\r\n", "output": "3\r\ncol 1\r\ncol 1\r\ncol 1\r\n"}, {"input": "3 2\r\n2 2\r\n1 1\r\n1 1\r\n", "output": "3\r\ncol 1\r\ncol 2\r\nrow 1\r\n"}, {"input": "5 3\r\n1 1 2\r\n1 1 2\r\n1 1 2\r\n1 1 2\r\n1 1 2\r\n", "output": "4\r\ncol 1\r\ncol 2\r\ncol 3\r\ncol 3\r\n"}, {"input": "1 2\r\n2 3\r\n", "output": "3\r\nrow 1\r\nrow 1\r\ncol 2\r\n"}, {"input": "5 1\r\n2\r\n2\r\n2\r\n2\r\n2\r\n", "output": "2\r\ncol 1\r\ncol 1\r\n"}, {"input": "3 2\r\n1 1\r\n2 2\r\n2 2\r\n", "output": "4\r\ncol 1\r\ncol 2\r\nrow 2\r\nrow 3\r\n"}, {"input": "3 3\r\n1 1 1\r\n2 3 3\r\n4 4 4\r\n", "output": "-1\r\n"}, {"input": "2 1\r\n5\r\n2\r\n", "output": "5\r\ncol 1\r\ncol 1\r\nrow 1\r\nrow 1\r\nrow 1\r\n"}, {"input": "4 2\r\n2 2\r\n2 2\r\n2 2\r\n2 2\r\n", "output": "4\r\ncol 1\r\ncol 2\r\ncol 1\r\ncol 2\r\n"}, {"input": "3 2\r\n5 10\r\n5 10\r\n5 10\r\n", "output": "15\r\ncol 1\r\ncol 2\r\ncol 1\r\ncol 2\r\ncol 1\r\ncol 2\r\ncol 1\r\ncol 2\r\ncol 1\r\ncol 2\r\ncol 2\r\ncol 2\r\ncol 2\r\ncol 2\r\ncol 2\r\n"}, {"input": "4 3\r\n3 4 3\r\n5 6 5\r\n3 4 3\r\n3 4 3\r\n", "output": "12\r\ncol 1\r\ncol 2\r\ncol 3\r\ncol 1\r\ncol 2\r\ncol 3\r\ncol 1\r\ncol 2\r\ncol 3\r\ncol 2\r\nrow 2\r\nrow 2\r\n"}, {"input": "4 2\r\n1 1\r\n1 1\r\n1 1\r\n2 2\r\n", "output": "3\r\ncol 1\r\ncol 2\r\nrow 4\r\n"}, {"input": "2 3\r\n1 1 1\r\n500 500 500\r\n", "output": "501\nrow 1\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\n"}, {"input": "4 1\r\n4\r\n4\r\n4\r\n4\r\n", "output": "4\r\ncol 1\r\ncol 1\r\ncol 1\r\ncol 1\r\n"}, {"input": "3 2\r\n1 1\r\n1 1\r\n2 2\r\n", "output": "3\r\ncol 1\r\ncol 2\r\nrow 3\r\n"}, {"input": "2 3\r\n2 2 2\r\n2 2 2\r\n", "output": "4\r\nrow 1\r\nrow 2\r\nrow 1\r\nrow 2\r\n"}, {"input": "3 2\r\n3 3\r\n3 3\r\n3 3\r\n", "output": "6\r\ncol 1\r\ncol 2\r\ncol 1\r\ncol 2\r\ncol 1\r\ncol 2\r\n"}, {"input": "2 3\r\n10 10 10\r\n5 5 5\r\n", "output": "15\r\nrow 1\r\nrow 2\r\nrow 1\r\nrow 2\r\nrow 1\r\nrow 2\r\nrow 1\r\nrow 2\r\nrow 1\r\nrow 2\r\nrow 1\r\nrow 1\r\nrow 1\r\nrow 1\r\nrow 1\r\n"}, {"input": "5 2\r\n1 2\r\n1 2\r\n1 2\r\n1 2\r\n1 2\r\n", "output": "3\r\ncol 1\r\ncol 2\r\ncol 2\r\n"}, {"input": "1 2\r\n500 500\r\n", "output": "500\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\n"}, {"input": "2 1\r\n5\r\n5\r\n", "output": "5\r\ncol 1\r\ncol 1\r\ncol 1\r\ncol 1\r\ncol 1\r\n"}]
| false |
stdio
|
import sys
def main():
input_path = sys.argv[1]
output_path = sys.argv[2]
submission_path = sys.argv[3]
with open(input_path, 'r') as f:
n, m = map(int, f.readline().split())
grid = [list(map(int, f.readline().split())) for _ in range(n)]
possible = True
g1_1 = grid[0][0] if n > 0 and m > 0 else 0
for j in range(1, m):
expected_delta = grid[0][j] - g1_1
for i in range(n):
if grid[i][j] - grid[i][0] != expected_delta:
possible = False
break
if not possible:
break
if possible:
for i in range(1, n):
expected_delta_row = grid[i][0] - g1_1
for j in range(m):
if grid[i][j] - grid[0][j] != expected_delta_row:
possible = False
break
if not possible:
break
with open(submission_path, 'r') as f:
lines = [line.strip() for line in f.readlines()]
if not lines:
print(0)
return
first_line = lines[0]
if first_line == '-1':
print(1 if not possible else 0)
return
else:
if not possible:
print(0)
return
try:
k_sub = int(first_line)
except:
print(0)
return
if len(lines) != k_sub + 1:
print(0)
return
moves = lines[1:]
c_min_j = max(g1_1 - grid[0][j] for j in range(m))
c_min = max(c_min_j, 0)
c_max = min(row[0] for row in grid) if n > 0 else 0
if m > n:
c_opt = c_min
elif m < n:
c_opt = c_max
else:
c_opt = c_min
sum_gi1 = sum(row[0] for row in grid)
sum_g1j = sum(grid[0]) if m > 0 else 0
minimal_sum = sum_gi1 + sum_g1j - m * g1_1 + (m - n) * c_opt
if k_sub != minimal_sum:
print(0)
return
valid_moves = True
for move in moves:
parts = move.split()
if len(parts) != 2:
valid_moves = False
break
typ, num = parts
if typ not in ('row', 'col'):
valid_moves = False
break
try:
x = int(num)
if (typ == 'row' and not (1 <= x <= n)) or (typ == 'col' and not (1 <= x <= m)):
valid_moves = False
break
except:
valid_moves = False
break
if not valid_moves:
print(0)
return
sim = [[0] * m for _ in range(n)]
for move in moves:
typ, num = move.split()
x = int(num)
if typ == 'row':
for j in range(m):
sim[x-1][j] += 1
else:
for i in range(n):
sim[i][x-1] += 1
match = all(sim[i][j] == grid[i][j] for i in range(n) for j in range(m))
print(1 if match else 0)
if __name__ == '__main__':
main()
| true |
797/B
|
797
|
B
|
Python 3
|
TESTS
| 16 | 124 | 409,600 |
77743956
|
from collections import Counter,defaultdict,deque
import heapq as hq
from itertools import count, islice
#alph = 'abcdefghijklmnopqrstuvwxyz'
#from math import factorial as fact
import math
import sys
input=sys.stdin.readline
#print=sys.stdout.write
#tt = int(input())
#total=0
#n = int(input())
#n,m,k = [int(x) for x in input().split()]
#n = int(input())
#l,r = [int(x) for x in input().split()]
n = int(input())
arr = [int(x) for x in input().split()]
pos = []
neg = []
s = 0
for i in range(n):
if arr[i]>0:
pos.append(arr[i])
s+=arr[i]
else:
neg.append(arr[i])
if s%2:
print(s)
else:
pos.sort()
neg.sort(reverse=True)
lp = len(pos)
ln = len(neg)
if lp>ln:
neg.extend([0]*(lp-ln))
else:
pos.extend([0]*(ln-lp))
for i in range(max(ln,lp)):
if neg[i]%2:
if pos[i]%2:
print(s-min(pos[i],-neg[i]))
break
else:
print(s+neg[i])
break
elif pos[i]%2:
print(s-pos[i])
break
| 126 | 92 | 13,721,600 |
219660805
|
def main():
n = int(input())
a = list(map(int, input().split()))
sum_ = 0
for i in range(n):
if a[i] > 0:
sum_ += a[i]
if sum_ % 2 == 1:
return sum_
min_pos = sum_
max_neg = sum_
for i in range(n):
if a[i] > 0 and a[i] % 2 == 1:
min_pos = min(min_pos, a[i])
for i in range(n):
if a[i] % 2 == 1:
max_neg = min(max_neg, a[i])
for i in range(n):
if a[i] % 2 == 1 and a[i] < 0:
max_neg = max(max_neg, a[i])
max_neg = abs(max_neg)
if max_neg == sum_:
return sum_ - min_pos
else:
if min_pos == sum_:
return sum_ - max_neg
return max(sum_ - max_neg, sum_ - min_pos)
print(main())
|
Educational Codeforces Round 19
|
ICPC
| 2,017 | 1 | 256 |
Odd sum
|
You are given sequence a1, a2, ..., an of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements.
You should write a program which finds sum of the best subsequence.
|
The first line contains integer number n (1 ≤ n ≤ 105).
The second line contains n integer numbers a1, a2, ..., an ( - 104 ≤ ai ≤ 104). The sequence contains at least one subsequence with odd sum.
|
Print sum of resulting subseqeuence.
| null |
In the first example sum of the second and the fourth elements is 3.
|
[{"input": "4\n-2 2 -3 1", "output": "3"}, {"input": "3\n2 -5 -3", "output": "-1"}]
| 1,400 |
["dp", "greedy", "implementation"]
| 126 |
[{"input": "4\r\n-2 2 -3 1\r\n", "output": "3\r\n"}, {"input": "3\r\n2 -5 -3\r\n", "output": "-1\r\n"}, {"input": "1\r\n1\r\n", "output": "1\r\n"}, {"input": "1\r\n-1\r\n", "output": "-1\r\n"}, {"input": "15\r\n-6004 4882 9052 413 6056 4306 9946 -4616 -6135 906 -1718 5252 -2866 9061 4046\r\n", "output": "53507\r\n"}, {"input": "2\r\n-5439 -6705\r\n", "output": "-5439\r\n"}, {"input": "2\r\n2850 6843\r\n", "output": "9693\r\n"}, {"input": "2\r\n144 9001\r\n", "output": "9145\r\n"}, {"input": "10\r\n7535 -819 2389 4933 5495 4887 -5181 -9355 7955 5757\r\n", "output": "38951\r\n"}, {"input": "10\r\n-9169 -1574 3580 -8579 -7177 -3216 7490 3470 3465 -1197\r\n", "output": "18005\r\n"}, {"input": "10\r\n941 7724 2220 -4704 -8374 -8249 7606 9502 612 -9097\r\n", "output": "28605\r\n"}, {"input": "10\r\n4836 -2331 -3456 2312 -1574 3134 -670 -204 512 -5504\r\n", "output": "8463\r\n"}, {"input": "10\r\n1184 5136 1654 3254 6576 6900 6468 327 179 7114\r\n", "output": "38613\r\n"}, {"input": "10\r\n-2152 -1776 -1810 -9046 -6090 -2324 -8716 -6103 -787 -812\r\n", "output": "-787\r\n"}, {"input": "3\r\n1 1 1\r\n", "output": "3\r\n"}, {"input": "5\r\n5 5 5 3 -1\r\n", "output": "17\r\n"}, {"input": "5\r\n-1 -2 5 3 0\r\n", "output": "7\r\n"}, {"input": "5\r\n-3 -2 5 -1 3\r\n", "output": "7\r\n"}, {"input": "3\r\n-2 2 -1\r\n", "output": "1\r\n"}, {"input": "5\r\n5 0 7 -2 3\r\n", "output": "15\r\n"}, {"input": "2\r\n-2 -5\r\n", "output": "-5\r\n"}, {"input": "3\r\n-1 -3 0\r\n", "output": "-1\r\n"}, {"input": "5\r\n2 -1 0 -3 -2\r\n", "output": "1\r\n"}, {"input": "4\r\n2 3 0 5\r\n", "output": "7\r\n"}, {"input": "5\r\n-5 3 -2 2 5\r\n", "output": "7\r\n"}, {"input": "59\r\n8593 5929 3016 -859 4366 -6842 8435 -3910 -2458 -8503 -3612 -9793 -5360 -9791 -362 -7180 727 -6245 -8869 -7316 8214 -7944 7098 3788 -5436 -6626 -1131 -2410 -5647 -7981 263 -5879 8786 709 6489 5316 -4039 4909 -4340 7979 -89 9844 -906 172 -7674 -3371 -6828 9505 3284 5895 3646 6680 -1255 3635 -9547 -5104 -1435 -7222 2244\r\n", "output": "129433\r\n"}, {"input": "17\r\n-6170 2363 6202 -9142 7889 779 2843 -5089 2313 -3952 1843 5171 462 -3673 5098 -2519 9565\r\n", "output": "43749\r\n"}, {"input": "26\r\n-8668 9705 1798 -1766 9644 3688 8654 -3077 -5462 2274 6739 2732 3635 -4745 -9144 -9175 -7488 -2010 1637 1118 8987 1597 -2873 -5153 -8062 146\r\n", "output": "60757\r\n"}, {"input": "51\r\n8237 -7239 -3545 -6059 -5110 4066 -4148 -7641 -5797 -994 963 1144 -2785 -8765 -1216 5410 1508 -6312 -6313 -680 -7657 4579 -6898 7379 2015 -5087 -5417 -6092 3819 -9101 989 -8380 9161 -7519 -9314 -3838 7160 5180 567 -1606 -3842 -9665 -2266 1296 -8417 -3976 7436 -2075 -441 -4565 3313\r\n", "output": "73781\r\n"}, {"input": "1\r\n-1\r\n", "output": "-1\r\n"}, {"input": "1\r\n1\r\n", "output": "1\r\n"}, {"input": "1\r\n-1\r\n", "output": "-1\r\n"}, {"input": "1\r\n1\r\n", "output": "1\r\n"}, {"input": "1\r\n1\r\n", "output": "1\r\n"}, {"input": "1\r\n-1\r\n", "output": "-1\r\n"}, {"input": "1\r\n-1\r\n", "output": "-1\r\n"}, {"input": "1\r\n1\r\n", "output": "1\r\n"}, {"input": "2\r\n-2 1\r\n", "output": "1\r\n"}, {"input": "2\r\n3 2\r\n", "output": "5\r\n"}, {"input": "2\r\n1 2\r\n", "output": "3\r\n"}, {"input": "2\r\n-1 1\r\n", "output": "1\r\n"}, {"input": "2\r\n0 -1\r\n", "output": "-1\r\n"}, {"input": "2\r\n2 1\r\n", "output": "3\r\n"}, {"input": "2\r\n3 0\r\n", "output": "3\r\n"}, {"input": "2\r\n0 -1\r\n", "output": "-1\r\n"}, {"input": "3\r\n-3 1 -1\r\n", "output": "1\r\n"}, {"input": "3\r\n3 -1 1\r\n", "output": "3\r\n"}, {"input": "3\r\n1 3 1\r\n", "output": "5\r\n"}, {"input": "3\r\n-1 0 1\r\n", "output": "1\r\n"}, {"input": "3\r\n-3 -3 -2\r\n", "output": "-3\r\n"}, {"input": "3\r\n3 -1 1\r\n", "output": "3\r\n"}, {"input": "3\r\n3 -1 1\r\n", "output": "3\r\n"}, {"input": "3\r\n-2 -2 1\r\n", "output": "1\r\n"}, {"input": "4\r\n0 -1 -3 -4\r\n", "output": "-1\r\n"}, {"input": "4\r\n5 3 2 1\r\n", "output": "11\r\n"}, {"input": "4\r\n-1 -2 4 -2\r\n", "output": "3\r\n"}, {"input": "4\r\n-1 -3 0 -3\r\n", "output": "-1\r\n"}, {"input": "4\r\n1 -4 -3 -4\r\n", "output": "1\r\n"}, {"input": "4\r\n5 3 3 4\r\n", "output": "15\r\n"}, {"input": "4\r\n-1 -3 -1 2\r\n", "output": "1\r\n"}, {"input": "4\r\n3 2 -1 -4\r\n", "output": "5\r\n"}, {"input": "5\r\n-5 -4 -3 -5 2\r\n", "output": "-1\r\n"}, {"input": "5\r\n5 5 1 2 -2\r\n", "output": "13\r\n"}, {"input": "5\r\n-2 -1 -5 -1 4\r\n", "output": "3\r\n"}, {"input": "5\r\n-5 -5 -4 4 0\r\n", "output": "-1\r\n"}, {"input": "5\r\n2 -3 -1 -4 -5\r\n", "output": "1\r\n"}, {"input": "5\r\n4 3 4 2 3\r\n", "output": "13\r\n"}, {"input": "5\r\n0 -2 -5 3 3\r\n", "output": "3\r\n"}, {"input": "5\r\n4 -2 -2 -3 0\r\n", "output": "1\r\n"}, {"input": "6\r\n6 7 -1 1 5 -1\r\n", "output": "19\r\n"}, {"input": "6\r\n-1 7 2 -3 -4 -5\r\n", "output": "9\r\n"}, {"input": "6\r\n0 -1 -3 -5 2 -6\r\n", "output": "1\r\n"}, {"input": "6\r\n4 -1 0 3 6 1\r\n", "output": "13\r\n"}, {"input": "6\r\n5 3 3 4 4 -3\r\n", "output": "19\r\n"}, {"input": "6\r\n0 -3 5 -4 5 -4\r\n", "output": "7\r\n"}, {"input": "6\r\n-5 -3 1 -1 -5 -3\r\n", "output": "1\r\n"}, {"input": "6\r\n-2 1 3 -2 7 4\r\n", "output": "15\r\n"}, {"input": "7\r\n0 7 6 2 7 0 6\r\n", "output": "21\r\n"}, {"input": "7\r\n6 -6 -1 -5 7 1 7\r\n", "output": "21\r\n"}, {"input": "7\r\n2 3 -5 0 -4 0 -4\r\n", "output": "5\r\n"}, {"input": "7\r\n-6 3 -3 -1 -6 -6 -5\r\n", "output": "3\r\n"}, {"input": "7\r\n7 6 3 2 4 2 0\r\n", "output": "21\r\n"}, {"input": "7\r\n-2 3 -3 4 4 0 -1\r\n", "output": "11\r\n"}, {"input": "7\r\n-5 -7 4 0 5 -3 -5\r\n", "output": "9\r\n"}, {"input": "7\r\n-3 -5 -4 1 3 -4 -7\r\n", "output": "3\r\n"}, {"input": "8\r\n5 2 4 5 7 -2 7 3\r\n", "output": "33\r\n"}, {"input": "8\r\n-8 -3 -1 3 -8 -4 -4 4\r\n", "output": "7\r\n"}, {"input": "8\r\n-6 -7 -7 -5 -4 -9 -2 -7\r\n", "output": "-5\r\n"}, {"input": "8\r\n8 7 6 8 3 4 8 -2\r\n", "output": "41\r\n"}, {"input": "8\r\n6 7 0 -6 6 5 4 7\r\n", "output": "35\r\n"}, {"input": "8\r\n0 -7 -5 -5 5 -1 -8 -7\r\n", "output": "5\r\n"}, {"input": "8\r\n1 -6 -5 7 -3 -4 2 -2\r\n", "output": "9\r\n"}, {"input": "8\r\n1 -8 -6 -6 -6 -7 -5 -1\r\n", "output": "1\r\n"}, {"input": "9\r\n-3 -1 4 4 8 -8 -5 9 -2\r\n", "output": "25\r\n"}, {"input": "9\r\n-9 -1 3 -2 -7 2 -9 -1 -4\r\n", "output": "5\r\n"}, {"input": "9\r\n-6 -9 -3 -8 -5 2 -6 0 -5\r\n", "output": "-1\r\n"}, {"input": "9\r\n5 4 3 3 6 7 8 5 9\r\n", "output": "47\r\n"}, {"input": "9\r\n5 3 9 1 5 2 -3 7 0\r\n", "output": "31\r\n"}, {"input": "9\r\n-3 -9 -1 -7 5 6 -4 -6 -6\r\n", "output": "11\r\n"}, {"input": "9\r\n-6 -5 6 -5 -2 0 1 2 -9\r\n", "output": "9\r\n"}, {"input": "9\r\n8 3 6 1 -3 5 2 9 1\r\n", "output": "35\r\n"}, {"input": "10\r\n-6 -4 -7 -1 -9 -10 -10 1 0 -3\r\n", "output": "1\r\n"}, {"input": "10\r\n-2 -10 -5 -6 -10 -3 -6 -3 -8 -8\r\n", "output": "-3\r\n"}, {"input": "10\r\n8 5 9 2 3 3 -6 1 -1 8\r\n", "output": "39\r\n"}, {"input": "10\r\n2 10 -7 6 -1 -1 7 -9 -4 -6\r\n", "output": "25\r\n"}, {"input": "10\r\n-10 -2 -2 -1 -10 -7 1 0 -4 -5\r\n", "output": "1\r\n"}, {"input": "10\r\n4 3 10 -2 -1 0 10 6 7 0\r\n", "output": "39\r\n"}, {"input": "10\r\n-2 6 6 5 0 10 6 7 -1 1\r\n", "output": "41\r\n"}, {"input": "10\r\n-10 2 8 -6 -1 -5 1 -10 -10 -1\r\n", "output": "11\r\n"}]
| false |
stdio
| null | true |
797/B
|
797
|
B
|
PyPy 3
|
TESTS
| 37 | 233 | 10,752,000 |
84147165
|
n=int(input())
l=sorted([int(i) for i in input().split()])
s=0
c=-1
c1=0
c2=0
for i in range(n):
if(l[i]>=0):
s+=l[i]
else:
c=i
if(c<n-1):
if(s%2==1):
print(s)
else:
for i in range(c,-1,-1):
if(l[i]%2==1):
k=l[i]
c1=1
break
for i in range(c+1,n):
if(l[i]%2==1):
k1=l[i]
c2=1
break
if(c1==1 and c2==1):
print(max(s+k,s-k1))
elif(c1==1):
print(s+k)
else:
print(s-k1)
else:
s=0
for i in range(n-1,-1,-1):
s+=l[i]
if(s%2==1):
break
print(s)
| 126 | 93 | 6,758,400 |
160946235
|
n = int(input())
a = list(map(int, input().split()))
maximal = sum(x for x in a if x > 0)
if maximal % 2 == 1:
print(maximal)
else:
INF = 1e9
print(max(
maximal - min((x for x in a if x > 0 and x & 1), default=INF),
maximal + max((x for x in a if x < 0 and x & 1), default=-INF),
))
|
Educational Codeforces Round 19
|
ICPC
| 2,017 | 1 | 256 |
Odd sum
|
You are given sequence a1, a2, ..., an of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements.
You should write a program which finds sum of the best subsequence.
|
The first line contains integer number n (1 ≤ n ≤ 105).
The second line contains n integer numbers a1, a2, ..., an ( - 104 ≤ ai ≤ 104). The sequence contains at least one subsequence with odd sum.
|
Print sum of resulting subseqeuence.
| null |
In the first example sum of the second and the fourth elements is 3.
|
[{"input": "4\n-2 2 -3 1", "output": "3"}, {"input": "3\n2 -5 -3", "output": "-1"}]
| 1,400 |
["dp", "greedy", "implementation"]
| 126 |
[{"input": "4\r\n-2 2 -3 1\r\n", "output": "3\r\n"}, {"input": "3\r\n2 -5 -3\r\n", "output": "-1\r\n"}, {"input": "1\r\n1\r\n", "output": "1\r\n"}, {"input": "1\r\n-1\r\n", "output": "-1\r\n"}, {"input": "15\r\n-6004 4882 9052 413 6056 4306 9946 -4616 -6135 906 -1718 5252 -2866 9061 4046\r\n", "output": "53507\r\n"}, {"input": "2\r\n-5439 -6705\r\n", "output": "-5439\r\n"}, {"input": "2\r\n2850 6843\r\n", "output": "9693\r\n"}, {"input": "2\r\n144 9001\r\n", "output": "9145\r\n"}, {"input": "10\r\n7535 -819 2389 4933 5495 4887 -5181 -9355 7955 5757\r\n", "output": "38951\r\n"}, {"input": "10\r\n-9169 -1574 3580 -8579 -7177 -3216 7490 3470 3465 -1197\r\n", "output": "18005\r\n"}, {"input": "10\r\n941 7724 2220 -4704 -8374 -8249 7606 9502 612 -9097\r\n", "output": "28605\r\n"}, {"input": "10\r\n4836 -2331 -3456 2312 -1574 3134 -670 -204 512 -5504\r\n", "output": "8463\r\n"}, {"input": "10\r\n1184 5136 1654 3254 6576 6900 6468 327 179 7114\r\n", "output": "38613\r\n"}, {"input": "10\r\n-2152 -1776 -1810 -9046 -6090 -2324 -8716 -6103 -787 -812\r\n", "output": "-787\r\n"}, {"input": "3\r\n1 1 1\r\n", "output": "3\r\n"}, {"input": "5\r\n5 5 5 3 -1\r\n", "output": "17\r\n"}, {"input": "5\r\n-1 -2 5 3 0\r\n", "output": "7\r\n"}, {"input": "5\r\n-3 -2 5 -1 3\r\n", "output": "7\r\n"}, {"input": "3\r\n-2 2 -1\r\n", "output": "1\r\n"}, {"input": "5\r\n5 0 7 -2 3\r\n", "output": "15\r\n"}, {"input": "2\r\n-2 -5\r\n", "output": "-5\r\n"}, {"input": "3\r\n-1 -3 0\r\n", "output": "-1\r\n"}, {"input": "5\r\n2 -1 0 -3 -2\r\n", "output": "1\r\n"}, {"input": "4\r\n2 3 0 5\r\n", "output": "7\r\n"}, {"input": "5\r\n-5 3 -2 2 5\r\n", "output": "7\r\n"}, {"input": "59\r\n8593 5929 3016 -859 4366 -6842 8435 -3910 -2458 -8503 -3612 -9793 -5360 -9791 -362 -7180 727 -6245 -8869 -7316 8214 -7944 7098 3788 -5436 -6626 -1131 -2410 -5647 -7981 263 -5879 8786 709 6489 5316 -4039 4909 -4340 7979 -89 9844 -906 172 -7674 -3371 -6828 9505 3284 5895 3646 6680 -1255 3635 -9547 -5104 -1435 -7222 2244\r\n", "output": "129433\r\n"}, {"input": "17\r\n-6170 2363 6202 -9142 7889 779 2843 -5089 2313 -3952 1843 5171 462 -3673 5098 -2519 9565\r\n", "output": "43749\r\n"}, {"input": "26\r\n-8668 9705 1798 -1766 9644 3688 8654 -3077 -5462 2274 6739 2732 3635 -4745 -9144 -9175 -7488 -2010 1637 1118 8987 1597 -2873 -5153 -8062 146\r\n", "output": "60757\r\n"}, {"input": "51\r\n8237 -7239 -3545 -6059 -5110 4066 -4148 -7641 -5797 -994 963 1144 -2785 -8765 -1216 5410 1508 -6312 -6313 -680 -7657 4579 -6898 7379 2015 -5087 -5417 -6092 3819 -9101 989 -8380 9161 -7519 -9314 -3838 7160 5180 567 -1606 -3842 -9665 -2266 1296 -8417 -3976 7436 -2075 -441 -4565 3313\r\n", "output": "73781\r\n"}, {"input": "1\r\n-1\r\n", "output": "-1\r\n"}, {"input": "1\r\n1\r\n", "output": "1\r\n"}, {"input": "1\r\n-1\r\n", "output": "-1\r\n"}, {"input": "1\r\n1\r\n", "output": "1\r\n"}, {"input": "1\r\n1\r\n", "output": "1\r\n"}, {"input": "1\r\n-1\r\n", "output": "-1\r\n"}, {"input": "1\r\n-1\r\n", "output": "-1\r\n"}, {"input": "1\r\n1\r\n", "output": "1\r\n"}, {"input": "2\r\n-2 1\r\n", "output": "1\r\n"}, {"input": "2\r\n3 2\r\n", "output": "5\r\n"}, {"input": "2\r\n1 2\r\n", "output": "3\r\n"}, {"input": "2\r\n-1 1\r\n", "output": "1\r\n"}, {"input": "2\r\n0 -1\r\n", "output": "-1\r\n"}, {"input": "2\r\n2 1\r\n", "output": "3\r\n"}, {"input": "2\r\n3 0\r\n", "output": "3\r\n"}, {"input": "2\r\n0 -1\r\n", "output": "-1\r\n"}, {"input": "3\r\n-3 1 -1\r\n", "output": "1\r\n"}, {"input": "3\r\n3 -1 1\r\n", "output": "3\r\n"}, {"input": "3\r\n1 3 1\r\n", "output": "5\r\n"}, {"input": "3\r\n-1 0 1\r\n", "output": "1\r\n"}, {"input": "3\r\n-3 -3 -2\r\n", "output": "-3\r\n"}, {"input": "3\r\n3 -1 1\r\n", "output": "3\r\n"}, {"input": "3\r\n3 -1 1\r\n", "output": "3\r\n"}, {"input": "3\r\n-2 -2 1\r\n", "output": "1\r\n"}, {"input": "4\r\n0 -1 -3 -4\r\n", "output": "-1\r\n"}, {"input": "4\r\n5 3 2 1\r\n", "output": "11\r\n"}, {"input": "4\r\n-1 -2 4 -2\r\n", "output": "3\r\n"}, {"input": "4\r\n-1 -3 0 -3\r\n", "output": "-1\r\n"}, {"input": "4\r\n1 -4 -3 -4\r\n", "output": "1\r\n"}, {"input": "4\r\n5 3 3 4\r\n", "output": "15\r\n"}, {"input": "4\r\n-1 -3 -1 2\r\n", "output": "1\r\n"}, {"input": "4\r\n3 2 -1 -4\r\n", "output": "5\r\n"}, {"input": "5\r\n-5 -4 -3 -5 2\r\n", "output": "-1\r\n"}, {"input": "5\r\n5 5 1 2 -2\r\n", "output": "13\r\n"}, {"input": "5\r\n-2 -1 -5 -1 4\r\n", "output": "3\r\n"}, {"input": "5\r\n-5 -5 -4 4 0\r\n", "output": "-1\r\n"}, {"input": "5\r\n2 -3 -1 -4 -5\r\n", "output": "1\r\n"}, {"input": "5\r\n4 3 4 2 3\r\n", "output": "13\r\n"}, {"input": "5\r\n0 -2 -5 3 3\r\n", "output": "3\r\n"}, {"input": "5\r\n4 -2 -2 -3 0\r\n", "output": "1\r\n"}, {"input": "6\r\n6 7 -1 1 5 -1\r\n", "output": "19\r\n"}, {"input": "6\r\n-1 7 2 -3 -4 -5\r\n", "output": "9\r\n"}, {"input": "6\r\n0 -1 -3 -5 2 -6\r\n", "output": "1\r\n"}, {"input": "6\r\n4 -1 0 3 6 1\r\n", "output": "13\r\n"}, {"input": "6\r\n5 3 3 4 4 -3\r\n", "output": "19\r\n"}, {"input": "6\r\n0 -3 5 -4 5 -4\r\n", "output": "7\r\n"}, {"input": "6\r\n-5 -3 1 -1 -5 -3\r\n", "output": "1\r\n"}, {"input": "6\r\n-2 1 3 -2 7 4\r\n", "output": "15\r\n"}, {"input": "7\r\n0 7 6 2 7 0 6\r\n", "output": "21\r\n"}, {"input": "7\r\n6 -6 -1 -5 7 1 7\r\n", "output": "21\r\n"}, {"input": "7\r\n2 3 -5 0 -4 0 -4\r\n", "output": "5\r\n"}, {"input": "7\r\n-6 3 -3 -1 -6 -6 -5\r\n", "output": "3\r\n"}, {"input": "7\r\n7 6 3 2 4 2 0\r\n", "output": "21\r\n"}, {"input": "7\r\n-2 3 -3 4 4 0 -1\r\n", "output": "11\r\n"}, {"input": "7\r\n-5 -7 4 0 5 -3 -5\r\n", "output": "9\r\n"}, {"input": "7\r\n-3 -5 -4 1 3 -4 -7\r\n", "output": "3\r\n"}, {"input": "8\r\n5 2 4 5 7 -2 7 3\r\n", "output": "33\r\n"}, {"input": "8\r\n-8 -3 -1 3 -8 -4 -4 4\r\n", "output": "7\r\n"}, {"input": "8\r\n-6 -7 -7 -5 -4 -9 -2 -7\r\n", "output": "-5\r\n"}, {"input": "8\r\n8 7 6 8 3 4 8 -2\r\n", "output": "41\r\n"}, {"input": "8\r\n6 7 0 -6 6 5 4 7\r\n", "output": "35\r\n"}, {"input": "8\r\n0 -7 -5 -5 5 -1 -8 -7\r\n", "output": "5\r\n"}, {"input": "8\r\n1 -6 -5 7 -3 -4 2 -2\r\n", "output": "9\r\n"}, {"input": "8\r\n1 -8 -6 -6 -6 -7 -5 -1\r\n", "output": "1\r\n"}, {"input": "9\r\n-3 -1 4 4 8 -8 -5 9 -2\r\n", "output": "25\r\n"}, {"input": "9\r\n-9 -1 3 -2 -7 2 -9 -1 -4\r\n", "output": "5\r\n"}, {"input": "9\r\n-6 -9 -3 -8 -5 2 -6 0 -5\r\n", "output": "-1\r\n"}, {"input": "9\r\n5 4 3 3 6 7 8 5 9\r\n", "output": "47\r\n"}, {"input": "9\r\n5 3 9 1 5 2 -3 7 0\r\n", "output": "31\r\n"}, {"input": "9\r\n-3 -9 -1 -7 5 6 -4 -6 -6\r\n", "output": "11\r\n"}, {"input": "9\r\n-6 -5 6 -5 -2 0 1 2 -9\r\n", "output": "9\r\n"}, {"input": "9\r\n8 3 6 1 -3 5 2 9 1\r\n", "output": "35\r\n"}, {"input": "10\r\n-6 -4 -7 -1 -9 -10 -10 1 0 -3\r\n", "output": "1\r\n"}, {"input": "10\r\n-2 -10 -5 -6 -10 -3 -6 -3 -8 -8\r\n", "output": "-3\r\n"}, {"input": "10\r\n8 5 9 2 3 3 -6 1 -1 8\r\n", "output": "39\r\n"}, {"input": "10\r\n2 10 -7 6 -1 -1 7 -9 -4 -6\r\n", "output": "25\r\n"}, {"input": "10\r\n-10 -2 -2 -1 -10 -7 1 0 -4 -5\r\n", "output": "1\r\n"}, {"input": "10\r\n4 3 10 -2 -1 0 10 6 7 0\r\n", "output": "39\r\n"}, {"input": "10\r\n-2 6 6 5 0 10 6 7 -1 1\r\n", "output": "41\r\n"}, {"input": "10\r\n-10 2 8 -6 -1 -5 1 -10 -10 -1\r\n", "output": "11\r\n"}]
| false |
stdio
| null | true |
797/B
|
797
|
B
|
PyPy 3
|
TESTS
| 37 | 170 | 11,878,400 |
160947060
|
n = int(input())
nums = [int(x) for x in input().split()]
posi = []
nega = []
odd = []
sum = 0
for x in nums:
if x >= 0:
posi.append(x)
else:
nega.append(x)
sort = sorted(posi, reverse=True) + sorted(nega, reverse = True)
ans = []
for x in range(len(sort)):
sum += sort[x]
ans.append(sum)
if sort[x]%2 == 1:
odd.append(abs(sort[x]))
if max(ans)%2 == 1:
print(max(ans))
else:
print(max(ans) - min(odd))
| 126 | 93 | 7,270,400 |
132354899
|
def solution(n, a):
oddMin = 10**4
isOdd = False
sum = 0
for i in range(n):
if (a[i] > 0):
sum = sum+a[i]
if (a[i]%2 !=0):
isOdd = True
if (oddMin > abs(a[i])):
oddMin = abs(a[i])
if (isOdd == False):
return -1
if (sum%2==0):
sum = sum - oddMin
return sum
n = int(input())
a = list(map(int, input().split()))
print(solution(n, a))
|
Educational Codeforces Round 19
|
ICPC
| 2,017 | 1 | 256 |
Odd sum
|
You are given sequence a1, a2, ..., an of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements.
You should write a program which finds sum of the best subsequence.
|
The first line contains integer number n (1 ≤ n ≤ 105).
The second line contains n integer numbers a1, a2, ..., an ( - 104 ≤ ai ≤ 104). The sequence contains at least one subsequence with odd sum.
|
Print sum of resulting subseqeuence.
| null |
In the first example sum of the second and the fourth elements is 3.
|
[{"input": "4\n-2 2 -3 1", "output": "3"}, {"input": "3\n2 -5 -3", "output": "-1"}]
| 1,400 |
["dp", "greedy", "implementation"]
| 126 |
[{"input": "4\r\n-2 2 -3 1\r\n", "output": "3\r\n"}, {"input": "3\r\n2 -5 -3\r\n", "output": "-1\r\n"}, {"input": "1\r\n1\r\n", "output": "1\r\n"}, {"input": "1\r\n-1\r\n", "output": "-1\r\n"}, {"input": "15\r\n-6004 4882 9052 413 6056 4306 9946 -4616 -6135 906 -1718 5252 -2866 9061 4046\r\n", "output": "53507\r\n"}, {"input": "2\r\n-5439 -6705\r\n", "output": "-5439\r\n"}, {"input": "2\r\n2850 6843\r\n", "output": "9693\r\n"}, {"input": "2\r\n144 9001\r\n", "output": "9145\r\n"}, {"input": "10\r\n7535 -819 2389 4933 5495 4887 -5181 -9355 7955 5757\r\n", "output": "38951\r\n"}, {"input": "10\r\n-9169 -1574 3580 -8579 -7177 -3216 7490 3470 3465 -1197\r\n", "output": "18005\r\n"}, {"input": "10\r\n941 7724 2220 -4704 -8374 -8249 7606 9502 612 -9097\r\n", "output": "28605\r\n"}, {"input": "10\r\n4836 -2331 -3456 2312 -1574 3134 -670 -204 512 -5504\r\n", "output": "8463\r\n"}, {"input": "10\r\n1184 5136 1654 3254 6576 6900 6468 327 179 7114\r\n", "output": "38613\r\n"}, {"input": "10\r\n-2152 -1776 -1810 -9046 -6090 -2324 -8716 -6103 -787 -812\r\n", "output": "-787\r\n"}, {"input": "3\r\n1 1 1\r\n", "output": "3\r\n"}, {"input": "5\r\n5 5 5 3 -1\r\n", "output": "17\r\n"}, {"input": "5\r\n-1 -2 5 3 0\r\n", "output": "7\r\n"}, {"input": "5\r\n-3 -2 5 -1 3\r\n", "output": "7\r\n"}, {"input": "3\r\n-2 2 -1\r\n", "output": "1\r\n"}, {"input": "5\r\n5 0 7 -2 3\r\n", "output": "15\r\n"}, {"input": "2\r\n-2 -5\r\n", "output": "-5\r\n"}, {"input": "3\r\n-1 -3 0\r\n", "output": "-1\r\n"}, {"input": "5\r\n2 -1 0 -3 -2\r\n", "output": "1\r\n"}, {"input": "4\r\n2 3 0 5\r\n", "output": "7\r\n"}, {"input": "5\r\n-5 3 -2 2 5\r\n", "output": "7\r\n"}, {"input": "59\r\n8593 5929 3016 -859 4366 -6842 8435 -3910 -2458 -8503 -3612 -9793 -5360 -9791 -362 -7180 727 -6245 -8869 -7316 8214 -7944 7098 3788 -5436 -6626 -1131 -2410 -5647 -7981 263 -5879 8786 709 6489 5316 -4039 4909 -4340 7979 -89 9844 -906 172 -7674 -3371 -6828 9505 3284 5895 3646 6680 -1255 3635 -9547 -5104 -1435 -7222 2244\r\n", "output": "129433\r\n"}, {"input": "17\r\n-6170 2363 6202 -9142 7889 779 2843 -5089 2313 -3952 1843 5171 462 -3673 5098 -2519 9565\r\n", "output": "43749\r\n"}, {"input": "26\r\n-8668 9705 1798 -1766 9644 3688 8654 -3077 -5462 2274 6739 2732 3635 -4745 -9144 -9175 -7488 -2010 1637 1118 8987 1597 -2873 -5153 -8062 146\r\n", "output": "60757\r\n"}, {"input": "51\r\n8237 -7239 -3545 -6059 -5110 4066 -4148 -7641 -5797 -994 963 1144 -2785 -8765 -1216 5410 1508 -6312 -6313 -680 -7657 4579 -6898 7379 2015 -5087 -5417 -6092 3819 -9101 989 -8380 9161 -7519 -9314 -3838 7160 5180 567 -1606 -3842 -9665 -2266 1296 -8417 -3976 7436 -2075 -441 -4565 3313\r\n", "output": "73781\r\n"}, {"input": "1\r\n-1\r\n", "output": "-1\r\n"}, {"input": "1\r\n1\r\n", "output": "1\r\n"}, {"input": "1\r\n-1\r\n", "output": "-1\r\n"}, {"input": "1\r\n1\r\n", "output": "1\r\n"}, {"input": "1\r\n1\r\n", "output": "1\r\n"}, {"input": "1\r\n-1\r\n", "output": "-1\r\n"}, {"input": "1\r\n-1\r\n", "output": "-1\r\n"}, {"input": "1\r\n1\r\n", "output": "1\r\n"}, {"input": "2\r\n-2 1\r\n", "output": "1\r\n"}, {"input": "2\r\n3 2\r\n", "output": "5\r\n"}, {"input": "2\r\n1 2\r\n", "output": "3\r\n"}, {"input": "2\r\n-1 1\r\n", "output": "1\r\n"}, {"input": "2\r\n0 -1\r\n", "output": "-1\r\n"}, {"input": "2\r\n2 1\r\n", "output": "3\r\n"}, {"input": "2\r\n3 0\r\n", "output": "3\r\n"}, {"input": "2\r\n0 -1\r\n", "output": "-1\r\n"}, {"input": "3\r\n-3 1 -1\r\n", "output": "1\r\n"}, {"input": "3\r\n3 -1 1\r\n", "output": "3\r\n"}, {"input": "3\r\n1 3 1\r\n", "output": "5\r\n"}, {"input": "3\r\n-1 0 1\r\n", "output": "1\r\n"}, {"input": "3\r\n-3 -3 -2\r\n", "output": "-3\r\n"}, {"input": "3\r\n3 -1 1\r\n", "output": "3\r\n"}, {"input": "3\r\n3 -1 1\r\n", "output": "3\r\n"}, {"input": "3\r\n-2 -2 1\r\n", "output": "1\r\n"}, {"input": "4\r\n0 -1 -3 -4\r\n", "output": "-1\r\n"}, {"input": "4\r\n5 3 2 1\r\n", "output": "11\r\n"}, {"input": "4\r\n-1 -2 4 -2\r\n", "output": "3\r\n"}, {"input": "4\r\n-1 -3 0 -3\r\n", "output": "-1\r\n"}, {"input": "4\r\n1 -4 -3 -4\r\n", "output": "1\r\n"}, {"input": "4\r\n5 3 3 4\r\n", "output": "15\r\n"}, {"input": "4\r\n-1 -3 -1 2\r\n", "output": "1\r\n"}, {"input": "4\r\n3 2 -1 -4\r\n", "output": "5\r\n"}, {"input": "5\r\n-5 -4 -3 -5 2\r\n", "output": "-1\r\n"}, {"input": "5\r\n5 5 1 2 -2\r\n", "output": "13\r\n"}, {"input": "5\r\n-2 -1 -5 -1 4\r\n", "output": "3\r\n"}, {"input": "5\r\n-5 -5 -4 4 0\r\n", "output": "-1\r\n"}, {"input": "5\r\n2 -3 -1 -4 -5\r\n", "output": "1\r\n"}, {"input": "5\r\n4 3 4 2 3\r\n", "output": "13\r\n"}, {"input": "5\r\n0 -2 -5 3 3\r\n", "output": "3\r\n"}, {"input": "5\r\n4 -2 -2 -3 0\r\n", "output": "1\r\n"}, {"input": "6\r\n6 7 -1 1 5 -1\r\n", "output": "19\r\n"}, {"input": "6\r\n-1 7 2 -3 -4 -5\r\n", "output": "9\r\n"}, {"input": "6\r\n0 -1 -3 -5 2 -6\r\n", "output": "1\r\n"}, {"input": "6\r\n4 -1 0 3 6 1\r\n", "output": "13\r\n"}, {"input": "6\r\n5 3 3 4 4 -3\r\n", "output": "19\r\n"}, {"input": "6\r\n0 -3 5 -4 5 -4\r\n", "output": "7\r\n"}, {"input": "6\r\n-5 -3 1 -1 -5 -3\r\n", "output": "1\r\n"}, {"input": "6\r\n-2 1 3 -2 7 4\r\n", "output": "15\r\n"}, {"input": "7\r\n0 7 6 2 7 0 6\r\n", "output": "21\r\n"}, {"input": "7\r\n6 -6 -1 -5 7 1 7\r\n", "output": "21\r\n"}, {"input": "7\r\n2 3 -5 0 -4 0 -4\r\n", "output": "5\r\n"}, {"input": "7\r\n-6 3 -3 -1 -6 -6 -5\r\n", "output": "3\r\n"}, {"input": "7\r\n7 6 3 2 4 2 0\r\n", "output": "21\r\n"}, {"input": "7\r\n-2 3 -3 4 4 0 -1\r\n", "output": "11\r\n"}, {"input": "7\r\n-5 -7 4 0 5 -3 -5\r\n", "output": "9\r\n"}, {"input": "7\r\n-3 -5 -4 1 3 -4 -7\r\n", "output": "3\r\n"}, {"input": "8\r\n5 2 4 5 7 -2 7 3\r\n", "output": "33\r\n"}, {"input": "8\r\n-8 -3 -1 3 -8 -4 -4 4\r\n", "output": "7\r\n"}, {"input": "8\r\n-6 -7 -7 -5 -4 -9 -2 -7\r\n", "output": "-5\r\n"}, {"input": "8\r\n8 7 6 8 3 4 8 -2\r\n", "output": "41\r\n"}, {"input": "8\r\n6 7 0 -6 6 5 4 7\r\n", "output": "35\r\n"}, {"input": "8\r\n0 -7 -5 -5 5 -1 -8 -7\r\n", "output": "5\r\n"}, {"input": "8\r\n1 -6 -5 7 -3 -4 2 -2\r\n", "output": "9\r\n"}, {"input": "8\r\n1 -8 -6 -6 -6 -7 -5 -1\r\n", "output": "1\r\n"}, {"input": "9\r\n-3 -1 4 4 8 -8 -5 9 -2\r\n", "output": "25\r\n"}, {"input": "9\r\n-9 -1 3 -2 -7 2 -9 -1 -4\r\n", "output": "5\r\n"}, {"input": "9\r\n-6 -9 -3 -8 -5 2 -6 0 -5\r\n", "output": "-1\r\n"}, {"input": "9\r\n5 4 3 3 6 7 8 5 9\r\n", "output": "47\r\n"}, {"input": "9\r\n5 3 9 1 5 2 -3 7 0\r\n", "output": "31\r\n"}, {"input": "9\r\n-3 -9 -1 -7 5 6 -4 -6 -6\r\n", "output": "11\r\n"}, {"input": "9\r\n-6 -5 6 -5 -2 0 1 2 -9\r\n", "output": "9\r\n"}, {"input": "9\r\n8 3 6 1 -3 5 2 9 1\r\n", "output": "35\r\n"}, {"input": "10\r\n-6 -4 -7 -1 -9 -10 -10 1 0 -3\r\n", "output": "1\r\n"}, {"input": "10\r\n-2 -10 -5 -6 -10 -3 -6 -3 -8 -8\r\n", "output": "-3\r\n"}, {"input": "10\r\n8 5 9 2 3 3 -6 1 -1 8\r\n", "output": "39\r\n"}, {"input": "10\r\n2 10 -7 6 -1 -1 7 -9 -4 -6\r\n", "output": "25\r\n"}, {"input": "10\r\n-10 -2 -2 -1 -10 -7 1 0 -4 -5\r\n", "output": "1\r\n"}, {"input": "10\r\n4 3 10 -2 -1 0 10 6 7 0\r\n", "output": "39\r\n"}, {"input": "10\r\n-2 6 6 5 0 10 6 7 -1 1\r\n", "output": "41\r\n"}, {"input": "10\r\n-10 2 8 -6 -1 -5 1 -10 -10 -1\r\n", "output": "11\r\n"}]
| false |
stdio
| null | true |
815/A
|
815
|
A
|
PyPy 3
|
TESTS
| 11 | 171 | 4,812,800 |
58700504
|
a,b=map(int,input().split())
m=[]
for i in range(a):
m.append(list(map(int,input().split())))
r=[]
if a <= b:
for i in range(a):
mn=min(m[i])
for j in range(b):
m[i][j]-=mn
for j in range(mn):
r.append('row ' + str(i+1))
for i in range(b):
mn=502
for j in range(a):
if m[j][i] < mn:
mn=m[j][i]
for j in range(a):
m[j][i]-=mn
for j in range(mn):
r.append('col ' + str(i+1))
else:
for i in range(b):
mn=502
for j in range(a):
if m[j][i] < mn:
mn=m[j][i]
for j in range(a):
m[j][i]-=mn
for j in range(mn):
r.append('col ' + str(i+1))
for i in range(a):
mn=min(m[i])
for j in range(b):
m[i][j]-=mn
for j in range(mn):
r.append('row ' + str(i+1))
if len(r) > 0:
print(len(r))
print(*r,sep='\n')
else:
t=True
for i in m:
for j in i:
if j != 0:
t=False
break
if not t:
break
if not t:
print(-1)
else:
print(0)
| 177 | 124 | 1,843,200 |
48908067
|
n,m=map(int,input().split())
L=[list(map(int,input().split())) for i in range(n)]
s="row"
s1="col"
if n>m :
L1=[[0 for i in range(n)] for j in range(m)]
for i in range(n) :
for j in range(m) :
L1[j][i]=L[i][j]
L=L1
n,m=m,n
s,s1=s1,s
w=[0 for i in range(n)]
w1=[0 for i in range(m)]
for i in range(n) :
w[i]=min(L[i])
for i in range(m) :
for j in range(n) :
ma=0
ma=max(L[j][i]-w[j],ma)
w1[i]=ma
for i in range(n) :
for j in range(m) :
if L[i][j]-w[i]-w1[j]!=0 :
print(-1)
exit()
otv=[]
for i in range(n) :
otv+=[s+" "+str(i+1)]*w[i]
for i in range(m) :
otv+=[s1+" "+str(i+1)]*w1[i]
print(len(otv))
print('\n'.join(otv))
|
Codeforces Round 419 (Div. 1)
|
CF
| 2,017 | 2 | 512 |
Karen and Game
|
On the way to school, Karen became fixated on the puzzle game on her phone!
The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0.
One move consists of choosing one row or column, and adding 1 to all of the cells in that row or column.
To win the level, after all the moves, the number in the cell at the i-th row and j-th column should be equal to gi, j.
Karen is stuck on one level, and wants to know a way to beat this level using the minimum number of moves. Please, help her with this task!
|
The first line of input contains two integers, n and m (1 ≤ n, m ≤ 100), the number of rows and the number of columns in the grid, respectively.
The next n lines each contain m integers. In particular, the j-th integer in the i-th of these rows contains gi, j (0 ≤ gi, j ≤ 500).
|
If there is an error and it is actually not possible to beat the level, output a single integer -1.
Otherwise, on the first line, output a single integer k, the minimum number of moves necessary to beat the level.
The next k lines should each contain one of the following, describing the moves in the order they must be done:
- row x, (1 ≤ x ≤ n) describing a move of the form "choose the x-th row".
- col x, (1 ≤ x ≤ m) describing a move of the form "choose the x-th column".
If there are multiple optimal solutions, output any one of them.
| null |
In the first test case, Karen has a grid with 3 rows and 5 columns. She can perform the following 4 moves to beat the level:
In the second test case, Karen has a grid with 3 rows and 3 columns. It is clear that it is impossible to beat the level; performing any move will create three 1s on the grid, but it is required to only have one 1 in the center.
In the third test case, Karen has a grid with 3 rows and 3 columns. She can perform the following 3 moves to beat the level:
Note that this is not the only solution; another solution, among others, is col 1, col 2, col 3.
|
[{"input": "3 5\n2 2 2 3 2\n0 0 0 1 0\n1 1 1 2 1", "output": "4\nrow 1\nrow 1\ncol 4\nrow 3"}, {"input": "3 3\n0 0 0\n0 1 0\n0 0 0", "output": "-1"}, {"input": "3 3\n1 1 1\n1 1 1\n1 1 1", "output": "3\nrow 1\nrow 2\nrow 3"}]
| 1,700 |
["brute force", "greedy", "implementation"]
| 177 |
[{"input": "3 5\r\n2 2 2 3 2\r\n0 0 0 1 0\r\n1 1 1 2 1\r\n", "output": "4\r\nrow 1\r\nrow 1\r\ncol 4\r\nrow 3\r\n"}, {"input": "3 3\r\n0 0 0\r\n0 1 0\r\n0 0 0\r\n", "output": "-1\r\n"}, {"input": "3 3\r\n1 1 1\r\n1 1 1\r\n1 1 1\r\n", "output": "3\r\nrow 1\r\nrow 2\r\nrow 3\r\n"}, {"input": "3 5\r\n2 4 2 2 3\r\n0 2 0 0 1\r\n1 3 1 1 2\r\n", "output": "6\r\nrow 1\r\nrow 1\r\ncol 2\r\ncol 2\r\ncol 5\r\nrow 3\r\n"}, {"input": "3 5\r\n0 0 0 0 0\r\n0 0 0 0 0\r\n0 0 0 0 1\r\n", "output": "-1\r\n"}, {"input": "9 10\r\n14 5 6 4 8 9 4 14 14 13\r\n13 4 5 3 7 8 3 13 13 12\r\n16 7 8 6 10 11 6 16 16 15\r\n10 1 2 0 4 5 0 10 10 9\r\n11 2 3 1 5 6 1 11 11 10\r\n10 1 2 0 4 5 0 10 10 9\r\n12 3 4 2 6 7 2 12 12 11\r\n13 4 5 3 7 8 3 13 13 12\r\n13 4 5 3 7 8 3 13 13 12\r\n", "output": "73\nrow 1\nrow 1\nrow 1\nrow 1\nrow 2\nrow 2\nrow 2\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 5\nrow 7\nrow 7\nrow 8\nrow 8\nrow 8\nrow 9\nrow 9\nrow 9\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 2\ncol 3\ncol 3\ncol 5\ncol 5\ncol 5\ncol 5\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\n"}, {"input": "10 10\r\n30 30 30 33 30 33 30 33 30 33\r\n431 431 431 434 431 434 431 434 431 434\r\n19 19 19 22 19 22 19 22 19 22\r\n24 24 24 27 24 27 24 27 24 27\r\n5 5 5 8 5 8 5 8 5 8\r\n0 0 0 3 0 3 0 3 0 3\r\n0 0 0 3 0 3 0 3 0 3\r\n0 0 0 3 0 3 0 3 0 3\r\n0 0 0 3 0 3 0 3 0 3\r\n0 0 0 3 0 3 0 3 0 3\r\n", "output": "521\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\ncol 4\ncol 4\ncol 4\ncol 6\ncol 6\ncol 6\ncol 8\ncol 8\ncol 8\ncol 10\ncol 10\ncol 10\n"}, {"input": "1 1\r\n0\r\n", "output": "0\r\n"}, {"input": "1 1\r\n500\r\n", "output": "500\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\n"}, {"input": "10 10\r\n1 1 1 1 1 1 1 1 1 1\r\n1 1 1 1 1 1 1 1 1 1\r\n1 1 1 1 1 1 1 1 1 1\r\n1 1 1 1 1 1 1 1 1 1\r\n0 0 0 0 0 0 0 0 0 0\r\n1 1 1 1 1 1 1 1 1 1\r\n1 1 1 1 1 1 1 1 1 1\r\n1 1 1 1 1 1 1 1 1 1\r\n1 1 1 1 1 1 1 1 1 1\r\n1 1 1 1 1 1 1 1 1 1\r\n", "output": "9\r\nrow 1\r\nrow 2\r\nrow 3\r\nrow 4\r\nrow 6\r\nrow 7\r\nrow 8\r\nrow 9\r\nrow 10\r\n"}, {"input": "10 10\r\n1 1 1 1 1 1 0 1 1 1\r\n1 1 1 1 1 1 0 1 1 1\r\n1 1 1 1 1 1 0 1 1 1\r\n1 1 1 1 1 1 0 1 1 1\r\n1 1 1 1 1 1 0 1 1 1\r\n1 1 1 1 1 1 0 1 1 1\r\n1 1 1 1 1 1 0 1 1 1\r\n1 1 1 1 1 1 0 1 1 1\r\n1 1 1 1 1 1 0 1 1 1\r\n1 1 1 1 1 1 0 1 1 1\r\n", "output": "9\r\ncol 1\r\ncol 2\r\ncol 3\r\ncol 4\r\ncol 5\r\ncol 6\r\ncol 8\r\ncol 9\r\ncol 10\r\n"}, {"input": "10 11\r\n8 7 10 15 5 13 12 9 14 11 6\r\n6 5 8 13 3 11 10 7 12 9 4\r\n10 9 12 17 7 15 14 11 16 13 8\r\n9 8 11 16 6 14 13 10 15 12 7\r\n12 11 14 19 9 17 16 13 18 15 10\r\n14 13 16 21 11 19 18 15 20 17 12\r\n7 6 9 14 4 12 11 8 13 10 5\r\n5 4 7 12 2 10 9 6 11 8 3\r\n11 10 13 18 8 16 15 12 17 14 9\r\n13 12 15 20 10 18 17 14 19 16 11\r\n", "output": "120\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 2\nrow 2\nrow 2\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 7\nrow 7\nrow 7\nrow 7\nrow 8\nrow 8\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\ncol 1\ncol 1\ncol 1\ncol 2\ncol 2\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 8\ncol 8\ncol 8\ncol 8\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 11\n"}, {"input": "5 3\r\n2 2 2\r\n2 2 2\r\n2 2 2\r\n1 1 1\r\n2 2 2\r\n", "output": "7\r\ncol 1\r\ncol 2\r\ncol 3\r\nrow 1\r\nrow 2\r\nrow 3\r\nrow 5\r\n"}, {"input": "3 5\r\n2 2 2 1 2\r\n2 2 2 1 2\r\n2 2 2 1 2\r\n", "output": "7\r\nrow 1\r\nrow 2\r\nrow 3\r\ncol 1\r\ncol 2\r\ncol 3\r\ncol 5\r\n"}, {"input": "1 100\r\n396 314 350 362 287 349 266 289 297 305 235 226 256 385 302 304 253 192 298 238 360 366 163 340 247 395 318 260 252 281 178 188 252 379 212 187 354 232 225 159 290 335 387 234 383 215 356 182 323 280 195 209 263 215 322 262 334 157 189 214 195 386 220 209 177 193 368 174 270 329 388 237 260 343 230 173 254 371 327 266 193 178 161 209 335 310 323 323 353 172 368 307 329 234 363 264 334 266 305 209\r\n", "output": "11960\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 5\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 12\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 13\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 14\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 15\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 16\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 17\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 18\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 19\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 20\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 21\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 22\ncol 23\ncol 23\ncol 23\ncol 23\ncol 23\ncol 23\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 24\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 25\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 26\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 27\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 28\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 29\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 30\ncol 31\ncol 31\ncol 31\ncol 31\ncol 31\ncol 31\ncol 31\ncol 31\ncol 31\ncol 31\ncol 31\ncol 31\ncol 31\ncol 31\ncol 31\ncol 31\ncol 31\ncol 31\ncol 31\ncol 31\ncol 31\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 32\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 33\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 34\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 35\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 36\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 37\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 38\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 39\ncol 40\ncol 40\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 41\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 42\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 43\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 44\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 45\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 46\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 47\ncol 48\ncol 48\ncol 48\ncol 48\ncol 48\ncol 48\ncol 48\ncol 48\ncol 48\ncol 48\ncol 48\ncol 48\ncol 48\ncol 48\ncol 48\ncol 48\ncol 48\ncol 48\ncol 48\ncol 48\ncol 48\ncol 48\ncol 48\ncol 48\ncol 48\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 49\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 50\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 51\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 52\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 53\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 54\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 55\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 56\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 57\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 59\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 60\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 61\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 62\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 63\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 64\ncol 65\ncol 65\ncol 65\ncol 65\ncol 65\ncol 65\ncol 65\ncol 65\ncol 65\ncol 65\ncol 65\ncol 65\ncol 65\ncol 65\ncol 65\ncol 65\ncol 65\ncol 65\ncol 65\ncol 65\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 66\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 67\ncol 68\ncol 68\ncol 68\ncol 68\ncol 68\ncol 68\ncol 68\ncol 68\ncol 68\ncol 68\ncol 68\ncol 68\ncol 68\ncol 68\ncol 68\ncol 68\ncol 68\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 69\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 70\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 71\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 72\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 73\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 74\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 75\ncol 76\ncol 76\ncol 76\ncol 76\ncol 76\ncol 76\ncol 76\ncol 76\ncol 76\ncol 76\ncol 76\ncol 76\ncol 76\ncol 76\ncol 76\ncol 76\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 77\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 78\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 79\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 80\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 81\ncol 82\ncol 82\ncol 82\ncol 82\ncol 82\ncol 82\ncol 82\ncol 82\ncol 82\ncol 82\ncol 82\ncol 82\ncol 82\ncol 82\ncol 82\ncol 82\ncol 82\ncol 82\ncol 82\ncol 82\ncol 82\ncol 83\ncol 83\ncol 83\ncol 83\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 84\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 85\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 86\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 87\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 88\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 89\ncol 90\ncol 90\ncol 90\ncol 90\ncol 90\ncol 90\ncol 90\ncol 90\ncol 90\ncol 90\ncol 90\ncol 90\ncol 90\ncol 90\ncol 90\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 91\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 92\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 93\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 94\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 95\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 96\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 97\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 98\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 99\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\ncol 100\n"}, {"input": "100 1\r\n173\r\n164\r\n99\r\n114\r\n255\r\n223\r\n280\r\n235\r\n207\r\n190\r\n136\r\n204\r\n206\r\n282\r\n253\r\n335\r\n267\r\n184\r\n288\r\n299\r\n263\r\n243\r\n341\r\n111\r\n278\r\n111\r\n214\r\n133\r\n125\r\n245\r\n99\r\n144\r\n232\r\n203\r\n131\r\n204\r\n117\r\n315\r\n269\r\n206\r\n262\r\n125\r\n212\r\n95\r\n220\r\n243\r\n141\r\n163\r\n311\r\n171\r\n222\r\n266\r\n141\r\n314\r\n329\r\n138\r\n187\r\n342\r\n272\r\n181\r\n300\r\n261\r\n339\r\n110\r\n194\r\n187\r\n183\r\n129\r\n151\r\n187\r\n129\r\n185\r\n322\r\n167\r\n99\r\n340\r\n285\r\n99\r\n176\r\n175\r\n272\r\n126\r\n220\r\n164\r\n237\r\n214\r\n96\r\n162\r\n129\r\n141\r\n144\r\n135\r\n172\r\n191\r\n155\r\n333\r\n186\r\n324\r\n237\r\n318\r\n", "output": "11282\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 3\nrow 3\nrow 3\nrow 3\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 11\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 12\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 13\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 14\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 15\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 16\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 17\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 18\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 19\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 20\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 21\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 22\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 23\nrow 24\nrow 24\nrow 24\nrow 24\nrow 24\nrow 24\nrow 24\nrow 24\nrow 24\nrow 24\nrow 24\nrow 24\nrow 24\nrow 24\nrow 24\nrow 24\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 25\nrow 26\nrow 26\nrow 26\nrow 26\nrow 26\nrow 26\nrow 26\nrow 26\nrow 26\nrow 26\nrow 26\nrow 26\nrow 26\nrow 26\nrow 26\nrow 26\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 27\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 28\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 29\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 30\nrow 31\nrow 31\nrow 31\nrow 31\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 32\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 33\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 34\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 35\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 36\nrow 37\nrow 37\nrow 37\nrow 37\nrow 37\nrow 37\nrow 37\nrow 37\nrow 37\nrow 37\nrow 37\nrow 37\nrow 37\nrow 37\nrow 37\nrow 37\nrow 37\nrow 37\nrow 37\nrow 37\nrow 37\nrow 37\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 38\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 39\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 40\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 41\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 42\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 43\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 45\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 46\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 47\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 48\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 49\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 50\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 51\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 52\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 53\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 54\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 55\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 56\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 57\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 58\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 59\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 60\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 61\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 62\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 63\nrow 64\nrow 64\nrow 64\nrow 64\nrow 64\nrow 64\nrow 64\nrow 64\nrow 64\nrow 64\nrow 64\nrow 64\nrow 64\nrow 64\nrow 64\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 65\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 66\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 67\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 68\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 69\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 70\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 71\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 72\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 73\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 74\nrow 75\nrow 75\nrow 75\nrow 75\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 76\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 77\nrow 78\nrow 78\nrow 78\nrow 78\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 79\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 80\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 81\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 82\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 83\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 84\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 85\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 86\nrow 87\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 88\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 89\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 90\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 91\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 92\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 93\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 94\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 95\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 96\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 97\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 98\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 99\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\nrow 100\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\n"}, {"input": "1 100\r\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\r\n", "output": "0\r\n"}, {"input": "100 1\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n0\r\n", "output": "0\r\n"}, {"input": "1 100\r\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\r\n", "output": "1\r\nrow 1\r\n"}, {"input": "100 1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n", "output": "1\r\ncol 1\r\n"}, {"input": "1 100\r\n500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500\r\n", "output": "500\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\n"}, {"input": "100 1\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n500\r\n", "output": "500\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\n"}, {"input": "2 1\r\n1\r\n1\r\n", "output": "1\r\ncol 1\r\n"}, {"input": "4 3\r\n1 1 1\r\n1 1 1\r\n1 1 1\r\n1 1 1\r\n", "output": "3\r\ncol 1\r\ncol 2\r\ncol 3\r\n"}, {"input": "2 1\r\n2\r\n2\r\n", "output": "2\r\ncol 1\r\ncol 1\r\n"}, {"input": "3 2\r\n1 1\r\n1 1\r\n1 1\r\n", "output": "2\r\ncol 1\r\ncol 2\r\n"}, {"input": "2 1\r\n1\r\n2\r\n", "output": "2\r\ncol 1\r\nrow 2\r\n"}, {"input": "2 3\r\n1 1 1\r\n1 1 1\r\n", "output": "2\r\nrow 1\r\nrow 2\r\n"}, {"input": "1 2\r\n1 1\r\n", "output": "1\r\nrow 1\r\n"}, {"input": "5 1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n", "output": "1\r\ncol 1\r\n"}, {"input": "10 3\r\n101 201 301\r\n102 202 302\r\n103 203 303\r\n104 204 304\r\n105 205 305\r\n106 206 306\r\n107 207 307\r\n108 208 308\r\n109 209 309\r\n111 211 311\r\n", "output": "649\nrow 2\nrow 3\nrow 3\nrow 4\nrow 4\nrow 4\nrow 5\nrow 5\nrow 5\nrow 5\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\n"}, {"input": "2 1\r\n10\r\n10\r\n", "output": "10\r\ncol 1\r\ncol 1\r\ncol 1\r\ncol 1\r\ncol 1\r\ncol 1\r\ncol 1\r\ncol 1\r\ncol 1\r\ncol 1\r\n"}, {"input": "4 3\r\n2 2 2\r\n2 2 2\r\n2 2 2\r\n2 2 2\r\n", "output": "6\r\ncol 1\r\ncol 2\r\ncol 3\r\ncol 1\r\ncol 2\r\ncol 3\r\n"}, {"input": "3 1\r\n1\r\n1\r\n1\r\n", "output": "1\r\ncol 1\r\n"}, {"input": "8 2\r\n2 2\r\n2 2\r\n2 2\r\n2 2\r\n2 2\r\n2 2\r\n2 2\r\n2 2\r\n", "output": "4\r\ncol 1\r\ncol 2\r\ncol 1\r\ncol 2\r\n"}, {"input": "1 2\r\n2 2\r\n", "output": "2\r\nrow 1\r\nrow 1\r\n"}, {"input": "3 2\r\n2 3\r\n2 3\r\n2 3\r\n", "output": "5\r\ncol 1\r\ncol 2\r\ncol 1\r\ncol 2\r\ncol 2\r\n"}, {"input": "2 1\r\n3\r\n3\r\n", "output": "3\r\ncol 1\r\ncol 1\r\ncol 1\r\n"}, {"input": "6 2\r\n1 1\r\n1 1\r\n1 1\r\n1 1\r\n1 1\r\n1 1\r\n", "output": "2\r\ncol 1\r\ncol 2\r\n"}, {"input": "4 1\r\n1\r\n1\r\n1\r\n1\r\n", "output": "1\r\ncol 1\r\n"}, {"input": "2 5\r\n1 1 1 1 1\r\n1 1 1 1 1\r\n", "output": "2\r\nrow 1\r\nrow 2\r\n"}, {"input": "3 1\r\n500\r\n500\r\n500\r\n", "output": "500\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\n"}, {"input": "5 2\r\n1 1\r\n2 2\r\n2 2\r\n2 2\r\n2 2\r\n", "output": "6\r\ncol 1\r\ncol 2\r\nrow 2\r\nrow 3\r\nrow 4\r\nrow 5\r\n"}, {"input": "4 3\r\n3 3 3\r\n3 3 3\r\n3 3 3\r\n3 3 3\r\n", "output": "9\r\ncol 1\r\ncol 2\r\ncol 3\r\ncol 1\r\ncol 2\r\ncol 3\r\ncol 1\r\ncol 2\r\ncol 3\r\n"}, {"input": "5 2\r\n1 1\r\n1 1\r\n1 1\r\n1 1\r\n1 1\r\n", "output": "2\r\ncol 1\r\ncol 2\r\n"}, {"input": "1 4\r\n1 1 1 1\r\n", "output": "1\r\nrow 1\r\n"}, {"input": "3 1\r\n2\r\n3\r\n2\r\n", "output": "3\r\ncol 1\r\ncol 1\r\nrow 2\r\n"}, {"input": "1 5\r\n1 1 1 1 1\r\n", "output": "1\r\nrow 1\r\n"}, {"input": "2 4\r\n3 1 1 1\r\n3 1 1 1\r\n", "output": "4\r\nrow 1\r\nrow 2\r\ncol 1\r\ncol 1\r\n"}, {"input": "3 3\r\n1 1 1\r\n0 1 0\r\n0 0 0\r\n", "output": "-1\r\n"}, {"input": "3 2\r\n2 2\r\n1 1\r\n2 2\r\n", "output": "4\r\ncol 1\r\ncol 2\r\nrow 1\r\nrow 3\r\n"}, {"input": "2 1\r\n9\r\n9\r\n", "output": "9\r\ncol 1\r\ncol 1\r\ncol 1\r\ncol 1\r\ncol 1\r\ncol 1\r\ncol 1\r\ncol 1\r\ncol 1\r\n"}, {"input": "1 7\r\n3 3 3 3 3 3 3\r\n", "output": "3\r\nrow 1\r\nrow 1\r\nrow 1\r\n"}, {"input": "5 2\r\n3 3\r\n3 3\r\n3 3\r\n3 3\r\n3 3\r\n", "output": "6\r\ncol 1\r\ncol 2\r\ncol 1\r\ncol 2\r\ncol 1\r\ncol 2\r\n"}, {"input": "10 11\r\n250 198 192 182 85 239 295 91 318 216 249\r\n290 238 232 222 125 279 335 131 358 256 289\r\n409 357 351 341 244 398 454 250 477 375 408\r\n362 310 304 294 197 351 407 203 430 328 361\r\n352 300 294 284 187 341 397 193 420 318 351\r\n409 357 351 341 244 398 454 250 477 375 408\r\n209 157 151 141 44 198 254 50 277 175 208\r\n313 261 255 245 148 302 358 154 381 279 312\r\n171 119 113 103 6 160 216 12 239 137 170\r\n275 223 217 207 110 264 320 116 343 241 274\r\n", "output": "2770\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 3\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 4\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 5\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 6\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 7\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 8\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 9\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\nrow 10\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 1\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 3\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 4\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 6\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 7\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 8\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 9\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 10\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\ncol 11\n"}, {"input": "7 1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n", "output": "1\r\ncol 1\r\n"}, {"input": "5 3\r\n1 1 1\r\n1 1 1\r\n1 1 1\r\n1 1 1\r\n1 1 1\r\n", "output": "3\r\ncol 1\r\ncol 2\r\ncol 3\r\n"}, {"input": "5 3\r\n3 3 3\r\n3 3 3\r\n3 3 3\r\n3 3 3\r\n3 3 3\r\n", "output": "9\r\ncol 1\r\ncol 2\r\ncol 3\r\ncol 1\r\ncol 2\r\ncol 3\r\ncol 1\r\ncol 2\r\ncol 3\r\n"}, {"input": "2 1\r\n4\r\n5\r\n", "output": "5\r\ncol 1\r\ncol 1\r\ncol 1\r\ncol 1\r\nrow 2\r\n"}, {"input": "4 2\r\n3 3\r\n3 3\r\n3 3\r\n3 3\r\n", "output": "6\r\ncol 1\r\ncol 2\r\ncol 1\r\ncol 2\r\ncol 1\r\ncol 2\r\n"}, {"input": "6 3\r\n2 2 2\r\n1 1 1\r\n1 1 1\r\n1 1 1\r\n1 1 1\r\n1 1 1\r\n", "output": "4\r\ncol 1\r\ncol 2\r\ncol 3\r\nrow 1\r\n"}, {"input": "5 1\r\n1\r\n2\r\n3\r\n4\r\n5\r\n", "output": "11\r\ncol 1\r\nrow 2\r\nrow 3\r\nrow 3\r\nrow 4\r\nrow 4\r\nrow 4\r\nrow 5\r\nrow 5\r\nrow 5\r\nrow 5\r\n"}, {"input": "2 1\r\n1\r\n3\r\n", "output": "3\r\ncol 1\r\nrow 2\r\nrow 2\r\n"}, {"input": "3 2\r\n1 500\r\n1 500\r\n1 500\r\n", "output": "501\ncol 1\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\ncol 2\n"}, {"input": "10 1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n1\r\n", "output": "1\r\ncol 1\r\n"}, {"input": "6 2\r\n2 2\r\n2 2\r\n2 2\r\n2 2\r\n2 2\r\n2 2\r\n", "output": "4\r\ncol 1\r\ncol 2\r\ncol 1\r\ncol 2\r\n"}, {"input": "3 5\r\n1 1 1 1 1\r\n1 1 1 1 1\r\n1 1 1 1 1\r\n", "output": "3\r\nrow 1\r\nrow 2\r\nrow 3\r\n"}, {"input": "2 3\r\n2 1 2\r\n2 1 2\r\n", "output": "4\r\nrow 1\r\nrow 2\r\ncol 1\r\ncol 3\r\n"}, {"input": "5 2\r\n2 2\r\n2 2\r\n2 2\r\n2 2\r\n2 2\r\n", "output": "4\r\ncol 1\r\ncol 2\r\ncol 1\r\ncol 2\r\n"}, {"input": "1 2\r\n1 3\r\n", "output": "3\r\nrow 1\r\ncol 2\r\ncol 2\r\n"}, {"input": "4 3\r\n2 2 2\r\n1 1 1\r\n1 1 1\r\n1 1 1\r\n", "output": "4\r\ncol 1\r\ncol 2\r\ncol 3\r\nrow 1\r\n"}, {"input": "3 2\r\n1 1\r\n2 2\r\n3 3\r\n", "output": "5\r\ncol 1\r\ncol 2\r\nrow 2\r\nrow 3\r\nrow 3\r\n"}, {"input": "4 2\r\n1 1\r\n1 1\r\n1 1\r\n1 1\r\n", "output": "2\r\ncol 1\r\ncol 2\r\n"}, {"input": "3 4\r\n1 1 1 1\r\n1 1 1 1\r\n1 1 1 1\r\n", "output": "3\r\nrow 1\r\nrow 2\r\nrow 3\r\n"}, {"input": "2 1\r\n2\r\n3\r\n", "output": "3\r\ncol 1\r\ncol 1\r\nrow 2\r\n"}, {"input": "5 3\r\n2 2 2\r\n2 2 2\r\n2 2 2\r\n2 2 2\r\n2 2 2\r\n", "output": "6\r\ncol 1\r\ncol 2\r\ncol 3\r\ncol 1\r\ncol 2\r\ncol 3\r\n"}, {"input": "3 2\r\n1 0\r\n2 1\r\n2 1\r\n", "output": "3\r\ncol 1\r\nrow 2\r\nrow 3\r\n"}, {"input": "3 2\r\n1 2\r\n2 3\r\n3 4\r\n", "output": "6\r\ncol 1\r\ncol 2\r\ncol 2\r\nrow 2\r\nrow 3\r\nrow 3\r\n"}, {"input": "3 3\r\n1 1 1\r\n1 2 1\r\n1 1 1\r\n", "output": "-1\r\n"}, {"input": "4 3\r\n2 1 1\r\n2 1 1\r\n2 1 1\r\n2 1 1\r\n", "output": "4\r\ncol 1\r\ncol 2\r\ncol 3\r\ncol 1\r\n"}, {"input": "4 1\r\n3\r\n3\r\n3\r\n3\r\n", "output": "3\r\ncol 1\r\ncol 1\r\ncol 1\r\n"}, {"input": "1 3\r\n2 3 2\r\n", "output": "3\r\nrow 1\r\nrow 1\r\ncol 2\r\n"}, {"input": "1 2\r\n1 2\r\n", "output": "2\r\nrow 1\r\ncol 2\r\n"}, {"input": "3 2\r\n2 2\r\n2 2\r\n2 2\r\n", "output": "4\r\ncol 1\r\ncol 2\r\ncol 1\r\ncol 2\r\n"}, {"input": "1 3\r\n1 1 1\r\n", "output": "1\r\nrow 1\r\n"}, {"input": "6 3\r\n1 1 1\r\n1 1 1\r\n1 1 1\r\n1 1 1\r\n1 1 1\r\n1 1 1\r\n", "output": "3\r\ncol 1\r\ncol 2\r\ncol 3\r\n"}, {"input": "3 1\r\n2\r\n2\r\n2\r\n", "output": "2\r\ncol 1\r\ncol 1\r\n"}, {"input": "3 1\r\n3\r\n3\r\n3\r\n", "output": "3\r\ncol 1\r\ncol 1\r\ncol 1\r\n"}, {"input": "3 2\r\n2 2\r\n1 1\r\n1 1\r\n", "output": "3\r\ncol 1\r\ncol 2\r\nrow 1\r\n"}, {"input": "5 3\r\n1 1 2\r\n1 1 2\r\n1 1 2\r\n1 1 2\r\n1 1 2\r\n", "output": "4\r\ncol 1\r\ncol 2\r\ncol 3\r\ncol 3\r\n"}, {"input": "1 2\r\n2 3\r\n", "output": "3\r\nrow 1\r\nrow 1\r\ncol 2\r\n"}, {"input": "5 1\r\n2\r\n2\r\n2\r\n2\r\n2\r\n", "output": "2\r\ncol 1\r\ncol 1\r\n"}, {"input": "3 2\r\n1 1\r\n2 2\r\n2 2\r\n", "output": "4\r\ncol 1\r\ncol 2\r\nrow 2\r\nrow 3\r\n"}, {"input": "3 3\r\n1 1 1\r\n2 3 3\r\n4 4 4\r\n", "output": "-1\r\n"}, {"input": "2 1\r\n5\r\n2\r\n", "output": "5\r\ncol 1\r\ncol 1\r\nrow 1\r\nrow 1\r\nrow 1\r\n"}, {"input": "4 2\r\n2 2\r\n2 2\r\n2 2\r\n2 2\r\n", "output": "4\r\ncol 1\r\ncol 2\r\ncol 1\r\ncol 2\r\n"}, {"input": "3 2\r\n5 10\r\n5 10\r\n5 10\r\n", "output": "15\r\ncol 1\r\ncol 2\r\ncol 1\r\ncol 2\r\ncol 1\r\ncol 2\r\ncol 1\r\ncol 2\r\ncol 1\r\ncol 2\r\ncol 2\r\ncol 2\r\ncol 2\r\ncol 2\r\ncol 2\r\n"}, {"input": "4 3\r\n3 4 3\r\n5 6 5\r\n3 4 3\r\n3 4 3\r\n", "output": "12\r\ncol 1\r\ncol 2\r\ncol 3\r\ncol 1\r\ncol 2\r\ncol 3\r\ncol 1\r\ncol 2\r\ncol 3\r\ncol 2\r\nrow 2\r\nrow 2\r\n"}, {"input": "4 2\r\n1 1\r\n1 1\r\n1 1\r\n2 2\r\n", "output": "3\r\ncol 1\r\ncol 2\r\nrow 4\r\n"}, {"input": "2 3\r\n1 1 1\r\n500 500 500\r\n", "output": "501\nrow 1\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\nrow 2\n"}, {"input": "4 1\r\n4\r\n4\r\n4\r\n4\r\n", "output": "4\r\ncol 1\r\ncol 1\r\ncol 1\r\ncol 1\r\n"}, {"input": "3 2\r\n1 1\r\n1 1\r\n2 2\r\n", "output": "3\r\ncol 1\r\ncol 2\r\nrow 3\r\n"}, {"input": "2 3\r\n2 2 2\r\n2 2 2\r\n", "output": "4\r\nrow 1\r\nrow 2\r\nrow 1\r\nrow 2\r\n"}, {"input": "3 2\r\n3 3\r\n3 3\r\n3 3\r\n", "output": "6\r\ncol 1\r\ncol 2\r\ncol 1\r\ncol 2\r\ncol 1\r\ncol 2\r\n"}, {"input": "2 3\r\n10 10 10\r\n5 5 5\r\n", "output": "15\r\nrow 1\r\nrow 2\r\nrow 1\r\nrow 2\r\nrow 1\r\nrow 2\r\nrow 1\r\nrow 2\r\nrow 1\r\nrow 2\r\nrow 1\r\nrow 1\r\nrow 1\r\nrow 1\r\nrow 1\r\n"}, {"input": "5 2\r\n1 2\r\n1 2\r\n1 2\r\n1 2\r\n1 2\r\n", "output": "3\r\ncol 1\r\ncol 2\r\ncol 2\r\n"}, {"input": "1 2\r\n500 500\r\n", "output": "500\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\nrow 1\n"}, {"input": "2 1\r\n5\r\n5\r\n", "output": "5\r\ncol 1\r\ncol 1\r\ncol 1\r\ncol 1\r\ncol 1\r\n"}]
| false |
stdio
|
import sys
def main():
input_path = sys.argv[1]
output_path = sys.argv[2]
submission_path = sys.argv[3]
with open(input_path, 'r') as f:
n, m = map(int, f.readline().split())
grid = [list(map(int, f.readline().split())) for _ in range(n)]
possible = True
g1_1 = grid[0][0] if n > 0 and m > 0 else 0
for j in range(1, m):
expected_delta = grid[0][j] - g1_1
for i in range(n):
if grid[i][j] - grid[i][0] != expected_delta:
possible = False
break
if not possible:
break
if possible:
for i in range(1, n):
expected_delta_row = grid[i][0] - g1_1
for j in range(m):
if grid[i][j] - grid[0][j] != expected_delta_row:
possible = False
break
if not possible:
break
with open(submission_path, 'r') as f:
lines = [line.strip() for line in f.readlines()]
if not lines:
print(0)
return
first_line = lines[0]
if first_line == '-1':
print(1 if not possible else 0)
return
else:
if not possible:
print(0)
return
try:
k_sub = int(first_line)
except:
print(0)
return
if len(lines) != k_sub + 1:
print(0)
return
moves = lines[1:]
c_min_j = max(g1_1 - grid[0][j] for j in range(m))
c_min = max(c_min_j, 0)
c_max = min(row[0] for row in grid) if n > 0 else 0
if m > n:
c_opt = c_min
elif m < n:
c_opt = c_max
else:
c_opt = c_min
sum_gi1 = sum(row[0] for row in grid)
sum_g1j = sum(grid[0]) if m > 0 else 0
minimal_sum = sum_gi1 + sum_g1j - m * g1_1 + (m - n) * c_opt
if k_sub != minimal_sum:
print(0)
return
valid_moves = True
for move in moves:
parts = move.split()
if len(parts) != 2:
valid_moves = False
break
typ, num = parts
if typ not in ('row', 'col'):
valid_moves = False
break
try:
x = int(num)
if (typ == 'row' and not (1 <= x <= n)) or (typ == 'col' and not (1 <= x <= m)):
valid_moves = False
break
except:
valid_moves = False
break
if not valid_moves:
print(0)
return
sim = [[0] * m for _ in range(n)]
for move in moves:
typ, num = move.split()
x = int(num)
if typ == 'row':
for j in range(m):
sim[x-1][j] += 1
else:
for i in range(n):
sim[i][x-1] += 1
match = all(sim[i][j] == grid[i][j] for i in range(n) for j in range(m))
print(1 if match else 0)
if __name__ == '__main__':
main()
| true |
370/D
|
370
|
D
|
Python 3
|
TESTS
| 40 | 390 | 52,019,200 |
5414654
|
#!/usr/bin/python3
def readln(): return list(map(int, input().split()))
import sys
def exit():
print(-1)
sys.exit()
n, m = readln()
mon = [list(input()) for _ in range(n)]
hor = [i for i in range(n) if mon[i] != ['.'] * m]
rmon = list(zip(*mon))
ver = [j for j in range(m) if rmon[j] != ('.',) * n]
mini = hor[0]
maxi = hor[-1]
minj = ver[0]
maxj = ver[-1]
cnt_in = len([1 for i in range(mini + 1, maxi) for j in range(minj + 1, maxj) if mon[i][j] == 'w'])
cnt_l = len([1 for i in range(mini + 1, maxi) if mon[i][minj] == 'w'])
cnt_r = len([1 for i in range(mini + 1, maxi) if mon[i][maxj] == 'w'])
cnt_d = len([1 for j in range(minj + 1, maxj) if mon[mini][j] == 'w'])
cnt_u = len([1 for j in range(minj + 1, maxj) if mon[maxi][j] == 'w'])
if cnt_in:
exit()
if maxi - mini < maxj - minj:
k = maxj - minj + 1
if maxi == mini and cnt_d:
if mini >= k - 1:
mini -= k - 1
elif maxi + k - 1 < n:
maxi += k - 1
else:
exit()
else:
if not cnt_d:
mini = max(0, mini - k + 1)
if maxi - maxi + 1 != k and not cnt_u:
maxi = min(mini + k - 1, n - 1)
if maxi - mini + 1 != k:
exit()
else:
k = maxi - mini + 1
if maxj == minj and cnt_l:
if minj >= k - 1:
minj -= k - 1
elif maxj + k - 1 < m:
maxj += k - 1
else:
exit()
else:
if not cnt_l:
minj = max(0, maxj - k + 1)
if maxj - minj + 1 != k and not cnt_r:
maxj = min(minj + k - 1, m - 1)
if maxj - minj + 1 != k:
exit()
for i in range(mini, maxi + 1):
if mon[i][minj] == '.':
mon[i][minj] = '+'
for i in range(mini, maxi + 1):
if mon[i][maxj] == '.':
mon[i][maxj] = '+'
for j in range(minj, maxj + 1):
if mon[mini][j] == '.':
mon[mini][j] = '+'
for j in range(minj, maxj + 1):
if mon[maxi][j] == '.':
mon[maxi][j] = '+'
print('\n'.join([''.join(row) for row in mon]))
| 125 | 1,465 | 35,123,200 |
139630574
|
from itertools import chain
def draw_square(ans, square_a, ymin, xmin) -> list:
for i in range(square_a + 1):
if(ans[ymin][xmin + i] != 'w'):
ans[ymin] = ans[ymin][:xmin + i] + '+' + ans[ymin][xmin + i + 1:]
if(ans[ymin + square_a][xmin + i] != 'w'):
ans[ymin + square_a] = ans[ymin + square_a][:xmin + i] + '+' + ans[ymin + square_a][xmin + i + 1:]
if(ans[ymin + i][xmin] != 'w'):
ans[ymin + i] = ans[ymin + i][:xmin] + '+' + ans[ymin + i][xmin + 1:]
if(ans[ymin + i][xmin + square_a] != 'w'):
ans[ymin + i] = ans[ymin + i][:xmin + square_a] + '+' + ans[ymin + i][xmin + square_a + 1:]
return ans
def find_a(pixel, y, x) -> tuple:
ymax = xmax = 0
ymin, xmin = y, x
ymaxl, yminl, xmaxl, xminl = [], [], [], []
count_pixel = len(pixel) // 2
for i in range(count_pixel):
if(ymax < pixel[2 * i]):
ymax = pixel[2 * i]
if(ymin > pixel[2 * i]):
ymin = pixel[2 * i]
if(xmax < pixel[2 * i + 1]):
xmax = pixel[2 * i + 1]
if(xmin > pixel[2 * i + 1]):
xmin = pixel[2 * i + 1]
for i in range(count_pixel):
f = True
if(pixel[2 * i] == ymax):
f = False
ymaxl.append(pixel[2 * i])
ymaxl.append(pixel[2 * i + 1])
if(pixel[2 * i] == ymin):
f = False
yminl.append(pixel[2 * i])
yminl.append(pixel[2 * i + 1])
if(pixel[2 * i + 1] == xmax):
f = False
xmaxl.append(pixel[2 * i])
xmaxl.append(pixel[2 * i + 1])
if(pixel[2 * i + 1] == xmin):
f = False
xminl.append(pixel[2 * i])
xminl.append(pixel[2 * i + 1])
if(f):
print('-1')
exit()
return ymax, ymin, xmax, xmin, ymaxl, yminl, xmaxl, xminl
if __name__ == '__main__':
y, x = map(int, input().split())
scr = []
for i in range(y):
scr.append(input())
pixel = []
for i in range(y):
for j in range(x):
if(scr[i][j] == 'w'):
pixel.append(i)
pixel.append(j)
ymax, ymin, xmax, xmin, ymaxl, yminl, xmaxl, xminl = find_a(pixel, y, x)
count_ymax, count_ymin, count_xmax, count_xmin = len(ymaxl)/2, len(yminl)/2, len(xmaxl)/2, len(xminl)/2
countx_ymax = ymaxl[1::2].count(xmax) + ymaxl[1::2].count(xmin)
countx_ymin = yminl[1::2].count(xmax) + yminl[1::2].count(xmin)
county_xmax = xmaxl[::2].count(ymax) + xmaxl[::2].count(ymin)
county_xmin = xminl[::2].count(ymax) + xminl[::2].count(ymin)
if(ymax - ymin > xmax - xmin):
square_a = ymax - ymin
if(county_xmax < count_xmax and county_xmin < count_xmin):
if(xmax == xmin):
if(xmin + square_a < x):
xmax = xmin + square_a
elif(xmax - square_a >= 0):
xmin = xmax - square_a
else:
print('-1')
exit()
else:
print('-1')
exit()
elif(county_xmax < count_xmax and county_xmin == count_xmin):
xmin = xmax - square_a
if(xmin < 0):
print('-1')
exit()
elif(county_xmax == count_xmax and county_xmin < count_xmin):
xmax = xmin + square_a
if(xmax >= x):
print('-1')
exit()
elif(county_xmax == count_xmax and county_xmin == count_xmin):
if(square_a < x):
if(xmin + square_a < x):
xmax = xmin + square_a
elif(xmax - square_a >= 0):
xmin = xmax - square_a
else:
xmin = 0
xmax = xmin + square_a
else:
print('-1')
exit()
elif(ymax - ymin < xmax - xmin):
square_a = xmax - xmin
if(countx_ymax < count_ymax and countx_ymin < count_ymin):
if(ymax == ymin):
if(ymin + square_a < y):
ymax = ymin + square_a
elif(ymax - square_a >= 0):
ymin = ymax - square_a
else:
print('-1')
exit()
else:
print('-1')
exit()
elif(countx_ymax < count_ymax and countx_ymin == count_ymin):
ymin = ymax - square_a
if(ymin < 0):
print('-1')
exit()
elif(countx_ymax == count_ymax and countx_ymin < count_ymin):
ymax = ymin + square_a
if(ymax >= y):
print('-1')
exit()
elif(countx_ymax == count_ymax and countx_ymin == count_ymin):
if(square_a < y):
if(ymin + square_a < y):
ymax = ymin + square_a
elif(ymax - square_a >= 0):
ymin = ymax -square_a
else:
ymin = 0
ymax = ymin + square_a
else:
print('-1')
exit()
elif(ymax - ymin == xmax - xmin):
square_a = xmax - xmin
ans = draw_square(scr, square_a, ymin, xmin)
for i in range(y):
print(ans[i])
|
Codeforces Round 217 (Div. 2)
|
CF
| 2,013 | 2 | 256 |
Broken Monitor
|
Innocentius has a problem — his computer monitor has broken. Now some of the pixels are "dead", that is, they are always black. As consequence, Innocentius can't play the usual computer games. He is recently playing the following game with his younger brother Polycarpus.
Innocentius is touch-typing a program that paints a white square one-pixel wide frame on the black screen. As the monitor is broken, some pixels that should be white remain black. Polycarpus should look at what the program displayed on the screen and guess the position and size of the frame Innocentius has painted. Polycarpus doesn't like the game but Innocentius persuaded brother to play as "the game is good for the imagination and attention".
Help Polycarpus, automatize his part in the gaming process. Write the code that finds such possible square frame that:
- the frame's width is 1 pixel,
- the frame doesn't go beyond the borders of the screen,
- all white pixels of the monitor are located on the frame,
- of all frames that satisfy the previous three conditions, the required frame must have the smallest size.
Formally, a square frame is represented by such pixels of the solid square, that are on the square's border, that is, are not fully surrounded by the other pixels of the square. For example, if the frame's size is d = 3, then it consists of 8 pixels, if its size is d = 2, then it contains 4 pixels and if d = 1, then the frame is reduced to a single pixel.
|
The first line contains the resolution of the monitor as a pair of integers n, m (1 ≤ n, m ≤ 2000). The next n lines contain exactly m characters each — the state of the monitor pixels at the moment of the game. Character "." (period, ASCII code 46) corresponds to the black pixel, and character "w" (lowercase English letter w) corresponds to the white pixel. It is guaranteed that at least one pixel of the monitor is white.
|
Print the monitor screen. Represent the sought frame by characters "+" (the "plus" character). The pixels that has become white during the game mustn't be changed. Print them as "w". If there are multiple possible ways to position the frame of the minimum size, print any of them.
If the required frame doesn't exist, then print a single line containing number -1.
| null |
In the first sample the required size of the optimal frame equals 4. In the second sample the size of the optimal frame equals 3. In the third sample, the size of the optimal frame is 1. In the fourth sample, the required frame doesn't exist.
|
[{"input": "4 8\n..w..w..\n........\n........\n..w..w..", "output": "..w++w..\n..+..+..\n..+..+..\n..w++w.."}, {"input": "5 6\n......\n.w....\n......\n..w...\n......", "output": "......\n+w+...\n+.+...\n++w...\n......"}, {"input": "2 4\n....\n.w..", "output": "....\n.w.."}, {"input": "2 6\nw..w.w\n...w..", "output": "-1"}]
| 2,100 |
["brute force", "constructive algorithms", "greedy", "implementation"]
| 125 |
[{"input": "4 8\r\n..w..w..\r\n........\r\n........\r\n..w..w..\r\n", "output": "..w++w..\r\n..+..+..\r\n..+..+..\r\n..w++w..\r\n"}, {"input": "5 6\r\n......\r\n.w....\r\n......\r\n..w...\r\n......\r\n", "output": "......\r\n+w+...\r\n+.+...\r\n++w...\r\n......\r\n"}, {"input": "2 4\r\n....\r\n.w..\r\n", "output": "....\r\n.w..\r\n"}, {"input": "2 6\r\nw..w.w\r\n...w..\r\n", "output": "-1\r\n"}, {"input": "9 4\r\n....\r\n....\r\n....\r\n....\r\n....\r\n..w.\r\n....\r\n....\r\n.w..\r\n", "output": "....\r\n....\r\n....\r\n....\r\n....\r\n++w+\r\n+..+\r\n+..+\r\n+w++\r\n"}, {"input": "10 4\r\n....\r\n.w..\r\n....\r\n....\r\n.w..\r\n....\r\n....\r\n....\r\n....\r\n....\r\n", "output": "....\r\n+w++\r\n+..+\r\n+..+\r\n+w++\r\n....\r\n....\r\n....\r\n....\r\n....\r\n"}, {"input": "4 10\r\n..........\r\n..........\r\n.w..w.....\r\n..........\r\n", "output": ".++++.....\r\n.+..+.....\r\n.w..w.....\r\n.++++.....\r\n"}, {"input": "3 3\r\n...\r\nw.w\r\n...\r\n", "output": "+++\r\nw.w\r\n+++\r\n"}, {"input": "1 1\r\nw\r\n", "output": "w\r\n"}, {"input": "2 1\r\nw\r\n.\r\n", "output": "w\r\n.\r\n"}, {"input": "2 1\r\nw\r\nw\r\n", "output": "-1\r\n"}, {"input": "1 2\r\nww\r\n", "output": "-1\r\n"}, {"input": "2 2\r\nww\r\n..\r\n", "output": "ww\r\n++\r\n"}, {"input": "2 2\r\n.w\r\n.w\r\n", "output": "+w\r\n+w\r\n"}, {"input": "2 2\r\n..\r\nww\r\n", "output": "++\r\nww\r\n"}, {"input": "2 2\r\nw.\r\nw.\r\n", "output": "w+\r\nw+\r\n"}, {"input": "2 2\r\nw.\r\n.w\r\n", "output": "w+\r\n+w\r\n"}, {"input": "2 2\r\n..\r\nw.\r\n", "output": "..\r\nw.\r\n"}, {"input": "3 3\r\n...\r\n..w\r\nw..\r\n", "output": "+++\r\n+.w\r\nw++\r\n"}, {"input": "3 3\r\n.w.\r\n..w\r\n...\r\n", "output": ".w+\r\n.+w\r\n...\r\n"}, {"input": "4 4\r\nw...\r\n..w.\r\n....\r\n....\r\n", "output": "w++.\r\n+.w.\r\n+++.\r\n....\r\n"}, {"input": "4 6\r\n....w.\r\n......\r\n.w....\r\n......\r\n", "output": ".+++w.\r\n.+..+.\r\n.w..+.\r\n.++++.\r\n"}, {"input": "4 6\r\n....w.\r\n......\r\n......\r\n.w....\r\n", "output": ".+++w.\r\n.+..+.\r\n.+..+.\r\n.w+++.\r\n"}, {"input": "4 6\r\nw...w.\r\n......\r\n......\r\n.w....\r\n", "output": "-1\r\n"}, {"input": "4 6\r\nw.....\r\n......\r\n......\r\n.w....\r\n", "output": "w+++..\r\n+..+..\r\n+..+..\r\n+w++..\r\n"}, {"input": "4 6\r\nw....w\r\n......\r\n.....w\r\n.w....\r\n", "output": "-1\r\n"}, {"input": "7 3\r\n...\r\n...\r\n...\r\n..w\r\n...\r\nw..\r\n...\r\n", "output": "...\r\n...\r\n...\r\n++w\r\n+.+\r\nw++\r\n...\r\n"}, {"input": "7 3\r\n...\r\n...\r\n...\r\n.w.\r\n..w\r\nw..\r\n...\r\n", "output": "...\r\n...\r\n...\r\n+w+\r\n+.w\r\nw++\r\n...\r\n"}, {"input": "7 3\r\n...\r\n...\r\n...\r\n.w.\r\nw.w\r\nw..\r\n...\r\n", "output": "...\r\n...\r\n...\r\n+w+\r\nw.w\r\nw++\r\n...\r\n"}, {"input": "5 7\r\n.......\r\n.......\r\n.......\r\n.www...\r\n.......\r\n", "output": ".......\r\n.+++...\r\n.+.+...\r\n.www...\r\n.......\r\n"}, {"input": "5 7\r\n.......\r\n.wwww..\r\n.......\r\n.......\r\n.......\r\n", "output": ".......\r\n.wwww..\r\n.+..+..\r\n.+..+..\r\n.++++..\r\n"}, {"input": "5 7\r\n.......\r\n.w.....\r\n.w.....\r\n.w.....\r\n.w.....\r\n", "output": ".......\r\n.w+++..\r\n.w..+..\r\n.w..+..\r\n.w+++..\r\n"}, {"input": "1 7\r\nw.....w\r\n", "output": "-1\r\n"}, {"input": "6 9\r\n.w.......\r\n.........\r\n.........\r\n.........\r\n.w.......\r\n......w..\r\n", "output": ".w+++++..\r\n.+....+..\r\n.+....+..\r\n.+....+..\r\n.w....+..\r\n.+++++w..\r\n"}, {"input": "6 9\r\n...ww....\r\n.........\r\n.........\r\n.........\r\n.........\r\n......w..\r\n", "output": "...ww++++\r\n...+....+\r\n...+....+\r\n...+....+\r\n...+....+\r\n...+++w++\r\n"}, {"input": "6 9\r\n.......w.\r\n.........\r\n.........\r\n.........\r\n.........\r\n......w..\r\n", "output": "..+++++w.\r\n..+....+.\r\n..+....+.\r\n..+....+.\r\n..+....+.\r\n..++++w+.\r\n"}, {"input": "8 10\r\n..........\r\n...w......\r\n.....w....\r\n.w........\r\n....w.....\r\n..........\r\n..........\r\n..........\r\n", "output": "-1\r\n"}, {"input": "8 10\r\n..........\r\n...w......\r\n.....w....\r\n.w........\r\n..........\r\n....w.....\r\n..........\r\n..........\r\n", "output": "..........\r\n.++w++....\r\n.+...w....\r\n.w...+....\r\n.+...+....\r\n.+++w+....\r\n..........\r\n..........\r\n"}, {"input": "8 10\r\n..........\r\n...w......\r\n..........\r\n.w........\r\n..........\r\n....w.....\r\n..........\r\n..........\r\n", "output": "..........\r\n.++w++....\r\n.+...+....\r\n.w...+....\r\n.+...+....\r\n.+++w+....\r\n..........\r\n..........\r\n"}, {"input": "8 10\r\n..........\r\n..........\r\n.....w....\r\n.w........\r\n..........\r\n....w.....\r\n..........\r\n..........\r\n", "output": "..........\r\n.+++++....\r\n.+...w....\r\n.w...+....\r\n.+...+....\r\n.+++w+....\r\n..........\r\n..........\r\n"}, {"input": "8 10\r\n..........\r\n...w......\r\n..........\r\n..........\r\n..........\r\n....w.....\r\n..........\r\n..........\r\n", "output": "..........\r\n+++w+.....\r\n+...+.....\r\n+...+.....\r\n+...+.....\r\n++++w.....\r\n..........\r\n..........\r\n"}, {"input": "5 4\r\n....\r\n....\r\n....\r\nw...\r\n....\r\n", "output": "....\r\n....\r\n....\r\nw...\r\n....\r\n"}, {"input": "5 4\r\n....\r\nw...\r\n...w\r\n.w..\r\n..w.\r\n", "output": "-1\r\n"}, {"input": "5 4\r\nw..w\r\n...w\r\nw...\r\n..w.\r\n....\r\n", "output": "w++w\r\n+..w\r\nw..+\r\n++w+\r\n....\r\n"}, {"input": "5 4\r\nwwww\r\nwwww\r\nwwww\r\nwwww\r\nwwww\r\n", "output": "-1\r\n"}, {"input": "5 4\r\n..w.\r\n..ww\r\n.www\r\n.w..\r\nwwww\r\n", "output": "-1\r\n"}, {"input": "5 4\r\n....\r\n.w..\r\n....\r\n.w..\r\n....\r\n", "output": "....\r\n+w+.\r\n+.+.\r\n+w+.\r\n....\r\n"}, {"input": "5 4\r\nw...\r\n....\r\n...w\r\n....\r\n....\r\n", "output": "w+++\r\n+..+\r\n+..w\r\n++++\r\n....\r\n"}, {"input": "5 4\r\nwwww\r\nw..w\r\nwwww\r\n.www\r\n..ww\r\n", "output": "-1\r\n"}, {"input": "5 4\r\n..w.\r\n....\r\n...w\r\n..w.\r\nw...\r\n", "output": "-1\r\n"}, {"input": "6 5\r\n.w...\r\n.....\r\n.....\r\n.....\r\nw....\r\n.....\r\n", "output": "+w+++\r\n+...+\r\n+...+\r\n+...+\r\nw++++\r\n.....\r\n"}, {"input": "8 16\r\n................\r\n................\r\n................\r\n................\r\n............w...\r\n................\r\n................\r\n..............w.\r\n", "output": "................\r\n................\r\n................\r\n................\r\n............w+++\r\n............+..+\r\n............+..+\r\n............++w+\r\n"}, {"input": "3 10\r\n.......w..\r\n........w.\r\n......w...\r\n", "output": "......+w+.\r\n......+.w.\r\n......w++.\r\n"}, {"input": "10 3\r\n...\r\n...\r\n...\r\n...\r\n...\r\n...\r\n.w.\r\n..w\r\nw..\r\n...\r\n", "output": "...\r\n...\r\n...\r\n...\r\n...\r\n...\r\n+w+\r\n+.w\r\nw++\r\n...\r\n"}, {"input": "1 2\r\n.w\r\n", "output": ".w\r\n"}, {"input": "2 2\r\n.w\r\n..\r\n", "output": ".w\r\n..\r\n"}, {"input": "5 2\r\n..\r\n.w\r\nww\r\n..\r\n..\r\n", "output": "..\r\n+w\r\nww\r\n..\r\n..\r\n"}, {"input": "1 6\r\n..w...\r\n", "output": "..w...\r\n"}, {"input": "4 4\r\n..w.\r\n....\r\n....\r\n....\r\n", "output": "..w.\r\n....\r\n....\r\n....\r\n"}, {"input": "6 2\r\nw.\r\n..\r\n..\r\n..\r\n..\r\n..\r\n", "output": "w.\r\n..\r\n..\r\n..\r\n..\r\n..\r\n"}, {"input": "3 2\r\n..\r\n.w\r\n..\r\n", "output": "..\r\n.w\r\n..\r\n"}, {"input": "5 6\r\n......\r\n......\r\n.ww...\r\n......\r\n......\r\n", "output": "......\r\n......\r\n.ww...\r\n.++...\r\n......\r\n"}, {"input": "1 4\r\nw...\r\n", "output": "w...\r\n"}, {"input": "4 2\r\nw.\r\n..\r\n..\r\n..\r\n", "output": "w.\r\n..\r\n..\r\n..\r\n"}, {"input": "6 3\r\n...\r\n...\r\nw.w\r\n...\r\nwww\r\n...\r\n", "output": "...\r\n...\r\nw+w\r\n+.+\r\nwww\r\n...\r\n"}, {"input": "2 1\r\n.\r\nw\r\n", "output": ".\r\nw\r\n"}, {"input": "5 5\r\n.....\r\n.....\r\n.....\r\n.w...\r\n.....\r\n", "output": ".....\r\n.....\r\n.....\r\n.w...\r\n.....\r\n"}, {"input": "1 5\r\nw....\r\n", "output": "w....\r\n"}, {"input": "4 3\r\nw..\r\n...\r\n...\r\n...\r\n", "output": "w..\r\n...\r\n...\r\n...\r\n"}, {"input": "6 1\r\n.\r\n.\r\nw\r\n.\r\n.\r\n.\r\n", "output": ".\r\n.\r\nw\r\n.\r\n.\r\n.\r\n"}, {"input": "2 5\r\n.....\r\nww...\r\n", "output": "++...\r\nww...\r\n"}, {"input": "5 5\r\n.....\r\n.....\r\n..ww.\r\n.....\r\n.....\r\n", "output": ".....\r\n.....\r\n..ww.\r\n..++.\r\n.....\r\n"}, {"input": "1 3\r\n..w\r\n", "output": "..w\r\n"}, {"input": "4 1\r\n.\r\nw\r\n.\r\n.\r\n", "output": ".\r\nw\r\n.\r\n.\r\n"}, {"input": "6 2\r\n..\r\n.w\r\n..\r\n..\r\n..\r\n..\r\n", "output": "..\r\n.w\r\n..\r\n..\r\n..\r\n..\r\n"}, {"input": "2 1\r\nw\r\n.\r\n", "output": "w\r\n.\r\n"}, {"input": "5 1\r\n.\r\n.\r\n.\r\nw\r\n.\r\n", "output": ".\r\n.\r\n.\r\nw\r\n.\r\n"}, {"input": "1 5\r\n....w\r\n", "output": "....w\r\n"}, {"input": "4 3\r\n..w\r\nw.w\r\n...\r\n...\r\n", "output": "++w\r\nw.w\r\n+++\r\n...\r\n"}, {"input": "6 1\r\nw\r\n.\r\n.\r\n.\r\n.\r\n.\r\n", "output": "w\r\n.\r\n.\r\n.\r\n.\r\n.\r\n"}, {"input": "2 1\r\nw\r\n.\r\n", "output": "w\r\n.\r\n"}, {"input": "5 5\r\n.....\r\n...w.\r\n.....\r\n.....\r\n.w...\r\n", "output": ".....\r\n+++w.\r\n+..+.\r\n+..+.\r\n+w++.\r\n"}, {"input": "1 3\r\n.w.\r\n", "output": ".w.\r\n"}, {"input": "4 1\r\n.\r\n.\r\n.\r\nw\r\n", "output": ".\r\n.\r\n.\r\nw\r\n"}, {"input": "4 2\r\n..\r\nw.\r\n.w\r\n..\r\n", "output": "..\r\nw+\r\n+w\r\n..\r\n"}, {"input": "6 6\r\n......\r\nw.....\r\n...w..\r\n.w....\r\n......\r\n......\r\n", "output": "++++..\r\nw..+..\r\n+..w..\r\n+w++..\r\n......\r\n......\r\n"}, {"input": "3 6\r\n......\r\n....w.\r\n......\r\n", "output": "......\r\n....w.\r\n......\r\n"}, {"input": "5 4\r\nw.w.\r\nw...\r\nwww.\r\n....\r\n....\r\n", "output": "w+w.\r\nw.+.\r\nwww.\r\n....\r\n....\r\n"}, {"input": "2 2\r\n..\r\nw.\r\n", "output": "..\r\nw.\r\n"}, {"input": "4 2\r\n..\r\n..\r\nw.\r\n..\r\n", "output": "..\r\n..\r\nw.\r\n..\r\n"}, {"input": "1 6\r\n.....w\r\n", "output": ".....w\r\n"}, {"input": "3 4\r\nw...\r\n..w.\r\n.ww.\r\n", "output": "w++.\r\n+.w.\r\n+ww.\r\n"}, {"input": "5 2\r\n..\r\n..\r\n..\r\n..\r\nw.\r\n", "output": "..\r\n..\r\n..\r\n..\r\nw.\r\n"}, {"input": "2 2\r\n..\r\nw.\r\n", "output": "..\r\nw.\r\n"}, {"input": "2 1\r\nw\r\n.\r\n", "output": "w\r\n.\r\n"}, {"input": "4 1\r\n.\r\n.\r\nw\r\n.\r\n", "output": ".\r\n.\r\nw\r\n.\r\n"}, {"input": "1 5\r\nw....\r\n", "output": "w....\r\n"}, {"input": "3 3\r\n...\r\n...\r\n.w.\r\n", "output": "...\r\n...\r\n.w.\r\n"}, {"input": "6 1\r\n.\r\nw\r\n.\r\n.\r\n.\r\n.\r\n", "output": ".\r\nw\r\n.\r\n.\r\n.\r\n.\r\n"}, {"input": "2 1\r\n.\r\nw\r\n", "output": ".\r\nw\r\n"}, {"input": "5 5\r\n.w...\r\n.....\r\n.....\r\n.....\r\n.....\r\n", "output": ".w...\r\n.....\r\n.....\r\n.....\r\n.....\r\n"}, {"input": "1 3\r\n..w\r\n", "output": "..w\r\n"}, {"input": "3 1\r\n.\r\n.\r\nw\r\n", "output": ".\r\n.\r\nw\r\n"}, {"input": "6 1\r\n.\r\n.\r\n.\r\n.\r\n.\r\nw\r\n", "output": ".\r\n.\r\n.\r\n.\r\n.\r\nw\r\n"}, {"input": "6 3\r\n...\r\n...\r\n...\r\n...\r\n...\r\n.w.\r\n", "output": "...\r\n...\r\n...\r\n...\r\n...\r\n.w.\r\n"}]
| false |
stdio
|
import sys
def read_grid(file_path, n):
with open(file_path) as f:
return [list(line.strip()) for line in f.readlines()[:n]]
def main(input_path, output_path, submission_path):
with open(input_path) as f:
n, m = map(int, f.readline().split())
input_grid = [list(line.strip()) for line in f.readlines()]
with open(submission_path) as f:
submission = f.read().splitlines()
if submission == ['-1']:
w_positions = [(i, j) for i in range(n) for j in range(m) if input_grid[i][j] == 'w']
min_x = min(i for i, j in w_positions) if w_positions else 0
max_x = max(i for i, j in w_positions) if w_positions else 0
min_y = min(j for i, j in w_positions) if w_positions else 0
max_y = max(j for i, j in w_positions) if w_positions else 0
d_candidate = max(max_x - min_x, max_y - min_y) + 1
possible = any(check_frame_exists(input_grid, n, m, d) for d in range(1, d_candidate + 1))
print(100 if not possible else 0)
return
else:
if len(submission) != n or any(len(line) != m for line in submission):
print(0)
return
submission_grid = [list(line) for line in submission]
for i in range(n):
for j in range(m):
if input_grid[i][j] == 'w' and submission_grid[i][j] != 'w':
print(0)
return
if submission_grid[i][j] == '+' and input_grid[i][j] != '.':
print(0)
return
frame_positions = [(i, j) for i in range(n) for j in range(m) if submission_grid[i][j] in ('+', 'w')]
if not frame_positions:
print(0)
return
min_x = min(i for i, j in frame_positions)
max_x = max(i for i, j in frame_positions)
min_y = min(j for i, j in frame_positions)
max_y = max(j for i, j in frame_positions)
d = max_x - min_x + 1
if d != max_y - min_y + 1 or max_x >= n or max_y >= m:
print(0)
return
for i, j in frame_positions:
if not ((i == min_x or i == max_x) and (min_y <= j <= max_y) or
(j == min_y or j == max_y) and (min_x <= i <= max_x)):
print(0)
return
for i in range(n):
for j in range(m):
if input_grid[i][j] == 'w' and (i, j) not in frame_positions:
print(0)
return
w_positions = set((i, j) for i in range(n) for j in range(m) if input_grid[i][j] == 'w')
for d_candidate in range(1, d):
if check_frame_exists(input_grid, n, m, d_candidate):
print(0)
return
print(100)
def check_frame_exists(grid, n, m, d):
if d == 1:
return len([(i, j) for i in range(n) for j in range(m) if grid[i][j] == 'w']) == 1
for x in range(n - d + 1):
for y in range(m - d + 1):
valid = True
perimeter = set()
for i in range(x, x + d):
for j in (y, y + d - 1):
perimeter.add((i, j))
for j in range(y, y + d):
for i in (x, x + d - 1):
perimeter.add((i, j))
for i in range(n):
for j in range(m):
if grid[i][j] == 'w' and (i, j) not in perimeter:
valid = False
if (i, j) not in perimeter and grid[i][j] == 'w':
valid = False
if valid:
return True
return False
if __name__ == '__main__':
main(sys.argv[1], sys.argv[2], sys.argv[3])
| true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.