Search is not available for this dataset
name
stringlengths
2
88
description
stringlengths
31
8.62k
public_tests
dict
private_tests
dict
solution_type
stringclasses
2 values
programming_language
stringclasses
5 values
solution
stringlengths
1
983k
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; signed main() { int n; cin >> n; map<char, int> cnt; cnt['M'] = 0; cnt['A'] = 0; cnt['R'] = 0; cnt['C'] = 0; cnt['H'] = 0; for (int i = 0; i < n; ++i) { string s; cin >> s; cnt[s[0]]++; } int ans = 0; ans += cnt['M'] * cnt['A'] * cnt['R']; ans += cnt['M'] * cnt['A'] * cnt['C']; ans += cnt['M'] * cnt['A'] * cnt['H']; ans += cnt['M'] * cnt['R'] * cnt['C']; ans += cnt['M'] * cnt['R'] * cnt['H']; ans += cnt['M'] * cnt['C'] * cnt['H']; ans += cnt['A'] * cnt['R'] * cnt['C']; ans += cnt['A'] * cnt['R'] * cnt['H']; ans += cnt['A'] * cnt['C'] * cnt['H']; ans += cnt['R'] * cnt['C'] * cnt['H']; cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
from collections import Counter from itertools import combinations n = int(input()) l = Counter(input()[0] for _ in range(n)) con = [l[c] for c in 'MARCH' if c in l] print(sum(a * b * c) for a, b, c in combinations(con, 3))
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> int main() { char s[10001][11]; int n; char march[] = {'M', 'A', 'R', 'C', 'H'}; int d[5] = {0, 0, 0, 0, 0}; int p[5] = {0, 1, 2, 3, 4}; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%s", s[i]); for (int j = 0; j < 5; j++) if (s[i][0] == march[j]) d[j]++; } int sum; do { sum += d[p[0]] + d[p[1]] + d[p[2]]; } while (std::next_permutation(p, p + 5)); printf("%d\n", sum); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { long long int a, e = 0; cin >> a; vector<long long int> c(a); vector<long long int> d(a); string b; for (int i = 0; i < (int)(a); ++i) c[i] = 0; for (int i = 0; i < (int)(a); ++i) d[i] = i; for (int i = 0; i < (int)(a); ++i) { cin >> b; if (b.at(0) == 'M') c[0]++; if (b.at(0) == 'A') c[1]++; if (b.at(0) == 'R') c[2]++; if (b.at(0) == 'C') c[3]++; if (b.at(0) == 'H') c[4]++; } for (int i = 0; i < (int)(a - 2); ++i) { for (int j = i + 1; j < a - 1; j++) { for (int o = j + 1; o < a; o++) { e += c[i] * c[o] * c[j]; } } } cout << e; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; long int ans = 0; int main() { int n, i, g; int f[5] = {0}; char a[15]; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%s", a); if (a[0] == 'A') f[1] += 1; if (a[0] == 'M') f[2] += 1; if (a[0] == 'R') f[3] += 1; if (a[0] == 'H') f[4] += 1; if (a[0] == 'C') f[0] += 1; } for (i = 0; i < 3; i++) { for (int j = i + 1; j < 4; j++) { for (int k = j + 1; k < 5; k++) { ans += f[i] * f[j] * f[k]; } } } printf("%ld", ans); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { long long s = 0; int n, i, a = 0, b = 0, c = 0, d = 0, e = 0; char arr, tmp[100]; scanf("%d", &n); getchar(); for (i = 0; i < n; i++) { scanf("%s", tmp); getchar(); arr = tmp[0]; if (arr == 'M') e++; if (arr == 'A') a++; if (arr == 'R') b++; if (arr == 'C') c++; if (arr == 'H') d++; } s += a * b * c + a * b * d + a * b * e + a * c * d + a * c * e + a * d * e + b * c * d + b * c * e + b * d * e + c * d * e; printf("%d", s); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } int main() { int n; cin >> n; string s; map<char, int> S; S['M'] = 0; S['A'] = 1; S['R'] = 2; S['C'] = 3; S['H'] = 4; map<int, int> m; for (int i = 0; i < (n); ++i) { cin >> s; if (s[0] != 'M' && s[0] != 'A' && s[0] != 'R' && s[0] != 'C' && s[0] != 'H') continue; ++m[S[s[0]]]; } int ans = 0; for (int bit = 0; bit < (1 << 5); ++bit) { if (__builtin_popcount(bit) == 3) { int tmp = 1; for (int i = 0; i < (5); ++i) { if (bit & (1 << i)) { tmp *= m[i]; } } ans += tmp; } } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; string i_s(int x) { if (x == 0) return "0"; string ret = ""; while (x) { ret = ret + (char)(x % 10 + '0'); x /= 10; } reverse(ret.begin(), ret.end()); return ret; } string add(string a, string b) { if (a == "") a = "0"; if (b == "") b = "0"; if (a.length() < b.length()) swap(a, b); while (b.length() < a.length()) { b = '0' + b; } for (int i = 0; i < a.length(); i++) { a[i] = a[i] + (b[i] - '0'); } bool big = false; for (int i = a.length() - 1; i >= 0; i--) { if (big) { a[i]++; } big = false; if (a[i] > '9') { a[i] = a[i] - 10; big = true; } } if (big) a = '1' + a; return a; } string mul(string a, string b) { vector<int> va, vb; if (a == "0" || b == "0") return "0"; string ans; for (int i = 0; i < a.length(); i++) { va.push_back(a[i] - '0'); } for (int i = 0; i < b.length(); i++) { vb.push_back(b[i] - '0'); } reverse(va.begin(), va.end()); reverse(vb.begin(), vb.end()); vector<int> res; res.clear(); res.resize(1005); for (int i = 0; i < a.length(); i++) { for (int j = 0; j < b.length(); j++) { res[i + j] += (va[i] * vb[j]); } } for (int i = 0; i < 1005; i++) { if (res[i] > 9) { res[i + 1] += (res[i] / 10); res[i] %= 10; } } for (int i = 0; i < 1005; i++) { ans += (res[i] + '0'); } reverse(ans.begin(), ans.end()); int k = 0; while (ans[k] == '0') { k++; } ans = ans.substr(k); return ans; } bool is_prime(int n) { if (n < 2) return false; for (int i = 2; i * i <= n; i++) if (n % i == 0) return false; return true; } long long n, a[10], ans; string s; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> s; if (s[0] == 'M') a[1]++; if (s[0] == 'A') a[2]++; if (s[0] == 'R') a[3]++; if (s[0] == 'C') a[4]++; if (s[0] == 'H') a[5]++; } for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { ans += a[i] * a[j] * a[k]; } } } cout << ans; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; unsigned long long nCr(int n, int r) { return (n * (n - 1) * (n - 2)) / (r * (r - 1) * (r - 2)); } int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; int march = 0; vector<int> same_initial(26, 0); for (int i = 0; i < N; i++) { string s; cin >> s; if (s[0] == 'M' || s[0] == 'A' || s[0] == 'R' || s[0] == 'C' || s[0] == 'H') { march++; same_initial[s[0] - 'A']++; } } unsigned long long sum = nCr(march, 3); for (int i = 0; i < 26; i++) { if (same_initial[i] > 1) { int cnt = same_initial[i]; for (int j = 0; j < 26; j++) { if (j == i) continue; sum -= same_initial[j]; } } } cout << sum << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
"use strict"; const getGcd = input => { let len, a, b; len = input.length; a = input[0]; for (let i = 1; i < len; i++) { b = input[i]; a = gcdTwoNumbers(a, b); } return a; } const gcdTwoNumbers = (x, y) => { x = Math.abs(x); y = Math.abs(y); while(y) { let t = y; y = x % y; x = t; } return x; } const main = arg => { arg = arg.trim().split("\n"); const N = parseInt(arg[0]); const monsters = arg[1].split(" ").map(n=>parseInt(n)); console.log(getGcd(monsters)); } main(require('fs').readFileSync('/dev/stdin', 'utf8'));
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
import sys import itertools if sys.platform =='ios': sys.stdin=open('Untitled.txt') input = sys.stdin.readline def INT(): return int(input()) def MAP(): return [int(s) for s in input().split()] N = INT() S = [input().rstrip() for _ in range(N)] S = [s for s in S if s[0] in 'MARCH'] C = list(itertools.combinations(S, 3)) #print(C) cnt = 0 for c in C: #print(c) x, y, z = c if x[0] != y[0] and y[0] != z[0] and x[0] != z[0]: cnt += 1 print(cnt)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { double N, count = 0; vector<double> f(5, 0); double ans = 0, sum = 1; string name; cin >> N; for (int i = 0; i < N; i++) { cin >> name; if (name[0] == 'M') { f[0]++; } else if (name[0] == 'A') { f[1]++; } else if (name[0] == 'R') { f[2]++; } else if (name[0] == 'C') { f[3]++; } else if (name[0] == 'H') { f[4]++; } } for (int i = 0; i < 5; i++) { if (0 < f[i]) { count++; sum *= f[i]; } } if (count < 3) { cout << 0 << endl; } else if (count == 3) { cout << sum << endl; } else if (count == 4) { for (int i = 0; i < 5; i++) { if (f[i] != 0) { ans += sum / f[i]; } } cout << ans << endl; } else { for (int i = 0; i < 4; i++) { for (int j = i + 1; j < 5; j++) { ans += sum / f[i] / f[j]; } } cout << ans << endl; } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { string s = "MARCH"; int c[5] = {0}; int n; scanf("%d", &n); for (int i = 0; i < n; i++) { string t; cin >> t; for (int j = 0; j < 5; j++) { if (t[0] == s[j]) { c[j]++; } } } unsigned long long ans = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { ans += c[i] * c[j] * c[k]; } } } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s = "MARCH"; int c[5] = {0}; for (int i = 0; i < n; ++i) { string t; cin >> t; for (int j = 0; j < 5; ++j) { if (t[0] == s[j]) c[j]++; } } int ans = 0; for (int i = 0; i < 5; ++i) { for (int j = i + 1; j < 5; ++j) { for (int k = j + 1; k < 5; ++k) { ans += c[i] * c[j] * c[k]; } } } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include <bits/stdc++.h> int main() { long a[5] = {0, 0, 0, 0, 0}; int N; scanf("%d", &N); int k; for (k = 1; k <= N; k++) ; { char s[10]; scanf("%s", s); if (s[0] == 'M') a[0]++; if (s[0] == 'A') a[1]++; if (s[0] == 'R') a[2]++; if (s[0] == 'C') a[3]++; if (s[0] == 'H') a[4]++; } long O = 0; int s, t, r; for (s = 0; s <= 2; s++) { for (t = s + 1; t <= 3; t++) { for (r = t + 1; r <= 4; r++) { O += a[s] * a[t] * a[r]; } } } printf("%d", O); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
/* ---------- STL Libraries ---------- */ // IO library #include <cstdio> #include <fstream> #include <iomanip> #include <ios> #include <iostream> // algorithm library #include <algorithm> #include <cmath> #include <numeric> #include <random> // container library #include <array> #include <bitset> #include <deque> #include <map> #include <queue> #include <set> #include <string> #include <tuple> #include <vector> /* ---------- Namespace ---------- */ using namespace std; /* ---------- Type Abbreviation ---------- */ template <typename T> using PQ = priority_queue<T>; template <typename T> using GPQ = priority_queue<T, vector<T>, greater<T>>; using ll = long long; #define fst first #define snd second #define mp make_pair #define mt make_tuple /* ---------- conversion ---------- */ #define INT(c) static_cast<int>(c) #define CHAR(n) static_cast<char>(n) #define LL(n) static_cast<ll>(n) #define DOUBLE(n) static_cast<double>(n) /* ---------- container ---------- */ #define ALL(v) (v).begin(), (v).end() #define SIZE(v) (LL((v).size())) #define FIND(v, k) (v).find(k) != (v).end() #define VFIND(v, k) find(ALL(v), k) != (v).end() #define gsort(b, e) sort(b, e, greater<decltype(*b)>()) /* ----------- debug ---------- */ template <class T> ostream& operator<<(ostream& os, vector<T> v) { os << "["; for (auto vv : v) os << vv << ","; return os << "]"; } template <class T> ostream& operator<<(ostream& os, set<T> v) { os << "["; for (auto vv : v) os << vv << ","; return os << "]"; } template <class L, class R> ostream& operator<<(ostream& os, pair<L, R> p) { return os << "(" << p.fst << "," << p.snd << ")"; } /* ---------- Constants ---------- */ // const ll MOD = 1e9 + 7; // const int INF = 1 << 25; // const ll INF = 1LL << 50; // const double PI = acos(-1); // const double EPS = 1e-10; // mt19937 mert(LL(time(0))); /* ---------- Short Functions ---------- */ template <typename T> T sq(T a) { return a * a; } template <typename T> T gcd(T a, T b) { if (a > b) return gcd(b, a); return a == 0 ? b : gcd(b % a, a); } template <typename T, typename U> T mypow(T b, U n) { if (n == 0) return 1; if (n == 1) return b /* % MOD */; if (n % 2 == 0) { return mypow(b * b /* % MOD */, n / 2); } else { return mypow(b, n - 1) * b /* % MOD */; } } ll pcnt(ll b) { return __builtin_popcountll(b); } // const ll dx[4] = {0, -1, 1, 0}; // const ll dy[4] = {-1, 0, 0, 1}; // const ll dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1}; // const ll dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1}; /* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */ int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; int cnt_M = 0, cnt_A = 0, cnt_R = 0, cnt_C = 0, cnt_H = 0; for(int i=0;i<N;i++) { char S; cin >> S; if (S[0] == 'M') cnt_M++; else if (S[0] == 'A') cnt_A++; else if (S[0] == 'R') cnt_R++; else if (S[0] == 'C') cnt_C++; else if (S[0] == 'H') cnt_H++; } cout << cnt_M * cnt_A*cnt_R*cnt_C*cnt_H << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int INF = (1 << 28); const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0}; const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1}; int n; string s[100000]; int sl[100000]; int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> n; for (int i = 0; i < n; i++) { cin >> s[i]; sl[i] = s[i].length(); s[i] = s[i].c_str(); } int countm = 0; int counta = 0; int countr = 0; int countc = 0; int counth = 0; for (int i = 0; i < n; i++) { if (s[i][0] == 'M') countm++; if (s[i][0] == 'A') counta++; if (s[i][0] == 'R') countr++; if (s[i][0] == 'C') countc++; if (s[i][0] == 'H') counth++; } long long ans = long long(long long(countm * counta * countr) + long long(countm * counta * countc) + long long(countm * counta * counth) + long long(countm * countr * countc) + long long(countm * countr * counth) + long long(countm * countc * counth) + long long(counta * countr * countc) + long long(counta * countr * counth) + long long(counta * countc * counth) + long long(countr * countc * counth)); cout << ans << "\n"; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Globalization; using System.Numerics; using System.Text.RegularExpressions; //byte 255 int<2147483647 ≒ 2 * 10^9 long < 9223372036854775807 ≒ 9 * 10^18 //decimal 29桁 class Myon { //chokudaiさんのコードをコピペ static Scanner cin; public Myon() { } public static int Main() { //Console.SetOut(new Printer(Console.OpenStandardOutput())); cin = new Scanner(); new Myon().calc(); return 0; } public void calc() { int n = cin.nextInt(); char[] march = new char[] { 'M', 'A', 'R', 'C', 'H' }; int[] count = new int[5]; for (int i = 0; i < n; i++) { int index = Array.IndexOf(march, cin.next()[0]); if (index >= 0) count[index]++; } int ans = 0; for(int i = 0; i < 5; i++) { if (count[i] == 0) continue; for (int j = i + 1; j < 5; j++) { if (count[j] == 0) continue; for (int k = j + 1; k < 5; k++) { if (count[k] != 0) ans += count[i] * count[j] * count[k]; } } } ShowL(ans); } public void calcB() { int n = cin.nextInt(); int m = cin.nextInt(); int[] k = cin.nextIntArr(n); bool isOK = false; foreach (int k1 in k) { foreach (int k2 in k) { foreach (int k3 in k) { foreach (int k4 in k) { if(k1+k2+k3+k4 == m) { isOK = true; goto endphase; } } } } } endphase: Yorn(isOK); } public static void ShowL() { Console.WriteLine(""); } public static void ShowL<T>(T s) { Console.WriteLine(s); } public static void Show<T>(T s) { Console.Write(s); } public static void Yorn(bool isOK,string ifOK = "Yes",string ifNOTOK ="No") { if (isOK) ShowL(ifOK); else ShowL(ifNOTOK); } } class Printer : StreamWriter { public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } } public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { } public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { } } class Scanner { string[] s; int i; char[] cs = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string next() { while (i >= s.Length) { string st = Console.ReadLine(); while (st == "") st = Console.ReadLine(); s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); i = 0; } return s[i++]; } public int nextInt() { return int.Parse(next()); } public int[] nextIntArr(long n) { int[] output = new int[n]; for (int i = 0; i < n; i++) output[i] = nextInt(); return output; } public long nextLong() { return long.Parse(next()); } public double nextDouble() { return double.Parse(next()); } } static class SMath { /// <summary> /// 素因数分解して、n番目に見つかった素因数をoutput[n-1]に返します。 /// 12 なら 2,2,3 です。 /// </summary> /// <param name="n"></param> /// <returns></returns> public static List<long> Factorization(long n) { if (n <= 0) return null; List<long> output = new List<long>(); int i = 2; long max = (long)Math.Sqrt(n); ; while (n > 1) { if (i > max) { output.Add(n); break; } while (n % i == 0) { output.Add(i); n /= i; } i++; } return output; } /// <summary> /// 素因数分解して、n番目に見つかった素因数をoutput[n-1]に返します。 /// 84 = (2^2 * 3 * 7) なら 2, 1, 0, 1  remainder = 1です。(打ち切られない) /// 13 = 0,0,...0 remainder = 2019 /// ただし、試行を打ち切った時に限り残りをremainderに返す。(remainderは素数または1となる) /// </summary> /// <param name="n"></param> /// <param name="remainder"></param> /// <returns></returns> public static List<long> Factorization(long n, out long remainder) { //output[i] が i-1番目の素数の数を示す //ただし、試行を打ち切った時に限り残りをremainderに返す。(remainderは素数または1となる) remainder = 1; if (n <= 0) return null; List<long> output = new List<long>(); long tempn = 2; long max = (long)Math.Sqrt(n); bool[] isNOTPrime = new bool[max+1]; while (n > 1) { if (tempn > max) { remainder = n; break; } if (!isNOTPrime[tempn]) { output.Add(0); while (n % tempn == 0) { output[output.Count - 1]++; n /= tempn; } for (long j = tempn * 2; j < isNOTPrime.Length; j += tempn) isNOTPrime[j] = true; } tempn++; } return output; } /// <summary> /// i番目の素数をoutput[i-1]に返します。 /// ただしnより大きい素数については判定しません。 /// </summary> /// <param name="n"></param> /// <returns></returns> public static List<long> GetPrimeNumbers(long n) { if (n <= 0) return null; List<long> output = new List<long>(); long tempn = 2; bool[] isNOTPrime = new bool[n + 1]; while (n > 1) { if (tempn > n) { break; } if (!isNOTPrime[tempn]) { output.Add(tempn); for (long j = tempn * 2; j < isNOTPrime.Length; j += tempn) isNOTPrime[j] = true; } tempn++; } return output; } private static long[][] combMemo; private static int maxn_combination = -1; public static long Combination(int n, int k) { if (n < 0 || k > n) return 0; if (n == k || k == 0) return 1; if (k > n/2) return Combination(n, n - k); if (maxn_combination < n) { maxn_combination = n; combMemo = new long[n+1][]; } if (combMemo[n] == null) combMemo[n] = new long[n/2 + 1]; if (combMemo[n][k] != 0) return combMemo[n][k]; else { combMemo[n][k] = Combination(n - 1, k) + Combination(n - 1, k - 1); return combMemo[n][k]; } } public static long Gcd(long a, long b) { if (a <= 0) return -1; //if (a > b) return gcd(b, a); if (b == 0) return a; return Gcd(b, a % b); } public static long Lcm(long a,long b) { return a / Gcd(a, b) * b; } public class pairComparer : IComparer<int[]> { int index = 0; public pairComparer(int n) { index = n; } public pairComparer() { index = 0; } public int Compare(int[] x, int[] y) { return y[index] - y[index]; } } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.*; import java.util.HashSet; import java.util.Set; public class Main{ public static void main(String[]args){ Scanner sc=new Scanner(System.in); int N=sc.nextInt(); ArrayList<String>M=new ArrayList<String>(); ArrayList<String>A=new ArrayList<String>(); ArrayList<String>R=new ArrayList<String>(); ArrayList<String>C=new ArrayList<String>(); ArrayList<String>H=new ArrayList<String>(); String[]namae=new String[N]; for(int i=0;i<N;i++){ namae[i]=sc.next(); char[]a=namae[i].toCharArray(); if(a[0]=='M'){ M.add(namae[i]); } if(a[0]=='A'){ A.add(namae[i]); } if(a[0]=='R'){ R.add(namae[i]); } if(a[0]=='C'){ C.add(namae[i]); } if(a[0]=='H'){ H.add(namae[i]); } } long sum=0; sum+=M.size()*A.size()*R.size(); sum+=M.size()*A.size()*C.size(); sum+=M.size()*A.size()*H.size(); sum+=M.size()*R.size()*C.size(); sum+=M.size()*R.size()*H.size(); sum+=M.size()*C.size()*H.size(); sum+=A.size()*R.size()*C.size(); sum+=A.size()*R.size()*H.size(); sum+=A.size()*C.size()*H.size(); sum+=R.size()*C.size()*H.size(); System.out.println(sum); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int p[5]; int main() { int n; cin >> n; string s; for (int i = 0; i < n; i++) { cin >> s; if (s[0] == 'M') p[0]++; if (s[0] == 'A') p[1]++; if (s[0] == 'R') p[2]++; if (s[0] == 'C') p[3]++; if (s[0] == 'H') p[4]++; } long long ans = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { ans += p[i] * p[j] * p[k]; } } } cout << ans; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
import sys, re, os from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from itertools import permutations, combinations, product, accumulate from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_uppercase, digits from fractions import gcd def input(): return sys.stdin.readline().strip() def INT(): return int(input()) def MAP(): return map(int, input().split()) def S_MAP(): return map(str, input().split()) def LIST(): return list(map(int, input().split())) def S_LIST(): return list(map(str, input().split())) sys.setrecursionlimit(10 ** 9) INF = float('inf') mod = 10 ** 9 + 7 N = INT() S = [input() for i in range(N)] s = set(S) s = list(s) ans = 0 import itertools # seq = ('a', 'b', 'c', 'd', 'e') # ptr = list(itertools.combinations(seq,3)) # 組み合わせ列挙 5C3 l = [] for i in range(len(s)): if s[i][0] in "MARCH": ans += 1 l.append(s[i]) r = [] if ans == 0: print(ans) else: ptr = list(itertools.combinations(l,3)) # 組み合わせ列挙 5C3 for i in range(len(ptr)): if ptr[i][0][0] != ptr[i][1][0] and ptr[i][2][0] != ptr[i][1][0] and ptr[i][2][0] != ptr[i][0][0]: r.append(ptr[i]) # for j in range(3): # print(ptr[i][j][0]) # if ptr[i][j][0] != ptr[i][j][1] and ptr[i][j][0] != ptr[i][j][2] and ptr[i][j][1] != ptr[i][j][2]: # # print(len(ptr)) # # print(ptr[i]) # r.append(ptr[i]) # break # r.append(ptr[i]) print(len(r))
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int m, a, r, c, h; int main(void) { int N; long long int ans; cin >> N; string S[N]; char s[N]; for (int i = 0; i < N; i++) { cin >> S[i]; s[i] = S[i][0]; if (s[i] == 'M') { m++; } if (s[i] == 'A') { a++; } if (s[i] == 'R') { r++; } if (s[i] == 'C') { c++; } if (s[i] == 'H') { h++; } } cout << m << a << r << c << h; ans = m * a * r + m * a * c + m * a * h + m * r * c + m * r * h + m * c * h + a * r * c + a * r * h + a * c * h + r * c * h; cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
package main import ( "bufio" "container/list" "fmt" "os" "strconv" ) var sc = bufio.NewScanner(os.Stdin) func read() string { sc.Scan() return sc.Text() } func readInt() int { i, _ := strconv.Atoi(read()) return i } var res int = 0 var l = list.New() func main() { sc.Split(bufio.ScanWords) n := readInt() name := make([][]rune, 0) for i := 0; i < n; i++ { name = append(name, []rune(read())) } // for i := 0; i < n; i++ { fmt.Println("----------------") dp := make(map[rune]int, 0) _ = Solve(name, 0, dp) fmt.Println("----------------") // } fmt.Println(res) } func Solve(name [][]rune, c int, dp map[rune]int) map[rune]int { if c == 3 { res++ return dp } if len(name) == 0 { return dp } if _, ok := dp[name[0][0]]; !ok { if name[0][0] == 'M' || name[0][0] == 'A' || name[0][0] == 'R' || name[0][0] == 'C' || name[0][0] == 'H' { fmt.Println(string(name[0]), c) dp[name[0][0]] = 1 dp = Solve(name[1:], c+1, dp) delete(dp, name[0][0]) } dp = Solve(name[1:], c, dp) } return dp }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { string s = "MARCH"; int c[5] = {0}; int N; cin >> N; for (int i = 0; i < N; i++) { string t; cin >> t; for (int j = 0; j < 5; j++) { if (t[0] == s[j]) c[j]++; } } int ans = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { ans += c[i] * c[j] * c[k]; } } } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long long m = 0, a = 0, r = 0, c = 0, h = 0; vector<int> D(5); long long ans = 0; vector<int> P = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2}; vector<int> Q = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3}; vector<int> R = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4}; for (int i = 0; i < (int)(n); i++) { string s; cin >> s; if (s[0] == 'M') m++; else if (s[0] == 'A') a++; else if (s[0] == 'R') r++; else if (s[0] == 'C') c++; else if (s[0] == 'H') h++; } D[0] = m; D[1] = a; D[2] = r; D[3] = c; D[4] = h; for (int i = 0; i < (int)(10); i++) { ans += D[P[i]] * D[Q[i]] * D[R[i]]; } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
import itertools n=int(input()) s=list(input() for _ in range(n)) s=list(map(lambda _s: _s[0], filter(lambda _s: _s[0] == "M" or _s[0] == "A" or _s[0] == "R" or _s[0] == "C" or _s[0] == "H", s))) if len(s) == 0: print(0) quit() print(len(list(filter(lambda x: len(x)==3, map(set, itertools.combinations(s, 3))))))
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { cout << 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int SZ = 5; signed main() { ios::sync_with_stdio(false); cin.tie(0); int n; string s; cin >> n; vector<int> cnt(n); for (int i = 0; i < n; i++) { cin >> s; if (s[0] == 'M') cnt[0]++; else if (s[0] == 'A') cnt[1]++; else if (s[0] == 'R') cnt[2]++; else if (s[0] == 'C') cnt[3]++; else if (s[0] == 'H') cnt[4]++; } long long ans = 0; for (int i = (0), i_len = (SZ); i < i_len; ++i) for (int j = (i + 1), j_len = (SZ); j < j_len; ++j) for (int k = (j + 1), k_len = (SZ); k < k_len; ++k) { ans += (cnt[i] * cnt[j] * cnt[k]); } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string str; int m = 0; int a = 0; int r = 0; int c = 0; int h = 0; for (int i = 0; i < n; i++) { cin >> str; if (str[0] == 'M') { m++; } else if (str[0] == 'A') { a++; } else if (str[0] == 'R') { r++; } else if (str[0] == 'C') { c++; } else if (str[0] == 'H') { h++; } } long long answer; answer = m * a * r + m * a * c + m * a * h + m * r * c + m * r * h + m * c * h + a * r * c + a * r * h + a * c * h + r * c * h; cout << answer << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<string> s(n); for (int i = 0; i < (int)(n); i++) cin >> s.at(i); vector<int> cnt(5, 0); string march = "MARCH"; for (int i = 0; i < n; i++) { for (int j = 0; j < 5; j++) { if (s.at(i).at(0) == march.at(j)) { cnt.at(j) = cnt.at(j) + 1; } } } int answer = 0; for (int i = 0; i < 32; i++) { int cnt_1 = 0; int tmp = i; int tmp_c = 1; for (int j = 0; j < 5; j++) { if (tmp % 2 == 1) { cnt_1++; tmp_c *= cnt.at(j); } tmp /= 2; } if (cnt_1 == 3) { answer += tmp_c; } } cout << answer << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
N = int(input()) Sdic = {} L = ["M","A","R","C","H"] for i in L: Sdic[i] = [] tN = N for i in range(N): s = input() if s[0] in L: Sdic[s[0]].append(s) else: tN -= 1 zen = tN*(tN-1)*(tN-2) / 6 one = 0 for i in ["M","A","R","C","H"]: c = len(Sdic[i]) if c >= 3: one += c * (c-1) * (c-2) / 6 lis = [] for i in range(N): for j in range(N): if i < j: lis.append(len(Sdic[L[i]]) + len(Sdic[L[j]])) two = 0 for c in lis: if c >= 3: two += c * (c-1) * (c-2) / 6 print(int(zen - one - two))
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <iostream> #include <cstdio> int main() { lomg lomg n; char s[10]; //char top[]={'M','A','R','C','H'}; long long c[5]={0}; long long ans=0; scanf("%lld",&n); for(int i=0;i<n;i++){ scanf("%s",s); if(s[0]=='M'){c[0]++;} if(s[0]=='A'){c[1]++;} if(s[0]=='R'){c[2]++;} if(s[0]=='C'){c[3]++;} if(s[0]=='H'){c[4]++;} } for(int i=0;i<5;i++){ for(int j=i+1;j<5;j++){ for(int k=j+1;k<5;k++){ ans+=c[i]*c[j]*c[k]; } } } printf("%lld\n",ans); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { long long i, j, n, ans = 0; int m = 0, a = 0, r = 0, c = 0, h = 0; string s[100001]; cin >> n; for (i = 0; i < n; i++) { cin >> s[i]; } for (i = 0; i < n; i++) { if (s[i][0] == 'M') { m++; } if (s[i][0] == 'A') { a++; } if (s[i][0] == 'R') { r++; } if (s[i][0] == 'C') { c++; } if (s[i][0] == 'H') { h++; } } ans = (m * a * r) + (m * a * c) + (m * a * h) + (m * r * c) + (m * r * h) + (m * c * h) + (a * r * c) + (a * r * h) + (a * c * h) + (r * c * h); cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n, m = 0, a = 0, r = 0, c = 0, h = 0; cin >> n; string s; for (int i = 0; i < n; i++) { cin >> s; if (s[0] == 'M') { m++; } else if (s[0] == 'A') { a++; } else if (s[0] == 'R') { r++; } else if (s[0] == 'C') { c++; } else if (s[0] == 'H') { h++; } } cout << m * (a * r + a * c + a * h + r * c + r * h + c * h) + a * (r * c + r * h + c * h) + r * c * h; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; char ch[20]; int b[1000]; char cd[5] = {'M', 'A', 'R', 'C', 'H'}; long long int sum = 0; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) { cin >> ch; b[ch[0]]++; } for (int i = 0; i <= 2; i++) for (int j = i + 1; j <= 3; j++) for (int k = j + 1; k <= 4; k++) { sum += b[cd[i]] * b[cd[j]] * b[cd[k]]; } cout << sum; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
fun main(args: Array<String>){ val N: String = kotlin.io.readLine() ?: return val n = Integer.parseInt(N) var a = intArrayOf(0, 0, 0, 0, 0) var ans = 0 for(i in 1..n){ val s = kotlin.io.readLine() ?: return when(s[0]){ 'M' -> a[0]++ 'A' -> a[1]++ 'R' -> a[2]++ 'C' -> a[3]++ 'H' -> a[4]++ } } for(i in a.indices){ for(j in a.indices){ if(i == j) continue for(k in a.indices){ if(i == k || j == k) continue ans += a[i] * a[j] * a[k] } } } println(ans/6) }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.*; import java.lang.*; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int N = sc.nextInt(); char[] alp = new char[]{"M","A","R","C","H"}; long[] count = new int[5]; for( int i=1; i<=N; i++ ){ String ss = sc.next(); char cc = ss.charAt(0); for( int j=0; j<=4; j++ ){ if( cc==alp[j] ){ count[j]++; break; } } } long ans = 0; for( int i=0; i<=2; i++ ){ for( int j=i+1; j<=3; j++ ){ for( int k=j+1; k<=4; k++ ){ ans += count[i]*count[j]*count[k]; } } } System.out.println(ans); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int MOD = 998244353; const long long int INF = 1e18; int main() { int n; cin >> n; string s, t = "MARCH"; int d[5] = {}; for (int i = (0); i < (n); i++) { cin >> s; for (int j = (0); j < (5); j++) { if (s[0] == t[j]) d[j]++; } } int pair<long long int, long long int>[10] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2}; int q[10] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3}; int r[10] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4}; long long int ans = 0; for (int i = (0); i < (10); i++) { ans += d[pair<long long int, long long int>[i]] * d[q[i]] * d[r[i]]; } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int INF = (1 << 30) - 1; const int MOD = 1000000007; int dy[] = {0, 0, 1, -1}; int dx[] = {1, -1, 0, 0}; int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } int n, cnt[5]; long long ans; char cc[] = {'M', 'A', 'R', 'C', 'H'}; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n; for (int i = 0; i < (n); i++) { string s; cin >> s; for (int j = 0; j < (5); j++) { if (s[0] == cc[j]) cnt[j]++; } } int p = 0; for (int i = 0; i < (5); i++) { if (cnt[i] == 0) p++; } if (p > 3) { cout << 0 << endl; return 0; } if (p == 0) p = 10; else if (p == 1) p = 4; else p = 1; for (int i = 0; i < (5); i++) { for (int j = i + 1; j < (5); j++) { for (int k = j + 1; k < (5); k++) { ans += cnt[i] * cnt[j] * cnt[k]; } } } printf("%lld\n", ans); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main(void) { int N; int M = 0, A = 0, R = 0, C = 0, H = 0; int result = 0; string *S; cin >> N; S = (string *)malloc(sizeof(string) * N); for (int i = 0; i < N; i++) { cin >> S[i]; if (S[i][0] == 'M') { M++; } else if (S[i][0] == 'A') { A++; } else if (S[i][0] == 'R') { R++; } else if (S[i][0] == 'C') { C++; } else if (S[i][0] == 'H') { H++; } } result = M * A * R + M * A * C + M * A * H + M * R * C + M * R * H + M * C * H + A * R * C + A * R * H + A * C * H + R * C * H; cout << result << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include<iostream> #include<string> #include<cstring> using namespace std; int name[5], n; int main(){ cin >> n; memset(name, 0, sizeof(name)); for(int i=0; i<n; i++){ string s; cin >> s; if(s[0] == 'M') name[0]++; else if(s[1] == 'A') name[1]++; else if(s[2] == 'R') name[2]++; else if(s[3] == 'C') name[3]++; else if(s[4] == 'H') name[4]++; } long long ret = 0; for(int i=0; i<5; i++){ for(int j=i+1; j<5; j++){ for(int k=j+1; k<5; k++){ ret += s[i] * s[j] * s[k]; } } } cout << ret << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; string S[N]; for (int i = 0; i < N; i++) { cin >> S[i]; } int M = 0; int A = 0; int R = 0; int C = 0; int H = 0; for (int i = 0; i < N; i++) { if (S[i][0] == 'M') { M++; } else if (S[i][0] == 'A') { A++; } else if (S[i][0] == 'R') { R++; } else if (S[i][0] == 'C') { C++; } else if (S[i][0] == 'H') { H++; } } int ans = 0; ans += M * A * R; ans += M * A * C; ans += M * A * H; ans += M * R * C; ans += M * R * H; ans += M * C * H; ans += A * R * C; ans += A * R * H; ans += A * C * H; ans += R * C * H; cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.Scanner; public class Main { public static double comb(int n, int r) { double ans = 1; if (n < r) return 0; if (n == r) return 1; for (int i = 1; i <= r; ++i) { ans *= (double) (n - i + 1); ans /= i; } return ans; } public static double comp(String a[], int n) { double count = 0; int count2[], count3 = 0; count2 = new int[5]; if (n < 3) return 0; count = comb(n, 3); for (int i = 0; i < n; ++i) { if (a[i].charAt(0) == 'M') { ++count2[0]; if (count2[0] == 1) ++count3; } if (a[i].charAt(0) == 'A') { ++count2[1]; if (count2[1] == 1) ++count3; } if (a[i].charAt(0) == 'R') { ++count2[2]; if (count2[2] == 1) ++count3; } if (a[i].charAt(0) == 'C') { ++count2[3]; if (count2[3] == 1) ++count3; } if (a[i].charAt(0) == 'H') { ++count2[4]; if (count2[4] == 1) ++count3; } } // System.out.println(count3 + " " + count); for (int i = 0; i < 5; ++i) { if (count2[i] == 2) count -= (double) (count3 - 1); else if (count2[i] > 2) { count -= comb(count2[2], 3); count -= comb(count2[2], 2) * (double) (count3 - 1); } } return count; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n, count = 0; String s[], tmp; n = sc.nextInt(); s = new String[n]; for (int i = 0; i < n; ++i) { tmp = sc.next(); if (tmp.charAt(0) == 'M' || tmp.charAt(0) == 'A' || tmp.charAt(0) == 'R' || tmp.charAt(0) == 'C' || tmp.charAt(0) == 'H') { s[count++] = tmp; } } double ans = comp(s, count); System.out.println((long) ans); sc.close(); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { string s = "MARCH"; int c[5] = {0}; int N; cin >> N; for (int i = 0; i < N; i++) { string t; cin >> t; for (int j = 0; j < 5; j++) { if (t[0] == s[j]) { c[j]++; } } } int ans = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { ans += c[i] * c[j] * c[k]; } } } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); char[] initials = {'M', 'A', 'R', 'C', 'H'}; int n = sc.nextInt(); HashMap<Character, Integer> map = new HashMap<>(); for(int i = 0; i < n; i++) { String name = sc.next(); char initial = name.charAt(0); if(initial == 'M' || initial == 'A' || initial == 'R' || initial == 'C' || initial == 'H') { map.put(initial, map.getOrDefault(initial, 0) + 1); } } long count = 0; for(int i = 0; i < 5; i++) { for(int j = i + 1; j < 5; j++) { for(int k = j + 1; k < 5; k++) { count += (map.getOrDefault(initials[i], 0) * map.getOrDefault(initials[j], 0) * map.getOrDefault(initials[k], 0)); } } } System.out.println(count); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1); const double eps = 1e-6; long long c(long long a, long long b) { int i; long long ans; ans = 1; for (i = a; i > a - b; i--) { ans *= i; } for (i = b; i >= 1; i--) { ans /= i; } return ans; } int main() { ios::sync_with_stdio(false); int n; cin >> n; string s[n + 1]; long long M, A, R, C, H; M = 0; A = 0; R = 0; C = 0; H = 0; int i; for (i = 1; i <= n; i++) { cin >> s[i]; } for (i = 1; i <= n; i++) { if (s[i][0] == 'M') { M++; } if (s[i][0] == 'A') { A++; } if (s[i][0] == 'R') { R++; } if (s[i][0] == 'C') { C++; } if (s[i][0] == 'H') { H++; } } long long ans, x; ans = c(M + A + R + C + H, 3); if (M > 1) { x = 0; for (i = 1; i <= M; i++) { x += i; } ans -= x; } if (A > 1) { x = 0; for (i = 1; i <= A; i++) { x += i; } ans -= x; } if (R > 1) { x = 0; for (i = 1; i <= R; i++) { x += i; } ans -= x; } if (C > 1) { x = 0; for (i = 1; i <= C; i++) { x += i; } ans -= x; } if (H > 1) { x = 0; for (i = 1; i <= H; i++) { x += i; } ans -= x; } if (M == 0 && A == 0 && R == 0 && C == 0 && H == 0) { cout << 0 << endl; return 0; } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.io.*; public class Main{ public static void main(String[] args) { try { long result; int n, i = 0; int num[] = {0, 0, 0, 0, 0}; BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); n = Integer.parseInt(reader.readLine()); String name[] = new String[n]; char nameF[] = new char[n]; for(i = 0; i < n; i++){ name[i] = reader.readLine(); } for(i = 0; i < n; i++){ nameF[i] = name[i].charAt(0); } for(i = 0; i < n; i++){ if (nameF[i] == 'M') { num[0] = ++num[0]; } if (nameF[i] == 'A') { num[1] = ++num[1]; } if (nameF[i] == 'R') { num[2] = ++num[2]; } if (nameF[i] == 'C') { num[3] = ++num[3]; } if (nameF[i] == 'H') { num[4] = ++num[4]; } } result = num[0]*num[1]*(num[2]+num[3]+num[4])+num[0]*num[2]*(num[3]+num[4])+num[0]*num[3]*num[4] +num[1]*num[2]*(num[3]+num[4])+num[1]*num[3]*num[4] + num[2]*num[3]*num[4]; Sustem.out.println(result); } catch (Exception e) { } } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s[n]; int cou[5]; char check[5] = {'M', 'A', 'R', 'C', 'H'}; for (int i = 0; i < 5; i++) { cou[i] = 0; } for (int i = 0; i < n; i++) { cin >> s[i]; for (int j = 0; j < 5; j++) { if (s[i][0] == check[j]) { cou[j]++; } } } long long ans = 0; int used[5][5][5]; for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { for (int k = 0; k < 5; k++) { used[i][j][k] = 0; } } } for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { for (int m = 0; m < 5; m++) { if (j == m || i == m || i == j) { continue; } else { if (used[i][j][m] == 0 || used[i][m][j] == 0 || used[m][i][j] == 0 || used[j][i][m] == 0 || used[m][j][i] == 0 || used[j][m][i] == 0) { ans += cou[i] * cou[j] * cou[m]; used[i][j][m] = 1; used[j][i][m] = 1; used[i][m][j] = 1; used[j][m][i] = 1; used[m][i][j] = 1; used[m][j][i] = 1; } } } } } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main(int argc, const char* argv[]) { int N; vector<long long> march(5, 0); cin >> N; vector<long long> c3 = {0, 0, 0, 1, 4, 10}; string temp; for (int i = 0; i < N; i++) { cin >> temp; switch (temp[0]) { case 'M': march[0] += 1; break; case 'A': march[1] += 1; break; case 'R': march[2] += 1; break; case 'C': march[3] += 1; break; case 'H': march[4] += 1; break; default: break; } } int count = 0; for (int i = 0; i < 5; i++) { if (march[i] > 0) { count += 1; } } if (count < 3) { cout << "0" << endl; } long long ans = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { ans += march[i] * march[j] * march[k]; } } } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int cnt[100010]; int main() { string MARCH = "MARCH"; cin.tie(0); ios::sync_with_stdio(false); int N, maxV = 0; string s[5]; long long c[5] = {0}; cin >> N; for (int i = 0, i_len = (N); i < i_len; ++i) { cin >> s[i]; for (int j = 0, j_len = (MARCH.length()); j < j_len; ++j) { if (s[i][0] == MARCH[j]) { c[j]++; break; } } } long long ans = 0; for (int i = 0, i_len = (5); i < i_len; ++i) { for (int j = i + 1, j_len = (5); j < j_len; ++j) { for (int k = j + 1, k_len = (5); k < k_len; ++k) { ans += c[i] * c[j] * c[k]; } } } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
N=int(input()) M,A,R,C,H=0,0,0,0,0 for i in range(N): s=input()[0] if s=='M': M+=1 elif s=='A': A+=1 elif s=='R': R+=1 elif s=='C': C+=1 elif s=='H': H+=1 print(M,A,R,C,H) print(M*A*R + M*A*C + M*A*H + M*R*C + M*R*H + \ M*C*H + A*R*C + A*R*H + A*C*H + R*C*H)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf("%d", &n); int m = 0; int a = 0; int r = 0; int c = 0; int h = 0; string str; for (int i = 0; i < n; i++) { cin >> str; if (str[0] == 'M') { m++; } if (str[0] == 'A') { a++; } if (str[0] == 'R') { r++; } if (str[0] == 'C') { c++; } if (str[0] == 'H') { h++; } } unsigned long long sum = 0; sum += m * a * r; sum += m * a * c; sum += m * a * h; sum += m * r * c; sum += m * r * h; sum += m * c * h; sum += a * r * c; sum += a * r * h; sum += a * c * h; sum += r * c * h; printf("%llu\n", sum); }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int N; cin >> N; string S; vector<int> count(5); for (int i = 0; i < N; i++) { cin >> S; if (S.at(0) == 'M') count.at(0)++; else if (S.at(0) == 'A') count.at(1)++; else if (S.at(0) == 'R') count.at(2)++; else if (S.at(0) == 'C') count.at(3)++; else if (S.at(0) == 'H') count.at(4)++; } int flag = 0; for (int i = 0; i < 5; i++) if (count.at(i)) flag++; int ans = 0; if (flag < 3) ans = 0; else { for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 4; j++) { for (int k = j + 1; k < 5; k++) { ans += count.at(i) * count.at(j) * count.at(k); } } } } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (a % b == 0) { return b; } else { return (gcd(b, a % b)); } } long long lcm(long long a, long long b) { return a / gcd(a, b) * b; } const int INF = 1e9; const long long MX = 1e18; const long long MOD = INF + 7; const int di[] = {-1, 0, 1, 0}; const int dj[] = {0, -1, 0, 1}; const double PI = acos(-1); const long long MAX = 1000001; long long fac[MAX], finv[MAX], inv[MAX]; void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (long long i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } long long COM(long long n, long long k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } int main() { string s = "MARCH"; int c[5] = {0}; int n; cin >> n; for (long long i = 0; i < (n); i++) { string t; cin >> t; for (long long j = 0; j < (5); j++) { if (t[0] == s[j]) c[j]++; } } int ans = 0; for (long long i = 0; i < (5); i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { ans += c[i] * c[j] * c[k]; } } } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; map<string, int> names; string init = "MARCH"; for (size_t i = 0; i < 5; i++) { names[init.substr(i, 1)] = 0; } for (size_t i = 0; i < N; i++) { string s; cin >> s; if (init.find(s.substr(0, 1)) != string::npos) { names[s.substr(0, 1)]++; } } long long ret = 0; ret += names["M"] * names["A"] * names["R"]; ret += names["M"] * names["A"] * names["C"]; ret += names["M"] * names["A"] * names["H"]; ret += names["M"] * names["R"] * names["C"]; ret += names["M"] * names["R"] * names["H"]; ret += names["A"] * names["R"] * names["C"]; ret += names["A"] * names["R"] * names["H"]; ret += names["A"] * names["C"] * names["H"]; ret += names["R"] * names["C"] * names["H"]; cout << ret << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; int m_san = 0; int a_san = 0; int r_san = 0; int c_san = 0; int h_san = 0; cin >> N; string s; for (int i = 0; i < N; i++) { cin >> s; if (s[0] == 'M') m_san++; if (s[0] == 'A') a_san++; if (s[0] == 'R') r_san++; if (s[0] == 'C') c_san++; if (s[0] == 'H') h_san++; } uint64_t total = 0; total += m_san * a_san * r_san; total += m_san * a_san * c_san; total += m_san * a_san * h_san; total += m_san * c_san * r_san; total += m_san * h_san * r_san; total += m_san * c_san * h_san; total += c_san * a_san * r_san; total += h_san * a_san * r_san; total += c_san * a_san * h_san; total += c_san * r_san * h_san; cout << total << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); input_inner!{iter, $($r)*} }; ($($r:tt)*) => { let mut s = { use std::io::Read; let mut s = String::new(); std::io::stdin().read_to_string(&mut s).unwrap(); s }; let mut iter = s.split_whitespace(); input_inner!{iter, $($r)*} }; } macro_rules! input_inner { ($iter:expr) => {}; ($iter:expr, ) => {}; ($iter:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($iter, $t); input_inner!{$iter $($r)*} }; } macro_rules! read_value { ($iter:expr, ( $($t:tt),* )) => { ( $(read_value!($iter, $t)),* ) }; ($iter:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>() }; ($iter:expr, chars) => { read_value!($iter, String).chars().collect::<Vec<char>>() }; ($iter:expr, usize1) => { read_value!($iter, usize) - 1 }; ($iter:expr, $t:ty) => { $iter.next().unwrap().parse::<$t>().expect("Parse error") }; } fn main() { input! { n: usize, s: [chars; n], } let mut c = std::collections::BTreeMap::new(); for t in s { *c.entry(t[0]).or_insert(0) += 1; } let mut r = 0; for i in 0..5 { for j in i + 1..5 { for k in j + 1..5 { let t: usize = [i, j, k] .iter() .map(|&x| c.get(&"MARCH".chars().nth(x).unwrap()).unwrap_or(&&0)) .product(); r += t; } } } println!("{}", r); }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include <bits/stdc++.h> using namespace std; int main() { int a; cin >> a; string h; if (a == 4) { cout << 0; } for (int i = 0; i < a; i++) { cin >> h; if (h == "CHOKUDAI") { cout << 7; return 0; } else { cout << 2; return 0; } } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; double m, a, r, c, h = 0; for (int i = 0; i < n; i++) { cin >> s; if (s[0] == 'M') m++; if (s[0] == 'A') a++; if (s[0] == 'R') r++; if (s[0] == 'C') c++; if (s[0] == 'H') h++; } double ans = 0; ans = ans + m * a * r; ans = ans + m * a * c; ans = ans + m * a * h; ans = ans + m * r * c; ans = ans + m * r * h; ans = ans + m * c * h; ans = ans + a * r * c; ans = ans + a * c * h; ans = ans + a * r * h; ans = ans + r * c * h; cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; string s[100005]; int a[26]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) cin >> s[i]; for (int i = 0; i < n; i++) a[s[i][0] - 'A']++; long long ans = 1, flag = 0, cnt = 0, c[5]; if (a['M' - 'A']) c[0] = a['M' - 'A'], flag = 1, cnt++; if (a['A' - 'A']) c[1] = a['A' - 'A'], flag = 1, cnt++; if (a['R' - 'A']) c[2] = a['R' - 'A'], flag = 1, cnt++; if (a['C' - 'A']) c[3] = a['C' - 'A'], flag = 1, cnt++; if (a['H' - 'A']) c[4] = a['H' - 'A'], flag = 1, cnt++; if (flag && cnt >= 3) { ans = c[0] * c[1] * c[2]; ans += c[0] * c[3] * c[1]; ans += c[0] * c[1] * c[4]; ans += c[0] * c[3] * c[2]; ans += c[0] * c[4] * c[2]; ans += c[0] * c[4] * c[3]; ans += c[3] * c[1] * c[2]; ans += c[4] * c[1] * c[2]; ans += c[4] * c[3] * c[2]; ans += c[3] * c[1] * c[4]; cout << ans << endl; } else cout << 0 << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
def cmb(n, r): if n - r < r: r = n - r if r == 0: return 1 if r == 1: return n numerator = [n - r + k + 1 for k in range(r)] denominator = [k + 1 for k in range(r)] for p in range(2, r+1): pivot = denominator[p - 1] if pivot > 1: offset = (n - r) % p for k in range(p-1, r, p): numerator[k - offset] /= pivot denominator[k] /= pivot result = 1 for k in range(r): if numerator[k] > 1: result *= int(numerator[k]) return result n = int(input()) s = [str(input()) for i in range(n)] lists = [] for i in s: if i[0] == "M" or i[0] == "A" or i[0] == "R" or i[0] == "C" or i[0] == "H": lists.append(i[0]) if len(set(lists)) == 0: print(0) exit() set_lists = list(set(lists)) ans = cmb(len(lists), 3) print(ans-(len(set_lists) - 1))
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int N; string S; long long ans = 0; int num = 0; long long D[5]; int P[10] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2}; int Q[10] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3}; int R[10] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4}; int main() { int count[5]; cin >> N; for (int i = 0; i < N; i++) { cin >> S; switch (S[0]) { case 'M': count[0]++; break; case 'A': count[1]++; break; case 'R': count[2]++; break; case 'C': count[3]++; break; case 'H': count[4]++; break; } } for (int i = 0; i < N; i++) D[i] = count[i]; for (int d = 0; d < 10; d++) { ans += D[P[d]] * D[Q[d]] * D[R[d]]; } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { long long N; cin >> N; string s; int m = 0, a = 0, r = 0, c = 0, h = 0; int num[5]; int A[10] = {0, 0, 0, 0, 0, 1, 1, 1, 2}, B[10] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3}, C[10] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4}; for (long long i = 0; i < N; ++i) { cin >> s; if (s[0] == 'M') ++m; if (s[0] == 'A') ++a; if (s[0] == 'R') ++r; if (s[0] == 'C') ++c; if (s[0] == 'H') ++h; } num[0] = m, num[1] = a, num[2] = r, num[3] = c, num[4] = h; int ans = 0; for (long long i = 0; i < 10; ++i) ans += num[A[i]] * num[B[i]] * num[C[i]]; cout << ans << endl; cin >> N; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main(int argc, char const *argv[]) { int n; std::cin >> n; std::vector<int> v(5, 0); string march = "MARCH"; for (size_t i = 0; i < n; i++) { string temp; std::cin >> temp; for (size_t im = 0; im < march.size(); im++) { if (temp[0] == march[im]) { v[im]++; } } } int ans = 0; for (size_t i = 0; i < v.size(); i++) { for (size_t j = i + 1; j < v.size(); j++) { for (size_t k = j + 1; k < v.size(); k++) { ans = ans + v[i] * v[j] * v[k]; } } } std::cout << ans << '\n'; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.HashSet; import java.util.Set; import java.util.StringTokenizer; public class Main { public static void main(String[] args) { FastReader sc = new FastReader(); int n = sc.nextInt(); int[] dp = new int[5]; // For counting 'm', 'a', 'r', 'c', 'h'. // Choose three from five, there is total ten patterns. int[] p = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2}; int[] q = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3}; int[] r = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4}; long res = 0; for (int i = 0; i < n; i++) { String s = sc.next(); if (s.charAt(0) == 'M') { dp[0]++; } else if (s.charAt(0) == 'A') { dp[1]++; } else if (s.charAt(0) == 'R') { dp[2]++; } else if (s.charAt(0) == 'C') { dp[3]++; } else if (s.charAt(0) == 'H') { dp[4]++; } } for (int i = 0; i < 10; i++) { res += (dp[p[i]] * dp[q[i]] * dp[r[i]]); } System.out.println(res); } static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try{ str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include <bits/stdc++.h> int Combination(int, int); int main() { int N = 0; int M = 0, A = 0, R = 0, C = 0, H = 0; int Z = 0; int Result = 0; char Input[10]; scanf("%d", &N); for (int i = 0; i < N; i++) { scanf("%s", Input); if (Input[0] == 'M') M++; if (Input[0] == 'A') A++; if (Input[0] == 'R') R++; if (Input[0] == 'C') C++; if (Input[0] == 'H') H++; } if (M > 0) Z++; else M = 1; if (A > 0) Z++; else A = 1; if (R > 0) Z++; else R = 1; if (C > 0) Z++; else C = 1; if (H > 0) Z++; else H = 1; Result = Combination(Z, 3); if (M > 1) Result = Result * M - Combination(Z - 1, 3); if (A > 1) Result = Result * A - Combination(Z - 1, 3) * M; if (R > 1) Result = Result * R - Combination(Z - 1, 3) * M * A; if (C > 1) Result = Result * C - Combination(Z - 1, 3) * M * A * R * H; if (H > 1) Result = Result * H - Combination(Z - 1, 3) * M * A * R * C; printf("%d", Result); return 0; } int Combination(int x, int y) { int a = 1, b = 1; int result = 0; for (int i = 1; i <= x; i++) { a *= i; } for (int i = 1; i <= y; i++) { b *= i; } for (int i = 1; i <= (x - y); i++) { b *= i; } result = a / b; return result; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
from collections import defaultdict N = int(input()) d = defaultdict(int) for _ in range(N): s = input() if s[0] in 'MARCH': d[s[0]] += 1 if d: ans = 1 for c in d.values(): ans *= c else: ans = 0 print(ans)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; int m = 0, a = 0, r = 0, c = 0, h = 0; string name; for (int i = 0; i < N; i++) { cin >> name; if (name.at(0) == 'M') { m++; } else if (name.at(0) == 'A') { a++; } else if (name.at(0) == 'R') { r++; } else if (name.at(0) == 'C') { c++; } else if (name.at(0) == 'H') { h++; } else { continue; } } int sum = m * a * r + m * a * c + m * a * h + m * r * c + m * r * h + m * c * h + a * r * c + a * r * h + a * c * h + r * c * h; cout << sum << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> int main(void) { int n, x[5] = {}, t, a = 0; char name[11]; std::cin >> n; for (int i = 0; i != n; i++) { std::cin >> name; if (name[0] == 'M') x[0]++; if (name[0] == 'A') x[1]++; if (name[0] == 'R') x[2]++; if (name[0] == 'C') x[3]++; if (name[0] == 'H') x[4]++; } for (int i = 0; i != 3; i++) for (int j = i + 1; j != 4; j++) for (int k = j + 1; k != 5; k++) a += x[i] * x[j] * x[k]; std::cout << a << std::endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Scanner; import java.util.Set; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); Map<Character, Set<String>> map = new HashMap<>(); for(int i =0; i < n; i++){ String s = sc.next(); char c = s.charAt(0); if(c == 'M' || c == 'A' || c == 'R' || c == 'C' || c=='H'){ if(!map.containsKey(c)) map.put(c, new HashSet<>()); map.get(c).add(s); } } if(map.keySet().size() < 3){ System.out.println(0); return; } long l = 0; int keySize = map.keySet().size(); List<Character> list = new ArrayList<>(map.keySet()); int x; for(int i =0; i< list.size() -2; i++){ for(int j =i+1; j < list.size()-1; j++){ for(int k = j+1; k < list.size(); k++){ x =1; x *= map.get(list.get(i)).size() * map.get(list.get(j)).size() * map.get(list.get(k)).size(); l +=x; } } } System.out.println(l); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
using System.Linq; using System.Collections.Generic; using System; public class Hello { public static void Main() { // 自分の得意な言語で // Let's チャレンジ!! var n = int.Parse (System.Console.ReadLine ()); var M = 0; var A = 0; var R = 0; var C = 0; var H = 0; var res = 0; for(int i = 0; i < n; i++) { switch (Console.ReadLine ()[0]) { case ('M'): M++; break; case ('A'): A++; break; case ('R'): R++; break; case ('C'): C++; break; case ('H'): H++; break; } } res += M * A * R; res += M * A * C; res += M * A * H; res += M * R * C; res += M * R * H; res += M * C * H; res += A * R * C; res += A * C * H; res += R * C * H; Console.WriteLine (res); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; vector<int> arr; stack<int> st; queue<int> qu; queue<pair<int, int> > qu2; priority_queue<int> pq; static const int NIL = -1; static const int INF = 1000000007; int m, a, r, c, h; int k[5]; int main() { int n; cin >> n; for (int i = 0; i < (int)(n); i++) { string s; cin >> s; if (s[0] == 'M') { m++; k[0]++; } else if (s[0] == 'A') { a++; k[1]++; } else if (s[0] == 'R') { r++; k[2]++; } else if (s[0] == 'C') { c++; k[3]++; } else if (s[0] == 'H') { h++; k[4]++; } } long long ans = 0; for (int i = 0; i <= 2; i++) { for (int j = i + 1; j <= 3; j++) { for (int l = j + 1; l <= 4; l++) { ans += k[i] * k[j] * k[l]; } } } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<string> s(n); vector<int> p(5); for (int i = 0; i < (int)(n); i++) { cin >> s.at(i); if (s.at(i).at(0) == 'M') { p.at(0)++; } if (s.at(i).at(0) == 'A') { p.at(1)++; } if (s.at(i).at(0) == 'R') { p.at(2)++; } if (s.at(i).at(0) == 'C') { p.at(3)++; } if (s.at(i).at(0) == 'H') { p.at(4)++; } } long long ans = 0; int i, j, k; for (i = 0; i < 3; i++) { for (j = i + 1; j < 4; j++) { for (k = j + 1; k < 5; k++) { ans += p.at(i) * p.at(j) * p.at(k); } } } cout << ans; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#![allow(non_snake_case, unused)] use std::cmp::*; use std::collections::*; use std::f64::consts::*; macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes .by_ref() .map(|r|r.unwrap() as char) .skip_while(|c|c.is_whitespace()) .take_while(|c|!c.is_whitespace()) .collect() }; input_inner!{next, $($r)*} }; } macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; } macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; } fn main() { input!{ n: usize, mut s: [chars; n], } let mut res = 0; let mut cnt = vec![0; 5]; let P = vec![0, 0, 0, 0, 0, 0, 1, 1, 1, 2]; let Q = vec![1, 1, 1, 2, 2, 3, 2, 3, 2, 3]; let R = vec![2, 3, 4, 3, 4, 4, 3, 4, 4, 4]; for c in s { let s_ = c[0]; match s_ { 'M' => cnt[0] += 1, 'A' => cnt[1] += 1, 'R' => cnt[2] += 1, 'C' => cnt[3] += 1, 'H' => cnt[4] += 1, _ => continue, } } for i in 0..10 { res += cnt[P[i]] * cnt[Q[i]] * cnt[R[i]]; } println!("{}", res); }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> inline long long read(); using namespace std; int ans[6]; long long out; int main() { int n = read(); string s; for (int i = 1; i <= n; i++) { cin >> s; if (s[0] == 'M') ans[1]++; if (s[0] == 'A') ans[2]++; if (s[0] == 'R') ans[3]++; if (s[0] == 'C') ans[4]++; if (s[0] == 'H') ans[5]++; } for (int i = 1; i < 4; i++) { for (int j = i + 1; j < 5; j++) { for (int q = j + 1; q <= 5; q++) { out += ans[i] * ans[j] * ans[q]; } } } cout << out << endl; } inline long long read() { register long long x = 0, k = 1; char c; c = getchar(); while (c < '0' || c > '9') { if (c == '-') k = -1; c = getchar(); } while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar(); return x * k; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> int main() { int N, s[5] = {0, 0, 0, 0, 0}; std::string name; std::cin >> N; for (int i = 0; i < N; ++i) { std::cin >> name; char a = name[0]; switch (a) { case 'M': s[0]++; break; case 'A': s[1]++; break; case 'R': s[2]++; break; case 'C': s[3]++; break; case 'H': s[4]++; break; } } long long ans = 0; for (int i = 0; i < 5; ++i) { for (int j = i + 1; j < 5; ++j) { for (int k = j + 1; k < 5; ++k) { ans += s[i] * s[j] * s[k]; } } } std::cout << ans << std::endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
fun main(args: Array<String>) { val n = readLine()!!.toInt() val s = (1..n).map { readLine()!!.first() } .plus("MARCH".toList()) .filter { it in "MARCH" }.groupBy { it }.map { it.value.size.toInt() } var ans = 0L for(i in 0..4)for(j in i+1..4)for(k in j+1..4){ ans+=s[i]*s[j]*s[k] } println(ans) }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include <bits/stdc++.h> int main(void) { int N; scanf("%d", &N); char s[N][11]; int i, j, k, c[5] = {0, 0, 0, 0, 0}; for (i = 0; i < N; i++) { scanf("%s", s[i]); if (s[i][0] == 'M') { c[0]++; } else if (s[i][0] == 'A') { c[1]++; } else if (s[i][0] == 'R') { c[2]++; } else if (s[i][0] == 'C') { c[3]++; } else if (s[i][0] == 'H') { c[4]++; } } long long ans = 0; for (i = 0; i < 3; i++) { for (j = i + 1; j < 4; j++) { for (k = j + 1; k < 5; k++) { ans += c[i] * c[j] * c[k]; } } } printf("%lld\n", ans); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int P[10] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2}; int Q[10] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3}; int R[10] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4}; int main() { int n, MARCH[5] = {0}; cin >> n; for (int i = 0; i < n; i++) { string S; cin >> S; if (S[0] == 'M') MARCH[0]++; else if (S[0] == 'A') MARCH[1]++; else if (S[0] == 'R') MARCH[2]++; else if (S[0] == 'C') MARCH[3]++; else if (S[0] == 'H') MARCH[4]++; } long long ans = 0; for (int i = 0; i < 10; i++) { ans += MARCH[P[i]] * MARCH[Q[i]] * MARCH[R[i]]; } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
mod = 10**9 + 7 def cmb(n,r,mod): a=1 b=1 r = min(r,n-r) for i in range(r): a = a*(n-i)%mod b = b*(i+1)%mod return a*pow(b,mod-2,mod)%mod N = int(input()) march = [] for _ in range(N): H =str(input()) if H[0] == 'M' or H[0] == 'A' or H[0] == 'R' or H[0] == 'C' or H[0] == 'H': march.append(H[0]) march = ''.join(march) m = march.count('M') a = march.count('A') r = march.count('R') c = march.count('C') h = march.count('H') l = [m,a,r,c,h] L = [] for i in range(len(l)): if l[i] > 0: L.append(l[i]) if L == []: print(0) else: ans = cmb(len(L),3,mod) for i in range(len(L)): if L[i] > 1: ans = ans*L[i]-(len(L)-3) print(ans)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include<stdio.iostream> int main() { int MASHIKE,RUMOI,OBIRA,HABORO,HOROKANAI,; char s [11]; scanf ("%d %d %d",&MASAKIE,&RUMOI,&HABORO); scanf ("%d %d %d",&MASAKIE,&RUMOI,&HOROKANAI); scanf ("%d",s); printf("%d %s\n" ,2); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; char s[20]; int num[200]; long long sum = 0; int same = 0; long long jiecheng(long long x) { return x * (x - 1) * (x - 2) / 6; } int main() { int n; long long k; scanf("%d", &n); for (int i = 0; i < n; i++) { getchar(); scanf("%s", s); if (s[0] == 'M' || s[0] == 'A' || s[0] == 'R' || s[0] == 'C' || s[0] == 'H') { sum++; } if (num[s[0] - 'A'] != 0) same++; num[s[0] - 'A']++; } if (sum < 3) printf("0\n"); else { k = jiecheng(sum); for (int i = 0; i < 26; i++) { if (num[i] > 1) { k = k - (sum - num[i]) * (num[i] * (num[i] - 1) / 2); } } if (k > 0) printf("%lld\n", k); else printf("0\n"); } return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N, count = 0; cin >> N; int S[5] = {0}; for (int i = 0; i < N; i++) { string name; cin >> name; switch (name.at(0)) { case 'M': S[0]++; break; case 'A': S[1]++; break; case 'R': S[2]++; break; case 'C': S[3]++; break; case 'H': S[4]++; break; } } for (int i = 0; i < 4; i++) for (int j = i + 1; j < 5; j++) { int x = 0, y = 1, z = 2; while (i == x || j == x) x++; while (x >= y || i == y || j == y) y++; while (y >= z || i == z || j == z) z++; count += S[x] * S[y] * S[z]; } cout << count << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using std::cin; using std::cout; using std::endl; template <typename T> void input1DArray(T*& outArray, size_t size) { outArray = new T[size]; for (size_t index = 0; index < size; index++) { cin >> outArray[index]; } } template <typename T> void input2DArray(T**& outArray, size_t xsize, size_t ysize) { outArray = new T*[xsize]; for (size_t index = 0; index < xsize; index++) { outArray[index] = new T[ysize]; cin >> outArray[index]; } } template <typename T> void delete1DArray(T*& array) { delete[] array; } template <typename T> void delete2DArray(T**& array, size_t size) { for (size_t index = 0; index < size; index++) { delete[] array[index]; } delete[] array; } bool isBeginWithMarch(char* s) { char b = s[0]; return (b == 'M' || b == 'A' || b == 'R' || b == 'C' || b == 'H'); } int main() { uint32_t N; cin >> N; char** s; input2DArray(s, N, 10); std::unordered_map<char, int> c; c['M'] = 0; c['A'] = 0; c['R'] = 0; c['C'] = 0; c['H'] = 0; for (size_t index = 0; index < (N); index++) { if (isBeginWithMarch(s[index])) { char begin = s[index][0]; c[begin] += 1; } } uint64_t result = 0; { result += c['M'] * c['A'] * c['R']; result += c['M'] * c['A'] * c['C']; result += c['M'] * c['A'] * c['H']; result += c['M'] * c['R'] * c['C']; result += c['M'] * c['R'] * c['H']; result += c['M'] * c['C'] * c['H']; result += c['A'] * c['R'] * c['C']; result += c['A'] * c['R'] * c['H']; result += c['A'] * c['C'] * c['H']; result += c['R'] * c['C'] * c['H']; } cout << result << endl; delete2DArray(s, N); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include <bits/stdc++.h> int Combination(int, int); int main() { int N = 0; int M = 0, A = 0, R = 0, C = 0, H = 0; int Z = 0; int Result = 0; char Input[10]; scanf("%d", &N); for (int i = 0; i < N; i++) { scanf("%s", Input); if (Input[0] == 'M') M++; if (Input[0] == 'A') A++; if (Input[0] == 'R') R++; if (Input[0] == 'C') C++; if (Input[0] == 'H') H++; } if (M > 0) Z++; if (A > 0) Z++; if (R > 0) Z++; if (C > 0) Z++; if (H > 0) Z++; Result = Combination(Z, 3); if (M > 1) Result = Result * M - Combination(Z - 1, 3); if (A > 1) Result = Result * A - Combination(Z - 1, 3); if (R > 1) Result = Result * R - Combination(Z - 1, 3); if (C > 1) Result = Result * C - Combination(Z - 1, 3); if (H > 1) Result = Result * H - Combination(Z - 1, 3); printf("%d", Result); return 0; } int Combination(int x, int y) { int a = 1, b = 1; int result = 0; for (int i = 1; i <= x; i++) { a *= i; } for (int i = 1; i <= y; i++) { b *= i; } for (int i = 1; i <= (x - y); i++) { b *= i; } result = a / b; return result; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; int cnt[5] = {}; string s = "MARCH"; for (int i = 0; i < N; ++i) { string S; cin >> S; for (int j = 0; j < 5; ++j) { if (S[0] == s[j]) cnt[j]++; } } int64_t ans = 0; for (int i = 0; i < 3; ++i) { for (int j = i + 1; j < 4; ++j) { for (int k = j + 1; k < 5; ++k) { ans += cnt[i] * cnt[j] * cnt[k]; } } } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include<bits/stdc++.h> using namespace std; int main(){ int N; cin>>N; vector<string> s(N); for(int i=0;i<N;i++) cin>>s[i]; long long vari[5] = {}; long long cnt[5] ={}; for(int i=0;i<N;i++){ if(s[i][0]=='M'){ cnt[0]+=1; } if(s[i][0]=='A'){ cnt[1]+=1; } if(s[i][0]=='R'){ cnt[2]+=1; } if(s[i][0]=='C'){ cnt[3]+=1; } if(s[i][0]=='H'){ cnt[4]+=1; } } int R[10]= {0,0,0,0,0,0,1,1,1,2}; int P[10]= {1,1,1,2,2,3,2,2,3,3}; int Q[10]= {2,3,4,3,4,4,3,4,4,4} long long ans =0; for(int i=0;i<10;i++){ ans +=cnt[R[i]]*cnt[P[i]]*cnt[Q[i]]; } cout<<ans<<endl; return 0; for(int i=0;i<5;i++) cout<<cnt[i]<<endl; int cn = accumulate(vari,vari+5,0); long long ans = 1; if(cn<3){ cout<<"0"<<endl; return 0; }else if(cn==3){ for(int i=0;i<N;i++){ if(cnt[i]!=0){ ans *= cnt[i]; } } }else if(cn==4){ ans = 4; for(int i=0;i<N;i++){ if(cnt[i]!=0){ ans *= cnt[i]; } } }else if(cn==5){ ans = 10; for(int i=0;i<N;i++){ if(cnt[i]!=0){ ans *= cnt[i]; } } } cout<<ans<<endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
import math def combi(a, b): ans = math.factorial(a) / (math.factorial(a - b) * math.factorial(b)) return ans N = int(input()) S = [0] * 5 for i in range(N): s = input() temp = s[0] if temp == "M": S[0] += 1 elif temp == "A": S[1] += 1 elif temp == "R": S[2] += 1 elif temp == "C": S[3] += 1 elif temp == "H": S[4] += 1 c = 0 N = 0 for i in range(5): N += S[i] if S[i] != 0: c += 1 if c <= 2: print(0) else: ans = 0 for i in range(2): for j in range(i + 1, 4): for k in range(j + 1, 5): ans += S[i] * S[j] * S[k] print(ans)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int num[26] = {0}; long long c = 0; char pr[5] = {'A', 'C', 'H', 'M', 'R'}; string s; int n; cin >> n; for (int i = 0; i < n; i++) { cin >> s; num[s[0] - 'A']++; } for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 4; j++) { for (int k = j + 1; k < 5; k++) { c += num[pr[i] - 'A'] * num[pr[j] - 'A'] * num[pr[k] - 'A']; } } } cout << c; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
# coding: utf-8 # Your code here! import sys import math from collections import Counter def P(n, r): return math.factorial(n)//math.factorial(n-r) def C(n, r): return P(n, r)//math.factorial(r) N = int(sys.stdin.readline().strip()) arr = [sys.stdin.readline().strip() for i in range(N)] mar_arr = [j for j in arr if j[0] == "M" or j[0] == "A" or j[0] == "R" or j[0] == "C" or j[0] == "H"] ini_arr = [k[0] for k in mar_arr] dic = Counter(ini_arr) key_num = len(dic) val_num = sum(v for v in dic.values()) if key_num < 3: print(0) else: total = C(len(ini_arr), 3) for i in dic.values(): if i == 2: total -= C(val_num - i, 1) elif i >= 3: total -= C(i, 2) * C(val_num - i, 1) + C(i, 3) print(total)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
extern crate itertools; use itertools::Itertools; use std::io::*; use std::str::FromStr; fn read<T: FromStr>() -> T { let stdin = stdin(); let stdin = stdin.lock(); let token: String = stdin .bytes() .map(|c| c.expect("filed to read char") as char) .skip_while(|c| c.is_whitespace()) .take_while(|c| !c.is_whitespace()) .collect(); token.parse().ok().expect("failed to parse token") } fn main() { let n:usize = read(); let mut arr = vec![0; 5]; for _ in 0..n { let s:String = read(); match &s[0..1] { "M" => arr[0] += 1, "A" => arr[1] += 1, "R" => arr[2] += 1, "C" => arr[3] += 1, "H" => arr[4] += 1, _ => continue } } let mut ans = 0; arr.into_iter().combinations(3).for_each(|x| { ans += x[0] * x[1] * x[2]; }); println!("{}", ans); }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; template <typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <typename T> inline bool chmin(T &a, T b) { if (b < a) { a = b; return true; } return false; } template <typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); } template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); } template <typename T> T vdebug(vector<T> v) { for (auto vv : v) { cout << vv << " "; } cout << endl; } template <typename T> T adebug(T arr[], int n) { for (int i = 0; i < n; i++) { cout << arr[i] << " "; } cout << endl; } void ans(bool b) { if (b) cout << "Yes" << endl; else cout << "No" << endl; } void ans2(bool b) { if (b) cout << "YES" << endl; else cout << "NO" << endl; } int keta(ll num) { int k = 0; while (num > 0) { num /= 10; k++; } return k; } int dx[] = {1, -1, 0, 0, 1, -1, 1, -1}; int dy[] = {0, 0, 1, -1, 1, -1, -1, 1}; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; int cnt[5]; string s; for (int i = 0; i < 5; i++) { cnt[i] = 0; } cin >> n; for (int i = 0; i < n; i++) { cin >> s; if (s[0] == 'M') cnt[0]++; if (s[0] == 'A') cnt[1]++; if (s[0] == 'R') cnt[2]++; if (s[0] == 'C') cnt[3]++; if (s[0] == 'H') cnt[4]++; } vector<int> flg; for (int i = 0; i < 5; i++) { if (cnt[i] > 0) { flg.push_back(i); } } if (flg.size() < 3) { cout << 0 << endl; return 0; } ll res = 0; for (int i = 0; i < flg.size() - 2; i++) { for (int j = i + 1; j < flg.size() - 1; j++) { for (int k = j + 1; k < flg.size(); k++) { res += cnt[flg[i]] * cnt[flg[j]] * cnt[flg[k]]; } } } cout << res << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { string s = "MARCH"; int c[5] = {}; int n; cin >> n; for (int i = 0; i < n; i++) { string t; cin >> t; for (int j = 0; j < 5; j++) { if (s[j] == t[0]) c[j]++; } } long long ans = 0; for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 4; j++) { for (int k = j + 1; k < 5; k++) { ans += c[i] * c[j] * c[k]; } } } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } const long long INF = 1LL << 60; int MOD = 1000000007; int main() { std::ios_base::sync_with_stdio(false); int n; cin >> n; long long cnt[5]; for (int i = 0; i < 5; i++) cnt[i] = 0LL; for (int i = 0; i < n; i++) { string s; cin >> s; if (s[0] == 'M') cnt[0]++; else if (s[0] == 'A') cnt[1]++; else if (s[0] == 'R') cnt[2]++; else if (s[0] == 'C') cnt[3]++; else if (s[0] == 'H') cnt[4]++; } long long ans = 0LL; for (int i = 0; i < 5; i++) for (int j = i + 1; j < n; ++j) for (int k = j + 1; k < n; ++k) { ans += cnt[i] * cnt[j] * cnt[k]; } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { string m = "MARCH"; int n; cin >> n; vector<string> s(n); vector<int> x(5, 0); for (int i = 0; i < (n); ++i) { cin >> s[i]; for (int j = 0; j < (5); ++j) { if (s[i][0] == m[j]) x[j]++; } } ll ans = 0; for (int i = 0; i < 5; ++i) { for (int j = i + 1; j < 5; ++j) { for (int k = j + 1; k < 5; ++k) { ans += x[i] * x[j] * x[k]; } } } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const long long int INF = 1e18; const long long int mod = 1e9 + 7; struct Edge { long long int to, weight; Edge(long long int t, long long int w) : to(t), weight(w) {} }; using graph = vector<vector<long long int>>; using Graph = vector<vector<Edge>>; long long int gcd(long long int a, long long int b) { if (b == 0) { return a; } else { return gcd(b, a % b); } } long long int lcm(long long int a, long long int b) { return a / gcd(a, b) * b; } long long int keta(long long int N) { int tmp{}; while (N > 0) { tmp += (N % 10); N /= 10; } N = tmp; return N; } bool kai(string S) { bool flag = true; for (long long int i = 0; i < S.size() / 2; ++i) { if (S[i] != S[S.size() - i - 1]) { flag = false; break; } } return flag; } int main() { long long int n; cin >> n; long long int m = 0, a = 0, r = 0, c = 0, h = 0; for (long long int i = 0; i < n; ++i) { string s; cin >> s; char t = s[0]; if (t == 'M') { m++; } else if (t == 'A') { a++; } else if (t == 'R') { r++; } else if (t == 'C') { c++; } else if (t == 'H') { h++; } } long long int ans = 0; ans += m * a * r; ans += m * a * c; ans += m * a * h; ans += m * r * c; ans += m * r * h; ans += r * c * h; ans += a * r * c; ans += a * r + h; ans += a * c * h; ans += r * c * h; cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> int main(void) { char s[10001][11]; int n, i, m, a, r, c, h; long long int z; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%s", &s[i]); if (s[i][0] == 'M') m = m + 1; if (s[i][0] == 'A') a = a + 1; if (s[i][0] == 'R') r = r + 1; if (s[i][0] == 'C') c = c + 1; if (s[i][0] == 'H') h = h + 1; } z = m * a * r + m * a * c + m * a * h + m * r * c + m * r * h + m * c * h + a * r * c + a * r * h + a * c * h + r * c * h; printf("%lld\n", z); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> template <typename T> inline T max(T a, T b, T c) { return max(a, max(b, c)); } template <typename T> inline T min(T a, T b, T c) { return min(a, min(b, c)); } template <typename T> inline T max(T a, T b, T c, T d) { return max(a, max(b, c, d)); } template <typename T> inline T min(T a, T b, T c, T d) { return min(a, min(b, c, d)); } const int dx[] = {0, 1, 0, -1, 0, 1, -1, 1, -1}; const int dy[] = {0, 0, 1, 0, -1, 1, -1, -1, 1}; using namespace std; char s[10]; int a[100010]; int main() { ios::sync_with_stdio(false); int n; cin >> n; int sum = 0; memset(a, 0, sizeof(a)); while (n--) { cin >> s; if (s[0] == 'M') a[0]++; else if (s[0] == 'A') a[1]++; else if (s[0] == 'R') a[2]++; else if (s[0] == 'C') a[3]++; else if (s[0] == 'H') a[4]++; } for (int i = 0; i < 5; i++) for (int j = i + 1; j < 5; j++) for (int k = j + 1; k < 5; k++) sum += a[i] * a[j] * a[k]; cout << sum << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include <bits/stdc++.h> int compare_int(const void *a, const void *b) { return *(int *)a - *(int *)b; } void sort_char(char *C, int string_long) { int i; int num[string_long]; for (i = 0; i < string_long; i++) { num[i] = (int)C[i]; } qsort(num, string_long, sizeof(int), compare_int); for (i = 0; i < string_long; i++) { C[i] = (char)num[i]; } } void change_int(int *a, int *b) { int c = *a; *a = *b; *b = c; } void change_char(char *s, char *t) { char u = *s; *s = *t; *t = u; } int diff_abso_value(int a, int b) { if (a >= b) return a - b; else return b - a; } int main() { int n; char s[10]; int mozi[5] = {}; int ans = 1; int poyo = 0; int zenbu = 0; int i, j, k; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%s", s); if (s[0] == 'M') mozi[0]++; else if (s[0] == 'A') mozi[1]++; else if (s[0] == 'R') mozi[2]++; else if (s[0] == 'C') mozi[3]++; else if (s[0] == 'H') mozi[4]++; } for (int i = 0; i < 5; i++) { if (mozi[i] == 0) poyo++; if (poyo >= 3) { printf("0\n"); return 0; } } for (i = 0; i < 3; i++) { for (j = i + 1; j < 4; j++) { for (k = j + 1; k < 5; k++) { ans = mozi[i] * mozi[j] * mozi[k]; zenbu += ans; } } } printf("%d\n", zenbu); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
n = int(input()) s = [] m = 0 a = 0 r = 0 c = 0 h = 0 cnt = 0 for i in range(s): a = input() if a[0] == "M": m += 1 if a[0] == "A": a += 1 if a[0] == "R": r += 1 if a[0] == "C": c += 1 if a[0] == "H": h += 1 if m > 0: cnt += 1 if a > 0: cnt += 1 if r > 0: cnt += 1 if c > 0: cnt += 1 if h > 0: cnt += 1 if cnt < 3: print(0) else: print(m*a*r + m*a*c + m*a*h + m*r*c + m*r*h + m*c*h + a*r*h + a*c*h + r*c*h)