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; using ll = long long; using vi = vector<int>; using vvi = vector<vi>; ll nCk(int n, int k) { if (n <= k) k -= n; if (k == 0) return 1LL; ll ans = 1LL; for (int i = 0; i < k; ++i) { ans *= n--; } return ans / 6; } int main() { int N; cin >> N; map<char, int> S; string T{"MARCH"}; for (int i = 0; i < (N); i++) { string s; cin >> s; for (int j = 0; j < (T.size()); j++) { if (s[0] == T[j]) { S[s[0]]++; } } } if (S.size() < 1) { cout << 0 << endl; return 0; } map<string, int> C; for (auto a : S) { for (auto b : S) { if (a == b) continue; for (auto c : S) { if (a == c || b == c) continue; string s{a.first, b.first, c.first}; sort((s).begin(), (s).end()); decltype(C)::iterator it = C.find(s); if (it == C.end()) { C[s] += a.second * b.second * c.second; } } } } ll ans = 0; for (auto e : C) { ans += e.second; } 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> const int MGN = 8; const int ARY_SZ_MAX = 10000000; using namespace std; using ll = long long; using ull = unsigned long long; using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>; using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>; using vl = vector<ll>; using vvl = vector<vl>; using vd = vector<double>; using vs = vector<string>; using pii = pair<int, int>; using pll = pair<ll, ll>; void get_combination(vvl& C, const ll N) { C = vvl(N + 1, vl(N + 1, 0)); for (int i = int(0); i < int(N + 1); ++i) { C[i][0] = 1; C[i][i] = 1; } for (int i = int(1); i < int(N + 1); ++i) { for (int j = int(1); j < int(i); ++j) { C[i][j] = C[i - 1][j - 1] + C[i - 1][j]; } } } int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; vs S(N); for (int i = int(0); i < int(N); ++i) cin >> S[i]; string ptn = "MARCH"; map<char, int> mp; for (string s : S) { if (ptn.find(s[0]) != string::npos) mp[s[0]]++; } ll M = 0; for (char c : ptn) { M += mp[c]; } ll ans = 0; if (M >= 3) { vvl C; get_combination(C, M); ll total = C[M][3]; for (char c : ptn) { int n = mp[c]; if (n >= 3) total -= C[n][3]; if (n >= 2) total -= C[n][2] * C[M - n][1]; } ans = total; } 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
#include <bits/stdc++.h> int main() { int n; char buf[16]; int cnt[] = {0, 0, 0, 0, 0}; long long ans; long long temp; int i, j, k; scanf("%d\n", &n); for (i = 0; i < n; i++) { fgets(buf, sizeof(buf), stdin); switch (buf[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; } } ans = 0; for (i = 0; i < 5; i++) for (j = i + 1; j < 5; j++) for (k = j + 1; k < 5; k++) ans += cnt[i] * cnt[j] * cnt[k]; printf("%lld\n", ans); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int N; vector<int> let(5); const char letter[5] = {'M', 'A', 'R', 'C', 'H'}; int main() { cin >> N; for (int i = 0; i < N; i++) { string temp; cin >> temp; for (int j = 0; j < 5; j++) { if (temp[0] == letter[j]) { let[j]++; } } } int res = 0; for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 4; j++) { for (int k = j + 1; k < N; k++) { res += let[i] * let[j] * let[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> char name[100005][15]; int main() { int n; int m = 0, a = 0, r = 0, c = 0, h = 0; long long int ans = 0; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%s", name[i]); if (name[i][0] == 'M') m++; if (name[i][0] == 'A') a++; if (name[i][0] == 'R') r++; if (name[i][0] == 'C') c++; if (name[i][0] == 'H') h++; } n = m + a + r + c + h; if (n < 3) { printf("0"); return 0; } ans = m * a * (r + c + h) + m * r * (c + h) + m * c * h + a * r * (c + h) + a * c * h + r * c * h; printf("%lld", ans); }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<int, int>; int main() { int n; cin >> n; vector<string> s(n); for (int i = 0; i < (n); ++i) { cin >> s[i]; } vector<int> list(5, 0); for (int i = 0; i < (n); ++i) { string ss = s[i]; switch (ss[0]) { case 'M': list[0]++; break; case 'A': list[1]++; break; case 'R': list[2]++; break; case 'C': list[3]++; break; case 'H': list[4]++; break; default: break; } } ll res = 0; for (int bit = 0; bit < (1 << list.size()); ++bit) { vector<int> S; for (int i = 0; i < list.size(); ++i) { if (bit & (1 << i)) { S.push_back(i); } } if (S.size() != 3) { continue; } res += list[S[0]] * list[S[1]] * list[S[2]]; } 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; vector<string> s(n); for (int i = 0; i < (n); i++) cin >> s[i]; ; long long int cntm = 0; long long int cnta = 0; long long int cntr = 0; long long int cntc = 0; long long int cnth = 0; for (int i = 0; i < n; i++) { if (s[i][0] == 'M') cntm++; if (s[i][0] == 'A') cnta++; if (s[i][0] == 'R') cntr++; if (s[i][0] == 'C') cntc++; if (s[i][0] == 'H') cnth++; } long long int ans = cntm * cnta * cntr + cntm * cnta * cntc + cntm * cnta * cnth + cntm * cntr * cntc + cntm * cntr * cnth + cntm * cntc * cnth + cnta * cntr + cntc + cnta * cntr * cnth + cnta * cntc * cnth + 0 * cntr * cntc * cnth; 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() { unsigned long long int a, b, c, d, e, ans = 0, n; int M = 0, A = 0, R = 0, C = 0, H = 0; int num[100000]; unsigned long long x, y; string s; cin >> n; b = 0; for (a = 0; a < n; a++) { 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++; } } a = 0; a += M * A * R; a += M * A * C; a += M * A * H; a += M * R * C; a += M * R * H; a += M * C * H; a += A * R * C; a += A * R * H; a += A * C * H; a += R * C * H; cout << a << 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> namespace FastIn { static constexpr size_t BUF_SIZE = 1 << 17, INT_LEN = 24, FLT_LEN = 400; static char buf[BUF_SIZE | 1] = {}, *pos = buf, *endbuf = nullptr; FILE *fin; inline bool rebuffer() { size_t rest = endbuf - pos; if (buf + rest > pos) { return true; } std::memcpy(buf, pos, rest); pos = buf; size_t len = std::fread(pos + rest, 1, BUF_SIZE - rest, fin); *(endbuf = buf + (rest + len)) = 0; return *pos; } inline bool scan(char &in) { if ((in = *pos)) { ++pos; return true; } return rebuffer() && (in = *pos++); } inline bool scan(char *in) { if ((*in = *pos) == 0) { if (rebuffer() && (*in = *pos) == 0) { return false; } } ++in; while (true) { if ((*in = *pos++) == 0) { if (rebuffer() && (*in = *pos++) == 0) { return true; } } ++in; } } inline bool scan(double &in) { if (pos + FLT_LEN >= endbuf && !rebuffer()) { in = 0.0; return false; } char *tmp; in = std::strtod(pos, &tmp); pos = tmp; return true; } template <class Int> inline bool scan(Int &in) { in = 0; if (pos + INT_LEN >= endbuf && !rebuffer()) { return false; } if (std::is_signed<Int>::value) { if (*pos == '-') { in = ~*++pos + '1'; while (*++pos >= '0') { in = in * 10 + ~*pos + '1'; } ++pos; return true; } } do { in = in * 10 + *pos - '0'; } while (*++pos >= '0'); ++pos; return true; } inline bool eat() { if (*pos > ' ') { return true; } do { if (*pos == 0 && !rebuffer()) { return false; } } while (*++pos <= ' '); return true; } inline bool eat(char ch) { if (*pos == ch) { return !(*++pos == 0 && !rebuffer()); } do { if (*pos == 0 && !rebuffer()) { return false; } } while (*++pos != ch); return !(*++pos == 0 && !rebuffer()); } class Scanner { bool rebuffer() { return FastIn::rebuffer(); } public: Scanner(FILE *fin = stdin) { FastIn::fin = fin; endbuf = pos + std::fread(buf, 1, BUF_SIZE, fin); } template <class T> inline bool scan(T &in) { return FastIn::scan(in); } template <class First, class... Rest> inline bool scan(First &in, Rest &...ins) { return scan(in) && scan(ins...); } inline bool eat(char ch) { return FastIn::eat(ch); } }; } // namespace FastIn FastIn::Scanner cin; int main() { size_t N; cin.scan(N); intmax_t S[256] = {}; for (size_t i = 0; i < N; ++i) { char c; cin.scan(c); ++S[c]; cin.eat('\n'); } intmax_t res = 0; res += S['M'] * S['A'] * S['R']; res += S['M'] * S['A'] * S['C']; res += S['M'] * S['A'] * S['H']; res += S['M'] * S['R'] * S['C']; res += S['M'] * S['R'] * S['H']; res += S['M'] * S['C'] * S['H']; res += S['A'] * S['R'] * S['C']; res += S['A'] * S['R'] * S['H']; res += S['A'] * S['C'] * S['H']; res += S['R'] * S['C'] * S['H']; printf("%jd\n", res); }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; 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 < 3; i++) { for (int j = i + 1; j < 4; j++) { for (int k = j + 1; k < 5; k++) { ans += c[i] * c[j] * c[k]; } } } cout << ans << endl; 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> name; vector<int> count(5, 0); for (int i = 0; i < n; i++) { string tmp; cin >> tmp; name.push_back(tmp); ; if (name[i][0] == 'M') { count[0]++; } else if (name[i][0] == 'A') { count[1]++; } else if (name[i][0] == 'R') { count[2]++; } else if (name[i][0] == 'C') { count[3]++; } else if (name[i][0] == 'H') { count[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 += (count[i] * count[j] * count[k]); } } } cout << res << 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, M = 0, A = 0, R = 0, C = 0, H = 0, i, a[10]; long long s = 0LL; string L; cin >> n; for (i = 0; i < n; i++) { getline(cin, L); switch (L[0]) { case 'M': M++; break; case 'A': A++; break; case 'R': R++; break; case 'C': C++; break; case 'H': H++; break; default: break; } } a[0] = M * A * R; a[1] = M * A * C; a[2] = M * A * H; a[3] = M * R * C; a[4] = M * R * H; a[5] = M * C * H; a[6] = A * R * C; a[7] = A * R * H; a[8] = A * C * H; a[9] = R * C * H; for (i = 0; i < 10; i++) { s += a[i]; } cout << s << 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
from itertools import combinations n = int(input()) arr = [input()[0] for s in range(n)] arr = [s for s in arr if s in "MARCH"] combi = [len(set(i)) for i in combinations(arr, 3)] print(sum([1 for i in combi if i==3]))
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int a[5]; int main() { int n; scanf("%d", &n); memset(a, 0, sizeof(a)); for (int i = 1; i <= n; i++) { char ch[5000]; scanf("%s", ch); if (ch[0] == 'M') a[1]++; else if (ch[0] == 'A') a[2]++; else if (ch[0] == 'R') a[3]++; else if (ch[0] == 'C') a[4]++; else if (ch[0] == 'H') a[5]++; } long long ans = 0; for (int i = 1; i <= 5; i++) cout << a[i] << endl; for (int i = 1; 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]; printf("%lld", ans); }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
import numpy as np member = [] count = np.array([0], dtype='int64') name_count = {'M': 0, 'A': 0, 'R': 0, 'C': 0, 'H': 0} N = int(input()) for i in range(N): name = input() member.append(name) for i in range(N): if member[i][0] in name_count: name_count[member[i][0]] += 1 count[0] += name_count['M'] * name_count['A'] * name_count['R'] count[0] += name_count['M'] * name_count['A'] * name_count['C'] count[0] += name_count['M'] * name_count['A'] * name_count['H'] count[0] += name_count['M'] * name_count['R'] * name_count['C'] count[0] += name_count['M'] * name_count['R'] * name_count['H'] count[0] += name_count['M'] * name_count['C'] * name_count['H'] count[0] += name_count['A'] * name_count['C'] * name_count['R'] count[0] += name_count['A'] * name_count['H'] * name_count['R'] count[0] += name_count['H'] * name_count['C'] * name_count['R'] print(count[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() { long long int n; char s[15]; int mozi[5] = {}; int ans = 1; int poyo = 0; int zenbu = 0; int i, j, k; scanf("%lld", &n); for (int i = 0; i < n; i++) { scanf("%s", s); if (s[0] == 'M') mozi[0]++; else if (s[0] == 'A') mozi[1]++; else if (s[0] == 'R') mozi[2]++; else if (s[0] == 'C') mozi[3]++; else if (s[0] == 'H') mozi[4]++; } for (i = 0; i < 3; i++) { for (j = i + 1; j < 4; j++) { for (k = j + 1; k < 5; k++) { ans = mozi[i] * mozi[j] * mozi[k]; zenbu += ans; } } } printf("%d\n", zenbu); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
import itertools N = int(input()) nm = [] for i in range(N): S = input() nm.append(S[0]) tm = [nm.count(i) for i in str('MARCH')] f = [(n == 0) for n in tm] ans = 0 for i,j,k in itertools.combinations(range(5), 3): ans += tm[i]*tm[j]*tm[k] print(ans)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; long long a[5], ans = 0; for (int i = 0; i < (int)(n); i++) a[i] = 0; for (int i = 0; i < (int)(n); i++) { cin >> s; if (s[0] == 'M') { a[0]++; } else if (s[0] == 'A') { a[1]++; } else if (s[0] == 'R') { a[2]++; } else if (s[0] == 'C') { a[3]++; } else if (s[0] == 'H') { a[4]++; } } ans = 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 << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
import itertools n = int(input()) sl = [] dic = {'M':0,'A':0,'R':0,'C':0,'H':0} for i in range(n): name = input() if name[0] in dic: dic[name[0]] += 1 lst = [] for com in itertools.combinations(dic.keys(),3): lst.append(com) print(lst) ans = 0 for v in lst: ans += dic[v[0]] * dic[v[1]] * dic[v[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(void) { int n, a[5] = {0, 0, 0, 0, 0}; long 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> using namespace std; int N; char S[15]; int hashfunc(char c) { switch (c) { case 'M': return 0; case 'A': return 1; case 'R': return 2; case 'C': return 3; case 'H': return 4; } return -1; } int main() { scanf("%d", &N); int counts[5] = {0, 0, 0, 0, 0}; int hashcode; for (int i = 1; i <= N; ++i) { scanf("%s", S); hashcode = hashfunc(S[0]); if (hashcode != -1) ++counts[hashcode]; } long long res = 0; for (int i = 0; i <= 2; ++i) { for (int j = i + 1; j <= 3; ++j) { for (int x = j + 1; x <= 4; ++x) { res += counts[i] * counts[j] * counts[x]; } } } cout << res; 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
from sys import stdin import numpy as np import math from math import factorial from itertools import combinations n = int(stdin.readline().rstrip()) li = [stdin.readline().rstrip() for _ in range(n)] lin = [] for i in range(n): if li[i][0] in "MARCH": lin.append(li[i][0]) liv = list(combinations(lin, 3)) point = 0 for i in liv: if i[0] != i[1] and i[0] != i[2] and i[2] != i[1]: point += 1 print(point)
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; constexpr int INF = 1e9 + 7; constexpr int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}; int main() { int N; cin >> N; int cnt[5]; for (int i = (0); i < (5); ++i) cnt[i] = 0; string S; char march[5] = {'M', 'A', 'R', 'C', 'H'}; for (int i = (0); i < (N); ++i) { cin >> S; for (int i = (0); i < (5); ++i) if (S[0] == march[i]) cnt[i]++; } long long int ans = 0; ans = cnt[0] * cnt[1] * cnt[2] + cnt[0] * cnt[1] * cnt[3] + cnt[0] * cnt[1] * cnt[4] + cnt[0] * cnt[2] * cnt[3] + cnt[0] * cnt[2] * cnt[4] + cnt[0] * cnt[3] * cnt[4] + cnt[1] * cnt[2] * cnt[3] + cnt[1] * cnt[2] * cnt[4] + cnt[1] * cnt[3] * cnt[4] + cnt[2] * cnt[3] * cnt[4]; cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
import copy n = int(input()) s = [input().replace("\n", "") for i in range(n)] march_num_list = [0, 0, 0, 0, 0] for name in s: for i, head in enumerate(("M", "A", "R", "C", "H")): if name[0] == head: march_num_list[i] += 1 pattern_num = 0 for i, one in enumerate(march_num_list): two_list = copy.copy(march_num_list) two_list.pop(i) for j, two in enumerate(two_list): three_list = copy.copy(two_list) three_list.pop(j) for k, three in enumerate(three_list): pattern_num += one * two * sum(three_list) print(pattern_num)
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 P = pair<int, int>; const int MOD = 1000000007; int main() { int n; cin >> n; string s; long long ans = 0; vector<int> a(5, 0); for (int i = 0; i < (n); ++i) { cin >> s; if (s[0] == 'M') a[0]++; else if (s[0] == 'A') a[1]++; else if (s[0] == 'R') a[2]++; else if (s[0] == 'C') a[3]++; else if (s[0] == 'H') a[4]++; } for (int i = 0; i < 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; }
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
<?php $n = trim(fgets(STDIN)); $count = []; $t = 0; $march=["M","A","R","C","H"]; for($i=0; $i<$n; $i++){ $s = trim(fgets(STDIN)); if(in_array($s[0],$march)){ $count[$s[0]]++; $t++; } } // print_r($count); function perm($k){ return ($k*($k-1))/2; } $ans = 0; foreach($count as $d){ if($d>1){ $ans += perm($t-$d)*$d; }else{ $c++; } } $p=0; if($c == 3){ $p=1; }else if($c == 4){ $p=4; }else if($c == 5){ $p=10; } echo $ans+$p;
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 static System.Console; using System.Numerics; class Program { static void Main() { var N = int.Parse(ReadLine()); var S = new string[N]; for (int i = 0; i < N; i++) { S[i] = ReadLine(); } BigInteger M = S.Count(x => x.First() == 'M'); BigInteger A = S.Count(x => x.First() == 'A'); BigInteger R = S.Count(x => x.First() == 'R'); BigInteger C = S.Count(x => x.First() == 'C'); BigInteger H = S.Count(x => x.First() == 'H'); var L = M * A * R + M * A * C + M * A * H + M * R * C + M * R * H + M * C * H + A * R * C + A * R * H + R * C * H; WriteLine(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
python3
from collections import Counter N = int(input()) S = [input() for i in range(N)] S = [s[0] for s in S if s[0] in 'MARCH'] counter = Counter(S) if len(counter) < 3: print(0) else: cnt = 0 mar = 'MARCH' for a in range(0,3): if mar[a] not in counter: continue for b in range(a+1, min(a+1+3, N)): if mar[b] not in counter: continue for c in range(b+1, min(b+1+3, N)): if mar[c] not in counter: continue cnt += counter[mar[a]] * counter[mar[b]] * counter[mar[c]] print(cnt)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
import std.stdio; import std.string; import std.format; import std.conv; import std.typecons; import std.algorithm; import std.functional; import std.bigint; import std.numeric; import std.array; import std.math; import std.range; import std.container; import std.ascii; import std.concurrency; import std.traits; import core.bitop : popcnt; alias Generator = std.concurrency.Generator; const long INF = long.max/3; const long MOD = 10L^^9+7; void main() { int N; scanln(N); string[] as = N.rep!(() => readln.chomp).sort.array; char[] cs = ['M', 'A', 'R', 'C', 'H']; long[] xs = cs.map!(c => as.count!(a => a.front==c).to!long).array; long ans = 0; foreach(i; 0..5) foreach(j; 0..i) foreach(k; 0..j) { ans += xs[i]*xs[j]*xs[k]; } ans.writeln; } // ---------------------------------------------- void scanln(Args...)(auto ref Args args) { import std.meta; template getFormat(T) { static if (isIntegral!T) { enum getFormat = "%d"; } else static if (isFloatingPoint!T) { enum getFormat = "%g"; } else static if (isSomeString!T || isSomeChar!T) { enum getFormat = "%s"; } else { static assert(false); } } enum string str = [staticMap!(getFormat, Args)].join(" ") ~ "\n"; // readf!str(args); mixin("str.readf(" ~ Args.length.iota.map!(i => "&args[%d]".format(i)).join(", ") ~ ");"); } void times(alias fun)(int n) { // n.iota.each!(i => fun()); foreach(i; 0..n) fun(); } auto rep(alias fun, T = typeof(fun()))(int n) { // return n.iota.map!(i => fun()).array; T[] res = new T[n]; foreach(ref e; res) e = fun(); return res; } T ceil(T)(T x, T y) if (__traits(isIntegral, T)) { // `(x+y-1)/y` will only work for positive numbers ... T t = x / y; if (t * y < x) t++; return t; } T floor(T)(T x, T y) if (__traits(isIntegral, T)) { T t = x / y; if (t * y > x) t--; return t; } // fold was added in D 2.071.0 static if (__VERSION__ < 2071) { template fold(fun...) if (fun.length >= 1) { auto fold(R, S...)(R r, S seed) { static if (S.length < 2) { return reduce!fun(seed, r); } else { return reduce!fun(tuple(seed), r); } } } } // cumulativeFold was added in D 2.072.0 static if (__VERSION__ < 2072) { template cumulativeFold(fun...) if (fun.length >= 1) { import std.meta : staticMap; private alias binfuns = staticMap!(binaryFun, fun); auto cumulativeFold(R)(R range) if (isInputRange!(Unqual!R)) { return cumulativeFoldImpl(range); } auto cumulativeFold(R, S)(R range, S seed) if (isInputRange!(Unqual!R)) { static if (fun.length == 1) return cumulativeFoldImpl(range, seed); else return cumulativeFoldImpl(range, seed.expand); } private auto cumulativeFoldImpl(R, Args...)(R range, ref Args args) { import std.algorithm.internal : algoFormat; static assert(Args.length == 0 || Args.length == fun.length, algoFormat("Seed %s does not have the correct amount of fields (should be %s)", Args.stringof, fun.length)); static if (args.length) alias State = staticMap!(Unqual, Args); else alias State = staticMap!(ReduceSeedType!(ElementType!R), binfuns); foreach (i, f; binfuns) { static assert(!__traits(compiles, f(args[i], e)) || __traits(compiles, { args[i] = f(args[i], e); }()), algoFormat("Incompatible function/seed/element: %s/%s/%s", fullyQualifiedName!f, Args[i].stringof, E.stringof)); } static struct Result { private: R source; State state; this(R range, ref Args args) { source = range; if (source.empty) return; foreach (i, f; binfuns) { static if (args.length) state[i] = f(args[i], source.front); else state[i] = source.front; } } public: @property bool empty() { return source.empty; } @property auto front() { assert(!empty, "Attempting to fetch the front of an empty cumulativeFold."); static if (fun.length > 1) { import std.typecons : tuple; return tuple(state); } else { return state[0]; } } void popFront() { assert(!empty, "Attempting to popFront an empty cumulativeFold."); source.popFront; if (source.empty) return; foreach (i, f; binfuns) state[i] = f(state[i], source.front); } static if (isForwardRange!R) { @property auto save() { auto result = this; result.source = source.save; return result; } } static if (hasLength!R) { @property size_t length() { return source.length; } } } return Result(range, args); } } } // minElement/maxElement was added in D 2.072.0 static if (__VERSION__ < 2072) { auto minElement(alias map, Range)(Range r) if (isInputRange!Range && !isInfinite!Range) { alias mapFun = unaryFun!map; auto element = r.front; auto minimum = mapFun(element); r.popFront; foreach(a; r) { auto b = mapFun(a); if (b < minimum) { element = a; minimum = b; } } return element; } auto maxElement(alias map, Range)(Range r) if (isInputRange!Range && !isInfinite!Range) { alias mapFun = unaryFun!map; auto element = r.front; auto maximum = mapFun(element); r.popFront; foreach(a; r) { auto b = mapFun(a); if (b > maximum) { element = a; maximum = b; } } return element; } }
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 functools import reduce from itertools import combinations N = int(input()) S = {"M": set([]), "A": set([]), "R": set([]), "C": set([]), "H": set([])} for _ in range(N): i = input() head = i[0] if head == "M": S["M"].add(i) elif head == "A": S["A"].add(i) elif head == "R": S["R"].add(i) elif head == "C": S["C"].add(i) elif head == "H": S["H"].add(i) result = [len(S[head]) for head in list("MARCH") if len(S[head]) != 0] ans = sum([reduce(lambda x, y: x * y, list(combinations(result, 3))[i]) for i in range(len(result))]) 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; const int NN = 330; struct rec1 { int x, y; } a[NN * NN]; int h, w, d, x, q, l, r, n, sum[NN * NN]; int dis(int p, int q) { return abs(a[p].x - a[q].x) + abs(a[p].y - a[q].y); } int main() { scanf("%d%d%d", &h, &w, &d); for (int i = 1; i <= h; i++) { for (int j = 1; j <= w; j++) { scanf("%d", &x); a[x].x = i; a[x].y = j; } } n = h * w; memset(sum, 0, sizeof(sum)); for (int i = 1; i <= d; i++) { for (int j = i + d; j <= n; j += d) sum[j] = sum[j - d] + dis(j, j - d); } scanf("%d", &q); while (q--) { scanf("%d%d", &l, &r); printf("%d\n", sum[r] - sum[l]); } 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 mark[30], n; string s; char ch[5] = {'M', 'A', 'R', 'C', 'H'}; long long ans; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; for (int i = 0; i < n; i++) { cin >> s; mark[s[0] - 'A']++; } for (int i = 0; i < 5; i++) for (int j = i + 1; j < n; j++) for (int k = j + 1; k < n; k++) ans += (1LL * mark[ch[k] - 'A'] * mark[ch[j] - 'A'] * mark[ch[i] - 'A']); cout << ans; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { string T{"MARCH"}; int N; cin >> N; vector<int> C(T.size()); while (N--) { string s; cin >> s; for (int t = 0; t < T.size(); ++t) if (s[0] == T[t]) C[t]++; } int ans = 0; for (int i = 0; i < C.size(); ++i) for (int j = i + 1; j < C.size(); ++j) for (int k = j + 1; k < C.size(); ++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> int main(void) { long long i, c0, c1, c2, N, m[5] = {0}; long long s; char name[14]; const char sign[7] = "MARCH"; scanf("%d", &N); for (i = 0; i < N; i++) { scanf("%s", name); for (int j = 0; j < 5; j++) if (name[0] == sign[j]) m[j]++; } s = 0; for (c0 = 0; c0 < 5; c0++) for (c1 = c0 + 1; c1 < 5; c1++) for (c2 = c1 + 1; c2 < 5; c2++) s += m[c0] * m[c1] * m[c2]; printf("%d\n", s); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.math.BigDecimal; import java.math.BigInteger; import java.util.ArrayDeque; import java.util.Arrays; import java.util.Scanner; /** * * @author Administrator */ public class Main { /** * @param args the command line arguments */ public static double plzh(int a,int b){ double fenzi=1,fenmu=1; for(int i=b;i>=a;i--){ fenzi*=i; } for(int i=1;i<=a;i++){ fenmu*=i; } return fenzi/fenmu; } public static void main(String[] args) { // TODO code application logic long res; Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int count=0; int book[]=new int[5]; for(int i=0;i<5;i++){ book[i]=0; } for(int i=0;i<n;i++){ String s=sc.next(); char c=s.charAt(0); if(c=='M') book[0]++; else if(c=='A') book[1]++; else if(c=='R') book[2]++; else if(c=='C') book[3]++; else if(c=='H') book[4]++; } res=book[0]*book[1]*book[2]+book[0]*book[1]*book[3]+book[0]*book[1]*book[4]+book[0]*book[2]*book[3]+book[0]*book[2]*book[4]+book[0]*book[3]*book[4]+book[1]*book[2]*book[3]+book[1]*book[2]*book[4]+book[1]*book[3]*book[4]+book[2]*book[3]*book[4]; System.out.println(res); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N, num1 = 0; cin >> N; string s; int num[5] = {0}; for (int i = 0; i < N; i++) { cin >> s; if (s[0] == 'M') { num[0]++; } else { if (s[0] == 'A') { num[1]++; } else { if (s[0] == 'R') { num[2]++; } else { if (s[0] == 'C') { num[3]++; } else { if (s[0] == 'H') { num[4]++; } } } } } } sort(num, num + 5); for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { if (num[i] > 0) { if (num[j] > 0) { if (num[k] > 0) { num1 += num[i] * num[j] * num[k]; } } } } } } cout << num1 << 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 str[1000]; int a[10000]; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%s", str); if (str[0] == 'M') a[0]++; if (str[0] == 'A') a[1]++; if (str[0] == 'R') a[2]++; if (str[0] == 'C') a[3]++; if (str[0] == 'H') a[4]++; } int ans = 0; for (int s = 0; s < (1 << 5); s++) { int cnt = 0; for (int j = 0; j < 5; j++) cnt += ((s & (1 << j)) != 0); if (cnt == 3) { int ttt = 1; for (int i = 0; i < 5; i++) { if (s & (1 << i)) { ttt *= a[i]; } } ans += ttt; } } 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
UNKNOWN
<?php $n = trim(fgets(STDIN)); $count = []; $march=["M","A","R","C","H"]; for($i=0; $i<$n; $i++){ $s = trim(fgets(STDIN)); if(in_array($s[0],$march)){ $count[$s[0]]++; } } // print_r($count); $c = count($count); if($c == 3){ $c = 1; $ans = $c; }else if($c < 3){ echo "0"; exit; }else{ $ans = $c; $c--; } foreach ($count as $d){ if($d > 1){ $ans += ($d-1)*$c; } } echo $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 P[10] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2}; int Q[10] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3}; int R[10] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4}; int main() { int n; cin >> n; int m, a, r, c, h = 0; for (int i = 0; i < n; i++) { string name; 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++; } } int result = 0; int v[5] = {m, a, r, c, h}; for (int i; i < 10; i++) { result += v[P[i]] * v[Q[i]] * v[R[i]]; } cout << result << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
use std::io::*; use std::str::FromStr; use std::collections::HashMap; use std::collections::BTreeSet; use std::collections::HashSet; use std::cmp; use std::f64::consts; fn main() { let n: i64 = read(); let mut vec: Vec<String> = (0..n).map(|_| read()).collect(); let mut map: HashMap<char, i64> = HashMap::new(); map.insert('M', 0); map.insert('A', 0); map.insert('R', 0); map.insert('C', 0); map.insert('H', 0); let march_vec = vec!['M', 'A', 'R', 'C', 'H']; for s in vec.iter() { let char_vec: Vec<char> = s.chars().collect(); let first_letter = char_vec[0]; if march_vec.contains(&first_letter) { let count = map.get(&first_letter).unwrap(); map.insert(first_letter, count+1); } } let mut count = 0; for i in 0..i64::pow(2, march_vec.len() as u32) { let mut each_vec: Vec<char> = Vec::new(); for j in 0..march_vec.len() { if (1 & i >> j) == 1 { each_vec.push(march_vec[j].clone()); } } let mut each_count = 1; if each_vec.len() == 3 { for s in each_vec.iter() { let val = map.get(s).unwrap(); each_count *= val; } count+=each_count; } } println!("{:?}", count); } fn read<T: FromStr>() -> T { let stdin = stdin(); let stdin = stdin.lock(); let token: String = stdin .bytes() .map(|c| c.expect("failed to read char") as char) .skip_while(|c| c.is_whitespace()) .take_while(|c| !c.is_whitespace()) .collect(); token.parse().ok().expect("failed to parse token") } // 最大公約数 fn gcd(a: i32, b: i32) -> i32 { match b { 0 => a, _ => gcd(b, a % b) } } // 最小公倍数 fn lcm(a: i32, b: i32) -> i32 { a * b / gcd(a, b) } // 階乗 fn kaijou(n: i32)->i32 { if n == 1 { return n; } return n * kaijou(n-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
python3
import itertools as ite N=int(input()) C=[0]*(N+1) J="MARCH" for i in range(N): C[J.find(input()[0])]+=1 ans=0 for i,j,k in list(ite.combinations(range(5),3)): ans+=C[i]*C[j]*C[k] print(ans)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.io.BufferedReader; import java.util.*; public class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int M = 0; int A = 0; int R = 0; int C = 0; int H = 0; for(int i = 0; i < N; i++) { String Si = sc.next(); switch(Si.substring(0, 1)) { case "M": M++; break; case "A": A++; break; case "R": R++; break; case "C": C++; break; case "H": H++; break; } } long answer = 0; answer = M*A*R; answer += M * A * C; answer += M * A * H; answer += M * R * C; answer += M * R * H; answer += M * C * H; answer += A * R * C; answer += A * R * H; answer += A * C * H; answer += R * C * H; System.out.println(answer); } }
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); int arr[25] = {0}; while (n--) { char c[11] = {0}; scanf("%s", c); if (c[0] == 'M') arr[0]++; if (c[0] == 'A') arr[1]++; if (c[0] == 'R') arr[2]++; if (c[0] == 'C') arr[3]++; if (c[0] == 'H') arr[4]++; } long long int ans = 1; long long int tol = 0; for (int i = 0; i < 5; i++) { if (arr[i] != 0) tol++; } if (tol < 3) ans = 0ll; else if (tol == 3) { for (int i = 0; i < 5; i++) { if (arr[i] != 0) ans *= arr[i]; } } else if (tol == 4) { ans--; int tep[10] = {0}; int t = 0; for (int i = 0; i < 5; i++) { if (arr[i] != 0) tep[t++] = arr[i]; } ans += tep[0] * tep[1] * tep[2]; ans += tep[0] * tep[1] * tep[3]; ans += tep[1] * tep[2] * tep[3]; ans += tep[0] * tep[3] * tep[2]; } else { ans--; int tep[10] = {0}; for (int i = 0; i < 5; i++) { tep[i] = arr[i]; } ans += tep[0] * tep[1] * tep[2]; ans += tep[0] * tep[1] * tep[3]; ans += tep[0] * tep[1] * tep[4]; ans += tep[1] * tep[2] * tep[3]; ans += tep[4] * tep[2] * tep[3]; ans += tep[0] * tep[3] * tep[2]; ans += tep[0] * tep[4] * tep[2]; ans += tep[1] * tep[3] * tep[4]; ans += tep[1] * tep[2] * tep[4]; ans += tep[0] * tep[3] * tep[4]; } printf("%lld\n", 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
java
import java.util.HashMap; import java.util.Map; import java.util.Scanner; public class Main { private static Map<Character, Integer> map = new HashMap<Character, Integer>() { { put('M', 0); put('A', 1); put('R', 2); put('C', 3); put('H', 4); } }; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); String[] s = new String[n]; long[] cnt = new long[n]; for (int i = 0; i < n; i++) { s[i] = sc.next(); char c = s[i].charAt(0); if (c == 'M' || c == 'A' || c == 'R' || c == 'C' || c == 'H') { cnt[map.get(c)]++; } } long sum = 0; for (int i = 0; i < map.size(); i++) { for (int j = i + 1; j < map.size(); j++) { for (int k = j + 1; k < map.size(); k++) { sum += cnt[i] * cnt[j] * cnt[k]; } } } System.out.println(sum); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> march(5); for (int i = 0; i < N; i++) { string s; cin >> s; char c = s.at(0); if (c == 'M') { march.at(0)++; } else if (c == 'A') { march.at(1)++; } else if (c == 'R') { march.at(2)++; } else if (c == 'C') { march.at(3)++; } else if (c == 'H') { march.at(4)++; } } long long int res = 0; for (int f = 0; f < 3; f++) { for (int s = f + 1; s < 4; s++) { for (int t = s + 1; t < 5; t++) { res += march.at(f) * march.at(s) * march.at(t); } } } cout << res << 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; int m[5] = {}; for (int i = 0; i < n; i++) { string s; cin >> s; if (s[0] == 'M') { m[0]++; } else if (s[0] == 'A') { m[1]++; } else if (s[0] == 'R') { m[2]++; } else if (s[0] == 'C') { m[3]++; } else if (s[0] == 'H') { m[4]++; } } int cnt = 0; for (int i = 0; i < 5; i++) { if (m[i] > 0) { cnt++; } } if (cnt < 3) { cout << 0 << '\n'; return 0; } int ans = m[0] * m[1] * m[2] + m[0] * m[1] * m[3] + m[0] * m[2] * m[3] + m[1] * m[2] * m[3] + m[0] * m[1] * m[4] + m[0] * m[2] * m[4] + m[0] * m[3] * m[4] + m[1] * m[2] * m[4] + m[1] * m[3] * m[4] + m[2] * m[3] * m[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
python3
#pypyは内包表記使わない def main(): import sys #input = sys.stdin.readline sys.setrecursionlimit(10000000) from collections import Counter, deque #from collections import defaultdict from itertools import combinations, permutations #from itertools import accumulate, product from bisect import bisect_left,bisect_right from math import floor, ceil #from operator import itemgetter #mod = 1000000007 N = int(input()) M = 0 A = 0 R = 0 C = 0 H = 0 for _ in range(N): s = input().rstrip() if s[0]=='M': M += 1 elif s[0]=='A': A += 1 elif s[0]=='R': R += 1 elif s[0]=='C': C += 1 else: H += 1 res = 0 l = [M, A, R, C, H] for a, b, c in combinations(l, 3): res += a*b*c print(res) if __name__ == '__main__': main()
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> template <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; } using namespace std; using P = pair<int, int>; using ll = long long; const ll INF = 1LL << 60; const double PI = 3.1415926535897932; const int MOD = 1e9 + 7; int main() { int n; cin >> n; map<char, ll> mci; 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') { continue; } mci[s[0]]++; } if (mci.size() < 3) { cout << 0 << endl; return 0; } ll ans = 1; for (auto v : mci) { ans *= v.second; } 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; map<char, int> mp; int main() { int N; cin >> N; string s; for (int i = 0; i < N; i++) { cin >> s; mp[s[0]]++; } vector<int> v(5); v[0] = mp['M']; v[1] = mp['A']; v[2] = mp['R']; v[3] = mp['C']; v[4] = mp['H']; long long int 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 += 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
UNKNOWN
#include <bits/stdc++.h> using namespace std; long long x[6]; long long fact(long long n) { if (n == 0) { return 1; } return n * fact(n - 1); } int main() { long long n, m, a, b, c = 0; string s; cin >> n; for (int i = 0; i < n; i++) { cin >> s; if (s[0] == 'M') { x[1]++; } if (s[0] == 'A') { x[2]++; } if (s[0] == 'R') { x[3]++; } if (s[0] == 'C') { x[4]++; } if (s[0] == 'H') { x[5]++; } } b = fact(x[1] + x[2] + x[3] + x[4] + x[5]); if (b == 1) { cout << 0; return 0; } for (int i = 1; i <= 5; i++) { b = b / fact(x[i]); } cout << b / n; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { long long 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
UNKNOWN
use std::io::*; use std::str::FromStr; fn read<T: FromStr>() -> T { let stdin = stdin(); let stdin = stdin.lock(); let token: String = stdin .bytes() .map(|c| c.expect("filed to read char") as char) .skip_while(|c| c.is_whitespace()) .take_while(|c| !c.is_whitespace()) .collect(); token.parse().ok().expect("failed to parse token") } fn main() { let n:usize = read(); let mut arr = vec![0; 5]; for _ in 0..n { let s:String = read(); let tmp:Vec<char> = s.chars().collect(); match tmp[0] { 'M' => arr[0] += 1, 'A' => arr[1] += 1, 'R' => arr[2] += 1, 'C' => arr[3] += 1, 'H' => arr[4] += 1, _ => () } } let mut ans = 0; for i in 0..5 { for j in 0..i { for k in 0..j { ans += arr[i] * arr[j] * arr[k]; } } } println!("{}", ans); }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> int main(void) { char s[10001][11]; int n, i, m, a, r, c, h; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%s", &s[i]); if (s[i][0] == 'M') m = m + 1; if (s[i][0] == 'A') a = a + 1; if (s[i][0] == 'R') r = r + 1; if (s[i][0] == 'C') c = c + 1; if (s[i][0] == 'H') h = h + 1; } printf("%lld\n", 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); 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[5] = {0}; string A = "MARCH"; cin >> N; string S[N]; for (int i = 0; i < N; i++) { string s; cin >> s; for (int j = 0; j < 5; j++) { if (A[j] == s[0]) a[j]++; } } 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 << "\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; const int dx[] = {1, -1, 0, 0}; const int dy[] = {0, 0, -1, 1}; template <typename T> void printA(vector<T> &printArray, char between = ' ') { int paSize = printArray.size(); for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between; } if (between != '\n') { cerr << endl; } } long long kai(long long x) { long long ret = 1; while (x > 0) { ret *= x; x--; } return ret; } int main() { long long n; cin >> n; string march = "MARCH"; map<char, int> m; for (int(i) = (0); (i) < (n); ++(i)) { string s; cin >> s; char c = s[0]; if (c == 'M' || c == 'A' || c == 'R' || c == 'C' || c == 'H') { m[s[0]]++; } } long long a[5] = {0}; int cnt = 0; for (auto x : m) { a[cnt] = x.second; cnt++; } long long t = kai(3); long long sum = 0; for (int(i) = (0); (i) < (3); ++(i)) { for (int(j) = (i + 1); (j) < (4); ++(j)) { if (i == j) continue; for (int(k) = (j + 1); (k) < (5); ++(k)) { if (j == k) continue; if (a[i] == 0 || a[j] == 0 || a[k] == 0) continue; long long b = a[i] + a[j] + a[k]; sum += max(0LL, b - 2); } } } 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; int main() { int n; cin >> n; vector<string> s(n); int march[5] = {}; for (int i = (0); i < (n); ++i) { cin >> s[i]; if (s[i][0] == 'M') march[0]++; if (s[i][0] == 'A') march[1]++; if (s[i][0] == 'R') march[2]++; if (s[i][0] == 'C') march[3]++; if (s[i][0] == 'H') march[4]++; } 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++) { sum += march[i] * march[j] * march[k]; } } } cout << (sum) << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; using Graph = vector<vector<int>>; using P = pair<int, int>; int main() { int n; cin >> n; string s = "MARCH"; int c[5] = {0}; for (int i = 0; i < (n); i++) { string t; cin >> t; for (int j = 0; j < (5); j++) { if (t[0] == s[j]) { c[j]++; } } } 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 += 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
python3
import copy from itertools import combinations N=int(input()) S=list(input()[0] for _ in range(N)) cS=copy.deepcopy(S) ans=0 for i in cS: if i not in ['M', 'A', 'R', 'C', 'H']: S.remove(i) P=list(combinations(S,3)) for i in P: 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; string s[10000]; long long m = 0, a = 0, r = 0, c = 0, h = 0; for (int i = 0; i < n; i++) { cin >> s[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++; } 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 << 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
from collections import defaultdict from scipy.misc import comb #ID b = defaultdict(lambda: len(b)) n = int(input()) hed = ["M","A","R","C","H"] for i in hed: b[i] li = [0]*5 for _ in range(n): a = input() if a[0] in hed: li[b[a[0]]] += 1 c = [i for i in li if i != 0] print(int(comb(len(c),3))*2 -int(comb(len(c)-1,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
python3
from collections import Counter from itertools import combinations n = int(input()) l = [input()[0] for _ in range(n)] lc = Counter(l) print(lc) con = [] for c in "MARCH": if c in lc: con.append(lc[c]) ans = 0 for a, b, c in combinations(con, 3): ans += a * b * c 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; const long long mod = 1e9 + 7; long long N, ans; string s; map<char, int> m; int main() { cin >> N; for (int i = 0; i < N; i++) { cin >> s; m[s[0]]++; } ans += m['M'] * m['H'] * m['R']; ans += m['M'] * m['H'] * m['C']; ans += m['M'] * m['H'] * m['A']; ans += m['M'] * m['R'] * m['C']; ans += m['M'] * m['R'] * m['A']; ans += m['M'] * m['A'] * m['C']; ans += m['A'] * m['H'] * m['C']; ans += m['R'] * m['H'] * m['C']; ans += m['A'] * m['R'] * m['C']; ans += m['A'] * m['H'] * m['R']; ans = max<long long>(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 <bits/stdc++.h> using namespace std; int main() { long long n, m, a, r, c, h; string s; cin >> n; map<char, long long> mp; for (int i = 0; i < n; i++) { cin >> s; mp[s[0]]++; } m = mp['m'], a = mp['a'], r = mp['r'], c = mp['c'], h = mp['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; }
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 i, N; string S; int M = 0, A = 0, R = 0, C = 0, H = 0; cin >> N; for (i = 0; i < N; ++i) { cin >> S; if (S[0] == 'M') ++M; else if (S[0] == 'A') ++A; else if (S[0] == 'R') ++R; else if (S[0] == 'C') ++C; else if (S[0] == 'H') ++H; } long int total; total = 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 << total << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
def nodup(a, b, c) !(a.chr == b.chr || b.chr == c.chr || c.chr == a.chr) end s = [] while line = gets s.push(line.chomp) if 'MARCH'.split('').include?(line.chr) end count = 0 0.upto(s.length - 3) do |i| (i + 1).upto(s.length - 2) do |j| (j + 1).upto(s.length - 1) do |k| count += 1 if nodup(s[i], s[j], s[k]) end end end puts 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
java
import java.io.IOException; import java.io.InputStream; import java.util.NoSuchElementException; public class Main { public static void main(String[] args) { new Main().solve(); } void solve() { FastScanner sc = new FastScanner(); int N = sc.nextInt(); long count = 0; char[] march = new char[] {'M','A','R','C','H'}; for (int i = 0; i < N; i++) { String s = sc.next(); for (char t : march) if (s.charAt(0) == t) count++; } long ans = count * (count-1) / 2; out(ans); } class Combination { final int mod; final int max; final long[] fact; final long[] inv; final long[] invfact; public Combination(int n) { this(n, 1_000_000_007); } public Combination(int n, int mod) { this.mod = mod; max = n + 1; fact = new long[max]; invfact = new long[max]; inv = new long[max]; inv[1] = 1; for (int i = 2; i < inv.length; i++) { inv[i] = inv[mod % i] * (mod - mod / i) % mod; } fact[0] = 1; invfact[0] = 1; for (int i = 1; i < inv.length; i++) { fact[i] = i * fact[i - 1] % mod; invfact[i] = inv[i] * invfact[i - 1] % mod; } } public long get(int n, int r) { return fact[n] * invfact[n - r] % mod * invfact[r] % mod; } } public long gcd(long a, long b) { long remainder = a % b; if (remainder == 0) { return b; } else { return gcd(b, remainder); } } void out(String a) { System.out.println(a); } void out(int a) { System.out.println(a); } void out(long a) { System.out.println(a); } void out(double a) { System.out.println(a); } void out(char a) { System.out.println(a); } } class FastScanner { private final InputStream in = System.in; private final byte[] buffer = new byte[1024]; private int ptr = 0; private int buflen = 0; private boolean hasNextByte() { if (ptr < buflen) { return true; } else { ptr = 0; try { buflen = in.read(buffer); } catch (IOException e) { e.printStackTrace(); } if (buflen <= 0) { return false; } } return true; } private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1; } private boolean isPrintableChar(int c) { return 33 <= c && c <= 126; } public boolean hasNext() { while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte(); } public String next() { if (!hasNext()) throw new NoSuchElementException(); StringBuilder sb = new StringBuilder(); int b = readByte(); while (isPrintableChar(b)) { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } public long nextLong() { if (!hasNext()) throw new NoSuchElementException(); long n = 0; boolean minus = false; int b = readByte(); if (b == '-') { minus = true; b = readByte(); } if (b < '0' || '9' < b) { throw new NumberFormatException(); } while (true) { if ('0' <= b && b <= '9') { n *= 10; n += b - '0'; } else if (b == -1 || !isPrintableChar(b)) { return minus ? -n : n; } else { throw new NumberFormatException(); } b = readByte(); } } public int nextInt() { long nl = nextLong(); if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException(); return (int) nl; } public double nextDouble() { return Double.parseDouble(next()); } }
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[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; 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; } int main() { string S = "MARCH"; int c[5] = {0}; int N; cin >> N; for (int i = 0; i < (N); i++) { string T; cin >> T; for (int j = 0; j < (5); j++) { if (T[0] == S[j]) c[j]++; } } int ans = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { ans += c[i] * c[j] * c[k]; } } } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
import numpy as np N = int(input()) S = [None]*5 for i in range(N): S[i] = input() S_M = [S[i] for i in range(N) if S[i][0] == 'M'] S_A = [S[i] for i in range(N) if S[i][0] == 'A'] S_R = [S[i] for i in range(N) if S[i][0] == 'R'] S_C = [S[i] for i in range(N) if S[i][0] == 'C'] S_H = [S[i] for i in range(N) if S[i][0] == 'H'] souwa = 0 kahi = [0]*5 kahi[0] = len(S_M) kahi[1] = len(S_A) kahi[2] = len(S_R) kahi[3] = len(S_C) kahi[4] = len(S_H) kahi_not0 = kahi[kahi != 0] if len(kahi_not0) <= 2: print(0) else: for i in range(len(kahi_not0)-2): for j in range(i+1, len(kahi_not0)-1): for k in range(j+1, len(kahi_not0)): souwa += kahi_not0[i]*kahi_not0[j]*kahi_not0[k] if souwa >= 2**32: print(souwa/(2**32), end='') print(souwa-(souwa/(2**32))*(2**32)) else: print(souwa)
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 march[] = {'M', 'A', 'R', 'C', 'H'}; int cnt[] = {0, 0, 0, 0, 0}; int main() { cin >> n; for (int i = 0; i < n; ++i) { string name; cin >> name; for (int k = 0; k < 5; ++k) { if (name[0] == march[k]) { cnt[k]++; } } } long long ans; int bit; while (bit < 32) { int c = 0; for (int i = 0; i < 5; ++i) { c += (bit >> i) & 1; } if (c == 3) { long long tmp = 1; for (int i = 0; i < 5; ++i) { if ((bit >> i) & 1) tmp *= cnt[i]; } ans += tmp; } bit++; } 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 abc(int a, int b) { int x = 0; for (int i = b; i <= a; i++) { for (int j = b; j <= a; j++) { if (j % i >= b) x++; } } return x; } int main() { int a; long long ans = 0; string s[100000]; cin >> a; for (int i = 0; i < (a); i++) { cin >> s[i]; } for (int i = 0; i < (a); i++) { for (int j = 0; j < (a); j++) { for (int l = 0; l < (a); l++) { if ((s[i][0] == 'M' || s[i][0] == 'A' || s[i][0] == 'R' || s[i][0] == 'C' || s[i][0] == 'H') && (s[j][0] == 'M' || s[j][0] == 'A' || s[j][0] == 'R' || s[j][0] == 'C' || s[j][0] == 'H') && (s[l][0] == 'M' || s[l][0] == 'A' || s[l][0] == 'R' || s[l][0] == 'C' || s[l][0] == 'H') && s[i][0] != s[j][0] && s[l][0]) ans++; } } } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt();scan.nextLine(); String[] S = new String[n]; for (int i = 0; i < n; i++) { S[i] = scan.nextLine(); } int[] s = new int[5]; for (int i = 0; i < n; i++) { if (S[i].charAt(0) == 'M') s[0]++; else if (S[i].charAt(0) == 'A') s[1]++; else if (S[i].charAt(0) == 'R') s[2]++; else if (S[i].charAt(0) == 'C') s[3]++; else if (S[i].charAt(0) == 'H') s[4]++; } long ans = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { ans += s[i]*s[j]*s[k]; } } } System.out.println(ans); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include "bits/stdc++.h" // Begin {{{ using namespace std; #define all(x) x.begin(), x.end() #define rep(i, n) for (i64 i = 0; i < (n); ++i) #define reps(i, b, e) for (i64 i = (b); i <= (e); ++i) #define repr(i, b, e) for (i64 i = (b); i >= (e); --i) #define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__) #ifdef DEBUG #define dump(...) dump_(#__VA_ARGS__, __VA_ARGS__); #else #define dump(...) #endif using i64 = int_fast64_t; using pii = pair<i64, i64>; template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); } template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); } constexpr int INF = 0x3f3f3f3f; constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL; constexpr int MOD = int(1e9) + 7; // input void input() {} template <class Head, class... Tail> void input(Head&& head, Tail&&... tail) { cin >> head; input(forward<Tail>(tail)...); } // outs void outs() {} template <class Head, class... Tail> void outs(Head&& head, Tail&&... tail) { cout << head << " \n"[sizeof...(tail)==0]; outs(forward<Tail>(tail)...); } template <class T> void outs(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; } template <class T> void outs(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); } // outl void outl() {} template <class Head, class... Tail> void outl(Head&& head, Tail&&... tail) { cout << head << "\n"; outl(forward<Tail>(tail)...); } template <class T> void outl(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; } // outn void outn() {} template <class Head, class... Tail> void outn(Head&& head, Tail&&... tail) { cout << head; outn(forward<Tail>(tail)...); } template <class T> void outn(vector<T> &vec) { for (auto &e : vec) cout << e; } // dump template <class T> void dump_(const char *s, T&& x) { clog << '{'; while(*s != '\0') clog << *(s++); clog << ": " << x << '}' << "\n"; } template <class Head, class... Tail> void dump_(const char *s, Head&& head, Tail&&... tail) { clog << '{'; while(*s != ',') clog << *(s++); clog << ": " << head << "}, "; for (++s; !isgraph(*s); ++s); dump_(s, forward<Tail>(tail)...); } // }}} End // Mint {{{ template <i64 MOD> class ModInt { i64 value; public: inline ModInt(const ModInt& other) noexcept : value(other.value) {} inline ModInt(i64 value = 0) noexcept : value((value >= MOD) ? value % MOD : (value < 0) ? (value + MOD) % MOD : value) {} inline ModInt inv() const noexcept { return power(value, MOD - 2); } inline ModInt& operator+=(const ModInt& other) noexcept { value = (value + other.value) % MOD; return *this; } inline ModInt& operator-=(const ModInt& other) noexcept { value = (MOD + value - other.value) % MOD; return *this; } inline ModInt& operator*=(const ModInt& other) noexcept { value = (value * other.value) % MOD; return *this; } inline ModInt& operator/=(const ModInt& other) noexcept { value = (value * other.inv().value) % MOD; return *this; } inline ModInt operator+(const ModInt& other) noexcept { return ModInt(*this) += other; } inline ModInt operator-(const ModInt& other) noexcept { return ModInt(*this) -= other; } inline ModInt operator*(const ModInt& other) noexcept { return ModInt(*this) *= other; } inline ModInt operator/(const ModInt& other) noexcept { return ModInt(*this) /= other; } inline bool operator==(const ModInt& other) noexcept { return value == *other; } inline bool operator!=(const ModInt& other) noexcept { return value != *other; } template <class int_> explicit inline operator int_() const noexcept { return static_cast<int_>(value); } friend ostream& operator<<(ostream &os, ModInt other) noexcept { os << other.value; return os; } friend istream& operator>>(istream &is, ModInt& other) noexcept { is >> other.value; return is; } static constexpr inline ModInt power(i64 n, i64 p) noexcept { i64 ret = 1; for (; p > 0; p >>= 1) { if (p & 1) ret = (ret * n) % MOD; n = (n * n) % MOD; } return ret; } }; using Mint = ModInt<int(1e9) + 7>; // }}} // Factorial {{{ #ifdef DEBUG #define constexpr #endif template <size_t N, int M> struct Factorial { uint_fast64_t fact_[N+1]; constexpr inline Factorial() : fact_{1} { for (i64 i = 1; i <= N; ++i) fact_[i] = (fact_[i-1] * i) % M; } constexpr inline Mint operator[] (size_t pos) const { return fact_[pos]; } }; template <size_t N, int M> struct InvFact { uint_fast64_t inv_[N+1]; uint_fast64_t finv_[N+1]; constexpr inline InvFact() : inv_{0, 1}, finv_{1, 1} { for (i64 i = 2; i <= N; ++i) { inv_[i] = M - inv_[M%i] * (M / i) % M; finv_[i] = finv_[i-1] * inv_[i] % M; } } constexpr inline Mint operator[] (size_t pos) const { return finv_[pos]; } }; #ifdef constexpr #undef constexpr #endif Factorial<510000, MOD> fact; InvFact<510000, MOD> finv; Mint nCr(int n, int r) { if (n < r) return 0; if (n < 0 || r < 0) return 0; return fact[n] * (finv[r] * finv[n-r]); } Mint nPr(int n, int r) { if (n < r) return 0; if (n < 0 || r < 0) return 0; return fact[n] * finv[r]; } // }}} signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); var(int, N); map<char, i64> cnt; rep(i, N) { var(string, s); ++cnt[s.front()]; } i64 res = 0; string march = "MARCH"; for (int i = 0; i < 5; ++i) { for (int j = i + 1; j < 5; ++j) { for (int k = j + 1; k < 5; ++k) { i64 c1 = cnt[march[i]], c2 = cnt[march[j]], c3 = cnt[march[k]]; if (c1 && c2 && c3) { res += max({c1, c2, c3}); } } } } outl(res); 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; string s; cin >> n; int m, a, r, c, h; m = a = r = c = h = 0; for (int i = 0; i < n; i++) { cin >> s; if (s[0] == 'M') m++; if (s[0] == 'A') a++; if (s[0] == 'R') r++; if (s[0] == 'C') c++; if (s[0] == 'H') h++; } unsigned int 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; int main() { int N; cin >> N; vector<string> S(N); vector<int> march(5); for (int i = 0; i < N; i++) { cin >> S.at(i); if (S.at(i).at(0) == 'M') march.at(0)++; else if (S.at(i).at(0) == 'A') march.at(1)++; else if (S.at(i).at(0) == 'R') march.at(2)++; else if (S.at(i).at(0) == 'C') march.at(3)++; else if (S.at(i).at(0) == 'H') march.at(4)++; } long long ans = 0; for (int i = 0; i < 5 - 2; i++) { for (int j = i + 1; j < 5 - 1; j++) { for (int k = j + 1; k < 5; k++) { ans += march.at(i) * march.at(j) * march.at(k); } } } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int N; cin >> N; vector<string> S; for (int i = 0; i < N; ++i) { string x; cin >> x; S.push_back(x); } int m = 0; int a = 0; int r = 0; int c = 0; int h = 0; for (int i = 0; i < N; ++i) { if (S[i].at(0) == 'M') { ++m; } else if (S[i].at(0) == 'A') { ++a; } else if (S[i].at(0) == 'R') { ++r; } else if (S[i].at(0) == 'C') { ++c; } else if (S[i].at(0) == 'H') { ++h; } } long long answer = m * a * r + m * a * c + m * a * h + m * r * c + m * r * h + m * c * h + a * r * c + a * r * h + a * c * h + r * c * h; cout << answer << endl; 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=[input() for i in range(n)] cnt=[0]*5 for t in s: if t[0]=='M': cnt[0]+=1 elif t[0]=='A': cnt[1]+=1 elif t[0]=='R': cnt[2]+=1 elif t[0]=='C': cnt[3]+=1 elif t[0]=='H': cnt[4]+=1 ans=0 for v in itertools.combinations([0,1,2,3,4],3): ans+=cnt[v[0]]*cnt[v[1]]*cnt[v[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
import itertools def main(): n = int(input()) m = 0 a = 0 r = 0 c = 0 h = 0 for _ in range(n): s = input() if(s[0] == "M"): m += 1 elif(s[0] == "A"): a += 1 elif(s[0] == "R"): r += 1 elif(s[0] == "C"): c += 1 elif(s[0] == "H"): h += 1 T = [m, a, r, c, h] ans = 0 for i in range(3): for j in range(i + 1, 4): for k in range(j + 1, 5): ans += T[i] * T[j] * T[k] print(ans) if __name__ == "__main__": main()
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.Text; using System.Collections.Generic; using System.Linq; using E = System.Linq.Enumerable; class Program { static int[] A; static void Main(string[] args) { //入力を受け取る var N = int.Parse(Console.ReadLine()); var march = new int[5]; for(int i = 0; i < N; i++){ var str = Console.ReadLine(); var sento = str[0]; if(sento == 'M'){ march[0]++; }else if(sento == 'A'){ march[1]++; }else if(sento == 'R'){ march[2]++; }else if(sento == 'C'){ march[3]++; }else if(sento == 'H'){ march[4]++; } } var 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++){ //Console.WriteLine("i:"+i+"j:"+j+"k:"+k); ans += march[i]*march[j]*march[k]; } } } 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
python3
N = int(input()) S = [str(input()) for i in range(N)] ans_list = [0 for i in range(5)] carList = ['M', 'A', 'R', 'C', 'H'] for s in S: for i, c in enumerate(carList): if s[0] == c: ans_list[i] += 1 ans_list = [a for a in ans_list if a != 0] ans = 1 for i, v in enumerate(ans_list): ans *= v if len(ans_list) < 3: print(0) elif len(ans_list) == 3: print(ans_list[0]*ans_list[1]*ans_list[2]) elif len(ans_list) == 4: tmp = 0 for i, v in enumerate(ans_list): tmp += ans // v print(tmp) else: tmp = 0 for i in range(5): for j in range(5): if i != j: tmp += ans // (ans_list[i]*ans_list[j]) print(tmp)
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 check[5] = {'M', 'A', 'R', 'C', 'H'}; int main() { int n; cin >> n; int num[n]; fill(num, num + n, 0); string tmp; for (int i = 0; i < n; i++) { cin >> tmp; for (int j = 0; j < 5; j++) { if (tmp[0] == check[j]) num[j]++; } } long long sum = 0; for (int i = 0; i < (1 << 5); i++) { bool alt[5]; long long hoge = 0; for (int j = 0; j < 5; j++) alt[j] = ((i & (1 << j)) != 0); for (int j = 0; j < 5; j++) if (alt[j]) hoge++; if (hoge != 3) continue; hoge = 1; for (int j = 0; j < 5; j++) { if (alt[j]) hoge *= num[j]; } sum += hoge; } 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; typedef long long ll; using Graph = vector<vector<ll>>; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } vector<ll> dy = {0, 0, -1, 1, 0}; vector<ll> dx = {-1, 1, 0, 0, 0}; vector<ll> factorial = {}; vector<ll> factorialInverse = {}; vector<ll> INV(ll n) { vector<ll> v(n); for (ll i = 0; i < n; i++) cin >> v[i]; return v; } vector<vector<ll>> INV2(ll n, ll map<ll, ll>) { vector<vector<ll>> v(n, vector<ll>(map<ll, ll>)); for (ll i = 0; i < n; i++) { for (ll j = 0; j < map<ll, ll>; j++) { cin >> v[i][j]; } } return v; } bool isOK(vector<ll> &v, int index, int key) { if (v[index] >= key) return true; else return false; } ll bs(vector<ll> &v, ll key) { int ng = -1; int ok = ((int)(v).size()); while (abs(ok - ng) > 1) { int mid = (ok + ng) / 2; if (isOK(v, mid, key)) ok = mid; else ng = mid; } return ok; } ll gcd(ll a, ll b) { if (a < b) swap(a, b); ll r = a % b; while (r != 0) { a = b; b = r; r = a % b; } return b; } void lcm(ll a, ll b) {} bool is_prime(ll n) { bool flg = true; if (n <= 1) flg = false; else if (n == 2) flg = true; else if (n % 2 == 0) flg = false; else { for (ll i = 3; i * i <= n; i += 2) { if (n % i == 0) flg = false; } } return flg; } vector<ll> prime_factorization(ll n) { vector<ll> cnt_pf(sqrt(n), 0); for (ll i = 1; i < ((int)(cnt_pf).size()); i++) { while (n % (i + 1) == 0) { cnt_pf[i]++; n /= (i + 1); } if (n == 1) break; } if (n != 1) { cnt_pf[0] = n; } return cnt_pf; } vector<vector<ll>> map_vec(vector<string> &str) { vector<vector<ll>> v( ((int)(str).size()), vector<ll>(((int)(str[distance(str.begin(), max_element(str.begin(), str.end()))]) .size()), (int)(1e9))); for (ll i = 0; i < ((int)(str).size()); i++) { for (ll j = 0; j < ((int)(str[i]).size()); j++) { if (str[i][j] == '#') v[i][j] = -1; } } return v; } ll cnt_wall(vector<string> str) { ll cnt = 0; for (ll i = 0; i < ((int)(str).size()); i++) { for (ll j = 0; j < ((int)(str[i]).size()); j++) { if (str[i][j] == '#') cnt++; } } return cnt; } ll bfs_maze(vector<string> &str, ll s_y, ll s_x, ll g_y, ll g_x) { struct Corr { ll y; ll x; ll depth; }; queue<Corr> que; vector<vector<ll>> v( ((int)(str).size()), vector<ll>(( (int)(str[distance(str.begin(), max_element(str.begin(), str.end()))]) .size()))); v = map_vec(str); que.push({s_y, s_x, 0}); while (!que.empty()) { Corr now = que.front(); que.pop(); if (now.y == g_y && now.x == g_x) break; for (ll i = 0; i < 4; i++) { Corr next = {now.y + dy[i], now.x + dx[i], now.depth + 1}; if (0 <= (int)next.y && (int)next.y < ((int)(v).size()) && 0 <= (int)next.x && (int)next.x < ((int)(v[distance(v.begin(), max_element(v.begin(), v.end()))]) .size()) && v[(int)next.y][(int)next.x] == (1e9)) { v[(int)next.y][(int)next.x] = next.depth; que.push(next); } } } return v[(int)g_y][(int)g_x]; } vector<ll> cumulative_sum(vector<ll> a) { vector<ll> v(((int)(a).size()) + 1); v[0] = 0; for (ll i = 0; i < ((int)(a).size()); i++) { v[i + 1] = v[i] + a[i]; } return v; } ll iterativePower(ll a, ll n) { ll res = 1; while (n > 0) { if (n & 1) res = (res * a) % 1000000007LL; a = a * a % 1000000007LL; n >>= 1; } return res; } vector<ll> MODInverse(ll n, ll factN) { vector<ll> res(n + 1); res[n] = iterativePower(factN, 1000000007LL - 2); for (ll i = n - 1; i >= 0; i--) { res[i] = res[i + 1] * (i + 1) % 1000000007LL; } return res; } void factorialFunc(ll n) { factorial.push_back(1); for (ll i = 1; i < n + 1; i++) { factorial.push_back(factorial[i - 1] * i % 1000000007LL); } vector<ll> fact; fact = MODInverse(n, factorial[n]); for (ll i = 0; i < n + 1; i++) { factorialInverse.push_back(fact[i]); } } ll comb(ll n, ll r) { if (n < r) return 0; return (factorial[n] * factorialInverse[r]) % 1000000007LL * factorialInverse[n - r] % 1000000007LL; } vector<pair<char, ll>> decompose_str(string set<ll>) { vector<pair<char, ll>> moji_cnt; moji_cnt.push_back(make_pair(set<ll>[0], 0)); for (ll i = 0; i < ((int)(set<ll>).size()); i++) { if (moji_cnt.back().first == set<ll>[i]) { moji_cnt.back().second++; } else { moji_cnt.push_back(make_pair(set<ll>[i], 1)); } } return moji_cnt; } void ans_vec(vector<ll> ans) { for (ll i = 0; i < ((int)(ans).size()); i++) { cout << ans[i] << " "; } cout << endl; } void dinamic_programming(void) {} ll totalSumFirst(ll x, ll y) { x = x - 1; return (y * (y + 1) - x * (x + 1)) / 2; } ll totalSumSecond(ll x, ll y) { x = x - 1; return (y * (y + 1) * (2 * y + 1) - x * (x + 1) * (2 * x + 1)) / 6; } ll totalSumThird(ll x, ll y) { return pow(totalSumFirst(x, y), 2); } vector<ll> makeDivisors(ll n) { vector<ll> divisors; for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { divisors.push_back(i); if (i != n / i) { divisors.push_back(n / i); } } } sort(divisors.begin(), divisors.end()); return divisors; } ll shakutori(vector<ll> &v, ll x) { ll res = 0; ll n = ((int)(v).size()); ll sum = 0; ll right = 0; for (ll left = 0; left < n; left++) { while (right < n && sum + v[right] <= x) { sum += v[right]; right++; } res += (right - left); if (right == left) right++; else sum -= v[left]; } return res; } void dfs(const Graph &g, ll x) {} void bfs() {} void bitFullSearch(ll n) { for (ll bit = 0; bit < 1 << n; bit++) { vector<ll> vec; for (ll i = 0; i < n; i++) { if (bit >> i & 1) { vec.push_back(i); } } } } signed main() { ll n; cin >> n; vector<string> str(n); for (ll i = 0; i < n; i++) { cin >> str[i]; } factorialFunc(n); ll ans = 0; vector<ll> name(5, 0); ll sum = 0; for (ll i = 0; i < n; i++) { if (str[i][0] == 'M') { name[0]++; } else if (str[i][0] == 'A') { name[1]++; } else if (str[i][0] == 'R') { name[2]++; } else if (str[i][0] == 'C') { name[3]++; } else if (str[i][0] == 'H') { name[4]++; } } ans += name[0] * name[1] * name[2]; ans += name[0] * name[1] * name[3]; ans += name[0] * name[1] * name[4]; ans += name[0] * name[2] * name[3]; ans += name[0] * name[1] * name[4]; ans += name[0] * name[3] * name[4]; ans += name[1] * name[2] * name[3]; ans += name[1] * name[2] * name[4]; ans += name[1] * name[3] * name[4]; ans += name[2] * name[3] * name[4]; cout << ans << "\n"; ; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); StringBuilder sb = new StringBuilder(); int n = sc.nextInt(); int[] a = new int[5];//m a r c h String str; for (int i = 0; i < n; i++) { str = sc.next(); if (str.startsWith("M")) { a[0]++; } else if (str.startsWith("A")) { a[1]++; } else if (str.startsWith("R")) { a[2]++; } else if (str.startsWith("C")) { a[3]++; } else if (str.startsWith("H")) { a[4]++; } } 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++) { sum += a[i] * a[j] * a[k]; } } } System.out.println(sum); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; string S; int march[5] = {0}; string MARCH = "MARCH"; for (int i = 0; i < N; ++i) { cin >> S; for (int j = 0; j < 5; ++j) { if (S[0] == MARCH[j]) ++march[j]; } } int res = 0; for (int i = 0; i < 3; ++i) { for (int j = i + 1; j < 4; ++j) { for (int k = j + 1; k < 5; ++k) { res += march[i] * march[j] * march[k]; } } } cout << res << 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> #pragma GCC optimize "-O3" #pragma GCC target("avx") signed gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } using namespace std; const long long mod = 1e9 + 7; void run(); long long fact(long long n); long long combi(long long n, long long r); void init() { ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(12); } signed main() { init(); run(); return 0; } void run() { long long n; cin >> n; vector<long long> march(n, 0); string s; for (long long i = 0; i != n; ++i) { cin >> s; if (s[0] != 'M' && s[0] != 'A' && s[0] != 'R' && s[0] != 'C' && s[0] != 'H') continue; if (s[0] == 'M') ++march[0]; if (s[0] == 'A') ++march[1]; if (s[0] == 'R') ++march[2]; if (s[0] == 'C') ++march[3]; if (s[0] == 'H') ++march[4]; } long long ans = 0; for (long long i = 0; i != 5; ++i) { if (march[i] == 1) ++ans; } cout << combi(ans, 3) << endl; } long long fact(long long n) { long long sum = 1; for (long long i = 1; i <= n; ++i) { sum *= i; } return sum; } long long combi(long long n, long long r) { long long num = 1; num = fact(n) / fact(r) / fact(n - r); return num; }
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, p[5]; int main() { long long ans = 0; char s[11], ch[5] = {'M', 'A', 'R', 'C', 'H'}; cin >> n; for (int i = 0; i < n; ++i) { cin >> s; for (int k = 0; k < 5; ++k) if (s[0] == ch[k]) ++p[k]; } for (int i = 0; i < 3; ++i) { for (int j = i + 1; j < 4; ++j) { for (int k = j + 1; k < 5; ++k) { ans += p[i] * p[j] * p[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 ll = long long; int main() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(18); ll n; cin >> n; vector<ll> march(5); for (ll i = (0); i < (n); i++) { string s; cin >> s; if (s[0] == 'M') march[0]++; if (s[0] == 'A') march[1]++; if (s[0] == 'R') march[2]++; if (s[0] == 'C') march[3]++; if (s[0] == 'H') march[4]++; } ll cnt = count(march.begin(), march.end(), 0); if (cnt >= 3) { cout << 0 << "\n"; return 0; } sort(march.begin(), march.end()); ll ans = 0; if (cnt == 2) ans += march[2] * march[3] * march[4]; else if (cnt == 1) { for (ll i = (1); i < (5); i++) { ll c = 1; for (ll j = (1); j < (5); j++) { if (i != j) c *= march[j]; } ans += c; } } else { for (ll i = (0); i < (5); i++) { for (ll j = (0); j < (5); j++) { ll c = 1; for (ll k = (0); k < (5); k++) { if (j != i and k != i) c *= march[k]; } ans += c; } } ans /= 2; } cout << ans << "\n"; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
N = gets.chomp.to_i S = [] march = 'MARCH' cnt = Array.new(5,0) N.times do line = gets.chomp if march.include?(line[0]) cnt[march.index(line[0])]+=1 end end sum = 0 param = [0,0,1,3,9] 3.times do |i| if cnt[i] >= 1 tmp = cnt[i] par = 0 for j in (i+1)..4 do if cnt[j] > 0 tmp*=cnt[j] cnt[j] = 1 par += 1 end end sum+=tmp*param[par] end end print "#{sum}\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; using lint = long long; #pragma GCC target("avx2") #pragma GCC optimization("O3") #pragma GCC optimization("unroll-loops") template <typename T> lint gcd(T a, T b) { return b ? gcd(b, a % b) : a; } template <typename T> lint lcm(T a, T b) { return a * b / gcd(a, b); }; template <typename T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; } template <typename T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; } struct IoSetup { IoSetup() { ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20); cerr << fixed << setprecision(20); } } IoSetup; int main() { int n; cin >> n; string s; vector<char> correct = {'M', 'A', 'R', 'C', 'H'}; vector<string> vec; for (int i = 0; i < n; ++i) { cin >> s; for (int j = 0; j < 5; ++j) { if (s[0] == correct[j]) vec.push_back(s); } } lint ans = 0; n = (int)vec.size(); for (int i = 0; i < n; ++i) { for (int j = i + 1; j < n; ++j) { for (int k = j + 1; k < n; ++k) { if (vec[i][0] != vec[j][0] && vec[i][0] != vec[k][0] && vec[j][0] != vec[k][0]) { ++ans; } } } } 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
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s[n]; for (int i = 0; i < n; i++) { cin >> s[i]; } sort(s, s + n); int m, a, r, c, h; m = lower_bound(s, s + n, "N") - lower_bound(s, s + n, "M"); a = lower_bound(s, s + n, "B") - lower_bound(s, s + n, "A"); r = lower_bound(s, s + n, "S") - lower_bound(s, s + n, "R"); c = lower_bound(s, s + n, "D") - lower_bound(s, s + n, "C"); h = lower_bound(s, s + n, "I") - lower_bound(s, s + n, "H"); 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; 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(void) { int n; vector<long long> march(5, 0); cin >> n; for (int i = 0; i < n; i++) { string s; cin >> s; if (s[0] == 'M') march[0]++; if (s[0] == 'A') march[1]++; if (s[0] == 'R') march[2]++; if (s[0] == 'C') march[3]++; if (s[0] == 'H') march[4]++; } long long ans = 0; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { for (int k = j + 1; k < n; k++) { ans += march[i] * march[j] * march[k]; } } } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; map<char, int> m; 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') { m[s[0]]++; } } int ans = 0; ans += m['M'] * m['A'] * m['R']; ans += m['M'] * m['A'] * m['C']; ans += m['M'] * m['A'] * m['H']; ans += m['M'] * m['R'] * m['C']; ans += m['M'] * m['R'] * m['H']; ans += m['M'] * m['C'] * m['H']; ans += m['A'] * m['R'] * m['C']; ans += m['A'] * m['R'] * m['H']; ans += m['A'] * m['C'] * m['H']; ans += m['R'] * m['C'] * m['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; int main() { set<char> s; string t; map<char, int> m; int n; cin >> n; string march = "MARCH"; for (int i = 0; i < n; i++) { cin >> t; if (march.find(t[0]) == string::npos) continue; if (s.find(t[0]) == s.end()) { s.insert(t[0]); m[t[0]] = 1; } else { m[t[0]] = m[t[0]] + 1; } } vector<char> v(m.size()); int sum = 0; char cr[3]; if (m.size() < 3) { cout << 0; } else { for (int i = m.size() - 1; i > int(m.size()) - 4; i--) { v[i] = 1; } vector<int> vec(s.begin(), s.end()); set<string> oc; memset(cr, 0, sizeof(cr)); do { int tmp = 1; int cnt = 0; for (int i = 0; i < v.size(); i++) { if (v[i] == 0) continue; char c = vec[i]; int mc = m[c]; tmp *= mc; cr[cnt] = c; cnt++; } sort(cr, cr + 3); if (oc.find(cr) == oc.end()) { sum += tmp; oc.insert(cr); } } while (next_permutation(v.begin(), v.end())); cout << sum; } cout << 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> using namespace std; int main(){ long long int N; string S[110000]; char c[110000]; int a = 0; for(int i = 0; i < N; i++){ cin >> S[i]; c[i] = S[i][1]; } for(int i = 0; i < N; i++){ if(c[i] == "M" || c[i] == "A" || c[i] == "R" || c[i] == "C" || c[i] == "H"){ for(int j = i+1; j < N; j++){ if(c[i] == "M" || c[i] == "A" || c[i] == "R" || c[i] == "C" || c[i] == "H" && c[i] != c[j]){ for(int k = j+1; k < N; k++){ if(c[i] == "M" || c[i] == "A" || c[i] == "R" || c[i] == "C" || c[i] == "H" && c[i] != c[j] && c[i] != c[k] && c[j] != c[k]){ a += 1; } } } } } } cout << a << 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
#coding=utf-8 from itertools import combinations from collections import Counter def solve(n, ss): filtered_ss = list(filter(lambda x: x in "MARCH", map(lambda x:x[0], ss))) gc = Counter(filtered_ss) if len(gc) < 3: return 0 ans = 0 for permutation in combinations("MARCH", 3): if permutation[0] in gc.keys() and permutation[1] in gc.keys() and permutation[2] in gc.keys(): tmp = (gc[permutation[0]] * gc[permutation[1]] * gc[permutation[2]]) ans = ans + tmp return ans def main(): n = int(input()) ss = [] for x in range(n): ss = ss + [input()] print(solve(n, ss)) if __name__ == '__main__': main()
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
num = gets.to_i initial = {"M": 0,"A": 0,"R": 0,"C": 0,"H": 0} person = [] while num > 0 do num -= 1 n = gets.to_s[0] if n == "M"||"A"||"R"||"C"||"H" initial[n.to_sym] += 1 end end #{M: 1,A: 2,R: 1,C: 0,H: 1} initial = initial.select {|k, v| v > 0 } #{M: 1,A: 2,R: 1,H: 1} A=1 => 3 A=2 =>6 keys = initial.keys sum_1 = initial.keys.combination(3).to_a.length initial2 = initial.select {|k, v| v > 1 } initial2.each{|key, value| sum_1 = sum_1 * value } puts sum_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
UNKNOWN
N = gets.chomp.to_i S = [] march = 'MARCH' cnt = Array.new(5,0) N.times do line = gets.chomp if march.include?(line[0]) cnt[march.index(line[0])]+=1 end end sum = 0 param = [0,0,1,3,8] 3.times do |i| if cnt[i] >= 1 tmp = cnt[i] par = 0 for j in (i+1)..4 do if cnt[j] > 0 tmp*=cnt[j] cnt[j] = 1 par += 1 end end sum+=tmp*param[par] end end print "#{sum}\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 <function> 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
n=int(input()) c=0 d=set() for i in range(n): s=input() if s[0]==('M' or 'A' or 'C' or 'R' or 'H'): if s not in d: c+=1 d.add(s) ans=0 if c<3: print(ans) else: ans=(c*(c-1)*(c-2))//6
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const long long mei = (long long)1e9 + 7; int main() { long long a, b, c, d, e, k; k = 0; string s; a = 0; b = 0; c = 0; d = 0; e = 0; long long n; for (long long i = 0; i < (long long)(n); i++) { cin >> s; if (s[0] == 'M') a++; if (s[0] == 'A') b++; if (s[0] == 'R') c++; if (s[0] == 'C') d++; if (s[0] == 'H') e++; } k = a * b * c + a * b * d + a * b * e + a * c * d + a * c * e + a * d * e + b * c * d + b * c * e + b * d * e + c * d * e; cout << k; cout << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.*; public class Main { public static void main(String args[]) { // 入力 Scanner sc = new Scanner(System.in); int n = Integer.parseInt(sc.next()); String[] s = new String[n]; for (int i = 0; i < n; i++) { s[i] = sc.next(); } // 主処理 long[] count = new long[5]; for (int i = 0; i < s.length; i++) { if (s[i].startsWith("M")) { count[0]++; } else if (s[i].startsWith("A")) { count[1]++; } else if (s[i].startsWith("R")) { count[2]++; } else if (s[i].startsWith("C")) { count[3]++; } else if (s[i].startsWith("H")) { count[4]++; } } long result = 1; int kind = 0; for (int i = 0; i < count.length; i++) { if (0 < count[i]) { result *= count[i]; kind++; } } if (3 < kind) { result *= calcCombination(kind, 3); result--; } else if (kind < 3) { result = 0; } // 出力 System.out.println(result); sc.close(); } public static long calcCombination(int n, int m) { if (n < m || m < 0) { throw new IllegalArgumentException("引数の値が不正です ( n : " + n + ", m : " + m + ")"); } long c = 1; m = (n - m < m ? n - m : m); for (int ns = n - m + 1, ms = 1; ms <= m; ns++, ms++) { c *= ns; c /= ms; } return c; } }