description
stringlengths
35
9.39k
solution
stringlengths
7
465k
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
tiles = list(map(str, input().split())) cnt = [0]*3 pos = [[0 for x in range(3)] for y in 'mps'] mps = ['m', 'p', 's'] for i in range(3): t = tiles[i] p = int(mps.index(t[1])) cnt[p] += 1 pos[p][i] = t[0] if 3 in cnt: i = cnt.index(3) tmp = pos[i] tmp.sort() if int(tmp[0])+1 == int(tmp[1]) and int(tmp[1]) + ...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
def split(s): return [int(s[0]), s[1]] def check_seq(nums, colors): for n in nums: if n not in range(1,10): return False if len(set(colors)) != 1: return False nums = set(sorted(nums)) a = sorted(nums)[0] return {a, a+1, a+2} == nums def main(): a, b, c = input().split(' ') if len(set([a,b,c])) == 1...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
def check(aa): a=[i for i in aa] b = a[:] b.sort() ans1 = 100 c = [int(i[0]) for i in a] for i in range(3): m = 10 ** 12 for j in range(3): if c[i]-2+j>=0: d = [] d.append(str(c[i] - 2 + j) + a[i][1]) d.append(str(c[i] ...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.StringTokenizer; import java.io.BufferedReader; imp...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
def iskoutsu(arr): return len(set(arr)) == 1 def isshuntsu(arr): nos = [int(ele[0]) for ele in arr] nos.sort() return nos[0]+1 == nos[1] and nos[1]+1 == nos[2] and len(set([ele[1] for ele in arr])) == 1 arr = input().strip().split() if isshuntsu(arr) or iskoutsu(arr): exit(print(0)) # to make koutsu total1 = 0 ...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
#include <bits/stdc++.h> using namespace std; struct data { int v; char a; }; bool compare(data c, data d) { if (c.a > d.a) return true; else if (c.a == d.a) { if (c.v < d.v) return true; else return false; } return false; } int main() { int i, j, k, l; data arr[3]; cin >> arr[...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
import java.io.*; import java.math.BigInteger; import java.util.*; public class gym{ public static void main(String[] args) throws IOException{ MScanner sc = new MScanner(System.in); PrintWriter pw=new PrintWriter(System.out); HashMap<Character,Character>h=new HashMap<Character,Character...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
li = list(map(str,input().split())) lis=[ i[1]+i[0] for i in li] lis.sort() ans=[] ans.append(1) for i in range(1,len(lis)): if lis[i]==lis[i-1]: ans[-1]+=1 else: ans.append(1) an=min(max(ans),3) #print(ans,lis) if an==3: print('0') exit() ans=[] ans.append(1) for i in range(1,len(lis)):...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
import javax.print.DocFlavor; import javax.swing.plaf.basic.BasicInternalFrameTitlePane; import java.io.*; import java.lang.reflect.Array; import java.math.BigInteger; import java.net.CookieHandler; import java.nio.Buffer; import java.nio.charset.IllegalCharsetNameException; import java.sql.BatchUpdateException; import...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
# alpha = "abcdefghijklmnopqrstuvwxyz" # prime = 998244353 # INF = 1000_000_000 # from heapq import heappush, heappop from collections import defaultdict # from math import sqrt # from collections import deque # from math import gcd t = 1#int(input()) for test in range(t): # n = int(input()) # strs = ...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
''' 1. Figure out min number to get a kontsu Get a 'counter', count exact match. - 3 - find max value 2. Figure out min number to get a mentsu Sort the cards Do a while loop While i is < len(lst) Count # of consecutive cards Move j until index of the last consecutive card ''...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
import java.io.*; import java.lang.reflect.Array; import java.math.BigInteger; import java.util.*; public class q5 { public static void main(String[] args) throws IOException { Reader.init(System.in); PrintWriter out=new PrintWriter(System.out); // String[] arr=new String[3]; int[][] count=ne...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
from __future__ import print_function import sys def get_seq(line): a = line.split() d = {'m': [], 'p': [], 's': []} for x in a: n = ord(x[0]) - ord('0') d[x[1]].append(n) l = [(len(l), l) for l in d.values()] l.sort(reverse=True) return sorted(l[0][1]) def get_best(a): ...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
f = lambda c: 'mps'.index(c) l = [[], [], []] for c in input().split(): a, b = c l[f(b)].append(int(a)) for i in range(3): l[i].sort() res = 3 for x in l: if len(x) == 0: continue elif len(x) == 1: res = min(res, 2) elif len(x) == 3: if len(set(x)) == 1: res = min(res, 0) ...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
import collections as cl v = sorted(input().split()) cnt = cl.Counter(v) seq = 1 if int(v[0][0]) + 1 == int(v[1][0]) and v[0][1] == v[1][1]: if int(v[1][0]) + 1 == int(v[2][0]) and v[1][1] == v[2][1]: seq = 3 else: seq = 2 elif int(v[0][0]) + 2 == int(v[1][0]) and v[0][1] == v[1][1]: seq = 2...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
n=input() q=n.replace(" ","") a=list(q) suit=[] no=[] for i in range(6): if i%2==0: no.append(a[i]) else: suit.append(a[i]) noo=[int(i) for i in no] temp=[0,0,0] su="a" for i in suit: if i=='m': temp[0]+=1 elif i=='p': temp[1]+=1 elif i=='s': temp[2]+=1 tem=tu...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
import java.util.*; import java.lang.*; import java.io.*; public class SolutionB { public void solve(){ Scanner sc = new Scanner(System.in); String one = sc.next(); String two = sc.next(); String three = sc.next(); if(one.equals(two) && two.equals(three)){ System.out.println(0); return; } if(one...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
a=sorted(10*ord(y)+int(x)for x,y in input().split()) s={a[1]-a[0],a[2]-a[1]} print(2-bool(s&{0,1,2})-(s in({0},{1})))
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
s = input() st = s.split() st.sort() ans=2 if st[0]==st[1] and st[1]==st[2]: ans=0 if st[0][1]==st[1][1] and st[1][1]==st[2][1]: if int(st[0][0])+1==int(st[1][0]) and int(st[1][0])+1==int(st[2][0]): ans=0 if st[0]==st[1] or st[1]==st[2] or st[0]==st[2]: ans=min(1,ans) if st[0][1]==st[1][1]: if int(st[1][0])-...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
a,b,c=input().split() def fine(x): if x[0]==x[1] and x[1]==x[2]: return True if x[0][1]==x[1][1] and x[1][1]==x[2][1]: if (int(x[0][0])+1)==int(x[1][0]) and (int(x[0][0])+2)==int(x[2][0]): return True return False l=[a,b,c] for i in range(3): for j in range(3): for k ...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
a=input().split() n={} n['m']=[0 for i in range(9)] n['s']=[0 for i in range(9)] n['p']=[0 for i in range(9)] maxcount=1 for i in a: t=i[1] l=int(i[0]) n[t][l-1]+=1 if n[t][l-1]>maxcount: maxcount=n[t][l-1] flag=1 if maxcount==2 and flag: print(1) flag=0 if maxcount==3 and flag:...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
import java.io.*; import java.math.*; import java.util.*; import java.util.Arrays; public class Test1{ public static void main(String args[])throws IOException{ Scanner sc=new Scanner(System.in); String s[]=new String[3]; s[0]=sc.next(); s[1]=sc.next(); s[2]=sc.next(); ...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
import java.util.*; public class solver{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); String s1 = sc.next(); String s2 = sc.next(); String s3 = sc.next(); sc.close(); if(s1.equals(s2) && s2.equals(s3)) { System.out.println(0); return; } int a = Integer.par...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
#include <bits/stdc++.h> using namespace std; char s[3][10]; int cnt[1000]; int a[10]; set<int> ss; struct node { int ch, val; node(int ch = 0, int val = 0) { this->ch = ch; this->val = val; } friend bool operator<(const node& mm, const node& gg) { if (mm.ch != gg.ch) return mm.ch < gg.ch; ...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
h = sorted(list(input().split())) if len(set(h)) < 3: print(len(set(h)) - 1) else: n = list(map(int, (h[0][0], h[1][0], h[2][0]))) s = [h[0][1], h[1][1], h[2][1]] if len(set(s)) == 3: print(2) elif len(set(s)) == 2: if h[0][1] == h[1][1] and abs(n[0] - n[1]) < 3 or h[0][1] == h[2][1]...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
import java.io.*; import java.util.*; public class cardgame { public static void main(String[] args) throws Exception{ // TODO Auto-generated method stub Scanner inputs = new Scanner(System.in); String[] cards = new String[3]; int[] nums = new int[3]; char[] lets = new char[3]; for(int i=0;i<3;i++) { c...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
a, b, c = map(str, input().split()) if a == b == c: print(0) exit(0) p = [int(a[0]), int(b[0]), int(c[0])] p.sort() if a[1] == b[1] == c[1] and p[2] - p[1] == p[1] - p[0] == 1: print(0) elif a == b: print(1) elif b == c: print(1) elif a == c: print(1) elif a[1] != b[1] and b[1] != c[1] and c[1] ...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
def meth(arr): for i in range(3): arr[i]=int(arr[i]) arr.sort() if arr[0]+1==arr[1] and arr[0]+2==arr[2]: return 0 if arr[1]-arr[0]>=3 and arr[2]-arr[1]>=3: return 2 return 1 def meth1(arr): for i in range(2): arr[i]=int(arr[i]) arr.sort() if arr[0]+1==...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
t = sorted(input().split()) ans = 3 l = 0 while l < len(t): r = l while r < len(t) and t[r] == t[l]: r += 1 ans = min(ans, 3 - (r - l)) l = r t = sorted(list(set(t)), key=lambda e: e[1] + e[0]) l = 0 while l < len(t): r = l while r < len(t) and t[r][1] == t[l][1]: r += 1 for ...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
l=input().split() l.sort() if l[0]==l[1]==l[2]: print(0) elif l[0][1]==l[1][1]==l[2][1]: if int(l[0][0])-int(l[1][0])==int(l[1][0])-int(l[2][0])==-1: print(0) elif int(l[0][0])-int(l[1][0])>=-2 or int(l[1][0])- int(l[2][0])>=-2 or int(l[0][0])-int(l[2][0])>=-2: print(1) else: pri...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
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" not in file.mode self.write = self.buffer.write if self...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
a=sorted(10*ord(x[1])+int(x[0])for x in input().split()) s={a[1]-a[0],a[2]-a[1]} print(2-bool(s&{0,1,2})-(s in({0},{1})))
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
#include <bits/stdc++.h> using namespace std; int minimum(int x, int y, int z) { return min(x, min(y, z)); } int main() { unordered_map<char, vector<int> > m; unordered_map<char, vector<int> >::iterator itr; string a, b, c; cin >> a >> b >> c; itr = m.find(a[1]); if (itr == m.end()) { vector<int> v; ...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
def dbl(x, y): if x[1] != y[1]: return False else: return abs(x[0] - y[0]) < 3 p = sorted(map(lambda x: (int(x[0]), x[1]), input().split())) k = dbl(p[0], p[1]) + dbl(p[0], p[2]) + dbl(p[1], p[2]) if k == 0: print(2) elif k == 3 and 2 * p[1][0] == p[0][0] + p[2][0]: print(0) else: p...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
def solve(arr): d = Counter(arr) mx = 0 for i in d.keys(): mx = max(mx,d[i]) if mx >= 3: return 0 d1 = {'m':[],'p':[],'s':[]} for a,v in arr: d1[v].append(int(a)) count = 0 counttwo = 0 #print(d1) for key in d1.keys(): if len(d1[key]) > 0: ...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
import sys #sys.stdin = open('in', 'r') #n = int(input()) #n,m = map(int, input().split()) #a = [int(x) for x in input().split()] inp = input().split() m = [0]*10 s = [0]*10 p = [0]*10 for st in inp: if st[1] == 'm': m[int(st[0])] += 1 if st[1] == 's': s[int(st[0])] += 1 if st[1] == 'p': ...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
import java.util.*; import java.lang.*; import java.math.*; import java.io.*; import java.text.*; public class Rough{ static PrintWriter w=new PrintWriter(System.out); public static void main(String [] args){ DecimalFormat dm=new DecimalFormat("0.000000"); Scanner sc=new Scanner(System.in);...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
a=input().split() for i in range(3): a[i]=[int(a[i][0]),a[i][1]] a.sort() if (a[0][0]+2==a[1][0]+1==a[2][0] and a[0][1]==a[1][1]==a[2][1]) or (a[0]==a[1]==a[2]): print(0) elif ((a[0][0]+1==a[1][0] or a[0][0]+2==a[1][0]) and a[0][1]==a[1][1]) or ((a[1][0]+1==a[2][0] or a[1][0]+2==a[2][0]) and a[1][1]==a[2][1]) o...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
# target Specialist """ Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. * Readability counts * // Author...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); vector<string> ar(3); for (int i = 0; i < 3; ++i) cin >> ar[i]; sort(ar.begin(), ar.end()); char a = ar[0][0]; char b = ar[1][0]; char c = ar[2][0]; if (a - '0' + 1 == b - '0' && b -...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); map<char, vector<long long>> mp; string s[3]; bool flag; for (long long i = 0; i < 3; i++) { cin >> s[i]; mp[s[i][1]].push_back(s[i][0] - '0'); } if (s[0] == s[1] && s[1] == s[2]) { cout <<...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.*; import java.lang.Math.*; public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; Scanner in = new Scanner...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
import sys ss = sys.stdin.readline().replace('\n', '').split() def brick (sb): return (int(sb[0]), sb[1]) ss = map(brick, ss) ss = sorted(ss) a = ss[0] b = ss[1] c = ss[2] if ss[0] == ss[1] and ss[1] == ss[2]: print "0" elif a[1] == b[1] and b[1] == c[1] and a[0] == b[0]-1 and b[0] == c[0]-1: print "0" elif a ==...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
l = list(input().split()) d = {} for i in l: if i[1] not in d:d[i[1]] = [int(i[0])] else: d[i[1]].append(int(i[0])) best = [] for i in d: if len(d[i]) > len(best): best = d[i] best.sort() if len(best)==1:print(2) elif len(set(best))==1:print(3-len(best)) else: if len(best)==3: if...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
import sys input = sys.stdin.readline sys.setrecursionlimit(100000) def getN(): return int(input()) def getList(): return list(map(int, input().split())) import math def main(): # something pie = input().split() man = [] pin = [] soh = [] for p in pie: if p.endswith("p"): ...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
tl=list(map(str,input().split())) n1=tl[0][0] n2=tl[1][0] n3=tl[2][0] s1=tl[0][1] s2=tl[1][1] s3=tl[2][1] nl=[int(n1),int(n2),int(n3)] sl=[s1,s2,s3] #print(nl) #print(sl) if len(set(sl))==3: print(2) elif len(set(sl))==1: if len(set(nl))==1: print(0) elif len(set(nl))==2: print(1) else: ...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
#include <bits/stdc++.h> using namespace std; char s[10][4]; int main() { scanf("%2s %2s %2s", s[0], s[1], s[2]); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3 - i - 1; j++) { if (strcmp(s[j], s[j + 1]) == 1) { swap(s[j], s[j + 1]); } } } int cot = 0; if (strcmp(s[0], s[1]) =...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
def f(a, b, c): if a[0] > b[0]: a, b = b, a if abs(int(a[0]) - int(b[0])) == 1 and a[1] == b[1]: if a[1] == c[1] and abs(int(c[0]) - int(b[0])) == 1 and a != c: return 0 else: return 1 if abs(int(a[0]) - int(b[0])) == 2 and a[1] == b[1]: return 1 r...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
from sys import stdin, stdout, exit t1, t2, t3 = stdin.readline().split() if t1 == t2 and t2 == t3: print(0) exit() ts = [(int(t[0]), t[1]) for t in [t1, t2, t3]] ts.sort() ns = [t[0] for t in ts] ss = [t[1] for t in ts] if ns[0] + 1== ns[1] and ns[0] + 2 == ns[2] and ss[0] == ss[1] and ss[1] == ss[2]: ...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
from collections import Counter a=map(str,raw_input().split()) d=Counter(a) m=100 for i in d: m=min(m,3-d[i]) dic={} for i in a: if(dic.get(i[-1])): dic[i[-1]].append(int(i[0])) else: dic[i[-1]]=[(int(i[0]))] # print dic for i in dic: f=list(set(dic[i])) # print f # print f if(len(f)==1): m=min(m,2) elif...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int m[]=new int[10]; int s[]=new int[10]; int p[]=new int[10]; String st =sc.next(); if(st.charAt(1)=='m'){m[st.charAt(0)-'0']+...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
from __future__ import print_function le=['m','p','s'] d={str(k)+i:0 for k in range(1,10) for i in le} for k in raw_input().split(): d[k]+=1 def tr(): for k in d: if d[k]==3: return True for k in range(1,8): for deb in ['m','p','s']: if d[str(k)+deb]*d[str(k+1)+deb]*d...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
from sys import stdin a = [str(x) for x in stdin.readline().split()] ans = len(set(a)) - 1 for ch in ['s', 'p', 'm']: all = [str(i) + ch for i in range(1, 10)] for i in range(3, 10): tem = 0 for j in range(i - 1, i - 4, -1): if all[j] not in a: tem = 2 ...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
a,b,c = map(str, raw_input().split()) def f2(a,b,c): x = [int(a[0]), int(b[0]), int(c[0])] x.sort() # print (a,b,c) if a==b and b==c and c==a: return 0 elif a[1]==b[1] and b[1]==c[1] and c[1]==a[1] and x[1]-x[0]==1 and x[2]-x[1]==1: return 0 elif a==b or b==c or c==a: re...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; import java.util.StringTokenizer; import java.io.PrintWriter; public class Ideone { static class FastReader { BufferedReader br; StringTokenizer st; public FastRe...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
x,y,z = input().split() p = [] n1 = int(x[0]) n2 = int(y[0]) n3 = int(z[0]) p.append(int(n1)) p.append(int(n2)) p.append(int(n3)) p.sort() t1 = x[1] t2 = y[1] t3 = z[1] #Zero cards required if(((t1 == t2 == t3)and(n1 == n2 == n3)) or ((t1 == t2 == t3) and p[1] == p[0]+1 and p[2] == p[0]+2)): print(0) #One card re...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
# m = k ΠΈΠ»ΠΈ s # k = Ρ‚Ρ€ΠΈ ΠΈΠ΄Π΅Π½Ρ‚ΠΈΡ‡Π½Ρ‹Ρ… Ρ‚Π°ΠΉΠ»Π° # s = Ρ‚Ρ€ΠΈ ΠΏΠΎΡΠ»Π΅Π΄ΠΎΠ²Π°Ρ‚Π΅Π»ΡŒΠ½Ρ‹Ρ… Ρ‚Π°ΠΉΠ»Π° def check(l, r, d=1): return l[0] == r[0] - d and l[1] == r[1] s = [i for i in input().split()] a = [] for i in s: a.append([int(i[0]), i[1]]) a.sort() if s[0] == s[1] == s[2] or check(a[0], a[1]) and check(a[1], a[2]): print(0) ...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
import random as random def quicksort(nums): if len(nums) <= 1: return nums else: q = random.choice(nums) l_nums = [n for n in nums if n < q] e_nums = [q] * nums.count(q) b_nums = [n for n in nums if n > q] return quicksort(l_nums) + e_nums + quicksort(b_nums) l = list(input()....
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
d={"s":100,"p":200,"m":300};z=sorted([int(i[0])+d[i[1]] for i in map(str,input().split())]) if len(set(z))==1 or (z[0]==z[1]-1 and z[1]==z[2]-1):print(0) elif (z[0]==z[1] or z[1]==z[2]) or (z[1]-z[0] in [1,2] or z[2]-z[1] in [1,2]):print(1) else:print(2)
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
#include <bits/stdc++.h> using namespace std; string s[3]; int main() { while (cin >> s[0] >> s[1] >> s[2]) { if (s[0] == s[1] && s[1] == s[2]) { puts("0"); } else if (s[0] == s[1] || s[0] == s[2] || s[1] == s[2]) { puts("1"); } else { int cntm = 0, cntp = 0, cnts = 0; for (int i =...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
import java.util.Scanner; import java.util.Arrays; import java.util.HashMap; import java.util.Vector; public class B{ public static void main(String[] args){ Scanner in = new Scanner(System.in); StringBuilder str = new StringBuilder().append(in.nextLine()); //System.out.println(str); String[] hand = str.toStri...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
#include<bits/stdc++.h> #include<stdio.h> //per fare input output con scanf and printf #include<stdlib.h> //per fare qsort e bsearch #include<string.h> // per fare strcpy(sarrivo, spartenza) strcat(str, aggiungo) strcmp(a,b) che da 0 se sono uguali #include<math.h> #include<algorithm> #include<iostream> #include<queue>...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
import java.io.*; import java.util.*; public class B { class Token implements Comparable<Token> { int n; char c; public Token(int n, char c) { this.n = n; this.c = c; } @Override public int compareTo(Token o) { if (c == o.c) { ...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
l=input().split() if(len(set(l))==1): print(0) else: d=dict() #d1=dict('s':0,'m':0;'p':0) for i in l: if(i[1] not in d): d[i[1]]=[int(i[0])] else: d[i[1]].append(int(i[0])) mi=9 for i in d.values(): if(len(i)>0): i.sort() if(len(i)==3): c=[] for j in range(0,2): c.append(abs(i[j...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
from sys import * m=list(input().split()) ans1=ans2=2 d=[] if m[0][1]==m[1][1]: if abs(int(m[0][0])-int(m[1][0]))<=2 and abs(int(m[0][0])-int(m[1][0]))!=0: ans1-=1 d.append(int(m[0][0])-int(m[1][0])) if abs(int(m[0][0])-int(m[1][0]))==0: ans2-=1 if m[0][1]==m[2][1]: if abs(int(m[0][...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
def check(a, b): if a[1] == b[1] and 1 <= abs(int(b[0]) - int(a[0])) <= 2: return True arr = input().split() d = {} for i in arr: d[i] = d.get(i, 0) + 1 mineq = 3 - max(d.values()) arr.sort(key=lambda x: x[0]) arr.sort(key=lambda x: x[1]) if check(arr[0], arr[1]) or check(arr[1], arr[2]): mineq = m...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
def main(): s = input().split() maxIdent = 0 maxIncr = 0 for el in s: cnt = s.count(el) if cnt == 3: print(0) return if cnt > maxIdent: maxIdent = cnt cnt2 = 1 item1 = str(int(el[0]) + 1) + el[1] item2 = s...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
#573_B st = input().split(" ") nums = sorted([[int(i[0]), i[1]] for i in st]) if st[0] == st[1] and st[1] == st[2]: print(0) elif nums[0][1] == nums[1][1] and nums[1][1] == nums[2][1] and nums[0][0] == nums[1][0] - 1 and nums[1][0] == nums[2][0] - 1: print(0) else: if nums[0][1] == nums[1][1] and nums[1]...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
// No sorceries shall previal. // import java.util.Scanner; import java.io.PrintWriter; import java.util.Arrays; import java.io.*; import java.util.*; public class InVoker { public static void main(String args[]) { Scanner inp = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); Str...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
a,b,c=raw_input().split() d={'p':[],'m':[],'s':[]} d[a[1]].append((int(a[0]))) d[b[1]].append((int(b[0]))) d[c[1]].append((int(c[0]))) c=100 for k in d.keys(): d[k].sort() if(len(d[k])==1): c=min(c,2) elif(len(d[k])==0): c=min(3,c) elif(len(d[k])==2): if(d[k][0]==d[k][1]-1):c=m...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
import java.io.*; public class mahjong { public static void main(String args[])throws IOException { InputStreamReader read=new InputStreamReader(System.in); BufferedReader in=new BufferedReader(read); int i,r,t; r=0; String s,st; s=in.readLine(); s+=' '; int[] a=new int[3]; for(i=0;i<s.length();i++)...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
a,b,c = input().split() if a[1] == b[1] == c[1]: t = sorted([int(a[0]),int(b[0]),int(c[0])]) if (t[1] == t[0] + 1 == t[2] - 1) or (t[0] == t[2]):print(0) elif t[0] == t[1] or t[1] == t[2]:print(1) elif t[0] + 1 == t[1] or t[1] + 1 == t[2] or t[0] + 2 == t[1] or t[1] + 2 == t[2]:print(1) else:print(2...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
def get_min_draw(d): symbols = list(d.keys()) min_draw = 3 for key in symbols: for i in range(1, 8): curr = 3 if i in d[key]: curr -= 1 if i + 1 in d[key]: curr -= 1 if i + 2 in d[key]: curr -= 1 ...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
lis = list(map(str,input().split())) ans = 2 s = len(set(lis)) if s==1: ans = 0 elif s==2: ans = 1 lis.sort() if int(lis[0][0])+1 == int(lis[1][0]) and lis[0][1] == lis[1][1] and int(lis[1][0])+1 == int(lis[2][0]) and lis[1][1] == lis[2][1]: ans = min(ans,0) elif int(lis[0][0])+1 == int(lis[1][0]) and l...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
def trans(x): return int(x[0])*10+{"m":0,"p":1,"s":2}[x[1]] def isKoutsu(a,b,c): return a == b and a == c def isShuntsu(a,b,c): x, z = max(a,b,c), min(a,b,c) y = (a + b + c) - (x + z) return x - y == 10 and y - z == 10 a,b,c = map(trans, input().split(' ')) if isKoutsu(a,b,c) or isShuntsu(a,b,c): print(0) exit(0...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
/* If you want to aim high, aim high Don't let that studying and grades consume you Just live life young ****************************** If I'm the sun, you're the moon Because when I go up, you go down ******************************* I'm working for the day I will surpass you **************************************** *...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
m={"s":[0]*9, "m":[0]*9, "p":[0]*9} for e in input().split(): m[e[1]][int(e[0])-1]+=1 ret=2 for t in "smp": l=m[t] if max(l)>=2: ret=min(ret, 3-max(l)) else: for i in range(7): seq = sum(l[i:i+3]) ret = min(ret, 3-seq) print(ret)
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
import java.util.*; import java.io.*; public class B_Tokitsukaze_and_Mahjong { public static void main(String[] args) throws IOException{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out); StringTokenizer st=new StringTokenizer(br.readLine()); ...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
a, b, c = input().split() if a == b and b == c : print("0") else : ok = False if a[1] == b[1] and b[1] == c[1] : aa, bb, cc = int(a[0]), int(b[0]), int(c[0]) l = [aa, bb, cc] l.sort() if l[0] == l[1]-1 and l[1] == l[2]-1 : ok = True if ok : print("0") else : if a == b or b == c or a==c : print("...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
ll= lambda : list(map(int,input().split())) testcases=1 # testcases=int(input()) for testcase in range(testcases): s1,s2,s3=input().split() ss=[s1,s2,s3] ss.sort() if(len(set([i[1] for i in ss]))==1): if(len(set([i[0] for i in ss]))==1 or ((int(ss[0][0])==int(ss[1][0])-1) and (int(ss[0][0])==int(ss[2][0])-2))): ...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
import java.io.*; import java.util.ArrayList; import java.util.Collections; import java.util.StringTokenizer; public class F { public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); PrintWriter writer = new PrintWrit...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
s1,s2,s3=map(str,input().split()) arr=[] arr.append(ord(s1[0])) arr.append(ord(s2[0])) arr.append(ord(s3[0])) flag=0 if s1==s2 and s1==s3: flag=1 print(0) if s1[1]==s2[1] and s1[1]==s3[1]: arr.sort() if arr[1]-arr[0]==1 and arr[2]-arr[1]==1: if flag==0: flag=1 print(0) i...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
a,b,c = input().split() ans = 2 if a == b == c: ans = 0 elif a[1] == b[1] == c[1]: l = sorted([int(a[0]), int(b[0]), int(c[0])]) if l[0] == l[1] - 1 == l[2] - 2: ans = 0 if ans != 0: if a == b or b == c or a == c: ans = 1 else: if a[1] == b[1] and abs(int(a[0]) - int(b[0]))...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
#include <bits/stdc++.h> using namespace std; const int INF = 1000000000; const double EPS = 1e-9; int mods(int a, int b) { return (b + (a % b)) % b; } bool compare(string a, string b) { if (a[1] == b[1]) return a[0] < b[0]; return a[1] < b[1]; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
#include <bits/stdc++.h> using namespace std; void err(istream_iterator<string> it) {} template <typename S37, typename... Args> void err(istream_iterator<string> it, S37 a, Args... args) { cerr << *it << " = " << a << endl; err(++it, args...); } const long long N = 300100, mod = 1e9 + 7, mod2 = 1e9 + 9, mod3 = 998...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
s=input().split() hashi=dict() for i in s: if(i in hashi): hashi[i]+=1 else: hashi[i]=1 maxa=3 for i in ['s','m','p']: for j in range(1,10): z=chr(48+j)+i if z in hashi: maxa=min(maxa,3-hashi[z]) for i in ['s','m','p']: for j in range(1,8): z1=chr(48+j...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
import java.util.Arrays; import java.util.Scanner; public class TokitsukazeMahjong { public static void main(String[] args) { Scanner in = new Scanner(System.in); String s1 = in.next(), s2 = in.next(), s3 = in.next(); in.close(); char c1 = s1.charAt(1), c2 = s2.charAt(1), c3 = s3.charAt(1); int i1 = Integ...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
''' parse the string so that we have a dictionary of s - [1, 3, 5] p -[2, 2] m - [1] it is 1-9 for each of the color, we check can we form a 3 same number -- this is easy, have a another count or 3 consercutive number -- this is easy as well, sort the list and traverse over ''' def parse_string_to_counts(inpu...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
q = list(input().split()) s1 = q[0] s2 = q[1] s3 = q[2] #print(1) l = [] #print(q[:-1]) #print(s1[:-1]) l.append(int(s1[:-1])) l.append(int(s2[:-1])) l.append(int(s3[:-1])) if(s1==s2==s3): print('0') exit() if(s1[-1]==s2[-1] and s2[-1]==s3[-1] and s3[-1]==s1[-1]): #print(1) a = sorted(l) if(a[2]-a[...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
#include <bits/stdc++.h> long long power(long long a, long long b, long long c) { long long ans = 1; a = (a % c); while (b > 0) { if (b & 1) { ans = (ans * a) % c; } b = b >> 1; a = (a * a) % c; } return ans; } using namespace std; int main() { vector<string> s; for (int i = 0; i < 3...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); string s1, s2, s3; cin >> s1 >> s2 >> s3; long long ans = 3; set<string> s; s.insert(s1); s.insert(s2); s.insert(s3); if (s.size() == 1) ans = 0; else if (s.size() == 2) ans = 1; e...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
#include <bits/stdc++.h> using namespace std; int judge(string a1, string a2, string a3) { int ans1 = 2, ans2 = 2, ans3 = 2, ans4 = 2, ans5 = 2, ans6 = 2, ans7 = 2; if (a1 == a2) ans1--; if (a1 == a3) ans1--; string a4, a5; a4 += (((a1[0] - '0') + 1) + '0'); a5 += (((a1[0] - '0') - 1) + '0'); a4 += a1[1];...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
from collections import Counter ts=Counter(''.join(reversed(t)) for t in input().split()) t0 = None run = 0 ans = 3 for t, c in sorted(ts.items()): if t0 is None or t[0] != t0[0] or int(t[1]) != int(t0[1])+1: run = 0 t0 = t run += 1 ans = min(ans, 3-max(c,run)) for s in 'spm': for r in range...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
import java.util.*; import java.io.*; public class Main { PrintWriter out; FastReader sc; long[] m= {(long)(1e9+7),998244353}; long mod=m[1]; long maxlong=Long.MAX_VALUE; long minlong=Long.MIN_VALUE; /****************************************************************************************...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
""" NTC here """ from sys import setcheckinterval, stdin setcheckinterval(1000) # print("Case #{}: {} {}".format(i, n + m, n * m)) iin = lambda: int(stdin.readline()) lin = lambda: list(map(int, stdin.readline().split())) def check1(a): if not a: return 3 n=len(a) ans=1 for i in range(n): ...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
c1, c2, c3 = input().strip().split() nums = sorted([int(c1[0]), int(c2[0]), int(c3[0])]) if c1 == c2 == c3: print(0) elif (c1[1] == c2[1] == c3[1]) and (nums[0] == nums[1]-1 == nums[2]-2): print(0) elif c1 == c2 or c1 == c3 or c2 == c3: print(1) elif (c1[1] == c2[1] and abs(int(c1[0])-int(c2[0])) in (1,2)) ...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
#include <bits/stdc++.h> using namespace std; string s[3]; int main() { cin >> s[0] >> s[1] >> s[2]; int data[3]; for (int i = 0; i < 3; i++) { if (s[i][1] == 's') { data[i] = s[i][0] - '0' + 10 * 1; } else if (s[i][1] == 'm') { data[i] = s[i][0] - '0' + 10 * 3; } else if (s[i][1] == 'p') ...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
st = list(map(str, input().split())) def is_koutsu(s): cnt = 0 arr = [] for i in s: cnt = 0 for j in s: if i == j: cnt += 1 arr.append(cnt) return max(arr) def is_shuntsu(s): cnt = 0 arr = [] for i in s: cnt = 0 for j in s...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
# In[10]: m = {} p = {} s = {} for i in range(1,10): p[str(i)+'p'] = i s[str(i)+'s'] = i m[str(i)+'m'] = i card = [] card.append(m) card.append(p) card.append(s) # In[12]: a = input() tmp = a.split(' ') # In[13]: ma = [[],[],[]] for obj in tmp: if obj in card[0]: ma[0].append(int(obj[...
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c...
t=list(map(str,input().split())) t.sort(key=lambda x: x[1]+x[0]) s=0 ins=0 ist=0 m=0 inm=0 imt=0 p=0 inp=0 ipt=0 count=1 shout=1 prev=0 last=1 pout=1 one=0 for i in range(1,len(t)): prev=i-1 if(t[i][1]==t[prev][1]): if(int(t[i][0])==int(t[prev][0])): last=last+1 elif((int(t[i][0])==(int(t[prev][0])+1)) ): ...