Search is not available for this dataset
name
stringlengths
2
112
description
stringlengths
29
13k
source
int64
1
7
difficulty
int64
0
25
solution
stringlengths
7
983k
language
stringclasses
4 values
1191_B. Tokitsukaze and Mahjong
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...
2
8
import java.io.*; import java.util.*; public class Codeforces { public static class Pair implements Comparable<Pair> { int x; char c; public Pair(int x, char c) { this.x = x; this.c = c; } @Override public int compareTo(Pair o) { ...
JAVA
1191_B. Tokitsukaze and Mahjong
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...
2
8
a,b,c=sorted(10*ord(y)+int(x)for x,y in input().split()) s={b-a,c-b} print(2-bool(s&{0,1,2})-(s in({0},{1})))
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
import java.io.*; import java.util.*; import java.math.*; public class temp { public static void main(String args[])throws IOException { FastReader in=new FastReader(); PrintWriter out=new PrintWriter(System.out, true); int m[]=new int[10]; int p[]=new int[10]; int s[]=ne...
JAVA
1191_B. Tokitsukaze and Mahjong
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...
2
8
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class B_573 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] input = br.readLine().split( " "); ...
JAVA
1191_B. Tokitsukaze and Mahjong
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...
2
8
#include <bits/stdc++.h> using namespace std; int main() { string s[3]; map<string, long long> map1; map<char, long long> map2; map2['m'] = 0, map2['p'] = 1, map2['s'] = 2; long long a[10][3] = {}; for (int i = 0; i < 3; i++) { cin >> s[i]; map1[s[i]]++; a[s[i][0] - '0'][map2[s[i][1]]] = 1; } ...
CPP
1191_B. Tokitsukaze and Mahjong
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...
2
8
a = map(lambda x: [int(x[0]),x[1]], raw_input().split()) ck = 3 - max(a.count(a[0]), max(a.count(a[1]), a.count(a[2]))) cs0, cs1, cs2 = 2, 2, 2 if [a[0][0]+1, a[0][1]] in a : cs0 -= 1 if [a[0][0]+2, a[0][1]] in a : cs0 -= 1 if [a[1][0]+1, a[1][1]] in a : cs1 -= 1 if [a[1][0]+2, a[1][1]] in a : cs1 -= 1 if [a[2][0...
PYTHON
1191_B. Tokitsukaze and Mahjong
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...
2
8
def main(): ss = list(map(str,input().split())) for i in range(0,len(ss)): ss[i] = ss[i][::-1] ss = sorted(ss) for i in range(0,len(ss)): ss[i] = ss[i][::-1] for i in range(0,len(ss)-2): if ss[i]==ss[i+1]==ss[i+2]: print(0) exit(0) elif (ord(ss...
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
m,p,s = input().split() sp = [(int(m[0]),m[1]),(int(p[0]),p[1]),(int(s[0]),s[1])] sp.sort() g = set() g.add(m[1]) g.add(p[1]) g.add(s[1]) if m == p and p == s or sp[2][0]-sp[1][0] == 1 and sp[2][0]-sp[0][0] == 2 and len(g) == 1: print(0) else: if m == p or p == s or m == s: print(1) elif sp[2][0...
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
def smaller(x, y): if x < y: return x return y def kohtsu(a, b, c): if a == b: if b == c: return 0 else: return 1 return 2 def shuntsu(a, b, c): if a[1] == b[1]: if int(a[0])+2 == int(b[0]): if (c[1] == a[1]) and (int(a[0])+1 == int(c[0])): return 0 else: return 1 if int(a[0])+1 == ...
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
#include <bits/stdc++.h> using namespace std; void putitin(string ss, vector<int> &s, vector<int> &m, vector<int> &p) { int ele = (int)ss[0] - (int)'0'; if (ss[1] == 's') { s.push_back(ele); } if (ss[1] == 'm') { m.push_back(ele); } if (ss[1] == 'p') { p.push_back(ele); } } void solve() { st...
CPP
1191_B. Tokitsukaze and Mahjong
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...
2
8
d = { 'm': 10, 's': 30, 'p': 60 } a, b, c = list(sorted([int(i[0]) + d[i[1]] for i in input().split(' ')])) if (a == b and b == c) or (a == b - 1 and b == c - 1): print(0) exit() if a == b - 1 or b == c - 1 or a == b or b == c or a == c - 2 or a == b - 2 or b == c - 2: pr...
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
from __future__ import division, print_function def main(): from itertools import product, combinations s = input().split() c = [(int(d), t) for d, t in s] def f(c): if c[0] == c[1] == c[2]: return True sc = sorted(c) if c[0][1] == c[1][1] == c[2][1] and sc...
PYTHON
1191_B. Tokitsukaze and Mahjong
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...
2
8
from collections import Counter as ct a = map(lambda x: (int(x[0]), x[1]), input().split()) ms = { 's': [], 'p': [], 'm': [], } for num, suit in a: ms[suit].append(num) def to_koutsu(arr: list): st = ct(arr).most_common() return 3 - st[0][1] def to_shuntsu(arr: list): st = list(sorted(arr...
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
#include <bits/stdc++.h> using namespace std; int main() { vector<string> v; for (int i = 0; i < 3; i++) { string s; cin >> s; v.push_back(s); } vector<string> so; vector<string> po; vector<string> mo; for (int i = 0; i < v.size(); i++) { if (v[i][1] == 's') so.push_back(v[i]); e...
CPP
1191_B. Tokitsukaze and Mahjong
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...
2
8
hand = input().split() s_hand = [[] for i in range(3)] # m, p, s shuntsu = 100 for i in hand: s_hand['mps'.index(i[1])].append(int(i[0])) for i in s_hand: if not i: continue if len(i) == 1: shuntsu = min(shuntsu, 2) elif len(i) == 2: shuntsu = min(shuntsu, 1 if abs(i[0] - i[1]) i...
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
s = input().split() s.sort() if s[0] == s[1] == s[2]: print(0) exit() if s[0][1] == s[1][1] == s[2][1]: if ord(s[0][0]) + 1 == ord(s[1][0]) == ord(s[2][0]) - 1: print(0) exit() if s[0][1] == s[1][1] and ord(s[0][0]) + 2 >= ord(s[1][0]) or s[1][1] == s[2][1] and ord(s[1][0]) + 2 >= ord(s[2][0]) or s[0][1] == s[2]...
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
a=list(input().split()) ar1=[] ar2=[] for i in a: ar1.append(int(i[0])) ar2.append(i[1]) s=set() for i in range(3): for j in range(i+1,3): if ar2[i]==ar2[j]: s.add(i) s.add(j) if len(s)==0: print(2) elif len(s)==2: i1=s.pop() i2=s.pop() if abs(ar1[i1]-ar1[i2])...
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
from collections import Counter a,b,c=list(map(str,input().split())) s=[a[1],b[1],c[1]] t=[a[0],b[0],c[0]] u=Counter(s) v=Counter(t) if(len(u.keys())==1): if(len(v.keys())==1): print(0) elif(len(v.keys())==2): print(1) else: t[0]=int(t[0]) t[1]=int(t[1]) t[2]=int(t[2]) t.sort() if(t[0]+1==t[1] and t[...
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
import collections nums = list(map(str,input().split())) dd = collections.defaultdict(int) for i in nums: dd[i] += 1 if dd[i] == 3: print(0) exit() for key in dd: if dd[key] == 2: print(1) exit() else: tk0 = str(int(key[0]) + 1) + key[1] tk1 = str(int(key[0]) + 2) + key[1] tk2 = str(i...
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
####################################################################################################################### # Author: BlackFyre # Language: PyPy 3.7 ####################################################################################################################### from sys import stdin, stdou...
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
a=input().split() b=[a[0][1],a[1][1],a[2][1]] c=sorted([int(a[0][0]),int(a[1][0]),int(a[2][0])]) d=len(list(set(a))) e=len(list(set(b))) if e==1: if d==1: print(0) elif d==2: print(1) elif d==3: if c[1]-c[0]==1 and c[2]-c[1]==1: print(0) elif c[1]-c[0]==1 or c[2]-...
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
l = input().split() p = [] m = [] s = [] for i in l: if i[1] == "p": p.append(int(i[0])) if i[1] =="m": m.append(int(i[0])) if i[1] == "s": s.append(int(i[0])) same = 1 conseq = 1 ans = 2 if p and m and s: print(2) exit() if len(p)>1: p.sort() for i in p: same = max(same,p.count(i)) for i in range(len...
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
t1, t2, t3 = input().split() ans = 2 if t1 == t2 or t2 == t3 or t3 == t1: if t1 == t2 == t3: ans = 0 else: ans = 1 aaa = [] for i in range(10): for j in range(10): for k in range(10): if k - j == j - i == 1: aaa.append({i, j, k}) if t1[1] == t2[1] == t3[1]...
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
#include <bits/stdc++.h> using namespace std; const long long MX5 = 3 * 1e5 + 3; const long long MX6 = 1 * 1e6 + 37; const long long INF = 8e18; const long long MOD = 1e9 + 7; const long long MOD2 = 998244353; long long power(long long a, long long b, long long md) { return (!b ? 1 : (b & 1 ? a * power(a...
CPP
1191_B. Tokitsukaze and Mahjong
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...
2
8
ms = [i for i in input().split()] m1, m2, m3 = [i for i in sorted(ms, reverse=True)] if m1 == m2 == m3 or (m1[1] == m2[1] == m3[1] and int(m1[0]) == int(m2[0]) + 1 == int(m3[0]) + 2): print(0) elif (m1 == m2 or m2 == m3 or m1 == m3) \ or (m1[1] == m2[1] and (int(m1[0]) == int(m2[0]) + 1 or int(m1[0]) == int...
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
################# # July 17th 2019. ################# ############################################################## # Class Definition. class Mahjong: # Method to determine solution. def requiredTileCount(self): # Finding Costs and return minimum tiles. mahjong.costOfMentsu();mahjong.costOfKou...
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
l = list(input().split(" ")) d={} d["m"]=[] d["p"]=[] d["s"]=[] q=[] for i in l : if i[1]=="m": d["m"].append(int(i[0])) elif i[1]=="p": d["p"].append(int(i[0])) else: d["s"].append(int(i[0])) ma=0 e="" for i in d: if len(d[i])>=ma: ma=len(d[i]) e=i if len(d[e])==...
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
a=list(map(str,input().split())) p=[0]*9 m=[0]*9 s=[0]*9 p1=[0]*9 m1=[0]*9 s1=[0]*9 p2=[0]*9 m2=[0]*9 s2=[0]*9 for i in a: if(i[1]=="p"): u=int(i[0]) p[u-1]+=1 p2[u-1]=1 elif(i[1]=="m"): u=int(i[0]) m[u-1]+=1 m2[u-1]=1 else: u=int(i[0]) s[u-1]+...
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
a = list(map(str,input().split())) a.sort() #print(a[0],a[1],a[2]) if(a[0]==a[1]==a[2]): print(0) elif(a[0][1]==a[1][1]==a[2][1] and int(a[0][0])==int(a[1][0])-1 and int(a[1][0])==int(a[2][0])-1): print(0) elif(a[0]==a[1] or a[1]==a[2] or a[0]==a[2]): print(1) elif(a[0][1]==a[1][1] and abs(int(a[0][0])...
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
import java.io.*; import java.math.*; import java.nio.Buffer; import java.sql.SQLSyntaxErrorException; import java.util.*; import java.text.*; import java.util.stream.Collectors; public class Main { public static int c(int n,int m){ int count=1; for(int i=1;i<=m;i++){ count*=(n-i...
JAVA
1191_B. Tokitsukaze and Mahjong
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...
2
8
m={"m":[0]*9, "s":[0]*9, "p":[0]*9} for s in input().split(): m[s[1]][int(s[0])-1]+=1 ans = 2 for c in "smp": l = m[c] if(max(l)>=2): ans = min(ans, 3-max(l)) else: for i in range(7): sm = sum(l[i:i+3]) ans = min(ans, 3-sm) print(ans)
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
def majong(tiles): result, flag = 2, 0 if tiles[0] == tiles[1] and tiles[1] == tiles[2]: result = 0 elif tiles[0] != tiles[1] and tiles[1] != tiles[2]: if tiles[0][1] == tiles[1][1]: if int(tiles[0][0]) >= int(tiles[1][0]) - 2: result = 1 if int(ti...
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
#include <bits/stdc++.h> using namespace std; int k, ans; int a[4]; string s1, s2, s3; map<string, int> fix; int main() { cin >> s1 >> s2 >> s3; fix[s1]++; fix[s2]++; fix[s3]++; ans = min(min((3 - fix[s2]), (3 - fix[s3])), (3 - fix[s1])); if (s1[1] == s2[1] && s1[1] == s3[1]) { a[1] = s1[0]; a[2] = ...
CPP
1191_B. Tokitsukaze and Mahjong
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...
2
8
#include <bits/stdc++.h> const long long INF = (1LL << 60) - 1; using namespace std; long long power(long long x, long long y) { long long res = 1; x = x % 1000000007; while (y > 0) { if (y & 1) res = (res * x) % 1000000007; y = y >> 1; x = (x * x) % 1000000007; } return res; } long long BINARY_SE...
CPP
1191_B. Tokitsukaze and Mahjong
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...
2
8
tiles = [tile for tile in input().split()] tiles = sorted(tiles) num0 = int(tiles[0][0]) suit0 = tiles[0][1] num1 = int(tiles[1][0]) suit1 = tiles[1][1] num2 = int(tiles[2][0]) suit2 = tiles[2][1] if suit0 == suit1 == suit2: if num0 == num1 == num2 or (abs(num0 - num1) == 1 and abs(num1 - num2) == 1 and abs(num0 - ...
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); map<string, int> mp; string s1, s2, s3; cin >> s1 >> s2 >> s3; mp[s1]++; mp[s2]++; mp[s3]++; int ans = 3; for (char c = '1'; c <= '9'; c++) { string x; x += c; string a = x + 'm'; ans = min(ans...
CPP
1191_B. Tokitsukaze and Mahjong
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...
2
8
M = 10**9 + 7 R = lambda: map(int, input().split()) L = [[0 for j in range(9)] for i in range(3)] #print(L) a = input().split() def f(p): if p[1] == 'm': L[0][int(p[0])-1] += 1 elif p[1] == 'p': L[1][int(p[0])-1] += 1 elif p[1] == 's': L[2][int(p[0])-1] += 1 for i in range(3): f(...
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
def mode(List): counter = 0 num = List[0] for i in List: curr_frequency = List.count(i) if (curr_frequency > counter): counter = curr_frequency num = i return num a,b,c = map(str, input().split()) a=list(a) b=list(b) c=list(c) numbers=[int(a[0]),int(b[0]),int(c[0]...
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
o=input().split() if o[0]==o[1]==o[2]: print(0) exit() pch=int(o[0][0]) vch=int(o[1][0]) tch=int(o[2][0]) l=[pch,vch,tch] l.sort() if l[0]+2==l[1]+1==l[2] and o[0][1]==o[1][1]==o[2][1]: print(0) exit() if o[0]==o[1] or o[0]==o[2] or o[1]==o[2]: print(1) exit() if pch+1==vch and o[0][1]==o[1][1]:...
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
s = list(input().split()) M=[] P=[] S=[] for i in s: if i[1]=='m': M.append(int(i[0])) elif i[1]=='s': S.append(int(i[0])) elif i[1]=='p': P.append(int(i[0])) x = True for i in [M, P, S]: if len(i)==3: i.sort() if (i[0]==i[1] and i[1]==i[2]) or (i[0]+1 ==i[1] a...
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
import java.util.Arrays; import java.util.Scanner; public class Problems { public static void main(String [] args) { Scanner in = new Scanner(System.in); String a = in.next(); String b = in.next(); String c = in.next(); int a1 = Integer.parseInt(a.substring(0,1)); a1 = a1 * 100 + a.charAt(1)-'a'; int ...
JAVA
1191_B. Tokitsukaze and Mahjong
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...
2
8
#include <bits/stdc++.h> using namespace std; int main() { string s; pair<int, char> arr[3]; cin >> s; arr[0].first = s[0] - '0'; arr[0].second = s[1]; cin >> s; arr[1].first = s[0] - '0'; arr[1].second = s[1]; cin >> s; arr[2].first = s[0] - '0'; arr[2].second = s[1]; if (arr[0].first == arr[1]...
CPP
1191_B. Tokitsukaze and Mahjong
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...
2
8
l = list(input().split()) l.sort() a,b = zip(*l) a = list(map(int,a)) # print(a,b) x,y,z = len(set(a)),len(set(b)),len(set(l)) # print(y,a,x,b,a[1]-a[0],a[2]-a[1]) if(x==1 and y==1): print(0) elif(y==1 and (a[1]-a[0])==(a[2]-a[1])==1): print(0) elif((a[1]-a[0]<=2 and b[0]==b[1]) or (a[2]-a[1]<=2 and b[1]==b[2])...
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
# so basically what we want to do is get some ice, then we get salt and we salt # the ice. it becomes salty ice, on top of which you add lovely flavors like # vanilla and chocolate sauce to add to the taste. from that point, you got some # of that great ice cream. but suppose you want toppings; what about sprinkles # o...
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
s = raw_input().split() s.sort() dic = {} for i in s: if i[1] in dic: dic[i[1]].append(int(i[0])) else: dic[i[1]] = [int(i[0])] ans = 3 for i in dic: if len(dic[i]) == 3: if len(set(dic[i])) == 1: ans = min(ans, 0) elif len(set(dic[i])) == 3 and dic[i][0] + 1 == dic[i][1] and dic[i][1] + 1 == dic[i][2]: ...
PYTHON
1191_B. Tokitsukaze and Mahjong
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...
2
8
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collections; import java.util.StringTokenizer; public class Main { // A B C D 1 3 2 0 static int x; static ArrayList<Integer> m = new ArrayList<Integer>(); static ArrayList<Inte...
JAVA
1191_B. Tokitsukaze and Mahjong
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...
2
8
import javafx.util.Pair; import java.io.*; import java.math.*; import java.security.Key; import java.util.*; @SuppressWarnings("Duplicates") // author @mdazmat9 // swing +socket java(udemy) public class codeforces{ static Scanner sc = new Scanner(System.in); static PrintWriter out = new PrintWriter(System.out);...
JAVA
1191_B. Tokitsukaze and Mahjong
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...
2
8
s=input().split(" ") s1=[] p1=[] m1=[] for i in s: if i[1]=="m": m1.append(int(i[0])) elif i[1]=="p": p1.append(int(i[0])) else: s1.append(int(i[0])) s1=sorted(s1) p1=sorted(p1) m1=sorted(m1) if len(m1)==len(s1)==len(p1)==1: print(2) else: if len(m1)>=2: if len(...
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
import sys def f(a, b): r = a[0] == b[0] and a[1] + 1 == b[1] #print "{} == {} and {} + 1 == {}, {}".format(a[0], b[0], a[1], b[1], r) return r def check(a): if len(set(a)) == 1: return True b = a r = f(b[0], b[1]) and f(b[1], b[2]) return r t = 1 if len(sys.argv) > 1: t = in...
PYTHON
1191_B. Tokitsukaze and Mahjong
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...
2
8
suit=list(map(str,input().split())) suit=sorted(suit) num=[int(suit[0][0]),int(suit[1][0]),int(suit[2][0])] if suit[0]==suit[1] and suit[0]==suit[2]: print(0) elif suit[0]==suit[1] or suit[1]==suit[2]: print(1) elif suit[0][1]==suit[1][1] and suit[0][1]==suit[2][1]: if num[0]==num[1]-1 and num[0]==num[2]-2:...
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
a=sorted(input().split()) r=len({*a})-1 a=sorted(a,key=lambda x:(x[1],x[0])) v,s=[*zip(*a)] c=1 for i in range(1,3): if s[i]==s[i-1] and int(v[i-1])+1==int(v[i]): c+=1 r=min(r,3-c) elif s[i]==s[i-1] and int(v[i-1])+2==int(v[i]): r=min(r,1) else:c=1 print(r)
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
hand = input().split() # Analyse hand m, p, s = 9 * [False], 9 * [False], 9 * [False] for h in hand: if h[1] == 'm': m[int(h[0]) - 1] = True if h[1] == 'p': p[int(h[0]) - 1] = True if h[1] == 's': s[int(h[0]) - 1] = True # Win in zero, by koutsu if hand[0] == hand[1] and hand[0] ==...
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
a = [i for i in input().split()] m_dict = {'m':[],'p':[],'s':[]} for word in a: m_dict[word[1]].append(int(word[0])) val = 2 for i in ['m','p','s']: temp = m_dict[i] if len(temp)==2: if temp[0] == temp[1] or abs(temp[0]-temp[1])<=2: val = 1 break if len(temp) == 3: ...
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
ans=2 x=input().split() for i in ["m","s","p"]: c=[int(j[0]) for j in x if j[1]==i] c.sort() if len(c)<2: continue if len(c)==3: if c[0]==c[1] and c[1]==c[2]: ans=0 break if c[0]+1==c[1] and c[1]+1==c[2]: ans=0 break if c[0]...
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
#include <bits/stdc++.h> using namespace std; long long modInverse(long long a, long long m); long long gcd(long long a, long long b); long long power(long long x, unsigned long long y, unsigned long long m); long long logint(long long x, long long y); long long gcd(long long a, long long b) { if (a == 0) return b; ...
CPP
1191_B. Tokitsukaze and Mahjong
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...
2
8
p = input().split() p = set(p) ans = 2 lol = [0] * 3 for i1 in p: for i2 in p: if i1[1] == i2[1] and 1 <= int(i1[0]) - int(i2[0]) <= 2: if int(i1[0]) - int(i2[0]) == 1: lol[1] += 1 else: lol[2] = 1 ans -= max(lol) ans = min(ans, len(p) - 1) print(max(0...
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
import java.util.Scanner; public class TaskB { public static void main(String[] args) { Scanner s = new Scanner(System.in); int[][] cards = new int[3][9]; for(int i=0;i<3;i++) { char[] c = s.next().toCharArray(); int a = Character.getNumericValue(c[0]) - 1; if(c[1] == 'm') { cards[0][a]++; } els...
JAVA
1191_B. Tokitsukaze and Mahjong
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...
2
8
b=list(input().split()) a=b[0] c=b[1] d=b[2] p=[int(a[0]),int(c[0]),int(d[0])] p.sort() if a[1]==c[1]: if a[1]==d[1]: k=p[1]-p[0] q=p[2]-p[1] if k==0 and q==0: print(0) elif k==0 or q==0: print(1) elif k==1 and q==1: print(0) elif k...
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
a = input().split() res = 2 for i in range(1, 10): for j in "smp": 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)
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
first_list = raw_input().split() data_dic = {} for item in first_list: digit = int(item[0]) letter = item[1] if letter not in data_dic: data_dic.update({letter: [digit]}) else: data_dic[letter].append(digit) koutsu = False shuntsu = False koutsu_action = 100 shuntsu_action = 100 for j in...
PYTHON
1191_B. Tokitsukaze and Mahjong
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...
2
8
import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.Scanner; import java.util.Set; import java.util.stream.Collectors; import java.util.stream.IntStream; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String[] tiles = new St...
JAVA
1191_B. Tokitsukaze and Mahjong
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...
2
8
import java.util.*; import java.io.*; public class R573B { public static void main(String[] args){ JS scan = new JS(); int[][] got = new int[14][3]; int[] aarrr = new int[1000]; aarrr['m'] = 0; aarrr['p'] = 1; aarrr['s'] = 2; for(int i = 0; i < 3; i++) { String s = scan.next(); int a = s.charAt(0...
JAVA
1191_B. Tokitsukaze and Mahjong
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...
2
8
#include <bits/stdc++.h> using namespace std; template <class T> inline bool read(T &x) { int c = getchar(); int sgn = 1; while (~c && c<'0' | c> '9') { if (c == '-') sgn = -1; c = getchar(); } for (x = 0; ~c && '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0'; x *= sgn; return ~c; } cons...
CPP
1191_B. Tokitsukaze and Mahjong
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...
2
8
a, b, c = input().split() a = a[::-1] b = b[::-1] c = c[::-1] a1 = int(a[1]) b1 = int(b[1]) c1 = int(c[1]) k = [a1, b1, c1] k.sort() if a == b == c: print(0) elif a == b or b == c or a == c: print(1) elif a[0] == b[0] == c[0] and k[0] == k[1] - 1 == k[2] - 2: print(0) elif (a[0] == b[0] and abs(a1 - b1) ...
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
def main(): nums = [] chars = [] for elm in input().split(" "): num, char = list(elm) num = int(num) nums.append(num) chars.append(char) set_char = list(set(chars)) for i, char in enumerate(set_char): tmp_count = chars.count(char) #print("tmp_count", ...
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
inp = list(map(str, input().split())) inp.sort() slist = [] mlist = [] plist = [] ret = [] for i in inp: if i[1] == 's': slist.append(i) elif i[1] == 'm': mlist.append(i) elif i[1] == 'p': plist.append(i) if len(slist) > 0: likes = 0 ...
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
#include <bits/stdc++.h> using namespace std; int a[3], i; int main() { string s; for (i = 0; i < 3; i++) { cin >> s; a[i] = (s[0] - '0') + (s[1] - 'a') * 100; } sort(a, a + 3); int t1 = a[1] - a[0]; int t2 = a[2] - a[1]; if (t1 == t2 && (t1 == 0 || t1 == 1)) cout << "0"; else if (t1 == 1 ||...
CPP
1191_B. Tokitsukaze and Mahjong
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...
2
8
import java.util.*; import java.io.*; import static java.lang.Math.*; public class Main implements Runnable { boolean multiple = false; @SuppressWarnings("Duplicates") void solve() throws Exception { String[] tiles = (new Scanner(System.in)).nextLine().split(" "); int[] s = new int[9],...
JAVA
1191_B. Tokitsukaze and Mahjong
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...
2
8
a, b, c = input().split() numbers = [int(a[0]), int(b[0]), int(c[0])] letters = [a[1], b[1], c[1]] if (a == b == c): print(0) else: order = sorted(numbers) flag = 0 for i in range(2): diff = order[i + 1] - order[i] if (diff != 1): flag = 1 break if(flag == 0 and letters[0] == letters[1] == letters[2]):...
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
import java.util.Arrays; import java.util.Scanner; public class Code1 { public static void main(String[] args) { Scanner scanner=new Scanner(System.in); String a,b,c; int a1[]=new int[3];int t=0; a=scanner.next(); b=scanner.next();c=scanner.next();scanner.close(); a1[0]=a.charAt(0)-'0';a1[1]=b.charAt(0...
JAVA
1191_B. Tokitsukaze and Mahjong
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...
2
8
tiles = input().split() s = [] m = [] p = [] for i in tiles: if i[1] == 's': s.append(int(i[0])) elif i[1] == 'p': p.append(int(i[0])) else: m.append(int(i[0])) s.sort() m.sort() p.sort() num_s = len(s) num_p = len(p) num_m = len(m) if num_s == 3: if len(set(s)) == 1: ...
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
def same(nums): curr = nums[0] for i in nums: if i != curr: return False return True def increasing(nums): for i in range(1,len(nums)): if nums[i]-nums[i-1] != 1: return False return True def main(): cards = list(map(str,input().split())) letters =...
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
import java.util.*; public class Solution { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int s[] = new int[10]; int m[] = new int[10]; int p[] = new int[10]; for (int i = 0; i < 3; i++) { String string = scanner.next(); ...
JAVA
1191_B. Tokitsukaze and Mahjong
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...
2
8
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc =new Scanner(System.in); List<Integer> m = new ArrayList<Integer>(); List<Integer> p = new ArrayList<Integer>(); List<Integer> s = new ArrayList<Integer>(); for(int i = 0; i < 3; i++) { String input = sc.ne...
JAVA
1191_B. Tokitsukaze and Mahjong
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...
2
8
#include <bits/stdc++.h> using namespace std; long long int arr[10] = {0}; long long int brr[10] = {0}; long long int crr[10] = {0}; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); string s1, s2, s3; cin >> s1 >> s2 >> s3; if (s1[1] == 'm') arr[int(s1[0]) - 48]++; else if...
CPP
1191_B. Tokitsukaze and Mahjong
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...
2
8
#include <bits/stdc++.h> using namespace std; template <typename T> void pr(vector<T> &v) { for (int i = 0; i < (int)(v).size(); i++) cout << v[i] << " "; cout << '\n'; ; } template <typename T> void pr(vector<vector<T>> &v) { for (int i = 0; i < (int)(v).size(); i++) { pr(v[i]); } } template <typename T>...
CPP
1191_B. Tokitsukaze and Mahjong
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...
2
8
tiles = input().split() tile0s = tiles[0][1] tile1s = tiles[1][1] tile2s = tiles[2][1] tile0v = int(tiles[0][0]) tile1v = int(tiles[1][0]) tile2v = int(tiles[2][0]) tvals = sorted ([tile0v, tile1v, tile2v]) if tiles[0] == tiles[1] and tiles[0] == tiles[2]: print (0) elif tile0s == tile1s and tile1s == tile2s an...
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
import sys import math input = sys.stdin.readline a,b,c=input().split() s=[] p=[] m=[] if a[1]=='p': p.append(int(a[0])) elif a[1]=='s': s.append(int(a[0])) else: m.append(int(a[0])) if b[1]=='p': p.append(int(b[0])) elif b[1]=='s': s.append(int(b[0])) else: m.append(int(b[0])) if c[1]=='p': p.append(int(c[...
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
var tiles = readline().split(" ").map(function(x) { return (x) }); tiles.sort(); var first = tiles[0][1]; var second = tiles[1][1]; var third = tiles[2][1]; var firstNo = tiles[0][0]; var secondNo = tiles[1][0]; var thirdNo = tiles[2][0]; if (first != second && first != third && second != third){ print (2); } e...
JAVA
1191_B. Tokitsukaze and Mahjong
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...
2
8
a=[[0 for i in range(10)] for j in range(3)] s=input().split() m1=0 for i in s: k=int(i[0]) if i[1]=='m': a[0][k]+=1 m1=max(m1,a[0][k]) elif i[1]=='p': a[1][k]+=1 m1=max(m1,a[1][k]) elif i[1]=='s': a[2][k]+=1 m1=max(m1,a[2][...
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
l=input().split() l=sorted(l) # print(l) if(l[0]==l[1]==l[2]): print(0) elif(l[0][1]==l[1][1]==l[2][1]): if(int(l[0][0])+1==int(l[1][0]) and int(l[0][0])+2==int(l[2][0])): print(0) elif(int(l[1][0])-int(l[0][0])<=2): print(1) elif(int(l[2][0])-int(l[0][0])<=2): print(1) elif...
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
arr = input().split(" ") arr = set(arr) ans = 2 tmp = [0]*3 for i in arr: for j in arr: if i[1] == j[1] and 1 <= int(i[0]) - int(j[0]) <= 2: if int(i[0]) - int(j[0]) == 1: tmp[1] += 1 else: tmp[2] = 1 ans -= max(tmp) ans = min(ans, len(arr) - 1) print(...
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
import sys def splitTiles(a): return [list(filter(lambda x: x[1] == 's', a)), list(filter(lambda x: x[1] == 'p', a)), list(filter(lambda x: x[1] == 'm', a))] def missingElements(a): if len(a) == 0: return 2 return min(map(lambda i: 2 - (1 if (i[0]+1, i[1]) in a else 0) - (1 if (i[0]+2, i[1]) in ...
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
import java.util.*; public class test { public static void main(String[] args) { Scanner s = new Scanner(System.in); String[] str=new String[3]; StringBuilder[] sb=new StringBuilder[3]; str[0]=s.next(); sb[0] = new StringBuilder(str[0]); sb[0]=sb[0].reverse(); ...
JAVA
1191_B. Tokitsukaze and Mahjong
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...
2
8
import sys from collections import defaultdict as dc #input=sys.stdin.readline from bisect import bisect_left, bisect_right l=list(input().split()) x=[] y=dc(int) for i in range(3): y[l[i]]+=1 x.append(list(l[i])) if 3 in y.values(): print(0) elif 2 in y.values(): print(1) else: x.sort(key=lambda x:...
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
//package codeforces; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.stream.Stream; public class Solution { public static void main(String[] args) throws IOException { try(BufferedReader reader = new BufferedReader(new InputStreamReader(System.in...
JAVA
1191_B. Tokitsukaze and Mahjong
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...
2
8
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); string s[3]; cin >> s[0] >> s[1] >> s[2]; int ans = 2; if (s[0] == s[1] && s[1] == s[2]) return cout << 0, 0; if (s[0] == s[1] || s[1] == s[2] || s[0] == s[2]) return cout << 1, 0;...
CPP
1191_B. Tokitsukaze and Mahjong
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...
2
8
#include <bits/stdc++.h> using namespace std; void solve() { string a[3]; cin >> a[0] >> a[1] >> a[2]; map<char, vector<long long> > m; for (auto i : a) m[i[1]].push_back(i[0]); int ok = 2; for (auto i : m) { vector<long long> r = i.second; sort(r.begin(), r.end()); if (r.size() == 1) { co...
CPP
1191_B. Tokitsukaze and Mahjong
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...
2
8
from operator import itemgetter A = [[int(a[0]), a[1]] for a in list(map(str, input().split()))] D = {} for a in A: if not a[1] in D.keys(): D[a[1]] = [a[0]] else: D[a[1]].append(a[0]) ans = 2 for d in D.values(): if len(d) == 1: continue elif len(d) == 2: if d[0] == d...
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
t = input() a = t[0] + t[1] b = t[3] + t[4] c = t[6] + t[7] d = { 'm': t.count('m'), 'p': t.count('p'), 's': t.count('s') } if d['m'] == 0: d.pop('m') if d['p'] == 0: d.pop('p') if d['s'] == 0: d.pop('s') l = list() if len(d) == 1: a_n = int(a[0]) b_n = int(b[0]) c_n = int(c[0]) ...
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
'''input 1s 3s 5s ''' arr = input().split() arr.sort() m = [] p = [] s = [] for i in range(3): if (arr[i][-1]=='s'): s.append(int(arr[i][0])) if (arr[i][-1]=='m'): m.append(int(arr[i][0])) if (arr[i][-1]=='p'): p.append(int(arr[i][0])) if (len(m)==3 and m[0]+1==m[1] and m[1]+1==m[2]): print(0) elif (len(m)==3...
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
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]), v+=abs(d[x][0]-d[x][2]), ...
PYTHON3
1191_B. Tokitsukaze and Mahjong
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...
2
8
/* Roses are red Memes are neat All my test cases time out Lmao yeet */ import java.util.*; import java.io.*; public class B { public static void main(String args[]) throws Exception { BufferedReader infile = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st...
JAVA
120_B. Quiz League
A team quiz game called "What? Where? When?" is very popular in Berland. The game is centered on two teams competing. They are the team of six Experts versus the team of the Audience. A person from the audience asks a question and the experts are allowed a minute on brainstorming and finding the right answer to the que...
2
8
import java.io.*; import java.util.*; import java.math.*; public class P120B { @SuppressWarnings("unchecked") public void run() throws Exception { boolean [] played = new boolean [nextInt()]; int k = nextInt() - 1; for (int i = 0; i < played.length; i++) { played[i] = (nextInt() == 0); } ...
JAVA
120_B. Quiz League
A team quiz game called "What? Where? When?" is very popular in Berland. The game is centered on two teams competing. They are the team of six Experts versus the team of the Audience. A person from the audience asks a question and the experts are allowed a minute on brainstorming and finding the right answer to the que...
2
8
//package codeforces; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.Closeable; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.ArrayList; im...
JAVA
120_B. Quiz League
A team quiz game called "What? Where? When?" is very popular in Berland. The game is centered on two teams competing. They are the team of six Experts versus the team of the Audience. A person from the audience asks a question and the experts are allowed a minute on brainstorming and finding the right answer to the que...
2
8
import java.io.*; import java.util.*; public class Main { void solve() throws IOException { int n = nextInt(); int k = nextInt() - 1; int[] xs = new int[n]; for(int i = 0; i < n; ++i) xs[i] = nextInt(); while(xs[k] == 0) k = (k ...
JAVA
120_B. Quiz League
A team quiz game called "What? Where? When?" is very popular in Berland. The game is centered on two teams competing. They are the team of six Experts versus the team of the Audience. A person from the audience asks a question and the experts are allowed a minute on brainstorming and finding the right answer to the que...
2
8
import java.awt.Point; import java.io.*; import java.math.BigInteger; import java.util.*; import static java.lang.Math.*; public class B { final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE")!=null; BufferedReader in; PrintWriter out; StringTokenizer tok = new Strin...
JAVA
120_B. Quiz League
A team quiz game called "What? Where? When?" is very popular in Berland. The game is centered on two teams competing. They are the team of six Experts versus the team of the Audience. A person from the audience asks a question and the experts are allowed a minute on brainstorming and finding the right answer to the que...
2
8
/* /$$$$$ /$$$$$$ /$$ /$$ /$$$$$$ |__ $$ /$$__ $$ |$$ |$$ /$$__ $$ | $$| $$ \ $$| $$|$$| $$ \ $$ ...
JAVA
120_B. Quiz League
A team quiz game called "What? Where? When?" is very popular in Berland. The game is centered on two teams competing. They are the team of six Experts versus the team of the Audience. A person from the audience asks a question and the experts are allowed a minute on brainstorming and finding the right answer to the que...
2
8
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.util.StringTokenizer; public class QuizLeague { public static void main(String[] args) throws IOException { FileReader in = new Fil...
JAVA
120_B. Quiz League
A team quiz game called "What? Where? When?" is very popular in Berland. The game is centered on two teams competing. They are the team of six Experts versus the team of the Audience. A person from the audience asks a question and the experts are allowed a minute on brainstorming and finding the right answer to the que...
2
8
import java.util.*; import java.lang.*; import java.math.*; import java.io.*; import static java.lang.Math.*; import static java.util.Arrays.*; public class Main { static int INF=1<<28; // static int key=1; /*int x,y; Main(int x,int y){ this.x=x; this.y=y; }*/ //static int sum=0; public sta...
JAVA