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
UNKNOWN
using System; class prog{ static void Main(string[] args){ int N =int.Parse(Console.ReadLine()); int count=0; for(int i=0;i<N;i++){ string name=Console.ReadLine(); char[] march={'m','r','a','c','h'}; foreach(char c in march){ if(name[0] == c){ count++; break; } } } if(count>=3) Console.WriteLine(count*(count -1)*(count-2)/1/2/3); else Console.WriteLine("0"); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using ll = long long; using namespace std; const int INF = 1e9; int main() { int N; cin >> N; ll cnt[5] = {0}; string T = "MARCH"; for (int i = 0; i < N; ++i) { string S; cin >> S; for (int j = 0; j < N; ++j) if (S[0] == T[j]) { ++cnt[j]; break; } } ll ans = 0; for (int i = 0; i < N; ++i) { for (int j = i + 1; j < N; ++j) { for (int k = j + 1; k < N; ++k) { if (i == j || j == k) continue; ans += cnt[i] * cnt[j] * cnt[k]; } } } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") using namespace std; const long long int INF = 2147483647; const long long int MINF = -2147483648; const long long int LINF = 9223372036854775807; const long long int MOD = 1000000007; const double PI = acos(-1); using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>; using vlli = vector<long long int>; using vvli = vector<vlli>; using vs = vector<string>; using vvs = vector<vs>; using vb = vector<bool>; using vvb = vector<vb>; using ll = long long; template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (T &x : vec) is >> x; return is; } template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) { for (int i = 0; i < vec.size(); i++) { os << vec[i] << (i + 1 == vec.size() ? "" : ""); } return os; } template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; } long long int solve() { long long int a = 0, b = 0, c = 0, h = 0, n = 0, w = 0, ans = 0, count = 0; string s = "", t = ""; vector<pair<long long int, long long int>> pr; map<long long int, long long int> make_pair; set<long long int> st; ios::sync_with_stdio(false); cin.tie(nullptr); cin >> n; vs d; map<char, long long int> e; for (long long int i = 0; i < (n); i++) { cin >> s; if (s[0] == 'M' || s[0] == 'A' || s[0] == 'R' || s[0] == 'C' || s[0] == 'H') { e[s[0]]++; count++; } } for (auto x : e) { ans += (count - x.second) * (x.second - 1); } w = (count * (count - 1) * (count - 2) / 6) - ans; return w; } signed main() { cout << solve() << '\n'; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; 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][1]) { 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 * 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 <bits/stdc++.h> using namespace std; int main() { int n; string s; cin >> n; int m, a, r, c, h; m = a = r = c = h = 0; for (int i = 0; i < n; i++) { cin >> s; if (s[0] == 'M') m++; if (s[0] == 'A') a++; if (s[0] == 'R') r++; if (s[0] == 'C') c++; if (s[0] == 'H') h++; } long 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; cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using LL = long long; template <typename T1, typename T2> using P = pair<T1, T2>; using Pii = P<int, int>; using Pdd = P<double, double>; template <typename T> using V = vector<T>; using Vi = V<int>; using Vll = V<LL>; using Vs = V<string>; template <typename T1, typename T2> using M = map<T1, T2>; using Mii = M<int, int>; using Msi = M<string, int>; const int MOD = 1000000007; const int INF = 1999999999; const LL INFLL = 999999999999999LL; const double EPS = 1e-10; const int DX[8] = {-1, 0, 1, 0, -1, -1, 1, 1}; const int DY[8] = {0, -1, 0, 1, -1, 1, 1, -1}; const double PI = 3.141592653589793; void SCAN(int *a) { scanf("%d", a); } void SCAN(int *a, int n) { for (int(i) = 0; (i) < (n); (i)++) { scanf("%d", &a[i]); } } void SCAN(Pii *a) { scanf("%d", &a->first); scanf("%d", &a->second); } void SCAN(LL *a) { scanf("%lld", a); } void SCAN(LL *a, int n) { for (int(i) = 0; (i) < (n); (i)++) { scanf("%lld", &a[i]); } } void SCAN(char *c) { scanf(" %c", c); } void SCAN(char *c, int n) { for (int(i) = 0; (i) < (n); (i)++) { scanf(" %c", &c[i]); } } void PRINT(int a) { printf("%d\n", a); } void PRINT(int *a, int s, char c = '\n') { for (int(i) = 0; (i) < (s); (i)++) { if (i == s - 1) { c = '\n'; } printf("%d%c", a[i], c); } } void PRINT(Vi a, char c = '\n') { for (int(i) = 0; (i) < (a.size()); (i)++) { if (i == a.size() - 1) { c = '\n'; } printf("%d%c", a[i], c); } } void PRINT(LL a) { printf("%lld\n", a); } void PRINT(LL *a, int s, char c = '\n') { for (int(i) = 0; (i) < (s); (i)++) { if (i == s - 1) { c = '\n'; } printf("%lld%c", a[i], c); } } void PRINT(double a) { printf("%.15f\n", a); } void PRINT(double *a, int s, char c = '\n') { for (int(i) = 0; (i) < (s); (i)++) { if (i == s - 1) { c = '\n'; } printf("%f%c", a[i], c); } } void PRINT(char a) { printf("%c\n", a); } void PRINT(string a) { printf("%s\n", a.c_str()); } template <typename A> void UNIQUE(vector<A> &a, int mode = 0) { if (mode == 0) { sort((a).begin(), (a).end(), greater<A>()); } else { sort((a).begin(), (a).end()); } a.erase(unique((a).begin(), (a).end()), a.end()); } template <typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val) { fill((T *)array, (T *)(array + N), val); } template <typename T> int sgn(T val) { return (T(0) < val) - (val < T(0)); } LL pascalTri(LL n, LL r) { LL tri[n + 1][n + 1]; for (int(i) = 0; (i) < (n + 1); (i)++) { for (int(j) = 0; (j) < (n + 1); (j)++) { tri[i][j] = 0; } } for (int(i) = 0; (i) < (n + 1); (i)++) { for (int(j) = 0; (j) < (n + 1); (j)++) { if (j > i) { break; } if (j == 0 || j == i) { tri[i][j] = 1; } else { tri[i][j] = (tri[i - 1][j - 1] + tri[i - 1][j]); } } } return tri[n][r]; } LL GCD(LL a, LL b) { LL t; LL r; if (a < b) { t = a; a = b; b = t; } if (b == 0) { return a; } while (a % b != 0) { r = a % b; a = b; b = r; } return b; } LL LCM(LL a, LL b) { LL ab = (a * b) % MOD; return ab / GCD(a % b, b); } LL BMPow(int x, int n, int m = 0) { LL ans = 1; LL p = x; if (m == 0) { while (n > 0) { if (n & 1 == 1) { ans *= p; } p *= p; n >>= 1; } } else { while (n > 0) { if (n & 1 == 1) { ans = (ans * p) % m; } p = (p * p) % m; n >>= 1; } } return ans; } LL modInv(LL x, int m) { return BMPow(x, m - 2, m); } LL factorial(int x, int m = 0) { LL a = 1; if (m == 0) { for (int(i) = (x); (i) >= (1); (i)--) { a *= i; } } else { for (int(i) = (x); (i) >= (1); (i)--) { a = (a * i) % m; } } return a; } P<Vll, Vll> primeFactor(LL n) { Vll p, e; LL m = n; int c; for (LL i = 2; i * i <= n; i++) { if (m % i != 0) { continue; } c = 0; while (m % i == 0) { c++; m /= i; } p.push_back(i); e.push_back(c); } if (m > 1) { p.push_back(m); e.push_back(1); } return make_pair(p, e); } template <typename T> using coordinate = P<T, T>; template <typename T> using coordinateSet = V<coordinate<T>>; template <typename T> coordinate<double> centroidPolygon(coordinateSet<T> &a) { coordinate<double> G; G.first = 0.; G.second = 0.; int n = a.size(); for (auto &(i) : a) { G.first += i.first; G.second += i.second; } G.first /= n; G.second /= n; return G; } double area(coordinate<int> a, coordinate<int> b, coordinate<int> c) { return ((b.first - a.first) * (c.second - a.second) - (b.second - a.second) * (c.first - a.first)) / 2.; } int checkCross(coordinate<int> v1, coordinate<int> v2, coordinate<int> a, coordinate<int> b) { if (area(a, b, v1) * area(a, b, v2) >= 0) { return 0; } if (area(v1, v2, a) * area(v1, v2, b) >= 0) { return 0; } return 1; } struct edge { int src; int dst; int weight; edge() : src(0), dst(0), weight(0) {} edge(int s, int d, int w) : src(s), dst(d), weight(w) {} }; using edges = V<edge>; using graph = V<edges>; void add_edge(edges &g, int s, int d, int w = 1) { g.push_back(edge(s, d, w)); } void add_edge(graph &g, int s, int d, int w = 1) { g[s].push_back(edge(s, d, w)); } V<Vi> floyd(const graph &g) { int i, j, k; int n = g.size(); V<Vi> dist(n, Vi(n, INF / 2)); for (int(i) = 0; (i) < (n); (i)++) { dist[i][i] = 0; } for (int(i) = 0; (i) < (n); (i)++) { for (auto &e : g[i]) { dist[e.src][e.dst] = e.weight; } } for (int(k) = 0; (k) < (n); (k)++) { for (int(i) = 0; (i) < (n); (i)++) { for (int(j) = 0; (j) < (n); (j)++) { dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]); } } } return dist; } Vi dijkstra(graph &g, int s) { int i, j, k; int n = g.size(); int visit[n]; Vi dist(n); priority_queue<Pii, V<Pii>, greater<Pii>> q; for (int(i) = 0; (i) < (n); (i)++) { visit[i] = 0; dist[i] = INF / 2; } dist[s] = 0; q.push(make_pair(0, s)); int nv; int min_cost = 0; while (!q.empty()) { int d, t; tie(d, t) = q.top(); q.pop(); if (visit[t] == 1) { continue; } visit[t] = 1; dist[t] = d; for (auto &e : g[t]) { if (dist[e.dst] <= d + e.weight) { continue; } q.push(make_pair(d + e.weight, e.dst)); } } return dist; } template <typename T> struct binaryIndexedTree { private: int n; V<T> x; public: binaryIndexedTree(int num = 0) : n(num), x(n, 0) {} void add(int a, T w) { for (int i = a; i < n; i |= i + 1) { if (x[i] < w) { x[i] = w; } } } T maximum(int a) { T m = -1; for (int k = a - 1; k >= 0; k = (k & (k + 1)) - 1) { m = max(m, x[k]); } return m; } }; struct unionFind { private: Vi data; public: unionFind(int size) : data(size, -1) {} bool unionSet(int x, int y) { x = root(x); y = root(y); if (x != y) { if (data[y] < data[x]) { swap(x, y); } data[x] += data[y]; data[y] = x; } return x != y; } bool findSet(int x, int y) { return root(x) == root(y); } int root(int x) { return ((data[x] < 0) ? x : (data[x] = root(data[x]))); } int size(int x) { return -data[root(x)]; } }; int main() { cin.tie(0); ios::sync_with_stdio(false); LL n; cin >> n; string s; string m = "MARCH"; M<char, LL> ss; for (int(i) = 0; (i) < (n); (i)++) { cin >> s; ss[s[0]]++; } LL a = 0; for (int(i) = 0; (i) < (m.size()); (i)++) { a += ss[m[i]]; } if (a == 0) { cout << 0 << endl; return 0; } LL ans = pascalTri(a, 3LL); for (int(i) = 0; (i) < (m.size()); (i)++) { if (ss[m[i]] <= 1) { continue; } ans -= pascalTri(ss[m[i]], 2LL) * pascalTri(a - ss[m[i]], 1LL); } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n, m, a, r, c, h; cin >> n; m = a = r = c = h = 0; 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++; } long long int sum; sum = m * a * r + m * a * c + m * a * h + m * r * c + m * r * h + m * c * h + a * r * c + a * r * h + a * c * h + r * c * h; cout << sum << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; const int MOD = 1e9 + 7; const double pi = 3.14159265358979323846; const int inf = 1e9; const ll INF = 1e18; using P = pair<int, int>; int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}; int main() { cin.tie(0), cout.tie(0); ios::sync_with_stdio(false); ll n, ans = 0; string s; map<int, int> m; cin >> n; for (int i = 0; i < n; i++) { 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]++; } } for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; 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; const double PI = 3.14159265358979323846; template <class T> void print(const T& x) { cout << x << endl; } template <class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); } struct PreMain { PreMain() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); } } premain; int kosu[5]; int main() { int n; cin >> n; string s; for (int(i) = 0; (i) < (int)(n); ++(i)) { cin >> s; if (s[0] == 'M') kosu[0]++; else if (s[0] == 'A') kosu[1]++; else if (s[0] == 'R') kosu[2]++; else if (s[0] == 'C') kosu[3]++; else if (s[0] == 'H') kosu[4]++; } long long ans = 0; for (int(i) = 0; (i) < (int)(2); ++(i)) for (int(j) = 0; (j) < (int)(2); ++(j)) for (int(k) = 0; (k) < (int)(2); ++(k)) for (int(l) = 0; (l) < (int)(2); ++(l)) for (int(m) = 0; (m) < (int)(2); ++(m)) { int tmp = 1; if (i + j + k + l + m == 3) { if (i) { tmp *= kosu[0]; } if (j) { tmp *= kosu[1]; } if (k) { tmp *= kosu[2]; } if (l) { tmp *= kosu[3]; } if (m) { tmp *= kosu[4]; } ans += tmp; } } 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; char s[100000]; map<char, int> S; int main() { int n; int sum = 0; scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%s", s); if (s[0] == 'M' || s[0] == 'A' || s[0] == 'R' || s[0] == 'C' || s[0] == 'H') S[s[0]]++; } if (n < 3) printf("0\n"); else { sum += (S['M'] * S['A'] * S['R']); sum += (S['M'] * S['A'] * S['C']); sum += (S['M'] * S['A'] * S['H']); sum += (S['M'] * S['R'] * S['C']); sum += (S['M'] * S['R'] * S['H']); sum += (S['M'] * S['C'] * S['H']); sum += (S['A'] * S['R'] * S['C']); sum += (S['A'] * S['R'] * S['H']); sum += (S['A'] * S['C'] * S['H']); sum += (S['R'] * S['C'] * S['H']); printf("%d\n", sum); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; signed main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; int cnt[10] = {}; 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 ans = 0; for (int i = 0; i < (5); ++i) for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < n; k++) { ans += cnt[i] * cnt[j] * cnt[k]; } } 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; template <class Type_a, class Type_b> bool chmax(Type_a &a, const Type_b &b) { if (a < b) { a = b; return true; } return false; } template <class Type_a, class Type_b> bool chmin(Type_a &a, const Type_b &b) { if (a > b) { a = b; return true; } return false; } template <class Type> void line(const Type &a) { int cnt = 0; for (const auto &elem : a) { if (cnt++) cout << ' '; cout << elem; } cout << endl; } int main() { string key = "MARCH"; int n; cin >> n; map<char, int> mp; for (int i = 0; i < (n); ++i) { string s; cin >> s; mp[s[0]]++; } 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 += mp[key[i]] * mp[key[j]] * mp[key[k]]; } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> int main() { long n; std::cin >> n; std::vector<std::string> s(n); for (int i = 0; i < n; i++) { std::cin >> s[i]; } char ch[5] = {'M', 'A', 'R', 'C', 'H'}; std::vector<std::vector<std::string>> v(5); for (int i = 0; i < n; i++) { for (int j = 0; j < 5; j++) { if (s[i][0] == ch[j]) { v[j].push_back(s[i]); } } } std::vector<int> a = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2}; std::vector<int> b = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3}; std::vector<int> c = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4}; int res = 0; for (int i = 0; i < 10; i++) { res += v[a[i]].size() * v[b[i]].size() * v[c[i]].size(); } std::cout << res << std::endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; 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 = 0; for (int j = 0; j < (int)(5); j++) { b = b + a[j]; } ans = ans + a[i] - b; } } } 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() { int N, count = 0; vector<int> f(5, 0); long long int ans = 0, sum = 1; string name; cin >> N; for (int i = 0; i < N; i++) { cin >> name; if (name[0] == 'M') { f[0]++; } else if (name[0] == 'A') { f[1]++; } else if (name[0] == 'R') { f[2]++; } else if (name[0] == 'C') { f[3]++; } else if (name[0] == 'H') { f[4]++; } } for (int i = 0; i < 5; i++) { if (0 < f[i]) { count++; sum *= f[i]; } } if (count < 3) { cout << "0" << endl; } else if (count == 3) { cout << sum << endl; } else if (count == 4) { for (int i = 0; i < 5; i++) { if (f[i] != 0) { ans += sum / f[i]; } } cout << ans << endl; } else { for (int i = 0; i < 4; i++) { for (int j = i + 1; j < 5; j++) { ans += sum / f[i] / f[j]; } } cout << ans << endl; } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
a=int(input()) lis=[input()[0] for i in range(a)] lis2=[0,0,0,0,0] dellist=[] for m in lis: if m=="M": lis2[0]+=1 elif m=="A": lis2[1]+=1 elif m=="R": lis2[2]+=1 elif m=="C": lis2[3]+=1 elif m=="H": lis2[4]+=1 a=sum(lis2) print(lis2,a) def c3(a): return a*(a-1)*(a-2)/6 def c2(a): return a*(a-1)/2 ans=c3(a) for i in lis2: ans=ans-c3(i)-c2(i)*(a-i) print(int(ans))
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main(void) { int N; cin >> N; string S; long MARCH[5] = {0}; for (int i = 0; i < N; i++) { cin >> S; switch (S[0]) { case 'M': MARCH[0]++; break; case 'A': MARCH[1]++; break; case 'R': MARCH[2]++; break; case 'C': MARCH[3]++; break; case 'H': MARCH[4]++; break; } } long count = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { count += MARCH[i] * MARCH[j] * MARCH[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; int main(){ int n; cin>>n; string s; int a[n]={}; for(int i=0;i<n;i++){ cin>>s; char c=s.front(); if(c=='M') a[0]++; else if(c=='A') a[1]++; else if(c=='R') a[2]++; else if(c=='C') a[3]++; else if(c=='H') a[4]++; } int c=0; for(int i=0;i<3;i++){ for(int j=i+1;j<4;j++){ for(int k=j+1;k<5;k++){ c+=a[i]*a[j]*a[k]; } } } cout<<c; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { vector<set<string>> V; int n; set<string> M, A, R, C, H; V.push_back(M); V.push_back(A); V.push_back(R); V.push_back(C); V.push_back(H); cin >> n; string s; for (int i = 0; i < n; i++) { cin >> s; if (s[0] == 'M') V[0].insert(s); if (s[0] == 'A') V[1].insert(s); if (s[0] == 'R') V[2].insert(s); if (s[0] == 'C') V[3].insert(s); if (s[0] == 'H') V[4].insert(s); } int ans = 0; ans += V[0].size() * V[1].size() * V[2].size(); ans += V[0].size() * V[1].size() * V[3].size(); ans += V[0].size() * V[1].size() * V[4].size(); ans += V[0].size() * V[2].size() * V[3].size(); ans += V[0].size() * V[2].size() * V[4].size(); ans += V[1].size() * V[3].size() * V[4].size(); ans += V[1].size() * V[2].size() * V[3].size(); ans += V[1].size() * V[2].size() * V[4].size(); ans += V[1].size() * V[3].size() * V[4].size(); ans += V[2].size() * V[3].size() * V[4].size(); 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 T{"MARCH"}; int N; cin >> N; vector<int> C(T.size()); while (N--) { string s; cin >> s; for (int t = 0; t < T.size(); ++t) if (s[0] == T[t]) C[t]++; } long long ans = 0; for (int i = 0; i < C.size(); ++i) for (int j = i + 1; j < C.size(); ++j) for (int k = j + 1; k < C.size(); ++k) ans += C[i] * C[j] * C[k]; cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
n=int(input()) march=[0]*5 march_dic={"M":0,"A":1,"R":2,"C":3,"H":4} for i in range(n): name=input() if name[0] in "MARCH": march[march_dic[name[0]]]+=1 def count_type(march): ans=[] for i in march: if i!=0: ans.append(i) ans.sort() return n-march.count(0),ans type_num,each_num=count_type(march) if type_num<3: print(0) else: ans=0 for i in range(type_num-2): for j in range(i+1,type_num-1): for k in range(j+1,type_num): ans+=each_num[i]*each_num[j]*each_num[k] print(ans)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n, cm = 0, ca = 0, cr = 0, cc = 0, ch = 0, f = 0; cin >> n; vector<string> data(n); for (int i = 0; i < n; i++) { cin >> data.at(i); } sort(data.begin(), data.end()); data.erase(unique(data.begin(), data.end()), data.end()); for (int i = 0; i < data.size(); i++) { if (data.at(i).at(0) == 'M') { cm++; } else if (data.at(i).at(0) == 'A') { ca++; } else if (data.at(i).at(0) == 'R') { cr++; } else if (data.at(i).at(0) == 'C') { cc++; } else if (data.at(i).at(0) == 'H') { ch++; } } long long ans; ans = cm * ca * cr + cm * ca * cc + cm * ca * ch + cm * cr * cc + cm * cr * ch + cm * cc * ch + ca * cr * cc + ca * cr * ch + ca * cc * ch + cr * cc * ch; 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 c[5]; int main() { ios::sync_with_stdio(0); cin.tie(0); ; int n; while (cin >> n) { for (int i = 0; i < n; i++) { string a; cin >> a; if (a[0] == 'M') { c[0]++; } else if (a[0] == 'A') { c[1]++; } else if (a[0] == 'R') { c[2]++; } else if (a[0] == 'C') { c[3]++; } else if (a[0] == 'H') { c[4]++; } else { continue; } } int ans = 0; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { for (int k = j + 1; k < n; k++) { ans = ans + c[i] * c[j] * c[k]; } } } cout << ans << endl; } return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int asc(const void *a, const void *b) { return *(int *)a - *(int *)b; } int desc(const void *a, const void *b) { return *(int *)b - *(int *)a; } long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } long long lcm(long long a, long long b) { long long g = gcd(a, b); return a / g * b; } long long fac(long long n) { if (n > 0) { return n * fac(n - 1); } else { return 1; } } int main() { long long n, ans = 0; cin >> n; vector<int> cnt(n, 0); string s; for (int(i) = 0; (i) < (n); ++(i)) { cin >> s; if (s[0] == 'M') { ++cnt[0]; } else if (s[0] == 'A') { ++cnt[1]; } else if (s[0] == 'R') { ++cnt[2]; } else if (s[0] == 'C') { ++cnt[3]; } else if (s[0] == 'H') { ++cnt[4]; } } for (int(i) = 0; (i) < (3); ++(i)) { for (int(j) = (i + 1); (j) < (4); ++(j)) { for (int(k) = (j + 1); (k) < (5); ++(k)) { ans += cnt[i] * cnt[j] * cnt[k]; } } } cout << ans << endl; 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 pi = acos(-1); const double eps = 1e-6; long long c(long long a, long long b) { int i; long long ans; ans = 1; for (i = a; i > a - b; i--) { ans *= i; } for (i = b; i >= 1; i--) { ans /= i; } return ans; } int main() { ios::sync_with_stdio(false); int n; cin >> n; if (n <= 2) { cout << 0 << endl; return 0; } string s[n + 1], name[n + 1]; long long M, A, R, C, H; M = 0; A = 0; R = 0; C = 0; H = 0; int i; for (i = 1; i <= n; i++) { cin >> s[i]; } for (i = 1; i <= n; i++) { if (s[i][0] == 'M') { M++; name[i] = 'M'; } if (s[i][0] == 'A') { A++; name[i] = 'A'; } if (s[i][0] == 'R') { R++; name[i] = 'R'; } if (s[i][0] == 'C') { C++; name[i] = 'C'; } if (s[i][0] == 'H') { H++; name[i] = s[i][0] = 'H'; } } long long ans, x, cnt; ans = c(M + A + R + C + H, 3); if (M > 1) { x = 0; for (i = 1; i <= M - 1; i++) { x += i; } cnt = 0; for (i = 1; i <= n; i++) { if (name[i] != "M" && name[i] != "") { cnt++; } } if (cnt != 0) ans -= x * cnt; else ans = 1; } if (A > 1) { x = 0; for (i = 1; i <= A - 1; i++) { x += i; } cnt = 0; for (i = 1; i <= n; i++) { if (name[i] != "A" && name[i] != "") { cnt++; } } if (cnt != 0) ans -= x * cnt; else ans = 1; } if (R > 1) { x = 0; for (i = 1; i <= R - 1; i++) { x += i; } cnt = 0; for (i = 1; i <= n; i++) { if (name[i] != "R" && name[i] != "") { cnt++; } } if (cnt != 0) ans -= x * cnt; else ans = 1; } if (C > 1) { x = 0; for (i = 1; i <= C - 1; i++) { x += i; } cnt = 0; for (i = 1; i <= n; i++) { if (name[i] != "C" && name[i] != "") { cnt++; } } if (cnt != 0) ans -= x * cnt; else ans = 1; } if (H > 1) { x = 0; for (i = 1; i <= H - 1; i++) { x += i; } cnt = 0; for (i = 1; i <= n; i++) { if (name[i] != "H" && name[i] != "") { cnt++; } } if (cnt != 0) ans -= x * cnt; else ans = 1; } if (M == 0 && A == 0 && R == 0 && C == 0 && H == 0) { cout << 0 << endl; return 0; } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int n; cin >> n; vector<string> s(n); for (int i = 0; i < n; i++) { cin >> s[i]; } map<char, int> top; for (string str : s) { top[str[0]]++; } ll ans = 0; char march[5] = {'M', 'A', 'R', 'C', 'H'}; for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 4; j++) { for (int k = j + 1; k < 5; k++) { ans += top[march[i]] * top[march[j]] * top[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
python3
for i in range(n): a = input() if a[0] == "M":Mnum+=1 elif a[0] == "A":Anum+=1 elif a[0] == "R":Rnum+=1 elif a[0] == "C":Cnum+=1 elif a[0] == "H":Hnum+=1 alist = [] alist.append(Mnum) alist.append(Anum) alist.append(Rnum) alist.append(Cnum) alist.append(Hnum) from itertools import combinations blist =list(combinations(alist,3)) from functools import reduce sum = 0 for i in range(len(blist)): sum+=reduce(mul,blist) print(sum)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; 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, no = 0; for (int i = 0; i < N; i++) { switch (name[i][1]) { case 'M': m++; break; case 'A': a++; break; case 'R': r++; break; case 'C': c++; break; case 'H': h++; break; default: no++; break; } } long long ans; ans = m * a * r + m * a * c + m * a * h + m * r * c + m * r * h + m * c * h + a * r * c + a * r * h + a * c * h + r * c * h + 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
java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.*; class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); Task solver = new Task(); solver.solve(in, out); out.close(); } static class Task { int next_combination(int sub) { int x = sub & -sub, y = sub + x; return (((sub & ~y) / x) >> 1) | y; } void solve(InputReader in, PrintWriter out) { int N = in.nextInt(); char[] march = new char[] {'M', 'A', 'R', 'C', 'H'}; Map<Character, Integer> cntByIni = new HashMap<>(); for (char c : march) cntByIni.put(c, 0); for (int i = 0; i < N; i++) { char ini = in.next().charAt(0); if (cntByIni.containsKey(ini)) { cntByIni.put(ini, cntByIni.get(ini) + 1); } } int ans = 0; int mask = (1 << 3) - 1; for (; mask < (1 << 5); mask = next_combination(mask)) { int pattern = 1; for (int i = 0; i < 5; i++) { if ((mask >> i & 1) == 1) { pattern *= cntByIni.get(march[i]); } } ans += pattern; } out.println(ans); } } static class InputReader { BufferedReader reader; StringTokenizer tokenizer; InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream)); tokenizer = null; } String next() { while (tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new StringTokenizer(reader.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken(); } int nextInt() { return Integer.parseInt(next()); } } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int64_t n; cin>>n; vector<string> s(n); for(int i=0;i<n;i++){ cin>>s.at(i); } int M=0; int A=0; int R=0; int C=0; int H=0; for(int i=0;i<n;i++){ if(s.at(i)=='M'){ M++; } if(s.at(i)=='A'){ A++; } if(s.at(i)=='R'){ R++; } if(s.at(i)=='C'){ C++; } if(s.at(i)=='H'){ H++; } } int64_t count=0; count+=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<<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
#include <bits/stdc++.h> int main(void) { int N; scanf("%d", &N); static char S[10000][11]; for (int i = 0; i < N; i++) { scanf("%s", S[i]); } long long int name[5] = {0}; for (int i = 0; i < N; i++) { switch (S[i][0]) { case 'M': name[0]++; break; case 'A': name[1]++; break; case 'R': name[2]++; break; case 'C': name[3]++; break; case 'H': name[4]++; break; } } 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}; long long int ans = 0; for (int i = 0; i < 10; i++) { ans += name[P[i]] * name[Q[i]] * name[R[i]]; } printf("%lld\n", ans); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> const int MGN = 8; const int ARY_SZ_MAX = 10000000; using namespace std; using ll = long long; using ull = unsigned long long; using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>; using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>; using vl = vector<ll>; using vvl = vector<vl>; using vd = vector<double>; using vs = vector<string>; using pii = pair<int, int>; using pll = pair<ll, ll>; int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; vs S(N); for (int i = int(0); i < int(N); ++i) cin >> S[i]; string ptn = "MARCH"; map<char, int> mp; for (string s : S) { for (int i = int(0); i < int(5); ++i) { if (s[0] == ptn[i]) mp[s[0]]++; } } ll ans = 0; if (mp.size() >= 3) { for (int i = int(0); i < int(5); ++i) for (int j = int(i + 1); j < int(5); ++j) for (int k = int(j + 1); k < int(5); ++k) ans += mp[ptn[i]] * mp[ptn[j]] * mp[ptn[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; string s[25]; int a[10]; int n, i, j, k; long long cnt = 0; int main() { cin >> n; for (i = 1; i <= n; ++i) { cin >> s[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]++; } for (i = 1; i <= 3; ++i) { while (a[i] == 0 && i < 3) ++i; if (i == 3 && a[i] == 0) continue; for (j = i + 1; j <= 4; ++j) { while (a[j] == 0 && j < 4) ++j; if (j == 4 && a[j] == 0) continue; for (k = j + 1; k <= 5; ++k) { while (a[k] == 0 && k < 5) ++k; if (k == 5 && a[k] == 0) continue; cnt += a[i] * a[j] * a[k]; } } } cout << cnt << 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; static const int MOD = 1000000007; int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; string str; vector<long long> cnt(5, 0); for (int i = (int)0; i < (int)N; ++i) { cin >> str; switch (str[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; } } sort((cnt).begin(), (cnt).end(), [](long long x, long long y) { return x > y; }); long long ans = 0ll, sum; for (int i = (int)0; i < (int)5; ++i) { sum = 0ll; if (cnt[i] == 0) continue; for (int j = (int)i + 1; j < (int)5; ++j) { if (cnt[j] == 0) continue; for (int k = (int)j + 1; k < (int)5; ++k) { if (cnt[k] == 0) continue; ++sum; } } ans += sum * cnt[i]; } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N, i, j, k; int count[5] = {0}; long long int sum = 0; char S[12]; cin >> N; for (i = 0; i < N; i++) { cin >> S; switch (S[0]) { case 'M': count[0]++; break; case 'A': count[1]++; break; case 'R': count[2]++; break; case 'C': count[3]++; break; case 'H': count[4]++; break; } } for (i = 0; i < 3; i++) { for (j = i + 1; j < 4; j++) { for (k = j + 1; k < 5; k++) { sum += count[i] * count[j] * count[k]; } } } cout << sum << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n, i, j, k, sum = 0; int c[5] = {}; string s; cin >> n; for (i = 0; i < n; i++) { cin >> s; switch (s[0]) { case 'M': c[0]++; break; case 'A': c[1]++; break; case 'R': c[2]; break; case 'C': c[3]; break; case 'H': c[4]; break; } } for (i = 0; i < 5; i++) { for (j = i + 1; j < 5; j++) { for (k = j + 1; k < 5; k++) { sum += c[i] * c[j] * c[k]; } } } cout << sum; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N, countm = 0, counta = 0, countr = 0, countc = 0, counth = 0; long long ans = 0; string people; cin >> N; for (int i = 0; i < N; i++) { cin >> people; if (people[0] == 'M') countm++; if (people[0] == 'A') counta++; if (people[0] == 'R') countr++; if (people[0] == 'C') countc++; if (people[0] == 'H') counth++; } ans = countm * counta * countr + countm * counta * countc + countm * counta * counth + countm * countr * countc + countm * countr * counth + countm * countc * counth + counta * countr * countc + counta * countr * counth + countr * countc * counth; cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int N; cin >> N; int M, A, R, C, H; M = 0; A = 0; R = 0; C = 0; H = 0; for (int i = 0; i < N; i++) { string S; cin >> S; if (S[0] == 'M') M++; if (S[0] == 'A') A++; if (S[0] == 'R') R++; if (S[0] == 'C') C++; if (S[0] == 'H') H++; } vector<int> V = {M, A, R, C, H}; ll ans = 0; for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 4; j++) { for (int k = j + 1; k < 5; k++) { ans += V[i] * V[j] * V[k]; } } } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
import std.stdio; import std.string; import std.conv; import std.algorithm; void main() { long N = to!long(readln.chomp); char[] name = ['M', 'A', 'R', 'C', 'H']; long[char] hash; foreach (long i; 0..N) { string s = readln; if (name.count(s[0])) { hash[s[0]]++; } } writeln(reduce!("a * b")(1L, hash) * combination(cast(long)hash.length) - (3 == hash.length ? 0 : reduce!("a + b - 1")(0L, hash))); } long combination(long n, long r = 3) { return factorial(n) / (factorial(r) * factorial(n - r)); } long factorial(long n) { long ret = 1; for (long i = 1; i <= n; i++) { ret *= i; } return ret; } unittest { /* factorial */ assert(factorial(3) == 6); assert(factorial(5) == 120); }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.Scanner; public class Main { public static void main(String [] args){ Scanner sc =new Scanner(System.in); int N =sc.nextInt(); String s[] = new String[N]; int m=0; int a=0; int r=0; int c=0; int h=0; for (int i=0;i<N;i++) { s[i] = sc.nextLine(); if(s[i].startsWith("M")) { m++; } if(s[i].startsWith("A")) { a++; } if(s[i].startsWith("R")) { r++; } if(s[i].startsWith("C")) { c++; } if(s[i].startsWith("H")) { h++; } } long ans =m*a*r + m*a*c + m*a*h + a*r*c + a*r*h + r*c*h +m*r*c + m*c*h +a*c*h; 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
python3
import sys import math n = int(input()) s = [input() for m in range(n)] march = ['M','A','R','C','H'] ans = [] for i in range(n): if s[i][0] in march: ans.append(s[i][0]) s_set = set(ans) sl = len(s_set) double_num = len(ans) - len(s_set) factorial_num = math.factorial(sl) // (math.factorial(sl - 3) * math.factorial(3)) if sl <= 2: print(0) sys.exit() elif sl == 3: print(factorial_num + factorial_num*double_num) sys.exit() elif sl == 4: print(factorial_num + factorial_num*(double_num) -(1*double_num)) sys.exit() else: print(factorial_num + factorial_num*double_num -(4 *double_num)) sys.exit()
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include<iostream> #include<string> #include <cmath> #include <algorithm> #include <vector> #include <cstdint> #include <map> #define MOD 1000000007 using namespace std; typedef long long ll; int main(){ ll n; cin >> n; string s[10]; ll MARCH[5] = {}; for(ll i = 0; i<n; i++){ s.shrink_to_fit(); cin >> s; switch ( s[0] ) { case 'M': MARCH[0]++; break; case 'A': MARCH[1]++; break; case 'R': MARCH[2]++; break; case 'C': MARCH[3]++; break; case 'H': MARCH[4]++; break; } } ll ans = 0; for(ll i = 0; i<n; i++){ for(ll j = i+1; j < n;j++){ for(ll k = j+1; k < n;k++){ ans += MARCH[i]* MARCH[j]* MARCH[k]; } } } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; string S[N]; for (int i = 0; i < N; ++i) { cin >> S[i]; } char head[] = {'M', 'A', 'R', 'C', 'H'}; long long headCount[] = {0, 0, 0, 0, 0}; for (int i = 0; i < N; ++i) { for (int j = 0; j < 5; ++j) { if (S[i][0] == head[j]) { headCount[j]++; } } } long long result = 0; for (int i = 0; i < 3; ++i) { for (int j = i + 1; j < 4; ++j) { for (int k = j + 1; k < 5; ++k) { cout << i << j << k << endl; result += headCount[i] * headCount[j] * headCount[k]; } } } cout << result << 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()) s = [] for i in range(N): s.append(input()) m = 0 a = 0 r = 0 c = 0 h = 0 for person in s: if person[0]=='M': m += 1 elif person[0]=='A': a += 1 elif person[0]=='R': r += 1 elif person[0]=='C': c += 1 elif person[0]=='H': h += 1 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 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()) sd = {} hl = ["M","A","R","C","H"] for i in range(n): s = input() head = s[0] if not head in hl: continue if head in sd: sd[head] += 1 else: sd[head] = 1 values = list(sd.values()) #print(values) length = len(values) counts = 0 if length < 3: print(0) else: for i in range(length-2): for j in range(i+1,length-1): for k in range(j+1,length): # print(i,j,k) counts += values[i]*values[j]*values[k] print(counts)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\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; class Program { static void Main(string[] args) { Solve(); } static void Solve() { Scan sc = new Scan(); write wr = new write(); var k = sc.intarr; int n = k[0]; int m = 0, a = 0, r = 0, c = 0, h = 0; int[] k1 = { 0, 0, 0, 0, 0, 0, 1, 1, 1, 2 }; int[] k2 = { 1, 1, 1, 2, 2, 3, 2, 2, 3, 3 }; int[] k3 = { 2, 3, 4, 3, 4, 4, 3, 4, 4, 4 }; for(int i = 0; i < n; ++i) { string s = sc.str; if (s[0] == 'M') m++; if (s[0] == 'A') a++; if (s[0] == 'R') r++; if (s[0] == 'C') c++; if (s[0] == 'H') h++; } long ans = 0; int[] d = { m, a, r, c, h }; for(int i = 0; i < 10; ++i) { ans += d[k1[i]] * d[k2[i]] * d[k3[i]]; } wr.wri(ans); } } class Scan { public string str => Console.ReadLine(); public string[] strarr => str.Split(' '); public long[] longarr => strarr.Select(long.Parse).ToArray(); public int[] intarr => strarr.Select(int.Parse).ToArray(); public char[] chararr => strarr.Select(char.Parse).ToArray(); } class write { public void wri<Type>(Type x) { Console.WriteLine(x); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "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, i, j, b = 0; cin >> n; int a[6] = {0}; string s[n + 1]; for (i = 1; i <= n; i++) { cin >> s[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]++; } for (i = 1; i <= 3; i++) { if (a[i] != 0) for (j = i + 1; j <= 4; j++) { if (a[j] != 0) for (m = j + 1; m <= 5; m++) { if (a[m] != 0) b = b + a[i] * a[j] * a[m]; } } } cout << b; 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 <stdio.h> int main(){ unsigned long n; scanf("%lu¥n",&n); unsigned long m=0; unsigned long r=0; unsigned long c=0; unsigned long a=0; unsigned long h=0; for(unsigned long i = 0;i<n;i++){ char str[64]; scanf("%s¥n",&str); if(str[0] == "M"){m++;} if(str[0] == "C"){c++;} if(str[0] == "A"){a++;} if(str[0] == "R"){r++;} if(str[0] == "H"){h++;} } unsigned long ans=0; ans = (m+c+a+r+h)*(m+c+a+r+h)*(m+c+a+r+h); ans -= (m+c+a+r+h)*3*a*a-2*a*a*a; ans -= (m+c+a+r+h)*3*m*m-2*m*m*m; ans -= (m+c+a+r+h)*3*h*h-2*h*h*h; ans -= (m+c+a+r+h)*3*r*r-2*r*r*r; ans -= (m+c+a+r+h)*3*c*c-2*c*c*c; printf("%lu",ans/6); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
using System; class prog{ static void Main(string[] args){ int N =int.Parse(Console.ReadLine()); long count=0; for(int i=0;i<N;i++){ string name=Console.ReadLine(); char[] march={'M','A','R','C','H'}; foreach(char c in march){ if(name[0] == c){ count++; break; } } } if(count>=3) Console.WriteLine(count*(count -1)*(count-2)/1/2/3); else Console.WriteLine("0"); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
n = int(input()) # M,A,R,C,H num = [0] * 5 check_list = ['M','A','R','C','H'] for _ in range(n): s = input() for i, c in enumerate(check_list): if s[0] == c: num[i]+=1 break ans = 0 for i in range(n-2): for j in range(i+1, n-1): for k in range(j+1, n): ans += num[i]*num[j]*num[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
UNKNOWN
#[allow(unused_imports)] use std::char::*; #[allow(unused_imports)] use std::cmp::*; #[allow(unused_imports)] use std::collections::*; #[allow(unused_macros)] macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}} #[allow(unused_macros)] macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; } #[allow(unused_macros)] macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; } #[allow(unused_macros)] macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; } #[derive(PartialEq, PartialOrd)] pub struct Total<T>(pub T); impl<T: PartialEq> Eq for Total<T> {} impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }} #[allow(dead_code)] const MAX:usize = 100006; #[allow(dead_code)] const INF_U32:u32 = 1 << 31; #[allow(dead_code)] const INF_I32:i32 = 1 << 30; #[allow(dead_code)] const INF_U64:u64 = 1 << 63; #[allow(dead_code)] const INF_I64:i64 = 1 << 62; #[allow(dead_code)] const MOD:i64 = 1e9 as i64 + 7; #[allow(dead_code)] fn read_vec<T: std::str::FromStr>() -> Vec<T> { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().split_whitespace() .map(|e| e.parse().ok().unwrap()).collect() } pub trait BinarySearch<T> { fn lower_bound(&self, x: &T) -> usize; fn upper_bound(&self, x: &T) -> usize; } impl<T: Ord> BinarySearch<T> for [T] { fn lower_bound(&self, x: &T) -> usize { let mut low = 0; let mut high = self.len(); while low != high { let mid = (low + high) / 2; match self[mid].cmp(x) { Ordering::Less => { low = mid + 1; } Ordering::Equal | Ordering::Greater => { high = mid; } } } low } fn upper_bound(&self, x: &T) -> usize { let mut low = 0; let mut high = self.len(); while low != high { let mid = (low + high) / 2; match self[mid].cmp(x) { Ordering::Less | Ordering::Equal => { low = mid + 1; } Ordering::Greater => { high = mid; } } } low } } #[allow(unused_imports)] use std::f64; pub trait LexicalPermutation { fn next_permutation(&mut self) -> bool; fn prev_permutation(&mut self) -> bool; } impl<T> LexicalPermutation for [T] where T: Ord { fn next_permutation(&mut self) -> bool { if self.len() < 2 { return false; } let mut i = self.len() - 1; while i > 0 && self[i-1] >= self[i] { i -= 1; } if i == 0 { return false; } let mut j = self.len() - 1; while j >= i && self[j] <= self[i-1] { j -= 1; } self.swap(j, i-1); self[i..].reverse(); true } fn prev_permutation(&mut self) -> bool { if self.len() < 2 { return false; } let mut i = self.len() - 1; while i > 0 && self[i-1] <= self[i] { i -= 1; } if i == 0 { return false; } self[i..].reverse(); let mut j = self.len() - 1; while j >= i && self[j-1] < self[i-1] { j -= 1; } self.swap(i-1, j); true } } fn main() { input!{n:usize, s:[chars;n]}; let mut map = HashMap::new(); for i in 0..n { let ch = s[i][0]; let mut count = map.entry(ch).or_insert(0); *count += 1; } let v:Vec<char> = "MARCH".to_string().chars().collect(); //debug!(v); let mut ans = 0; for i in 0..5 { for j in i+1..5 { for k in j+1..5 { let zero = 0; let val1 = map.get(&v[i]).unwrap_or(&zero); let val2 = map.get(&v[j]).unwrap_or(&zero); let val3 = map.get(&v[k]).unwrap_or(&zero); ans += val1*val2*val3; } } } 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 n; cin >> n; vector<int> march(5); int m = 0, a = 0, r = 0, c = 0, h = 0; string s; 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++; } march[0] = m, march[1] = a, march[2] = r, march[3] = c, march[4] = h; long long ans = 0; for (int i = 0; i < (3); ++i) { for (int j = int(i + 1); j < int(5); ++j) { for (int k = int(j + 1); k < int(5); ++k) { ans += march[i] * march[j] * march[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
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using unit = unsigned; using vl = vector<ll>; using ull = unsigned long long; using vvi = vector<vi>; using P = pair<int, int>; using vvl = vector<vl>; using vp = vector<P>; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); } template <class T> string join(const vector<T> &v) { stringstream s; for (int i = (int)(0); i < (int)(((int)(v).size())); ++i) s << ' ' << v[i]; return s.str().substr(1); } template <class T> istream &operator>>(istream &i, vector<T> &v) { for (auto &x : v) { i >> v; } return i; } template <class T> ostream &operator<<(ostream &o, const vector<T> &v) { o << "["; for (auto &x : v) o << x << ","; o << "]"; return o; } template <class T> ostream &operator<<(ostream &o, const deque<T> &v) { o << "deq["; for (auto &x : v) o << x << ","; o << "]"; return o; } template <class T> ostream &operator<<(ostream &o, const set<T> &v) { o << "{"; for (auto &x : v) o << x << ","; o << "}"; return o; } template <class T> ostream &operator<<(ostream &o, const unordered_set<T> &v) { o << "{"; for (auto &x : v) o << x << ","; o << "}"; return o; } template <class T> ostream &operator<<(ostream &o, const multiset<T> &v) { o << "{"; for (auto &x : v) o << x << ","; o << "}"; return o; } template <class T> ostream &operator<<(ostream &o, const unordered_multiset<T> &v) { o << "{"; for (auto &x : v) o << x << ","; o << "}"; return o; } template <class T1, class T2> ostream &operator<<(ostream &o, const pair<T1, T2> &p) { o << "(" << p.first << "," << p.second << ")"; return o; } template <class TK, class TV> ostream &operator<<(ostream &o, const map<TK, TV> &m) { o << "{"; for (auto &x : m) o << x.first << "=>" << x.second << ","; o << "}"; return o; } template <class TK, class TV> ostream &operator<<(ostream &o, const unordered_map<TK, TV> &m) { o << "{"; for (auto &x : m) o << x.first << "=>" << x.second << ","; o << "}"; return o; } template <class T> void YES(T c) { if (c) cout << "YES" << endl; else cout << "NO" << endl; } template <class T> void Yes(T c) { if (c) cout << "Yes" << endl; else cout << "No" << endl; } template <class T> void POSS(T c) { if (c) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; } template <class T> void Poss(T c) { if (c) cout << "Possible" << endl; else cout << "Impossible" << endl; } template <class T> void chmax(T &a, const T &b) { if (a < b) a = b; } template <class T> void chmin(T &a, const T &b) { if (b < a) a = b; } template <class T> T gcd(T a, T b) { return (b == 0) ? a : gcd(b, a % b); } template <class T> T lcm(T a, T b) { return a * (b / gcd(a, b)); } const double EPS = 1e-10; const double PI = acos(-1.0); const int INF = INT_MAX / 2; const ll INFL = 1LL << 60; const int dx[] = {-1, 0, 1, 0, -1, -1, 1, 1}; const int dy[] = {0, 1, 0, -1, -1, 1, -1, 1}; void _main() { string march = "MARCH"; ll cnt[5] = {}; int N; cin >> N; for (int i = (int)(0); i < (int)(N); ++i) { string s; cin >> s; for (int j = (int)(0); j < (int)(5); ++j) if (s[0] == march[j]) ++cnt[j]; } ll ans = 0; for (int i = (int)(0); i < (int)(5); ++i) for (int j = (int)(i + 1); j < (int)(5); ++j) for (int k = (int)(j + 1); k < (int)(5); ++k) { cout << "i,j,k: " << i << ", " << j << ", " << k << endl; ans += cnt[i] * cnt[j] * cnt[k]; } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; typedef long long int ll; int main(){ int n,m=0,a=0,r=0,c=0,h=0,sum; ll count; cin >> n; vector<string> S(n); for(int i=0;i<n;i++){ cin >> S.at(i); if(S.at(i)[0]=='M')m++; else if(S.at(i)[0]=='A')a++; else if(S.at(i)[0]=='R')r++; else if(S.at(i)[0]=='C')c++; else if(S.at(i)[0]=='H')h++; } sum = m+a+r+c+h; count = {sum*(sum-1)*(sum-2)/6} - (sum-2)/2*{m*(m-1)+a*(a-1)+r*(r-1)+c*(c-1)+h*(h-1)}; cout << count << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
n = int(input()) s = [input()[0] for _ in range(n)] from collections import Counter c = Counter(s) c = list(c.values()) c_len = len(c) ans = 0 for i in range(c_len): for j in range(i+1, c_len): for k in range(j+1, c_len): ans += c[i] * c[j] * c[k] print(ans)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using Graph = vector<vector<int>>; const long long MOD = 1e9 + 7; int main() { int n; cin >> n; vector<int> march(5, 0); string s = "MARCH"; for (int i = 0; i < (int)(n); i++) { string t; cin >> t; for (int i = 0; i < (int)(5); i++) if (t[0] == s[i]) march[i]++; } long long ans = 0; for (int i = 0; i < (int)(5); i++) for (int j = 0; j < (int)(i); j++) for (int k = 0; k < (int)(j); k++) ans += march[i] * march[j] * march[k]; cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> int n, ai[6]; long long dp[6][4]; int main() { std::cin >> n; char op[15]; for (int i = 1; i <= n; i++) { scanf("%s", op); if (op[0] == 'M') ai[1]++; if (op[0] == 'A') ai[2]++; if (op[0] == 'R') ai[3]++; if (op[0] == 'C') ai[4]++; if (op[0] == 'H') ai[5]++; } dp[0][0] = 1; for (int i = 1; i <= 5; i++) for (int v = 1; v <= 3; v++) dp[i][v] = dp[i - 1][v - 1] * ai[i] + dp[i - 1][v]; std::cout << dp[5][3] << std::endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
N = gets.to_i S = [] count_M = 0 count_A = 0 count_R = 0 count_C = 0 count_H = 0 for i in 0..N-1 S[i] = gets.chomp if S[i][0] == 'M' count_M += 1 elsif S[i][0] == 'A' count_A += 1 elsif S[i][0] == 'R' count_R += 1 elsif S[i][0] == 'C' count_C += 1 elsif S[i][0] == 'H' count_H += 1 end end puts (count_M * count_A * count_R + count_M * count_A * count_C + count_M * count_A * count_H + count_M * count_R * count_C + count_M * count_R * count_H + count_M * count_C * count_H + count_A * count_R * count_C + count_A * count_R * count_H + count_R * count_C * count_H)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> int main(int argc, char const *argv[]) { int N; scanf("%d", &N); int inic[5] = {0}; char ini[5]; ini[0] = 'M'; ini[1] = 'A'; ini[2] = 'R'; ini[3] = 'C'; ini[4] = 'H'; int nz = 0; for (int i = 0; i < N; i++) { char name[11]; scanf("%s", name); for (int i = 0; i < 5; i++) { if (name[0] == ini[i]) { inic[i]++; if (inic[i] == 1) { nz++; } } } } if (nz < 3) { printf("0\n"); return 0; } std::vector<int> v; for (int i = 0; i < 5; i++) { if (inic[i] != 0) { v.push_back(inic[i]); } } int result = 0; int bits = (int)std::pow(2, nz); for (int i = 0; i < bits; i++) { int count = 0; for (int j = 0; j < nz; j++) { if (i >> j & 1) count++; } if (count == 3) { int r = 1; for (int k = 0; k < nz; k++) { if (i >> k & 1) { r *= v[k]; } } result += r; } } printf("%d\n", 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; using ll = long long; const long long INF = 1LL << 60; const ll C = 1e9 + 7; int main() { int N; cin >> N; vector<int> MARCH(5, 0); for (int i = 0; i < N; i++) { string s; cin >> s; if (s[0] == 'M') MARCH[0]++; if (s[0] == 'A') MARCH[1]++; if (s[0] == 'R') MARCH[2]++; if (s[0] == 'C') MARCH[3]++; if (s[0] == 'H') MARCH[4]++; } 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 += 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
cpp
#include <bits/stdc++.h> using namespace std; int main() { char c[] = "MARCH"; vector<int> a(5); int n; cin >> n; string s; for (int i = 0; i < n; i++) { cin >> s; for (int j = 0; j < 5; j++) { if (s[0] == c[j]) a[j]++; } } long long ans = 0; for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 4; j++) { for (int k = j + 1; k < 5; k++) { ans += 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; long long f(int a, int b, int c) { return a * b * c; } int main() { int N; cin >> N; vector<string> S(N); for (int i = 0; i < N; i++) cin >> S.at(i); vector<vector<string>> v(5); for (int i = 0; i < N; i++) { if (S.at(i).at(0) == 'M') { v.at(0).push_back(S.at(i)); } if (S.at(i).at(0) == 'A') { v.at(1).push_back(S.at(i)); } if (S.at(i).at(0) == 'R') { v.at(2).push_back(S.at(i)); } if (S.at(i).at(0) == 'C') { v.at(3).push_back(S.at(i)); } if (S.at(i).at(0) == 'H') { v.at(4).push_back(S.at(i)); } } int sum = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { sum += f(v.at(i).size(), v.at(j).size(), v.at(k).size()); } } } 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
N = int(input()) l = [0] * N march = 'MARCH' for i in range(N): S = input() for j in range(len(march)): if S[0] == march[j]: l[j] += 1 tmp = [] lenl = len(l) for i in range(lenl): for j in range(i + 1, lenl): for k in range(j + 1, lenl): tmp.append(l[i]*l[j]*l[k]) print(sum(tmp))
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int atcoder() { int n; cin >> n; long long march[5] = {}; for (int i = 0; i < n; ++i) { string tmp; cin >> tmp; if (tmp[0] == 'M') ++march[0]; else if (tmp[0] == 'A') ++march[1]; else if (tmp[0] == 'R') ++march[2]; else if (tmp[0] == 'C') ++march[3]; else if (tmp[0] == 'H') ++march[4]; } long long ans = 0; for (int i = 0; i < n - 2; ++i) { for (int j = i + 1; j < n - 1; ++j) { for (int k = j + 1; k < n; ++k) ans += march[i] * march[j] * march[k]; } } cout << ans << "\n"; return 0; } int main() { cin.tie(0); ios::sync_with_stdio(false); atcoder(); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; int m = 0, a = 0, r = 0, c = 0, h = 0; for (long long i = 0; i < (long long)(N); i++) { string str; cin >> str; if (str[0] == 'M') { m++; } else if (str[0] == 'A') { a++; } else if (str[0] == 'R') { r++; } else if (str[0] == 'C') { c++; } else if (str[0] == 'H') { h++; } } if (m + a + r + c + h < 3) { cout << 0 << endl; return 0; } long long int ans; ans = m * a * r + m * a * c + m * a * h + m * r * c + m * r * h + m * c * h + a * r * c + a * r * h + a * c * h + r * c * h; cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "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 cnt[5]; long long dp[6][3]; int main() { int N; cin >> N; string str; for (int i = 0; i < N; i++) { cin >> str; switch (str[0]) { case 'M': dp[1][1]++; break; case 'A': dp[2][1]++; break; case 'R': dp[3][1]++; break; case 'C': dp[4][1]++; break; case 'H': dp[5][1]++; break; } } dp[0][0] = 0; dp[1][0] = 0; dp[2][0] = 0; dp[3][0] = 0; dp[4][0] = 0; dp[5][0] = 0; for (int i = 1; i < 6; i++) { for (int k = 2; k < 3; k++) { dp[i][k] = dp[i - 1][k - 1] * dp[i - 1][1] + dp[i - 1][k]; } } cout << dp[5][2] << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.io.File; import java.io.IOException; import java.lang.reflect.Array; import java.util.*; import java.util.Map.Entry; public class Main{ public static void main(String[] args) throws IOException{ //File file = new File("input.txt"); //Scanner in = new Scanner(file); Scanner in = new Scanner(System.in); int N = in.nextInt(); int[] march = new int[5]; String marchS = "MARCH"; for(int i = 0; i < N; i++){ String S = in.next().substring(0, 1); for(int j = 0; j < 5; j++){ if(S.equals(String.valueOf(marchS.charAt(j)))){ march[j]++; break; } } } int ans = 0; for(int i = 0; i < 5 - 2; i++){ for(int j = i + 1; j < 5 - 1; j++){ for(int k = j + 1; k < 5; k++){ ans += march[i] * march[j] * march[k]; } } } System.out.println(ans); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; std::cin >> N; vector<set<string>> S(5); for (int n = 0; n < N; ++n) { string s; std::cin >> s; switch (s.front()) { case 'M': S[0].insert(s); break; case 'A': S[1].insert(s); break; case 'R': S[2].insert(s); break; case 'C': S[3].insert(s); break; case 'H': S[4].insert(s); break; } } vector<int> X = {0, 1, 2, 3, 4}; set<set<int>> P; do { set<int> p; for (int ii = 0; ii < 3; ++ii) p.insert(X[ii]); P.insert(p); } while (next_permutation(X.begin(), X.end())); int x = 0; for (auto p : P) { int k = 1; for (auto i : p) { k *= S[i].size(); } x += k; } 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; const long long INF = 1e18; int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; int num[5]; memset(num, 0, sizeof(num)); for (int i = (int)0; i < (int)N; i++) { string s; cin >> s; if (s[0] == 'M') num[0]++; else if (s[0] == 'A') num[1]++; else if (s[0] == 'R') num[2]++; else if (s[0] == 'C') num[3]++; else if (s[0] == 'H') num[4]++; } long long res = 0; for (int i = (int)0; i < (int)5; i++) for (int j = (int)i + 1; j < (int)5; j++) for (int k = (int)j + 1; k < (int)5; k++) res += (num[i] * num[j] * num[k]); cout << res << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int num1 = 0; int num2 = 0; int num3 = 0; int num4 = 0; int num5 = 0; for (int i = 0; i < n; i++) { string tmp; cin >> tmp; if (tmp[0] == 'M') { num1 += 1; } else if (tmp[0] == 'A') { num2 += 1; } else if (tmp[0] == 'R') { num3 += 1; } else if (tmp[0] == 'C') { num4 += 1; } else if (tmp[0] == 'H') { num5 += 1; } } vector<long long int> ans(10); ans[0] = num1 * num2 * num3; ans[1] = num1 * num2 * num4; ans[2] = num1 * num2 * num5; ans[3] = num1 * num3 * num4; ans[4] = num1 * num3 * num5; ans[5] = num1 * num4 * num5; ans[6] = num2 * num3 * num4; ans[7] = num2 * num3 * num5; ans[8] = num2 * num4 * num5; ans[9] = num3 * num4 * num5; cout << accumulate(ans.begin(), ans.end(), 0LL) << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.*; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int N = sc.nextInt(); String[] names = new String[N]; int counterM = 0; int counterA = 0; int counterR = 0; int counterC = 0; int counterH = 0; for(int i = 0; i < N; i++){ String name = sc.next(); names[i] = name; } for(int j = 0; j < N; j++){ if(names[j].startsWith("M")){ counterM++; }else if(names[j].startsWith("A")){ counterA++; }else if(names[j].startsWith("R")){ counterR++; }else if(names[j].startsWith("C")){ counterC++; }else if(names[j].startsWith("H")){ counterH++; } } //MAR long MAR = counterM * counterA * counterR; //MAC long MAC = counterM * counterA * counterC; //MAH long MAH = counterM * counterA * counterH; //MRC long MRC = counterM * counterR * counterC; //MRH long MRH = counterM * counterR * counterH; //MCH long MCH = counterM * counterC * counterH; //ARC long ARC = counterA * counterR * counterC; //ARH long ARH = counterA * counterR * counterH; //ACH long ACH = counterA * counterC * counterH; //RCH long RCH = counterR * counterC * counterH; long total = MAR + MAC + MAH + MRC + MRH + MCH + ARC + ARH + ACH + RCH; System.out.println(total); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; long mp[5] = {0L}; int main() { int n, m = 0, a = 0, r = 0, c = 0, h = 0, ans = 0; cin >> n; string s; for (int i = 0; i < n; i++) { cin >> s; if (s[0] == 'M') mp[0]++; else if (s[0] == 'A') mp[1]++; else if (s[0] == 'R') mp[2]++; else if (s[0] == 'C') mp[3]++; else if (s[0] == 'H') mp[4]++; } for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 4; j++) { for (int o = j + 1; o < 5; o++) ans += mp[i] * mp[j] * mp[o]; } } cout << ans; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; map<char, int> m; char I[] = "MARCH"; long long ans = 0; cin >> N; for (int i = 0; i < N; i++) { string str; cin >> str; m[str[0]]++; } for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { if (i == j || j == k || i == k) continue; ans += m[I[i]] * m[I[j]] * m[I[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; char c[5] = {'M', 'A', 'R', 'C', 'H'}; map<char, int> mp; for (int i = 0; i < (n); i++) { string s; cin >> s; for (int i = 0; i < (5); i++) { if (s[0] == c[i]) { mp[c[i]]++; } } } long long ans = 0; char c1, c2, c3; for (int i = 0; i <= n - 2; i++) { for (int j = i + 1; j <= n - 1; j++) { for (int k = j + 1; k <= n; k++) { c1 = c[i]; c2 = c[j]; c3 = c[k]; ans += mp[c1] * mp[c2] * mp[c3]; } } } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; int m = 0; int a = 0; int r = 0; int c = 0; int h = 0; string name; cin >> N; for (int i = 0; i < N; i++) { cin >> name; switch (name[0]) { case 'M': m++; break; case 'A': a++; break; case 'R': r++; break; case 'C': c++; break; case 'H': h++; break; default: break; } } cout << m * a * r + m * a * c + m * a * h + m * r * c + m * r * h + m * c * h + a * r * c + a * r * h + a * c * h + r * c * h << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const long long INF = 1e18; int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; int num[5]; memset(num, 0, sizeof(num)); for (int i = (int)0; i < (int)N; i++) { string s; cin >> s; if (s[0] == 'M') num[0]++; else if (s[0] == 'A') num[1]++; else if (s[0] == 'R') num[2]++; else if (s[0] == 'C') num[3]++; else if (s[0] == 'H') num[4]++; } long long res = 0; for (int i = (int)0; i < (int)N; i++) for (int j = (int)i + 1; j < (int)N; j++) for (int k = (int)j + 1; k < (int)N; k++) res += (num[i] * num[j] * num[k]); cout << res << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; char s[100000]; map<char, int> S; int main() { int n; long long sum = 0; scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%s", s); if (s[0] == 'M' || s[0] == 'A' || s[0] == 'R' || s[0] == 'C' || s[0] == 'H') S[s[0]]++; } if (n < 3) printf("0\n"); else { sum += (S['M'] * S['A'] * S['R']); sum += (S['M'] * S['A'] * S['C']); sum += (S['M'] * S['A'] * S['H']); sum += (S['M'] * S['R'] * S['C']); sum += (S['M'] * S['R'] * S['H']); sum += (S['M'] * S['C'] * S['H']); sum += (S['A'] * S['R'] * S['C']); sum += (S['A'] * S['R'] * S['H']); sum += (S['A'] * S['C'] * S['H']); sum += (S['R'] * S['C'] * S['H']); printf("%lld\n", sum); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
from collections import defaultdict N = int(input()) d = defaultdict(int) for _ in range(N): s = input() if s[0] in 'MARCH': d[s[0]] += 1 if len(d.keys()) >= 3: ans = 1 for c in d.values(): ans *= c else: ans = 0 print(ans)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; cin>>N; int m=0,a=0,r=0,c=0,h=0; for(int i=0;i<N;i++){ string name; cin>>name; if(name.at(0)==M){m++;} else if(name.at(0)==A){a++;} else if(name.at(0)==R){r++;} else if(name.at(0)==C){c++;} else if(name.at(0)==H){h++;} else{continue;} } int sum=m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*r*h+a*c*h+r*c*h; cout<<sum<<endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int n, m, a, r, c, h; string s; int main() { cin >> n; for (int i = 1; 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++; } cout << m * a * r + m * a * c + m * a * h + a * r * c + a * r * h + r * c * h; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main(void) { int n; cin >> n; int march[5] = {0}; for (int i = 0; i < n; i++) { string s; cin >> s; if (s[0] == 'M') march[0]++; if (s[0] == 'A') march[1]++; if (s[0] == 'R') march[2]++; if (s[0] == 'C') march[3]++; if (s[0] == 'H') march[4]++; } long long ans = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { ans += march[i] * march[j] * march[k]; } } } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python2
#!/usr/bin/env python # -*- coding: utf-8 -*- N = input() m = 0 a = 0 r = 0 c = 0 h = 0 for i in range(N): S = raw_input() if S[:1] == "M": m += 1 elif S[:1] == "A": a += 1 elif S[:1] == "R": r += 1 elif S[:1] == "C": c += 1 elif S[:1] == "H": h += 1 print float(m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+m*c*h+a*r*c+a*r*h+a*c*h+r*c*h)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; vector<int> s_cnt(5, 0); int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; vector<string> s(n); for (int i = 0; i < n; ++i) cin >> s[i]; char s_list[5] = {'M', 'A', 'R', 'C', 'H'}; for (int i = 0; i < n; ++i) { for (int j = 0; j < 5; ++j) { if (s[i][0] == s_list[j]) s_cnt[j]++; } } long long ans = 0LL; for (int i = 0; i < 3; ++i) { for (int j = i + 1; j < 5; ++j) { for (int k = j + 1; k < 5; ++k) { ans += s_cnt[i] * s_cnt[j] * s_cnt[k]; } } } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> long nCr(int n, int r) { if (n < r) { return 0; } long ans = 1; for (int i = n; i > n - r; --i) { ans = ans * i; } for (int i = 1; i < r + 1; ++i) { ans = ans / i; } return ans; } int main() { int N; std::cin >> N; std::string tmp; std::vector<std::string> arrM; std::vector<std::string> arrA; std::vector<std::string> arrR; std::vector<std::string> arrC; std::vector<std::string> arrH; long long int M, A, R, C, H; long long int ans; for (int i = 0; i < N; i++) { std::cin >> tmp; if (tmp[0] == 'M') { arrM.push_back(tmp); } else if (tmp[0] == 'A') { arrA.push_back(tmp); } else if (tmp[0] == 'R') { arrR.push_back(tmp); } else if (tmp[0] == 'C') { arrC.push_back(tmp); } else if (tmp[0] == 'H') { arrH.push_back(tmp); } else { continue; } } long long int hoge[5]; hoge[0] = (long long int)arrM.size(); hoge[1] = (long long int)arrA.size(); hoge[2] = (long long int)arrR.size(); hoge[3] = (long long int)arrC.size(); hoge[4] = (long long int)arrH.size(); for (int i = 0; i < 5; i++) { for (int j = i; j < 5; j++) { for (int k = j; k < 5; k++) { ans += hoge[i] * hoge[j] * hoge[k]; } } } std::cout << ans << std::endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include <bits/stdc++.h> int main(void) { int N; scanf("%d", &N); int i, j, k; int c[5] = {0, 0, 0, 0, 0}; for (i = 0; i < N; i++) { char S[20]; scanf("%s", S); if (S[0] == 'M') { c[0]++; } else if (S[0] == 'A') { c[1]++; } else if (S[0] == 'R') { c[2]++; } else if (S[0] == 'C') { c[3]++; } else if (S[0] == 'H') { c[4]++; } } unsigned long long count = 0; for (i = 0; i < 5; i++) { for (j = i; j < 5; j++) { for (k = j; k < 5; k++) { if (i != j && j != k && k != i) { count += c[i] * c[j] * c[k]; } } } } printf("%llu\n", 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
python3
s = [input() for _ in range(n)] prefix = ['M', 'A', 'R', 'C', 'H'] cnt = [0] * 5 ans = 0 for i in range(n): for j in range(5): if s[i][0] == prefix[j]: cnt[j] += 1 for i in range(2 ** 5): flag = [False] * 5 for j in range(5): if (i >> j) & 1: flag[j] = True if flag.count(True) == 3: tmp = 1 for k in range(5): if flag[k]: tmp *= cnt[k] ans += tmp print(ans)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.HashMap; import java.util.Map; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); Map<Character,Long> m = new HashMap<Character,Long>(); long one = 1; for(int i=0;i<n;i++) { char[] s = sc.next().toCharArray(); m.merge(s[0], one, Long::sum); } long[] num = new long[5]; char[] march = "MARCH".toCharArray(); long sum =0; long kind =0; long subst =0; if(n<3) { System.out.println(0); return; } for(int i=0;i<5;i++) { if(m.containsKey(march[i])) { num[i] = m.get(march[i]); } if(num[i]>0) { kind++; } sum += num[i]; } for(int i=0;i<5;i++) { if(num[i]>0) { subst += num[i]*(num[i]-1)/2*(kind-1); } if(num[i]>=3) { subst += num[i]*(num[i]-1)*(num[i]-2)/6; } } long ret = sum*(sum-1)*(sum-2)/6-subst; System.out.println(ret); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define int long long int q[200]; main(){ int n,i,c,k,l=0; cin>>n; string s; for (i=0;i<n;++i){ cin>>s; q[s[0]]++; } int r=1; c=q['M']+q['A']+q['R']+q['C']+q['H']; if (q['M']>1){ l+=q['A']+q['R']+q['C']+q['H']; } if (q['A']>1){ l+=q['M']+q['R']+q['C']+q['H']; } if (q['R']>1){ l+=q['M']+q['A']+q['C']+q['H']; } if (q['C']>1){ l+=q['M']+q['A']+q['R']+q['H']; } if (q['H']>1){ l+=q['M']+q['A']+q['R']+q['C']; } if (c-3>3){ k=1; int pr=0; for (i=c-2;i<=c;++i){ k*=i; if (k%6==0){ k/=6; pr=1; } } if (pr==0) r=6; } else { k=1; for (i=4;i<=c;++i){ k*=i; } for (i=2;i<=c-3;++i){ r*=i; } } if (k==1) cout <<0; else cout <<k/r-l; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int n; cin >> n; vector<string> s(n); for (int i = 0; i < (n); i++) cin >> s[i]; string t = "MARCH"; vector<int> cnt(5); for (int i = 0; i < (n); i++) { for (int j = 0; j < (5); j++) { if (t[j] == s[i][0]) cnt[j]++; } } ll ans = 0; for (int i = 0; i < (3); i++) for (int j = i + 1; j < 4; j++) for (int k = j + 1; k < 5; k++) { ans += cnt[i] * cnt[j] * cnt[k]; } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<string> s(n); for (int i = 0; i < (int)(n); i++) cin >> s[i]; vector<int> c(5, 0); for (int i = 0; i < (int)(n); i++) { if (s[i][0] == 'M') c[0]++; if (s[i][0] == 'A') c[1]++; if (s[i][0] == 'R') c[2]++; if (s[i][0] == 'C') c[3]++; if (s[i][0] == 'H') c[4]++; } long long int ans = 0; for (int i = int(0); i < int(5); i++) { for (int j = int(i + 1); j < int(5); j++) { for (int k = int(j + 1); k < int(5); k++) { ans += c[i] * c[j] * c[k]; } } } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; 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++; } vector<int> nums{m, a, r, c, h}; vector<bool> v{true, true, true, false, false}; int res = 0; do { int patterns = 1; for (int i = 0; i < 5; i++) { if (v[i]) { patterns *= nums[i]; } } res += patterns; } while (prev_permutation(v.begin(), v.end())); 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; const long long INF = 1e18; int main() { long long ans = 0, n; vector<int> cnt(5, 0); string s; cin >> n; for (long long 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 (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++) { ans += cnt[i] * cnt[j] * cnt[k]; } } } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string a; int i, j, k; int b[6]{0}; for (i = 1; i <= n; i++) { cin >> a; if (a[0] == 'M') b[1]++; else if (a[0] == 'A') b[2]++; else if (a[0] == 'R') b[3]++; else if (a[0] == 'C') b[4]++; else if (a[0] == 'H') b[5]++; } int s = 0; for (i = 1; i <= 5; i++) { if (b[i] != 0) { for (j = i + 1; j <= 5; j++) { if (b[j] != 0) { for (k = j + 1; k <= 5; k++) { if (b[k] != 0) { s += b[i] * b[j] * b[k]; } } } } } } cout << s << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s[n]; int cou[5]; char check[5] = {'M', 'A', 'R', 'C', 'H'}; for (int i = 0; i < 5; i++) { cou[i] = 0; } for (int i = 0; i < n; i++) { cin >> s[i]; for (int j = 0; j < 5; j++) { if (s[i][0] == check[j]) { cou[j]++; } } } long long ans = 0; int a[10] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2}; int b[10] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3}; int c[10] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4}; for (int i = 0; i < 10; i++) { ans += cou[a[i]] * cou[b[i]] * cou[c[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
java
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] names = new int[5]; for (int i = 0; i < n; i++) { int index = nameIndex(sc.next()); if (index != -1) names[index]++; } long count = 0; for (int i = 0; i < names.length; i++) { for (int j = i + 1; j < names.length; j++) { for (int k = j + 1; k < names.length; k++) { count += names[i] * names[j] * names[k]; } } } System.out.println(count); } static int nameIndex(String str) { switch (str.charAt(0)) { case 'M': return 0; case 'A': return 1; case 'R': return 2; case 'C': return 3; case 'H': return 4; default: return -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; using ll = long long; int INF = 1000000009; map<char, int> mp; int main() { int n; cin >> n; char c[5] = {'M', 'A', 'R', 'C', 'H'}; for (int i = 0; i < n; i++) { string s; cin >> s; mp[s[0]]++; } ll 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 += mp[c[i]] * mp[c[j]] * mp[c[k]]; } } } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<string> S(N); vector<int> counter(5); for (int i = 0; i < N; i++) { cin >> S[i]; if (S[i][0] == 'M') counter[0]++; else if (S[i][0] == 'A') counter[1]++; else if (S[i][0] == 'R') counter[2]++; else if (S[i][0] == 'C') counter[3]++; else if (S[i][0] == 'H') counter[4]++; } long long int total = 0; for (int i = 0; i < counter.size(); i++) { for (int j = i + 1; j < counter.size(); j++) { for (int k = j + 1; k < counter.size(); k++) { total += counter[i] * counter[j] * counter[k]; } } } cout << total << 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 INF = 1000000000; int d[5]; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; for (int i = 0; i < (n); ++i) { string s; cin >> s; if (s[0] == 'M') { d[0]++; } else if (s[0] == 'A') { d[1]++; } else if (s[0] == 'R') { d[2]++; } else if (s[0] == 'C') { d[3]++; } else if (s[0] == 'H') { d[4]++; } } long long ans = 0; for (int i = 0; i < (5); ++i) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { ans += d[i] * d[j] * d[k]; } } } cout << ans << "\n"; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n, i, j, k, sum = 0; int c[5] = {}; string s; cin >> n; for (i = 0; i < n; i++) { cin >> s; switch (s[0]) { case 'M': c[0]++; break; case 'A': c[1]++; break; case 'R': c[2]++; break; case 'C': c[3]++; break; case 'H': c[4]++; break; } } for (i = 0; i < 5; i++) { for (j = i + 1; j < 5; j++) { for (k = j + 1; k < 5; k++) { sum += c[i] * c[j] * c[k]; } } } cout << sum; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include <bits/stdc++.h> int Combination(int, int); int main() { int N = 0; int M = 0, A = 0, R = 0, C = 0, H = 0; int Z = 0; int Result = 0; char Input[10]; scanf("%d", &N); for (int i = 0; i < N; i++) { scanf("%s", Input); if (Input[0] == 'M') M++; if (Input[0] == 'A') A++; if (Input[0] == 'R') R++; if (Input[0] == 'C') C++; if (Input[0] == 'H') H++; } printf("M = %d\nA = %d\nR = %d\nC = %d\nH = %d\n", M, A, R, C, H); if (M > 0) Z++; if (A > 0) Z++; if (R > 0) Z++; if (C > 0) Z++; if (H > 0) Z++; Result = Combination(Z, 3); if (M > 1) Result = Result * M - Combination(Z - 1, 3); if (A > 1) Result = Result * A - Combination(Z - 1, 3); if (R > 1) Result = Result * R - Combination(Z - 1, 3); if (C > 1) Result = Result * C - Combination(Z - 1, 3); if (H > 1) Result = Result * H - Combination(Z - 1, 3); printf("%d", Result); return 0; } int Combination(int x, int y) { int a = 1, b = 1; int result = 0; for (int i = 1; i <= x; i++) { a *= i; } for (int i = 1; i <= y; i++) { b *= i; } for (int i = 1; i <= (x - y); i++) { b *= i; } result = a / b; return result; }