message stringlengths 2 23.4k | message_type stringclasses 2
values | message_id int64 0 1 | conversation_id int64 129 108k | cluster float64 6 6 | __index_level_0__ int64 258 216k |
|---|---|---|---|---|---|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The preferred way to generate user login in Polygon is to concatenate a prefix of the user's first name and a prefix of their last name, in that order. Each prefix must be non-empty, and any of ... | instruction | 0 | 11,358 | 6 | 22,716 |
Yes | output | 1 | 11,358 | 6 | 22,717 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The preferred way to generate user login in Polygon is to concatenate a prefix of the user's first name and a prefix of their last name, in that order. Each prefix must be non-empty, and any of ... | instruction | 0 | 11,359 | 6 | 22,718 |
Yes | output | 1 | 11,359 | 6 | 22,719 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The preferred way to generate user login in Polygon is to concatenate a prefix of the user's first name and a prefix of their last name, in that order. Each prefix must be non-empty, and any of ... | instruction | 0 | 11,360 | 6 | 22,720 |
Yes | output | 1 | 11,360 | 6 | 22,721 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The preferred way to generate user login in Polygon is to concatenate a prefix of the user's first name and a prefix of their last name, in that order. Each prefix must be non-empty, and any of ... | instruction | 0 | 11,361 | 6 | 22,722 |
No | output | 1 | 11,361 | 6 | 22,723 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The preferred way to generate user login in Polygon is to concatenate a prefix of the user's first name and a prefix of their last name, in that order. Each prefix must be non-empty, and any of ... | instruction | 0 | 11,362 | 6 | 22,724 |
No | output | 1 | 11,362 | 6 | 22,725 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The preferred way to generate user login in Polygon is to concatenate a prefix of the user's first name and a prefix of their last name, in that order. Each prefix must be non-empty, and any of ... | instruction | 0 | 11,364 | 6 | 22,728 |
No | output | 1 | 11,364 | 6 | 22,729 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Santa Claus decided to disassemble his keyboard to clean it. After he returned all the keys back, he suddenly realized that some pairs of keys took each other's place! That is, Santa suspects that each key is either on its place, or on the p... | instruction | 0 | 12,130 | 6 | 24,260 |
Tags: implementation, strings
Correct Solution:
```
import sys
s=input()
t=input()
st1=[]
st2=[]
checked=[]
right=[]
for i in range(len(s)):
a=[]
if s[i] in checked and t[i] not in checked:
print('-1')
sys.exit()
if s[i] not in checked and t[i] in checked:
print('-1')
sys.exi... | output | 1 | 12,130 | 6 | 24,261 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Santa Claus decided to disassemble his keyboard to clean it. After he returned all the keys back, he suddenly realized that some pairs of keys took each other's place! That is, Santa suspects that each key is either on its place, or on the p... | instruction | 0 | 12,131 | 6 | 24,262 |
Tags: implementation, strings
Correct Solution:
```
a = input()
b = input()
alph = [0] * 26
for i in range(26):
alph[i] = chr(97 + i)
ans = []
for i in range(len(a)):
if a[i] != alph[ord(b[i]) - 97]:
if (alph[ord(a[i]) - 97] == a[i]) and (alph[ord(b[i]) - 97] == b[i]):
alph[ord(a[i]) - 97] = b[i]
... | output | 1 | 12,131 | 6 | 24,263 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Santa Claus decided to disassemble his keyboard to clean it. After he returned all the keys back, he suddenly realized that some pairs of keys took each other's place! That is, Santa suspects that each key is either on its place, or on the p... | instruction | 0 | 12,132 | 6 | 24,264 |
Tags: implementation, strings
Correct Solution:
```
def areBidirectionalDictionaries(s1, s2):
d = {}
other = {}
perfect = set()
for i, j in zip(s1, s2):
if i != j:
if (i in d and d[i] != j) or (j in d and d[j] != i) or (i in perfect) or (j in perfect):
print('-1')
... | output | 1 | 12,132 | 6 | 24,265 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Santa Claus decided to disassemble his keyboard to clean it. After he returned all the keys back, he suddenly realized that some pairs of keys took each other's place! That is, Santa suspects that each key is either on its place, or on the p... | instruction | 0 | 12,133 | 6 | 24,266 |
Tags: implementation, strings
Correct Solution:
```
s = input()
t = input()
used, ln = set(), 0
for i in range(len(s)):
if (s[i] != t[i]) and (not (tuple(sorted([s[i], t[i]])) in used)):
ln += 1
used.add(tuple(sorted([s[i], t[i]])))
a = [i[0] for i in used]
b = [i[1] for i in used]
if s=='bd' and t=='cc... | output | 1 | 12,133 | 6 | 24,267 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Santa Claus decided to disassemble his keyboard to clean it. After he returned all the keys back, he suddenly realized that some pairs of keys took each other's place! That is, Santa suspects that each key is either on its place, or on the p... | instruction | 0 | 12,134 | 6 | 24,268 |
Tags: implementation, strings
Correct Solution:
```
def ic(s,t):
"""is correct"""
d=dict()
for c in range(len(s)):
if t[c] not in d or t[c] in d and s[c] not in d[t[c]]:
d.setdefault(s[c],set()).add(t[c])
d.setdefault(t[c],set()).add(s[c])
#print(d)
for k,v in d.items():
if len(v)>1:
return 0,None
d... | output | 1 | 12,134 | 6 | 24,269 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Santa Claus decided to disassemble his keyboard to clean it. After he returned all the keys back, he suddenly realized that some pairs of keys took each other's place! That is, Santa suspects that each key is either on its place, or on the p... | instruction | 0 | 12,135 | 6 | 24,270 |
Tags: implementation, strings
Correct Solution:
```
def main():
d = {}
for a, b in zip(input(), input()):
if d.get(a, b) != b or d.get(b, a) != a:
print(-1)
return
d[a], d[b] = b, a
res = ['%s %s' % (a, b) for a, b in d.items() if a < b]
print(len(res))
print(... | output | 1 | 12,135 | 6 | 24,271 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Santa Claus decided to disassemble his keyboard to clean it. After he returned all the keys back, he suddenly realized that some pairs of keys took each other's place! That is, Santa suspects that each key is either on its place, or on the p... | instruction | 0 | 12,136 | 6 | 24,272 |
Tags: implementation, strings
Correct Solution:
```
s1 = input()
s2 = input()
a = [[0]*2 for i in range(29)]
used = [-1]*29
good = 1
c = 0
for i in range(len(s2)):
if good == 0:
break
if s2[i] != s1[i]:
if used[ord(s2[i])- ord('a')] == -1 and used[ord(s1[i])- ord('a')] == -1:
used[or... | output | 1 | 12,136 | 6 | 24,273 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Santa Claus decided to disassemble his keyboard to clean it. After he returned all the keys back, he suddenly realized that some pairs of keys took each other's place! That is, Santa suspects that each key is either on its place, or on the p... | instruction | 0 | 12,137 | 6 | 24,274 |
Tags: implementation, strings
Correct Solution:
```
before = input()
after = input()
length = len(before)
stock = {}
answer = []
for l in range(length):
if before[l] != after[l] and stock.get(after[l],0) == 0 and stock.get(before[l],0) == 0:
answer.append(str(before[l]) + " " + str(after[l]))
stock[... | output | 1 | 12,137 | 6 | 24,275 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Santa Claus decided to disassemble his keyboard to clean it. After he returned all the keys back, he suddenly realized that some pairs of keys took each other's place! That is, Santa suspects th... | instruction | 0 | 12,138 | 6 | 24,276 |
Yes | output | 1 | 12,138 | 6 | 24,277 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Santa Claus decided to disassemble his keyboard to clean it. After he returned all the keys back, he suddenly realized that some pairs of keys took each other's place! That is, Santa suspects th... | instruction | 0 | 12,139 | 6 | 24,278 |
Yes | output | 1 | 12,139 | 6 | 24,279 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Santa Claus decided to disassemble his keyboard to clean it. After he returned all the keys back, he suddenly realized that some pairs of keys took each other's place! That is, Santa suspects th... | instruction | 0 | 12,140 | 6 | 24,280 |
Yes | output | 1 | 12,140 | 6 | 24,281 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Santa Claus decided to disassemble his keyboard to clean it. After he returned all the keys back, he suddenly realized that some pairs of keys took each other's place! That is, Santa suspects th... | instruction | 0 | 12,141 | 6 | 24,282 |
Yes | output | 1 | 12,141 | 6 | 24,283 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Santa Claus decided to disassemble his keyboard to clean it. After he returned all the keys back, he suddenly realized that some pairs of keys took each other's place! That is, Santa suspects th... | instruction | 0 | 12,142 | 6 | 24,284 |
No | output | 1 | 12,142 | 6 | 24,285 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Santa Claus decided to disassemble his keyboard to clean it. After he returned all the keys back, he suddenly realized that some pairs of keys took each other's place! That is, Santa suspects th... | instruction | 0 | 12,143 | 6 | 24,286 |
No | output | 1 | 12,143 | 6 | 24,287 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Santa Claus decided to disassemble his keyboard to clean it. After he returned all the keys back, he suddenly realized that some pairs of keys took each other's place! That is, Santa suspects th... | instruction | 0 | 12,144 | 6 | 24,288 |
No | output | 1 | 12,144 | 6 | 24,289 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Santa Claus decided to disassemble his keyboard to clean it. After he returned all the keys back, he suddenly realized that some pairs of keys took each other's place! That is, Santa suspects th... | instruction | 0 | 12,145 | 6 | 24,290 |
No | output | 1 | 12,145 | 6 | 24,291 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Note that the only difference between String Transformation 1 and String Transformation 2 is in the move Koa does. In this version the letter y Koa selects must be strictly greater alphabetically than x (read statement for better understandi... | instruction | 0 | 12,618 | 6 | 25,236 |
Tags: dsu, graphs, greedy, sortings, strings, trees, two pointers
Correct Solution:
```
"""Template for Python Competitive Programmers prepared by pajengod and many others """
# ////////// SHUBHAM SHARMA \\\\\\\\\\\\\
# to use the print and division function of Python3
from __future__ import division, print_function... | output | 1 | 12,618 | 6 | 25,237 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Note that the only difference between String Transformation 1 and String Transformation 2 is in the move Koa does. In this version the letter y Koa selects must be strictly greater alphabetically than x (read statement for better understandi... | instruction | 0 | 12,619 | 6 | 25,238 |
Tags: dsu, graphs, greedy, sortings, strings, trees, two pointers
Correct Solution:
```
import sys
input = sys.stdin.readline
class UnionFind:
def __init__(self, n):
self.parent = [-1] * n
self.cnt = n
def root(self, x):
if self.parent[x] < 0:
return x
else:
... | output | 1 | 12,619 | 6 | 25,239 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Note that the only difference between String Transformation 1 and String Transformation 2 is in the move Koa does. In this version the letter y Koa selects must be strictly greater alphabetically than x (read statement for better understandi... | instruction | 0 | 12,620 | 6 | 25,240 |
Tags: dsu, graphs, greedy, sortings, strings, trees, two pointers
Correct Solution:
```
import sys
input = sys.stdin.readline
I = lambda : list(map(int,input().split()))
def find(x):
while x!=p[x]:
x=p[x]
return x
def union(a,b):
x=find(a)
y=find(b)
if x!=y:
p[y]=p[x]=min(x,y)
r[min(x,y)]+=r[max(x,y)]
t... | output | 1 | 12,620 | 6 | 25,241 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Note that the only difference between String Transformation 1 and String Transformation 2 is in the move Koa does. In this version the letter y Koa selects must be strictly greater alphabetically than x (read statement for better understandi... | instruction | 0 | 12,621 | 6 | 25,242 |
Tags: dsu, graphs, greedy, sortings, strings, trees, two pointers
Correct Solution:
```
y=lambda s:ord(s)-97
z=lambda:list(map(y,input()))
for _ in range(int(input())):
n=int(input())
a,b=z(),z()
f,c=0,0
for i in range(20):
m=20
l=[]
for j in range(n):
if a[j]==i:
if b[j]<i:
f=1
break
eli... | output | 1 | 12,621 | 6 | 25,243 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Note that the only difference between String Transformation 1 and String Transformation 2 is in the move Koa does. In this version the letter y Koa selects must be strictly greater alphabetically than x (read statement for better understandi... | instruction | 0 | 12,622 | 6 | 25,244 |
Tags: dsu, graphs, greedy, sortings, strings, trees, two pointers
Correct Solution:
```
from collections import defaultdict
import string
T = int(input())
for t in range(T):
n = int(input())
source = input()
target = input()
exit_flag = False
for i in range(n): # feasibility test
if target[i... | output | 1 | 12,622 | 6 | 25,245 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Note that the only difference between String Transformation 1 and String Transformation 2 is in the move Koa does. In this version the letter y Koa selects must be strictly greater alphabetically than x (read statement for better understandi... | instruction | 0 | 12,623 | 6 | 25,246 |
Tags: dsu, graphs, greedy, sortings, strings, trees, two pointers
Correct Solution:
```
import sys
import math
def II():
return int(sys.stdin.readline())
def LI():
return list(map(int, sys.stdin.readline().split()))
def MI():
return map(int, sys.stdin.readline().split())
def SI():
return sys.stdin.readline().str... | output | 1 | 12,623 | 6 | 25,247 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Note that the only difference between String Transformation 1 and String Transformation 2 is in the move Koa does. In this version the letter y Koa selects must be strictly greater alphabetically than x (read statement for better understandi... | instruction | 0 | 12,624 | 6 | 25,248 |
Tags: dsu, graphs, greedy, sortings, strings, trees, two pointers
Correct Solution:
```
t=int(input())
for _ in range(t):
n=int(input())
a=list(input())
b=list(input())
count=[[0 for i in range(20)] for i in range(20)]
flag=1
for i in range(n):
if(ord(a[i])>ord(b[i])):
flag=0... | output | 1 | 12,624 | 6 | 25,249 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Note that the only difference between String Transformation 1 and String Transformation 2 is in the move Koa does. In this version the letter y Koa selects must be strictly greater alphabetically than x (read statement for better understandi... | instruction | 0 | 12,625 | 6 | 25,250 |
Tags: dsu, graphs, greedy, sortings, strings, trees, two pointers
Correct Solution:
```
import sys
import heapq, functools, collections
import math, random
from collections import Counter, defaultdict
# available on Google, not available on Codeforces
# import numpy as np
# import scipy
def solve(arr,brr): # fix in... | output | 1 | 12,625 | 6 | 25,251 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Boy Valera likes strings. And even more he likes them, when they are identical. That's why in his spare time Valera plays the following game. He takes any two strings, consisting of lower case Latin letters, and tries to make them identical.... | instruction | 0 | 12,780 | 6 | 25,560 |
Tags: shortest paths
Correct Solution:
```
import sys, string
import itertools
s, t = input().strip(), input().strip()
if len(s) != len(t):
print(-1)
sys.exit()
vertices = string.ascii_lowercase
g = { c: { c: 0 } for c in vertices }
n = int(input())
for i in range(n):
u, v, cost = input().split()
cost = int(... | output | 1 | 12,780 | 6 | 25,561 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Boy Valera likes strings. And even more he likes them, when they are identical. That's why in his spare time Valera plays the following game. He takes any two strings, consisting of lower case Latin letters, and tries to make them identical.... | instruction | 0 | 12,781 | 6 | 25,562 |
Tags: shortest paths
Correct Solution:
```
import sys
large = 10000000
def solve():
s = input()
t = input()
if len(s) != len(t):
print(-1)
return
n = int(input())
mem = [[large] * 26 for _ in range(26)]
for i in range(26):
mem[i][i] = 0
for i in range(n):
chra... | output | 1 | 12,781 | 6 | 25,563 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Boy Valera likes strings. And even more he likes them, when they are identical. That's why in his spare time Valera plays the following game. He takes any two strings, consisting of lower case Latin letters, and tries to make them identical.... | instruction | 0 | 12,782 | 6 | 25,564 |
Tags: shortest paths
Correct Solution:
```
# http://codeforces.com/problemset/problem/33/B
# 33b: String Problem.
#input = raw_input
def build_graph(a):
w = [[float('inf') for col in range(26)] for row in range(26)]
for i in range(26):
w[i][i] = 0
for b in a:
if w[ord(b[0]) - 97][ord(b[1]... | output | 1 | 12,782 | 6 | 25,565 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Boy Valera likes strings. And even more he likes them, when they are identical. That's why in his spare time Valera plays the following game. He takes any two strings, consisting of lower case Latin letters, and tries to make them identical.... | instruction | 0 | 12,783 | 6 | 25,566 |
Tags: shortest paths
Correct Solution:
```
import os
import sys
from math import *
from collections import *
# from fractions import *
# from heapq import*
from bisect import *
from io import BytesIO, IOBase
def vsInput():
sys.stdin = open('input.txt', 'r')
sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192
cl... | output | 1 | 12,783 | 6 | 25,567 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Boy Valera likes strings. And even more he likes them, when they are identical. That's why in his spare time Valera plays the following game. He takes any two strings, consisting of lower case Latin letters, and tries to make them identical.... | instruction | 0 | 12,784 | 6 | 25,568 |
Tags: shortest paths
Correct Solution:
```
s = input()
t = input()
if(len(s) != len(t)):
print(-1)
exit()
dist = [[10**15 for j in range(26)] for i in range(26)]
for i in range(26):
dist[i][i] = 0
n = int(input())
for i in range(n):
a = input().split()
x = ord(a[0]) - 97
y = ord(a[1]) - 97
... | output | 1 | 12,784 | 6 | 25,569 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Boy Valera likes strings. And even more he likes them, when they are identical. That's why in his spare time Valera plays the following game. He takes any two strings, consisting of lower case Latin letters, and tries to make them identical.... | instruction | 0 | 12,785 | 6 | 25,570 |
Tags: shortest paths
Correct Solution:
```
def code(c):
return ord(c) - ord('a')
def main():
a = input()
b = input()
m = int(input())
n = 26
d = [[10 ** 9 for i in range(n)] for j in range(n)]
for i in range(n):
d[i][i] = 0
for i in range(m):
s, t, w = input().split()
... | output | 1 | 12,785 | 6 | 25,571 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Boy Valera likes strings. And even more he likes them, when they are identical. That's why in his spare time Valera plays the following game. He takes any two strings, consisting of lower case Latin letters, and tries to make them identical.... | instruction | 0 | 12,786 | 6 | 25,572 |
Tags: shortest paths
Correct Solution:
```
# http://codeforces.com/problemset/problem/33/B
# 33b: String Problem.
#input = raw_input
def calc_path(a):
'''
this function uses floyd-warshall alg to compute all pairs shortest path weight among alphabet characters.
input:
a: a 2d list which gives the wei... | output | 1 | 12,786 | 6 | 25,573 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Boy Valera likes strings. And even more he likes them, when they are identical. That's why in his spare time Valera plays the following game. He takes any two strings, consisting of lower case Latin letters, and tries to make them identical.... | instruction | 0 | 12,787 | 6 | 25,574 |
Tags: shortest paths
Correct Solution:
```
# http://codeforces.com/problemset/problem/33/B
# 33b: String Problem.
# 象道, montreal, quebec, canada.
#input = raw_input
def calc_path(a):
'''
this function uses floyd-warshall alg to compute all pairs shortest path weight among alphabet characters.
input:
... | output | 1 | 12,787 | 6 | 25,575 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Andrew, Fedor and Alex are inventive guys. Now they invent the game with strings for two players.
Given a group of n non-empty strings. During the game two players build the word together, initially the word is empty. The players move in tu... | instruction | 0 | 12,830 | 6 | 25,660 |
Tags: dfs and similar, dp, games, implementation, strings, trees
Correct Solution:
```
# https://codeforces.com/contest/455/problem/B
import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
class Trie:
def __init__(self):
self.arr = {}
def insert(self, word):
root = self
... | output | 1 | 12,830 | 6 | 25,661 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Andrew, Fedor and Alex are inventive guys. Now they invent the game with strings for two players.
Given a group of n non-empty strings. During the game two players build the word together, initially the word is empty. The players move in tu... | instruction | 0 | 12,831 | 6 | 25,662 |
Tags: dfs and similar, dp, games, implementation, strings, trees
Correct Solution:
```
# -*- coding:utf-8 -*-
"""
created by shuangquan.huang at 2/11/20
"""
import collections
import time
import os
import sys
import bisect
import heapq
from typing import List
def make_trie(A):
trie = {}
for word in A:
... | output | 1 | 12,831 | 6 | 25,663 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Andrew, Fedor and Alex are inventive guys. Now they invent the game with strings for two players.
Given a group of n non-empty strings. During the game two players build the word together, initially the word is empty. The players move in tu... | instruction | 0 | 12,832 | 6 | 25,664 |
Tags: dfs and similar, dp, games, implementation, strings, trees
Correct Solution:
```
class Node:
def __init__(self):
self._next = {}
self._win = None
self._lose = None
def get_or_create(self, c: str):
return self._next.setdefault(c, Node())
def traverse(self):
sel... | output | 1 | 12,832 | 6 | 25,665 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Andrew, Fedor and Alex are inventive guys. Now they invent the game with strings for two players.
Given a group of n non-empty strings. During the game two players build the word together, initially the word is empty. The players move in tu... | instruction | 0 | 12,833 | 6 | 25,666 |
Tags: dfs and similar, dp, games, implementation, strings, trees
Correct Solution:
```
from sys import stdin, setrecursionlimit
setrecursionlimit(200000)
n,k = [int(x) for x in stdin.readline().split()]
tree = {}
for x in range(n):
s = stdin.readline().strip()
cur = tree
for x in s:
if not x in cur:
... | output | 1 | 12,833 | 6 | 25,667 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Andrew, Fedor and Alex are inventive guys. Now they invent the game with strings for two players.
Given a group of n non-empty strings. During the game two players build the word together, initially the word is empty. The players move in tu... | instruction | 0 | 12,834 | 6 | 25,668 |
Tags: dfs and similar, dp, games, implementation, strings, trees
Correct Solution:
```
N = 100000
Z = 26
#别用这玩意儿: trie = [[0] * Z] * N 巨坑!https://www.cnblogs.com/PyLearn/p/7795552.html
trie = [[0 for i in range(Z)] for j in range(N)]
n = 0
k = 0
nodeNum = 0
def insertNode():
u = 0
string = input()
global nodeNum
... | output | 1 | 12,834 | 6 | 25,669 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Andrew, Fedor and Alex are inventive guys. Now they invent the game with strings for two players.
Given a group of n non-empty strings. During the game two players build the word together, initially the word is empty. The players move in tu... | instruction | 0 | 12,835 | 6 | 25,670 |
Tags: dfs and similar, dp, games, implementation, strings, trees
Correct Solution:
```
"""
Codeforces Contest 260 Div 1 Problem B
Author : chaotic_iak
Language: Python 3.3.4
"""
def main():
n,k = read()
s = set()
for i in range(n): s.add(read(0))
s = list(s)
s.sort()
s = treeify(s)
res = ... | output | 1 | 12,835 | 6 | 25,671 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Andrew, Fedor and Alex are inventive guys. Now they invent the game with strings for two players.
Given a group of n non-empty strings. During the game two players build the word together, initially the word is empty. The players move in tu... | instruction | 0 | 12,836 | 6 | 25,672 |
Tags: dfs and similar, dp, games, implementation, strings, trees
Correct Solution:
```
# https://codeforces.com/contest/455/problem/B
import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
class Trie:
def __init__(self):
self.arr = {}
def insert(self, word):
for x in wor... | output | 1 | 12,836 | 6 | 25,673 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Misha hacked the Codeforces site. Then he decided to let all the users change their handles. A user can now change his handle any number of times. But each new handle must not be equal to any handle that is already used or that was used at s... | instruction | 0 | 12,859 | 6 | 25,718 |
Tags: data structures, dsu, strings
Correct Solution:
```
n=int(input())
queries=[]
names=[]
f=[]
l=[]
for i in range(n):
queries.append(input().split(' '))
for i in range(n):
for j in range(2):
if queries[i][j] in names:
if j==0:
names.remove(queries[i][j])
l... | output | 1 | 12,859 | 6 | 25,719 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Misha hacked the Codeforces site. Then he decided to let all the users change their handles. A user can now change his handle any number of times. But each new handle must not be equal to any handle that is already used or that was used at s... | instruction | 0 | 12,860 | 6 | 25,720 |
Tags: data structures, dsu, strings
Correct Solution:
```
queries = []
for q in range(int(input())):
old, new = input().split()
done = False
for elem in queries:
if old == elem[-1]:
elem.append(new)
done = True
break
if not done:
queries.append([old, n... | output | 1 | 12,860 | 6 | 25,721 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Misha hacked the Codeforces site. Then he decided to let all the users change their handles. A user can now change his handle any number of times. But each new handle must not be equal to any handle that is already used or that was used at s... | instruction | 0 | 12,861 | 6 | 25,722 |
Tags: data structures, dsu, strings
Correct Solution:
```
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n = int(input())
b_a = {}
for n_ in range(n):
b, a = input().split()
replaced = False
for k in b_a:
if b_a[k] == b:
b_a[k] = a
replaced = True
if not replaced:
... | output | 1 | 12,861 | 6 | 25,723 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Misha hacked the Codeforces site. Then he decided to let all the users change their handles. A user can now change his handle any number of times. But each new handle must not be equal to any handle that is already used or that was used at s... | instruction | 0 | 12,862 | 6 | 25,724 |
Tags: data structures, dsu, strings
Correct Solution:
```
#/usr/bin/env python3
N = int(input())
names = [input().split() for i in range(N)]
c_to_old = dict()
for n in names:
if n[0] not in c_to_old:
c_to_old[n[1]] = n[0]
else:
old = c_to_old[n[0]]
del c_to_old[n[0]]
c_to_old[... | output | 1 | 12,862 | 6 | 25,725 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Misha hacked the Codeforces site. Then he decided to let all the users change their handles. A user can now change his handle any number of times. But each new handle must not be equal to any handle that is already used or that was used at s... | instruction | 0 | 12,863 | 6 | 25,726 |
Tags: data structures, dsu, strings
Correct Solution:
```
# MC521 - Desafios de Programacao I - 1s2021
# Contest: 02/04/2021
# Problema J: Misha and Changing Handles
# le o numero de alteracoes a serem realizadas
n = int(input())
# inicializa o mapa dos idenficadores
alt = {}
# realiza a leitura das alteracoes e map... | output | 1 | 12,863 | 6 | 25,727 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.