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...
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solu...
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 TokitsuzakeAndMahjong { public static void main(String[] args) { Scanner scan=new Scanner(System.in); int onee[]=new int[3]; String two[]=new String[3]; for(int i=0;i<3;i++) { two[i]=scan.next(); // onee[i]=Integer.parseInt(one.substring(0,one.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...
t1,t2,t3 = map(str, input().split(" ")) arr = sorted([int(t1[0]),int(t2[0]),int(t3[0])]) if (t1 == t2 and t2 == t3) or (t1[1] == t2[1] and t2[1] == t3[1] and (arr[2] - arr[1]) == 1 and (arr[1] - arr[0]) == 1): print(0) elif (t1 == t2 or t2 == t3 or t3 == t1): print(1) elif (t1[1] == t2[1] and (abs(int(t1[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...
s = sorted(input().split()) a1 = set(s) if len(a1) == 1: print(0) else: max_len = {} ans = 2 i0 = s[0][1] i1 = int(s[0][0]) for i in s: max_len[i[1]] = [] for i in s: max_len[i[1]].append(int(i[0])) for i in max_len.keys(): temp = max_len[i] if len(temp) =...
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 = list(input().split()) k = dict() mk = 0 s = 0 for e in a: if e not in k: k[e] = 0 k[e] += 1 if k[e] > mk: mk = k[e] for e in a: temp = 1 num = int(e[0]) t = e[1] if (str(num + 1) + t) in k: temp += 1 if (str(num - 1) + t) in k: temp += 1 elif (str(num - 1) + t) in k: temp += 1 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 java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; public class Mahjong { public static void main(String args[])throws IOException{ BufferedReader in =new BufferedReader(new InputStreamReade...
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 = [hi for hi in raw_input().split(" ")] suits = ['m','p','s'] k23 = [] kf = [] s23 = [] sf = [] a = 1 b = 9 for i in range(a,b+1): # print i,i,i for suit in suits: k23 += [[str(i)+suit,str(i)+suit]] kf += [[str(i)+suit,str(i)+suit,str(i)+suit]] for i in range(a,b): for suit in suits: s23 += [[str(i)+suit,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=input().split() a.sort() b=[int(a[0][0]),int(a[1][0]),int(a[2][0])] e=[a[0][1],a[1][1],a[2][1]] if(len(set(a))==1): print(0) elif a[0]==a[1] or a[1]==a[2]: print(1) elif(len(set(e))==3): print(2) elif(len(set(e))==1): b.sort() k=2 o=0 if b[1]-b[0]==1: k-=1 o=1 if b[2]-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...
import java.util.Arrays; import java.util.Scanner; public class Hp { public static void main(String[] args) { Scanner in = new Scanner(System.in); int[] idx = new int[257]; int[][] count = new int[3][9]; idx['m']=1; idx['p']=2; idx['s']=3; for(int i=0;i<3;i++) { char[] x = in.next().toCharArray(); ++count...
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 num[4]; template <class T> int check_mod(T a, T b) { return (a % b) ? 1 : 0; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); vector<string> cards(3); for (int i = 0; i < 3; i++) cin >> cards[i]; sort(cards.begin(), cards.end...
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.*; import java.math.*; import java.lang.*; import static java.lang.Math.*; public class Cf182 implements Runnable { static class InputReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numChars; private SpaceCha...
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.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.StringTokenizer; public class Main { public static void main(String[] args) { ...
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.InputStreamReader; import java.util.StringTokenizer; import java.io.BufferedReader; import java.io.InputStream; public class Main { public static void main(String[] args) { InputS...
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 buc[101][101], ans = 0x3f3f3f3f; char ch1, ch2; int hash_(char c) { if (c == 'm') return 1; if (c == 'p') return 2; if (c == 's') return 3; } int main() { while (~scanf("%c%c%*c", &ch1, &ch2)) { ++buc[hash_(ch2)][ch1 - '0']; } for (int i = 1; i <= 9; ++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...
d = {} for i in ['s', 'm', 'p']: for j in range(1, 10): d[str(j)+i] = 0 keys = list(d.keys()) for i in input().split(): d[i] += 1 def is_valid0(): for i in range(3): for j in range(9): if d[keys[i*9:i*9+9][j]] > 2: return True for j in range(7): ...
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...
data = input().split() data.sort() dic = {"s":[], "m":[], "p":[]} for d in data: dic[d[1]].append(d) #mx = max([len(l) for l in dic.values()]) vals = list(dic.values()) vals.sort(key=lambda a: len(a)) lis = vals[-1] lis.sort() if len(lis) == 3: # sm = 0 # for a in range(2): # if lis[a] == lis[a+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 itertools import combinations from collections import defaultdict from copy import deepcopy import sys input = sys.stdin.readline ''' for CASES in range(int(input())): n, m = map(int, input().split()) n = int(input()) A = list(map(int, input().split())) S = input().strip() sys.stdout.write(" ".join(map(str,ans))+"...
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...
k = {"m":[0] * 9, "s":[0] * 9, "p":[0] * 9} p = 1 a = list(map(str, input().split())) for i in a: k[i[1]][int(i[0])-1] += 1 for j in k: for i in range(7): if(k[j][i] == 2 or k[j][i+1] == 2 or k[j][i+2] == 2): p = max(2, p) continue x = k[j][i] + k[j][i+1] + k[j][i+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 = input().split() a.sort() if len(set(a)) == 1: print(0) elif len(set(a)) == 2: print(1) else: d = {} for i in a: n = int(i[0]) c = i[1] if c in d: d[c].append(n) else: d[c] = [n] v = list(d.values()) cond0 = False cond1 = Fals...
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 s[15], p[15], m[15], ans, l, i, j, minim = 9; string s1[5]; int main() { for (int i = 0; i < 3; ++i) { cin >> s1[i]; if (s1[i][1] == 's') s[s1[i][0] - '0']++; if (s1[i][1] == 'p') p[s1[i][0] - '0']++; if (s1[i][1] == 'm') m[s1[i][0] - '0']++; } 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...
#Tokitsukaze and Mahjong DEBUG = False def debug(to_print_args): if not DEBUG: return for arg in to_print_args: print(arg,end='') print() # def shuntsu(num1,num2,num3,a1,a2,a3): # if num1+1=num2 and num1+2=num3: # if a1=a2 and a2=a3: # return True; # else 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...
''' Auther: ghoshashis545 Ashis Ghosh College: jalpaiguri Govt Enggineering College ''' from os import path import sys from heapq import heappush,heappop from functools import cmp_to_key as ctk from collections import deque,defaultdict as dd from bisect import bisect,bisect_left,bisect_right,insort,insort_lef...
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.net.SocketTimeoutException; import java.util.Arrays; import java.util.InputMismatchException; import java.util.StringTokenizer; public class B { static class FastWriter { private final BufferedWriter bw; public FastWriter() { t...
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 resource import sys #resource.setrlimit(resource.RLIMIT_STACK, [0x100000000, resource.RLIM_INFINITY]) #import threading #threading.Thread(target=main).start() #threading.stack_size(2**26) #sys.setrecursionlimit(10**6) mod=(10**9)+7 #fact=[1] #for i in range(1,100001): # fact.append((fact[-1]*i)%mod) #ifact=[...
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() l=[] s.sort() for i in s: l.append(int(i[0])) l.append(i[1]) if l[0]==l[2] and l[1]==l[3]: if l[0]==l[4] and l[1]==l[5]: print(0) else: print(1) elif l[4]==l[2] and l[5]==l[3]: print(1) elif l[0]+1==l[2] and l[1]==l[3]: if l[2]+1==l[4] and l[3]==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...
#d=[[] for i in range(26)] a=[0]*26 d={'p':[],'s':[],'m':[]} for i in input().split(): d[i[1]]+=int(i[0]), a[ord(i[1])-97]+=1 if max(a)==1:print(2) else: x=chr(a.index(max(a))+97);v=[] if len(d[x])==2: g=abs(d[x][0]-d[x][1]) if g==1 or g==0 or g==2:print(1) else:print(2) else: v+=abs(d[x][0]-d[x][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...
l = [x for x in input().split()] l.sort() if l[0] == l[2]: print(0) elif int(l[0][0]) + 2 == int(l[1][0]) + 1 == int(l[2][0]) and l[0][1] == l[1][1] == l[2][1]: print(0) elif l[0][1] == l[1][1] and int(l[1][0]) - int(l[0][0]) <= 2: print(1) elif l[1][1] == l[2][1] and int(l[2][0]) - int(l[1][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...
d = [[0] * 10 for i in range(3)] for i in input().split(): if i[1] == 'm': d[0][int(i[0])] += 1 elif i[1] == 'p': d[1][int(i[0])] += 1 else: d[2][int(i[0])] += 1 for i in range(3): for j in range(10): if d[i][j] == 3: print(0) exit() for i in ran...
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); ; string a, b, c; cin >> a >> b >> c; vector<int> m(10, 0); vector<int> p(10, 0); vector<int> s(10, 0); if (a[1] == 'm') { m[a[0] - 48]++; } else if (a[1] == 'p') { p[a[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('input.txt', 'r') # sys.stdout = open('output.txt', 'w') s = input() arr = list(s.split()) a = [0]*10 b = [0]*10 c = [0]*10 for ch in arr: num = int(ch[0]) ch = ch[1] if (ch == 'm'): a[num] += 1 elif (ch == 'p'): b[num] += 1 else: c[num]...
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 p(s,n): return str(int(s[0])+n)+s[1] a,b,c=sorted(input().split(),key=lambda x:int(x[0])) if a==b==c or (a==p(b,-1) and c==p(b,1)): print(0) elif a==b or b==c or a==c:print(1) else: if p(a,1) in [b,c] or p(a,2) in [b,c] or p(a,-1) in [b,c] or p(a,-2) in [b,c]: print(1) elif p(b,1) in [a,c] 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...
s=input().rstrip().split(' ') l=[] q=[] w=[] S=[] D=[] for i in range(0,len(s)): t=list(s[i]) if t[1]=='s': l.append(int(t[0])) elif t[1]=='p': q.append(int(t[0])) else: w.append(int(t[0])) l.sort() q.sort() w.sort() F=[] if len(l)==0: F.append(3) elif len(l)==1: F.append...
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 check(int req, string s1, string s2, string s3) { int new_req = 3; vector<int> list; if (s1[1] == s2[1] && s1[1] == s3[1]) { list.push_back(s1[0] - 48); list.push_back(s2[0] - 48); list.push_back(s3[0] - 48); sort(list.begin(), list.end()); 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...
#include <bits/stdc++.h> using namespace std; void solve(); int main() { ios_base::sync_with_stdio(false); solve(); return 0; } void solve() { string a, b, c; cin >> a >> b >> c; vector<int> arr; arr.push_back(a[0]); arr.push_back(b[0]); arr.push_back(c[0]); if (a[1] == b[1] && a[1] == c[1]) { 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 = input().split() d = {} ds = {} for i in a: if d.get(i[1]): d[i[1]].append(int(i[0])) d[i[1]].sort() ds[i[1]] += 1 else: d[i[1]] = [int(i[0])] ds[i[1]] = 1 ds = dict(sorted(ds.items(), key = lambda x:x[1], reverse=True)) for i in ds: if ds[i] == 3: if len...
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.Arrays; public class que2 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] s = br.readLine().split(" "); ...
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 coconuts { public static void main (String[] args) throws java.lang.Exception { BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); String s[]=in.readLine().split(" "); Map<String,Integer> hmap=new HashMap<>(); ...
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 exit t = input().split()[:3:] s = set(t) res = 3 if len(s)==1: res = min(res,0) elif len(s)==2: res = min(res,1) elif len(s)==3: res = min(res,2) if res==0: print(res) exit(0) t.sort() m = [int(a[0]) for a in t if a[1]=='m'] p = [int(a[0]) for a in t if a[1]=='p'] s = [int(a[0]) for a in t if a[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...
l = input().split() s = [] m = [] p = [] for i in range(3): if l[i][1] == 's': s.append(l[i][0]) if l[i][1] == 'm': m.append(l[i][0]) if l[i][1] == 'p': p.append(l[i][0]) r = 2 for s in [s, m, p]: s = list(map(int, s)) s.sort() if len(s) > 1: for i in ran...
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=list(input().split()) s=[] m=[] p=[] for i in a: if i[1]=='s': s.append(int(i[0])) elif i[1]=='m': m.append(int(i[0])) else : p.append(int(i[0])) if len(s)==1 and len(m)==1 and len(p)==1: print(2) elif len(s)==2 or len(m)==2 or len(p)==2: if len(s)==2: if abs(s[1]-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...
a,b,c = input().split() if (a==b and b==c): print (0) exit() x = sorted([int(a[0]),int(b[0]),int(c[0])]) if (a[1]==b[1] and b[1]==c[1]) and (x[0]+1==x[1] and x[1]+1==x[2]): print (0) exit() if a==b or b==c or a==c: print (1) exit() d = {"p":[],"m":[],"s":[]} d[a[1]].append(a) d[b[1]].append(b) d[c[1]].append(c) 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...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigInteger; import java.util.*; import java.util.concurrent.ThreadLocalRandom; import java.util.stream.Collectors; import java.util.stream.IntStream; public class Main2 { static int mod = 1000000007; ...
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 itertools def cmp(A,B): cnt=0 for i in range(3):cnt+=A[i]!=B[i] return cnt a="123456789" b="mps" x=map(str,input().split()) x=sorted(list(x)) A=[] for i in range(len(a)-2): for j in range(len(b)): B=[a[i]+b[j],a[i+1]+b[j],a[i+2]+b[j]] A.append(B) for i in range(len(a)): for 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...
def main(): a, b, c = input().split() s = set([a, b, c]) if len(s) == 1: print(0) return elif len(s) == 2: curNeed = 1; else: curNeed = 2; lister = [a,b,c] lister.sort(key=lambda x:x[0]); lister.sort(key=lambda x:x[1]); before = '**' counter = 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 sys import stdin s=stdin.readline().strip().split() s1=[] for i in s: s1.append([int(i[0]),i[1]]) aux1=0 for i in range(3): aux=0 for j in range(3): if s[i]==s[j]: aux+=1 aux1=max(aux1,aux) aux2=0 for i in range(3): st=set() for j in range(3): if s[i][1]==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...
import java.io.*; import java.util.*; public class Main { public static void main(String args[]) { long start=System.currentTimeMillis(); FastReader input=new FastReader(); PrintWriter out=new PrintWriter(System.out); int T=1; while(T-->0) { String s1=...
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 = input().strip().split() m = 3 for i in range(1, 8): for j in 'mps': r = 3 if str(i) + j in t: r -= 1 if str(i+1) + j in t: r -= 1 if str(i+2) + j in t: r -= 1 m = min(m, r) print(min(m, len(set(t)) - 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 vsort(a): s=[] m=[] p=[] for i in range(3): k=a[i] if(k[1]=='s'): s.append(k) elif(k[1]=='p'): p.append(k) else: m.append(k) s.sort() m.sort() p.sort() v=[] for i in m: v.append(i) for i in p: v.append(i) for i in s: v.append(i) return v def next(a,b): a1=int(a[0]) b1=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...
import sys input = sys.stdin.readline A=[str(i) for i in input().split()] ans=2 S=[] if A[0]==A[1] and A[1]==A[2]: ans=0 else: for i in range(3): S.append(A[i][1]) if S[0]==S[1] and S[1]==S[2]: N=[] for i in range(3): N.append(int(A[i][0])) N.sort() if N[1]==N[0]+1 and N[2]==N[1]+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...
a = sorted(input().split()) ans = 2 for i in range(3): for j in range(i+1, 3): if a[i] == a[j]: ans = 1 elif a[i][1] == a[j][1] and abs(int(a[i][0])-int(a[j][0])) < 3: ans = 1 if a[0] == a[2]: ans = 0 if a[0][1] == a[1][1] and a[1][1] == a[2][1] and int(a[0][0]) == int(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> using namespace std; int main() { char s[10], s1[10], s2[10]; scanf("%s", s); scanf("%s", s1); scanf("%s", s2); vector<int> v, v1, v2; for (int i = 0; i < 5; i++) { v.push_back(100); v1.push_back(100); v2.push_back(100); } if (s[1] == 'm') v.push_back((char)s[0] - 48...
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() s.sort() if s[0] == s[1] == s[2]: print(0) exit(0) s[0] = [int(s[0][0]), s[0][1]] s[1] = [int(s[1][0]), s[1][1]] s[2] = [int(s[2][0]), s[2][1]] if s[0][1] == s[1][1] == s[2][1]: if s[0][0] + 1 == s[1][0] == s[2][0] - 1: print(0) exit(0) def g(x): if x[0][1] == x[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...
a = input().split() ans = 2 for i in range(1,10): for c in "spm": ans = min(ans,max(0,3-a.count(str(i)+c))) ans = min(ans,(not str(i-1)+c in a)+(not str(i)+c in a)+(not str((i+1))+c in a)) print(ans)
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() res = 2 for i in range(1, 10): for j in "smp": #print(str(i) + j, 3 - (str(i) + j in a) - (str(i+1) + j in a) - (str(i+2) + j in a)) res = min(res, 3 - (str(i) + j in a) - (str(i+1) + j in a) - (str(i+2) + j in a)) res = min(res, 3 - a.count(str(i) + j)) print(res)
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 def Check_2 (letters,num): rep_l = max(set(letters),key = letters.count) ip = [] for i in range (3): if letters[i] in rep_l: ip.append(i) if num[ip[0]] == num[ip[1]]: print(1) elif abs(num[ip[0]] - num[ip[1]]) <=2: print(1) else: print(2) my_String = list(raw_input().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...
cards=list(map(str,input().split(' '))) min_draw=2 dict={'p':[],'m':[],'s':[]} for i in cards: dict[i[1]].append(int(i[0])) for j in dict.keys(): nums=dict[j] if len(nums)==2: if abs(nums[0]-nums[1])<=2 and min_draw>1: min_draw=1 if len(nums)==3: nums.sort() m=len(set...
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...
# your code goes here a,b,c=input().split() d={'m':[],'p':[],'s':[]} d[a[1]].append(int(a[0])) d[b[1]].append(int(b[0])) d[c[1]].append(int(c[0])) l=['m','p','s'] ans=2 for i in l: if d[i]==[]: continue for j in range(1,10): ans=min(ans,3-d[i].count(j)) if ans<0: ans=0 if ans==0: break for j in range(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...
list_str = input().split() list_str.sort() def main(): """ p = ['3p', '5s', '5s'] (after sort) sorted by decimal its mean either ['3p','5p'] or ['5p','5p'] near to koutsu, or whole string koutsu either 1,2,3.... 0 is impossible""" # if koutsu 2 or 3 then cannot be shuntsu if len(set(list_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...
t1, t2, t3 = map(str, input().split()) m = [] s = [] p = [] if t1[1] == 'm': m.append(int(t1[0])) elif t1[1] == 's': s.append(int(t1[0])) else: p.append(int(t1[0])) if t2[1] == 'm': m.append(int(t2[0])) elif t2[1] == 's': s.append(int(t2[0])) else: p.append(int(t2[0])) if t3[1] == '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...
a = [x for x in input().split()] m = [] p = [] s = [] for x in a: if x[1] == 'm': m.append(int(x[0])) elif x[1] == 'p': p.append(int(x[0])) else: s.append(int(x[0])) maxi = max(len(m), len(p), len(s)) new = [m, p, s] if maxi == 1: print("2") elif maxi == 2: for x in new: ...
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() { string s1, s2, s3; cin >> s1 >> s2 >> s3; if (s1 == s2 && s2 == s3) { cout << "0"; return 0; } else if (s1 == s2 || s1 == s3 || s2 == s3) { cout << "1"; return 0; } int a = s1[0] - '0', b = s2[0] - '0', c = s3[0] - '0'; char x = s1...
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 from itertools import islice def check_hand(): hand = list(input().rstrip().split()) tiles_count = Counter(hand) needs = 3 - tiles_count.most_common(1)[0][1] if needs == 0: print(0) return by_suit = dict() for tile in hand: if tile[1] in 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...
import java.util.*; public class B { public static void main(String[] args) { // TODO Auto-generated method stub Scanner stdin = new Scanner(System.in); String[] tiles = new String[3]; char[] suit = new char[3]; int[] nums = new int[3]; for(int i = 0; i < 3; i++){ tiles[i] = stdin.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...
def func(arr): if(len(arr)==3): if(arr[0]==arr[1] and arr[1]==arr[2]): return 0 elif(arr[1]==arr[0]+1 and arr[2]==arr[0]+2): return 0 elif(arr[0]==arr[1] or arr[1]==arr[2]): return 1 elif(arr[0]==arr[1]-1 or arr[2]==arr[1]+1): return 1 elif(arr[0]==arr[1]-2 or arr[2]==arr[1]+2): return 1 els...
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); cout.tie(NULL); long long int s = 0, p = 0, m = 0, i, j, k, l; string s1, s2, s3; cin >> s1 >> s2 >> s3; if (s1 > s2) swap(s1, s2); if (s2 > s3) swap(s2, s3); if (s1 > s2) swap(s1, s2); if (s1...
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 ECHO(string _s) { cout << endl; (void)_s; } template <typename T, typename... Args> void ECHO(string _s, T x, Args... args) { unsigned _i; string _s2 = ""; for (_i = 0; _i < _s.length(); ++_i) { if (_s[_i] == ',') break; if (_s[_i] != ' ') _s2 += _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...
d={} for x,y in input().split():d.setdefault(y,[]).append(int(x)) r=2 for k in d: a=sorted(d[k]);s={y-x for x,y in zip(a,a[1:])} if len(a)>2 and s in({0},{1}):r=0 if{0,1,2}&s:r=min(r,1) print(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...
#include <bits/stdc++.h> using namespace std; int main() { vector<int> v1, v2, v3; string s; string a[3]; for (int i = 0; i < 3; i++) { cin >> s; a[i] = s; if (s[1] == 's') { v1.push_back(int(s[0]) - 48); } if (s[1] == 'p') { v2.push_back(int(s[0]) - 48); } if (s[1] == '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...
a = sorted(list(map(lambda x: ord(x[0]) + 256 * ord(x[1]), input().split()))) res = 2 if a[1] - a[0] in [0, 1, 2] or a[2] - a[1] in [0, 1, 2]: res = 1 if (a[0] == a[1] and a[1] == a[2]) or (a[0] + 1 == a[1] and a[1] + 1 == a[2]): res = 0 print(res)
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; vector<int> v[5]; int a, b, c, flag[5], flag1[5], flag2[5], mx; char x, y, z; int main() { for (int i = 0; i < 3; i++) { scanf("%d%c%c", &a, &x, &y); if (x == 'm') { v[0].push_back(a); } if (x == 'p') { v[1].push_back(a); } if (x == '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...
def diff(a,b): a=int(a) b=int(b) if a>b: return(a-b) else: return(b-a) x,y,z=input().split() if x==y and y==z: p=0 elif x==y or y==z or x==z: p=1 else: l=[x[1]] if y[1] not in l: l.append(y[1]) if z[1] not in l: l.append(z[1]) if len(l)==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...
import java.lang.*; import java.util.*; import java.io.*; public class Main { void solve() { char s[][]=new char[3][]; for(int i=0;i<3;i++) s[i]=ns().toCharArray(); int ans=3; HashSet<String> hs=new HashSet<>(); for(int i=0;i<3;i++) hs.add(new String(s[i])); if(hs.size()==1) ans=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> #pragma GCC target("avx2") #pragma GCC optimization("O3") #pragma GCC optimization("unroll-loops") using namespace std; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } long long lcm(long long a, long long b) { return a * b / gcd(a, b); } struct custom...
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; public class Q2 { public static void main(String[] args) { // TODO Auto-generated method stub Scanner read = new Scanner(System.in); int[][] st = new int[2][3]; String a = read.next(); String b = read.next(); String c = read.next(); int common = 0; if(a.equals(b)) { 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...
#include <bits/stdc++.h> using namespace std; int main() { string str; int m, s, p; m = s = p = 0; vector<pair<char, int>> hai; for (int i = 0; i < 3; i++) { cin >> str; hai.push_back(make_pair(str[1], str[0] - '0')); if (str[1] == 'm') m++; else if (str[1] == 's') s++; 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; const int N = 1e5 + 9; int t, id, n, m, x, y, k, c, p, dif, ans, pre, rem, cur, tmp, tot, r, l, u, d, xx, yy; vector<int> v, adj[N]; bool fl, ok; long long res, sum; char ch; string s, z; map<string, int> ide; map<char, set<int>> sui; int main() { ios::sync_with_stdio...
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 cm(a,b,c): if a[1]==b[1]==c[1]: if a[0]==b[0]==c[0]: return True m=[int(a[0]),int(b[0]),int(c[0])] m.sort() if (m[2]-m[1])==1 and (m[1]-m[0])==1: return True return False a,b,c=input().split() ans=False if cm(a,b,c): print(0) ans=True 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...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); map<char, vector<int>> check; check['m'] = vector<int>(10); check['p'] = vector<int>(10); check['s'] = vector<int>(10); for (int i = 0; i < 3; i++) { string cur; cin >> cur; ...
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() { int a, b, c; char x, y, z; cin >> a >> x >> b >> y >> c >> z; if (x != y && x != z && y != z) { cout << 2 << endl; } else if (x == y && y != z) { if (abs(a - b) == 1 || abs(a - b) == 2) cout << 1 << endl; else if (a == b) 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.util.*; public class E1191B { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int [] m = new int[10]; // whether m[i] is present int [] p = new int[10]; int [] s = new int[10]; int min = 2; for (int i= 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...
s = input().split() s.sort() if s[0] == s[2] or (s[0] == s[1] and s[0] == s[2]): print(0) exit() d = [int(i[0]) for i in s] c = [ord(i[1]) for i in s] if d[1] == d[0]+1 and d[2] == d[0]+2 and c[0] == c[1] and c[0] == c[2]: print(0) exit() dem = {i for i in s} ans = len(dem) - 1 for i in range(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...
a, b, c = sorted(input().split(), key = lambda x: int(x[0])) if a == b == c: print(0) elif a[1] == b[1] == c[1] and int(a[0])+2 == int(b[0])+1 == int(c[0]): print(0) elif a == b or b == c or c == a: print(1) elif a[1] == b[1] and (int(a[0])+1 == int(b[0]) or int(a[0])+2 == int(b[0])): print(1) elif b[1] == c[1] and (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...
tiles = input().split() m = [] p = [] s = [] for tile in tiles: if tile[-1] == 'm': m.append(int(tile[:-1])) elif tile[-1] == 'p': p.append(int(tile[:-1])) elif tile[-1] == 's': s.append(int(tile[:-1])) def get_minimum_extra_tiles(_list): if not _list: return 3 _li...
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 = int(input()) # m, n = map(int, input().split()) # nums = list(map(int, input().split())) import functools class node(object): def __init__(self): self.num=0 self.c='0' p=node() s=[node() for i in range(3)] def cmp_new(a,b): if a.num == b.num: return ord(a.c) - ord(b.c) return...
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() t = sorted([(int(a[0]), a[1]), (int(b[0]), b[1]), (int(c[0]), c[1])]) if t[0] == t[1] and t[1] == t[2]: print(0) exit(0) if t[0][1] == t[1][1] and t[1][1] == t[2][1] and t[0][0]+1 == t[1][0] and t[1][0]+1 == t[2][0]: print(0) exit(0) if t[0] == t[1]: print(1) exit(...
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 = [x for x in input().split()] a.sort() if a[0] == a[1] == a[2]: print(0) elif a[0] == a[1] or a[1] == a[2] or a[0] == a[2]: print(1) else: if a[0][1] == a[1][1] == a[2][1] and (abs(int(a[0][0]) - int(a[1][0])) == abs(int(a[1][0]) - int(a[2][0])) == 1): print(0) elif ((abs(int(a[1][0]) - int(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...
input = input().split() if input.count(input[0]) == 3: print(0) elif input.count(input[0]) == 2: print(1) elif input.count(input[1]) == 2: print(1) elif input.count(input[2]) == 2: print(1) else: num_0 = [int(i) for i in input[0] if i in '123456789'] num_1 = [int(i) for i in input[1] if i in '12...
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 = list(input().split()) s.sort() if s[0] == s[2]: print(0) exit() elif int(s[0][0])+2 == int(s[1][0])+1 == int(s[2][0]) and s[0][1] == s[1][1] == s[2][1]: print(0) exit() elif s[0][1] == s[1][1] and int(s[1][0]) - int(s[0][0]) <= 2: print(1) elif s[1][1] == s[2][1] and int(s[2][0]) - int(s[1][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 sys import math import bisect from collections import deque sys.setrecursionlimit(1000000000) def input(): return sys.stdin.readline().strip() def iinput(): return int(input()) def finput(): return float(input()) def tinput(): return input().split() def rinput(): return map(str, tin...
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 a,b,c=map(str,raw_input().split()) d={} h={} l=[a,b,c] for i in xrange(len(l)): key=l[i][1] if key not in d: d[key]=[int(l[i][0])] else: d[key].append(int(l[i][0])) q=d.values() ans=2 for i in xrange(len(q)): u=q[i] if len(u)==1: ans=min(ans,2) elif len(u)=...
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...
input_data = str(input()).split(" ") local_dict = {"m": 0, "s": 1, "p": 2} def koutsu_distance(data): top_same = 1 for i, tile in enumerate(data[0:2]): local_same = 1 for next_tile in data[i+1:]: if next_tile == tile: local_same += 1 if local_same > top_same:...
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() y = sorted([a[0], b[0], c[0]]) y1 = [int(y[i + 1]) - int(y[i]) for i in range(2)] y2 = sorted([a[1], b[1], c[1]]) if len(set(y2)) == 1: if set(y1) == {0}: print(0) elif set(y1) == {1}: print(0) elif 0 in set(y1) or 1 in set(y1) or 2 in set(y1): print(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...
s1,s2,s3 = input().split() A = [] if (s1[1]==s2[1])and(s2[1]==s3[1]): if (s1[0]==s2[0])and(s2[0]==s3[0]): print(0) exit() A.append(int(s1[0])) A.append(int(s2[0])) A.append(int(s3[0])) A.sort() if (A[0]==A[1]-1) and(A[0]==A[2]-2): print(0) exit() if (s1[1]==s2[1]): if (s1[0]==s2[0]): print(1) exi...
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(void) { vector<string> s(3); cin >> s[0] >> s[1] >> s[2]; reverse(s[0].begin(), s[0].end()); reverse(s[1].begin(), s[1].end()); reverse(s[2].begin(), s[2].end()); sort(s.begin(), s.end()); if (s[0] == s[1] && s[1] == s[2]) { cout << 0 << endl; }...
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.ArrayList; import java.util.Arrays; import java.util.Scanner; public class Majiang { public static void main(String[] args) { var scanner = new Scanner(System.in); var tiles = scanner.nextLine().split(" "); // System.out.println(Arrays.toString(tiles)); // if (til...
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()) for i in range(3): l[i] = [l[i][1],l[i][0]] l.sort() for i in range(3): l[i] = [l[i][1],l[i][0]] #print(l) flag = 0 if l[0] == l[1]: if l[1] == l[2]: print(0) else: print(1) elif l[1] == l[2]: print(1) elif l[0][1] == l[1][1]: if abs(int(l[1][0]) - int(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...
a = input() k=0 a1 = a[0]+a[1] a2 = a[3]+a[4] a3 = a[6]+a[7] q=[] w=[] w1=[] q1=[] t=[] t1=[0]*3 w.append(int(a[0])) w.append(int(a[3])) w.append(int(a[6])) q.append(a[1]) q.append(a[4]) q.append(a[7]) t = sorted(w) t = list(t) for i in range(3): m = w.index(t[i]) del w[w.index(t[i])] t1[i] = q[m] del q...
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 def solve(t): if t[0][1] != t[1][1] and t[0][1] != t[2][1] and t[1][1] != t[2][1]: return 2 if t[0][1] == t[1][1] and t[1][1] != t[2][1] \ or t[0][1] == t[2][1] and t[1][1] != t[0][1] \ or t[1][1] == t[2][1] and t[1][1] != t[0][1]: if t[0][1] == t[1][1] and t[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...
#include <bits/stdc++.h> using namespace std; int main() { long long num, m, tc, t = 1; int arr[3]; for (long long i = 0; i < 3; i++) { char ch; cin >> num >> ch; if (ch == 'm') arr[i] = num + 100; else if (ch == 'p') arr[i] = num + 200; else arr[i] = num + 300; } sort(ar...
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 Codechef { static PrintWriter out=new PrintWriter(System.out); static FastScanner in = new FastScanner(System.in); static class FastScanner { BufferedReader br; StringTokenizer stok; FastScanner(InputStream is) { ...