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; int main(void) { int n; cin >> n; int m = 0; int a = 0; int r = 0; int c = 0; int h = 0; string s; for (int i = 0; i < n; i++) { cin >> s; if (s.at(0) == 'M') { m++; } else if (s.at(0) == 'A') { a++; } else if (s.at(0) == 'R') { r++; } else if (s.at(0) == 'C') { c++; } else if (s.at(0) == 'H') { h++; } } std::deque<int> deq{m, a, r, c, h}; std::deque<int> num{0, 1, 2, 3, 4}; long long int count = 0; for (int j = 0; j < 3; j++) { for (int k = j + 1; k < 5; k++) { for (int l = k + 1; l < 5; l++) { if (deq[num[j]] != 0 && deq[num[k]] != 0 && deq[num[l]] != 0) { count += deq[num[j]] * deq[num[k]] * deq[num[l]]; } } } } cout << count << 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; char a[100010][100]; int n; long long an, b, c, d, e; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i][0] == 'M' && a[i][1] != 'M') an++; if (a[i][0] == 'A' && a[i][1] != 'A') b++; if (a[i][0] == 'R' && a[i][1] != 'R') c++; if (a[i][0] == 'C' && a[i][1] != 'C') d++; if (a[i][0] == 'H' && a[i][1] != 'H') e++; } long long a1, b1, c1; a1 = an * b * c + an * b * d + an * b * e + an * c * d + an * c * e + an * d * e; b1 = b * c * d + b * c * e + b * d * e; c1 = c * d * e; cout << a1 + b1 + c1 << endl; system("pause"); 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 itertools N = int(input()) s = "MARCH" lst = [] for i in range(N): begin = input()[0] if begin in list(s): lst.append(begin) ans = 0 for i in list(itertools.combinations(lst,3)): if (len(set(i)) == 3): ans += 1 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; vector<int> d(5, 0); for (int i = 0; i < n; i++) { string s; cin >> s; if (s[0] == 'M') d[0]++; if (s[0] == 'A') d[1]++; if (s[0] == 'R') d[2]++; if (s[0] == 'C') d[3]++; if (s[0] == 'H') d[4]++; } long long ans = 0; ans += d[0] * d[1] * d[2]; ans += d[0] * d[1] * d[3]; ans += d[0] * d[1] * d[4]; ans += d[0] * d[2] * d[3]; ans += d[0] * d[2] * d[4]; ans += d[0] * d[3] * d[4]; ans += d[1] * d[2] * d[3]; ans += d[1] * d[2] * d[4]; ans += d[1] * d[3] * d[4]; ans += d[2] * d[3] * d[4]; 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() { long n, a[5]={0,0,0,0,0}, r = 0, adb; scanf("%ld", &n); for (int i = 0; i < n; i++) { char s[5]; scanf("%s", 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 z = 0; z < 3; z++) { for ( int c = z+1; c < 4; c++){ for ( int v = c+1; v < 5; v++){ a[z]*a[c]*a[v] = adb;}}} cout<<adb<<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() { unsigned long long n; string s; cin >> n; unsigned long long m = 0; unsigned long long a = 0; unsigned long long r = 0; unsigned long long c = 0; unsigned long long h = 0; for (unsigned long long i = 0; i < n; i++) { cin >> s; switch ((long long)s.c_str()[0]) { case 'M': m++; break; case 'A': a++; break; case 'R': r++; break; case 'C': c++; break; case 'H': h++; break; } } unsigned long long all = m + a + r + c + h; unsigned long long cond = all * (all - 1) * (all - 2) / 6; unsigned long long hoge = 0; if (m > 1) hoge += (m * (m - 1) / 2) * (all - m) + m * (m - 1) * (m - 2); if (a != 0) hoge += (a * (a - 1) / 2) * (all - a) + a * (a - 1) * (a - 2); if (r != 0) hoge += (r * (r - 1) / 2) * (all - r) + r * (r - 1) * (r - 2); if (c != 0) hoge += (c * (c - 1) / 2) * (all - c) + c * (c - 1) * (c - 2); if (h != 0) hoge += (h * (h - 1) / 2) * (all - h) + h * (h - 1) * (h - 2); if (all < 3) { cout << 0 << endl; } else { cout << cond - hoge << 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 maxn = 1e6 + 100; string s[maxn]; bool mark[maxn]; int main() { int n; cin >> n; int c = 0; for (int i = 0; i < n; i++) { cin >> s[i]; string ty = s[i]; char t = ty[0]; if (mark[t]) c++; if (t != 'M' and t != 'A' and t != 'R' and t != 'C' and t != 'H') c++; } if (n - c > c) cout << n + c; else cout << n - c; 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); map<char, int> m; int i; for (i = 0; i < (int)(n); i++) { cin >> s[i]; m[s[i][0]]++; } long long sum = 0; vector<int> b(5, 0); vector<char> cc = {'M', 'A', 'R', 'C', 'H'}; int d = 0; for (b[0] = 0; b[0] < (int)(2); b[0]++) { if (b[0] == 1 && m['M'] == 0) continue; for (b[1] = 0; b[1] < (int)(2); b[1]++) { if (b[1] == 1 && m['A'] == 0) continue; for (b[2] = 0; b[2] < (int)(2); b[2]++) { if (b[2] == 1 && m['R'] == 0) continue; for (b[3] = 0; b[3] < (int)(2); b[3]++) { if (b[3] == 1 && m['C'] == 0) continue; for (b[4] = 0; b[4] < (int)(2); b[4]++) { if (b[4] == 1 && m['H'] == 0) continue; int ssum = 0; int aaa; for (aaa = 0; aaa < (int)(5); aaa++) ssum += b[aaa]; if (ssum == 3) { int tmp = 1; int bbb; for (bbb = 0; bbb < (int)(5); bbb++) if (b[bbb] != 0 && m[cc[bbb]] != 0) tmp *= b[bbb] * m[cc[bbb]]; sum += tmp; } } } } } } 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
cpp
#include <bits/stdc++.h> using ll = long long; using namespace std; template <typename T> using vec = std::vector<T>; int main() { int N; cin >> N; map<char, ll> mp; for (ll i = 0; i < (N); i++) { string s; cin >> s; ++mp[s[0]]; } ll ans = 0; ans += mp['M'] * mp['A'] * mp['R']; ans += mp['M'] * mp['A'] * mp['C']; ans += mp['M'] * mp['A'] * mp['H']; ans += mp['M'] * mp['R'] * mp['C']; ans += mp['M'] * mp['R'] * mp['H']; ans += mp['A'] * mp['R'] * mp['C']; ans += mp['A'] * mp['R'] * mp['H']; ans += mp['A'] * mp['C'] * mp['H']; ans += mp['R'] * mp['C'] * mp['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
#include <bits/stdc++.h> int main(void) { int n; int m = 0; int a = 0; int r = 0; int c = 0; int h = 0; long long ans = 0; char s[100001][11]; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%s", s[i]); switch (s[i][0]) { case 'M': m++; break; case 'A': a++; break; case 'R': r++; break; case 'C': c++; break; case 'H': h++; break; } } 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)); printf("%lld", 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
python3
import itertools n=int(input()) 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", list(input() for _ in range(n))))) if len(s) == 0: print(0) quit() print(len(list(filter(lambda x: len(set(x))==3, 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 "stdafx.h" #include<iostream> #include<string> #include<algorithm> #include<vector> #include<cmath> #include<stack> #include<map> #include<queue> using namespace std; bool b[8]; int main() { int n; cin >> n; long long m = 0, a = 0, r = 0, c = 0, h = 0; for (int i = 0; i < n; i++) { string s; 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++; } cout << 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; getchar(); getchar(); 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 main() { int n; long long int ans; scanf("%d", &n); int i; long long int m = 0, a = 0, r = 0, c = 0, h = 0; char s[n + 1][12]; for (i = 0; i <= n; i++) gets(s[i]); for (i = 0; i <= n; i++) { switch (s[i][0]) { case 'M': m++; break; case 'A': a++; break; case 'R': r++; break; case 'C': c++; break; case 'H': h++; break; } } 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; printf("%d", 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 n; string s[100000]; long long int matching_num = 0; int num[5]; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> s[i]; } for (int i = 0; i < n; i++) { num[i] = 0; } for (int i = 0; i < n; i++) { if (s[i][0] == 'M') { num[0] += 1; } else if (s[i][0] == 'A') { num[1] += 1; } else if (s[i][0] == 'R') { num[2] += 1; } else if (s[i][0] == 'C') { num[3] += 1; } else if (s[i][0] == 'H') { num[4] += 1; } } for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { matching_num += num[i] * num[j] * num[k]; } } } cout << matching_num << 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 void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] b = {0, 0, 0, 0, 0}; for(int i = 0; i < n; i++) { String str = sc.next(); switch(str.charAt(0)) { case 'M': b[0]++; break; case 'A': b[1]++; break; case 'R': b[2]++; break; case 'C': b[3]++; break; case 'H': b[4]++; break; } } long a = 0; for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 4; j++) { for (int k = j + 1; k < 5; k++) { a += b[i] * b[j] * b[k]; } } } System.out.println(a); } }
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; namespace ConsoleApp1 { class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); string[] Sn = new string[N]; for (int i = 0; i < N; i++) { Sn[i] = Console.ReadLine(); } int number = 0; foreach (string name in Sn) { if (name.Substring(0,1) == "M") { } } Console.WriteLine(Sn); Console.ReadLine(); } } }
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; for(int i=0;i<N;i++){ string name; 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> using namespace std; map<char, int> q; int main() { int n; scanf("%d", &n); char str[16]; for (int i = 0; i < n; i++) { scanf("%s", str); q[str[0]]++; } long long int sum = 0; sum += q['M'] * q['A'] * (q['R'] + q['C'] + q['H']) + q['A'] * q['R'] * (q['C'] + q['H']) + q['R'] * q['C'] * q['H'] + q['M'] * q['R'] * (q['C'] + q['H']) + q['M'] * q['C'] * q['H'] + q['A'] * q['C'] * q['H']; printf("%lld", 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; long long fn(int mh, int nm) { if (nm < 2) { return 0; } int sa = mh - nm; long long rt = sa; if (nm == 2) { return rt; } return rt + nm * (nm - 1) * (nm - 2) / 6; } int main() { int n; cin >> n; int m = 0, a = 0, r = 0, c = 0, h = 0; for (int i = 0; i < n; i++) { string s; cin >> s; char s1 = s.at(0); if (s1 == 'M') { m++; } else if (s1 == 'A') { a++; } else if (s1 == 'R') { r++; } else if (s1 == 'C') { c++; } else if (s1 == 'H') { h++; } } long long ans = 0; int mh = m + a + r + c + h; long long cm = mh * (mh - 1) * (mh - 2) / 6; ans = cm - fn(mh, m) - fn(mh, a) - fn(mh, r) - fn(mh, c) - fn(mh, h); if (ans < 0) { ans = 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
cpp
#include <iostream> #include <string> #include <vector> int main(void) { int N; std::cin >> N; std::vector<std::string> S; for(int i=0;i<N;i++) { std::string a; std::cin >> a; S.push_buck(a); } int m=0,a=0,r=0,c=0,h=0; for(int i=0;i<N;i++) { if(S[i][0] == 'M'){ m = 0; } else if(S[i][0] == 'A'){ a = 0; } else if(S[i][0] == 'R'){ r = 0; } else if(S[i][0] == 'C'){ c = 0; } else if(S[i][0] == 'H'){ h = 0; } } int x; x = m + a + r + c + h; if(x >=3){ std::cout << (x*(x-1)*(x-2)/6 << 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
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N, i, M, A, R, C, H, variety, combo, ans; string Name; M = 0; A = 0; R = 0; C = 0; H = 0; variety = 0; cin >> N; for (i = 0; i < N; i++) { cin >> Name; if (Name[0] == 'M') { M++; } else if (Name[0] == 'A') { A++; } else if (Name[0] == 'R') { R++; } else if (Name[0] == 'C') { C++; } else if (Name[0] == 'H') { H++; } } if (M > 0) { variety++; } if (A > 0) { variety++; } if (R > 0) { variety++; } if (C > 0) { variety++; } if (H > 0) { variety++; } if (variety < 3) { combo = 0; } if (variety == 3) { combo = 1; } if (variety == 4) { combo == 3; } if (variety == 5) { combo == 9; } if (M == 0) { M == 1; } if (A == 0) { A == 1; } if (R == 0) { R == 1; } if (C == 0) { C == 1; } if (H == 0) { H == 1; } ans = M * A * R * C * H * combo; 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; using ll = long long; int main() { int n; cin >> n; vector<string> s(n); for (int i = 0; i < (n); i++) cin >> s[i]; string t = "MARCH"; vector<int> cnt(5); for (int i = 0; i < (n); i++) { for (int j = 0; j < (5); j++) { if (t[j] == s[i][0]) cnt[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 += 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
python3
from scipy.special import comb def cmb(n,r): return comb(n, r) n = int(input()) ss = [input() for _ in range(n)] march = ['M','A','R','C','H'] d = dict(zip(march, [0]*5)) nn = 0 for s in ss: if s[0] in march: d[s[0]] += 1 nn += 1 ans = comb(nn, 3) for i in d.values(): if i >= 2: if i > 3: ans -= comb(i, 3) ans -= comb(i,2)*(nn-i) print(int(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; vector<int> vc(5, 0); string march = "MARCH"; for (int i = 0; i < (n); i++) { string s; cin >> s; if (s[0] == 'M') vc[0]++; else if (s[0] == 'A') vc[1]++; else if (s[0] == 'R') vc[2]++; else if (s[0] == 'C') vc[3]++; else if (s[0] == 'H') vc[4]++; } unsigned long long 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 += vc[i] * vc[j] * vc[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> int main(void) { int N; scanf("%d", &N); char S[N][10]; int sum[5] = {}; for (int i = 0; i < N; i++) { scanf("%s", S[i]); if (S[i][0] == 'M') { sum[0]++; } if (S[i][0] == 'A') { sum[1]++; } if (S[i][0] == 'R') { sum[2]++; } if (S[i][0] == 'C') { sum[3]++; } if (S[i][0] == 'H') { sum[4]++; } } int x = sum[0] + sum[1] + sum[2] + sum[3] + sum[4]; long long int y[5]; for (int i = 0; i < 5; i++) { y[i] = sum[i] * (sum[i] - 1) * (x - sum[i]) / 2; } long long int z[5]; for (int i = 0; i < 5; i++) { z[i] = sum[i] * (sum[i] - 1) * (sum[i] - 2) / 6; } long long int ans = x * (x - 1) * (x - 2) / 6 - y[0] - y[1] - y[2] - y[3] - y[4] - z[0] - z[1] - z[2] - z[3] - z[4]; printf("%lld", 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() { int n, ans = 0; string s; int a[10] = {0, 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}; int d[5] = {0}; cin >> n; for (int i = 0; i < n; i++) { cin >> s; if (s[0] == 'M') { d[0]++; } if (s[0] == 'A') { d[1]++; } if (s[0] == 'R') { d[2]++; } if (s[0] == 'C') { d[3]++; } if (s[0] == 'H') { d[4]++; } } for (int i = 0; i < 10; i++) { ans += d[a[i]] * d[b[i]] * d[c[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<iostream> #include<string> #include<vector> #include<utility> #include<algorithm> #include<map> #include<cstdlib> #include<cmath> #include<numeric> #include<iomanip> #include<functional> #define rep(i,n)for(int i=0;i<(n);i++) using namespace std; using ll =long long; //const int mod = 1000000007; //class mint { // long long x; //public: // mint(long long x = 0) : x((x% mod + mod) % mod) {} // mint operator-() const { // return mint(-x); // } // mint& operator+=(const mint & a) { // if ((x += a.x) >= mod) x -= mod; // return *this; // } // mint & operator-=(const mint & a) { // if ((x += mod - a.x) >= mod) x -= mod; // return *this; // } // mint & operator*=(const mint & a) { // (x *= a.x) %= mod; // return *this; // } // mint operator+(const mint & a) const { // mint res(*this); // return res += a; // } // mint operator-(const mint & a) const { // mint res(*this); // return res -= a; // } // mint operator*(const mint & a) const { // mint res(*this); // return res *= a; // } // mint pow(ll t) const { // if (!t) return 1; // mint a = pow(t >> 1); // a *= a; // if (t & 1) a *= *this; // return a; // } // // for prime mod // mint inv() const { // return pow(mod - 2); // } // mint& operator/=(const mint & a) { // return (*this) *= a.inv(); // } // mint operator/(const mint & a) const { // mint res(*this); // return res /= a; // } // // friend ostream& operator<<(ostream & os, const mint & m) { // os << m.x; // return os; // } //}; char num[5]{ 'm','a','r','c','h' }; void recursive_comb(int* indexes, int s, int rest, std::function<void(int*)> f) { if (rest == 0) { f(indexes); } else { if (s < 0) return; recursive_comb(indexes, s - 1, rest, f); indexes[rest - 1] = s; recursive_comb(indexes, s - 1, rest - 1, f); } } // nCkの組み合わせに対して処理を実行する void foreach_comb(int n, int k, std::function<void(int*)> f) { int indexes[k]; recursive_comb(indexes, n - 1, k, f); } int main() { int N; vector<string>s; rep(i, N)cin >> s[i]; map<char, int>a; rep(i, N) { a[s[i][0]]++; } ll ans=0; foreach_comb(5, 3, [](int* indexes) { ans += a[num[indexes[0]]] * a[num[indexes[1]]] * a[num[indexes[2]]]; }); }
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.Scanner; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); // 人数を取得 Integer 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>(); for(int i = 0; i < n ; i++){ String name = sc.next(); if("M".equals(name.substring(0,1))){ m.add(name); }else if("A".equals(name.substring(0,1))){ a.add(name); }else if("R".equals(name.substring(0,1))){ r.add(name); }else if("C".equals(name.substring(0,1))){ c.add(name); }else if("H".equals(name.substring(0,1))){ h.add(name); } } // それぞれの文字から始まる名前の数を集計 Integer mNum = m.size(); Integer aNum = a.size(); Integer rNum = r.size(); Integer cNum = c.size(); Integer hNum = h.size(); ArrayList<Integer> valid = new ArrayList<Integer>(); if(mNum != 0){ valid.add(mNum); } if(aNum != 0){ valid.add(aNum); } if(rNum != 0){ valid.add(rNum); } if(cNum != 0){ valid.add(cNum); } if(hNum != 0){ valid.add(hNum); } // 組み合わせ総数を計算(valid.size()<3の場合は組み合わせが1つも成立しないので更新なし) Integer pair = 0; if(3 == valid.size()){ Integer allMulti = 1; for(int i = 0 ; i < valid.size() ; i++){ allMulti = allMulti * valid.get(i); } pair = allMulti; }else if(4 == valid.size() || 5 == valid.size()){ Integer allMulti = 1; for(int i = 0; i < valid.size(); i++){ allMulti = allMulti * valid.get(i); } for(int i = 0; i < valid.size(); i++){ Integer tmp = allMulti/valid.get(i); pair = pair + tmp; } } System.out.println(pair); } }
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() { vector<int> a(5); int n; string t; cin >> n; for (int i = 0; i < n; i++) { cin >> t; if (t[0] == 'M') a[0]++; else if (t[0] == 'A') a[1]++; else if (t[0] == 'R') a[2]++; else if (t[0] == 'C') a[3]++; else if (t[0] == 'H') a[4]++; } long count; count = a[0] * a[1] * a[2] + a[0] * a[1] * a[3] + a[0] * a[1] * a[4] + a[0] * a[2] * a[3] + a[0] * a[2] * a[4] + a[0] * a[3] * a[4] + a[1] * a[2] * a[3] + a[1] * a[2] * a[4] + a[1] * a[3] * a[4] + a[2] * a[3] * a[4]; cout << count << 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[n]; int cnt[5] = {}; for (int i = 0; i < n; i++) { cin >> s[i]; if (s[i][0] == 'M') cnt[0]++; else if (s[i][0] == 'A') cnt[1]++; else if (s[i][0] == 'R') cnt[2]++; else if (s[i][0] == 'C') cnt[3]++; else if (s[i][0] == 'H') cnt[4]++; } long long ans = 0; for (int i = 0; i <= 4; i++) { for (int j = i + 1; j <= 4; j++) { for (int k = j + 1; k <= 4; 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
python3
n=int(input()) s={"M":0,"A":0,"R":0,"C":0,"H":0} for i in range(n): v=input() if v[0] in s: s[v[0]]+=1 sum=0 for a in s.keys(): for b in s.keys(): for c in s.keys(): if a==b or a==c or b==c: continue sum+=s[a]*s[b]*s[c] print(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
python3
n=int(input()) m=[0,0,0,0,0] for i in range(n): s=input() if s[0]=="M": m[0]+=1 elif s[0]=="A": m[1]+=1 elif s[0]=="R": m[2]+=1 elif s[0]=="C": m[3]+=1 elif s[0]=="H": m[4]+=1 m="".join(map(str,m)) m=m.replace("0","") if len(m)==0: print(0) quit() p=len(m) ans=1 for i in range(3): ans*=p-i ans=ans//6 for i in range(len(m)): if m[i]!=1: ans+=(len(m)-1)*(int(m[i])-1) 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 fok(int n) { if (n == 0) return 1; if (n == 1) return 1; if (n == 2) return 2; if (n > 2) return fok(n - 1) * n; } int ent(int n, int k) { if (k == 0) return 1; if (k > n || k < 0) return 0; else return fok(n) / (fok(k) * fok(n - k)); } int main() { int n, ans1 = 0, ans2 = 0, ans3 = 0, ans4 = 0, ans5 = 0, ans6 = 0, doogh = 0; cin >> n; string s[n]; for (int i = 0; i < n; i++) { cin >> s[i]; } for (int i = 0; i < n; i++) { if (s[i][0] == 'M') ans1++; if (s[i][0] == 'A') ans2++; if (s[i][0] == 'R') ans3++; if (s[i][0] == 'C') ans4++; if (s[i][0] == 'H') ans5++; } if (ans1 != 0) ans6 = ans6 + 1; if (ans2 != 0) ans6 = ans6 + 1; if (ans3 != 0) ans6 = ans6 + 1; if (ans4 != 0) ans6 = ans6 + 1; if (ans5 != 0) ans6 = ans6 + 1; if (ans1 + ans2 + ans3 + ans4 + ans5 < 3) cout << "0" << endl; else doogh = ent(3, ans6); if (ans1 != 0) doogh = doogh * ans1; if (ans2 != 0) doogh = doogh * ans2; if (ans3 != 0) doogh = doogh * ans3; if (ans4 != 0) doogh = doogh * ans4; if (ans5 != 0) doogh = doogh * ans5; cout << doogh << 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; vector<string> A(N); for (long long i = 0; i < N; i++) { cin >> A[i]; } long long m, a, r, c, h; for (long long i = 0; i < N; i++) { if (A[i][0] = 'M') { m++; } else if (A[i][0] = 'A') { a++; } else if (A[i][0] = 'R') { r++; } else if (A[i][0] = 'C') { c++; } else if (A[i][0] = 'H') { h++; } } long long X = 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 << X << 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, c[5] = {0}; cin >> n; string s = "MARCH"; 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> #define rep(i,n) for(int i=0;i<n;i++) #define FOR(i,start,end) for(int i=start;i<=end;i++) const int INF = 1001001001; typedef long long ll; const ll MOD=1000000007; using namespace std; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); } template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); } template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); } template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); } template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); } template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); } int GCD(int a, int b) { return b ? GCD(b, a%b) : a; } int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; } //--------------------------------------------------------------------------------------------------- template<int MOD> struct ModInt { static const int Mod = MOD; unsigned x; ModInt() : x(0) { } ModInt(signed sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; } ModInt(signed long long sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; } int get() const { return (int)x; } ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; } ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; } ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; } ModInt &operator/=(ModInt that) { return *this *= that.inverse(); } ModInt operator+(ModInt that) const { return ModInt(*this) += that; } ModInt operator-(ModInt that) const { return ModInt(*this) -= that; } ModInt operator*(ModInt that) const { return ModInt(*this) *= that; } ModInt operator/(ModInt that) const { return ModInt(*this) /= that; } ModInt inverse() const { long long a = x, b = MOD, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b; std::swap(a, b); u -= t * v; std::swap(u, v); } return ModInt(u); } bool operator==(ModInt that) const { return x == that.x; } bool operator!=(ModInt that) const { return x != that.x; } ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; } }; template<int MOD> ostream& operator<<(ostream& st, const ModInt<MOD> a) { st << a.get(); return st; }; template<int MOD> ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) { ModInt<MOD> r = 1; while (k) { if (k & 1) r *= a; a *= a; k >>= 1; } return r; } template<typename T, int FAC_MAX> struct Comb { vector<T> fac, ifac; Comb(){fac.resize(FAC_MAX,1);ifac.resize(FAC_MAX,1);FOR(i,1,FAC_MAX-1)fac[i]=fac[i-1]*i; ifac[FAC_MAX-1]=T(1)/fac[FAC_MAX-1];for(int i=FAC_MAX-2;i>=1;i--)ifac[i]=ifac[i+1]*T(i+1);} T aPb(int a, int b) { if (b < 0 || a < b) return T(0); return fac[a] * ifac[a - b]; } T aCb(int a, int b) { if (b < 0 || a < b) return T(0); return fac[a] * ifac[a - b] * ifac[b]; } T nHk(int n, int k) { if (n == 0 && k == 0) return T(1); if (n <= 0 || k < 0) return 0; return aCb(n + k - 1, k); } // nHk = (n+k-1)Ck : n is separator T pairCombination(int n) {if(n%2==1)return T(0);return fac[n]*ifac[n/2]/(T(2)^(n/2));} // combination of paris for n }; typedef ModInt<1000000007> mint; int main(void){ // Your code here! int n;cin >> n; map<char,int> mp; string s = "MARCH"; rep(i,n) { string c;cin >> c; mp[c[0]]++; } int ans = 0; rep(i,5){ FOR(j,i+1,4){ FOR(k,j+1,4){ ans += mp[s[i]]*mp[s[j]]*mp[s[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; int M[5] = {0, 0, 0, 0, 0}; for (int i = 0; i < N; ++i) { string S; cin >> S; if (S[0] == 'M') M[0]++; if (S[0] == 'A') M[1]++; if (S[0] == 'R') M[2]++; if (S[0] == 'C') M[3]++; if (S[0] == 'H') M[4]++; } 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 += M[i] * M[j] * M[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
/^[MARCH]/{ a[substr($1,1,1)]++ } END{ n=0 split("MARCH",b,"") for(v in b)c[b[v]]=v for(i in a) for(j in a) for(k in a) if(c[i]>c[j]&&c[j]>c[k]) n+=a[i]*a[j]*a[k] print 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
cpp
#include <bits/stdc++.h> using namespace std; int N; int num[5] = {}; int main() { cin >> N; string name; for (int i = 0; i < N; i++) { cin >> name; switch (name[0]) { case 'M': num[0]++; break; case 'A': num[1]++; break; case 'R': num[2]++; break; case 'C': num[3]++; break; case 'H': num[4]++; break; } } long long 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 += num[i] * num[j] * num[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> char initial[100000]; uint64_t count_char(char* array, size_t size, char ch) { uint64_t cnt = 0; for (size_t i = 0; i < size; i++) { if (array[i] == ch) { cnt++; } } return cnt; } int main() { int num; char lf; scanf("%d%c", &num, &lf); for (int i = 0; i < num; i++) { char buf[12]; fgets(buf, sizeof(buf), stdin); initial[i] = buf[0]; } uint64_t a = count_char(initial, num, 'A'); uint64_t c = count_char(initial, num, 'C'); uint64_t h = count_char(initial, num, 'H'); uint64_t m = count_char(initial, num, 'M'); uint64_t r = count_char(initial, num, 'R'); uint64_t result = 0; result += a * c * h; result += a * c * m; result += a * c * r; result += a * h * m; result += a * h * r; result += a * m * r; result += c * h * m; result += c * h * r; result += c * m * r; result += h * m * r; 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; cin >> N; vector<int> cnl(5, 0); for (int i = 0; i < N; ++i) { string name; cin >> name; if (name[0] == 'M') { ++cnl[0]; } else if (name[0] == 'A') { ++cnl[1]; } else if (name[0] == 'R') { ++cnl[2]; } else if (name[0] == 'C') { ++cnl[3]; } else if (name[0] == 'H') { ++cnl[4]; } } long long res = 0; for (int i = 0; i < 5; ++i) { for (int j = i + 1; j < 5; ++j) { for (int k = j + 1; k < 5; ++k) { res += cnl[i] * cnl[j] * cnl[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 ll = long long; using namespace std; int next_combination(int sub) { int x = sub & -sub, y = sub + x; return (((sub & ~y) / x) >> 1) | y; } int main() { int n; cin >> n; vector<char> march = {'M', 'A', 'R', 'C', 'H'}; vector<int> cnt = {0, 0, 0, 0, 0}; for (int i = 0; i < n; ++i) { string name; cin >> name; for (int i = 0; i < 5; ++i) { if (march[i] == name[0]) { cnt[i]++; break; } } } vector<int> tmp; for (int i = 0; i < n; ++i) { if (cnt[i] > 0) { tmp.push_back(cnt[i]); } } if (tmp.size() == 0) { cout << 0 << endl; } else { int _n = tmp.size(); int _k = 3; int _bit = (1 << _k) - 1; ll ans = 0; for (; _bit < (1 << _n); _bit = next_combination(_bit)) { ll sum = 1; for (int i = 0; i < _n; ++i) { if (_bit & (1 << i)) { sum *= (ll)tmp[i]; } } ans += sum; } 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() { int n; cin >> n; vector<int> initial(5, 0); for (int i = 0; i < n; i++) { string s; cin >> s; switch (s[0]) { case 'M': initial[0]++; break; case 'A': initial[1]++; break; case 'R': initial[2]++; break; case 'C': initial[3]++; break; case 'H': initial[4]++; break; } } long long 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 += initial[i] * initial[j] * initial[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, i, c[5] = {0}, count = 1, sum = 0; string S; cin >> N; for (i = 0; i < N; i++) { cin >> S; if (S[0] == 'M') { c[0]++; sum++; } else if (S[0] == 'A') { c[1]++; sum++; } else if (S[0] == 'R') { c[2]++; sum++; } else if (S[0] == 'C') { c[3]++; sum++; } else if (S[0] == 'H') { c[4]++; sum++; } else { } } for (i = 0; i < 5; i++) { if (sum < 3) { count = 0; break; } if (c[i] != 0) count *= c[i]; } 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 namespace std; int n; char s[12]; int an[10]; long long ans; int main() { scanf("%d", &n); for (int i = 1; i <= n; ++i) { scanf("%s", s); if (s[0] == 'M') an[1]++; if (s[0] == 'A') an[2]++; if (s[0] == 'R') an[3]++; if (s[0] == 'C') an[4]++; if (s[0] == 'H') an[5]++; } for (int i = 1; i <= 5; ++i) for (int j = i + 1; j <= 5; ++j) for (int k = j + 1; k <= 5; ++k) ans += an[i] * an[j] * an[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() { int n; cin >> n; vector<string> s; vector<int> march(5); for (int i = 0; i < n; i++) { string st; cin >> st; if (st.at(0) == 'M' || st.at(0) == 'A' || st.at(0) == 'R' || st.at(0) == 'C' || st.at(0) == 'H') { s.push_back(st); if (st.at(0) == 'M') march.at(0)++; if (st.at(0) == 'A') march.at(1)++; if (st.at(0) == 'R') march.at(2)++; if (st.at(0) == 'C') march.at(3)++; if (st.at(0) == 'H') march.at(4)++; } } long long ans = 0; for (int i = 0; i < 3; i++) { if (march.at(i) == 0) continue; for (int j = i + 1; j < 4; j++) { if (march.at(j) == 0) continue; for (int k = j + 1; k < 5; k++) { if (march.at(k) == 0) continue; ans += march.at(i) * march.at(j) * march.at(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; using pint = pair<int, int>; const long long INFLL = 1LL << 60; const int INFI = 1000000000; int main() { int N; cin >> N; map<char, int> m{}; for (int i = 0; i < N; i++) { string s; cin >> s; m[s[0]]++; } long long ans = 0; vector<int> v(5); v[0] = m['M']; v[1] = m['A']; v[2] = m['R']; v[3] = m['C']; v[4] = m['H']; for (int i = 0; i <= 5; i++) { for (int j = i + 1; j <= 5; j++) { for (int k = j + 1; k <= 5; k++) { ans += v[i] * v[j] * v[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; void swap(int &a, int &b) { a ^= b; b ^= a; a ^= b; } unsigned int tzcnt(unsigned int x) { x = ~x & (x - 1); x -= x >> 1 & 0x55555555; x = (x & 0x33333333) + (x >> 2 & 0x33333333); x = x + (x >> 4) & 0x0F0F0F0F; return x * 0x01010101 >> 24; } int popcount(unsigned int x) { x -= x >> 1 & 0x55555555; x = (x & 0x33333333) + (x >> 2 & 0x33333333); x = x + (x >> 4) & 0x0F0F0F0F; return x * 0x01010101 >> 24; } struct Point { int x, y; Point(int p, int q) : x(p), y(q) {} }; int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; map<char, int> person_count = { {'M', 0}, {'A', 0}, {'R', 0}, {'C', 0}, {'H', 0}, }; for (int i = 0; i < N; ++i) { string s; cin >> s; char first = s[0]; if (first == 'M' || first == 'A' || first == 'R' || first == 'C' || first == 'H') { ++person_count[first]; } } int ans = 0; const char table[] = {'M', 'A', 'R', 'C', 'H'}; for (int i = 0b111; i <= 0b11111; ++i) { if (popcount(i) != 3) continue; int j = i; char p1 = table[tzcnt(j)]; j &= j - 1; char p2 = table[tzcnt(j)]; j &= j - 1; char p3 = table[tzcnt(j)]; ans += person_count[p1] * person_count[p2] * person_count[p3]; } cout << (ans) << "\n"; int aaa; cin >> aaa; }
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 fact(long long k) { if (k == 0) return 1; return k * fact(k - 1); } int main() { long long N; cin >> N; map<char, long long> word; vector<string> S(N); for (long long i = 0; i < N; i++) { cin >> S[i]; if (S[i][0] == 'M' || S[i][0] == 'A' || S[i][0] == 'R' || S[i][0] == 'C' || S[i][0] == 'H') { word[S[i][0]]++; } } if (word.size() < 3) { cout << 0 << endl; return 0; } long long sum; sum = fact(word.size()) / (6 * fact(word.size() - 3)); long long minus[3] = {1, 3, 8}; long long i = 0; if (word.size() == 4) i = 1; else if (word.size() == 5) i = 2; if (word['M'] > 1) sum += (word['M'] - 1) * minus[i]; if (word['A'] > 1) sum += (word['A'] - 1) * minus[i]; if (word['R'] > 1) sum += (word['R'] - 1) * minus[i]; if (word['C'] > 1) sum += (word['C'] - 1) * minus[i]; if (word['H'] > 1) sum += (word['H'] - 1) * minus[i]; 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
int main() { long long n, a[5]={0,0,0,0,0}, r = 0; q[5]={0,0,0,0,0}; p = 0; scanf("%ld", &n); for (int i = 0; i < n; i++) { char s[10]; scanf("%s", s); if (s[0] == 'M'){ a[0]++;q[0] = 1; } else if (s[0] == 'A') { a[1]++;q[1] = 1; } else if (s[0] == 'R') { a[2]++;q[2] = 1; } else if (s[0] == 'C') { a[3]++;q[3] = 1; } else if (s[0] == 'H') { a[4]++;q[4] = 1; } } int ans; for ( int z = 0; z < 3; z++;) { for ( int c = z+1; x < 4; x++){ for ( int v = c+1; v < 5; v++){ a[z]*a[c]*z[v] == ans;}}}} printf(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> int fact(int); int Comb(int, int); int main() { int M, A, R, C, H, N, i; char str[11]; M = A = R = C = H = 0; scanf("%d", &N); for (i = 0; i < N; i++) { scanf("%s", str); switch (str[0]) { case 'M': M++; break; case 'A': A++; break; case 'R': R++; break; case 'C': C++; break; case 'H': H++; break; } } printf("%d", M * (A * (R + C + H) + R * (C + H) + C * H) + A * (R * (C + H) + C * H) + R * C * H); return 0; } int fact(int n) { if (n < 0) return 0; if (n == 0) return 1; if (n <= 2) return n; return n * fact(n - 1); } int Comb(int n, int m) { return fact(n) / (fact(m) * fact(n - m)); }
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() { int N; scanf("%d", &N); char si1mojime[N]; char dammy; scanf("%c", &dammy); int i; char buff[100]; for (i = 0; i < N; i++) { gets(buff); si1mojime[i] = buff[0]; } int m, a, r, c, h; m = a = r = c = h = 0; for (i = 0; i < N; i++) { if (si1mojime[i] == 'M') { m += 1; } else if (si1mojime[i] == 'A') { a += 1; } else if (si1mojime[i] == 'R') { r += 1; } else if (si1mojime[i] == 'C') { c += 1; } else if (si1mojime[i] == 'H') { h += 1; } } unsigned long long ans = 0; 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; printf("%llu", 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() { int n, count = 0, ans = 0; int cnt[5] = {0, 0, 0, 0, 0}; char s[11]; cin >> 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]++; } } for (int i = 0; i < 5; i++) { for (int j = 0; j < i; j++) { for (int k = 0; k < j; 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; const long long INF = 1LL << 60; template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } ll max(ll a, ll b) { if (a > b) return a; else return b; } ll min(ll a, ll b) { if (a < b) return a; else return b; } int main(void) { int N; cin >> N; map<char, int> mp; 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') { mp[S[0]]++; } } ll ans = 0; string S = "MARCH"; for (int i = 0; i < S.size(); i++) { for (int j = i + 1; j < S.size(); j++) { for (int k = j + 1; k < S.size(); k++) { ans += mp[S[i]] * mp[S[j]] * mp[S[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 NN; string s; cin >> NN; int M = 0, A = 0, R = 0, C = 0, H = 0; for (int i = 0; i < NN; 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++; } long long sum = 0; 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; 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 ans; int N; int c[5]; int main(void) { scanf("%d", &N); for (int i = (0); i < (N); i++) { char S[15]; scanf("%s", S); if (S[0] == 'M') c[0]++; else if (S[0] == 'A') c[1]++; else if (S[0] == 'R') c[2]++; else if (S[0] == 'C') c[3]++; else 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 += (long long)c[i] * c[j] * c[k]; } } } printf("%d\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() { 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; 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() { int n; scanf("%d", &n); char name[11]; int c[5] = {0, 0, 0, 0, 0}; int i, j, k; for (i = 0; i < n; i++) { scanf("%s", name); switch (name[0]) { case 'M': c[0]++; break; case 'A': c[1]++; break; case 'R': c[2]++; break; case 'C': c[3]++; break; case 'H': c[4]++; break; default: break; } } unsigned 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("%llu\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(int argc, char* argv[]) { int n; cin >> n; string s; int march[5] = {}; for (int i = 0; i < n; i++) { cin >> s; switch (s[0]) { case 'M': march[0]++; break; case 'A': march[1]++; break; case 'R': march[2]++; break; case 'C': march[3]++; break; case 'H': march[4]++; break; default: break; } } unsigned long long int ans = 0; ans = march[0] * march[1] * march[2] + march[0] * march[1] * march[3] + march[0] * march[1] * march[4] + march[0] * march[2] * march[3] + march[0] * march[2] * march[4] + march[0] * march[3] * march[4] + march[1] * march[2] * march[3] + march[1] * march[2] * march[4] + march[1] * march[3] * march[4] + march[2] * march[3] * march[4]; 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 maxn = 1005; int change(char a) { if (a == 'M') return 1; else if (a == 'A') return 2; else if (a == 'R') return 3; else if (a == 'C') return 4; else if (a == 'H') return 5; } int a[6] = {0}; long long ans; int main() { int n, cnt = 0; string s; cin >> n; while (n--) { cin >> s; if (s[0] == 'M' || s[0] == 'A' || s[0] == 'R' || s[0] == 'C' || s[0] == 'H') { a[change(s[0])]++; } } ans = a[1] * a[2] * a[3] + a[1] * a[2] * a[4] + a[1] * a[2] * a[5] + a[2] * a[3] * a[4] + a[2] * a[3] * a[5] + a[1] * a[3] * a[4] + a[1] * a[3] * a[5] + a[2] * a[4] * a[5] + a[3] * a[4] * a[5] + a[1] * a[4] * a[5]; 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; bool is_prime(int n) { for (int i = 2; i * i <= n; i++) { if (n % i == 0) return false; } return true; } int findSumOfDigits(int n) { int sum = 0; while (n > 0) { sum += n % 10; n /= 10; } return sum; } template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } int main() { int N; cin >> N; vector<long long> a(N); map<char, long long> mp; long long numbers = 0; int kinds = 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') { mp[s[0]]++; numbers++; } } long long two = 0; for (auto x : mp) { if (x.second >= 2) { ++two; } kinds++; } long long one = kinds - two; long long res = (numbers * (numbers - 1) * (numbers - 2)) / 6; long long b = (one * (one - 1)) / 2; if (kinds >= 3) { for (auto x : mp) { if (x.second >= 2) { res = x.second * b; } } if (one >= 3) { res += (one * (one - 1) * (one - 2)) / 6; } } else { cout << 0 << endl; return 0; } 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() { int n; cin >> n; string s = "MARCH"; vector<int> c(5); for (int i = 0; i < (int)(n); i++) { string t; cin >> t; for (int i = 0; i < (int)s.size(); i++) { if (t[0] == s[i]) { c[i]++; 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 += long long(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, counter = 0; vector<string> data; string temp; cin >> N; for (int i = 0; i < N; i++) { cin >> temp; if (temp[0] != 'M' && temp[0] != 'A' && temp[0] != 'R' && temp[0] != 'C' && temp[0] != 'H') { continue; } data.push_back(temp); } if (data.size() < 3) { cout << counter << endl; return 0; } for (vector<string>::size_type i = 0; i < data.size() - 2; i++) { for (vector<string>::size_type j = i + 1; j < data.size() - 1; j++) { for (vector<string>::size_type k = j + 1; k < data.size(); k++) { if (data[i][0] != data[j][0] && data[k][0] != data[j][0] && data[i][0] != data[k][0]) { counter++; } } } } cout << counter << 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(void) { int n, a[5] = {0, 0, 0, 0, 0}; long ans = 0; cin >> n; vector<string> s(n); for (int i = 0; i < n; i++) { cin >> s[i]; if (s[i][0] == 'M') a[0]++; else if (s[i][0] == 'A') a[1]++; else if (s[i][0] == 'R') a[2]++; else if (s[i][0] == 'C') a[3]++; else if (s[i][0] == 'H') a[4]++; } for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 4; j++) { for (int k = j + 1; k < 5; k++) { ans += a[i] * a[j] * a[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> int main(void) { int n, x[5] = {}; 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]++; } std::sort(x, x + 5, std::greater<int>()); if (x[2] == 0) std::cout << 0 << std::endl; if (x[3] == 0) std::cout << x[0] * x[1] * x[2] << std::endl; if (x[4] == 0) std::cout << x[0] * x[1] * x[2] + x[0] * x[1] * x[3] + x[0] * x[2] * x[3] + x[1] * x[2] * x[3] << std::endl; else std::cout << x[0] * x[1] * x[2] + x[0] * x[1] * x[3] + x[0] * x[2] * x[3] + x[1] * x[2] * x[3] + x[0] * x[1] * x[4] + x[0] * x[2] * x[4] + x[1] * x[2] * x[4] + x[0] * x[3] * x[4] + x[1] * x[3] * x[4] + x[2] * x[3] * x[4] << 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
cpp
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; vector<long long> cnt(5); for (int i = 0; i < n; ++i) { string S; cin >> S; switch (S[0]) { case 'M': ++cnt[0]; break; case 'A': ++cnt[1]; break; case 'R': ++cnt[2]; break; case 'C': ++cnt[3]; break; case 'H': ++cnt[4]; } } long long all = 0; for (int i = 0; i < 5; ++i) all += cnt[i]; long long ans = all * (all - 1) * (all - 2) / 6; for (int i = 0; i < 5; ++i) ans -= cnt[i] * (cnt[i] - 1) / 2 * (all - 2); for (int i = 0; i < 5; ++i) ans += cnt[i] * (cnt[i] - 1) * (cnt[i] - 2) / 6; 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; int c[5] = {}; cin >> N; char **names = new char *[N]; for (int i = 0; i < N; i++) { names[i] = new char[10]; cin >> names[i]; if (names[i][0] == 'M') c[0]++; if (names[i][0] == 'A') c[1]++; if (names[i][0] == 'R') c[2]++; if (names[i][0] == 'C') c[3]++; if (names[i][0] == 'H') c[4]++; } unsigned long long combination = 0; for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 4; j++) { for (int k = j + 1; k < 5; k++) { combination += c[i] * c[j] * c[k]; } } } printf("%llu\n", combination); 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() { int N; scanf("%d", &N); char S[N][10]; int m = 0, a = 0, r = 0, c = 0, h = 0; for (int i = 0; i < N; i++) { scanf("%c", &S[i]); switch (S[i][0]) { case 'M': m++; break; case 'A': a++; break; case 'R': r++; break; case 'C': c++; break; case 'H': h++; break; default: break; } } long long ans; 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; 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() { 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 (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; 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
using System; using System.Linq; namespace abc089_c { class Program { static void Main(string[] args) { char[] name = new char[] { 'M','A','R','C','H' }; int[] people = new int[5]; int n = int.Parse(Console.ReadLine()); for (int i = 0; i < n; i++) { string s = Console.ReadLine(); if (name.Contains(s[0])) { people[Array.IndexOf(name,s[0])]++; } } 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 += people[i] * people[j] * people[k]; } } } Console.WriteLine(ret); } } }
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() { long long N; cin >> N; vector<string> S(N); vector<long long> cnt(5); long long ok = 0; for (long long i = 0; i < N; i++) { cin >> S[i]; if (S[i][0] == 'M') { cnt[0]++; } else if (S[i][0] == 'A') { cnt[1]++; } else if (S[i][0] == 'R') { cnt[2]++; } else if (S[i][0] == 'C') { cnt[3]++; } else if (S[i][0] == 'H') { cnt[4]++; } else { ok++; } } if (N - ok < 3) { cout << 0 << endl; return 0; } long long ans = 1; for (long long i = 0; i < 5; i++) { if (cnt[i] != 0) { ans *= cnt[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
cpp
#include <bits/stdc++.h> int ones_num(int bit) { int ans = 0; for (int i = 0; i <= 4; i++) { if (((bit >> i) & 0x01) == 1) ans += 1; } return ans; } void select(int bit, int* ans, int cnt[5], int sou) { int tmp = 1; if (sou >= 5) return; else if (ones_num(bit) == 3) { for (int i = 0; i <= 4; i++) { if (((bit >> i) & 0x01) == 1) tmp *= cnt[i]; } *ans += tmp; return; } select(bit |= (1 << (sou + 1)), ans, cnt, sou + 1); select((bit &= ~(1 << (sou + 1))) & 0x1F, ans, cnt, sou + 1); } int main(void) { char S[10]; int N; int cnt[5] = {0, 0, 0, 0, 0}; int ans = 0; scanf("%d", &N); fflush(stdin); for (int i = 0; i <= N - 1; i++) { scanf("%s", 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]++; } select(0, &ans, cnt, 0); select(1, &ans, cnt, 0); printf("%d\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
UNKNOWN
using System; using System.Collections.Generic; public class Test { public static void Main() { // your code goes here char[] initial = new char[2]; int N, count=0; N = int.Parse(Console.ReadLine()); string[]name = new string[N]; for(int i=0;i<N;i++) { name[i] = Console.ReadLine(); } for(int i=0;i<N-2;i++) { initial[0] = name[i][0]; for(int j=i+1;j<N-1;j++) { if(0>Array.IndexOf(initial, name[j][0])) { initial[1] = name[j][0]; for(int a=j+1;a<N;a++) { if(0>Array.IndexOf(initial, name[a][0])) { count++; //Console.WriteLine("{0} {1} {2}", name[i], name[j], name[a]); } } initial[1] = '\0'; } } } Console.WriteLine(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 int MOD = 1000000007; const int INF = 0x3f3f3f3f; const long long INFL = 0x3f3f3f3f3f3f3f3f; long long gcd(long long x, long long y) { return y ? gcd(y, x % y) : x; } long long lcm(long long x, long long y) { long long g = gcd(x, y); return x / g * y; } int main() { int N; cin >> N; int M = 0, A = 0, R = 0, C = 0, H = 0; for (long long i = 0; i < (N); i++) { string S; 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++; } long long ans = 0; ans += M * A * R + M * A * C + M * A * H; ans += M * R * C + M * R * H; ans += M * C * H; ans += A * R * C + 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> using namespace std; #define rep(i, n) for(long long i=0;i<(long long)(n);i++) #define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++) #define repi(i, n) for(int i=0;i<(int)(n);i++) #define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++) #define all(v) v.begin(), v.end() #define deg2rad(deg) (((deg)/360)*2*M_PI) #define rad2deg(rad) (((rad)/2/M_PI)*360) using ll = long long; using ld = long double; using vll = vector<ll>; using vvll = vector<vll>; using P = pair<ll, ll>; using vi = vector<int>; using vvi = vector<vi>; const ll INF = (1LL<<60); const int INFi = (1<<29); /*素数判定*/ bool is_prime(ll n){ if(n==1) return false; for(ll i=2;i*i<=n;i++){ if(n%i==0) return false; } return true; } /*約数列挙*/ vll enum_divisors(ll n){ vll l; for(ll i=1;i*i<=n;i++){ if(n%i==0){ l.push_back(i); if(n/i != i) l.push_back(n/i); } } sort(all(l)); return l; } /*素因数分解*/ vector<P> prime_factorize(ll n){ vector<P> l; for(ll i=2;i*i<=n;i++){ if(n%i!=0) continue; ll e = 0; while(n%i==0){ e++; n /= i; } l.push_back({i, e}); } if(n!=1) l.push_back({n, 1}); return l; } /*階乗*/ ll factorial(ll n){ ll ret; for(ret=1;n>0;n--){ ret *= n; } return ret; } /*最小公倍数*/ ll lcm(ll a, ll b){ return a*b/__gcd(a,b); } /*最大公約数*/ ll gcd(ll a, ll b){ return __gcd(a,b); } #define C(n, r) (((factorial((r))*factorial((n)-(r)))!=0) ? (factorial((n))/(factorial((r))*factorial((n)-(r)))) : 0) int main(){ ll n; cin >> n; map<char, ll> mp; string in; rep(i, n){ cin >> in; mp[in[0]]++; } ll sum = mp['M'] + mp['A'] + mp['R'] + mp['C'] + mp['H']; ll ans = C(sum, 3); ll sub = 0; for(auto x:{'M', 'A', 'R', 'C', 'H'}){ if(mp[x]>1){ sub += C(mp[x], 2)*(sum-2); } } cout << ans-sub << 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; long long ans = 0; vector<int> memo(5), p = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2}, q = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3}, r = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4}; cin >> n; vector<string> s(n); for (int i = 0; i < n; i++) { cin >> s[i]; if (s[i][0] == 'M') memo[0]++; else if (s[i][0] == 'A') memo[1]++; else if (s[i][0] == 'R') memo[2]++; else if (s[i][0] == 'C') memo[3]++; else if (s[i][0] == 'H') memo[4]++; } for (int i = 0; i < 10; i++) ans += memo[p[i]] * memo[q[i]] * memo[r[i]]; 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; int main() { int N, m = 0, a = 0, r = 0, c = 0, h = 0, ans = 0; cin >> N; int w[5]; char S[N][100]; for (int i = 0; i < N; i++) { cin >> S[i]; } 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++; } else { continue; } } if (m == 0) { N--; } else if (a == 0) { N--; } else if (r == 0) { N--; } else if (c == 0) { N--; } else if (h == 0) { N--; } if (N < 3) { cout << 0 << endl; } else { w[0] = m; w[1] = a; w[2] = r; w[3] = c; w[4] = h; for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 4; j++) { for (int k = j + 1; k < 5; k++) { ans += w[i] * w[j] * w[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 dy[4] = {0, 0, 1, -1}; int dx[4] = {1, -1, 0, 0}; int main() { unsigned long long M = 0, A = 0, R = 0, C = 0, H = 0; int N; string s[10000]; cin >> N; for (int i = 0; i < N; i++) cin >> s[i]; for (int 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++; } unsigned long long ans = 0; 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
cpp
#include <bits/stdc++.h> using namespace std; long nCr(int n, int r) { long ans = 1; for (int i = n; i > n - r; --i) { ans = ans * i; } for (int i = 1; i < r + 1; ++i) { ans = ans / i; } return ans; } int main() { int N, cntM = 0, cntA = 0, cntR = 0, cntC = 0, cntH = 0, cnt = 0; cin >> N; char color[N][100]; for (int i = 0; i < N; i++) { cin >> color[i]; if (color[i][0] == 'M') { cntM++; } else if (color[i][0] == 'A') { cntA++; } else if (color[i][0] == 'R') { cntR++; } else if (color[i][0] == 'C') { cntC++; } else if (color[i][0] == 'H') { cntH++; } } if (cntM != 0) { cnt++; } else { cntM++; } if (cntA != 0) { cnt++; } else { cntA++; } if (cntR != 0) { cnt++; } else { cntR++; } if (cntC != 0) { cnt++; } else { cntC++; } if (cntH != 0) { cnt++; } else { cntH++; } if (cnt < 3) { cout << '0'; } else { int ans = cntM * cntA * cntR * cntC * cntH; 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
python3
# import bisect from collections import Counter, deque # import copy # from fractions import gcd # from functools import reduce # from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product # import math # import numpy as np import sys sys.setrecursionlimit(10 ** 5 + 10) # input = sys.stdin.readline def resolve(): N=int(input()) S=[str(input())[0] for i in range(N)] for i in S: if i != 'M' and i != 'A' and i != 'R' and i != 'C' and i != 'H': S.remove(i) SS=Counter(S) SSS=SS.items() from operator import mul from functools import reduce # 未読 def comb(n, r): if n < r: return 0 else: r = min(n - r, r) if r == 0: return 1 over = reduce(mul, range(n, n - r, -1)) under = reduce(mul, range(1, r + 1)) return over // under ans=comb(len(SSS),3) cnt=0 temp=1 for i in SSS: if i[1]!=1: temp*=i[1] ans*=i[1] cnt+=1 minus=comb(len(SSS)-cnt,3)*(temp-1) ans-=minus print(ans) resolve()
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 = readInt() val S = readSet().toList() var counter: Long = 0 for (s in S) { if (s.toCharArray()[0] == 'M' || s.toCharArray()[0] == 'A' || s.toCharArray()[0] == 'R' || s.toCharArray()[0] == 'C' || s.toCharArray()[0] == 'H') { counter += 1 } } println(counter * (counter -1 ) * (counter - 2)) } fun readInt() = readLine()!!.toInt() fun readSet(): Set<String> = readLine()!!.split(' ').map { it }.toSet()
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; string name; map<char, unsigned long long> mp; cin >> n; char cc[] = {'M', 'A', 'R', 'C', 'H'}; mp['M'] = 0; mp['A'] = 0; mp['R'] = 0; mp['C'] = 0; mp['H'] = 0; for (int i = 0; i < n; i++) { cin >> name; if (name[0] == 'M' || name[0] == 'A' || name[0] == 'R' || name[0] == 'C' || name[0] == 'H') { mp[name[0]]++; } } unsigned long long sum = 0; for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 4; j++) { for (int k = j + 1; k < 5; k++) { cout << i << " " << j << " " << k << endl; unsigned long long a = mp[cc[i]] * mp[cc[j]] * mp[cc[k]]; sum += a; } } } 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
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace abc089c { class Abc089c { static void Main(string[] args) { var n = int.Parse(Console.ReadLine()); ulong m = 0, a = 0, r = 0, c = 0, h = 0; for (var i = 0; i != n; ++i) { var name = Console.ReadLine(); switch (name[0]) { case 'M': ++m; break; case 'A': ++a; break; case 'R': ++r; break; case 'C': ++c; break; case 'H': ++h; break; } } ulong 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 += r * c * h; Console.WriteLine(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; long long ans = 0; int c[5]; void calc(int idx, vector<int> v) { if (idx == 5) { if (v.size() == 3) { ans += (v[0] * v[1] * v[2]); } return; } calc(idx + 1, v); v.push_back(c[idx]); calc(idx + 1, v); } int main() { int n; cin >> n; string march = "MARCH"; string s; for (int i = 0; i < 5; i++) c[i] = 0; for (int i = 0; i < n; i++) { cin >> s; for (int j = 0; j < 5; j++) { if (s[0] == march[j]) { c[j] += 1; break; } } } vector<int> v; calc(0, v); 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; const int MOD = 1e9 + 7; struct edge { int from, to; ll cost; }; class Eratosthenes { public: vector<bool> prime; Eratosthenes(int size) { prime.resize(size + 1, 1); prime[0] = 0; prime[1] = 0; for (ll i = 2; i <= (ll)size; ++i) { if (prime[i]) { for (int j = 2 * i; j <= size; j += i) { prime[j] = 0; } } } } }; class Combination { vector<ll> fac; vector<ll> ifac; public: Combination(ll size) { fac.resize(size); ifac.resize(size); fac[0] = 1; ifac[0] = 1; for (ll i = 0; i < size; i++) { fac[i + 1] = fac[i] * (i + 1) % MOD; ifac[i + 1] = ifac[i] * mpow(i + 1, MOD - 2) % MOD; } } ll mpow(ll x, ll n) { ll ans = 1; while (n != 0) { if (n & 1) ans = ans * x % MOD; x = x * x % MOD; n = n >> 1; } return ans; } ll comb(ll a, ll b) { if (a == 0 && b == 0) return 1; if (a < b || a < 0) return 0; ll tmp = ifac[a - b] * ifac[b] % MOD; return tmp * fac[a] % MOD; } }; ll GCD(ll a, ll b) { if (b == 0) return a; return GCD(b, a % b); } ll LCM(ll a, ll b) { ll gcd = GCD(a, b); return a / gcd * b; } ll N; int main() { cin >> N; vector<int> c(5); for (int i = 0; i < N; ++i) { string s; cin >> 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]++; } int res = 0; for (int i = 0; i < 5; ++i) { for (ll j = i + 1; j <= (ll)5; ++j) { for (ll k = j + 1; k <= (ll)5; ++k) { res += c[i] * c[j] * c[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
UNKNOWN
fun main(args : Array<String>) { val l = (1..readLine()!!.toInt()).map { readLine()!![0] }.run { listOf(count { it == 'M' }, count { it == 'A' }, count { it == 'R' }, count { it == 'C' }, count { it == 'H' }).filter { it != 0 } } when { l.size == 3 -> print(l[0] * l[1] * l[2]) l.size == 4 -> print(l.map { l[0] * l[1] * l[2] * l[3] / it }.sum()) l.size == 5 -> { var a: Long = 0 (0..2).forEach { i -> (i + 1..3).forEach { j -> (j + 1..4).forEach { k -> a += l[i] * l[j] * l[k] } } } print(a) } else -> print(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.*; import static java.lang.System.*; class Main { public static final int MOD = 1000000007; public static final int INF = 1000000000; public static void main(String[] args) { Scanner sc = new Scanner(in); int N = sc.nextInt(); String S[] = new String[N]; Integer march[] = new Integer[5]; Arrays.fill(march, 0); for(int i=0; i<N; i++){ S[i] = sc.next(); if(S[i].charAt(0) == 'M') march[0]++; if(S[i].charAt(0) == 'A') march[1]++; if(S[i].charAt(0) == 'R') march[2]++; if(S[i].charAt(0) == 'C') march[3]++; if(S[i].charAt(0) == 'H') march[4]++; } int count = 0; long multi = 1; for(int i=0; i<5; i++){ if(march[i] > 0){ count++; multi *= march[i]; } } long ans; if(count < 3) ans = 0; else ans = count * (count-1) * (count-2) / 6 * multi; out.println(ans); } public static int gcd(int a, int b){ if(b == 0) return a; return gcd(b, a%b); } }
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 namecache; int nm[5] = {}; for (int i = 0; i < n; ++i) { cin >> namecache; switch (namecache[0]) { case 'M': nm[0]++; break; case 'A': nm[1]++; break; case 'R': nm[2]++; break; case 'C': nm[3]++; break; case 'H': nm[4]++; break; } } long long res; res = nm[0] * nm[1] * nm[2] + nm[0] * nm[1] * nm[3] + nm[0] * nm[1] * nm[4] + nm[0] * nm[2] * nm[3] + nm[0] * nm[2] * nm[4] + nm[0] * nm[3] * nm[4] + nm[1] * nm[2] * nm[3] + nm[1] * nm[2] * nm[4] + nm[1] * nm[3] * nm[4] + nm[2] * nm[3] * nm[4]; cout << res << '\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.Generic; using System.Linq; public static partial class Program { public static void Main() { var n = CRL().ToInt(); var cnt = new int[5]; for (int i = 0; i < n; i++) { switch (CRL()[0]) { case 'M': cnt[0]++; break; case 'A': cnt[1]++; break; case 'R': cnt[2]++; break; case 'C': cnt[3]++; break; case 'H': cnt[4]++; break; default: break; } } 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 += cnt[i] * cnt[j] * cnt[k]; } } } CWL(count); } } public static partial class Program { //テンプレここから public static int ToInt(this double d) => (int) d; public static long ToLong(this double d) => (long) d; public static int ToInt(this string str) => int.Parse(str); public static long ToLong(this string str) => long.Parse(str); public static long[] ToLong(this IEnumerable<string> strs) => strs.Select(x => x.ToLong()).ToArray(); public static int[] ToInt(this IEnumerable<string> strs) => strs.Select(x => x.ToInt()).ToArray(); public static long[] ArrayLongs(this string str, char opr = ' ') => str.Split(opr).ToLong(); public static int[] ArrayInts(this string str, char opr = ' ') => str.Split(opr).ToInt(); public static string CRL() => Console.ReadLine(); public static void CWL(object obj) => Console.WriteLine(obj); public static long Diff(long a, long b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b)); public static int Diff(int a, int b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b)); public static long Sign(this long i) => Math.Sign(i); public static bool IsEven(this long i) => i % 2 == 0; public static bool IsEven(this int i) => i % 2 == 0; public static long[] dx = new long[] {0, -1, 0, 1}; public static long[] dy = new long[] {-1, 0, 1, 0}; public static long mod = 1000000007; public static string alphabet = "abcdefghijklmnopqrstuvwxyz"; public static long ToLong(this char c) => c.ToString().ToInt(); public static long[] Sort(this long[] array) => array.OrderBy(x => x).ToArray(); public static int[] Sort(this int[] array) => array.OrderBy(x => x).ToArray(); public static long[] DSort(this long[] array) => array.OrderByDescending(x => x).ToArray(); public static int[] DSort(this int[] array) => array.OrderByDescending(x => x).ToArray(); public static string Join(this IEnumerable<string> array, string sep = "") => string.Join(sep, array); public static string Join(this IEnumerable<char> array, string sep = "") => string.Join(sep, array); public static long GCD(long a, long b) => b == 0 ? a : GCD(b, a % b); public static long LCM(long a, long b) => a * b / GCD(a, b); //テンプレここまで }
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 c[5] = {'M', 'A', 'R', 'C', 'H'}; int a[5]; int main() { for (int i = 0; i < 5; i++) a[i] = 0; int n; cin >> n; for (int i = 0; i < n; i++) { char tmp[15]; cin >> tmp; for (int j = 0; j < 5; j++) { if (tmp[0] == c[j]) { a[j]++; break; } } } unsigned long int out = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { out += a[i] * a[j] * a[k]; } } } cout << out << 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(void) { int n; string s; long long int alp[5]; cin >> n; for (int i = 0; i < n; i++) { cin >> s; if (s[0] == 'M') alp[0]++; if (s[0] == 'A') alp[1]++; if (s[0] == 'R') alp[2]++; if (s[0] == 'C') alp[3]++; if (s[0] == 'H') alp[4]++; } long long int sum = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { sum += alp[i] * alp[j] * alp[k]; } } } 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
#include <stdio.h> #include <stdlib.h> #include <string.h> int main(void) { char buffer[15]; if (fgets(buffer, 15, stdin) == NULL) { return 1; } int N = atoi(buffer); char (* names)[11] = malloc(sizeof(char*)*N); for (int i = 0; i < N; i++) { if (fgets(names[i], 11, stdin) == NULL) { return 1; } names[i][strlen(names[i])-1] = '\0'; } double pattern_sum = 0; const char* MARCH = "MARCH"; char *ff = NULL, *sf = NULL, *tf = NULL; for (int f = 0; f < N; f++) { for (int s = f+1; s < N; s++) { for (int t = s+1; t < N; t++) { if ((names[f][0] != names[s][0]) && (names[f][0] != names[t][0]) && (names[s][0] != names[t][0])) { ff = index(MARCH, names[f][0]); sf = index(MARCH, names[s][0]); tf = index(MARCH, names[t][0]); if (ff != NULL && sf != NULL && tf != NULL) { pattern_sum += 1; } } } } } printf("%.f", pattern_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
python3
# import bisect from collections import Counter, deque # import copy # from fractions import gcd # from functools import reduce # from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product # import math # import numpy as np import sys sys.setrecursionlimit(10 ** 5 + 10) # input = sys.stdin.readline def resolve(): N=int(input()) S=[str(input())[0] for i in range(N)] for i in S: if i != 'M' and i != 'A' and i != 'R' and i != 'C' and i != 'H': S.remove(i) SS=Counter(S) SSS=SS.items() ans=len(SSS)*(len(SSS)-1)*(len(SSS)-2)//6 cnt=0 temp=1 for i in SSS: if i[1]!=1: temp*=i[1] ans*=i[1] cnt+=1 minus=(len(SSS)-cnt)*(len(SSS)-1-cnt)*(len(SSS)-2-cnt)//6*(temp-1) ans-=minus print(ans) resolve()
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()) l=[0]*5 for i in range(n): x=input() y=x[0] if y=='M': l[0]+=1 elif y=='A': l[1]+=1 elif y=='R': l[2]+=1 elif y=='C': l[3]+=1 elif y=='H': l[4]+=1 ans=l[0]*l[1]*l[2] 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; string S[5]; for (int i = 0; i < N; i++) cin >> S[N]; int count[5]; for (int i = 0; i < N; i++) { if (S[i][0] == 'M') { count[0] += 1; } else if (S[i][0] == 'A') { count[1] += 1; } else if (S[i][0] == 'R') { count[2] += 1; } else if (S[i][0] == 'C') { count[3] += 1; } else if (S[i][0] == 'H') { count[4] += 1; } } int sum = 0; for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 4; j++) { for (int k = j + 1; k < 5; k++) { sum += count[i] * count[j] * count[k]; } } } 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> using namespace std; #define pb push_back #define mp make_pair #define int unsigned long long int q[200]; main(){ int n,i,c,k,l=0; cin>>n; string s; for (i=0;i<n;++i){ cin>>s; q[s[0]]++; } int r=1; c=q['M']+q['A']+q['R']+q['C']+q['H']; if (q['M']>1){ l+=q['A']+q['R']+q['C']+q['H']; } if (q['A']>1){ l+=q['M']+q['R']+q['C']+q['H']; } if (q['R']>1){ l+=q['M']+q['A']+q['C']+q['H']; } if (q['C']>1){ l+=q['M']+q['A']+q['R']+q['H']; } if (q['H']>1){ l+=q['M']+q['A']+q['R']+q['C']; } if (c-3>3){ k=1; int pr=0; for (i=c-2;i<=c;++i){ k*=i; if (k%6==0){ k/=6; pr=1; } } if (pr==0) r=6; } else { k=1; for (i=4;i<=c;++i){ k*=i; } for (i=2;i<=c-3;++i){ r*=i; } } if (c<3) cout <<0; else cout <<k/r-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
cpp
#include <bits/stdc++.h> using namespace std; long long n, h[100005]; long long dp[100005]; long long GCD(long long a, long long b) { return b ? GCD(b, a % b) : a; } stack<long long> sta; queue<long long> que; set<string> s_set; void comb(vector<vector<long long> > &v) { for (long long i = 0; i < v.size(); i++) { v[i][0] = 1; v[i][i] = 1; } for (long long k = 1; k < v.size(); k++) { for (long long j = 1; j < k; j++) { v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]); } } } int main() { long long A, B, C, D, E, F, G, H, I, J, L, N, M, K, O, pair<long long, long long>, Q, R, S, T, U, V, W, X, Y, Z; long long ans; ans = 0; string s; long long sum, sum1, sum2, sum3, sum4; sum = sum1 = sum2 = sum3 = sum4 = 0; long long flg, flg1, flg2, flg3, flg4, flg5, cnt, cnt1, cnt2, cnt3, cnt4, cnt5; flg = flg1 = flg2 = flg3 = flg4 = flg5 = cnt = cnt1 = cnt2 = cnt3 = cnt4 = cnt5 = 0; long long max; long long max1; max = max1 = 0; long long min; long long min1; min = min1 = 1000000000; long long work, work1, work2, work3, work4; work = work1 = work2 = work3 = work4 = 0; std::cin >> N; string SS[N]; for (long long i = 0; i < N; i++) { std::cin >> SS[i]; } for (long long i = 0; i < N; i++) { if (SS[i][0] == 'M') { cnt1++; if (flg1 == 0) { sum++; flg1 = 1; } } if (SS[i][0] == 'A') { cnt2++; if (flg2 == 0) { sum++; flg2 = 1; } } if (SS[i][0] == 'R') { cnt3++; if (flg3 == 0) { sum++; flg3 = 1; } } if (SS[i][0] == 'C') { cnt4++; if (flg4 == 0) { sum++; flg4 = 1; } } if (SS[i][0] == 'H') { cnt5++; if (flg5 == 0) { sum++; flg5 = 1; } } } long long NN; NN = sum; vector<vector<long long> > v(N + 1, vector<long long>(N + 1, 0)); comb(v); if (sum < 3) { puts("0"); return 0; } else if (sum == 3) { printf("%lld\n", v[NN][3] + (cnt1 + cnt2 + cnt3 + cnt4 + cnt5) - 3); return 0; } else { printf("%lld\n", v[NN][3] * ((cnt1 + cnt2 + cnt3 + cnt4 + cnt5) - 3) - (cnt1 + cnt2 + cnt3 + cnt4 + cnt5) + 3 + 1); 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; int m=0,a=0,r=0,c=0,h=0; for(int i=0;i<N;i++){ string name; 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
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 dx[] = {1, 0, -1, 0}; int dy[] = {0, 1, 0, -1}; int main() { int n; cin >> n; int a[5] = {}; for (int i = 0; i < n; i++) { string s; cin >> 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 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 += (a[i] * a[j] * a[k]); } } } cout << ans << endl; return 0; }