description stringlengths 35 9.39k | solution stringlengths 7 465k |
|---|---|
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class Main {
... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
void READ(vector<long long> &v, long long n) {
long long a;
for (long long i = 0; i < n; i = i + 1) {
cin >> a;
v.push_back(a);
}
}
void PRINT(vector<long long> &v) {
long long a;
for (long long i = 0; i < v.size(); i = i + 1) {
cout << v[i] << " ";
... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
constexpr int MOD = 998244353;
int n, m, a[200001], w[200001], dp[3001][3001], sum[2], inv[10001], ans[2];
int ksm(int a, int b) {
int s = 1;
while (b) {
if (b & 1) {
s = s * static_cast<long long>(a) % MOD;
}
a = a * static_cast<long long>(a) % MOD;
... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
int n, m;
long long w[51], dp[51][51][51];
bool a[51];
long long mul(long long a, long long b) { return (a * b) % mod; }
long long add(long long a, long long b) { return (a + b) % mod; }
long long quickpow(long long a, long long b) {
if (b... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
const int MOD = 998244353;
pair<int, int> v[55];
int dp[2][55][55][55], inv[3005], ans[2];
int liked, disliked;
int exp(int a, int b) {
int r = 1;
while (b) {
if (b & 1) r = ((long long)r * a) % MOD;
b /= 2;
a = ((long long)a * a) % MOD;
}
return r;
}
in... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
inline int read() {
int x = 0;
char c = getchar();
while (c < '0' || c > '9') c = getchar();
while (c >= '0' && c <= '9') x = (x << 3) + (x << 1) + c - '0', c = getchar();
return x;
}
const int maxn = 2e5 + 10;
const int mod = 998244353;
const double eps = 1e-9;
l... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
const int N = 55;
const int P = 998244353;
int n, m, a[N], w[N], inv[N * N], f[N][N][N][N];
void add(int &x, int y) { (x += y) >= P && (x -= P); }
void init(int n) {
inv[1] = 1;
for (int i = 2; i <= n; i++) {
inv[i] = 1LL * (P - P / i) * inv[P % i] % P;
}
}
int main() {
scanf("%d%d"... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
const int MOD = 998244353;
const int MAXN = 50;
const int MAXM = 50;
const int MAXW = 100;
bool likes[MAXN];
int weight[MAXN];
int dp[MAXW + 1][MAXM + 1][MAXM + 1][MAXM + 1];
int dp2[MAXW + 1][MAXM + 1][MAXM + 1][MAXM + 1];
void modInv(int a, int b, int& ainv, int& binv) {
... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
const int64_t MAX = 55, MOD = 998244353;
int64_t n, m, sumW = 0, sumL = 0, C[MAX], W[MAX], F[MAX][MAX][2 * MAX][2];
bool Free[MAX][MAX][2 * MAX][2];
int64_t Mul(int64_t x, int64_t k) {
if (k == 0) return 1;
int64_t tmp = Mul(x, k / 2);
if (k % 2 == 0) return tmp * tmp... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
inline long long Getint() {
char ch = getchar();
long long x = 0, fh = 1;
while (ch < '0' || ch > '9') {
if (ch == '-') fh = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
(x *= 10) += ch ^ 48;
ch = getchar();
}
return x * fh;
}
const i... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
const int inf = 0x3f3f3f3f;
const int mod = 998244353;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
inline int read() {
int x = 0, f = 1, c = getchar();
for (; !isdigit(c); c = getchar())
if (c == 45) f ^= 1;
fo... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
const long long int maxn = 105;
const long long int modd = 998244353;
long long int dp[maxn][maxn][maxn], n, m, i;
long long int a[maxn], w[maxn];
void count(long long int a, long long int b, long long int &x,
long long int &y) {
if (a == 1 && b == 0) {
x =... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
int n, m, a[55], w[55];
long long f[55][55][55];
const int mod = 998244353;
int ksm(int x, int k) {
int ret = 1, tmp = x;
while (k) {
if (k & 1) ret = 1ll * ret * tmp % mod;
tmp = 1ll * tmp * tmp % mod;
k >>= 1;
}
return ret;
}
int inv(int x) { return ks... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline void smin(T &a, const U &b) {
if (a > b) a = b;
}
template <typename T, typename U>
inline void smax(T &a, const U &b) {
if (a < b) a = b;
}
template <class T>
inline void gn(T &first) {
char c, sg = 0;
while (c = getchar(), ... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
const int N = 200010;
const int M = 3010;
const int mod = 998244353;
int qpow(int x, int y) {
int out = 1;
while (y) {
if (y & 1) out = (long long)out * x % mod;
x = (long long)x * x % mod;
y >>= 1;
}
return out;
}
int n, m, a[N], w[N], f[M][M], g[M][M],... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
using INT = long long;
const int mod = 998244353;
int power(int a, int b, int m, int ans = 1) {
for (; b; b >>= 1, a = 1LL * a * a % m)
if (b & 1) ans = 1LL * ans * a % m;
return ans;
}
const int N = 50;
int a[110], w[110], dp[110][110][110], tmp[110][110][110];
voi... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
const int MAXM = 3010;
const int MOD = 998244353;
int qpow(int a, int b) {
int base = 1;
while (b) {
if (b & 1) base = 1ll * base * a % MOD;
a = 1ll * a * a % MOD;
b >>= 1;
}
return base;
}
int n, m, A[MAXN], W[MAXN], F[MAXM][M... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
int mod = MOD;
struct ModInt {
unsigned val;
ModInt() : val(0) {}
ModInt(long long x) : v... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
const int MOD = 998244353;
const int N = 55;
long long ans;
long long dp[N][N * 2][N];
long long rev[N * 2];
int n, m, tot, one, zero;
int l[N], w[N];
long long Pow(int x, int y) {
long long ret = 1ll, mt = 1ll * x;
while (y) {
if (y & 1) ret = (ret * mt) % MOD;
... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
using namespace std;
int n, m;
long long bm(long long base, int power) {
if (power == 0) {
return 1;
}
if (power % 2 == 0) {
long long ret = bm(base, power / 2);
return (ret * ret) % 998244353;
} else {
return (base * bm(base, power - 1)) % 998244353... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
const long long N = 60;
const long long INF = 0x3f3f3f3f;
const long long iinf = 1 << 30;
const long long linf = 2e18;
const long long MOD = 998244353;
const double eps = 1e-7;
void douout(double x) { printf("%lf\n", x + 0.0000000001); }
template <class T>
void print(T a) {... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
const int P = 998244353, INF = 0x3f3f3f3f;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long qpow(long long a, long long n) {
long long r = 1 % P;
for (a %= P; n; a = a * a % P, n >>= 1)
if (n & 1) r = r * a % P;
return r;
}
long ... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
const int N = 55;
const long long mod = 998244353;
long long a[N], w[N], dp[N][N][N], pre[N][N][N];
long long exgcd(long long a, long long b, long long &x, long long &y) {
if (b == 0) {
x = 1;
y = 0;
return a;
}
long long r = exgcd(b, a % b, x, y);
long ... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
const int M = 2e5 + 10;
const int N = 3e3 + 10;
int n, m, a[M], w[M], sum[3], f[N][N], g[N][N], inv[N << 1];
int qpow(int a, int b) {
int y = 1;
for (; b; b >>= 1, a = (long long)a * a % mod)
if (b & 1) y = (long long)y * a % mod;
return... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
int n, m;
int a[66], w[66];
long long dp[66][66][66];
int sa, sb, sum;
long long inv[10010];
void solve1(int x) {
memset(dp, 0, sizeof(dp));
dp[0][0][0] = 1;
long long zi, mu;
for (int i = 0; i < m; ++i)
for (int j = 0; j <= i; +... |
The only difference between easy and hard versions is constraints.
Nauuo is a girl who loves random picture websites.
One day she made a random picture website by herself which includes n pictures.
When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal proba... | #include <bits/stdc++.h>
using namespace std;
long long dpf[110][100][60];
long long dpg[110][100][60];
int diff;
int likes_init = 0;
const long long mod = 998244353;
long long fast_exp(long long b, int e) {
b = b % mod;
if (e == 0) return 1;
if (e == 1) return b;
if (e % 2 == 1) return (b * fast_exp(b, e - 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... | string = input().split()
first = string[0]
second = string[1]
third = string[2]
string.sort(key=lambda x: int(x[0]))
if first == second == third or first[1] == second[1] == third[1] and all(int(string[i][0]) == int(string[i - 1][0]) + 1 for i in range(1, 3)):
print(0)
elif (first == second or second == third or thi... |
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c... |
if __name__ == '__main__':
s = list(map(lambda x: (int(x[0]), x[1]), input().split()))
st = list(set([x for _, x in s]))
best = 2
for a in st:
mp = sorted(map(lambda t: t[0], list(filter(lambda x: x[1] == a, s))))
if len(mp) == 3 and (mp[0] == mp[1] == mp[2] or (mp[0] + 1 == mp[1] and 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,b,c=sorted(6*ord(y)+int(x)for x,y in input().split())
s={b-a,c-b}
print(2-bool(s&{0,1,2})-(s<{0,1})) |
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c... | import java.util.*;
public class Main {
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 min = 2;
if (a.equals(b) && b.equals(c)) {
min = 0;
}
... |
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c... | from sys import stdin, stdout
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353... |
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a 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 ={}
s['s'] = []
s['m'] = []
s['p'] = []
a = input()
h = a[0:2]
s[h[1]].append(int(h[0]))
h = a[3:5]
s[h[1]].append(int(h[0]))
h = a[6:8]
s[h[1]].append(int(h[0]))
s['s'].sort()
s['m'].sort()
s['p'].sort()
if len(s['s']) == 1 and len(s['p']) == 1 :
print("2")
for x in s :
if len(s[x]) == 2 :
if s[x]... |
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a 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.InputStreamReader;
import java.util.Arrays;
public class Ques1 {
public static void main(String[] args) throws Exception{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] z = br.readLine().split(" ");
int[][] mp... |
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c... | # http://codeforces.com/contest/1191/problem/B
'''
Author - Subhajit Das
University of Engineering and Management, Kolkata
14/07/2019
'''
def f(x: int) -> int:
return 1 if not not x else 0
def main():
inp = input().split()
idx = {'m': 0, 'p': 1, 's': 2}
table = [[0]*9 for _ 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... | cards = input().split()
m = []
s = []
p = []
for i in range(3):
if cards[i][1] == "m":
m.append(int(cards[i][0]))
elif cards[i][1] == "s":
s.append(int(cards[i][0]))
elif cards[i][1] == "p":
p.append(int(cards[i][0]))
msp = [m, s, p]
rmsp = [len(m), len(s), len(p)]
if rmsp[0] == 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... | arr = input().split()
arr = sorted(arr,key= lambda x:x[0])
no = [int(arr[0][0]),int(arr[1][0]),int(arr[2][0])]
if (arr[0] == arr[1] == arr[2]) or (no[1]-no[0]==1 and no[2]-no[1]==1 and no[2]-no[0]==2 and arr[0][1]==arr[1][1]==arr[2][1]):
print('0')
elif (arr[0]==arr[1] or arr[1]==arr[2] or arr[0]==arr[2]) or (no[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... | # -*- coding: utf-8 -*-
"""
Created on Sat Jul 13 01:25:40 2019
@author: Gulam Kibria
"""
from collections import defaultdict
st=input()
st2=st.replace(" ","")
g=defaultdict(list)
for x in range(0,7):
if(x%2==1):
g[st2[x]].append(int(st2[x-1]))
for x in g:
g[x].sort()
if(len(g)==3):
print (2)
elif... |
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c... | 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:
print(1)
exit()
prin... |
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c... | #include <bits/stdc++.h>
using namespace std;
char a[3][3];
int p[3];
int main() {
int i;
cin >> a[0] >> a[1] >> a[2];
int x;
for (i = 0; i < 3; i++) {
x = 0;
switch (a[i][1]) {
case 's':
x = 0;
break;
case 'm':
x = 10;
break;
case 'p':
x = 20;
... |
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c... | n=list(map(str,input().split(" ")))
d=dict()
mp = {"m":0 , "p":1 , "s":2}
l=[0]*10
ll=[0]*10
lll=[0]*10
arr = [l,ll,lll]
maxi=0
for i in n:
# print(i)
if (i in d.keys()):
d[i]+=1
maxi = max(maxi,d[i])
else:
d[i]=1
maxi = max(maxi,d[i])
arr[mp[i[1]]][int(i[0])-1] = 1
# print(arr)
# print(d)
if(maxi>... |
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a 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(input().split())
lm=[0]*9
lp=[0]*9
ls=[0]*9
for item in cards:
if item[1]=='m':
lm[int(item[0])-1]+=1
elif item[1]=='p':
lp[int(item[0])-1]+=1
else :
ls[int(item[0])-1]+=1
if max(lm)==3 or max(lp)==3 or max(ls)==3:
print(0)
else :
flag=0
def seq_checker(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... | a = input().split()
st = set([])
cnt = [[0 for i in range(9)] for i in range(3)]
for e in a:
cnt['mps'.index(e[1])][int(e[0]) - 1] = 1
st.add(e)
answ = len(st) - 1
for i in range(3):
for j in range(7):
answ = min(answ, 3 - sum(cnt[i][j:j + 3]))
print(answ) |
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a 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 = [0] * 10
m = [0] * 10
p = [0] * 10
D = list(input().split())
for i in D:
if i[1] == 'p':
p[int(i[0])] += 1
elif i[1] == 'm':
m[int(i[0])] += 1
else:
s[int(i[0])] += 1
need = 3
for i in range(1, 10):
need = min(3 - p[i], need)
need = min(3 - s[i], need)
need = min(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... | def main():
list_str = input().split()
list_str.sort()
""" 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
koutsu_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... | l = list(input().split())
d = {}
d["m"] = {}
d["s"] = {}
d["p"] = {}
for i in range(1,10):
d["m"][i] = 0
d["s"][i] = 0
d["p"][i] = 0
for a in l:
s = a[1]
c = int(a[0])
d[s][c] += 1
#koutsu
c = 0
for s in ["m","p","s"]:
for i in range(1,10):
c = max(c,d[s][i])
if c >= 3:
... |
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
const int mod = 1e9 + 7;
const int seed = 1333331;
long long qm(long long a, long long b, long long res = 1) {
for (a %= mod; b; b >>= 1, a = a * a % mod)
if (b & 1) res = res * a % mod;
return res;
}
int n, m;
long long a[maxn], res, lim[... |
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a 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 a, b, c;
cin >> a >> b >> c;
if (a == b && a == c)
cout << "0";
else if ((a == b && a != c))
cout << "1";
else if ((a == c && a != b))
cout << "1";
else if (b == c && b != a)
cout << "1";
else if (a[1] == b[1] && b[1] == c[1... |
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c... | o = []
n = input()
p = 0
for i in range(3):
o.insert(i, n[i + p] + n[i + 1 + p])
p = p + 2
o = sorted(o)
ans = 2
if (o[0][1] == o[1][1]) and (int(o[1][0]) - int(o[0][0]) < 3) or (o[1][1] == o[2][1]) and (int(o[2][0]) - int(o[1][0]) < 3):
ans = 1
if (o[0][1] == o[2][1]) and (int(o[2][0]) - int(o[0][0]) < 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.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String s[]=new String[3];
int a[]=new int[27];
for(int i=0;i<3;i++) {
s[i]=sc.next();
a[s[i].charAt(1)-'a']++;
}
int index='s'-'a';
if(a[index]<a['m'-... |
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c... | import java.util.*;
public class CF573B {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int[] m = new int[9];
int[] p = new int[9];
int[] s = new int[9];
for(int i=1; i<=3; i++) {
String temp = sc.next();
int pos = Integer.valueOf(temp.substring(0, 1));
char c = 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... | # for t in range(int(input())):
# s = input()
# i, j = 0, 0
# cnt = 0
# ans = float('inf')
# dic = {}
# while j < len(s):
# if len(dic) < 3:
# dic[s[j]] = dic.get(s[j], 0) + 1
# # print(j)
# # print(dic)
# while len(dic) == 3:
# ans = min(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... | a=list(map(str,input().split()));l=a
s=m=p=0;s1,m1,p1=[],[],[]
for i in a:
if 's' in i:s+=1;s1+=[int(i[0])]
elif 'p' in i:p+=1;p1+=[int(i[0])]
else:m+=1;m1+=[int(i[0])]
if m and s and p:print(2)
elif len(set(a))==1:print(0)
elif max(s,m,p)==3:
if s==3:a=s1
elif m==3:a=m1
else:a=p1
a=sorted(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 bisect
import collections
import copy
import functools
import heapq
import itertools
import math
import random
import re
import sys
import time
import string
from typing import *
sys.setrecursionlimit(99999)
arr = list(input().split())
arr.sort()
ans = 3
cs = collections.Counter(arr)
def check(ap):
cp = c... |
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c... | strInput = input()
m = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
s = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
p = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
nekoHands = 0
while (nekoHands+1 <= len(strInput)):
if (strInput[nekoHands] == " "):
nekoHands += 1
elif ( "9" >= strInput[nekoHands] >= "1" ):
if (strInput[neko... |
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a 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 TokitsukazeandMahjong
{
public static void main(String[] d)
{
int ans=2;
Scanner sc=new Scanner(System.in);
String s1=sc.next();
String s2=sc.next();
String s3=sc.next();
int a1=(s1.charAt(0)-'0');
int a2=(s2.charAt(0)-'0');
int a3=(s3.charAt(0)-'0');... |
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c... | a=[x for x in input().split()]
flag=0
m=[0 for x in range(10)]
p=[0 for x in range(10)]
s=[0 for x in range(10)]
m1=0
for i in a:
if i[1]=='s':
s[int(i[0])]=1
elif i[1]=='p':
p[int(i[0])]=1
elif i[1]=='m':
m[int(i[0])]=1
if a.count(i)==3:
flag=1
break
elif a.... |
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c... | 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)
elif 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:
print(1)
el... |
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a 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.InputStreamReader;
public class tok_and_mahjong {
public static void main(String[] args) throws java.io.IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] inputStr = br.readLine().trim().split(" ");
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... | def main():
cards = input().split()
my_list = []
if cards[0] == cards[1] == cards[2] :
ans = 0
print(ans)
elif cards[0][1] == cards[1][1] == cards[2][1]:
first_number = int(cards[0][0])
Secound_number = int(cards[1][0])
third_nubmer = int(cards[2][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... | # -*- coding: utf-8 -*-
"""
Created on Fri Jul 12 17:39:54 2019
@author: Hamadeh
"""
# -*- coding: utf-8 -*-
"""
Created on Fri Jul 12 17:33:49 2019
@author: Hamadeh
"""
class cinn:
def __init__(self):
self.x=[]
def cin(self,t=int):
if(len(self.x)==0):
a=input()
self.... |
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c... | a = input().split()
r = 2
for i in range(48,58):
for c in "mps":
r = min(r,max(0,3-a.count(chr(i)+c))) #ε€ζθ¦εε°ε
¨ι¨ηΈε
r = min(r,3-(chr(i-1)+c in a)-(chr(i)+c in a)-(chr(i+1)+c in a)) #ε€ζιι’ε«ζηεθ±ι‘Ί
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... | a,b,c=input().split()
def check(a,b,c):
if a==b==c:
return True
if a[1]==b[1]==c[1]:
a=int(a[0])
b=int(b[0])
c=int(c[0])
x=[a,b,c]
x.sort()
if x[1]==x[0]+1 and x[2]==x[1]+1:
return True
return False
s=[]
for i in range(1,10):
for cc in ... |
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.HashMap;
import java.util.ArrayList;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*
* @author... |
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c... | li = input().split()
li1 = sorted(map(lambda x: x[0], li))
li2 = sorted(map(lambda x: x[1], li))
if li[0] == li[1] and li[1] == li[2] or li2[0] == li2[2] and int(max(li1)) - int(min(li1)) == 2 and li1[0] != li1[1] and li1[1] != li1[2]:
print(0)
elif ((li[0] == li[1]) or (li[0] == li[2]) or (li[2] == li[1])) or ((
... |
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a 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][5];
int k[300];
int main() {
int a, b, c;
char x, y, z;
cin >> a >> x >> b >> y >> c >> z;
k['m'] = 1;
k['p'] = 2;
k['s'] = 3;
s[a][k[x]]++, s[b][k[y]]++, s[c][k[z]]++;
int ans = 3;
for (int i = 1; i <= 9; i++)
for (int j = 1; j <= 3; j++) an... |
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c... | li= list(input().split(" "))
li.sort()
x = li
ans = 2;
if((int(x[1][0]) - int(x[0][0])) == 1 ):
if(x[0][1] == x[1][1]):
ans = ans -1
if(int(x[1][0]) == (int(x[2][0])- 1)):
if(x[1][1] == x[2][1]):
ans = ans -1
if(int(x[2][0])- int(x[1][0]) == 2):
if(x[1][1] == x[2][1]):
... |
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c... | c = list(input().split())
a = []
for i in range(3):
a.append([])
for n in c:
if n[1]=='p':
a[0].append(int(n[0]))
elif n[1]=='m':
a[1].append(int(n[0]))
else:
a[2].append(int(n[0]))
m = 2
for i in range(3):
a[i].sort()
if len(a[i])==3 and a[i][0]==a[i][1] and a[i][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... | inp=input().split()
mps=[0,0,0]
k=['m','p','s']
num=[]
for i in range(3):
if(inp[i][1]==k[0]):
mps[0]+=1
elif(inp[i][1]==k[1]):
mps[1]+=1
else:
mps[2]+=1
sl=max(mps)
t=mps.index(sl)
for i in range(3):
if(inp[i][1]==k[t]):
num.append(int(inp[i][0]))
if(sl==1):
print(2)... |
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c... | a = input().split()
a.sort()
if a[0] == a[1] == a[2]:
print(0)
elif (int(a[0][0]) + 1 == int(a[1][0]) == int(a[2][0]) - 1) and a[0][1] == a[1][1] == a[2][1]:
print(0)
elif (a[0] == a[1] or a[0] == a[2] or a[1]==a[2]):
print(1)
elif (int(a[0][0]) + 1 == int(a[1][0]) and a[0][1] == a[1][1]) or (int(a[0][0]) +... |
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c... | l=input().split()
l.sort()
#print(l)
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:
print(1)
elif l[0][1]==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... | #include <bits/stdc++.h>
using namespace std;
int main() {
map<char, int> m;
m['s'] = 0;
m['m'] = 1;
m['p'] = 2;
string a, b, c;
cin >> a >> b >> c;
if (a == b && b == c) {
cout << 0;
return 0;
}
if (a == b || b == c || c == a) {
cout << 1;
return 0;
}
bool p[3][10];
for (int i =... |
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c... | #include <bits/stdc++.h>
using namespace std;
using namespace std;
string a[4];
int main() {
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
if (a[0][1] == a[1][1] && a[1][1] == a[2][1]) {
if (a[0][0] == a[1][0] && a[1][0] == a[2][0]) {
printf("0\n");
return 0;
}
if (a[0][0] + 1 == a[1][0] &&... |
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c... | a = sorted(input().split())
if a[0] == a[1] == a[2]:
print(0)
elif (a[0][1] == a[1][1] == a[2][1]) and (int(a[0][0]) + 1 == int(a[1][0]) and int(a[1][0]) + 1 == int(a[2][0])):
print(0)
elif a[0] == a[1] or a[1] == a[2]:
print(1)
else:
s = set(a)
r = None
for e in s:
num, word = int(e[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... |
Input=lambda:map(str,input().split())
s = list(Input())
s.sort()
num = list()
for i in range(3):
num.append(int(s[i][0]))
#0
if (s[0] == s[1] == s[2]):
print(0)
exit()
if (s[0][1] == s[1][1] == s[2][1]) and (num[0]+2 == num[1]+1 == num[2]):
print(0)
exit()
#1
if (s[0] == s[1]) or (s[1] == s[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... | # 1191B.py
l = list(map(str,input().split()))
p = []
s = []
m = []
for i in range(3):
if l[i][1] == 's':
s.append(int(l[i][0]))
if l[i][1] == 'p':
p.append(int(l[i][0]))
if l[i][1] == 'm':
m.append(int(l[i][0]))
ans = 2
m.sort()
p.sort()
s.sort()
for i in range(3):
m.appen... |
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a 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.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;
import javax.lang.model.util.ElementScanner6;
/* Name of the class has to be "Main" only if the class ... |
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a 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();
import sys;
x = int(a[0]);
y = int(b[0]);
z = int(c[0]);
if(a==b==c):
print(0);
sys.exit();
else:
arr = [x,y,z];
arr.sort();
if(a[1]==b[1]==c[1]):
if((arr[1]-arr[0])==1 and (arr[2]-arr[1])==1):
print(0);
sys.exit();
if((arr[1]-arr[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... | # Main
data = [x for x in raw_input().split(" ")]
sol = None
if len(set(data)) == 1:
sol = 0
elif data[0][1] == data[1][1] and data[0][1] == data[2][1]:
nums = [int(data[0][0]), int(data[1][0]), int(data[2][0])]
nums.sort()
if nums[0] == nums[1] - 1:
if nums[1] == nums[2] - 1:
sol = 0
else:
sol = 1
el... |
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c... | import java.util.*;
import java.io.*;
public class B {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String a = sc.next();
String b = sc.next();
String c = sc.next();
if(koutsu(a, b, c)) {
System.out.println(0);
}
else 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... | s = input()
ans = 2
s1 = s[0:2]
s2 = s[3:5]
s3 = s[6:8]
def func(inp):
ans = 2
num = int(inp[0])
c = inp[1]
ans = min( ans, 2 - int(s.find(str(num + 1)+c) != -1) - int(s.find(str(num + 2)+c) != -1))
ans = min( ans, 2 - int(s.find(str(num + 1)+c) != -1) - int(s.find(str(num - 1)+c) != -1))
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... | cards = input().split()
c1 = cards[0]
c2 = cards[1]
c3 = cards[2]
if c1 == c2 == c3:
ans = 0
elif (c1 != c3 and c1 == c2) or (c2 != c1 and c2 == c3) or (c2 != c1 and c1 == c3):
ans = 1
else:
S = [int(c1[0]), int(c2[0]), int(c3[0])]
if c1[1] == c2[1] == c3[1] and max(S) - min(S) == 2:
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... | arr=[(i[1],i[0]) for i in map(str,raw_input().split())]
arr.sort()
s,p,m=[],[],[]
de={}
ms=0
ps=1
cv=int(arr[0][1])
ca=arr[0][0]
for i in arr:
de[i]=de.get(i,[])+[i]
#print 'i-',i
#print 'cv-',cv,'ca-',ca
if cv+1==int(i[1]) and ca==i[0]:
ps+=1
else:
if cv+2==int(i[1]) and ca==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... | from sys import stdin
from math import fabs
x = [ i for i in stdin.readline().split()]
x.sort()
if x[0] == x[2]:
print(0)
elif ((int(x[0][0])+ 2) == (int(x[1][0]) + 1) == int(x[2][0])) and (x[0][1] == x[1][1] == x[2][1]) :
print(0)
elif x[0][1] == x[1][1] and int(x[1][0]) - int(x[0][0]) <= 2:
print(1)
el... |
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c... | ''' Ψ¨ΩΨ³ΩΩ
Ω Ψ§ΩΩΩΩΩΩ Ψ§ΩΨ±ΩΩΨΩΩ
ΩΩ°ΩΩ Ψ§ΩΨ±ΩΩΨΩΩΩ
Ω '''
#codeforces1191B_live
gi = lambda : list(map(int,input().strip().split()))
l = input().split()
l.sort()
if len(set(l)) == 1:
print(0)
exit()
c = l[0][1]
b = int(l[0][0])
flag = True
for e in l:
if e[1] != c:
flag = False
break
for e in l:
if int(e[0]) != b:
flag ... |
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c... | inn = raw_input()
s,m,p = [],[],[]
for x in inn.split():
if x[1] == 's':
s.append(int(x[0]))
elif x[1] == 'm':
m.append(int(x[0]))
elif x[1] == 'p':
p.append(int(x[0]))
s.sort()
m.sort()
p.sort()
if len(s) == 3 or len(m) == 3 or len(p) == 3:
def check1(q):
if (q[0] == 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... | l = input().split()
if l[0]==l[1] and l[1]==l[2]:
print(0)
exit(0)
def shuntsu(li):
li.sort()
return li[0][1]==li[1][1] and li[1][1]==li[2][1] and int(li[1][0])==int(li[0][0])+1 and int(li[2][0])==int(li[1][0])+1
if shuntsu(l):
print(0)
exit(0)
for k in l:
if len([x for x in l if x==k]) > 1:... |
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c... | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Hashtable;
public class TestClass{
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
... |
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c... | t1, t2, t3 = input().split()
if t1 == t2 == t3:
#print('koutsu')
print(0)
else:
s = []
m = []
p = []
for elem in (t1, t2, t3):
if elem[1] == "s":
s.append(int(elem[0]))
elif elem[1] == "m":
m.append(int(elem[0]))
else:
p.append(int(elem... |
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a 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 math as mt
import sys,string,bisect
input=sys.stdin.readline
l=list(input().split())
s=set(l)
for i in s:
if(l.count(i)==3):
print(0)
exit()
elif(l.count(i)==2):
print(1)
exit()
else:
g=[]
for i in range(3):
g.append((l[i][0],l[i][1]))
g.sort(key=la... |
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c... | from collections import Counter
a = list(input().split())
#print(a)
s = set(a)
r = 3
for b in a:
b1,b2 = int(b[0]),b[1]
for i in range(3):
c1,c2,c3 = b1-2+i,b1-1+i,b1+i
if c1>0 and c3<10:
d = set([str(c1)+b2,str(c2)+b2,str(c3)+b2])
r = min(r,len(d-s))
if r==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... | // No sorceries shall prevail. //
import java.util.Scanner;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Queue;
public class InVoker {
public static void main(String args[]) {
Scanner inp=new Scanner(System.in);
Prin... |
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a 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 random import randint
# a = list(map(int, input().split()))
# a, b, c, d = map(int, input().split())
# q = int(input())
def gcd(a, b):
if b == 0:
return a
else:
return gcd(b, a % b)
a = list(map(str, input().split()))
m = {}
for i in range(3):
if a[i] in m:
m[a[i]] += 1
... |
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c... |
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String s[]=new String[3];
int a[]=new int[30];
int n[]=new int[3];
for(int i=0;i<3;i++) {
s[i]=sc.next();
a[s[i].charAt(1)-'a']++;
n[i]=s[i].charAt(0)-... |
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c... | from collections import defaultdict as dfd
d = dfd(int)
arr = input().split()
arr.sort()
for i in arr:
d[i] += 1
if max(d.values())==3 or (arr[0][1]==arr[1][1]==arr[2][1] and int(arr[0][0])+1==int(arr[1][0]) and int(arr[1][0])+1==int(arr[2][0])):
print(0)
elif max(d.values())==2:
print(1)
else:
flag ... |
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c... | a=list(map(str,input().split()));l=a
s=m=p=0;s1,m1,p1=[],[],[]
for i in a:
if 's' in i:s+=1;s1+=[int(i[0])]
elif 'p' in i:p+=1;p1+=[int(i[0])]
else:m+=1;m1+=[int(i[0])]
if m and s and p:print(2)
elif len(set(a))==1:print(0)
elif max(s,m,p)==3:
if s==3:a=s1
elif m==3:a=m1
else:a=p1
a=sorted(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() {
int num, m = 0, p = 0, s = 0;
char alpha;
vector<pair<int, char>> tiles;
for (int i = 0; i < 3; i++) {
cin >> num >> alpha;
pair<int, char> temp = make_pair(num, alpha);
tiles.push_back(temp);
if (alpha == 'm') {
m++;
} else 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... | line = input().split()
line.sort()
a,b,c = line
if a == b and a == c:
print(0)
elif a == b:
print(1)
elif b == c:
print(1)
else:
if a[1] == b[1] and b[1] == c[1] \
and int(b[0])-int(a[0]) == 1 and int(c[0])-int(b[0]) == 1:
print(0)
elif a[1] == b[1] and int(b[0])-int(a[0]) in [1,2]:
... |
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c... | l = input().split()
suit = ['m', 'p', 's']
from collections import defaultdict
cnt = defaultdict(lambda : 0)
for i in range(3):
cnt[l[i]] += 1
mini = 10
for i in suit:
for j in range(1, 10):
# shuntsu
if j + 2 <= 9:
cn = 0
for k in range(3):
cn += int("... |
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a 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<vector<int>> b(9);
for (int i = 0; i < 9; i++)
for (int j = 0; j < 3; j++) b[i].push_back(0);
string s;
for (int i = 0; i < 3; i++) {
cin >> s;
switch (s[1]) {
case 'm':
b[s[0] - '1'][0]++;
break;
case 'p':... |
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first c... | import collections
a=input().split()
a.sort()
if a[0]==a[1] and a[1]==a[2]:
print(0)
elif a[0][1]==a[1][1] and a[1][1]==a[2][1] and abs(int(a[1][0])-int(a[0][0]))==1 and abs(int(a[2][0])-int(a[1][0]))==1:
print("0")
elif a[0]==a[1] or a[1]==a[2] or a[2]==a[0]:
print("1")
elif a[0][1]==a[1][1] and (abs(int(a... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.