message stringlengths 2 23.8k | message_type stringclasses 2
values | message_id int64 0 1 | conversation_id int64 97 109k | cluster float64 0 0 | __index_level_0__ int64 194 217k |
|---|---|---|---|---|---|
Provide tags and a correct Python 3 solution for this coding contest problem.
The only difference between easy and hard versions is the size of the input.
You are given a string s consisting of n characters, each character is 'R', 'G' or 'B'.
You are also given an integer k. Your task is to change the minimum number... | instruction | 0 | 67,347 | 0 | 134,694 |
Tags: data structures, dp, implementation, two pointers
Correct Solution:
```
from sys import stdin
input=stdin.readline
R = lambda:map(int,input().split())
q, = R()
a = 'RGB'
for q1 in range(q):
an =[300000]*3
n,k = R()
s = input()
for i2 in range(3):
ans = [0]*n
m = 0
for i in range(n):
ans[i]=s[i]==a[(i... | output | 1 | 67,347 | 0 | 134,695 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The only difference between easy and hard versions is the size of the input.
You are given a string s consisting of n characters, each character is 'R', 'G' or 'B'.
You are also given an integer k. Your task is to change the minimum number... | instruction | 0 | 67,348 | 0 | 134,696 |
Tags: data structures, dp, implementation, two pointers
Correct Solution:
```
from sys import stdin
input=stdin.readline
for _ in range(int(input())):
n,k=map(int,input().split())
s=list(input())
ans=10**9
a=['R','G','B']
for l in range(3):
x=l
dp=[0]*(n+1)
cnt=10**9
... | output | 1 | 67,348 | 0 | 134,697 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The only difference between easy and hard versions is the size of the input.
You are given a string s consisting of n characters, each character is 'R', 'G' or 'B'.
You are also given an integ... | instruction | 0 | 67,349 | 0 | 134,698 |
Yes | output | 1 | 67,349 | 0 | 134,699 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The only difference between easy and hard versions is the size of the input.
You are given a string s consisting of n characters, each character is 'R', 'G' or 'B'.
You are also given an integ... | instruction | 0 | 67,350 | 0 | 134,700 |
Yes | output | 1 | 67,350 | 0 | 134,701 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The only difference between easy and hard versions is the size of the input.
You are given a string s consisting of n characters, each character is 'R', 'G' or 'B'.
You are also given an integ... | instruction | 0 | 67,351 | 0 | 134,702 |
Yes | output | 1 | 67,351 | 0 | 134,703 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The only difference between easy and hard versions is the size of the input.
You are given a string s consisting of n characters, each character is 'R', 'G' or 'B'.
You are also given an integ... | instruction | 0 | 67,352 | 0 | 134,704 |
Yes | output | 1 | 67,352 | 0 | 134,705 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The only difference between easy and hard versions is the size of the input.
You are given a string s consisting of n characters, each character is 'R', 'G' or 'B'.
You are also given an integ... | instruction | 0 | 67,353 | 0 | 134,706 |
No | output | 1 | 67,353 | 0 | 134,707 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The only difference between easy and hard versions is the size of the input.
You are given a string s consisting of n characters, each character is 'R', 'G' or 'B'.
You are also given an integ... | instruction | 0 | 67,354 | 0 | 134,708 |
No | output | 1 | 67,354 | 0 | 134,709 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The only difference between easy and hard versions is the size of the input.
You are given a string s consisting of n characters, each character is 'R', 'G' or 'B'.
You are also given an integ... | instruction | 0 | 67,355 | 0 | 134,710 |
No | output | 1 | 67,355 | 0 | 134,711 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The only difference between easy and hard versions is the size of the input.
You are given a string s consisting of n characters, each character is 'R', 'G' or 'B'.
You are also given an integ... | instruction | 0 | 67,356 | 0 | 134,712 |
No | output | 1 | 67,356 | 0 | 134,713 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Authors have come up with the string s consisting of n lowercase Latin letters.
You are given two permutations of its indices (not necessary equal) p and q (both of length n). Recall that the permutation is the array of length n which conta... | instruction | 0 | 67,357 | 0 | 134,714 |
Tags: data structures, dfs and similar, dsu, graphs, greedy, implementation, strings
Correct Solution:
```
n, k = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
q = [int(i) for i in input().split()]
offs = ord("a")
ans = [chr(offs+k-1)] * n
# ans = ""
pmore = set()
qmore = set()
let = 0
# cnt... | output | 1 | 67,357 | 0 | 134,715 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Authors have come up with the string s consisting of n lowercase Latin letters.
You are given two permutations of its indices (not necessary equal) p and q (both of length n). Recall that the permutation is the array of length n which conta... | instruction | 0 | 67,358 | 0 | 134,716 |
Tags: data structures, dfs and similar, dsu, graphs, greedy, implementation, strings
Correct Solution:
```
import math
n = 3
k = 2
p = [1,2,3]
q = [1,3,2]
n,k = [int(x) for x in input().split(' ')]
p = [int(x) -1 for x in input().split(' ')]
q = [int(x) -1 for x in input().split(' ')]
group_ids = []
p_ids = s... | output | 1 | 67,358 | 0 | 134,717 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Authors have come up with the string s consisting of n lowercase Latin letters.
You are given two permutations of its indices (not necessary equal) p and q (both of length n). Recall that the permutation is the array of length n which conta... | instruction | 0 | 67,359 | 0 | 134,718 |
Tags: data structures, dfs and similar, dsu, graphs, greedy, implementation, strings
Correct Solution:
```
# https://codeforces.com/contest/1213/problem/F
n, k = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
def get(cur):
if cur>=97+25:
return chr(97+25)... | output | 1 | 67,359 | 0 | 134,719 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Authors have come up with the string s consisting of n lowercase Latin letters.
You are given two permutations of its indices (not necessary equal) p and q (both of length n). Recall that the permutation is the array of length n which conta... | instruction | 0 | 67,360 | 0 | 134,720 |
Tags: data structures, dfs and similar, dsu, graphs, greedy, implementation, strings
Correct Solution:
```
n, k = map(int, input().split())
s = [0] * n
for i, v in enumerate(map(int, input().split())):
s[v-1] = i
t = [0] * n
for i, v in enumerate(map(int, input().split())):
t[v-1] = i
p = [0] * n
for u, v in zi... | output | 1 | 67,360 | 0 | 134,721 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Authors have come up with the string s consisting of n lowercase Latin letters.
You are given two permutations of its indices (not necessary equal) p and q (both of length n). Recall that the permutation is the array of length n which conta... | instruction | 0 | 67,361 | 0 | 134,722 |
Tags: data structures, dfs and similar, dsu, graphs, greedy, implementation, strings
Correct Solution:
```
n, k = map(int,input().split())
l1 = list(map(int,input().split()))
l2 = list(map(int,input().split()))
d = {}
j = 1
for i in l1:
d[i] = j
j += 1
l = [d[i] for i in l2]
#l is the list that forces shit
wei ... | output | 1 | 67,361 | 0 | 134,723 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Authors have come up with the string s consisting of n lowercase Latin letters.
You are given two permutations of its indices (not necessary equal) p and q (both of length n). Recall that the permutation is the array of length n which conta... | instruction | 0 | 67,362 | 0 | 134,724 |
Tags: data structures, dfs and similar, dsu, graphs, greedy, implementation, strings
Correct Solution:
```
from sys import stdin, stdout, setrecursionlimit
setrecursionlimit(50000)
n, k = map(int, stdin.readline().split())
p = list(map(int, stdin.readline().split()))
q = list(map(int, stdin.readline().split()))
pos... | output | 1 | 67,362 | 0 | 134,725 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Authors have come up with the string s consisting of n lowercase Latin letters.
You are given two permutations of its indices (not necessary equal) p and q (both of length n). Recall that the permutation is the array of length n which conta... | instruction | 0 | 67,363 | 0 | 134,726 |
Tags: data structures, dfs and similar, dsu, graphs, greedy, implementation, strings
Correct Solution:
```
n,k=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
b=[int(x) for x in input().split()]
p=set()
q=set()
literals=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','... | output | 1 | 67,363 | 0 | 134,727 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Authors have come up with the string s consisting of n lowercase Latin letters.
You are given two permutations of its indices (not necessary equal) p and q (both of length n). Recall that the permutation is the array of length n which conta... | instruction | 0 | 67,364 | 0 | 134,728 |
Tags: data structures, dfs and similar, dsu, graphs, greedy, implementation, strings
Correct Solution:
```
n,k=map(int,input().split())
aa=list(map(int,input().split()))
bb=list(map(int,input().split()))
ab="abcdefghijklmnopqrstuvwxyz"
#print(len(ab))
ss={}
j=0
it=[]
for i in aa:
ss[i]=j
j+=1
jj=0
for i in bb:
... | output | 1 | 67,364 | 0 | 134,729 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Authors have come up with the string s consisting of n lowercase Latin letters.
You are given two permutations of its indices (not necessary equal) p and q (both of length n). Recall that the p... | instruction | 0 | 67,365 | 0 | 134,730 |
Yes | output | 1 | 67,365 | 0 | 134,731 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Authors have come up with the string s consisting of n lowercase Latin letters.
You are given two permutations of its indices (not necessary equal) p and q (both of length n). Recall that the p... | instruction | 0 | 67,366 | 0 | 134,732 |
Yes | output | 1 | 67,366 | 0 | 134,733 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Authors have come up with the string s consisting of n lowercase Latin letters.
You are given two permutations of its indices (not necessary equal) p and q (both of length n). Recall that the p... | instruction | 0 | 67,367 | 0 | 134,734 |
Yes | output | 1 | 67,367 | 0 | 134,735 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Authors have come up with the string s consisting of n lowercase Latin letters.
You are given two permutations of its indices (not necessary equal) p and q (both of length n). Recall that the p... | instruction | 0 | 67,368 | 0 | 134,736 |
Yes | output | 1 | 67,368 | 0 | 134,737 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Authors have come up with the string s consisting of n lowercase Latin letters.
You are given two permutations of its indices (not necessary equal) p and q (both of length n). Recall that the p... | instruction | 0 | 67,369 | 0 | 134,738 |
No | output | 1 | 67,369 | 0 | 134,739 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Authors have come up with the string s consisting of n lowercase Latin letters.
You are given two permutations of its indices (not necessary equal) p and q (both of length n). Recall that the p... | instruction | 0 | 67,370 | 0 | 134,740 |
No | output | 1 | 67,370 | 0 | 134,741 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Authors have come up with the string s consisting of n lowercase Latin letters.
You are given two permutations of its indices (not necessary equal) p and q (both of length n). Recall that the p... | instruction | 0 | 67,371 | 0 | 134,742 |
No | output | 1 | 67,371 | 0 | 134,743 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Authors have come up with the string s consisting of n lowercase Latin letters.
You are given two permutations of its indices (not necessary equal) p and q (both of length n). Recall that the p... | instruction | 0 | 67,372 | 0 | 134,744 |
No | output | 1 | 67,372 | 0 | 134,745 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
String diversity is the number of symbols that occur in the string at least once. Diversity of s will be denoted by d(s). For example , d("aaa")=1, d("abacaba")=3.
Given a string s, consisting ... | instruction | 0 | 67,601 | 0 | 135,202 |
No | output | 1 | 67,601 | 0 | 135,203 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
String diversity is the number of symbols that occur in the string at least once. Diversity of s will be denoted by d(s). For example , d("aaa")=1, d("abacaba")=3.
Given a string s, consisting ... | instruction | 0 | 67,602 | 0 | 135,204 |
No | output | 1 | 67,602 | 0 | 135,205 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
String diversity is the number of symbols that occur in the string at least once. Diversity of s will be denoted by d(s). For example , d("aaa")=1, d("abacaba")=3.
Given a string s, consisting ... | instruction | 0 | 67,603 | 0 | 135,206 |
No | output | 1 | 67,603 | 0 | 135,207 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A string is called palindrome if it reads the same from left to right and from right to left. For example "kazak", "oo", "r" and "mikhailrubinchikkihcniburliahkim" are palindroms, but strings "abb" and "ij" are not.
You are given string s c... | instruction | 0 | 67,701 | 0 | 135,402 |
Tags: constructive algorithms, greedy, strings
Correct Solution:
```
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r... | output | 1 | 67,701 | 0 | 135,403 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A string is called palindrome if it reads the same from left to right and from right to left. For example "kazak", "oo", "r" and "mikhailrubinchikkihcniburliahkim" are palindroms, but strings "abb" and "ij" are not.
You are given string s c... | instruction | 0 | 67,702 | 0 | 135,404 |
Tags: constructive algorithms, greedy, strings
Correct Solution:
```
from collections import Counter
from math import ceil
def construct(vals: list) -> str:
if len(vals) == 1:
return vals[0][0] * vals[0][1]
else:
x = vals.pop(0)
assert x[1] % 2 == 0
return x[0]*(x[1]//2) + cons... | output | 1 | 67,702 | 0 | 135,405 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A string is called palindrome if it reads the same from left to right and from right to left. For example "kazak", "oo", "r" and "mikhailrubinchikkihcniburliahkim" are palindroms, but strings "abb" and "ij" are not.
You are given string s c... | instruction | 0 | 67,703 | 0 | 135,406 |
Tags: constructive algorithms, greedy, strings
Correct Solution:
```
S = input()
letters = {}
for i in S:
if i not in letters:
letters[i] = 1
else:
letters[i] = letters[i] + 1
used_letters = sorted(letters.keys())
num_odd = 0
used_odd = False
for i in used_letters:
if letters[i] % 2 == 1:
... | output | 1 | 67,703 | 0 | 135,407 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A string is called palindrome if it reads the same from left to right and from right to left. For example "kazak", "oo", "r" and "mikhailrubinchikkihcniburliahkim" are palindroms, but strings "abb" and "ij" are not.
You are given string s c... | instruction | 0 | 67,704 | 0 | 135,408 |
Tags: constructive algorithms, greedy, strings
Correct Solution:
```
s = input()
i = 0
mp = [0 for x in range(26)]
out = ""
while i < len(s):
mp[ord(s[i]) - ord('a')] += 1
i += 1
front = 0
end = len(mp) - 1
while front < len(mp) and mp[front] % 2 != 1:
front += 1
while end > 0 and mp[end] % 2 != 1:
... | output | 1 | 67,704 | 0 | 135,409 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A string is called palindrome if it reads the same from left to right and from right to left. For example "kazak", "oo", "r" and "mikhailrubinchikkihcniburliahkim" are palindroms, but strings "abb" and "ij" are not.
You are given string s c... | instruction | 0 | 67,705 | 0 | 135,410 |
Tags: constructive algorithms, greedy, strings
Correct Solution:
```
s=input()
a=[int(i) for i in '0'*26]
k=-1
for i in s:
a[ord(i)-97]+=1
for i in range(25):
if a[i]%2!=0:
for j in range(25-i):
if a[25-j]%2!=0:
a[i]+=1
a[25-j]-=1
break
if ... | output | 1 | 67,705 | 0 | 135,411 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A string is called palindrome if it reads the same from left to right and from right to left. For example "kazak", "oo", "r" and "mikhailrubinchikkihcniburliahkim" are palindroms, but strings "abb" and "ij" are not.
You are given string s c... | instruction | 0 | 67,706 | 0 | 135,412 |
Tags: constructive algorithms, greedy, strings
Correct Solution:
```
s,l,p,z,x,k=input(),[0]*27,0,"","",""
for i in s:l[ord(i)-97]+=1
p=sum(1for i in l if i%2)//2
for i in range(26,-1,-1):
if l[i]%2 and p:
p-=1
l[i]-=1
for j in range(26):
if l[j]%2:
l[j]+=1
... | output | 1 | 67,706 | 0 | 135,413 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A string is called palindrome if it reads the same from left to right and from right to left. For example "kazak", "oo", "r" and "mikhailrubinchikkihcniburliahkim" are palindroms, but strings "abb" and "ij" are not.
You are given string s c... | instruction | 0 | 67,707 | 0 | 135,414 |
Tags: constructive algorithms, greedy, strings
Correct Solution:
```
from math import floor
s = input()
n = len(s)
ans = ['*'] * n
d = {}
e = []
o = []
for c in s:
if c in d:
d[c] += 1
else:
d[c] = 1
for k in d:
qnt = floor(d[k] / 2)
e += [k] * qnt
d[k] -= (qnt * 2)
if d[k]:
... | output | 1 | 67,707 | 0 | 135,415 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A string is called palindrome if it reads the same from left to right and from right to left. For example "kazak", "oo", "r" and "mikhailrubinchikkihcniburliahkim" are palindroms, but strings "abb" and "ij" are not.
You are given string s c... | instruction | 0 | 67,708 | 0 | 135,416 |
Tags: constructive algorithms, greedy, strings
Correct Solution:
```
inp_string = input()
LOWERCASELETTERS = "abcdefghijklmnopqrstuvwxyz"
OCCS = {letter:0 for letter in LOWERCASELETTERS}
for sym in inp_string:
OCCS[sym] += 1
ODD_OCCS = [letter for letter in LOWERCASELETTERS if OCCS[letter] % 2 != 0]
N_ODD = l... | output | 1 | 67,708 | 0 | 135,417 |
Provide tags and a correct Python 2 solution for this coding contest problem.
A string is called palindrome if it reads the same from left to right and from right to left. For example "kazak", "oo", "r" and "mikhailrubinchikkihcniburliahkim" are palindroms, but strings "abb" and "ij" are not.
You are given string s c... | instruction | 0 | 67,709 | 0 | 135,418 |
Tags: constructive algorithms, greedy, strings
Correct Solution:
```
from sys import stdin, stdout
from collections import Counter, defaultdict
from itertools import permutations, combinations
raw_input = stdin.readline
pr = stdout.write
def in_num():
return int(raw_input())
def in_arr():
return map(int,raw... | output | 1 | 67,709 | 0 | 135,419 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A string is called palindrome if it reads the same from left to right and from right to left. For example "kazak", "oo", "r" and "mikhailrubinchikkihcniburliahkim" are palindroms, but strings "a... | instruction | 0 | 67,710 | 0 | 135,420 |
Yes | output | 1 | 67,710 | 0 | 135,421 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A string is called palindrome if it reads the same from left to right and from right to left. For example "kazak", "oo", "r" and "mikhailrubinchikkihcniburliahkim" are palindroms, but strings "a... | instruction | 0 | 67,711 | 0 | 135,422 |
Yes | output | 1 | 67,711 | 0 | 135,423 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A string is called palindrome if it reads the same from left to right and from right to left. For example "kazak", "oo", "r" and "mikhailrubinchikkihcniburliahkim" are palindroms, but strings "a... | instruction | 0 | 67,712 | 0 | 135,424 |
Yes | output | 1 | 67,712 | 0 | 135,425 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A string is called palindrome if it reads the same from left to right and from right to left. For example "kazak", "oo", "r" and "mikhailrubinchikkihcniburliahkim" are palindroms, but strings "a... | instruction | 0 | 67,713 | 0 | 135,426 |
Yes | output | 1 | 67,713 | 0 | 135,427 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A string is called palindrome if it reads the same from left to right and from right to left. For example "kazak", "oo", "r" and "mikhailrubinchikkihcniburliahkim" are palindroms, but strings "a... | instruction | 0 | 67,714 | 0 | 135,428 |
No | output | 1 | 67,714 | 0 | 135,429 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A string is called palindrome if it reads the same from left to right and from right to left. For example "kazak", "oo", "r" and "mikhailrubinchikkihcniburliahkim" are palindroms, but strings "a... | instruction | 0 | 67,715 | 0 | 135,430 |
No | output | 1 | 67,715 | 0 | 135,431 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A string is called palindrome if it reads the same from left to right and from right to left. For example "kazak", "oo", "r" and "mikhailrubinchikkihcniburliahkim" are palindroms, but strings "a... | instruction | 0 | 67,716 | 0 | 135,432 |
No | output | 1 | 67,716 | 0 | 135,433 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A string is called palindrome if it reads the same from left to right and from right to left. For example "kazak", "oo", "r" and "mikhailrubinchikkihcniburliahkim" are palindroms, but strings "a... | instruction | 0 | 67,717 | 0 | 135,434 |
No | output | 1 | 67,717 | 0 | 135,435 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Pushok the dog has been chasing Imp for a few hours already.
<image>
Fortunately, Imp knows that Pushok is afraid of a robot vacuum cleaner.
While moving, the robot generates a string t consisting of letters 's' and 'h', that produces a ... | instruction | 0 | 67,847 | 0 | 135,694 |
Tags: greedy, sortings
Correct Solution:
```
n = int(input())
a = []
for i in range(n):
s = input()
l = 0
for c in s:
if c=="s":
l+=1
a.append((s, l/len(s)))
a.sort(key=lambda x: x[1], reverse=True)
ns = 0
ans = 0
for st, _ in a:
for c in st:
if c == 's':
ns +... | output | 1 | 67,847 | 0 | 135,695 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Pushok the dog has been chasing Imp for a few hours already.
<image>
Fortunately, Imp knows that Pushok is afraid of a robot vacuum cleaner.
While moving, the robot generates a string t consisting of letters 's' and 'h', that produces a ... | instruction | 0 | 67,850 | 0 | 135,700 |
Tags: greedy, sortings
Correct Solution:
```
#from collections import defaultdict
get= lambda : map(int,input().split())
f=next(get())
a=[]
# http://codeforces.com/problemset/problem/922/D
for i in range(f):
s=input()
a.append(s)
def key(y):
t=y.count('s')
if not t:
return float('inf')
ret... | output | 1 | 67,850 | 0 | 135,701 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Pushok the dog has been chasing Imp for a few hours already.
<image>
Fortunately, Imp knows that Pushok is afraid of a robot vacuum cleaner.
While moving, the robot generates a string t consisting of letters 's' and 'h', that produces a ... | instruction | 0 | 67,851 | 0 | 135,702 |
Tags: greedy, sortings
Correct Solution:
```
import sys
#f = open('input', 'r')
f = sys.stdin
n = int(f.readline())
s = [f.readline().strip() for _ in range(n)]
s = [(x, x.count('s'), x.count('h')) for x in s]
s = sorted(s, key=lambda x: x[2]/float(x[1]+0.00000001))
s = ''.join(x[0] for x in s)
cs = 0
ans = 0
for x ... | output | 1 | 67,851 | 0 | 135,703 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Pushok the dog has been chasing Imp for a few hours already.
<image>
Fortunately, Imp knows that Pushok is afraid of a robot vacuum cleaner.
While moving, the robot generates a string t consisting of letters 's' and 'h', that produces a ... | instruction | 0 | 67,852 | 0 | 135,704 |
Tags: greedy, sortings
Correct Solution:
```
n = int(input())
ts = []
res = 0
for _ in range(n):
i = input().strip()
m_res = 0
s_count = 0
for c in i:
if c == 's':
s_count += 1
else:
m_res += s_count
res += m_res
ts.append((i.count('s'), i.count('h')))
ts... | output | 1 | 67,852 | 0 | 135,705 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.