Search is not available for this dataset
name
stringlengths
2
88
description
stringlengths
31
8.62k
public_tests
dict
private_tests
dict
solution_type
stringclasses
2 values
programming_language
stringclasses
5 values
solution
stringlengths
1
983k
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int n, a[6], ans; string s[10000]; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) cin >> s[i]; for (int i = 1; i <= n; i++) { if (s[i][0] == 'M') ++a[1]; if (s[i][0] == 'A') ++a[2]; if (s[i][0] == 'R') ++a[3]; if (s[i][0] == 'C') ++a[4]; if (s[i][0] == 'H') ++a[5]; } ans += a[1] * a[2] * a[3]; ans += a[1] * a[2] * a[4]; ans += a[1] * a[2] * a[5]; ans += a[1] * a[3] * a[4]; ans += a[1] * a[3] * a[5]; ans += a[1] * a[4] * a[5]; ans += a[2] * a[3] * a[4]; ans += a[2] * a[3] * a[5]; ans += a[3] * a[4] * a[5]; printf("%d", ans); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; int64_t ans = 0; vector<string> S(N); set<char> sc; string name = "MARCH"; for (int i = 0; i < name.size(); i++) { sc.insert(name.at(i)); } for (int i = 0; i < N; i++) { cin >> S.at(i); } for (int i = 0; i < N; i++) { if (!sc.count(S.at(i).at(0))) { continue; } for (int j = i + 1; j < N; j++) { if (S.at(i).at(0) == S.at(j).at(0)) { continue; } if (!sc.count(S.at(j).at(0))) { continue; } for (int k = j + 1; k < N; k++) { if (S.at(k).at(0) == S.at(j).at(0)) { continue; } if (S.at(k).at(0) == S.at(i).at(0)) { continue; } if (sc.count(S.at(k).at(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
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n, i, arr[5] = {0}; cin >> n; char str[15]; for (i = 0; i < n; i++) { cin >> str; if (str[0] == 'C') arr[0]++; else if (str[0] == 'A') arr[1]++; else if (str[0] == 'M') arr[2]++; else if (str[0] == 'R') arr[3]++; else if (str[0] == 'H') arr[4]++; } int k1, k2, k3, res = 0; for (k1 = 0; k1 < 5; k1++) { for (k2 = k1 + 1; k2 < 5; k2++) { for (k3 = k2 + 1; k3 < 5; k3++) { if (k1 != k2 && k2 != k3 && k3 != k1) res += arr[k1] * arr[k2] * arr[k3]; } } } 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
cpp
#include <bits/stdc++.h> using namespace std; long long low(vector<long long> a, long long b) { decltype(a)::iterator c = lower_bound(a.begin(), a.end(), b); long long d = c - a.begin(); return d; } long long upp(vector<long long> a, long long b) { decltype(a)::iterator c = upper_bound(a.begin(), a.end(), b); long long d = c - a.begin(); return d; } template <class T> void cou(vector<vector<T>> a) { long long b = a.size(); long long c = a[0].size(); for (long long i = 0; i < b; i++) { for (long long j = 0; j < c; j++) { cout << a[i][j]; if (j == c - 1) cout << endl; else cout << ' '; } } } long long wari(long long a, long long b) { if (a % b == 0) return a / b; else return a / b + 1; } long long keta(long long a) { double b = a; b = log10(b); long long c = b; return c + 1; } long long souwa(long long a) { return a * (a + 1) / 2; } long long gcm(long long a, long long b) { if (a % b == 0) return b; return gcm(b, a % b); } bool prime(long long a) { if (a < 2) return false; else if (a == 2) return true; else if (a % 2 == 0) return false; double b = sqrt(a); for (long long i = 3; i <= b; i += 2) { if (a % i == 0) { return false; } } return true; } struct Union { vector<long long> par; Union(long long a) { par = vector<long long>(a, -1); } long long find(long long a) { if (par[a] < 0) return a; else return par[a] = find(par[a]); } bool same(long long a, long long b) { return find(a) == find(b); } long long Size(long long a) { return -par[find(a)]; } void unite(long long a, long long b) { a = find(a); b = find(b); if (a == b) return; if (Size(b) > Size(a)) swap<long long>(a, b); par[a] += par[b]; par[b] = a; } }; long long ketas(long long a) { string b = to_string(a); long long c = 0; for (long long i = 0; i < keta(a); i++) { c += b[i] - '0'; } return c; } long long lcm(long long a, long long b) { return a / gcm(a, b) * b; } bool fe(long long a, long long b) { a %= 10; b %= 10; if (a == 0) a = 10; if (b == 0) b = 10; if (a > b) return true; else return false; } long long INF = 1000000007; struct edge { long long s, t, d; }; vector<long long> mojisyu(string a) { vector<long long> b(26, 0); for (long long i = 0; i < a.size(); i++) { b[a[i] - 'a']++; } return b; } long long wa2(long long a) { if (a % 2 == 1) return a / 2; return a / 2 - 1; } signed main() { long long a; vector<long long> b(5); string c; for (long long i = 0; i < a; i++) { cin >> c; if (c[0] == 'M') b[0]++; if (c[0] == 'A') b[1]++; if (c[0] == 'R') b[2]++; if (c[0] == 'C') b[3]++; if (c[0] == 'H') b[4]++; } sort(b.begin(), b.end()); reverse(b.begin(), b.end()); long long d = 0; if (b[2] == 0) cout << 0 << endl; else if (b[3] == 0) cout << b[0] * b[1] * b[2]; else if (b[4] == 0) cout << b[0] * b[1] * b[2] + b[3] * b[1] * b[2] + b[0] * b[1] * b[3] + b[0] * b[3] * b[2] << endl; else { for (long long i = 0; i < 5; i++) { for (long long j = i + 1; j < 5; j++) { for (long long k = j + 1; k < 5; k++) { d += b[i] * b[j] * b[k]; } } } cout << d << 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()) member = [0,0,0,0,0] ans = 0 for _ in range(N): a = input().split() if a[0] == "M": member[0] += 1 elif a[0] == "A": member[1] += 1 elif a[0] == "R": member[2] += 1 elif a[0] == "C": member[3] += 1 elif a[0] == "H": member[4] += 1 for i in range(3): for j in range(i+1, 4): for k in range(j+1, 5): ans += member[i]*member[j]*member[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 ll = long long; using namespace std; int main() { int n; cin >> n; map<int, int> check; for (int i = 0; i < n; i++) { string s; cin >> s; char c = s[0]; if (c == 'M') check[0]++; if (c == 'A') check[1]++; if (c == 'R') check[2]++; if (c == 'C') check[3]++; if (c == 'H') check[4]++; } ll ans = 0; int len = check.size(); if (len == 3) { ans = 1; for (auto a : check) { ans *= a.second; } cout << ans << endl; } else if (len > 3) { vector<int> val; for (auto t : check) val.push_back(t.second); for (int a = 0; a < len - 2; a++) { for (int b = a + 1; b < len - 1; b++) { for (int c = b + 1; c < len; c++) { ans += val[a] * val[b] * val[c]; } } } cout << ans << endl; } else { cout << 0 << 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; using pii = pair<int, int>; int main() { int n; cin >> n; vector<int> cnt(30); for (int i = 0; i < (n); i++) { string s; cin >> s; cnt[s[0]]++; } int sum = 0; sum += cnt['M'] * cnt['A'] * cnt['R']; sum += cnt['M'] * cnt['A'] * cnt['C']; sum += cnt['M'] * cnt['A'] * cnt['H']; sum += cnt['M'] * cnt['R'] * cnt['C']; sum += cnt['M'] * cnt['R'] * cnt['H']; sum += cnt['M'] * cnt['C'] * cnt['H']; sum += cnt['A'] * cnt['R'] * cnt['C']; sum += cnt['A'] * cnt['R'] * cnt['H']; sum += cnt['A'] * cnt['C'] * cnt['H']; sum += cnt['R'] * cnt['C'] * cnt['H']; cout << sum << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { string s; int n, sum = 1, zero = 0, a = 1; int cnt[5] = {}; cin >> n; for (int i = 0; i < n; i++) { cin >> s; if (s[0] == 'M') { cnt[0]++; } else if (s[0] == 'A') { cnt[1]++; } if (s[0] == 'R') { cnt[2]++; } if (s[0] == 'C') { cnt[3]++; } if (s[0] == 'H') { cnt[4]++; } } for (int i = 0; i < 5; i++) { cout << cnt[i] << endl; if (cnt[i] == 0) { zero++; } } if (zero == 5 || zero == 4 || zero == 3) { sum = 0; } else if (zero == 2) { for (int i = 0; i < 5; i++) { if (cnt[i] != 0) sum *= cnt[i]; } } else if (zero == 1) { sum = 0; for (int i = 0; i < 5; i++) { a = 1; for (int j = i; j < 5; j++) { if (j != i) { if (cnt[j] != 0) { a *= cnt[j]; cout << a << " "; } } } cout << endl; sum += a; } } else if (zero == 0) { sum = 0; for (int i = 0; i < 5; i++) { for (int j = i; j < 5; j++) { a = 1; for (int k = 0; k < 5; k++) { if (k != i && k != j) { a *= cnt[k]; } } sum += a; } } } cout << sum << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } int ctoi(char c) { return c - '0'; } long long cmb5(int n) { int x = 1; for (int i = 5; i <= n - 1; i--) x *= i; for (int i = 0, temp = (int)(n); i < temp; ++i) x /= (i + 1); return x; } signed main(void) { int n; cin >> n; int march[5] = {0, 0, 0, 0, 0}; for (int i = 0, temp = (int)(n); i < temp; ++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, temp = (int)(5); i < temp; ++i) for (int j = i + 1, temp = (int)(5); j < 5; ++j) for (int k = j + 1, temp = (int)(5); k < 5; ++k) { ans += march[i] * march[j] * march[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
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Atcoder1_A { class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); string[] name = new string[n]; for (int i = 0; i < n; i++) { name[i] = Console.ReadLine(); } int M = 0; int A = 0; int R = 0; int C = 0; int H = 0; foreach (string item in name) { switch (item[0]) { case 'M': M++; break; case 'A': A++; break; case 'R': R++; break; case 'C': C++; break; case 'H': H++; break; } } long 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); Console.WriteLine(ans); } } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int n, cnt = 0; string b[1001]; int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> b[i]; if (b[1] == "M" || b[1] == "A" || b[1] == "R" || b[1] == "C" || b[1] == "H") { cnt++; } } if (cnt == n) cout << 0; else cout << n - 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
N=int(input()) S=[input() for _ in range(N)] cnt=[] ans=0 for i in range(N): if S[i][0]=='M': cnt.append('M') elif S[i][0]=='A': cnt.append('A') elif S[i][0]=='R': cnt.append('R') elif S[i][0]=='C': cnt.append('C') elif S[i][0]=='H': cnt.append('H') import math import itertools c_list = list(itertools.combinations(cnt, 3)) for v in itertools.combinations(cnt, 3): if len(set(v))==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
python3
import itertools n = int(input()) s = [input() for _ in range(n)] march = [0]*5 ans = 0 for i in range(n): if s[i][0] == "M": march[0] += 1 elif s[i][0] == "A": march[1] += 1 elif s[i][0] == "R": march[2] += 1 elif s[i][0] == "C": march[3] += 1 elif s[i][0] == "H": march[4] += 1 print(march) for j in itertools.combinations(march,3): comb_multi = 1 for k in range(3): comb_multi *= j[k] ans += comb_multi 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; int m_san = 0; int a_san = 0; int r_san = 0; int c_san = 0; int h_san = 0; cin >> N; string s; for (int i = 0; i < N; i++) { cin >> s; if (s[0] == 'M') m_san++; if (s[0] == 'A') a_san++; if (s[0] == 'R') r_san++; if (s[0] == 'C') c_san++; if (s[0] == 'H') h_san++; } uint64_t total = 0; total += m_san * a_san * r_san; total += m_san * a_san * c_san; total += m_san * a_san * h_san; total += m_san * c_san * r_san; total += m_san * h_san * r_san; total += m_san * c_san * h_san; total += c_san * a_san * r_san; total += h_san * a_san * r_san; total += c_san * a_san * h_san; total += c_san * r_san * h_san; printf("%llu\n", total); 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.*; public class Main { public static void main(String[] args) { int[] P ={0 ,0 ,0 ,0 ,0 ,0 ,1 ,1 ,1 ,2}; int[] Q ={1 ,1 ,1 ,2 ,2 ,3 ,2 ,2 ,3 ,3}; int[] R ={2 ,3 ,4 ,3 ,4 ,4 ,3 ,4 ,4 ,4}; Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int[] S = new int[5]; for (int i = 0; i < N; i++) { String name = sc.next(); if (name.charAt(0) == 'M') S[0]++; if (name.charAt(0) == 'A') S[1]++; if (name.charAt(0) == 'R') S[2]++; if (name.charAt(0) == 'C') S[3]++; if (name.charAt(0) == 'H') S[4]++; } long res = 0; for (int d = 0; d < 10; d++) { res += S[P[d]] * S[Q[d]] * S[R[d]]; } 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; cin >> n; string s[n]; for (int i = 0; i < n; i++) cin >> s[i]; int m = 0, a = 0, r = 0, c = 0, h = 0; for (int i = 0; i < n; i++) { if (s[i][0] == 'M') m++; else if (s[i][0] == 'A') a++; else if (s[i][0] == 'R') r++; else if (s[i][0] == 'C') c++; else if (s[i][0] == 'H') h++; } long long ways = 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 << ways << "\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; string S[110000]; char c[110000]; long long int a = 0; cin >> N; for (int i = 0; i < N; i++) { cin >> S[i]; c[i] = S[i][0]; } 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[j] == 'M' || c[j] == 'A' || c[j] == 'R' || c[j] == 'C' || c[j] == 'H' && c[i] != c[j]) { for (int k = j + 1; k < N; k++) { if (c[k] == 'M' || c[k] == 'A' || c[k] == 'R' || c[k] == 'C' || c[k] == '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
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int cn[5] = {}; for (int i = 0; i < n; i++) { string s; cin >> s; if (s[0] == 'M') cn[0]++; else if (s[0] == 'A') cn[1]++; else if (s[0] == 'C') cn[2]++; else if (s[0] == 'R') cn[3]++; else cn[4]++; } int cnt = 0; for (int i = 0; i < 5; i++) if (cn[i]) cnt++; long long ans = 0; if (cnt >= 3) { if (cnt == 3) { ans = 1; for (int i = 0; i < 5; i++) if (cn[i]) ans *= cn[i]; } else if (cnt == 4) { vector<int> cc; for (int i = 0; i < 5; i++) if (cn[i]) cc.push_back(cn[i]); ans += cc[0] * cc[1] * cc[2]; ans += cc[0] * cc[1] * cc[3]; ans += cc[0] * cc[2] * cc[3]; ans += cc[1] * cc[2] * cc[3]; } else { ans += cn[0] * cn[1] * cn[2]; ans += cn[0] * cn[1] * cn[3]; ans += cn[0] * cn[1] * cn[4]; ans += cn[0] * cn[2] * cn[3]; ans += cn[0] * cn[2] * cn[4]; ans += cn[0] * cn[3] * cn[4]; ans += cn[1] * cn[2] * cn[3]; ans += cn[1] * cn[2] * cn[4]; ans += cn[1] * cn[3] * cn[4]; ans += cn[3] * cn[2] * cn[4]; } } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int m, a, r, c, h, n; cin >> n; m = 0; a = 0; r = 0; c = 0; h = 0; vector<string> names(n); for (int i = 0; i < n; i++) { cin >> names.at(i); if (names.at(i).at(0) == 'M') { m++; } else if (names.at(i).at(0) == 'A') { a++; } else if (names.at(i).at(0) == 'R') { r++; } else if (names.at(i).at(0) == 'C') { c++; } else if (names.at(i).at(0) == 'H') { h++; } } long x; x = m * a * r + m * a * c + m * a * h + m * r * c + m * r * h + m * c * h + a * r * c + a * r * h + a * c * h + r * c * h; cout << x << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
using System; using System.Linq; using System.Collections.Generic; using System.Collections; public class Program { public static void Main() { // 終了後回答 int N = int.Parse(Console.ReadLine()); string[] names = new string[N]; for (int i = 0; i < N; i++) { names[i] = Console.ReadLine(); } int[] MARCH = { 'M', 'A', 'R', 'C', 'H' }.Select(c => names.Count(s => s[0] == c)).ToArray(); long res = 0; for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { if (i==j) continue; for (int k = 0; k < 5; k++) { if (i == k || i == j) continue; res += MARCH[i]*MARCH[j]*MARCH[k]; } } } Console.WriteLine(res); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> int diff[4][2] = { {0, -1}, {-1, 0}, {1, 0}, {0, 1}, }; int Min(int a, int b) { return (a) < (b) ? (a) : (b); } int Max(int a, int b) { return (a) > (b) ? (a) : (b); } int main() { int n; scanf("%d", &n); char s[11]; int cnt[5] = {0}; for (int i = 0, i_len = (int)(n); i < i_len; i++) { scanf("%s", &s); switch (s[0]) { case 'M': cnt[0]++; break; case 'A': cnt[1]++; break; case 'R': cnt[2]++; break; case 'C': cnt[3]++; break; case 'H': cnt[4]++; break; } } long long ans = 0; for (int i = 0, i_len = (int)(n); i < i_len; i++) { for (int j = (int)(i + 1), j_len = (int)(n); j < j_len; j++) { for (int k = (int)(j + 1), k_len = (int)(n); k < k_len; k++) { ans += (long long)cnt[i] * cnt[j] * cnt[k]; } } } 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
python3
import math N=int(input()) S=[] T=[] m=a=r=c=h=0 for i in range(N): S.append(list(input())) if S[i][0]=="M" or S[i][0]=="A" or S[i][0]=="R" or S[i][0]=="C" or S[i][0]=="H": T.append(S[i][0]) K=set(T) P=[] for i in K: P.append(T.count(i)) if P==[]: ans=0 else: ans=math.factorial(sum(P))//(6*math.factorial(sum(P)-3)) for i in range(len(P)): if P[i]>2: ans-=(math.factorial(P[i])//6)*(len(P)-1) if P[i]>1: ans-=(math.factorial(P[i])//2)*(len(P)-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; string s[100005]; int a[26]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) cin >> s[i]; for (int i = 0; i < n; i++) a[s[i][0] - 'A']++; if (n < 3) { cout << 0 << endl; return 0; } int ans = 1, flag = 0, cnt = 0, c[5]; memset(c, 0, sizeof(c)); if (a['M' - 'A']) c[0] = a['M' - 'A'], cnt++; if (a['A' - 'A']) c[1] = a['A' - 'A'], cnt++; if (a['R' - 'A']) c[2] = a['R' - 'A'], cnt++; if (a['C' - 'A']) c[3] = a['C' - 'A'], cnt++; if (a['H' - 'A']) c[4] = a['H' - 'A'], cnt++; if (cnt >= 3) { ans = 0; for (int i = 0; i < 5; i++) for (int j = 1; j < 5; j++) for (int k = 2; k < 5; k++) if (i < j && j < k) ans += c[i] * c[j] * c[k]; cout << ans << endl; } else if (cnt < 3) cout << 0 << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <iostream> #include <stdio.h> #include <algorithm> #include <cmath> #include <string> #include <vector> #include <iomanip> #include <queue> #include <deque> #include <map> #include <unordered_map> #define rep(i,n) for(int i=0;i<n;i++) #define repn(i,n) for(int i=1;i<=n;i++) #define repr(e,x) for(auto& e:x) using namespace std; typedef long long ll; typedef long double ld; ll const MOD=1'000'000'007; ll N; string S[100000]; ll cnt[5]; int main(){ cin>>N; rep(i,N) cin>>S[i]; rep(i,N){ if(S[i][0]=='M') cnt[0]++; if(S[i][0]=='A') cnt[1]++; if(S[i][0]=='R') cnt[2]++; if(S[i][0]=='C') cnt[3]++; if(S[i][0]=='H') cnt[4]++; } ll ans=0; rep(i,5-2){ for(int j=i+1;j<5-1;j++){ for(int k=j+1;k<5;k++){ ans+=cnt[i]*cnt[j]%MOD*cnt[k]%MOD; ans%=MOD; } } } ans+=MOD; ans%=MOD; 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 as i,collections as c;print(sum(p*q*r for p,q,r in i.combinations(c.Counter(s[0]*(s[0]in"MARCH")for s in open(0).readlines()[1:]).values(),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> class kin { public: inline void open(FILE *, int); inline void close(void); inline void scan(void); inline kin &operator>(char &); inline kin &operator>(int &); inline kin &operator>(long long &); inline kin &operator>(double &); inline kin &operator>(long double &); inline kin &operator>(char *); template <class T> inline void get(T *, int); private: FILE *fp; char *buf; int siz; int idx; } in; class kout { public: inline void open(FILE *, int); inline void close(void); inline void print(void); inline kout &operator<(char); inline kout &operator<(int); inline kout &operator<(long long); inline kout &operator<(double); inline kout &operator<(long double); inline kout &operator<(const char *); template <class T> inline void put(T *, int, char, char); private: FILE *fp; char *buf; int siz; int idx; } out; int main(int argc, char **argv) { in.open(stdin, 512); out.open(stdout, 512); in.scan(); int n; in > n; int m = 0, a = 0, r = 0, c = 0, h = 0; for (int i = 0; i < n; ++i) { char s[11]; in > 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; } out < 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 < '\n'; out.print(); in.close(); out.close(); return 0; } inline void kin::open(FILE *fparg, int sizarg) { fp = fparg; buf = new char[sizarg]; siz = sizarg; idx = 0; return; } inline void kin::close(void) { fp = nullptr; delete[] buf; buf = nullptr; siz = 0; idx = 0; return; } inline void kin::scan(void) { int readsiz = (int)std::fread((void *)buf, (std::size_t)1, (std::size_t)siz, fp); if (readsiz != siz) buf[readsiz] = '\x00'; idx = 0; return; } inline kin &kin::operator>(char &var) { if (!buf[idx]) { var = '\x00'; return *this; } var = buf[idx]; if (++idx == siz) scan(); if (++idx == siz) scan(); return *this; } inline kin &kin::operator>(int &var) { if (!buf[idx]) { var = 0; return *this; } int sign = -1; if (buf[idx] == '-') { sign = 1; if (++idx == siz) scan(); } var = 0; while (buf[idx] >= '0') { var = var * 10 - (int)(buf[idx] - '0'); if (++idx == siz) scan(); } var *= sign; if (++idx == siz) scan(); return *this; } inline kin &kin::operator>(long long &var) { if (!buf[idx]) { var = 0LL; return *this; } long long sign = -1LL; if (buf[idx] == '-') { sign = 1LL; if (++idx == siz) scan(); }; var = 0LL; while (buf[idx] >= '0') { var = var * 10LL - (long long)(buf[idx] - '0'); if (++idx == siz) scan(); } var *= sign; if (++idx == siz) scan(); return *this; } inline kin &kin::operator>(double &var) { if (!buf[idx]) { var = 0.0; return *this; } double sign = -1.0; if (buf[idx] == '-') { sign = 1.0; if (++idx == siz) scan(); } var = 0.0; while (buf[idx] >= '0') { var = var * 10.0 - (double)(buf[idx] - '0'); if (++idx == siz) scan(); } if (buf[idx] == '.') { if (++idx == siz) scan(); double dig = 1.0; while (buf[idx] >= '0') { var -= (double)(buf[idx] - '0') * (dig /= 10.0); if (++idx == siz) scan(); } } var *= sign; if (++idx == siz) scan(); return *this; } inline kin &kin::operator>(long double &var) { if (!buf[idx]) { var = 0.0L; return *this; } long double sign = -1.0L; if (buf[idx] == '-') { sign = 1.0L; if (++idx == siz) scan(); } var = 0.0L; while (buf[idx] >= '0') { var = var * 10.0L - (long double)(buf[idx] - '0'); if (++idx == siz) scan(); } if (buf[idx] == '.') { if (++idx == siz) scan(); long double dig = 1.0L; while (buf[idx] >= '0') { var -= (long double)(buf[idx] - '0') * (dig /= 10.0L); if (++idx == siz) scan(); } } var *= sign; if (++idx == siz) scan(); return *this; } inline kin &kin::operator>(char *str) { if (!buf[idx]) { str[0] = '\x00'; return *this; } int ptr = 0; while (buf[idx] >= '!') { str[ptr++] = buf[idx]; if (++idx == siz) scan(); } str[ptr] = '\x00'; if (++idx == siz) scan(); return *this; } template <class T> inline void kin::get(T *arr, int num) { for (int i = 0; i < num; ++i) (*this) > arr[i]; return; } inline void kout::open(FILE *fparg, int sizarg) { fp = fparg; buf = new char[sizarg]; siz = sizarg; idx = 0; return; } inline void kout::close(void) { fp = nullptr; delete[] buf; buf = nullptr; siz = 0; idx = 0; return; } inline void kout::print(void) { std::fwrite((void *)buf, (std::size_t)1, (std::size_t)idx, fp); idx = 0; return; } inline kout &kout::operator<(char val) { buf[idx] = val; if (++idx == siz) print(); return *this; } inline kout &kout::operator<(int val) { if (val < 0) { buf[idx] = '-'; if (++idx == siz) print(); } else val *= -1; char dig[10]; int ptr = 0; do { int tmp = val / 10; dig[ptr++] = (char)-(val - tmp * 10) + '0'; val = tmp; } while (val); while (ptr--) { buf[idx] = dig[ptr]; if (++idx == siz) print(); } return *this; } inline kout &kout::operator<(long long val) { if (val < 0LL) { buf[idx] = '-'; if (++idx == siz) print(); } else val *= -1LL; char dig[19]; int ptr = 0; do { long long tmp = val / 10LL; dig[ptr++] = (char)-(val - tmp * 10LL) + '0'; val = tmp; } while (val); while (ptr--) { buf[idx] = dig[ptr]; if (++idx == siz) print(); } return *this; } inline kout &kout::operator<(double val) { if (val < 0.0) { buf[idx] = '-'; if (++idx == siz) print(); } else val *= -1.0; double dig = 1.0; while (val / dig <= -10.0) dig *= 10.0; int tmp; while (dig >= 1.0) { buf[idx] = (char)-(tmp = (int)(val / dig)) + '0'; if (++idx == siz) print(); val -= (double)tmp * dig; dig /= 10.0; } buf[idx] = '.'; if (++idx == siz) print(); for (int i = 0; i < 12; ++i) { buf[idx] = (char)-(tmp = (int)(val / dig)) + '0'; if (++idx == siz) print(); val -= (double)tmp * dig; dig /= 10.0; } return *this; } inline kout &kout::operator<(long double val) { if (val < 0.0L) { buf[idx] = '-'; if (++idx == siz) print(); } else val *= -1.0L; long double dig = 1.0L; while (val / dig <= -10.0L) dig *= 10.0L; int tmp; while (dig >= 1.0L) { buf[idx] = (char)-(tmp = (int)(val / dig)) + '0'; if (++idx == siz) print(); val -= (long double)tmp * dig; dig /= 10.0L; } buf[idx] = '.'; if (++idx == siz) print(); for (int i = 0; i < 16; ++i) { buf[idx] = (char)-(tmp = (int)(val / dig)) + '0'; if (++idx == siz) print(); val -= (long double)tmp * dig; dig /= 10.0L; } return *this; } inline kout &kout::operator<(const char *str) { for (int i = 0; str[i]; ++i) { buf[idx] = str[i]; if (++idx == siz) print(); } return *this; } template <class T> inline void kout::put(T *arr, int num, char dlm, char end) { --num; for (int i = 0; i < num; ++i) (*this) < arr[i] < dlm; (*this) < arr[num] < end; return; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\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() { int64_t n, m, a, r, c, h; int64_t ans; cin >> n; string tmp; for (int i = 0; i < n; i++) { cin >> tmp; if (tmp[0] == 'M') ++m; if (tmp[0] == 'A') ++a; if (tmp[0] == 'R') ++r; if (tmp[0] == 'C') ++c; if (tmp[0] == 'H') ++h; } ans += m * a * r; ans += m * a * c; ans += m * a * h; ans += m * r * c; ans += m * r * h; ans += m * c * h; ans += a * r * c; ans += a * r * h; ans += a * c * h; ans += r * c * h; cout << ans << endl; 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 tmp: Vec<char> = read::<String>().chars().collect(); let s = tmp[0]; match s{ '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> using namespace std; string s; int n; long long int ans; int top[5]; int ncr[10][3]{{0, 1, 2}, {0, 1, 3}, {0, 2, 3}, {1, 2, 3}, {0, 1, 4}, {0, 2, 4}, {1, 2, 4}, {0, 3, 4}, {1, 3, 4}, {2, 3, 4}}; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> s; if (s[0] == 'M') top[0]++; if (s[0] == 'A') top[1]++; if (s[0] == 'R') top[2]++; if (s[0] == 'C') top[3]++; if (s[0] == 'H') top[4]++; } for (int i = 0; i < 10; i++) ans += top[ncr[i][0]] * top[ncr[i][1]] * top[ncr[i][2]]; cout << ans << endl; };
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main(int argc, char *argv[]) { map<char, int> m; int N; cin >> N; string s; for (int i = 0; i < N; i++) { cin >> s; char cur = s[0]; if (cur == 'M' || cur == 'A' || cur == 'R' || cur == 'C' || cur == 'H') { m[cur] += 1; } } int64_t ans = 0; if (m.size() > 0) { ans = 1; for (auto p : m) { ans *= p.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; using ll = long long; const int MOD = 1000000007; const int INF = 1061109567; const double EPS = 1e-10; const double PI = acos(-1.0); int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; int QP(int a, int b) { int ans = 1; do { if (b & 1) ans = 1ll * ans * a % MOD; a = 1ll * a * a % MOD; } while (b >>= 1); return ans; } int QP(int a, int b, int MOD) { int ans = 1; do { if (b & 1) ans = 1ll * ans * a % MOD; a = 1ll * a * a % MOD; } while (b >>= 1); return ans; } int GCD(int a, int b) { return b ? GCD(b, a % b) : a; } int N, M; vector<int> Vec; 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; } ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); } ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; } vector<vector<long long> > comb(int n) { vector<vector<long long> > v(n + 1, vector<long long>(n + 1, 0)); for (int i = 0; i < v.size(); i++) { v[i][0] = 1; v[i][i] = 1; } for (int j = 1; j < v.size(); j++) { for (int k = 1; k < j; k++) { v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]); } } return v; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int N; cin >> N; int m = 0, a = 0, r = 0, c = 0, h = 0; for (int i = (0); i < (N); ++i) { string S; cin >> S; 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++; } int counter = 0; vector<int> V{m, a, r, c, h}; for (int i = (0); i < (5); ++i) { for (int j = (0); j < (5); ++j) { if (i > j) { for (int k = (0); k < (5); ++k) { if (j > k) { counter += V[i] * V[j] * V[k]; } } } } } cout << counter << "\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 N; int a[5] = {0}; string s; int combi(int n, int r) { if (n < r) return 0; else if (n == r) { return 1; } std::vector<bool> v(n); std::fill(v.begin(), v.begin() + r, true); int count = 0; do { for (int i = 0; i < n; ++i) { if (v[i]) { count++; } } } while (std::prev_permutation(v.begin(), v.end())); return count / r; } int main(void) { cin >> N; for (long i = 0; i < (N); i++) { cin >> s; switch (s[0]) { case 'M': a[0]++; break; case 'A': a[1]++; break; case 'R': a[2]++; break; case 'C': a[3]++; break; case 'H': a[4]++; break; default: break; } } int count = 0; int m = 0; for (int i = 0; i < 5; i++) { if (a[i] > 0) { count++; if (a[i] > 1) m += a[i]; } } cout << combi(count, 3) * m - (combi(count - 1, 3) * (m - 1)); }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; string s[n]; char name[5] = {'M', 'A', 'R', 'C', 'H'}; int a[5] = {}; for (int i = 0; i < n; ++i) { cin >> s[i]; for (int j = 0; j < 5; ++j) { if (s[i][0] == name[j]) a[j]++; } } long long ans = 0, res = 1; for (int i = 0; i < 5; ++i) { if (a[i] != 0) res *= a[i]; } for (int i = 0; i < 3; ++i) { for (int j = 0; j < 4; ++j) { for (int k = 0; k < 5; ++k) { if (i < j && j < 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
cpp
#include <bits/stdc++.h> using namespace std; uintmax_t combination(unsigned int n, unsigned int r) { if (r * 2 > n) r = n - r; uintmax_t dividend = 1; uintmax_t divisor = 1; for (unsigned int i = 1; i <= r; ++i) { dividend *= (n - i + 1); divisor *= i; } return dividend / divisor; } void solve() { long long n; cin >> n; vector<string> s(n); vector<long long> a(5); for (int i = 0; i < (int)(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]++; } long long cnt = 0; for (int i = 0; i < (int)(5); i++) { if (a[i] == 0) cnt++; } if (cnt >= 3) { cout << 0 << endl; return; } long long sum = 0; for (int i = 0; i < (int)(5); i++) { sum += a[i]; } long long ans = combination(sum, 3); for (int i = 0; i < (int)(5); i++) { if (a[i] == 0) continue; else { if (a[i] > 1) { long long b = -a[i]; for (int j = 0; j < (int)(5); j++) { b = b + a[j]; } ans = ans - (b * combination(a[i], 2)); } } } cout << ans << endl; } int main() { cout << std::fixed << std::setprecision(10); ios::sync_with_stdio(false); cin.tie(0); solve(); }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main(void) { int N; cin >> N; int m[5] = {}; for (int i = 0; i < N; i++) { string c; cin >> c; switch (c[0]) { case 'M': m[0]++; break; case 'A': m[1]++; break; case 'R': m[2]++; break; case 'C': m[3]++; break; case 'H': m[4]++; break; } } int 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 += m[i] * m[j] * m[k]; } } } cout << res << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include <bits/stdc++.h> int main() { int N; int i; scanf("%d", &N); char name[N + 1][100]; for (i = 1; i <= N; i++) scanf("%s", &name[i][0]); int countM = 0, countA = 0, countR = 0, countC = 0, countH = 0; for (i = 1; i <= N; i++) { if (name[i][0] == 'M') countM += 1; if (name[i][0] == 'A') countA += 1; if (name[i][0] == 'R') countR += 1; if (name[i][0] == 'C') countC += 1; if (name[i][0] == 'H') countH += 1; } long result = 0; result += (long)(countM * countA * (countR + countC + countH)); result += (long)(countM * countR * (countC + countH)); result += (long)(countM * countC * countH); result += (long)(countA * countR * (countC + countH)); result += (long)(countA * countC * countH); result += (long)(countR * countC * countH); printf("%ld", result); 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, c_m, c_a, c_r, c_c, c_h; long long ans; string tmp; cin >> N; for (int i = 0; i < (int)(N); i++) { cin >> tmp; if (tmp.at(0) == 'M') c_m++; if (tmp.at(0) == 'A') c_a++; if (tmp.at(0) == 'R') c_r++; if (tmp.at(0) == 'C') c_c++; if (tmp.at(0) == 'H') c_h++; } ans = c_m * c_a * (c_r + c_c + c_h) + c_m * c_r * (c_c + c_h) + c_m * c_c * c_h + c_a * c_r * (c_c + c_h) + c_a * c_c * c_h + c_r * c_c * 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() { string s = "MARCH"; int c[5] = {0}; int n; cin >> n; for (int i = 0; i < n; i++) { string t; cin >> t; for (int j = 0; j < 5; j++) { if (t[0] == s[j]) { c[j]++; } } } int ans = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { ans += c[i] * c[j] * c[k]; } } } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <cstdio > #include <iostream > using namespace std; typedef long long ll; string s; int N; ll m,a,r,c,h; ll D[5]; int P[10]={0,0,0,0,0,0,1,1,1,2}; int Q[10]={1,1,1,2,2,3,2,2,3,3}; int R[10]={2,3,4,3,4,4,3,4,4,4}; int main() { scanf ("%d",&N); 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++; } D[0]=m,D[1]=a,D[2]=r,D[3]=c,D[4]=h; ll res =0; for(int d=0;d<10;d++) res+=D[P[d]]*D[Q[d]]*D[R[d]]; printf ("% lld\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
UNKNOWN
import scala.io.StdIn._ object Main extends App { val n = readInt var map = Map('M' -> 0, 'A' -> 0, 'R' -> 0, 'C' -> 0, 'H' -> 0) for (_ <- 1 to n) { val c = readLine()(0) map.get(c) match { case Some(i) => map = map + (c -> (i + 1)) case None => } } val res = "MARCH".toSeq.combinations(3).foldLeft(0) { (acc, s) => acc + (map(s(0)) * map(s(1)) * map(s(2))) } 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> int main() { using namespace std; int N; cin >> N; vector<string> S(N); for (int i = 0; i < N; i++) cin >> S[i]; vector<char> initials = {'M', 'A', 'R', 'C', 'H'}; vector<int> times(5, 0); for (int i = 0; i < N; i++) { for (int j = 0; j < 5; j++) { if (S[i][0] == initials[j]) times[j]++; } } int ans = 0; for (int a = 0; a < 5; a++) { for (int b = a + 1; b < N; b++) { for (int c = b + 1; c < N; c++) { ans += times[a] * times[b] * times[c]; } } } 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() { int n; cin >> n; vector<long long> cnt(5, 0); for (int i = 0; i < n; i++) { string s; cin >> s; if (s[0] == 'M') { cnt[0]++; } if (s[0] == 'A') { cnt[1]++; } if (s[0] == 'R') { cnt[2]++; } if (s[0] == 'C') { cnt[3]++; } if (s[0] == 'H') { cnt[4]++; } } 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++) { long long r = 1; r *= cnt[i]; r %= 1000000007; r *= cnt[j]; r %= 1000000007; r *= cnt[k]; r %= 1000000007; res += r; res %= 1000000007; } } } 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
java
import java.io.BufferedReader; import java.io.DataInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) throws IOException { Main m = new Main(); //* m.input(); m.solve(); m.output(); /*/ m.debug(); //*/ } public void debug() { int h=300; int w=300; int[][] A = new int[h][w]; for (int i=0; i<h*w; i++) { int i2 = i%4; int i3 = i/4; int offx = (i2==0||i2==2)?0:(h/2); int offy = (i2==0||i2==1)?0:(w/2); int x = i3%(h/2); int y = i3/(h/2); A[offx+x][offy+y]=i+1; } for(int x=0; x<h; x++) { for(int y=0; y<w; y++) { if(y>0) System.out.print(" "); System.out.print(A[x][y]); } System.out.println(""); } } InputUtil in = new InputUtil(); PrintWriter out = new PrintWriter(System.out); int N = 0; String[] S = null; int countM = 0; int countA = 0; int countR = 0; int countC = 0; int countH = 0; int countAll = 0; // int M = 0; // int[] A = null; // String S = null; // boolean ansb = false; long ans = 0; public void input() throws IOException { // N = in.nextInt(); // M = in.nextInt(); // A = in.nextInt(new int[N]); // S = in.nextLine(); N = in.nextInt(); S = new String[N]; for (int i=0; i<N; i++) { S[i] = in.nextLine(); switch(S[i].charAt(0)) { case 'M': countM++; countAll++; break; case 'A': countA++; countAll++; break; case 'R': countR++; countAll++; break; case 'C': countC++; countAll++; break; case 'H': countH++; countAll++; break; } } } public void solve() throws IOException { if (countAll < 3) { ans = 0; } else { solveSub(countM , countA , countR); solveSub(countM , countA , countC); solveSub(countM , countA , countH); solveSub(countM , countR , countC); solveSub(countM , countR , countH); solveSub(countM , countC , countH); solveSub(countA , countR , countC); solveSub(countA , countR , countH); solveSub(countA , countC , countH); solveSub(countR , countC , countH); } } private void solveSub(int a, int b, int c) { if (a+b+c>=3) { ans += a*b*c; } } public void output() { // out.println(ansb?"Yes":"No"); out.println(ans); out.flush(); } } class InputUtil { //Static Fields private static final int BUFSIZ = 100000; boolean lineMode = false; //Fields protected InputStream in; private byte[] buf = null; private int ptr = 0; private int max = -1; private DataInputStream dis = null; //Constructors public InputUtil() {this(System.in,BUFSIZ);} public InputUtil(InputStream in, int bufsiz) { initBuf(bufsiz); initIn(in); } //Methods //Initializer protected void initIn(InputStream in) {dis = new DataInputStream(this.in = in);} protected void initBuf(int bufsiz) {buf = new byte[bufsiz];} //buffer operation private void next() throws IOException {ptr++; readBuf();} private void readBuf() throws IOException { if(ptr >= max && dis.available()>0) { if(max>0) Arrays.fill(buf,0,max,(byte)0); max = dis.read(buf); ptr = 0; } } //String Input Reader/Parser private boolean isCrLf(byte b) {return b == 0x0a || b == 0x0d; } private void skipOneCrLf() throws IOException { byte b = buf[ptr]; if (isCrLf(b)) { ptr++; if (b == 0x0d) { readBuf(); if (ptr < max && buf[ptr] == 0x0a) { ptr++; } } } } public String nextLine() throws IOException { StringBuilder sb = new StringBuilder(); boolean isFirst = true; for(readBuf(); ptr < max ;readBuf()) { byte b = buf[ptr]; if(isCrLf(b)) { skipOneCrLf(); if (!isFirst || lineMode) { break; } }else{ int strPtr = ptr++; int endPtr = -1; for(int i = ptr; i<max; i++) { if(isCrLf(buf[i])) { endPtr = i; break; } } if(endPtr == -1) endPtr = max; sb.append(new String(buf,strPtr,endPtr-strPtr,"UTF-8")); ptr = endPtr; } isFirst = false; } lineMode = true; return sb.toString(); } public byte nextByte() throws IOException { lineMode=false; readBuf(); if(ptr < max) { return buf[ptr++]; }else{ return -1; } } //Number Input Reader/Parser private boolean isNum(byte b) {return '0' <= b && b <= '9'; } private boolean isMinus(byte b) {return b=='-'; } public int nextInt() throws IOException { lineMode=false; readBuf(); return (int)_nextLong(); } public int[] nextInt(int[] result) throws IOException { lineMode=false; readBuf(); for(int i=0; i<result.length; i++) { result[i] = (int)_nextLong(); } return result; } private long _nextLong() throws IOException { int sign = 1; long res = 0; byte c; while (!isNum(c=buf[ptr]) && !isMinus(c)) next(); if (isMinus(buf[ptr])) { sign = -1; next(); } while (isNum(c=buf[ptr])) { res *= 10; res += c - '0' ; next(); } next(); return sign * res; } public long nextLong() throws IOException { lineMode=false; readBuf(); return _nextLong(); } public long[] nextLong(long[] result) throws IOException { lineMode=false; readBuf(); for(int i=0; i<result.length; i++) { result[i] = _nextLong(); } return result; } //Close public void close() throws IOException { if(!this.in.equals(System.in)) this.in.close(); } } class OutputUtil { public static final String EOF = System.lineSeparator(); public static void outputDivSpace(PrintWriter out, int[] a) { OutputUtil.output(out,a,0,a.length," "); } public static void outputDivEOF(PrintWriter out, int[] a) { OutputUtil.output(out,a,0,a.length,EOF); } public static void output(PrintWriter out, int[] a, int off, int len, String delim) { out.print(a[off]); for(int i=off+1; i<len; i++){ out.print(delim); out.print(a[i]); } out.println(""); out.flush(); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\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 import sys def input(): return sys.stdin.readline().strip() def I(): return int(input()) def LI(): return list(map(int, input().split())) def IR(n): return [I() for i in range(n)] def LIR(n): return [LI() for i in range(n)] def SR(n): return [S() for i in range(n)] def S(): return input() def LS(): return input().split() n = I() s = SR(n) name_h = tuple([name[0] for name in s if name[0] in {'M', 'A', 'R', 'C', 'H'}]) ans = list(itertools.combinations(name_h, 3)) ans = len([a for a in ans if len(set(a)) == 3]) print(ans)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string t = "MARCH"; vector<int> c(5); for (int i = 0; i < (n); i++) { string s; cin >> s; for (int j = 0; j < 5; j++) { if (s[0] == t[j]) { c[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 += c[i] * c[j] * c[k]; } } } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; int main() { int n; cin >> n; string s; string word = "MARCH"; map<char, int> mp; for (int i = 0; i < n; i++) { cin >> s; mp[s[0]]++; } long long ans = 0; for (int i = 0; i < word.size() - 2; i++) { for (int j = i + 1; j < word.size() - 1; j++) { for (int k = j + 1; k < word.size(); k++) { ans += mp[word[i]] * mp[word[j]] * mp[word[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() { string s = "MARCH"; int c[5] = {0, 0, 0, 0, 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]++; } } } long long ans = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { ans += c[i] * c[j] * c[k]; } } } cout << ans; 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 <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<int, int>; int main() { int n; cin >> n; vector<int> dp(5, 0); ll ans = 0; for (int i = 0; i < (n); i++) { string s; cin >> s; if (s[0] == 'M') dp[0]++; if (s[0] == 'A') dp[1]++; if (s[0] == 'R') dp[2]++; if (s[0] == 'C') dp[3]++; if (s[0] == 'H') dp[4]++; } for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { ans += dp[i] * dp[j] * dp[k]; } } } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> int main() { char s[10001][11]; int n; char march[] = {'M', 'A', 'R', 'C', 'H'}; int d[5] = {0, 0, 0, 0, 0}; int p[5] = {0, 1, 2, 3, 4}; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%s", s[i]); for (int j = 0; j < 5; j++) if (s[i][0] == march[j]) d[j]++; } int sum = 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 += d[i] * d[j] * d[k]; } } } printf("%d\n", sum); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; string s[N]; for (int i = 0; i < N; i++) { cin >> s[i]; } int march[5]; for (int i = 0; i < 5; i++) { march[i] = 0; } for (int i = 0; i < N; i++) { switch (s[i][0]) { case 'M': march[0]++; break; case 'A': march[1]++; break; case 'R': march[2]++; break; case 'C': march[3]++; break; case 'H': march[4]++; break; default: break; } } 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 += ans + i * j * k; } } } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; map<char, int> mp; mp['M'] = 0, mp['A'] = 0, mp['R'] = 0, mp['C'] = 0, mp['H'] = 0; for (int i = 0; i < N; i++) { string str; cin >> str; char c = str.at(0); if (c == 'M' || c == 'A' || c == 'R' || c == 'C' || c == 'H') mp.at(c)++; } long long ans = 0; ans += mp.at('M') * mp.at('A') * mp.at('R'); ans += mp.at('M') * mp.at('A') * mp.at('C'); ans += mp.at('M') * mp.at('A') * mp.at('H'); ans += mp.at('M') * mp.at('R') * mp.at('C'); ans += mp.at('M') * mp.at('R') * mp.at('H'); ans += mp.at('M') * mp.at('C') * mp.at('H'); ans += mp.at('A') * mp.at('R') * mp.at('C'); ans += mp.at('A') * mp.at('R') * mp.at('H'); ans += mp.at('A') * mp.at('C') * mp.at('H'); ans += mp.at('R') * mp.at('C') * mp.at('H'); cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
incloud.(studio.h) int main() { int MASHIKE,RUMOI,OBIRA,HABORO,HOROKANAI,; char s [11]; scanf ("%d", &MASAKI); scanf ("%d %d %d %d %d" ,&RUMOI,BIRA,HABORO,HOROKANAI); scanf ("%d",s); printf("%d %s\n" ,2); }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; long long A[5] = {0, 0, 0, 0, 0}; cin >> N; vector<string> S(N); for (size_t i = 0; i < N; i++) { cin >> S.at(i); if (S.at(i).at(0) == 'M') { A[0]++; } else if (S.at(i).at(0) == 'A') { A[1]++; } else if (S.at(i).at(0) == 'R') { A[2]++; } else if (S.at(i).at(0) == 'C') { A[3]++; } else if (S.at(i).at(0) == 'H') { A[4]++; } long long ans = 0; for (size_t i = 0; i < N; i++) { for (size_t j = i + 1; j < N; j++) { for (size_t k = j + 1; k < N; k++) { ans += (A[i]) * A[j] * A[k]; } } } cout << ans; } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
int main(){ int N; cin >> N; char name[100000][11]; for(int i=0;i<N;i++){ cin >> name[i]; } int m=0,a=0,r=0,c=0,h=0; for(int i=0;i<N;i++){ switch(name[i][0]){ case 'M': m++; break; case 'A': a++; break; case 'R': r++; break; case 'C': c++; break; case 'H': h++; break; default: break; } } long long ans; ans=m*(a*r + a*c + a*h + r*c + r*h + c*h) + a*(r*c + r*h + c*h) + r*c*h + 0; cout << ans; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <stdio.h> enum int main() { int n; long long int mozi[5] = {0}; long long int ans = 1; long long int zenbu = 0; int i, j, k; char s[11]; scanf("%d", &n); for (i= 0; i < n; i++) { scanf("%s", s); switch (s[0]) { case 'M' : mozi[0]++; break; case 'A' : mozi[1]++; break; case 'R' : mozi[2]++; break; case 'C' : mozi[3]++; break; case 'H' : mozi[4]++; break; } } 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("%lld", 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
#include <bits/stdc++.h> using namespace std; constexpr int INF = numeric_limits<int>::max() / 2; constexpr long long INFL = numeric_limits<long long>::max() / 2; constexpr int MOD = 1000000007; using Graph = vector<vector<int>>; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int N; cin >> N; int m[5] = {}; for (int i = 0; i < (int)(N); i++) { string x; cin >> x; if (x[0] == 'M') m[0]++; if (x[0] == 'A') m[1]++; if (x[0] == 'R') m[2]++; if (x[0] == 'C') m[3]++; if (x[0] == 'H') m[4]++; } long long ans = 0; for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 4; j++) { for (int k = j + 1; k < 5; k++) { ans += m[i] * m[j] * m[k]; } } } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
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[N]; int count[5]; for (int i = 0; i < N; i++) { if (S[i][0] == 'M') { count[0] += 1; } else if (S[i][0] == 'A') { count[1] += 1; } else if (S[i][0] == 'R') { count[2] += 1; } else if (S[i][0] == 'C') { count[3] += 1; } else if (S[i][0] == 'H') { count[4] += 1; } } 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 += count[i] * count[j] * count[k]; } } } cout << sum << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
import itertools n = int(input()) l = [0]*n for i in range(n): s = input() if s[0] == "M": l[0] += 1 if s[0] == "A": l[1] += 1 if s[0] == "R": l[2] += 1 if s[0] == "C": l[3] += 1 if s[0] == "H": l[4] += 1 ans = 0 for a in list(itertools.combinations(l,3)): c = 1 for i in a: c *=i ans += 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
UNKNOWN
n = gets.to_i names = [] while name = gets[0] if name[0] == "M" || name[0] == "A" || name[0] == "R" || name[0] == "C" || name[0] == "H" names.push(name) end end count = 0 for i in 0..names.length-3 for j in i+1..names.length-2 if names[i][0] == names[j][0] next end for k in j+1..names.length-1 if names[i][0] == names[k][0] || names[j][0] == names[k][0] next end count += 1 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
cpp
#include <bits/stdc++.h> using namespace std; signed main(void) { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; vector<int> cnt(5); int sum = 0; for (int i = 0; i < N; i++) { string T; cin >> T; if (T[0] == 'M') cnt[0]++; else if (T[0] == 'A') cnt[1]++; else if (T[0] == 'R') cnt[2]++; else if (T[0] == 'C') cnt[3]++; else if (T[0] == 'H') cnt[4]++; } int num = 0; for (int i = 0; i < 5; i++) if (cnt[i] > 0) num++; num -= 3; num = max(0, num); sort(cnt.begin(), cnt.end()); long long int ans = 0; do { ans += cnt[0] * cnt[1] * cnt[2]; } while (next_permutation(cnt.begin(), cnt.end())); if (num == 1) ans /= 2; if (num == 2) ans /= 6; 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
class Problem getter :n, :a @n : Int32 @s : Array(String) @cnt : Hash(Char,Int64) def initialize @n = gets.to_s.to_i @s = Array.new(n){ gets.to_s.chomp } @cnt = Hash(Char,Int64).new{|h,k|h[k]=0_i64} @s.each do |s| @cnt[s[0]] += 1_i64 end end def solve ans = 0_i64 ['M','A','R','C','H'].each_combination do |(a,b,c)| next if @cnt[a].zero? next if @cnt[b].zero? next if @cnt[c].zero? ans += @cnt[a] * @cnt[b] * @cnt[c] end ans end def show(ans) puts ans end end Problem.new.try do |b| b.show(b.solve) end
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\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, c_m, c_a, c_r, c_c, c_h; long long ans; cin >> N; for (int i = 0; i < (int)(N); i++) { string tmp; cin >> tmp; if (tmp.at(0) == 'M') c_m++; if (tmp.at(0) == 'A') c_a++; if (tmp.at(0) == 'R') c_r++; if (tmp.at(0) == 'C') c_c++; if (tmp.at(0) == 'H') c_h++; } ans = (long long)(c_m * c_a * (c_r + c_c + c_h) + c_m * c_r * (c_c + c_h) + c_m * c_c * c_h + c_a * c_r * (c_c + c_h) + c_a * c_c * c_h + c_r * c_c * 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() { vector<int> s(5, 0); unordered_map<char, int> m; m['M'] = 0; m['A'] = 1; m['R'] = 2; m['C'] = 3; m['H'] = 4; int N; cin >> N; for (int i = 0; i < N; i++) { string str; cin >> str; if (m.find(str[0]) != m.end()) s[m[str[0]]]++; } unsigned long long result = 0; for (int i = 0; i < 5; i++) for (int j = i + 1; j < 5; j++) for (int k = j + 1; k < 5; k++) result += s[i] * s[j] * s[k]; cout << result << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using vi = vector<int>; using vvi = vector<vi>; using ll = long long; int MARCH(vector<string> vec, int cnt) { int M = 0, A = 0, R = 0, C = 0, H = 0; for (int i = 0; i < (int)vec.size(); i++) { if (vec.at(i).at(0) == 'M') M++; if (vec.at(i).at(0) == 'A') A++; if (vec.at(i).at(0) == 'R') R++; if (vec.at(i).at(0) == 'C') C++; if (vec.at(i).at(0) == 'H') H++; } if (M > 0) cnt++; if (A > 0) cnt++; if (R > 0) cnt++; if (C > 0) cnt++; if (H > 0) cnt++; return cnt; } int combination(int n, int k) { double ans = 1; if (k == 1) { return n / k; } ans = (double)n / k * combination(n - 1, k - 1); return ans; } int main() { int n; cin >> n; string s = "MARCH"; vi c(5); for (int i = 0; i < n; i++) { string t; cin >> t; for (int j = 0; j < 5; j++) { if (t.at(0) == s.at(j)) { c.at(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.at(i) * c.at(j) * c.at(k); } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (a % b == 0) { return b; } else { return (gcd(b, a % b)); } } long long lcm(long long a, long long b) { return a / gcd(a, b) * b; } const int INF = 1e9; const long long MX = 1e18; const long long MOD = INF + 7; const int di[] = {-1, 0, 1, 0}; const int dj[] = {0, -1, 0, 1}; const double PI = acos(-1); const long long MAX = 1000001; long long fac[MAX], finv[MAX], inv[MAX]; void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (long long i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } long long COM(long long n, long long k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } int main() { string s = "MARCH"; int c[5] = {0}; int n; cin >> n; for (long long i = 0; i < (n); i++) { string t; cin >> t; for (long long j = 0; j < (5); j++) { if (t[0] == s[j]) c[j]++; } } int ans = 0; for (long long i = 0; i < (3); i++) { for (int j = i + 1; j < 4; j++) { for (int k = j + 1; k < 5; k++) { ans += c[i] * c[j] * c[k]; } } } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
import functools N = int(input()) march = ["M","A","R","C","H"] S = {} for m in march: S[m] = 0 for i in range(N): s = input() if s[0] in march: S[s[0]] += 1 aS = [] for s in S.values(): if s != 0: aS.append(s) mul = 1 ans = 0 sum = 0 for s in aS: mul = mul * s sum += 1 if sum == 3: ans = mul elif sum == 4: # ans = mul * 4 for s in aS: ans = ans + mul / s elif sum == 5: # ans = mul * 5 for i in range(5): for j in range(i,5): ans = ans + mul / aS[i] / aS[j] print(int(ans))
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
N = int(input()) S = [] for i in range(N): s = input() if s[0] in [ 'M','A','R','C','H' ]: S.append(s) S = list(set(S)) N = len(S) selected = [""] * 2 cnt = 0 for i in range(N-2): selected = [""] * 2 selected[0] = S[i][0] for k in range(i+1, N-1): if S[k][0] in selected: continue selected[1] = S[k][0] for t in range(k+1, N): if S[t][0] in selected: continue cnt += 1 print(cnt)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int N; char S[10001]; 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", &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 << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; long long solve(vector<int> nums) { long long ans = 0; for (int i = 0; i < nums.size() - 2; i++) { for (int j = i + 1; j < nums.size() - 1; j++) { for (int k = j + 1; k < nums.size(); k++) { ans += nums[i] * nums[j] * nums[k]; } } } return ans; } int main() { int N; cin >> N; vector<int> nums(5, 0); for (int i = 0; i < N; i++) { string s; cin >> s; if (s[0] == 'M') nums[0]++; if (s[0] == 'A') nums[1]++; if (s[0] == 'R') nums[2]++; if (s[0] == 'C') nums[3]++; if (s[0] == 'H') nums[4]++; } long long ans; ans = solve(nums); 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
function solve() N = parse(Int64, readline()[1]) S = [chomp(readline()) for s in 1:N] numMARCH = [0, 0, 0, 0, 0] MARCH = ["M", "A", "R", "C", "H"] for name in S for (i, m) in enumerate(MARCH) if name[1] == m[1] numMARCH[i] += 1 end end end nonzero = numMARCH[numMARCH .!= 0] if length(nonzero) < 3 println(0) return end combinations = 0 for i in 1:length(nonzero) for j in i+1:length(nonzero) for k in j+1:length(nonzero) combinations += nonzero[i]*nonzero[j]*nonzero[k] end end end println(combinations) end solve()
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\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-1)): 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 # print(mar[a], mar[b], mar[c]) 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
cpp
#include <bits/stdc++.h> 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 (a > b) { a = b; return 1; } return 0; } using ll = long long; using namespace std; constexpr long long MAX = 5100000; constexpr long long INF = 1LL << 60; constexpr int MOD = 1000000007; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; map<char, int> dic; for (int i = 0; i < (n); i++) { string s; cin >> s; dic[s[0]]++; } string march = "MARCH"; 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++) { char c1 = march[i]; char c2 = march[j]; char c3 = march[k]; ans += dic[c1] * dic[c2] * dic[c3]; } } } 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 argc, char* argv[]) { int N, zero = 0; long long ans = 0; int cnt[5]; char S[10001][11]; char march[] = {'M', 'A', 'R', 'C', 'H'}; int M[] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2}; int Q[] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3}; int R[] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4}; cin >> N; for (int i = 0; i < N; i++) { if (!scanf("%s", S[i])) ; for (int j = 0; j < 5; j++) { if (S[i][0] == march[j]) cnt[j]++; } } for (int i = 0; i < 10; i++) { ans += cnt[M[i]] * cnt[Q[i]] * cnt[R[i]]; } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; int Len(int n) { int s = 0; while (n != 0) s++, n /= 10; return s; } int Sint(int n) { int m = 0, s = 0, a = n; while (a != 0) s++, a /= 10; for (int i = s - 1; i >= 0; i--) m += n / ((int)pow(10, i)) - (n / ((int)pow(10, i + 1))) * 10; return m; } int Svec(vector<int> v) { int n = 0; for (int i = 0; i < v.size(); i++) n += v[i]; return n; } int GCD(int a, int b) { int r, tmp; if (a < b) { tmp = a, a = b, b = tmp; } r = a % b; while (r != 0) { a = b, b = r, r = a % b; } return b; } int LCM(int a, int b) { int c = a, d = b, r, tmp; if (a < b) { tmp = a, a = b, b = tmp; } r = a % b; while (r != 0) { a = b, b = r, r = a % b; } return c / b * d; } int Factorial(int n) { int m = 1; while (n >= 1) m *= n, n--; return m; } int main() { long long int n; cin >> n; vector<int> c(5); for (int i = 0; i < (5); i++) c[i] = 0; for (int i = 0; i < (n); i++) { string s; cin >> s; if (s[0] == 'M') { c[0]++; } else if (s[0] == 'A') { c[1]++; } else if (s[0] == 'R') { c[2]++; } else if (s[0] == 'C') { c[3]++; } else if (s[0] == 'H') { c[4]++; } } 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 += c[i] * c[j] * c[k]; } } } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; long long int count = 0; cin >> N; int S[5] = {0}; for (int i = 0; i < N; i++) { string name; cin >> name; switch (name.at(0)) { case 'M': S[0]++; break; case 'A': S[1]++; break; case 'R': S[2]++; break; case 'C': S[3]++; break; case 'H': S[4]++; break; } } for (int i = 0; i < 4; i++) for (int j = i + 1; j < 5; j++) for (int k = j + 1; k < 5; k++) count += S[i] * S[j] * S[k]; cout << count << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; long long ans; int n; char name[100005][13]; long long s[1000]; int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> name[i]; s[name[i][0]]++; } if (s['M'] == 0) s['M'] = 1; if (s['A'] == 0) s['A'] = 1; if (s['R'] == 0) s['R'] = 1; if (s['C'] == 0) s['C'] = 1; if (s['H'] == 0) s['H'] = 1; ans = s['M'] * s['A'] * s['R'] * s['C'] * s['H']; cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.InputMismatchException; import java.util.List; import java.util.Map.Entry; import java.util.NoSuchElementException; import java.util.TreeSet; public class Main implements Runnable { // クラス名はMain1 PrintWriter out = new PrintWriter(System.out); InputReader sc = new InputReader(System.in); static int mod = 1000000000 + 7; //10^9+7 int[] dx = { 1, 0, -1, 0 }, dy = { 0, 1, 0, -1 }; //4 directions public static void main(String[] args) { Thread.setDefaultUncaughtExceptionHandler((t, e) -> System.exit(1)); new Thread(null, new Main(), "", 1024 * 1024 * 1024).start(); // 16MBスタックを確保して実行 } public void run() { try { /** * 2の累乗一覧 * http://www.gaoshukai.com/20/06/0022/ * * Bit 全探索 //Nは要素数 (bit全探索) //計算量はO(2^N) Nが0-20~25 (30は多分無理)くらいまでしか使えない Out: for (int bit = 0; bit < (1 << N); bit++) { out.println(Integer.toBinaryString(bit)); In: for (int j = 0; j < N; j++) { out.println(1 & (bit >> j)); //1が立ってれば対象。例えば101だったら1桁目と3桁目は選ばれている //「二進数iをjだけ右にビットシフトしたときの、iの1桁目と1とでビット論理積をとって、演算結果が1であるなら処理を実行する」 if ((1 & bit >> j) == 1) { } } } * * 表示系 * out.println(); * out.println("i:" + i + " ,j:" + j); * out.println(Arrays.toString(A)); * * Sort (Arrays) * Integer[] A = new Integer[N]; * Desc : Arrays.sort(A , Collections.reverseOrder()); * Asc : Arrays.sort(A); * * 定義系 * int[] s = new int[M]; * ArrayDeque<Integer> deq= new ArrayDeque<>();//先頭と末尾への要素の追加・先頭と末尾の要素の取り出しと削除が定数時間 * ArrayList<Integer> arr = new ArrayList<Integer>();//定数時間 * HashMap<Integer,Integer> hm = new HashMap<>(); //定数時間 * * //要素の追加と、最小の要素の取り出しと削除が対数時間 * PriorityQueue<Integer> pq = new PriorityQueue<>();//昇順 * PriorityQueue<Integer> pq = new PriorityQueue<>(Collections.reverseOrder()); //逆順。降順 * * TreeSet<Integer> ts = new TreeSet<>();//対数時間(重複はできない) * * 文字系 * String S = sc.next().trim(); * for (char i = 'a'; i <= 'z'; i++) {} * S.substring(1,2);//あいうえお → い * S.substring(0,1); // 1文字目をとりたいとき * * //同じ文字の繰り返し * String goy = String.join("", Collections.nCopies(2, "U")); //Uを2回繰り返し * * 文字列のSort * String sorted = S.chars().sorted().collect(StringBuilder::new,StringBuilder::appendCodePoint, StringBuilder::append) .toString(); */ // long l = sc.nextLong(); //String S = sc.next().trim(); //int N = sc.nextInt(); //int[] A = new int[N]; int N = sc.nextInt(); String[] s = new String[N]; TreeSet<String> tsm = new TreeSet<>(); TreeSet<String> tsa = new TreeSet<>(); TreeSet<String> tsr = new TreeSet<>(); TreeSet<String> tsc = new TreeSet<>(); TreeSet<String> tsh = new TreeSet<>(); for (int i = 0; i < N; i++) { String S = sc.next().trim(); s[i] = S; if (S.charAt(0) == 'M') { tsm.add(s[i]); } else if (S.charAt(0) == 'A') { tsa.add(s[i]); } else if (S.charAt(0) == 'R') { tsr.add(s[i]); } else if (S.charAt(0) == 'C') { tsc.add(s[i]); } else if (S.charAt(0) == 'H') { tsh.add(s[i]); } } long ans = 0; ans += tsm.size() * tsa.size() * tsr.size(); ans += tsm.size() * tsa.size() * tsc.size(); ans += tsm.size() * tsa.size() * tsh.size(); ans += tsm.size() * tsr.size() * tsc.size(); ans += tsm.size() * tsr.size() * tsh.size(); ans += tsm.size() * tsc.size() * tsh.size(); ans += tsa.size() * tsr.size() * tsc.size(); ans += tsa.size() * tsr.size() * tsh.size(); ans += tsa.size() * tsc.size() * tsh.size(); ans += tsr.size() * tsc.size() * tsh.size(); //out.println(Arrays.toString(A)); out.println(ans); } catch (ArithmeticException ae) { //ae.printStackTrace(); throw new RuntimeException(); } catch (Exception e) { //e.printStackTrace(); throw new RuntimeException(); } finally { out.flush(); out.close(); } } class Exm implements Comparable<Exm> { public int a; public int b; public Exm(int a, int b) { this.a = a; this.b = b; } @Override public int compareTo(Exm o) { //return this.a - o.a;//昇順 // return o.a - this.a;//降順 //複数項目で並び替え。aの降順、aが同じならbの降順 if (this.a == o.a) { return o.b - this.b; } else { return o.a - this.a; } } } //Arrays.sort(Sample,new Comp()); class Comp implements Comparator<Exm> { public int compare(Exm be, Exm af) { return Long.compare(af.a, be.a); } } /** * * @param n * @param m * @return Combinationの数を返す(mod無しなので、大きい値には使用できない桁溢れする) */ 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; } /* * 使用するときはModに注意。Global変数を参照 */ public static long comb(long a, long b) { if (a < b) return 0; long res = 1; long inv = pow(fact(Math.min(b, a - b)), mod - 2); for (long i = a; i > a - Math.min(b, a - b); i--) { res *= i; res %= mod; } res *= inv; res %= mod; return res; } public static long pow(long x, long n) { long res = 1; while (n > 0) { if ((n & 1) == 1) { res *= x; res %= mod; } x *= x; x %= mod; n >>= 1; } return res; } public static long fact(long n) { long res = 1; while (n > 0) { res *= n; res %= mod; n--; } return res; } /* * HashmapのSort * hmはhashmap * keyvalは"key" or "val"を指定して * ascdescは"asc" or "desc"を指定して */ private static List<Entry<Integer, Integer>> sortHashMapValue(HashMap<Integer, Integer> hm, String keyval, String ascdesc) { // 1.Map.Entryのリストを作成する List<Entry<Integer, Integer>> list_entries = new ArrayList<Entry<Integer, Integer>>(hm.entrySet()); // 2.比較関数Comparatorを使用してMap.Entryの値を比較する(昇順) Collections.sort(list_entries, new Comparator<Entry<Integer, Integer>>() { public int compare(Entry<Integer, Integer> obj1, Entry<Integer, Integer> obj2) { if (keyval.equals("val")) { if (ascdesc.equals("asc")) { // 昇順(value) return obj1.getValue().compareTo(obj2.getValue()); } else { // 降順(value) return obj2.getValue().compareTo(obj1.getValue()); } } else { if (ascdesc.equals("asc")) { // 昇順(value) return obj1.getKey().compareTo(obj2.getKey()); } else { // 降順(value) return obj2.getKey().compareTo(obj1.getKey()); } } } }); /* // 3. ループで要素順に値を取得する for (Entry<Integer, Integer> entry : list_entries) { out.println(entry.getKey() + " : " + entry.getValue()); } */ return list_entries; } // 高速なScanner static class InputReader { private InputStream in; private byte[] buffer = new byte[1024]; private int curbuf; private int lenbuf; public InputReader(InputStream in) { this.in = in; this.curbuf = this.lenbuf = 0; } public boolean hasNextByte() { if (curbuf >= lenbuf) { curbuf = 0; try { lenbuf = in.read(buffer); } catch (IOException e) { throw new InputMismatchException(); } if (lenbuf <= 0) return false; } return true; } private int readByte() { if (hasNextByte()) return buffer[curbuf++]; else return -1; } private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); } private void skip() { while (hasNextByte() && isSpaceChar(buffer[curbuf])) curbuf++; } public boolean hasNext() { skip(); return hasNextByte(); } public String next() { if (!hasNext()) throw new NoSuchElementException(); StringBuilder sb = new StringBuilder(); int b = readByte(); while (!isSpaceChar(b)) { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } public int nextInt() { if (!hasNext()) throw new NoSuchElementException(); int c = readByte(); while (isSpaceChar(c)) c = readByte(); boolean minus = false; if (c == '-') { minus = true; c = readByte(); } int res = 0; do { if (c < '0' || c > '9') throw new InputMismatchException(); res = res * 10 + c - '0'; c = readByte(); } while (!isSpaceChar(c)); return (minus) ? -res : res; } public long nextLong() { if (!hasNext()) throw new NoSuchElementException(); int c = readByte(); while (isSpaceChar(c)) c = readByte(); boolean minus = false; if (c == '-') { minus = true; c = readByte(); } long res = 0; do { if (c < '0' || c > '9') throw new InputMismatchException(); res = res * 10 + c - '0'; c = readByte(); } while (!isSpaceChar(c)); return (minus) ? -res : res; } public double nextDouble() { return Double.parseDouble(next()); } public int[] nextIntArray(int n) { int[] a = new int[n]; for (int i = 0; i < n; i++) a[i] = nextInt(); return a; } public long[] nextLongArray(int n) { long[] a = new long[n]; for (int i = 0; i < n; i++) a[i] = nextLong(); return a; } public char[][] nextCharMap(int n, int m) { char[][] map = new char[n][m]; for (int i = 0; i < n; i++) map[i] = next().toCharArray(); return map; } } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
n=int(input()) m,a,r,c,h=0,0,0,0,0 for i in range(n): s=input() 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 x=[m,a,r,c,h] cnt=x.count(0) for i in range(cnt): x.remove(0) l=len(x) if l<3: print(0) elif l==3: print(x[0]*x[1]*x[2]) elif l==4: print(4) else: print(5)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; struct mint { long long x; mint(long long x = 0) : x((x % mod + mod) % mod) {} mint operator-() const { return mint(-x); } mint& operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint& operator-=(const mint a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; } mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; } mint operator+(const mint a) const { return mint(*this) += a; } mint operator-(const mint a) const { return mint(*this) -= a; } mint operator*(const mint a) const { return mint(*this) *= a; } mint pow(long long t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } mint inv() const { return pow(mod - 2); } mint& operator/=(const mint a) { return *this *= a.inv(); } mint operator/(const mint a) const { return mint(*this) /= a; } }; istream& operator>>(istream& is, mint& a) { return is >> a.x; } ostream& operator<<(ostream& os, const mint& a) { return os << a.x; } long long kaijou(long long x) { long long sum = 1; for (int i = 1; i <= x; ++i) { sum *= i; } return sum; } int main() { int n; cin >> n; vector<int> a(5); for (int i = 0; i < (n); i++) { string s; cin >> s; char sin = s[0]; if (sin == 'M') a.at(0)++; else if (sin == 'A') a.at(1)++; else if (sin == 'R') a.at(2)++; else if (sin == 'C') a.at(3)++; else if (sin == 'H') a.at(4)++; } long long x = 0; long long y = 0; for (int i = 0; i < (5); i++) { if (a.at(i) != 0) x++; if (a.at(i) > 1) y++; } if (x < 3) { cout << 0 << endl; return 0; } int j; if (x == 3) j = 1; else if (x == 4) j = 2; else j = 3; if (y >= j) { if (x == 3) x = 1; else if (x == 4) x = 4; else x = 10; for (int i = 0; i < (5); i++) { if (a.at(i) > 1) { x *= a.at(i); } } } else { int h = x - y; long long ans = 0; long long ut = 0; if (y == 2) { for (int i = 0; i < (5); i++) if (a.at(i) > 1) { ans += h * a.at(i); ut = a.at(i); } ans += h * ut; ans += kaijou(h) / kaijou(3); x = ans; } else { for (int i = 0; i < (5); i++) if (a.at(i) > 1) ans += h * a.at(i); ans += kaijou(h) / kaijou(3); x = ans; } } cout << x << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; vector<int> initial(5); for (int i = 0; i < n; i++) { cin >> s; if (s.at(0) == 'M') initial.at(0)++; else if (s.at(0) == 'A') initial.at(1)++; else if (s.at(0) == 'R') initial.at(2)++; else if (s.at(0) == 'C') initial.at(3)++; else if (s.at(0) == 'H') initial.at(4)++; } int ans = 0; 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}; for (int i = 0; i < 10; i++) { ans += initial.at(P[i]) * initial.at(Q[i]) * initial.at(R[i]); } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> char label[] = {'M', 'A', 'R', 'C', 'H'}; int cache[30]; char name[11]; int main() { int N; scanf("%d", &N); for (int i = 0; i < 30; i++) cache[i] = 0; for (int i = 0; i < N; i++) { scanf("%s", name); cache[name[0] - 'A']++; } int totalcount = 0; for (int x = 0; x < 5; x++) { for (int y = 0; y < 5; y++) { for (int z = 0; z < 5; z++) { if (label[x] != label[y] && label[y] != label[z] && label[z] != label[x]) { totalcount += cache[label[x] - 'A'] * cache[label[y] - 'A'] * cache[label[z] - 'A']; } } } } printf("%ld\n", totalcount / 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; char a[15]; int c[10]; int main() { ios::sync_with_stdio(false); int n; cin >> n; memset(c, 0, sizeof(c)); while (n--) { cin >> a; if (a[0] == 'M') c[1]++; if (a[0] == 'A') c[2]++; if (a[0] == 'R') c[3]++; if (a[0] == 'C') c[4]++; if (a[0] == 'H') c[5]++; } long long ans = 0; for (int i = 1; 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; using ll = long long; int main(int argc, char const *argv[]) { int n; std::cin >> n; string s[100010]; int m = 0, a = 0, r = 0, c = 0, h = 0; for (int i = 0; i < n; i++) { std::cin >> s[i]; if (s[i][0] == 'M') m++; else if (s[i][0] == 'A') a++; else if (s[i][0] == 'R') r++; else if (s[i][0] == 'C') c++; else if (s[i][0] == 'H') h++; } unsigned long long ans = 0; ans += m * a * r; ans += m * a * c; ans += m * a * h; ans += m * r * c; ans += m * r * h; ans += m * c * h; ans += a * r * c; ans += a * r * h; ans += a * c * h; ans += r * c * h; std::cout << ans << '\n'; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; string a; char b[5] = {0}; cin >> N; while (N--) { cin >> a; if (a[0] == 'M') b[0]++; else if (a[0] == 'A') b[1]++; else if (a[0] == 'R') b[2]++; else if (a[0] == 'C') b[3]++; else if (a[0] == 'H') b[4]++; } int s, flag = 0; for (int i = 0; i < 5; i++) if (b[i]) flag++; printf("\n"); if (flag < 3) printf("0\n"); else if (flag == 3) { s = 1; for (int i = 0; i < 5; i++) if (b[i]) s *= b[i]; printf("%d\n", s); } else if (flag >= 4) { s = 0; int x, y, z; for (x = 0; x < 3; x++) for (y = x + 1; y < 4; y++) for (z = y + 1; z < 5; z++) if (b[x] && b[y] && b[z]) s += b[x] * b[y] * b[z]; 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
cpp
#include <bits/stdc++.h> using namespace std; const double EPS = 1e-10; const double PI = acos(-1.0); template <typename Iterator> inline bool next_combination(const Iterator first, Iterator k, const Iterator last) { if ((first == last) || (first == k) || (last == k)) return false; Iterator itr1 = first; Iterator itr2 = last; ++itr1; if (last == itr1) return false; itr1 = last; --itr1; itr1 = k; --itr2; while (first != itr1) { if (*--itr1 < *itr2) { Iterator j = k; while (!(*itr1 < *j)) ++j; iter_swap(itr1, j); ++itr1; ++j; itr2 = k; rotate(itr1, j, last); while (last != j) { ++j; ++itr2; } rotate(k, itr2, last); return true; } } rotate(first, k, last); return false; } inline double get_time_sec(void) { return static_cast<double>(chrono::duration_cast<chrono::nanoseconds>( chrono::steady_clock::now().time_since_epoch()) .count()) / 1000000000; } template <typename T> T gcd(T a, T b) { if (a > b) swap(a, b); if (a == 0) return b; else return gcd(b % a, a); } template <typename T> map<T, T> prime_list(T n) { map<T, T> ret; for (T i = 2; i * i <= n; i++) { if (n % i == 0) { ret[i] = 0; while (n % i == 0) { n /= i; ret[i]++; } } } if (n != 1) ret[n]++; return ret; } long long mypow(long long a, long long n) { if (n == 1) return a % 1000000007; if (n % 2 == 1) return (a * mypow(a, n - 1)) % 1000000007; long long t = mypow(a, n / 2); return (t * t) % 1000000007; } int main(void) { int n; cin >> n; vector<string> s(n); for (int i = (0); i < (n); ++i) cin >> s[i]; vector<long long> v(5, 0); for (int i = (0); i < (n); ++i) { switch (s[i][0]) { case 'M': v[0]++; break; case 'A': v[1]++; break; case 'R': v[2]++; break; case 'C': v[3]++; break; case 'H': v[4]++; break; } } for (int i = (0); i < (n); ++i) { cerr << v[i] << endl; } cout << v[0] * v[1] * v[2] + v[0] * v[1] * v[3] + v[0] * v[1] * v[4] + v[0] * v[2] * v[3] + v[0] * v[2] * v[4] + v[0] * v[3] * v[4] + v[1] * v[2] * v[3] + v[1] * v[2] * v[4] + v[1] * v[3] * v[4] + v[2] * v[3] * v[4] << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { os << v[i]; if (i != v.size() - 1) os << ", "; } os << "]"; return os; } template <typename T> void print(T v, string s = "\n") { cout << v << s; } template <typename T> void in(T& v) { cin >> v; } int main() { int n; in(n); vector<int> C(200, 0); string s; for (int i = 0; i < n; i++) { in(s); C[(int)s[0]]++; } vector<long long> A; long long ans = 0; string t = "MARCH"; 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[t[i]] * C[t[j]] * C[t[k]]; } print(ans); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main(void) { int n, i, j, cnt[5] = {0}, tmp, sum = 0, cnt1; string s; cin >> n; for (i = 0; i < n; i++) { cin >> s; if (s[0] == 'M') cnt[0]++; else if (s[0] == 'A') cnt[1]++; else if (s[0] == 'R') cnt[2]++; else if (s[0] == 'C') cnt[3]++; else if (s[0] == 'H') cnt[4]++; } for (i = 0; i < 1 << 5; i++) { tmp = 1; cnt1 = 0; for (j = 0; j < 5; j++) { if (1 & i >> j) { tmp *= cnt[j]; cnt1++; } } if (cnt1 == 3) { sum += tmp; cout << sum << endl; } } cout << sum << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> const int MAX_N = 100000; int main() { int N, cnt[5] = {}; std::string march = "MARCH"; std::cin >> N; for (int i = 0; i < N; ++i) { std::string S; std::cin >> S; for (int j = 0; j < 5; ++j) { if (S[0] == march[j]) ++cnt[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 += cnt[i] * cnt[j] * cnt[k]; } } } std::cout << ans << std::endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.*; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int N = scanner.nextInt(); HashMap<Character, ArrayList<String>> hashMap = new HashMap<>(); char[] prefixs = new char[5]; prefixs[0] = 'M'; prefixs[1] = 'A'; prefixs[2] = 'R'; prefixs[3] = 'C'; prefixs[4] = 'H'; long ans = 0; for(int i=0; i<5; i++){ hashMap.put(prefixs[i], new ArrayList<>()); } for(int i=0; i<N; i++){ String S = scanner.next(); char firstChar = S.charAt(0); if(hashMap.containsKey(firstChar)){ hashMap.get(firstChar).add(S); }else{ hashMap.put(firstChar, new ArrayList<>()); hashMap.get(firstChar).add(S); } } for(int i=0; i<3; i++){ for(int j=i+1; j<4; j++){ for(int k=j+1; k<5; k++){ ans += hashMap.get(prefixs[i]).size() * hashMap.get(prefixs[j]).size() * hashMap.get(prefixs[k]).size(); } } } System.out.println(ans); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int i, j, k; int n; int num[5] = {0}; int total = 0; string s[100000]; cin >> n; for (i = 0; i < n; i++) { cin >> s[i]; if (s[i][0] == 'M') num[0]++; if (s[i][0] == 'A') num[1]++; if (s[i][0] == 'R') num[2]++; if (s[i][0] == 'C') num[3]++; if (s[i][0] == 'H') num[4]++; } int keta = 0; for (i = 0; i < 5; i++) { if (num[i] > 0) keta++; } if (keta < 3) { cout << "0" << endl; getchar(); getchar(); return 0; } int cnt = 0; int sum[99999] = {0}; for (i = 0; i < 5; i++) { if (num[i] == 0) continue; total = num[i]; int total1 = total; for (j = i + 1; j < 5; j++) { if (num[j] == 0) continue; total = total1 * num[j]; int total2 = total; for (k = j + 1; k < 5; k++) { if (num[k] == 0) continue; total = total * num[k]; sum[cnt] = total; cnt++; total = total2; } } } int sum2 = 0; for (i = 0; i < cnt; i++) { sum2 = sum2 + sum[i]; } cout << sum2 << endl; getchar(); getchar(); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> 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 (a > b) { a = b; return 1; } return 0; } using ll = long long; using namespace std; constexpr long long MAX = 5100000; constexpr long long INF = 1LL << 60; constexpr int MOD = 1000000007; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; map<char, int> dic; for (int i = 0; i < (n); i++) { string s; cin >> s; dic[s[0]]++; } string march = "MARCH"; 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 += dic[march[i]] * dic[march[j]] * dic[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; string s[10000]; long long mm = 0; long long aa = 0; long long rr = 0; long long cc = 0; long long hh = 0; for (int i = 0; i < n; i++) { cin >> s[i]; if (s[i][0] == 'M') { mm++; } else if (s[i][0] == 'A') { aa++; } else if (s[i][0] == 'R') { rr++; } else if (s[i][0] == 'C') { cc++; } else if (s[i][0] == 'H') { hh++; } } long long ans = 0; if (mm != 0 && aa != 0 && rr != 0) { ans = ans + mm * aa * rr; } if (mm != 0 && aa != 0 && cc != 0) { ans = ans + mm * aa * cc; } if (mm != 0 && aa != 0 && hh != 0) { ans = ans + mm * aa * hh; } if (mm != 0 && rr != 0 && cc != 0) { ans = ans + mm * rr * cc; } if (mm != 0 && rr != 0 && hh != 0) { ans = ans + mm * rr * hh; } if (mm != 0 && cc != 0 && hh != 0) { ans = ans + mm * cc * hh; } if (aa != 0 && rr != 0 && cc != 0) { ans = ans + aa * rr * cc; } if (aa != 0 && rr != 0 && hh != 0) { ans = ans + aa * hh * rr; } if (aa != 0 && cc != 0 && hh != 0) { ans = ans + cc * aa * hh; } if (rr != 0 && cc != 0 && hh != 0) { ans = ans + hh * cc * rr; } 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,m=0,a=0,r=0,c=0,h=0; long long ans=; cin>>n; string s; for(int i=0;i<n;i++){ cin>>s; if(s[0]=='M'){m++;} else if(s[0]=='A'){a++;} else if(s[0]=='R'){r++;} else if(s[0]=='C'){c++;} else if(s[0]=='H'){h++;} } ans=m*(a*r+a*c+a*h+r*c+r*h+c*h)+a*(r*c+r*h+c*h)+r*c*h; 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
java
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int[] name = new int[5]; long count = 0; for (int i=0; i<N; i++){ char ini = sc.next().charAt(0); if (ini=='M'){ name[0]++; }else if (ini=='A'){ name[1]++; }else if (ini=='R'){ name[2]++; }else if (ini=='C'){ name[3]++; }else if (ini=='H'){ name[4]++; } } for (int i = 0; i < name.length; i++) { for (int j = i + 1; j < name.length; j++) { for (int k = j + 1; k < name.length; k++) { count += name[i] * name[j] * name[k]; } } } System.out.println(count); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; public static class Program { public static void Main(params string[] args) { var ary = "MARCH".ToArray(); var hash = new HashSet<Char>(ary); var n = int.Parse(Console.ReadLine()); var d = Enumerable .Range(0, n) .Select(x => Console.ReadLine()) .Distinct() .Where(x => hash.Contains(x[0])) .GroupBy(x => x[0]) .ToDictionary(x => x.Key, x => x.Count()); var r = 0; for (int i = 0; i < ary.Length; i++) { for (int j = i + 1; j < ary.Length; j++) { for (int k = j + 1; k < ary.Length; k++) { int v1, v2, v3; if (d.TryGetValue(ary[i], out v1) && d.TryGetValue(ary[j], out v2) && d.TryGetValue(ary[k], out v3)) { r += v1 * v2 * v3; } } } } Console.WriteLine(r); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; long long m = 0, a = 0, r = 0, c = 0, h = 0, n, ans = 0, x[6]; string s; int xx(int a1, int a2, int a3) { return x[a1] * x[a2] * x[a3]; } int main() { cin >> n; for (long long 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++; } x[1] = a; x[2] = r; x[3] = m; x[4] = c; x[5] = h; ans += xx(1, 2, 3); ans += xx(1, 2, 4); ans += xx(1, 2, 5); ans += xx(1, 3, 4); ans += xx(1, 3, 5); ans += xx(1, 4, 5); ans += xx(2, 3, 4); ans += xx(2, 3, 5); ans += xx(2, 4, 5); ans += xx(3, 4, 5); cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll MOD = 1e9 + 7; const long long INF = 1LL << 60; ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; } ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; } ll isPrime(ll n) { if (n < 2) { return 0; } for (ll i = 2; i * i <= n; i++) { if (n % i == 0) { return 0; } } return 1; } vector<ll> getDivisor(ll n) { vector<ll> v; for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { v.push_back(i); if (i != n / i) { v.push_back(n / i); } } } sort(v.begin(), v.end()); return v; } signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll n; cin >> n; vector<ll> m(5, 0); for (ll i = 0; i < (ll)(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]++; } ll ans = 0; for (ll i = 0; i < (ll)(n); i++) { for (ll j = 0; j < (ll)(n); j++) { for (ll k = 0; k < (ll)(n); k++) { if (i != j && j != k && k != i) ans += m[i] * m[j] * m[k]; } } } cout << ans / 6 << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int maxn = 100000; struct A { string name; }; A per[maxn]; long long N; long long ans; long long m = 0, a = 0, r = 0, c = 0, h = 0; int main() { cin >> N; for (int i = 1; i <= N; i++) { cin >> per[i].name; switch (per[i].name[0]) { case 'M': m += 1; break; case 'A': a += 1; break; case 'R': r += 1; break; case 'C': c += 1; break; case 'H': h += 1; break; } } ans += m * a * r + m * a * c + m * a * h + m * r * c + m * r * h + m * c * h + a * r * c + a * r * h + 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; using ll = long long; const int INF = 1 << 30; const int MOD = (int)1e9 + 7; const int MAX_N = (int)1e5 + 5; template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << p.first << " " << p.second; return os; } template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (int i = 0; i < (int)v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; } template <int mod> struct ModInt { int x; ModInt() : x(0) {} ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {} ModInt &operator+=(const ModInt &p) { if ((x += p.x) >= mod) { x -= mod; } return *this; } ModInt &operator-=(const ModInt &p) { if ((x += mod - p.x) >= mod) { x -= mod; } return *this; } ModInt &operator*=(const ModInt &p) { x = (int)(1LL * x * p.x % mod); return *this; } ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; } ModInt operator-() const { return ModInt(-x); } ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; } ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; } ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; } ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; } bool operator==(const ModInt &p) const { return x == p.x; } bool operator!=(const ModInt &p) const { return x != p.x; } ModInt inverse() const { int a = x, b = mod, u = 1, v = 0; while (b > 0) { int t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); } return ModInt(u); } ModInt pow(int64_t n) const { ModInt res(1), mul(x); while (n > 0) { if (n & 1) { res *= mul; } mul *= mul; n >>= 1; } return res; } friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x; } friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt<mod>(t); return (is); } static int get_mod() { return mod; } }; using modint = ModInt<MOD>; void solve() { int n; cin >> n; map<char, ll> mp; const string key = "MARCH"; for (int i = 0; i < n; i++) { string s; cin >> s; int pos = key.find(s.front()); if (pos == -1) continue; mp[s.front()]++; } modint ans = 0; for (int bit = 0; bit < (1 << (int)key.size()); bit++) { if (__builtin_popcount(bit) != 3) continue; modint cnt = 1; for (int i = 0; i < (int)key.size(); i++) { if (bit & (1 << i)) cnt *= mp[key[i]]; } ans += cnt; } cout << ans << endl; } signed main(void) { cin.tie(0); ios::sync_with_stdio(false); solve(); 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.*; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); HashMap<String, Integer> map = new HashMap<String, Integer>(); String[] a = {"M", "A", "R", "C", "H"}; for(String s:a) { map.put(s, 0); } for(int i = 0; i<N; i++) { String x = sc.next().substring(0,1); int c = (map.containsKey(x))? map.get(x): 0; map.put(x, c+1); } int sum = 0; for(int i = 0; i<3; i++) { for(int j = i+1; j<4; j++) { for(int k = j+1; k<5; k++) { sum += map.get(a[i])*map.get(a[j])*map.get(a[k]); } } } System.out.println(sum); } }