message
stringlengths
2
65.1k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
0
108k
cluster
float64
14
14
__index_level_0__
int64
0
217k
Provide tags and a correct Python 3 solution for this coding contest problem. A new Berland businessman Vitaly is going to open a household appliances' store. All he's got to do now is to hire the staff. The store will work seven days a week, but not around the clock. Every day at least k people must work in the store. Berland has a law that determines the order of working days and non-working days. Namely, each employee must work for exactly n consecutive days, then rest for exactly m days, then work for n more days and rest for m more, and so on. Vitaly doesn't want to break the law. Fortunately, there is a loophole: the law comes into force on the day when the employee is hired. For example, if an employee is hired on day x, then he should work on days [x, x + 1, ..., x + n - 1], [x + m + n, x + m + n + 1, ..., x + m + 2n - 1], and so on. Day x can be chosen arbitrarily by Vitaly. There is one more thing: the key to the store. Berland law prohibits making copies of keys, so there is only one key. Vitaly is planning to entrust the key to the store employees. At the same time on each day the key must be with an employee who works that day — otherwise on this day no one can get inside the store. During the day the key holder can give the key to another employee, if he also works that day. The key will handed to the first hired employee at his first working day. Each employee has to be paid salary. Therefore, Vitaly wants to hire as few employees as possible provided that the store can operate normally on each day from 1 to infinity. In other words, on each day with index from 1 to infinity, the store must have at least k working employees, and one of the working employees should have the key to the store. Help Vitaly and determine the minimum required number of employees, as well as days on which they should be hired. Input The first line contains three integers n, m and k (1 ≤ m ≤ n ≤ 1000, n ≠ 1, 1 ≤ k ≤ 1000). Output In the first line print a single integer z — the minimum required number of employees. In the second line print z positive integers, separated by spaces: the i-th integer ai (1 ≤ ai ≤ 104) should represent the number of the day, on which Vitaly should hire the i-th employee. If there are multiple answers, print any of them. Examples Input 4 3 2 Output 4 1 1 4 5 Input 3 3 1 Output 3 1 3 5
instruction
0
48,191
14
96,382
Tags: greedy Correct Solution: ``` def readInts(): return map(int, input().split()) def solve(): line0 = [] try: line0 = readInts() except EOFError: return False n, m, k = line0 cnt = [0] * 10000 ans = [] keyPos = 1 head = 1 while head <= n+m or keyPos <= n+m: head = min ( head, keyPos ) keyPos = max ( keyPos, head+n-1 ) ans.append ( head ) for i in range(head, head+n): cnt[i] += 1 while cnt[head] >= k: head += 1 print ( len(ans) ) print ( " ".join(map(str,ans)) ) return True while solve(): pass # Made By Mostafa_Khaled ```
output
1
48,191
14
96,383
Provide tags and a correct Python 3 solution for this coding contest problem. A new Berland businessman Vitaly is going to open a household appliances' store. All he's got to do now is to hire the staff. The store will work seven days a week, but not around the clock. Every day at least k people must work in the store. Berland has a law that determines the order of working days and non-working days. Namely, each employee must work for exactly n consecutive days, then rest for exactly m days, then work for n more days and rest for m more, and so on. Vitaly doesn't want to break the law. Fortunately, there is a loophole: the law comes into force on the day when the employee is hired. For example, if an employee is hired on day x, then he should work on days [x, x + 1, ..., x + n - 1], [x + m + n, x + m + n + 1, ..., x + m + 2n - 1], and so on. Day x can be chosen arbitrarily by Vitaly. There is one more thing: the key to the store. Berland law prohibits making copies of keys, so there is only one key. Vitaly is planning to entrust the key to the store employees. At the same time on each day the key must be with an employee who works that day — otherwise on this day no one can get inside the store. During the day the key holder can give the key to another employee, if he also works that day. The key will handed to the first hired employee at his first working day. Each employee has to be paid salary. Therefore, Vitaly wants to hire as few employees as possible provided that the store can operate normally on each day from 1 to infinity. In other words, on each day with index from 1 to infinity, the store must have at least k working employees, and one of the working employees should have the key to the store. Help Vitaly and determine the minimum required number of employees, as well as days on which they should be hired. Input The first line contains three integers n, m and k (1 ≤ m ≤ n ≤ 1000, n ≠ 1, 1 ≤ k ≤ 1000). Output In the first line print a single integer z — the minimum required number of employees. In the second line print z positive integers, separated by spaces: the i-th integer ai (1 ≤ ai ≤ 104) should represent the number of the day, on which Vitaly should hire the i-th employee. If there are multiple answers, print any of them. Examples Input 4 3 2 Output 4 1 1 4 5 Input 3 3 1 Output 3 1 3 5
instruction
0
48,192
14
96,384
Tags: greedy Correct Solution: ``` n, m, k = map(int, input().split()) span = n+m+1 count = (span+1)*[0] count[span] = k key = (span+1)*[False] key[1] = True hire = [] day = 1 while True: while day <= span and count[day] >= k: day += 1 if day > span: if key[span]: break day -= 1 while not key[day]: day -= 1 hire.append(day) last = min(span, day+n-1) for i in range(day, last+1): count[i] += 1 key[i] = True print(len(hire)) print(' '.join([str(x) for x in hire])) ```
output
1
48,192
14
96,385
Provide tags and a correct Python 3 solution for this coding contest problem. A new Berland businessman Vitaly is going to open a household appliances' store. All he's got to do now is to hire the staff. The store will work seven days a week, but not around the clock. Every day at least k people must work in the store. Berland has a law that determines the order of working days and non-working days. Namely, each employee must work for exactly n consecutive days, then rest for exactly m days, then work for n more days and rest for m more, and so on. Vitaly doesn't want to break the law. Fortunately, there is a loophole: the law comes into force on the day when the employee is hired. For example, if an employee is hired on day x, then he should work on days [x, x + 1, ..., x + n - 1], [x + m + n, x + m + n + 1, ..., x + m + 2n - 1], and so on. Day x can be chosen arbitrarily by Vitaly. There is one more thing: the key to the store. Berland law prohibits making copies of keys, so there is only one key. Vitaly is planning to entrust the key to the store employees. At the same time on each day the key must be with an employee who works that day — otherwise on this day no one can get inside the store. During the day the key holder can give the key to another employee, if he also works that day. The key will handed to the first hired employee at his first working day. Each employee has to be paid salary. Therefore, Vitaly wants to hire as few employees as possible provided that the store can operate normally on each day from 1 to infinity. In other words, on each day with index from 1 to infinity, the store must have at least k working employees, and one of the working employees should have the key to the store. Help Vitaly and determine the minimum required number of employees, as well as days on which they should be hired. Input The first line contains three integers n, m and k (1 ≤ m ≤ n ≤ 1000, n ≠ 1, 1 ≤ k ≤ 1000). Output In the first line print a single integer z — the minimum required number of employees. In the second line print z positive integers, separated by spaces: the i-th integer ai (1 ≤ ai ≤ 104) should represent the number of the day, on which Vitaly should hire the i-th employee. If there are multiple answers, print any of them. Examples Input 4 3 2 Output 4 1 1 4 5 Input 3 3 1 Output 3 1 3 5
instruction
0
48,193
14
96,386
Tags: greedy Correct Solution: ``` import math n,m,k = [int(x) for x in input().split()] week = n+m if k == 1: things = [] x = 1 while x <= week: things.append(str(x)) x += n-1 print(len(things)) print(' '.join(things)) else: things = ['1'] x = 1 while x <= week: things += [str(x)]*(k-1) x += n if x <= week+1: things.append(str(x-1)) print(len(things)) print(' '.join(things)) ```
output
1
48,193
14
96,387
Provide tags and a correct Python 3 solution for this coding contest problem. A new Berland businessman Vitaly is going to open a household appliances' store. All he's got to do now is to hire the staff. The store will work seven days a week, but not around the clock. Every day at least k people must work in the store. Berland has a law that determines the order of working days and non-working days. Namely, each employee must work for exactly n consecutive days, then rest for exactly m days, then work for n more days and rest for m more, and so on. Vitaly doesn't want to break the law. Fortunately, there is a loophole: the law comes into force on the day when the employee is hired. For example, if an employee is hired on day x, then he should work on days [x, x + 1, ..., x + n - 1], [x + m + n, x + m + n + 1, ..., x + m + 2n - 1], and so on. Day x can be chosen arbitrarily by Vitaly. There is one more thing: the key to the store. Berland law prohibits making copies of keys, so there is only one key. Vitaly is planning to entrust the key to the store employees. At the same time on each day the key must be with an employee who works that day — otherwise on this day no one can get inside the store. During the day the key holder can give the key to another employee, if he also works that day. The key will handed to the first hired employee at his first working day. Each employee has to be paid salary. Therefore, Vitaly wants to hire as few employees as possible provided that the store can operate normally on each day from 1 to infinity. In other words, on each day with index from 1 to infinity, the store must have at least k working employees, and one of the working employees should have the key to the store. Help Vitaly and determine the minimum required number of employees, as well as days on which they should be hired. Input The first line contains three integers n, m and k (1 ≤ m ≤ n ≤ 1000, n ≠ 1, 1 ≤ k ≤ 1000). Output In the first line print a single integer z — the minimum required number of employees. In the second line print z positive integers, separated by spaces: the i-th integer ai (1 ≤ ai ≤ 104) should represent the number of the day, on which Vitaly should hire the i-th employee. If there are multiple answers, print any of them. Examples Input 4 3 2 Output 4 1 1 4 5 Input 3 3 1 Output 3 1 3 5
instruction
0
48,194
14
96,388
Tags: greedy Correct Solution: ``` # 216C def do(): n, m, k = map(int, input().split(" ")) res = [1] * k p = [k] * n + [0] * 5000 for i in range(n + 1, n + m + 1): if p[i] == 0: res.append(i - 1) for j in range(i - 1, i - 1 + n): p[j] += 1 if p[i] < k: gap = k - p[i] for j in range(1, gap + 1): res.append(i) for j in range(i, i + n): p[j] += gap if p[n +m + 1] == 0: res.append(n + m) return [len(res), " ".join(str(c) for c in res)] x, y = do() print(x) print(y) ```
output
1
48,194
14
96,389
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A new Berland businessman Vitaly is going to open a household appliances' store. All he's got to do now is to hire the staff. The store will work seven days a week, but not around the clock. Every day at least k people must work in the store. Berland has a law that determines the order of working days and non-working days. Namely, each employee must work for exactly n consecutive days, then rest for exactly m days, then work for n more days and rest for m more, and so on. Vitaly doesn't want to break the law. Fortunately, there is a loophole: the law comes into force on the day when the employee is hired. For example, if an employee is hired on day x, then he should work on days [x, x + 1, ..., x + n - 1], [x + m + n, x + m + n + 1, ..., x + m + 2n - 1], and so on. Day x can be chosen arbitrarily by Vitaly. There is one more thing: the key to the store. Berland law prohibits making copies of keys, so there is only one key. Vitaly is planning to entrust the key to the store employees. At the same time on each day the key must be with an employee who works that day — otherwise on this day no one can get inside the store. During the day the key holder can give the key to another employee, if he also works that day. The key will handed to the first hired employee at his first working day. Each employee has to be paid salary. Therefore, Vitaly wants to hire as few employees as possible provided that the store can operate normally on each day from 1 to infinity. In other words, on each day with index from 1 to infinity, the store must have at least k working employees, and one of the working employees should have the key to the store. Help Vitaly and determine the minimum required number of employees, as well as days on which they should be hired. Input The first line contains three integers n, m and k (1 ≤ m ≤ n ≤ 1000, n ≠ 1, 1 ≤ k ≤ 1000). Output In the first line print a single integer z — the minimum required number of employees. In the second line print z positive integers, separated by spaces: the i-th integer ai (1 ≤ ai ≤ 104) should represent the number of the day, on which Vitaly should hire the i-th employee. If there are multiple answers, print any of them. Examples Input 4 3 2 Output 4 1 1 4 5 Input 3 3 1 Output 3 1 3 5 Submitted Solution: ``` temparr = input() temparr = temparr.split() n = int(temparr[0]) m = int(temparr[1]) k = int(temparr[2]) arr =[0 for _ in range(15)] work = [] leave = [] ans = [] maxsrange = max(n + m , 15) + 1 for i in range(maxsrange): if i == 0 : for j in range(k): ans.append(i + 1) work.append(n) continue newwork = [] newleave = [] for j in work: if j == 1: newleave.append(m) continue newwork.append(j - 1) for j in leave: if j == 1: newwork.append(n) newleave.append(j - 1) leave = newleave[::] work = newwork[::] #print(work) if len(work) == sum(work): work.append(n ) ans.append(i + 1) diff = k - len(work) if diff > 0 : for j in range(diff): work.append(n ) ans.append(i + 1) print(len(ans)) sans = [] for i in ans: sans.append(str(i)) print(" ".join(sans)) ```
instruction
0
48,195
14
96,390
Yes
output
1
48,195
14
96,391
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A new Berland businessman Vitaly is going to open a household appliances' store. All he's got to do now is to hire the staff. The store will work seven days a week, but not around the clock. Every day at least k people must work in the store. Berland has a law that determines the order of working days and non-working days. Namely, each employee must work for exactly n consecutive days, then rest for exactly m days, then work for n more days and rest for m more, and so on. Vitaly doesn't want to break the law. Fortunately, there is a loophole: the law comes into force on the day when the employee is hired. For example, if an employee is hired on day x, then he should work on days [x, x + 1, ..., x + n - 1], [x + m + n, x + m + n + 1, ..., x + m + 2n - 1], and so on. Day x can be chosen arbitrarily by Vitaly. There is one more thing: the key to the store. Berland law prohibits making copies of keys, so there is only one key. Vitaly is planning to entrust the key to the store employees. At the same time on each day the key must be with an employee who works that day — otherwise on this day no one can get inside the store. During the day the key holder can give the key to another employee, if he also works that day. The key will handed to the first hired employee at his first working day. Each employee has to be paid salary. Therefore, Vitaly wants to hire as few employees as possible provided that the store can operate normally on each day from 1 to infinity. In other words, on each day with index from 1 to infinity, the store must have at least k working employees, and one of the working employees should have the key to the store. Help Vitaly and determine the minimum required number of employees, as well as days on which they should be hired. Input The first line contains three integers n, m and k (1 ≤ m ≤ n ≤ 1000, n ≠ 1, 1 ≤ k ≤ 1000). Output In the first line print a single integer z — the minimum required number of employees. In the second line print z positive integers, separated by spaces: the i-th integer ai (1 ≤ ai ≤ 104) should represent the number of the day, on which Vitaly should hire the i-th employee. If there are multiple answers, print any of them. Examples Input 4 3 2 Output 4 1 1 4 5 Input 3 3 1 Output 3 1 3 5 Submitted Solution: ``` n,m,k = map(int,input().split()) cnt = [0]*100010 a = [] for day in range(n+m): while cnt[day] < k or cnt[day+1] == 0 : a.append(day+1) for i in range(n): cnt[day+i] += 1 print(len(a)) print(*a) ```
instruction
0
48,196
14
96,392
Yes
output
1
48,196
14
96,393
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A new Berland businessman Vitaly is going to open a household appliances' store. All he's got to do now is to hire the staff. The store will work seven days a week, but not around the clock. Every day at least k people must work in the store. Berland has a law that determines the order of working days and non-working days. Namely, each employee must work for exactly n consecutive days, then rest for exactly m days, then work for n more days and rest for m more, and so on. Vitaly doesn't want to break the law. Fortunately, there is a loophole: the law comes into force on the day when the employee is hired. For example, if an employee is hired on day x, then he should work on days [x, x + 1, ..., x + n - 1], [x + m + n, x + m + n + 1, ..., x + m + 2n - 1], and so on. Day x can be chosen arbitrarily by Vitaly. There is one more thing: the key to the store. Berland law prohibits making copies of keys, so there is only one key. Vitaly is planning to entrust the key to the store employees. At the same time on each day the key must be with an employee who works that day — otherwise on this day no one can get inside the store. During the day the key holder can give the key to another employee, if he also works that day. The key will handed to the first hired employee at his first working day. Each employee has to be paid salary. Therefore, Vitaly wants to hire as few employees as possible provided that the store can operate normally on each day from 1 to infinity. In other words, on each day with index from 1 to infinity, the store must have at least k working employees, and one of the working employees should have the key to the store. Help Vitaly and determine the minimum required number of employees, as well as days on which they should be hired. Input The first line contains three integers n, m and k (1 ≤ m ≤ n ≤ 1000, n ≠ 1, 1 ≤ k ≤ 1000). Output In the first line print a single integer z — the minimum required number of employees. In the second line print z positive integers, separated by spaces: the i-th integer ai (1 ≤ ai ≤ 104) should represent the number of the day, on which Vitaly should hire the i-th employee. If there are multiple answers, print any of them. Examples Input 4 3 2 Output 4 1 1 4 5 Input 3 3 1 Output 3 1 3 5 Submitted Solution: ``` n, m, k = map(int, input().split()) p = ['1 ' * k] + [str(i) + ' ' + (str(i + 1) + ' ') * (k - 1) for i in range(n, n + m, n)] if n % m == 0: p.append(str(n + m - 1) + ' ') p = ''.join(p) print(p.count(' ')) print(p) ```
instruction
0
48,197
14
96,394
No
output
1
48,197
14
96,395
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A new Berland businessman Vitaly is going to open a household appliances' store. All he's got to do now is to hire the staff. The store will work seven days a week, but not around the clock. Every day at least k people must work in the store. Berland has a law that determines the order of working days and non-working days. Namely, each employee must work for exactly n consecutive days, then rest for exactly m days, then work for n more days and rest for m more, and so on. Vitaly doesn't want to break the law. Fortunately, there is a loophole: the law comes into force on the day when the employee is hired. For example, if an employee is hired on day x, then he should work on days [x, x + 1, ..., x + n - 1], [x + m + n, x + m + n + 1, ..., x + m + 2n - 1], and so on. Day x can be chosen arbitrarily by Vitaly. There is one more thing: the key to the store. Berland law prohibits making copies of keys, so there is only one key. Vitaly is planning to entrust the key to the store employees. At the same time on each day the key must be with an employee who works that day — otherwise on this day no one can get inside the store. During the day the key holder can give the key to another employee, if he also works that day. The key will handed to the first hired employee at his first working day. Each employee has to be paid salary. Therefore, Vitaly wants to hire as few employees as possible provided that the store can operate normally on each day from 1 to infinity. In other words, on each day with index from 1 to infinity, the store must have at least k working employees, and one of the working employees should have the key to the store. Help Vitaly and determine the minimum required number of employees, as well as days on which they should be hired. Input The first line contains three integers n, m and k (1 ≤ m ≤ n ≤ 1000, n ≠ 1, 1 ≤ k ≤ 1000). Output In the first line print a single integer z — the minimum required number of employees. In the second line print z positive integers, separated by spaces: the i-th integer ai (1 ≤ ai ≤ 104) should represent the number of the day, on which Vitaly should hire the i-th employee. If there are multiple answers, print any of them. Examples Input 4 3 2 Output 4 1 1 4 5 Input 3 3 1 Output 3 1 3 5 Submitted Solution: ``` s = input().split() n = int ( s[0] ) m = int ( s[1] ) k = int ( s[2] ) Restore = [] for i in range(k): Restore += [1] if n == m : Restore += [n] for i in range(k-1): Restore += [n+1] Restore += [n+2] elif n - m <= 1 : Restore += [ n ] for i in range(k-1): Restore += [ n+1 ] else : for i in range(k): Restore += [n] temp = "" print ( len ( Restore ) ) for i in Restore: temp += str ( i ) + " " print ( temp ) ```
instruction
0
48,198
14
96,396
No
output
1
48,198
14
96,397
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A new Berland businessman Vitaly is going to open a household appliances' store. All he's got to do now is to hire the staff. The store will work seven days a week, but not around the clock. Every day at least k people must work in the store. Berland has a law that determines the order of working days and non-working days. Namely, each employee must work for exactly n consecutive days, then rest for exactly m days, then work for n more days and rest for m more, and so on. Vitaly doesn't want to break the law. Fortunately, there is a loophole: the law comes into force on the day when the employee is hired. For example, if an employee is hired on day x, then he should work on days [x, x + 1, ..., x + n - 1], [x + m + n, x + m + n + 1, ..., x + m + 2n - 1], and so on. Day x can be chosen arbitrarily by Vitaly. There is one more thing: the key to the store. Berland law prohibits making copies of keys, so there is only one key. Vitaly is planning to entrust the key to the store employees. At the same time on each day the key must be with an employee who works that day — otherwise on this day no one can get inside the store. During the day the key holder can give the key to another employee, if he also works that day. The key will handed to the first hired employee at his first working day. Each employee has to be paid salary. Therefore, Vitaly wants to hire as few employees as possible provided that the store can operate normally on each day from 1 to infinity. In other words, on each day with index from 1 to infinity, the store must have at least k working employees, and one of the working employees should have the key to the store. Help Vitaly and determine the minimum required number of employees, as well as days on which they should be hired. Input The first line contains three integers n, m and k (1 ≤ m ≤ n ≤ 1000, n ≠ 1, 1 ≤ k ≤ 1000). Output In the first line print a single integer z — the minimum required number of employees. In the second line print z positive integers, separated by spaces: the i-th integer ai (1 ≤ ai ≤ 104) should represent the number of the day, on which Vitaly should hire the i-th employee. If there are multiple answers, print any of them. Examples Input 4 3 2 Output 4 1 1 4 5 Input 3 3 1 Output 3 1 3 5 Submitted Solution: ``` def readInts(): return map(int, input().split()) n, m, k = readInts() cnt = [0] * 10000 ans = [] keyPos = 1 head = 1 print ( len(cnt)) while keyPos <= n+m and head < n+m: while cnt[head] >= k: head += 1 head = min ( head, keyPos ) ans.append ( head ) for i in range(head, head+n): cnt[i] += 1 keyPos = max ( keyPos, head+n-1 ) print ( len(ans) ) print ( " ".join(map(str,ans)) ) ```
instruction
0
48,199
14
96,398
No
output
1
48,199
14
96,399
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A new Berland businessman Vitaly is going to open a household appliances' store. All he's got to do now is to hire the staff. The store will work seven days a week, but not around the clock. Every day at least k people must work in the store. Berland has a law that determines the order of working days and non-working days. Namely, each employee must work for exactly n consecutive days, then rest for exactly m days, then work for n more days and rest for m more, and so on. Vitaly doesn't want to break the law. Fortunately, there is a loophole: the law comes into force on the day when the employee is hired. For example, if an employee is hired on day x, then he should work on days [x, x + 1, ..., x + n - 1], [x + m + n, x + m + n + 1, ..., x + m + 2n - 1], and so on. Day x can be chosen arbitrarily by Vitaly. There is one more thing: the key to the store. Berland law prohibits making copies of keys, so there is only one key. Vitaly is planning to entrust the key to the store employees. At the same time on each day the key must be with an employee who works that day — otherwise on this day no one can get inside the store. During the day the key holder can give the key to another employee, if he also works that day. The key will handed to the first hired employee at his first working day. Each employee has to be paid salary. Therefore, Vitaly wants to hire as few employees as possible provided that the store can operate normally on each day from 1 to infinity. In other words, on each day with index from 1 to infinity, the store must have at least k working employees, and one of the working employees should have the key to the store. Help Vitaly and determine the minimum required number of employees, as well as days on which they should be hired. Input The first line contains three integers n, m and k (1 ≤ m ≤ n ≤ 1000, n ≠ 1, 1 ≤ k ≤ 1000). Output In the first line print a single integer z — the minimum required number of employees. In the second line print z positive integers, separated by spaces: the i-th integer ai (1 ≤ ai ≤ 104) should represent the number of the day, on which Vitaly should hire the i-th employee. If there are multiple answers, print any of them. Examples Input 4 3 2 Output 4 1 1 4 5 Input 3 3 1 Output 3 1 3 5 Submitted Solution: ``` temparr = input() temparr = temparr.split() n = int(temparr[0]) m = int(temparr[1]) k = int(temparr[2]) arr =[0 for _ in range(15)] work = [] leave = [] ans = [] for i in range(15): if i == 0 : for j in range(k): ans.append(i + 1) work.append(n) continue newwork = [] newleave = [] for j in work: if j == 1: newleave.append(m) continue newwork.append(j - 1) for j in leave: if j == 1: newwork.append(n) newleave.append(j - 1) leave = newleave[::] work = newwork[::] #print(work) if len(work) == sum(work): work.append(n ) ans.append(i + 1) diff = k - len(work) if diff > 0 : for j in range(diff): work.append(n ) ans.append(i + 1) print(len(ans)) sans = [] for i in ans: sans.append(str(i)) print(" ".join(sans)) ```
instruction
0
48,200
14
96,400
No
output
1
48,200
14
96,401
Provide tags and a correct Python 3 solution for this coding contest problem. The ship crashed into a reef and is sinking. Now the entire crew must be evacuated. All n crew members have already lined up in a row (for convenience let's label them all from left to right with positive integers from 1 to n) and await further instructions. However, one should evacuate the crew properly, in a strict order. Specifically: The first crew members to leave the ship are rats. Then women and children (both groups have the same priority) leave the ship. After that all men are evacuated from the ship. The captain leaves the sinking ship last. If we cannot determine exactly who should leave the ship first for any two members of the crew by the rules from the previous paragraph, then the one who stands to the left in the line leaves the ship first (or in other words, the one whose number in the line is less). For each crew member we know his status as a crew member, and also his name. All crew members have different names. Determine the order in which to evacuate the crew. Input The first line contains an integer n, which is the number of people in the crew (1 ≤ n ≤ 100). Then follow n lines. The i-th of those lines contains two words — the name of the crew member who is i-th in line, and his status on the ship. The words are separated by exactly one space. There are no other spaces in the line. The names consist of Latin letters, the first letter is uppercase, the rest are lowercase. The length of any name is from 1 to 10 characters. The status can have the following values: rat for a rat, woman for a woman, child for a child, man for a man, captain for the captain. The crew contains exactly one captain. Output Print n lines. The i-th of them should contain the name of the crew member who must be the i-th one to leave the ship. Examples Input 6 Jack captain Alice woman Charlie man Teddy rat Bob child Julia woman Output Teddy Alice Bob Julia Charlie Jack
instruction
0
48,385
14
96,770
Tags: implementation, sortings, strings Correct Solution: ``` # bsdk idhar kya dekhne ko aaya hai, khud kr!!! # import math # from itertools import * # import random # import calendar import datetime # import webbrowser n = int(input()) cap = [] women = [] men = [] rat = [] for i in range(n): s = input().split(" ") if s[-1] == "captain": cap.append(s[0]) elif s[-1] == "woman" or s[-1] == "child": women.append(s[0]) elif s[-1] == "man": men.append(s[0]) elif s[-1] == "rat": rat.append(s[0]) for i in rat: print(i) for i in women: print(i) for i in men: print(i) for i in cap: print(i) ```
output
1
48,385
14
96,771
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The ship crashed into a reef and is sinking. Now the entire crew must be evacuated. All n crew members have already lined up in a row (for convenience let's label them all from left to right with positive integers from 1 to n) and await further instructions. However, one should evacuate the crew properly, in a strict order. Specifically: The first crew members to leave the ship are rats. Then women and children (both groups have the same priority) leave the ship. After that all men are evacuated from the ship. The captain leaves the sinking ship last. If we cannot determine exactly who should leave the ship first for any two members of the crew by the rules from the previous paragraph, then the one who stands to the left in the line leaves the ship first (or in other words, the one whose number in the line is less). For each crew member we know his status as a crew member, and also his name. All crew members have different names. Determine the order in which to evacuate the crew. Input The first line contains an integer n, which is the number of people in the crew (1 ≤ n ≤ 100). Then follow n lines. The i-th of those lines contains two words — the name of the crew member who is i-th in line, and his status on the ship. The words are separated by exactly one space. There are no other spaces in the line. The names consist of Latin letters, the first letter is uppercase, the rest are lowercase. The length of any name is from 1 to 10 characters. The status can have the following values: rat for a rat, woman for a woman, child for a child, man for a man, captain for the captain. The crew contains exactly one captain. Output Print n lines. The i-th of them should contain the name of the crew member who must be the i-th one to leave the ship. Examples Input 6 Jack captain Alice woman Charlie man Teddy rat Bob child Julia woman Output Teddy Alice Bob Julia Charlie Jack Submitted Solution: ``` d={} for _ in range(int(input())): a,b=input().split() if b=='child': b='woman' if b not in d: d[b]=[a] else: d[b].append(a) if 'rat' in d: print(*d['rat'],sep='\n') if 'woman' in d: print(*d['woman'],sep='\n') if 'man' in d: print(*d['man'],sep='\n') if 'captain' in d: print(*d['captain'],sep='\n') ```
instruction
0
48,390
14
96,780
Yes
output
1
48,390
14
96,781
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The ship crashed into a reef and is sinking. Now the entire crew must be evacuated. All n crew members have already lined up in a row (for convenience let's label them all from left to right with positive integers from 1 to n) and await further instructions. However, one should evacuate the crew properly, in a strict order. Specifically: The first crew members to leave the ship are rats. Then women and children (both groups have the same priority) leave the ship. After that all men are evacuated from the ship. The captain leaves the sinking ship last. If we cannot determine exactly who should leave the ship first for any two members of the crew by the rules from the previous paragraph, then the one who stands to the left in the line leaves the ship first (or in other words, the one whose number in the line is less). For each crew member we know his status as a crew member, and also his name. All crew members have different names. Determine the order in which to evacuate the crew. Input The first line contains an integer n, which is the number of people in the crew (1 ≤ n ≤ 100). Then follow n lines. The i-th of those lines contains two words — the name of the crew member who is i-th in line, and his status on the ship. The words are separated by exactly one space. There are no other spaces in the line. The names consist of Latin letters, the first letter is uppercase, the rest are lowercase. The length of any name is from 1 to 10 characters. The status can have the following values: rat for a rat, woman for a woman, child for a child, man for a man, captain for the captain. The crew contains exactly one captain. Output Print n lines. The i-th of them should contain the name of the crew member who must be the i-th one to leave the ship. Examples Input 6 Jack captain Alice woman Charlie man Teddy rat Bob child Julia woman Output Teddy Alice Bob Julia Charlie Jack Submitted Solution: ``` n=int(input()) cap=[] wom=[] chil=[] rat=[] ma=[] def thro(): global rat if (len(rat)>=1): for i in rat: print(i) rat=[] global wom if (len(wom)>=1): for i in wom: print(i) wom=[] global ma if (len(ma)>=1): for i in ma: print(i) ma=[] global cap if(len(cap)>=1): print(cap[0]) cap=[] for j in range(0,n): x,y=input().split() if y=="rat": rat.append(x) elif y=="woman" or y=="child": wom.append(x) elif y=="man": ma.append(x) elif y=="captain": cap.append(x) else: thro() print(x) thro() ```
instruction
0
48,391
14
96,782
Yes
output
1
48,391
14
96,783
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The ship crashed into a reef and is sinking. Now the entire crew must be evacuated. All n crew members have already lined up in a row (for convenience let's label them all from left to right with positive integers from 1 to n) and await further instructions. However, one should evacuate the crew properly, in a strict order. Specifically: The first crew members to leave the ship are rats. Then women and children (both groups have the same priority) leave the ship. After that all men are evacuated from the ship. The captain leaves the sinking ship last. If we cannot determine exactly who should leave the ship first for any two members of the crew by the rules from the previous paragraph, then the one who stands to the left in the line leaves the ship first (or in other words, the one whose number in the line is less). For each crew member we know his status as a crew member, and also his name. All crew members have different names. Determine the order in which to evacuate the crew. Input The first line contains an integer n, which is the number of people in the crew (1 ≤ n ≤ 100). Then follow n lines. The i-th of those lines contains two words — the name of the crew member who is i-th in line, and his status on the ship. The words are separated by exactly one space. There are no other spaces in the line. The names consist of Latin letters, the first letter is uppercase, the rest are lowercase. The length of any name is from 1 to 10 characters. The status can have the following values: rat for a rat, woman for a woman, child for a child, man for a man, captain for the captain. The crew contains exactly one captain. Output Print n lines. The i-th of them should contain the name of the crew member who must be the i-th one to leave the ship. Examples Input 6 Jack captain Alice woman Charlie man Teddy rat Bob child Julia woman Output Teddy Alice Bob Julia Charlie Jack Submitted Solution: ``` # Long Contest 1, Problem K def print_list(items): for item in items: print(item) n = int(input()) rats = [] women_children = [] men = [] captains = [] while n > 0: n -= 1 name, status = input().split() if status == 'rat': rats.append(name) elif status == 'woman' or status == 'child': women_children.append(name) elif status == 'man': men.append(name) elif status == 'captain': captains.append(name) print_list(rats) print_list(women_children) print_list(men) print_list(captains) ```
instruction
0
48,392
14
96,784
Yes
output
1
48,392
14
96,785
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The ship crashed into a reef and is sinking. Now the entire crew must be evacuated. All n crew members have already lined up in a row (for convenience let's label them all from left to right with positive integers from 1 to n) and await further instructions. However, one should evacuate the crew properly, in a strict order. Specifically: The first crew members to leave the ship are rats. Then women and children (both groups have the same priority) leave the ship. After that all men are evacuated from the ship. The captain leaves the sinking ship last. If we cannot determine exactly who should leave the ship first for any two members of the crew by the rules from the previous paragraph, then the one who stands to the left in the line leaves the ship first (or in other words, the one whose number in the line is less). For each crew member we know his status as a crew member, and also his name. All crew members have different names. Determine the order in which to evacuate the crew. Input The first line contains an integer n, which is the number of people in the crew (1 ≤ n ≤ 100). Then follow n lines. The i-th of those lines contains two words — the name of the crew member who is i-th in line, and his status on the ship. The words are separated by exactly one space. There are no other spaces in the line. The names consist of Latin letters, the first letter is uppercase, the rest are lowercase. The length of any name is from 1 to 10 characters. The status can have the following values: rat for a rat, woman for a woman, child for a child, man for a man, captain for the captain. The crew contains exactly one captain. Output Print n lines. The i-th of them should contain the name of the crew member who must be the i-th one to leave the ship. Examples Input 6 Jack captain Alice woman Charlie man Teddy rat Bob child Julia woman Output Teddy Alice Bob Julia Charlie Jack Submitted Solution: ``` n=int(input()) c=[] r=[] w=[] ch=[] m=[] for i in range(n): p,s=input().split() if s=="captain": c.append(p) elif s=="woman": w.append([i,p]) elif s=="rat": r.append(p) elif s=="child": ch.append([i,p]) else: m.append(p) for p in r: print(p) wc1=w+ch wc1.sort() for p in wc1: print(p[1]) for p in m: print(p) for p in c: print(p) ```
instruction
0
48,393
14
96,786
Yes
output
1
48,393
14
96,787
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The ship crashed into a reef and is sinking. Now the entire crew must be evacuated. All n crew members have already lined up in a row (for convenience let's label them all from left to right with positive integers from 1 to n) and await further instructions. However, one should evacuate the crew properly, in a strict order. Specifically: The first crew members to leave the ship are rats. Then women and children (both groups have the same priority) leave the ship. After that all men are evacuated from the ship. The captain leaves the sinking ship last. If we cannot determine exactly who should leave the ship first for any two members of the crew by the rules from the previous paragraph, then the one who stands to the left in the line leaves the ship first (or in other words, the one whose number in the line is less). For each crew member we know his status as a crew member, and also his name. All crew members have different names. Determine the order in which to evacuate the crew. Input The first line contains an integer n, which is the number of people in the crew (1 ≤ n ≤ 100). Then follow n lines. The i-th of those lines contains two words — the name of the crew member who is i-th in line, and his status on the ship. The words are separated by exactly one space. There are no other spaces in the line. The names consist of Latin letters, the first letter is uppercase, the rest are lowercase. The length of any name is from 1 to 10 characters. The status can have the following values: rat for a rat, woman for a woman, child for a child, man for a man, captain for the captain. The crew contains exactly one captain. Output Print n lines. The i-th of them should contain the name of the crew member who must be the i-th one to leave the ship. Examples Input 6 Jack captain Alice woman Charlie man Teddy rat Bob child Julia woman Output Teddy Alice Bob Julia Charlie Jack Submitted Solution: ``` n = int(float(input())) d = dict(input().split() for _ in range(n)) #print(d) l = list(d.items()) l1 = [] for i in d: if d[i] == "rat": d[i] = 0 elif d[i] == "child" or d[i] == "woman": d[i] = 1 elif d[i] == "man": d[i] = 2 else: d[i] = 3 print(d) l = list(d.items()) l1 = [] for i, j in l: l1.append((j,i)) l1.sort() for i, j in l1: print(j) ```
instruction
0
48,394
14
96,788
No
output
1
48,394
14
96,789
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The ship crashed into a reef and is sinking. Now the entire crew must be evacuated. All n crew members have already lined up in a row (for convenience let's label them all from left to right with positive integers from 1 to n) and await further instructions. However, one should evacuate the crew properly, in a strict order. Specifically: The first crew members to leave the ship are rats. Then women and children (both groups have the same priority) leave the ship. After that all men are evacuated from the ship. The captain leaves the sinking ship last. If we cannot determine exactly who should leave the ship first for any two members of the crew by the rules from the previous paragraph, then the one who stands to the left in the line leaves the ship first (or in other words, the one whose number in the line is less). For each crew member we know his status as a crew member, and also his name. All crew members have different names. Determine the order in which to evacuate the crew. Input The first line contains an integer n, which is the number of people in the crew (1 ≤ n ≤ 100). Then follow n lines. The i-th of those lines contains two words — the name of the crew member who is i-th in line, and his status on the ship. The words are separated by exactly one space. There are no other spaces in the line. The names consist of Latin letters, the first letter is uppercase, the rest are lowercase. The length of any name is from 1 to 10 characters. The status can have the following values: rat for a rat, woman for a woman, child for a child, man for a man, captain for the captain. The crew contains exactly one captain. Output Print n lines. The i-th of them should contain the name of the crew member who must be the i-th one to leave the ship. Examples Input 6 Jack captain Alice woman Charlie man Teddy rat Bob child Julia woman Output Teddy Alice Bob Julia Charlie Jack Submitted Solution: ``` n=int(input()) di={} for i in range(n): s=str(input()) if('captain' in s): e=s.index(" ") d=s[0:e] di[d]=4 if("man" in s and 'woman' not in s): e=s.index(" ") d=s[0:e] di[d]=3 if('woman' in s or 'child' in s): e=s.index(" ") d=s[0:e] di[d]=2 if('rat' in s): e=s.index(" ") d=s[0:e] di[d]=1 a=sorted(di.items(),key=lambda x:x[1]) for i in range(0,len(a)): print(a[i][0]) ```
instruction
0
48,395
14
96,790
No
output
1
48,395
14
96,791
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The ship crashed into a reef and is sinking. Now the entire crew must be evacuated. All n crew members have already lined up in a row (for convenience let's label them all from left to right with positive integers from 1 to n) and await further instructions. However, one should evacuate the crew properly, in a strict order. Specifically: The first crew members to leave the ship are rats. Then women and children (both groups have the same priority) leave the ship. After that all men are evacuated from the ship. The captain leaves the sinking ship last. If we cannot determine exactly who should leave the ship first for any two members of the crew by the rules from the previous paragraph, then the one who stands to the left in the line leaves the ship first (or in other words, the one whose number in the line is less). For each crew member we know his status as a crew member, and also his name. All crew members have different names. Determine the order in which to evacuate the crew. Input The first line contains an integer n, which is the number of people in the crew (1 ≤ n ≤ 100). Then follow n lines. The i-th of those lines contains two words — the name of the crew member who is i-th in line, and his status on the ship. The words are separated by exactly one space. There are no other spaces in the line. The names consist of Latin letters, the first letter is uppercase, the rest are lowercase. The length of any name is from 1 to 10 characters. The status can have the following values: rat for a rat, woman for a woman, child for a child, man for a man, captain for the captain. The crew contains exactly one captain. Output Print n lines. The i-th of them should contain the name of the crew member who must be the i-th one to leave the ship. Examples Input 6 Jack captain Alice woman Charlie man Teddy rat Bob child Julia woman Output Teddy Alice Bob Julia Charlie Jack Submitted Solution: ``` n = int(input()) rat = [] wc = [] man = [] cap = [] for i in range(n): a,b = input().split() if b == 'captain': cap.append(a) if b == 'rat': rat.append(a) if b == 'man': man.append(a) if b == 'woman' or b=="child": wc.append(a) cap = sorted(cap) rat = sorted(rat) wc = sorted(wc) man = sorted(man) for i in range(len(rat)): print(rat[i]) for i in range(len(wc)): print(wc[i]) for i in range(len(man)): print(man[i]) for i in range(len(cap)): print(cap[i]) ```
instruction
0
48,396
14
96,792
No
output
1
48,396
14
96,793
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The ship crashed into a reef and is sinking. Now the entire crew must be evacuated. All n crew members have already lined up in a row (for convenience let's label them all from left to right with positive integers from 1 to n) and await further instructions. However, one should evacuate the crew properly, in a strict order. Specifically: The first crew members to leave the ship are rats. Then women and children (both groups have the same priority) leave the ship. After that all men are evacuated from the ship. The captain leaves the sinking ship last. If we cannot determine exactly who should leave the ship first for any two members of the crew by the rules from the previous paragraph, then the one who stands to the left in the line leaves the ship first (or in other words, the one whose number in the line is less). For each crew member we know his status as a crew member, and also his name. All crew members have different names. Determine the order in which to evacuate the crew. Input The first line contains an integer n, which is the number of people in the crew (1 ≤ n ≤ 100). Then follow n lines. The i-th of those lines contains two words — the name of the crew member who is i-th in line, and his status on the ship. The words are separated by exactly one space. There are no other spaces in the line. The names consist of Latin letters, the first letter is uppercase, the rest are lowercase. The length of any name is from 1 to 10 characters. The status can have the following values: rat for a rat, woman for a woman, child for a child, man for a man, captain for the captain. The crew contains exactly one captain. Output Print n lines. The i-th of them should contain the name of the crew member who must be the i-th one to leave the ship. Examples Input 6 Jack captain Alice woman Charlie man Teddy rat Bob child Julia woman Output Teddy Alice Bob Julia Charlie Jack Submitted Solution: ``` n = int(input()) d = {} rat = [] wo = [] child = [] ma = [] cap = [] for i in range(0,n): a,b = map(str,input().split()) d[b] = a for i in d.keys(): if(i == 'rat'): rat.append(d[i]) if(i == 'woman' or i =='child'): wo.append(d[i]) if(i == 'man'): ma.append(d[i]) if(i == 'captain'): cap.append(d[i]) print(rat) print(wo) print(ma) print(cap) ```
instruction
0
48,397
14
96,794
No
output
1
48,397
14
96,795
Provide tags and a correct Python 3 solution for this coding contest problem. Suppose that you are in a campus and have to go for classes day by day. As you may see, when you hurry to a classroom, you surprisingly find that many seats there are already occupied. Today you and your friends went for class, and found out that some of the seats were occupied. The classroom contains n rows of seats and there are m seats in each row. Then the classroom can be represented as an n × m matrix. The character '.' represents an empty seat, while '*' means that the seat is occupied. You need to find k consecutive empty seats in the same row or column and arrange those seats for you and your friends. Your task is to find the number of ways to arrange the seats. Two ways are considered different if sets of places that students occupy differs. Input The first line contains three positive integers n,m,k (1 ≤ n, m, k ≤ 2 000), where n,m represent the sizes of the classroom and k is the number of consecutive seats you need to find. Each of the next n lines contains m characters '.' or '*'. They form a matrix representing the classroom, '.' denotes an empty seat, and '*' denotes an occupied seat. Output A single number, denoting the number of ways to find k empty seats in the same row or column. Examples Input 2 3 2 **. ... Output 3 Input 1 2 2 .. Output 1 Input 3 3 4 .*. *.* .*. Output 0 Note In the first sample, there are three ways to arrange those seats. You can take the following seats for your arrangement. * (1,3), (2,3) * (2,2), (2,3) * (2,1), (2,2)
instruction
0
48,514
14
97,028
Tags: brute force, implementation Correct Solution: ``` from sys import stdin def main(): k, r = int(input().split()[2]) - 1, 0 l = stdin.read().splitlines() if k: l += map(''.join, zip(*l)) for s in l: for x in map(len, filter(None, s.split('*'))): if x > k: r += x - k else: r = sum(s.count('.') for s in l) print(r) if __name__ == '__main__': main() ```
output
1
48,514
14
97,029
Provide tags and a correct Python 3 solution for this coding contest problem. Suppose that you are in a campus and have to go for classes day by day. As you may see, when you hurry to a classroom, you surprisingly find that many seats there are already occupied. Today you and your friends went for class, and found out that some of the seats were occupied. The classroom contains n rows of seats and there are m seats in each row. Then the classroom can be represented as an n × m matrix. The character '.' represents an empty seat, while '*' means that the seat is occupied. You need to find k consecutive empty seats in the same row or column and arrange those seats for you and your friends. Your task is to find the number of ways to arrange the seats. Two ways are considered different if sets of places that students occupy differs. Input The first line contains three positive integers n,m,k (1 ≤ n, m, k ≤ 2 000), where n,m represent the sizes of the classroom and k is the number of consecutive seats you need to find. Each of the next n lines contains m characters '.' or '*'. They form a matrix representing the classroom, '.' denotes an empty seat, and '*' denotes an occupied seat. Output A single number, denoting the number of ways to find k empty seats in the same row or column. Examples Input 2 3 2 **. ... Output 3 Input 1 2 2 .. Output 1 Input 3 3 4 .*. *.* .*. Output 0 Note In the first sample, there are three ways to arrange those seats. You can take the following seats for your arrangement. * (1,3), (2,3) * (2,2), (2,3) * (2,1), (2,2)
instruction
0
48,515
14
97,030
Tags: brute force, implementation Correct Solution: ``` # import time # # [int(x) for x in input().split()] # # # def timer(func): # def f(*args, **kwargs): # start_time = time.time() # ret = func(*args, **kwargs) # print("--- %s seconds ---" % (time.time() - start_time)) # return ret # return f def main(): n, m, k = [int(x) for x in input().split()] #n, m, k = [2000, 2000, 10] # M = ((('*****...*' * m).split()) * n ) #M = ['.', '.', '*', '*', '.', '*', '*', '*', '*', '.'] * (m // 10) size = 0 h = [0] * m for i in range(n): M = input() length = 0 for j in range(m): if M[j] == '.': length += 1 h[j] += 1 continue if length >= k: size += length - k + 1 if h[j] >= k > 1: size += h[j] - k + 1 length = 0 h[j] = 0 if length >= k: size += length - k + 1 for i in range(m): if h[i] >= k > 1: size += h[i] - k + 1 print(size) main() ```
output
1
48,515
14
97,031
Provide tags and a correct Python 3 solution for this coding contest problem. Suppose that you are in a campus and have to go for classes day by day. As you may see, when you hurry to a classroom, you surprisingly find that many seats there are already occupied. Today you and your friends went for class, and found out that some of the seats were occupied. The classroom contains n rows of seats and there are m seats in each row. Then the classroom can be represented as an n × m matrix. The character '.' represents an empty seat, while '*' means that the seat is occupied. You need to find k consecutive empty seats in the same row or column and arrange those seats for you and your friends. Your task is to find the number of ways to arrange the seats. Two ways are considered different if sets of places that students occupy differs. Input The first line contains three positive integers n,m,k (1 ≤ n, m, k ≤ 2 000), where n,m represent the sizes of the classroom and k is the number of consecutive seats you need to find. Each of the next n lines contains m characters '.' or '*'. They form a matrix representing the classroom, '.' denotes an empty seat, and '*' denotes an occupied seat. Output A single number, denoting the number of ways to find k empty seats in the same row or column. Examples Input 2 3 2 **. ... Output 3 Input 1 2 2 .. Output 1 Input 3 3 4 .*. *.* .*. Output 0 Note In the first sample, there are three ways to arrange those seats. You can take the following seats for your arrangement. * (1,3), (2,3) * (2,2), (2,3) * (2,1), (2,2)
instruction
0
48,516
14
97,032
Tags: brute force, implementation Correct Solution: ``` import sys try: sys.stdin = open('input.txt', 'r') sys.stdout = open('output.txt', 'w') except: pass input = sys.stdin.readline n, m, k = list(map(int, input().split())) grid = [] ans = 0 for _ in range(n): cons = 0 grid.append(input().strip()) for ch in grid[-1]: if ch == '.': cons += 1 else: ans += max(0, cons-k+1) cons = 0 ans += max(0, cons-k+1) cons = 0 for i in range(m): cons = 0 for j in range(n): ch = grid[j][i] if ch == '.': cons += 1 else: ans += max(0, cons-k+1) cons = 0 ans += max(0, cons-k+1) if k == 1: ans //=2 print(ans) ```
output
1
48,516
14
97,033
Provide tags and a correct Python 3 solution for this coding contest problem. Suppose that you are in a campus and have to go for classes day by day. As you may see, when you hurry to a classroom, you surprisingly find that many seats there are already occupied. Today you and your friends went for class, and found out that some of the seats were occupied. The classroom contains n rows of seats and there are m seats in each row. Then the classroom can be represented as an n × m matrix. The character '.' represents an empty seat, while '*' means that the seat is occupied. You need to find k consecutive empty seats in the same row or column and arrange those seats for you and your friends. Your task is to find the number of ways to arrange the seats. Two ways are considered different if sets of places that students occupy differs. Input The first line contains three positive integers n,m,k (1 ≤ n, m, k ≤ 2 000), where n,m represent the sizes of the classroom and k is the number of consecutive seats you need to find. Each of the next n lines contains m characters '.' or '*'. They form a matrix representing the classroom, '.' denotes an empty seat, and '*' denotes an occupied seat. Output A single number, denoting the number of ways to find k empty seats in the same row or column. Examples Input 2 3 2 **. ... Output 3 Input 1 2 2 .. Output 1 Input 3 3 4 .*. *.* .*. Output 0 Note In the first sample, there are three ways to arrange those seats. You can take the following seats for your arrangement. * (1,3), (2,3) * (2,2), (2,3) * (2,1), (2,2)
instruction
0
48,517
14
97,034
Tags: brute force, implementation Correct Solution: ``` n,m,k=map(int,input().split()) M=[input() for i in range(n)] ans=0 for i in range(n): res=0 for j in range(m): if M[i][j]=='.': res+=1 if res>=k: ans+=1 else: res=0 for j in range(m): ress=0 for i in range(n): if M[i][j]=='.': ress+=1 if ress>=k: ans+=1 else: ress=0 print(ans if k>1 else ans//2) ```
output
1
48,517
14
97,035
Provide tags and a correct Python 3 solution for this coding contest problem. Suppose that you are in a campus and have to go for classes day by day. As you may see, when you hurry to a classroom, you surprisingly find that many seats there are already occupied. Today you and your friends went for class, and found out that some of the seats were occupied. The classroom contains n rows of seats and there are m seats in each row. Then the classroom can be represented as an n × m matrix. The character '.' represents an empty seat, while '*' means that the seat is occupied. You need to find k consecutive empty seats in the same row or column and arrange those seats for you and your friends. Your task is to find the number of ways to arrange the seats. Two ways are considered different if sets of places that students occupy differs. Input The first line contains three positive integers n,m,k (1 ≤ n, m, k ≤ 2 000), where n,m represent the sizes of the classroom and k is the number of consecutive seats you need to find. Each of the next n lines contains m characters '.' or '*'. They form a matrix representing the classroom, '.' denotes an empty seat, and '*' denotes an occupied seat. Output A single number, denoting the number of ways to find k empty seats in the same row or column. Examples Input 2 3 2 **. ... Output 3 Input 1 2 2 .. Output 1 Input 3 3 4 .*. *.* .*. Output 0 Note In the first sample, there are three ways to arrange those seats. You can take the following seats for your arrangement. * (1,3), (2,3) * (2,2), (2,3) * (2,1), (2,2)
instruction
0
48,518
14
97,036
Tags: brute force, implementation Correct Solution: ``` from collections import Counter import string import math import sys # sys.setrecursionlimit(10**6) from fractions import Fraction def array_int(): return [int(i) for i in sys.stdin.readline().split()] def vary(arrber_of_variables): if arrber_of_variables==1: return int(sys.stdin.readline()) if arrber_of_variables>=2: return map(int,sys.stdin.readline().split()) def makedict(var): return dict(Counter(var)) testcases=1 for _ in range(testcases): n,m,k=vary(3) arr=[] for i in range(n): arr.append([i for i in input()]) # print(arr) rows=0 columns=0 i=0 while i<n: j=0 c=0 while j<m: if arr[i][j]=='.': c+=1 else: rows+=(c-k+1 if c>=k else 0) c=0 j+=1 rows+=(c-k+1 if c>=k else 0) i+=1 i=0 while i<m: j=0 c=0 while j<n: if arr[j][i]=='.': c+=1 else: columns+=(c-k+1 if c>=k else 0) c=0 j+=1 columns+=(c-k+1 if c>=k else 0) i+=1 # print(rows,columns) if k==1: print(rows) else: print(rows+columns) ```
output
1
48,518
14
97,037
Provide tags and a correct Python 3 solution for this coding contest problem. Suppose that you are in a campus and have to go for classes day by day. As you may see, when you hurry to a classroom, you surprisingly find that many seats there are already occupied. Today you and your friends went for class, and found out that some of the seats were occupied. The classroom contains n rows of seats and there are m seats in each row. Then the classroom can be represented as an n × m matrix. The character '.' represents an empty seat, while '*' means that the seat is occupied. You need to find k consecutive empty seats in the same row or column and arrange those seats for you and your friends. Your task is to find the number of ways to arrange the seats. Two ways are considered different if sets of places that students occupy differs. Input The first line contains three positive integers n,m,k (1 ≤ n, m, k ≤ 2 000), where n,m represent the sizes of the classroom and k is the number of consecutive seats you need to find. Each of the next n lines contains m characters '.' or '*'. They form a matrix representing the classroom, '.' denotes an empty seat, and '*' denotes an occupied seat. Output A single number, denoting the number of ways to find k empty seats in the same row or column. Examples Input 2 3 2 **. ... Output 3 Input 1 2 2 .. Output 1 Input 3 3 4 .*. *.* .*. Output 0 Note In the first sample, there are three ways to arrange those seats. You can take the following seats for your arrangement. * (1,3), (2,3) * (2,2), (2,3) * (2,1), (2,2)
instruction
0
48,519
14
97,038
Tags: brute force, implementation Correct Solution: ``` n, m, k = map(int, input().split()) a = [[0] * m for x in range(n)] s = [] count = 0 for i in range(n): s.append(input()) for i in range(n): y = 0 for j in range(m): if s[i][j] == ".": if(a[i][j] + 1 >= k and k > 1): count += 1 y +=1 if y >= k: count += 1 if i + 1 < n: a[i + 1][j] = a[i][j] + 1 else: y = 0 print(count) ```
output
1
48,519
14
97,039
Provide tags and a correct Python 3 solution for this coding contest problem. Suppose that you are in a campus and have to go for classes day by day. As you may see, when you hurry to a classroom, you surprisingly find that many seats there are already occupied. Today you and your friends went for class, and found out that some of the seats were occupied. The classroom contains n rows of seats and there are m seats in each row. Then the classroom can be represented as an n × m matrix. The character '.' represents an empty seat, while '*' means that the seat is occupied. You need to find k consecutive empty seats in the same row or column and arrange those seats for you and your friends. Your task is to find the number of ways to arrange the seats. Two ways are considered different if sets of places that students occupy differs. Input The first line contains three positive integers n,m,k (1 ≤ n, m, k ≤ 2 000), where n,m represent the sizes of the classroom and k is the number of consecutive seats you need to find. Each of the next n lines contains m characters '.' or '*'. They form a matrix representing the classroom, '.' denotes an empty seat, and '*' denotes an occupied seat. Output A single number, denoting the number of ways to find k empty seats in the same row or column. Examples Input 2 3 2 **. ... Output 3 Input 1 2 2 .. Output 1 Input 3 3 4 .*. *.* .*. Output 0 Note In the first sample, there are three ways to arrange those seats. You can take the following seats for your arrangement. * (1,3), (2,3) * (2,2), (2,3) * (2,1), (2,2)
instruction
0
48,520
14
97,040
Tags: brute force, implementation Correct Solution: ``` import sys input = sys.stdin.readline ins = lambda: input().rstrip() ini = lambda: int(input().rstrip()) inm = lambda: map(int, input().rstrip().split()) inl = lambda: list(map(int, input().split())) out = lambda x, s='\n': print(s.join(map(str, x))) n, m, k = inm() ans = 0 col = [0] * m for _ in range(n): s = ins() count = 0 for i in range(m): if s[i] == ".": count += 1 col[i] += 1 if count >= k: ans += 1 if n == 1 or k == 1: continue if col[i] >= k: ans += 1 else: count = 0 col[i] = 0 # print(ans if k != 1 else ans // 2) print(ans) ```
output
1
48,520
14
97,041
Provide tags and a correct Python 3 solution for this coding contest problem. Suppose that you are in a campus and have to go for classes day by day. As you may see, when you hurry to a classroom, you surprisingly find that many seats there are already occupied. Today you and your friends went for class, and found out that some of the seats were occupied. The classroom contains n rows of seats and there are m seats in each row. Then the classroom can be represented as an n × m matrix. The character '.' represents an empty seat, while '*' means that the seat is occupied. You need to find k consecutive empty seats in the same row or column and arrange those seats for you and your friends. Your task is to find the number of ways to arrange the seats. Two ways are considered different if sets of places that students occupy differs. Input The first line contains three positive integers n,m,k (1 ≤ n, m, k ≤ 2 000), where n,m represent the sizes of the classroom and k is the number of consecutive seats you need to find. Each of the next n lines contains m characters '.' or '*'. They form a matrix representing the classroom, '.' denotes an empty seat, and '*' denotes an occupied seat. Output A single number, denoting the number of ways to find k empty seats in the same row or column. Examples Input 2 3 2 **. ... Output 3 Input 1 2 2 .. Output 1 Input 3 3 4 .*. *.* .*. Output 0 Note In the first sample, there are three ways to arrange those seats. You can take the following seats for your arrangement. * (1,3), (2,3) * (2,2), (2,3) * (2,1), (2,2)
instruction
0
48,521
14
97,042
Tags: brute force, implementation Correct Solution: ``` import sys import math import bisect def solve(A, k): n = len(A) m = len(A[0]) B = [] for i in range(n): B.append([0] * m) C = [] for i in range(n): C.append([0] * m) for i in range(n): for j in range(m): if i == 0: if A[i][j] == '.': B[i][j] = 1 else: if A[i][j] == '.': B[i][j] = 1 + B[i-1][j] for i in range(n): for j in range(m): if j == 0: if A[i][j] == '.': C[i][j] = 1 else: if A[i][j] == '.': C[i][j] = 1 + C[i][j-1] ans = 0 for i in range(n): for j in range(m): if B[i][j] >= k: ans += 1 if k > 1 and C[i][j] >= k: ans += 1 ''' for i in range(n): print('B[%d]: %s' % (i, str(B[i]))) for i in range(n): print('C[%d]: %s' % (i, str(C[i]))) ''' return ans def main(): n, m, k = map(int, input().split()) A = [] for i in range(n): A.append(input()) ans = solve(A, k) print(ans) if __name__ == "__main__": main() ```
output
1
48,521
14
97,043
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Suppose that you are in a campus and have to go for classes day by day. As you may see, when you hurry to a classroom, you surprisingly find that many seats there are already occupied. Today you and your friends went for class, and found out that some of the seats were occupied. The classroom contains n rows of seats and there are m seats in each row. Then the classroom can be represented as an n × m matrix. The character '.' represents an empty seat, while '*' means that the seat is occupied. You need to find k consecutive empty seats in the same row or column and arrange those seats for you and your friends. Your task is to find the number of ways to arrange the seats. Two ways are considered different if sets of places that students occupy differs. Input The first line contains three positive integers n,m,k (1 ≤ n, m, k ≤ 2 000), where n,m represent the sizes of the classroom and k is the number of consecutive seats you need to find. Each of the next n lines contains m characters '.' or '*'. They form a matrix representing the classroom, '.' denotes an empty seat, and '*' denotes an occupied seat. Output A single number, denoting the number of ways to find k empty seats in the same row or column. Examples Input 2 3 2 **. ... Output 3 Input 1 2 2 .. Output 1 Input 3 3 4 .*. *.* .*. Output 0 Note In the first sample, there are three ways to arrange those seats. You can take the following seats for your arrangement. * (1,3), (2,3) * (2,2), (2,3) * (2,1), (2,2) Submitted Solution: ``` y,x,k=map(int,input().split()) m=[];ans=0 for i in range(y): m.append(list(input())) e=0 for z in m[i]: if z=='.': e+=1 else: ans+=max(0,e-k+1) e=0 ans+=max(0,e-k+1) if k-1: for j in range(x): e=0 for i in range(y): if m[i][j]=='.': e+=1 else: ans+=max(0,e-k+1) e=0 ans+=max(0,e-k+1) print(ans) ```
instruction
0
48,522
14
97,044
Yes
output
1
48,522
14
97,045
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Suppose that you are in a campus and have to go for classes day by day. As you may see, when you hurry to a classroom, you surprisingly find that many seats there are already occupied. Today you and your friends went for class, and found out that some of the seats were occupied. The classroom contains n rows of seats and there are m seats in each row. Then the classroom can be represented as an n × m matrix. The character '.' represents an empty seat, while '*' means that the seat is occupied. You need to find k consecutive empty seats in the same row or column and arrange those seats for you and your friends. Your task is to find the number of ways to arrange the seats. Two ways are considered different if sets of places that students occupy differs. Input The first line contains three positive integers n,m,k (1 ≤ n, m, k ≤ 2 000), where n,m represent the sizes of the classroom and k is the number of consecutive seats you need to find. Each of the next n lines contains m characters '.' or '*'. They form a matrix representing the classroom, '.' denotes an empty seat, and '*' denotes an occupied seat. Output A single number, denoting the number of ways to find k empty seats in the same row or column. Examples Input 2 3 2 **. ... Output 3 Input 1 2 2 .. Output 1 Input 3 3 4 .*. *.* .*. Output 0 Note In the first sample, there are three ways to arrange those seats. You can take the following seats for your arrangement. * (1,3), (2,3) * (2,2), (2,3) * (2,1), (2,2) Submitted Solution: ``` if __name__ == '__main__': n, m, k = [int(__) for __ in input().strip().split()] arr = [] ans = 0 for _ in range(n): arr.append(list(input().strip())) if k == 1: ans = 0 for x in arr: ans += x.count('.') print(ans) exit(0) if n == 1 and m == 1 and k == 1: if arr[0][0] == '.': print(1) else: print(0) else: for i in range(n): j = 0 count = 0 while j < m: if arr[i][j] == '.': count += 1 else: if count >= k: ans += count - k + 1 count = 0 j += 1 if count >= k: ans += count - k + 1 for i in range(m): j = 0 count = 0 while j < n: if arr[j][i] == '.': count += 1 else: if count >= k: ans += count - k + 1 count = 0 j += 1 if count >= k: ans += count - k + 1 print(ans) ```
instruction
0
48,523
14
97,046
Yes
output
1
48,523
14
97,047
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Suppose that you are in a campus and have to go for classes day by day. As you may see, when you hurry to a classroom, you surprisingly find that many seats there are already occupied. Today you and your friends went for class, and found out that some of the seats were occupied. The classroom contains n rows of seats and there are m seats in each row. Then the classroom can be represented as an n × m matrix. The character '.' represents an empty seat, while '*' means that the seat is occupied. You need to find k consecutive empty seats in the same row or column and arrange those seats for you and your friends. Your task is to find the number of ways to arrange the seats. Two ways are considered different if sets of places that students occupy differs. Input The first line contains three positive integers n,m,k (1 ≤ n, m, k ≤ 2 000), where n,m represent the sizes of the classroom and k is the number of consecutive seats you need to find. Each of the next n lines contains m characters '.' or '*'. They form a matrix representing the classroom, '.' denotes an empty seat, and '*' denotes an occupied seat. Output A single number, denoting the number of ways to find k empty seats in the same row or column. Examples Input 2 3 2 **. ... Output 3 Input 1 2 2 .. Output 1 Input 3 3 4 .*. *.* .*. Output 0 Note In the first sample, there are three ways to arrange those seats. You can take the following seats for your arrangement. * (1,3), (2,3) * (2,2), (2,3) * (2,1), (2,2) Submitted Solution: ``` for _ in range(1): n,m,k=map(int,input().split()) l=[] for i in range(n): l.append(list(input())) ans=0 for i in range(n): j=0 c=0 while(j<m): if l[i][j]==".": c+=1 else: if c>=k: ans+=(c-k+1) c=0 j+=1 if c>=k: ans+=(c-k+1) for a in range(m): b=0 d=0 while(b<n): if l[b][a]==".": d+=1 else: if d>=k: ans+=(d-k+1) d=0 b+=1 if d>=k: ans+=(d-k+1) if k==1: ans=ans//2 print(ans) ```
instruction
0
48,524
14
97,048
Yes
output
1
48,524
14
97,049
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Suppose that you are in a campus and have to go for classes day by day. As you may see, when you hurry to a classroom, you surprisingly find that many seats there are already occupied. Today you and your friends went for class, and found out that some of the seats were occupied. The classroom contains n rows of seats and there are m seats in each row. Then the classroom can be represented as an n × m matrix. The character '.' represents an empty seat, while '*' means that the seat is occupied. You need to find k consecutive empty seats in the same row or column and arrange those seats for you and your friends. Your task is to find the number of ways to arrange the seats. Two ways are considered different if sets of places that students occupy differs. Input The first line contains three positive integers n,m,k (1 ≤ n, m, k ≤ 2 000), where n,m represent the sizes of the classroom and k is the number of consecutive seats you need to find. Each of the next n lines contains m characters '.' or '*'. They form a matrix representing the classroom, '.' denotes an empty seat, and '*' denotes an occupied seat. Output A single number, denoting the number of ways to find k empty seats in the same row or column. Examples Input 2 3 2 **. ... Output 3 Input 1 2 2 .. Output 1 Input 3 3 4 .*. *.* .*. Output 0 Note In the first sample, there are three ways to arrange those seats. You can take the following seats for your arrangement. * (1,3), (2,3) * (2,2), (2,3) * (2,1), (2,2) Submitted Solution: ``` import re n, m, k = [int(x) for x in input().split()] s = [input() for _ in range(n)] print(sum([sum(len(x) - k + 1 for x in re.compile(r"\.{" + str(k) + ",}").findall(i)) for i in (s + ["".join(x) for x in zip(*s)] if n > 1 and k > 1 else s)])) ```
instruction
0
48,525
14
97,050
Yes
output
1
48,525
14
97,051
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Suppose that you are in a campus and have to go for classes day by day. As you may see, when you hurry to a classroom, you surprisingly find that many seats there are already occupied. Today you and your friends went for class, and found out that some of the seats were occupied. The classroom contains n rows of seats and there are m seats in each row. Then the classroom can be represented as an n × m matrix. The character '.' represents an empty seat, while '*' means that the seat is occupied. You need to find k consecutive empty seats in the same row or column and arrange those seats for you and your friends. Your task is to find the number of ways to arrange the seats. Two ways are considered different if sets of places that students occupy differs. Input The first line contains three positive integers n,m,k (1 ≤ n, m, k ≤ 2 000), where n,m represent the sizes of the classroom and k is the number of consecutive seats you need to find. Each of the next n lines contains m characters '.' or '*'. They form a matrix representing the classroom, '.' denotes an empty seat, and '*' denotes an occupied seat. Output A single number, denoting the number of ways to find k empty seats in the same row or column. Examples Input 2 3 2 **. ... Output 3 Input 1 2 2 .. Output 1 Input 3 3 4 .*. *.* .*. Output 0 Note In the first sample, there are three ways to arrange those seats. You can take the following seats for your arrangement. * (1,3), (2,3) * (2,2), (2,3) * (2,1), (2,2) Submitted Solution: ``` import sys import math import bisect def solve(A, k): n = len(A) m = len(A[0]) B = [] for i in range(n): B.append([0] * m) C = [] for i in range(n): C.append([0] * m) for i in range(n): for j in range(m): if i == 0: if A[i][j] == '.': B[i][j] = 1 else: if A[i][j] == '.': B[i][j] = 1 + B[i-1][j] for i in range(n): for j in range(m): if j == 0: if A[i][j] == '.': C[i][j] = 1 else: if A[i][j] == '.': C[i][j] = 1 + C[i][j-1] ans = 0 for i in range(n): for j in range(m): if B[i][j] >= k: ans += 1 if C[i][j] >= k: ans += 1 ''' for i in range(n): print('B[%d]: %s' % (i, str(B[i]))) for i in range(n): print('C[%d]: %s' % (i, str(C[i]))) ''' return ans def main(): n, m, k = map(int, input().split()) A = [] for i in range(n): A.append(input()) ans = solve(A, k) print(ans) if __name__ == "__main__": main() ```
instruction
0
48,526
14
97,052
No
output
1
48,526
14
97,053
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Suppose that you are in a campus and have to go for classes day by day. As you may see, when you hurry to a classroom, you surprisingly find that many seats there are already occupied. Today you and your friends went for class, and found out that some of the seats were occupied. The classroom contains n rows of seats and there are m seats in each row. Then the classroom can be represented as an n × m matrix. The character '.' represents an empty seat, while '*' means that the seat is occupied. You need to find k consecutive empty seats in the same row or column and arrange those seats for you and your friends. Your task is to find the number of ways to arrange the seats. Two ways are considered different if sets of places that students occupy differs. Input The first line contains three positive integers n,m,k (1 ≤ n, m, k ≤ 2 000), where n,m represent the sizes of the classroom and k is the number of consecutive seats you need to find. Each of the next n lines contains m characters '.' or '*'. They form a matrix representing the classroom, '.' denotes an empty seat, and '*' denotes an occupied seat. Output A single number, denoting the number of ways to find k empty seats in the same row or column. Examples Input 2 3 2 **. ... Output 3 Input 1 2 2 .. Output 1 Input 3 3 4 .*. *.* .*. Output 0 Note In the first sample, there are three ways to arrange those seats. You can take the following seats for your arrangement. * (1,3), (2,3) * (2,2), (2,3) * (2,1), (2,2) Submitted Solution: ``` from itertools import groupby n, m, k = map(int, input().split()) seats = [] res = 0 for _ in range(n): seats.append(input()) for key, group in groupby(seats[-1]): if key == '.': l = len(list(group)) if l >= k: res += l - k + 1 for j in range(m): g = [] for i in range(n): g.append(seats[i][j]) for key, group in groupby(g): if key == '.': l = len(list(group)) if l >= k: res += l - k + 1 if n == 1 and m == 1 and k == 1: print(1) if seats[0][0] == '.' else print(0) else: print(res) ```
instruction
0
48,527
14
97,054
No
output
1
48,527
14
97,055
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Suppose that you are in a campus and have to go for classes day by day. As you may see, when you hurry to a classroom, you surprisingly find that many seats there are already occupied. Today you and your friends went for class, and found out that some of the seats were occupied. The classroom contains n rows of seats and there are m seats in each row. Then the classroom can be represented as an n × m matrix. The character '.' represents an empty seat, while '*' means that the seat is occupied. You need to find k consecutive empty seats in the same row or column and arrange those seats for you and your friends. Your task is to find the number of ways to arrange the seats. Two ways are considered different if sets of places that students occupy differs. Input The first line contains three positive integers n,m,k (1 ≤ n, m, k ≤ 2 000), where n,m represent the sizes of the classroom and k is the number of consecutive seats you need to find. Each of the next n lines contains m characters '.' or '*'. They form a matrix representing the classroom, '.' denotes an empty seat, and '*' denotes an occupied seat. Output A single number, denoting the number of ways to find k empty seats in the same row or column. Examples Input 2 3 2 **. ... Output 3 Input 1 2 2 .. Output 1 Input 3 3 4 .*. *.* .*. Output 0 Note In the first sample, there are three ways to arrange those seats. You can take the following seats for your arrangement. * (1,3), (2,3) * (2,2), (2,3) * (2,1), (2,2) Submitted Solution: ``` n,m,k=map(int,input().split()) arr=[] for i in range(n): s=str(input()) arr.append(s) ans=0 for i in range(n): count=0 for j in range(m): if(arr[i][j]=='*'): if(count>=k): ans+=(count-k+1) count=0 else: count+=1 if(count>=k): ans+=(count-k+1) for i in range(m): count=0 for j in range(n): if(arr[j][i]=='*'): if(count>=k): ans+=(count-k+1) count=0 else: count+=1 if(count>=k): ans+=(count-k+1) print(ans) ```
instruction
0
48,528
14
97,056
No
output
1
48,528
14
97,057
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Suppose that you are in a campus and have to go for classes day by day. As you may see, when you hurry to a classroom, you surprisingly find that many seats there are already occupied. Today you and your friends went for class, and found out that some of the seats were occupied. The classroom contains n rows of seats and there are m seats in each row. Then the classroom can be represented as an n × m matrix. The character '.' represents an empty seat, while '*' means that the seat is occupied. You need to find k consecutive empty seats in the same row or column and arrange those seats for you and your friends. Your task is to find the number of ways to arrange the seats. Two ways are considered different if sets of places that students occupy differs. Input The first line contains three positive integers n,m,k (1 ≤ n, m, k ≤ 2 000), where n,m represent the sizes of the classroom and k is the number of consecutive seats you need to find. Each of the next n lines contains m characters '.' or '*'. They form a matrix representing the classroom, '.' denotes an empty seat, and '*' denotes an occupied seat. Output A single number, denoting the number of ways to find k empty seats in the same row or column. Examples Input 2 3 2 **. ... Output 3 Input 1 2 2 .. Output 1 Input 3 3 4 .*. *.* .*. Output 0 Note In the first sample, there are three ways to arrange those seats. You can take the following seats for your arrangement. * (1,3), (2,3) * (2,2), (2,3) * (2,1), (2,2) Submitted Solution: ``` from sys import stdin a,b,c=map(int,stdin.readline().split()) d=[0]*b;s=0 for _ in " "*a: z=stdin.readline() k=0 for i in range(b): if z[i]=='.':d[i]+=1;k+=1 else:s+=max(d[i]-c+1,0);s+=max(k-c+1,0);k=0;d[i]=0 if c!=1:s+=max(k-c+1,0) for i in range(b):s+=max(d[i]-c+1,0) print(s) ```
instruction
0
48,529
14
97,058
No
output
1
48,529
14
97,059
Provide a correct Python 3 solution for this coding contest problem. Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet. Constraints * All values in input are integers. * 2 \leq n \leq 10^9 * 1 \leq a < b \leq \textrm{min}(n, 2 \times 10^5) Input Input is given from Standard Input in the following format: n a b Output Print the number of bouquets that Akari can make, modulo (10^9 + 7). (If there are no such bouquets, print `0`.) Examples Input 4 1 3 Output 7 Input 1000000000 141421 173205 Output 34076506
instruction
0
48,558
14
97,116
"Correct Solution: ``` n,a,b = map(int,input().split()) mod = 10**9+7 def comb(n,r): u = 1 d = 1 for i in range(n-r+1,n+1): u = u*i%mod for i in range(1,r+1): d = d*i%mod D = pow(d,mod-2,mod) return u*D%mod ans = pow(2,n,mod)-1-comb(n,a)-comb(n,b) print(ans%mod) ```
output
1
48,558
14
97,117
Provide a correct Python 3 solution for this coding contest problem. Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet. Constraints * All values in input are integers. * 2 \leq n \leq 10^9 * 1 \leq a < b \leq \textrm{min}(n, 2 \times 10^5) Input Input is given from Standard Input in the following format: n a b Output Print the number of bouquets that Akari can make, modulo (10^9 + 7). (If there are no such bouquets, print `0`.) Examples Input 4 1 3 Output 7 Input 1000000000 141421 173205 Output 34076506
instruction
0
48,559
14
97,118
"Correct Solution: ``` n, a, b = map(int, input().split()) mod = 10 ** 9 + 7 ans = pow(2, n, mod) - 1 nca, ncb = 1, 1 for i in range(b): ncb = ncb * (n - i) % mod ncb *= pow(i + 1, mod - 2, mod) if i + 1 == a: nca = ncb print((ans - (nca + ncb)) % mod) ```
output
1
48,559
14
97,119
Provide a correct Python 3 solution for this coding contest problem. Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet. Constraints * All values in input are integers. * 2 \leq n \leq 10^9 * 1 \leq a < b \leq \textrm{min}(n, 2 \times 10^5) Input Input is given from Standard Input in the following format: n a b Output Print the number of bouquets that Akari can make, modulo (10^9 + 7). (If there are no such bouquets, print `0`.) Examples Input 4 1 3 Output 7 Input 1000000000 141421 173205 Output 34076506
instruction
0
48,560
14
97,120
"Correct Solution: ``` n, a, b = map(int, input().split()) mod = 10 ** 9 + 7 s = pow(2, n, mod) - 1 def comb(n, r): p, q = 1, 1 for i in range(r): p = p * (n - i) % mod q = q * (i + 1) % mod return p * pow(q, mod - 2, mod) % mod print((s - comb(n, a) - comb(n, b))%mod) ```
output
1
48,560
14
97,121
Provide a correct Python 3 solution for this coding contest problem. Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet. Constraints * All values in input are integers. * 2 \leq n \leq 10^9 * 1 \leq a < b \leq \textrm{min}(n, 2 \times 10^5) Input Input is given from Standard Input in the following format: n a b Output Print the number of bouquets that Akari can make, modulo (10^9 + 7). (If there are no such bouquets, print `0`.) Examples Input 4 1 3 Output 7 Input 1000000000 141421 173205 Output 34076506
instruction
0
48,561
14
97,122
"Correct Solution: ``` from functools import reduce n,a,b=map(int,input().split()) def nCr(N,R,DIV): f=lambda x,y:x*y%DIV X=reduce(f,range(N-R+1,N+1)) Y=reduce(f,range(1,R+1)) return X*pow(Y,DIV-2,DIV)%DIV DIV=10**9+7 ans=pow(2,n,DIV)-1 ans-=nCr(n,a,DIV) ans-=nCr(n,b,DIV) print(ans%DIV) ```
output
1
48,561
14
97,123
Provide a correct Python 3 solution for this coding contest problem. Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet. Constraints * All values in input are integers. * 2 \leq n \leq 10^9 * 1 \leq a < b \leq \textrm{min}(n, 2 \times 10^5) Input Input is given from Standard Input in the following format: n a b Output Print the number of bouquets that Akari can make, modulo (10^9 + 7). (If there are no such bouquets, print `0`.) Examples Input 4 1 3 Output 7 Input 1000000000 141421 173205 Output 34076506
instruction
0
48,562
14
97,124
"Correct Solution: ``` import math n,a,b = [int(i) for i in input().split()] mod = 10**9+7 def comb(n,k): ans = 1 for i in range(k): ans = ans*(n-i)%mod for i in range(1,k+1): ans = ans*pow(i,mod-2,mod)%mod return ans print((pow(2,n,mod)-1-comb(n,a)-comb(n,b))%mod) # print(comb(n,a)) ```
output
1
48,562
14
97,125
Provide a correct Python 3 solution for this coding contest problem. Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet. Constraints * All values in input are integers. * 2 \leq n \leq 10^9 * 1 \leq a < b \leq \textrm{min}(n, 2 \times 10^5) Input Input is given from Standard Input in the following format: n a b Output Print the number of bouquets that Akari can make, modulo (10^9 + 7). (If there are no such bouquets, print `0`.) Examples Input 4 1 3 Output 7 Input 1000000000 141421 173205 Output 34076506
instruction
0
48,563
14
97,126
"Correct Solution: ``` s=list(map(int,input().split())) ans=0 ad=1 mod=10**9+7 def comb(x): a=b=1 for i in range(x): a=a*(s[0]-i)%mod b=b*(i+1)%mod return a*pow(b,mod-2,mod)%mod ans=pow(2,s[0],mod) print((ans-1-comb(s[1])-comb(s[2]))%mod) ```
output
1
48,563
14
97,127
Provide a correct Python 3 solution for this coding contest problem. Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet. Constraints * All values in input are integers. * 2 \leq n \leq 10^9 * 1 \leq a < b \leq \textrm{min}(n, 2 \times 10^5) Input Input is given from Standard Input in the following format: n a b Output Print the number of bouquets that Akari can make, modulo (10^9 + 7). (If there are no such bouquets, print `0`.) Examples Input 4 1 3 Output 7 Input 1000000000 141421 173205 Output 34076506
instruction
0
48,564
14
97,128
"Correct Solution: ``` m = 10**9+7 n,a,b = map(int,input().split()) def c(k): v = 1 w = 1 for i in range(k): v = v*(n-i)%m #n*(n-1)*...*(n-k+1) 分子 w = w*(i+1)%m #1*2*...*k 分母 #pow(w,m-2,m)はmod mの世界でのwの逆元 return (v*pow(w,m-2,m)%m) print((pow(2,n,m)-1-c(a)-c(b))%m) ```
output
1
48,564
14
97,129
Provide a correct Python 3 solution for this coding contest problem. Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet. Constraints * All values in input are integers. * 2 \leq n \leq 10^9 * 1 \leq a < b \leq \textrm{min}(n, 2 \times 10^5) Input Input is given from Standard Input in the following format: n a b Output Print the number of bouquets that Akari can make, modulo (10^9 + 7). (If there are no such bouquets, print `0`.) Examples Input 4 1 3 Output 7 Input 1000000000 141421 173205 Output 34076506
instruction
0
48,565
14
97,130
"Correct Solution: ``` import itertools import math n,a,b = map(int,input().split()) mod = 10**9+7 def comb(n, r): ans = 1 for i in range(r): ans = ans * (n-i) * pow(i+1, mod-2, mod) % mod return ans print((pow(2, n, mod)-1-comb(n,a)-comb(n,b)) % mod) ```
output
1
48,565
14
97,131
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet. Constraints * All values in input are integers. * 2 \leq n \leq 10^9 * 1 \leq a < b \leq \textrm{min}(n, 2 \times 10^5) Input Input is given from Standard Input in the following format: n a b Output Print the number of bouquets that Akari can make, modulo (10^9 + 7). (If there are no such bouquets, print `0`.) Examples Input 4 1 3 Output 7 Input 1000000000 141421 173205 Output 34076506 Submitted Solution: ``` def MI(): return map(int, input().split()) MOD=10**9+7 def nCr(n,k): tmp=1 for i in range(n-k+1,n+1): tmp*=i tmp%=MOD for i in range(1,k+1): tmp*=pow(i,MOD-2,MOD) tmp%=MOD return tmp N,A,B=MI() ans=pow(2,N,MOD)-1-nCr(N,A)-nCr(N,B) print(ans%MOD) ```
instruction
0
48,566
14
97,132
Yes
output
1
48,566
14
97,133
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet. Constraints * All values in input are integers. * 2 \leq n \leq 10^9 * 1 \leq a < b \leq \textrm{min}(n, 2 \times 10^5) Input Input is given from Standard Input in the following format: n a b Output Print the number of bouquets that Akari can make, modulo (10^9 + 7). (If there are no such bouquets, print `0`.) Examples Input 4 1 3 Output 7 Input 1000000000 141421 173205 Output 34076506 Submitted Solution: ``` def cmb(n,r,mod): p,q=1,1 if r>n/2: r=n-r for i in range(r): p*=n-i p%=mod q*=i+1 q%=mod return (p*pow(q,mod-2,mod))%mod n,a,b=map(int,input().split()) mod=10**9+7 v=pow(2,n,mod)-1 print((v-cmb(n,a,mod)-cmb(n,b,mod))%mod) ```
instruction
0
48,567
14
97,134
Yes
output
1
48,567
14
97,135
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet. Constraints * All values in input are integers. * 2 \leq n \leq 10^9 * 1 \leq a < b \leq \textrm{min}(n, 2 \times 10^5) Input Input is given from Standard Input in the following format: n a b Output Print the number of bouquets that Akari can make, modulo (10^9 + 7). (If there are no such bouquets, print `0`.) Examples Input 4 1 3 Output 7 Input 1000000000 141421 173205 Output 34076506 Submitted Solution: ``` n,a,b=map(int,input().split()) mod = 10**9+7 def cmb(n,r): c=1 for i in range(r): c = (c*(n-i)*pow(i+1,mod-2,mod))%mod return c na = cmb(n,a) nb = cmb(n,b) print((pow(2,n,mod)-1-na-nb)%mod) ```
instruction
0
48,568
14
97,136
Yes
output
1
48,568
14
97,137
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet. Constraints * All values in input are integers. * 2 \leq n \leq 10^9 * 1 \leq a < b \leq \textrm{min}(n, 2 \times 10^5) Input Input is given from Standard Input in the following format: n a b Output Print the number of bouquets that Akari can make, modulo (10^9 + 7). (If there are no such bouquets, print `0`.) Examples Input 4 1 3 Output 7 Input 1000000000 141421 173205 Output 34076506 Submitted Solution: ``` M=10**9+7 n,a,b=map(int,input().split()) s=r=1 for i in range(b):r=r*(n-i)*pow(i+1,M-2,M)%M;s+=r*(i+1==a) print((pow(2,n,M)-s-r)%M) ```
instruction
0
48,569
14
97,138
Yes
output
1
48,569
14
97,139
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet. Constraints * All values in input are integers. * 2 \leq n \leq 10^9 * 1 \leq a < b \leq \textrm{min}(n, 2 \times 10^5) Input Input is given from Standard Input in the following format: n a b Output Print the number of bouquets that Akari can make, modulo (10^9 + 7). (If there are no such bouquets, print `0`.) Examples Input 4 1 3 Output 7 Input 1000000000 141421 173205 Output 34076506 Submitted Solution: ``` class Factorial: def __init__(self, n, mod=10**9+7): self.fac = [0] * (n+1) self.ifac = [0] * (n+1) self.fac[0] = 1 self.ifac[0] = 1 self.mod = mod modmod = self.mod - 2 for i in range(n): self.fac[i+1] = self.fac[i] * (i+1) % self.mod self.ifac[i+1] = self.ifac[i] * pow(i+1, modmod, self.mod) % self.mod def comb(self, n, r): if n == 0 and r == 0: return 1 if n < r or n < 0: return 0 tmp = self.ifac[n-r] * self.ifac[r] % self.mod return tmp * self.fac[n] % self.mod def perm(self, n, r): if n == 0 and r == 0: return 1 if n < r or n < 0: return 0 return (self.fac[n] * self.ifac[n-r]) % self.mod N, a, b = map(int,input().split()) mod = 10**9+7 fact = Factorial(N) sum = 0 for i in range(N) : sum = (sum + fact.comb(N,i)) % mod sum = (sum - fact.comb(N,a) - fact.comb(N,b)) % mod print(sum) ```
instruction
0
48,570
14
97,140
No
output
1
48,570
14
97,141
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet. Constraints * All values in input are integers. * 2 \leq n \leq 10^9 * 1 \leq a < b \leq \textrm{min}(n, 2 \times 10^5) Input Input is given from Standard Input in the following format: n a b Output Print the number of bouquets that Akari can make, modulo (10^9 + 7). (If there are no such bouquets, print `0`.) Examples Input 4 1 3 Output 7 Input 1000000000 141421 173205 Output 34076506 Submitted Solution: ``` import scipy.misc s = input().split() n = int(s[0]) a = int(s[1]) b = int(s[2]) ans =0 if n%2 ==0: for i in range(int((n+1)/2)): if i ==0: continue ans = ans + scipy.misc.comb(n,i, exact = True) ans = ans*2 +scipy.misc.comb(n,int(n/2), exact = True) -scipy.misc.comb(n,a, exact = True) -scipy.misc.comb(n,b, exact = True) +1 else: for k in range(int(n/2)): if k ==0: continue ans = ans + scipy.misc.comb(n,k, exact = True) ans = ans -scipy.misc.comb(n,a, exact = True) -scipy.misc.comb(n,b, exact = True) +1 print(int(ans)) ```
instruction
0
48,571
14
97,142
No
output
1
48,571
14
97,143
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet. Constraints * All values in input are integers. * 2 \leq n \leq 10^9 * 1 \leq a < b \leq \textrm{min}(n, 2 \times 10^5) Input Input is given from Standard Input in the following format: n a b Output Print the number of bouquets that Akari can make, modulo (10^9 + 7). (If there are no such bouquets, print `0`.) Examples Input 4 1 3 Output 7 Input 1000000000 141421 173205 Output 34076506 Submitted Solution: ``` N,a,b=map(int,input().split()) def kaijo(n): if n==1: return n return n*kaijo(n-1) def nCk(n,k): return kaijo(n)/(kaijo(k)*kaijo(n-k)) s=2**N-nCk(N,a)-nCk(N,b)-1 print(s%(10**9+7)) ```
instruction
0
48,572
14
97,144
No
output
1
48,572
14
97,145