Search is not available for this dataset
name
stringlengths
2
88
description
stringlengths
31
8.62k
public_tests
dict
private_tests
dict
solution_type
stringclasses
2 values
programming_language
stringclasses
5 values
solution
stringlengths
1
983k
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; using db = double; using vll = vector<long long>; template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } bool IsInt(double a) { int b = a / 1; if (a == b) { return true; } else { return false; } } bool coY() { cout << "Yes" << endl; } bool coN() { cout << "No" << endl; } const int mod = 1e9 + 7; const ll INF = 1LL << 60; const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; int main() { cout << setprecision(10); int n; cin >> n; vector<string> name(n); int initial[5]; for (int i = (0); i < (5); ++i) { initial[i] = 0; } for (int i = (0); i < (n); ++i) { cin >> name[i]; char c = name[i][0]; if (c == 'M') { initial[0]++; } else if (c == 'A') { initial[1]++; } else if (c == 'R') { initial[2]++; } else if (c == 'C') { initial[3]++; } else if (c == 'H') { initial[4]++; } } 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 += initial[i] * initial[j] * initial[k]; } } } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> int main() { int num; int names[5]; for (int i = 0; i < 5; i++) { names[i] = 0; } std::cin >> num; for (int i = 0; i < num; i++) { std::string str; std::cin >> str; switch (str[0]) { case 'M': names[0]++; break; case 'A': names[1]++; break; case 'R': names[2]++; break; case 'C': names[3]++; break; case 'H': names[4]++; break; } } 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++) { result += names[i] * names[j] * names[k]; } } } std::cout << result << std::endl; std::cin >> num; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; unsigned long long combination(unsigned long long t, unsigned long long r) { if (t == r || r == 0) return 1; else return (t - r + 1) / r * combination(t, r - 1); } int main(void) { unsigned long long n; unsigned long long d = 0; unsigned long long a[5] = {}; cin >> n; for (int i = 0; i < n; i++) { string s; cin >> s; if (s[0] == 'M') a[0]++; if (s[0] == 'A') a[1]++; if (s[0] == 'R') a[2]++; if (s[0] == 'C') a[3]++; if (s[0] == 'H') a[4]++; } for (int i = 0; i < 5; i++) { if (a[i] == 0) { d++; } } if (d >= 3) { cout << '0' << endl; return 0; } unsigned long long cnt1 = 0; unsigned long long cnt2 = 0; unsigned long long cnt3 = 0; for (int i = 0; i < 5; i++) { if (a[i] == 1) cnt1++; if (a[i] != 0) cnt2++; if (a[i] != 0 && a[i] != 1) cnt3++; } unsigned long long ans1 = 0; if (cnt1 >= 3) ans1 = combination(cnt1, 3); else ans1 = 0; unsigned long long ans2; if (cnt1 >= 2) ans2 = combination(cnt1, 2); else if (cnt1 == 1 || cnt1 == 0) ans2 = 1; for (int i = 0; i < 5; i++) { if (a[i] != 0) ans2 *= a[i]; } if (cnt1 == 1) cout << ans1 + ans2 * combination(cnt3, 2) << endl; else if (cnt1 == 0) cout << ans1 + ans2 * combination(cnt3, 3) << endl; else cout << ans1 + ans2 << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <iostream> #include <string> using namespace std; int m,a,r,c,h; int main(void){ int N; long ans; cin>>N; string S[N]; //char s[N]; for(int i=0;i<N;i++){ cin>>S[i]; S[i]=S[i][0]; if(S[i]=='M'){ m++; } if(S[i]=='A'){ a++; } if(S[i]=='R'){ r++; } if(S[i]=='C'){ c++; } if(S[i]=='H'){ h++; } } 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; const ll INF = 1e16; const ll mod = 1000000007; int main() { ll n; cin >> n; vector<ll> v(5, 0); for (int i = 0; i < (ll)(n); i++) { string s; cin >> s; if (s.at(0) == 'M') v.at(0)++; else if (s.at(0) == 'A') v.at(1)++; else if (s.at(0) == 'R') v.at(2)++; else if (s.at(0) == 'C') v.at(3)++; else v.at(4)++; } ll res = 0; for (ll bit = 0; bit < (1 << 5); bit++) { if (__builtin_popcount(bit) != 3) continue; ll tmp = 1; for (int i = 0; i < (ll)(5); i++) { if (bit & (1 << i)) tmp *= v.at(i); } res += tmp; } 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> const int N = 1e5; using namespace std; int main() { int n; string s; while (cin >> n) { int a[6] = {0}; for (int i = 1; i <= n; ++i) { cin >> s; if (s[0] == 'M') a[1]++; if (s[0] == 'A') a[2]++; if (s[0] == 'R') a[3]++; if (s[0] == 'C') a[4]++; if (s[0] == 'H') a[5]++; } int cnt = 0; for (int i = 1; i <= 5; ++i) if (a[i] != 0) cnt++; if (cnt == 0) cout << 0 << endl; if (cnt == 1) { int t; for (int i = 1; i <= 5; ++i) { if (a[i] != 0) t = a[i]; } long long ans = t * (t - 1) * (t - 2) / 6; cout << ans << endl; } if (cnt == 2) { int k[3] = {0}, l = 1; for (int i = 1; i <= 5; ++i) { if (a[i] != 0) { k[l] = a[i]; l++; } } long long ans = k[1] * k[2]; cout << ans << endl; } if (cnt == 3) { int x[4] = {0}, p = 1; for (int i = 1; i <= 5; ++i) { if (a[i] != 0) { x[p] = a[i]; p++; } } long long ans = (x[1] * x[2] * x[3]); cout << ans << endl; } if (cnt == 5) { long long ans = (a[1] * a[2] * a[3]) + (a[1] * a[2] * a[4]) + (a[1] * a[2] * a[5]) + (a[1] * a[3] * a[4]) + (a[1] * a[3] * a[5]) + (a[1] * a[4] * a[5]) + (a[2] * a[3] * a[4]) + (a[2] * a[3] * a[5]) + (a[2] * a[4] * a[5]) + (a[3] * a[4] * a[5]); cout << ans << endl; } if (cnt == 4) { int m[5], k = 1; for (int i = 1; i <= 5; ++i) { if (a[i] != 0) { m[k] = a[i]; k++; } } long long ans = (m[1] * m[2] * m[3]) + (m[1] * m[2] * m[4]) + (m[1] * m[3] * m[4]) + (m[2] * m[3] * m[4]); cout << ans << endl; } } return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; set<char> S{'M', 'A', 'R', 'C', 'H'}; int main() { int n; cin >> n; map<char, int> M; for (int i = 0; i < n; i++) { string s; cin >> s; if (!S.count(s[0])) continue; M[s[0]]++; } long long ans = 0; string u = "MARCH"; for (int i = 0; i < 3; i++) for (int j = i + 1; j < 4; j++) for (int k = j + 1; k < 5; k++) { ans += M[u[i]] * M[u[j]] * M[u[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
python2
# -*- coding: utf-8 -*- import itertools def filter_name(n): return n.startswith("M") or n.startswith("A") or n.startswith("R") or n.startswith("C") or n.startswith("H") def filter_ok(l): dic = {'M': 0, 'A': 0, 'R': 0, 'C': 0, 'H': 0} for i in l: dic[i[0:1]] += 1 for num in dic.values(): if num >= 2: return False return True n = input() a = [] for i in range(n): b = raw_input() if filter_name(b): a.append(b) r = filter(filter_name, a) c = list(itertools.combinations(r, 3)) r = filter(filter_ok, c) print len(r)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int i, j, k, N; string s; int cnt[5]; long long ans; int main() { cin >> N; for (int i = (0); i < (N); i++) { cin >> s; if (s[0] == 'M') cnt[0]++; if (s[0] == 'A') cnt[1]++; if (s[0] == 'R') cnt[2]++; if (s[0] == 'C') cnt[3]++; if (s[0] == 'H') cnt[4]++; } for (i = 0; i < 5; i++) for (j = i; j < 5; j++) for (k = j; k < 5; k++) ans += (long long)cnt[i] * (long long)cnt[j] * (long long)cnt[k]; cout << ans; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int bit_count(int num) { int count = 0; for (; num != 0; num &= num - 1) { count++; } return count; } int main() { long long ans = 0; int N; cin >> N; vector<int> table(5, 0); for (int i = 0; i < N; i++) { string s; cin >> s; switch (s[0]) { case 'M': table[0]++; break; case 'A': table[1]++; break; case 'R': table[2]++; break; case 'C': table[3]++; break; case 'H': table[4]++; break; default: break; } } for (int bin = 1; bin <= 0b11111; bin++) { if (bit_count(bin) == 3) { int multi = 1; for (int i = 0; i < 5; i++) { if (bin & (1 << i)) { multi *= table[i]; } } ans += multi; } } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
n = int(input()) A = [] march = ['M', 'A', 'R', 'C', 'H'] for _ in range(n): s = input() if s[0] in march: A.append(s) # 同じ文字から始まらない 3 人の選び方 from itertools import combinations cnt = 0 for v in combinations(A, 3): if v[0][0] == v[1][0] or v[1][0] == v[2][0] or v[2][0] == v[0][0]: continue cnt += 1 print(cnt)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
n = int(input()) lis = [] for i in range(n): lis.append(input()) count = 0 lis2 = [] for i in range(n): if lis[i][0:1] in 'MARCH': lis2.append(lis[i]) for i in range(len(lis2)-2): for j in range(i+1, len(lis2)-1): for k in range(j+1, len(lis2)): if lis2[i][0:1] != lis2[j][0:1] and lis2[j][0:1] != lis2[k][0:1] \ and lis2[k][0:1] != lis2[i][0:1]: count += 1 print(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
n = int(input()) alphabets = ["M","A","R","C","H"] names = list() counter_dict = {"M":0,"A":0,"R":0,"C":0,"H":0} for i in range(n): names.append(input()) for name in names: if list(name)[0] in alphabets: counter_dict[list(name)[0]] += 1 temp = 0 ans = 1 for value in counter_dict.values(): if value != 0: ans *= value temp = 1 else: if temp == 0: print(0) else: print(ans)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int maxn = 100010; char s[maxn][10 + 10]; int march[5 + 5]; int main() { int n, ans = 0; cin >> n; memset(s, 0, sizeof(s)); for (int i = 0; i < n; i++) cin >> s[i]; for (int i = 0; i < n; i++) { if (s[i][0] == 'M') march[0]++; if (s[i][0] == 'A') march[1]++; if (s[i][0] == 'R') march[2]++; if (s[i][0] == 'C') march[3]++; if (s[i][0] == 'H') march[4]++; } ans = march[0] * march[1] * march[2] + march[0] * march[1] * march[3] + march[0] * march[1] * march[4] + march[0] * march[2] * march[3] + march[0] * march[2] * march[4] + march[0] * march[3] * march[4] + march[1] * march[2] * march[3] + march[1] * march[2] * march[4] + march[1] * march[3] * march[4] + march[2] * march[3] * march[4]; cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; long long GCD(long long a, long long b) { if (b == 0) return a; return GCD(b, a % b); } int main() { int N; cin >> N; map<char, int> count; string MARCH = "MARCH"; for (int i = 0; i < 5; ++i) count[MARCH[i]] = 0; for (int i = 0; i < N; ++i) { string S; cin >> S; count[S[0]] += 1; } int first[10] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2}; int second[10] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3}; int third[10] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4}; long long res = 0; for (int i = 0; i < 10; ++i) res += count[MARCH[first[i]]] * count[MARCH[second[i]]] * count[MARCH[third[i]]]; 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 name[5] = {0}; string s; for (int i = 0; i < N; ++i) { cin >> s; switch (s[0]) { case 'M': name[0] += 1; continue; case 'A': name[1] += 1; continue; case 'R': name[2] += 1; continue; case 'C': name[3] += 1; continue; case 'H': name[4] += 1; continue; default: continue; } } long long ans = 0; for (int i = 0; i <= 2; ++i) { for (int j = i + 1; j <= 3; ++j) { for (int k = j + 1; k <= 4; ++k) { ans += name[i] * name[j] * name[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 ll = long long; constexpr ll INF = 1000000000; using namespace std; 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]; map<char, int> mp; vector<int> p(5); for (int i = 0; i < (n); i++) { if (s[i].at(0) == 'M') p[0]++; if (s[i].at(0) == 'A') p[1]++; if (s[i].at(0) == 'R') p[2]++; if (s[i].at(0) == 'C') p[3]++; if (s[i].at(0) == 'H') p[4]++; } int ans = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { ans += p[i] * p[j] * p[k]; } } } for (int i = 0; i < (n); i++) cout << p[i] << endl; cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; template <typename T> using reversed_priority_queue = std::priority_queue<T, std::vector<T>, std::greater<T> >; signed main() { vector<char> chrs = {'M', 'A', 'R', 'C', 'H'}; long long int n; cin >> n; vector<long long int> v(n, 0); for (long long int i = (0); i < (n); i++) { string s; cin >> s; for (long long int j = (0); j < (5); j++) if (s[0] == chrs[j]) v[j]++; } long long int ans = 0; for (long long int i = (0); i < (5); i++) for (long long int j = (i + 1); j < (5); j++) for (long long int k = (j + 1); k < (5); k++) ans += v[i] * v[j] * v[k]; cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> march(5); for (int i = 0; i < n; i++) { string st; cin >> st; if (st.at(0) == 'M' || st.at(0) == 'A' || st.at(0) == 'R' || st.at(0) == 'C' || st.at(0) == 'H') { if (st.at(0) == 'M') march.at(0)++; if (st.at(0) == 'A') march.at(1)++; if (st.at(0) == 'R') march.at(2)++; if (st.at(0) == 'C') march.at(3)++; if (st.at(0) == 'H') march.at(4)++; } } long long ans = 0; for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 4; j++) { for (int k = j + 1; k < 5; k++) { ans += march.at(i) * march.at(j) * march.at(k); } } } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<string> S(N); vector<int> march(5); for (int i = 0; i < N; i++) { cin >> S.at(i); if (S.at(i).at(0) == 'M') march.at(0)++; else if (S.at(i).at(0) == 'A') march.at(1)++; else if (S.at(i).at(0) == 'R') march.at(2)++; else if (S.at(i).at(0) == 'C') march.at(3)++; else if (S.at(i).at(0) == 'H') march.at(4)++; } unsigned long long ans = 0; for (int i = 0; i < 5 - 2; i++) { for (int j = i + 1; j < 5 - 1; j++) { for (int k = j + 1; k < 5; k++) { ans += march.at(i) * march.at(j) * march.at(k); } } } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
N = int(input()) S = [input() for i in range(N)] from collections import Counter from itertools import combinations march = ["M", "A", "R", "C", "H"] T = [] for s in S: if s[0] in march: T.append(s[0]) counter = Counter(T) if len(counter) < 3: print(0) exit() base = len(list(combinations(counter.keys(), 3))) for (key, value) in counter.most_common(): base *= value if value > 1: keys = list(filter(lambda x: x != key, counter.keys())) base -= len(list(combinations(keys, 3))) print(base)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++> 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
cpp
#include <bits/stdc++.h> using namespace std; constexpr long long MOD = (1e9 + 7); constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; } template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } long long factorial(long long n, long long m = 2) { m = max(2LL, m); long long rtn = 1; for (long long i = m; i <= n; i++) { rtn = (rtn * i) % MOD; } return rtn; } long long modinv(long long a, long long m) { long long b = m, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= m; if (u < 0) u += m; return u; } long long modpow(long long a, long long n) { long long res = 1; while (n > 0) { if (n & 1) res = res * a % MOD; a = a * a % MOD; n >>= 1; } return res; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; vector<int> march(5); int flag = 0; for (int i = 0; i < n; ++i) { string s; cin >> s; toupper(s[0]); if (s[0] == 'M') march[0]++; else if (s[0] == 'A') march[1]++; else if (s[0] == 'R') march[2]++; else if (s[0] == 'C') march[3]++; else if (s[0] == 'H') march[4]++; else flag++; } if (flag == n) cout << 0 << endl; else { int cnt = 0; for (int bit = 1; bit < (1 << n); ++bit) { int tmp = 1; if (__builtin_popcount(bit) != 3) continue; for (int i = 0; i < n; ++i) { if (bit & 1 << i) tmp *= march[i]; } cnt += tmp; } 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; int main() { int n; scanf("%d", &n); int m = 0; int a = 0; int r = 0; int c = 0; int h = 0; string str; for (int i = 0; i < n; i++) { cin >> str; if (str[0] == 'M') { m++; } if (str[0] == 'A') { a++; } if (str[0] == 'R') { r++; } if (str[0] == 'C') { c++; } if (str[0] == 'H') { h++; } } unsigned long long sum = 0; sum += m * a * r; sum += m * a * c; sum += m * a * h; sum += m * r * c; sum += m * r * h; sum += m * c * h; sum += a * r * c; sum += a * r * h; sum += a * c * h; sum += r * c * h; printf("%lld", sum); }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; string str("MRACH"); vector<string> name(N); int countM = 0; int countR = 0; int countA = 0; int countC = 0; int countH = 0; int all; for (int i = 0; i < N; i++) { cin >> name.at(i); char I = name.at(i).at(0); if (I == 'M') { countM++; } else if (I == 'R') { countR++; } else if (I == 'A') { countA++; } else if (I == 'C') { countC++; } else if (I == 'H') { countH++; } if (countM == 0) { countM++; } else if (countR == 0) { countR++; } else if (countA == 0) { countA++; } else if (countC == 0) { countC++; } else if (countH == 0) { countH++; } } if (countM + countR + countA + countC + countH < 8) { all = 0; } else { all = countM * countR * countA * countC * countH; } cout << all << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n, m = 0, a = 0, r = 0, c = 0, h = 0; cin >> n; vector<string> s(n); for (int i = 0; i < n; i++) { cin >> s[i]; if (s[i][0] == 'M') { m++; } if (s[i][0] == 'A') { a++; } if (s[i][0] == 'R') { r++; } if (s[i][0] == 'C') { c++; } if (s[i][0] == 'H') { h++; } } cout << m * a * r + m * a * c + m * a * h + m * r * c + m * r * h + m * c * h + a * r * c + a * r * h + a * c * h + r * c * h << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } int main() { int N; cin >> N; vector<string> S(N); vector<long long> num(5, 0); for (int i = 0; i < (int)(N); i++) { cin >> S[i]; if (S[i][0] == 'M') num[0] += 1; else if (S[i][0] == 'A') num[1] += 1; else if (S[i][0] == 'R') num[2] += 1; else if (S[i][0] == 'C') num[3] += 1; else if (S[i][0] == 'H') num[4] += 1; } 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 = ans + (num[i] * num[j] * num[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 <iostream>
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\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, b = 0, c = 0, d = 0, e = 0, f = 0; scanf("%d", &n); while (n--) { char q[12]; scanf("%s", q); if (q[0] == 'M') b++; else if (q[0] == 'A') c++; else if (q[0] == 'R') d++; else if (q[0] == 'C') e++; else if (q[0] == 'H') f++; } long long int ans = b * c * d + b * c * e + b * c * f + b * d * e + b * d * f + b * e * f + c * e * f + c * d * e + c * d * f + d * e * f; printf("%lld\n", ans); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long sum = 0; vector<string> name(n); string temp; for (int i = 0; i < n; i++) { cin >> temp; name.push_back(temp); } int m = 0, a = 0, r = 0, c = 0, h = 0; for (auto& na : name) { if (na[0] == 'M') { m++; } else if (na[0] == 'A') { a++; } else if (na[0] == 'R') { r++; } else if (na[0] == 'C') { c++; } else if (na[0] == 'H') { h++; } } sum += m * a * r + m * a * c + m * a * h + m * r * c + m * r * h + m * c * h; sum += a * r * c + a * r * h + a * c * h; sum += 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
python3
import numpy as np N = int(input()) S = np.empty(5, dtype=str) for i in range(N): S[i] = input() S_M = np.array([S[i] for i in range(N) if S[i][0] == 'M']) S_A = np.array([S[i] for i in range(N) if S[i][0] == 'A']) S_R = np.array([S[i] for i in range(N) if S[i][0] == 'R']) S_C = np.array([S[i] for i in range(N) if S[i][0] == 'C']) S_H = np.array([S[i] for i in range(N) if S[i][0] == 'H']) souwa = 0 kahi = np.array([0, 0, 0, 0, 0]) kahi[0] = len(S_M) kahi[1] = len(S_A) kahi[2] = len(S_R) kahi[3] = len(S_C) kahi[4] = len(S_H) kahi_not0 = kahi[kahi != 0] if len(kahi_not0) <= 2: print(0) else: for i in range(len(kahi_not0)-2): for j in range(i+1, len(kahi_not0)-1): for k in range(j+1, len(kahi_not0)): souwa += kahi_not0[i]*kahi_not0[j]*kahi_not0[k] if souwa >= 2**32: print(souwa/(2**32), end='') print(souwa-(souwa/(2**32))*(2**32)) else: print(souwa)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
def factorial(n): if n==1 or n==0: return 1 else: return n * factorial(n-1) def combination(n, r): if n<r: print (0) exit() return int(factorial(n)/factorial(n-r)/factorial(r)) N = int(input()) names = [] count = [0] * 5 overlap3 = [0] * 5 overlap2 = [0] * 5 for i in range(N): names.append(input()) if names[i][0] == 'M': count[0] += 1 elif names[i][0] == 'A': count[1] += 1 elif names[i][0] == 'R': count[2] += 1 elif names[i][0] == 'C': count[3] += 1 elif names[i][0] == 'H': count[4] += 1 if sum(count)<3: print (0) exit() for i in range(5): if count[i] > 2: overlap3[i] = combination(count[i], 3) if count[i] == 2: overlap2[i] = combination(count[i], 2) out = combination(sum(count),3) - sum(overlap2)*(sum(count)-2) - sum(overlap3) if out > 0: print (out) else: print (0)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
def main(): N = int(input().strip()) S = [] D1 = {} D2 = {} for _ in range(N): in_s = input().strip()[0] if in_s in ['M','A','R','C','H']: S.append(in_s) S.sort() count = 0 for i in range(len(S)): D1 = {} D2 = {} D1[S[i]]=True for j in range(i+1, len(S)): D2 = {} if S[j] in D1: continue D2[S[j]]=True for k in range(j+1, len(S)): if S[k] in D2: continue count += 1 return count if __name__ == '__main__': print(main())
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); const string alp = "abcdefghijklmnopqrstuvwxyz"; const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; bool isprime(int p) { if (p == 1) return false; for (int i = (2); i < (p); ++i) { if (p % i == 0) return false; } return true; } int main() { int n, a[5]; long t; cin >> n; string s; for (int i = (0); i < (5); ++i) { a[i] = 0; } for (int i = (0); i < (n); ++i) { cin >> s; for (int j = (0); j < (5); ++j) { if (s[0] == "MARCH"[j]) a[j]++; } } t = 0; for (int i = (0); i < (3); ++i) { for (int j = (1); j < (4); ++j) { for (int k = (2); k < (5); ++k) { if (i < j && j < k) { t += a[i] * a[j] * a[k]; } } } } cout << t; 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 <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; } template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } const long long INF = 1000000000000000000; const long long MOD = 1e9 + 7; int main() { int n; cin >> n; map<char, int> mp; for (int i = 0; i < (n); i++) { string s; cin >> s; char ss = s[0]; if (ss == 'M' || ss == 'A' || ss == 'R' || ss == 'C' || ss == 'H') { mp[ss]++; } } long long ans = 0; string sr = "MARCH"; 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[sr[i]] * mp[sr[j]] * mp[sr[k]]; } } } cout << ans << endl; system("pause"); }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\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; int m = 0, a = 0, r = 0, c = 0, h = 0; cin >> n; for (int i = 0; i < n; i++) { string name; cin >> name; if (name[0] == 'M') m++; else if (name[0] == 'A') a++; else if (name[0] == 'R') r++; else if (name[0] == 'C') c++; else if (name[0] == 'H') h++; } ll ans = m * (a * (r + c + h) + r * (c + h) + c * h) + a * (r * (c + h) + c * h) + r * c * h; cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
import numpy as np N = int(input()) S = [None]*5 for i in range(N): S[i] = input() S_M = [S[i] for i in range(N) if S[i][0] == 'M'] S_A = [S[i] for i in range(N) if S[i][0] == 'A'] S_R = [S[i] for i in range(N) if S[i][0] == 'R'] S_C = [S[i] for i in range(N) if S[i][0] == 'C'] S_H = [S[i] for i in range(N) if S[i][0] == 'H'] souwa = 0 kahi = [0]*5 kahi[0] = len(S_M) kahi[1] = len(S_A) kahi[2] = len(S_R) kahi[3] = len(S_C) kahi[4] = len(S_H) for i in range(len(kahi)-2): for j in range(i+1, len(kahi)-1): for k in range(j+1, len(kahi)): souwa += kahi[i]*kahi[j]*kahi[k] print(souwa)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; unsigned long long n, k, a, wynik, roz, p; int t[5]; int tab[100]; string b; int main() { scanf("%llu", &n); for (int i = 0; n > i; i++) { cin >> b; tab[b[0]]++; } if (tab[77] > 0) wynik++; if (tab[65] > 0) wynik++; if (tab[82] > 0) wynik++; if (tab[67] > 0) wynik++; if (tab[72] > 0) wynik++; t[0] = tab[77]; t[1] = tab[65]; t[2] = tab[82]; t[3] = tab[67]; t[4] = tab[72]; sort(t, t + 5); if (wynik - 2 > 0) { roz += (wynik - 1) * (wynik - 2) / 2 * t[4]; if (t[3] > 0) roz *= t[3]; if (t[2] > 0) roz *= t[2]; if (t[1] > 0) roz *= t[1]; if (t[0] > 0) roz *= t[0]; } if (wynik - 3 > 0) { roz += (wynik - 2) * (wynik - 3) / 2 * t[3]; ; if (t[2] > 0) roz *= t[2]; if (t[1] > 0) roz *= t[1]; if (t[0] > 0) roz *= t[0]; } if (wynik - 4 > 0) { roz += (wynik - 3) * (wynik - 4) / 2 * t[2]; if (t[1] > 0) roz *= t[1]; if (t[0] > 0) roz *= t[0]; } if (wynik - 5 > 0) { roz += (wynik - 4) * (wynik - 5) / 2 * t[1]; if (t[0] > 0) roz *= t[0]; } if (wynik - 6 > 0) roz += (wynik - 5) * (wynik - 6) / 2 * t[0]; cout << roz; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
N = int(input()) march = 'MARCH' mdict = {s:0 for s in march} for i in range(N): S = input() mdict[S[0]] += 1 lst = [mdict[key] for key in mdict] ans = 0 for i in range(3): for j in range(i+1, 4): for k in range(j+1, 5): ans += lst[i] * lst[j] * lst[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() { string s = "MARCH"; int c[5] = {0}; int N; cin >> N; for (int i = 0; i < N; i++) { string t; cin >> t; for (int j = 0; j < 5; j++) { if (t[0] == c[j]) c[j]++; } } int ans = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { ans += c[i] * c[j] * c[k]; } } } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> template <class T> bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } template <class T> bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } using namespace std; using vint = vector<int>; using vvint = vector<vector<int>>; using ll = long long; using vll = vector<ll>; using vvll = vector<vector<ll>>; using P = pair<int, int>; const int inf = 1e9; const ll inf_l = 1e18; const int MAX = 100005; int main() { int n; cin >> n; map<char, int> mp; for (int i = 0; i < (int)(n); i++) { string s; cin >> s; char c = s[0]; if (c == 'M' || c == 'A' || c == 'R' || c == 'C' || c == 'H') { mp[c]++; } } vint x; for (auto itr = mp.begin(); itr != mp.end(); itr++) { x.push_back(itr->second); } ll ans = 0; for (int i = 0; i < x.size(); i++) { for (int j = i + 1; j < x.size(); j++) { for (int l = j + 1; l < x.size(); l++) { ans += x[i] * x[j] * x[l]; } } } 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 ll = long long; int main() { int N; std::cin >> N; std::unordered_map<int, int> m; for (int i = 0; i < N; i++) { std::string in; std::cin >> in; switch (in[0]) { case 'M': m[0]++; break; case 'A': m[1]++; break; case 'R': m[2]++; break; case 'C': m[3]++; break; case 'H': m[4]++; break; } } int sum = 0; for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 4; j++) { for (int k = j + 1; k < 5; k++) { if (i != j && j != k && k != i) { sum += m[i] * m[j] * m[k]; } } } } std::cout << sum << std::endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.*; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int m = 0; int a = 0; int r = 0; int c = 0; int h = 0; int[] D = new int[5]; int[] x = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2}; int[] y = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3}; int[] z = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4}; for(int i=0; i<N; i++){ String s = sc.next(); if(s.charAt(0)=='M') m++; if(s.charAt(0)=='A') a++; if(s.charAt(0)=='R') r++; if(s.charAt(0)=='C') c++; if(s.charAt(0)=='H') h++; } D[0] = m; D[1] = a; D[2] = r; D[3] = c; D[4] = h; long ans = 0L; for(int i=0; i<10; i++){ ans += D[x[i]] * D[y[i]] * D[z[i]]; } 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
from itertools import combinations # input N = int(input()) S = [input()[0] for i in range(N)] # check MARCH = ["M", "A", "R", "C", "H"] cnt = 0 for c in combinations(S, 3): tops = [s for s in c if s in MARCH] if len(tops) == 3 and len(tops) == len(set(tops)): cnt += 1 print(cnt)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> int main() { int n; scanf("%d", &n); std::map<char, intmax_t> count; for (int i = 0; i < n; ++i) { char c; scanf(" %c%*s", &c); ++count[c]; } std::vector<std::string> const tt{ "MAR", "MAC", "MAH", "MRC", "MRH", "MCH", "ARC", "ARH", "ACH", "RCH", }; intmax_t res = 0; for (auto const& t : tt) { res += count[t[0]] * count[t[1]] * count[t[2]]; } printf("%jd\n", res); }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.*; public class Main { static Scanner sc = new Scanner(System.in); static void myout(Object t){System.out.println(t);}//standard output static void myerr(Object t){System.err.println(t);}//standard error static String getStr(){return sc.next();} static int getInt(){return Integer.parseInt(getStr());} static long getLong(){return Long.parseLong(getStr());} static boolean isNext(){return sc.hasNext();} static String[] mySplit(String str){return str.split("");} public static void main(String[] args){ int N = getInt(); long output = 0; HashMap<String,Integer> hm = new HashMap<String,Integer>(); hm.put("M",0); hm.put("A",0); hm.put("R",0); hm.put("C",0); hm.put("H",0); for(int i = 0; i < N; i++){ String tmp = getStr().substring(0,1); if(hm.containsKey(tmp)){ hm.put(tmp,hm.get(tmp) + 1); } } myerr(hm); ArrayList<String> keys = new ArrayList<String>(); keys.add("M"); keys.add("A"); keys.add("R"); keys.add("C"); keys.add("H"); for(int i = 0; i < keys.size() - 2; i++){ for(int j = i + 1; j < keys.size() - 1; j++){ for(int k = j + 1; k < keys.size(); k++){ myerr(hm.get(keys.get(i))); myerr(hm.get(keys.get(j))); myerr(hm.get(keys.get(k))); output += hm.get(keys.get(i)) * hm.get(keys.get(j)) * hm.get(keys.get(k)); } } } myout(output); } //Method addition frame start //Method addition frame end }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> name(5); for (int i = 0; i < N; i++) { string tmp; cin >> tmp; if (tmp[0] == 'M') name[0]++; else if (tmp[0] == 'A') name[1]++; else if (tmp[0] == 'R') name[2]++; else if (tmp[0] == 'C') name[3]++; else if (tmp[0] == 'H') name[4]++; } int64_t res = 0; vector<int> a = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2}; vector<int> b = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3}; vector<int> c = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4}; for (int i = 0; i < 10; i++) { res += (name[a[i]] * name[b[i]] * name[c[i]]); } 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; const long long N = 200010; inline long long read() { long long s = 0, w = 1; register char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') w = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') s = (s << 3) + (s << 1) + (ch ^ 48), ch = getchar(); return s * w; } long long n, a[66]; char s[13]; signed main() { n = read(); for (register long long i = 0; i < n; i++) { cin >> s; if (s[0] == 'M') a[0]++; if (s[0] == 'A') a[1]++; if (s[0] == 'R') a[2]++; if (s[0] == 'C') a[3]++; if (s[0] == 'H') a[4]++; } long long res = 0; for (register long long i = 0; i < 4; i++) { for (register long long j = i + 1; j < 4; j++) { for (register long long k = j + 1; k < 4; k++) res += a[i] * a[j] * a[k]; } } printf("%lld\n", res); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> int fact(int); int Comb(int, int); int main() { int M, A, R, C, H, N, i; char str[11]; M = A = R = C = H = 0; scanf("%d", &N); for (i = 0; i < N; i++) { scanf("%s", str); switch (str[0]) { case 'M': M++; break; case 'A': A++; break; case 'R': R++; break; case 'C': C++; break; case 'H': H++; break; } } printf("%d", M * (A * (R + C + H) + R * (C + H) + C * H) + A * (R * (C + H) + C * H) + R * C * H); printf("\nmarch:%d, %d, %d, %d, %d\n", M, A, R, C, H); return 0; } int fact(int n) { if (n < 0) return 0; if (n == 0) return 1; if (n <= 2) return n; return n * fact(n - 1); } int Comb(int n, int m) { return fact(n) / (fact(m) * fact(n - m)); }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> a(5, 0); for (int i = 0; i < N; i++) { string s; cin >> s; if (s[0] == 'M') a[0]++; else if (s[0] == 'A') a[1]++; else if (s[0] == 'R') a[2]++; else if (s[0] == 'C') a[3]++; else if (s[0] == 'H') a[4]++; } long long out = 0; for (int i = 0; i < 3; i++) for (int j = i + 1; j < 4; j++) for (int k = j + 1; k < 5; k++) { if (a[i] == 0 || a[j] == 0 || a[k] == 0) continue; out += a[i] * a[j] * a[k]; } cout << out << 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 combination(int n, int r) { if (n == 0) return 0; if (n == r) return (1); else if (r == 0) return (1); else if (r == 1) return (n); else return (combination(n - 1, r - 1) + combination(n - 1, r)); } int main() { int n, x; long long int c = 0; bool b = false; int m[5] = {0}; int a = 0; cin >> n; string s[n]; for (int i = 0; i < n; i++) cin >> s[i]; for (int i = 0; i < n; i++) { if (s[i][0] == 'M') m[0]++; if (s[i][0] == 'A') m[1]++; if (s[i][0] == 'R') m[2]++; if (s[i][0] == 'C') m[3]++; if (s[i][0] == 'H') m[4]++; } for (int j = 0; j < 5; j++) if (m[j] >= 1) a++; c = combination(a, 3); for (int j = 0; j < 5; j++) if (m[j] != 0) c *= m[j]; for (int j = 0; j < 5; j++) if (m[j] >= 2) c = c - m[j] + 1; cout << c << '\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> #include <numeric> using namespace std; #define ll long long #define mod 100000007 #define rep(i, n) for (int i = 0; i < n; ++i) ll lcm(ll a, ll b) { return a * b / __gcd(a, b); } int main() { int N; cin >> N; string S; vector<int> march(5,0); int P[10] = {0,0,0,0,0,0,1,1,1,2}; int Q[10] = {1,1,1,2,2,3,2,2,3,3}; int R[10] = {2,3,4,3,4,4,3,4,4,4}; for (int i = 0; i < N; i++) { cin >> S; if ('M' == S[0]) { march[0]++; } else if('A' == S[0]){ march[1]++; } else if('R' == S[0]){ march[2]++; } else if('C'== S[0]){ march[3]++; } else if('H' == S[0]){ march[4]++; } } ll ans = 0; for (int d = 0; d < 10;d++) { ans += march[P[d]] * march[Q[d]] * march[R[d]]; } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
n=int(input()) al=list('MARCH') d=[0]*5 for i in range(n): s=list(input()) if s[0] in al: d[al.index(s[0])]+=1 op=[[0],[1]] for i in range(4): tmp=[] for j in op: j.append(0) tmp.append(j) j.pop(-1) j.append(1) tmp.append(j) op=tmp k=[] for i in op: if sum(i)==3: k.append(i) ans=0 for i in k: t=1 for j in range(5): if i[j]==1: t*=d[j] ans+=t print(ans)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
import itertools n=int(input()) e=[] for i in range(n): a=input() if a[0] in "MARCH": e.append(a) count=0 for a,b,c in itertools.combinations(e,3): if a[0]!=b[0] and b[0]!=c[0] and c[0]!=a[0]: count+=1 print(count)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { unsigned long long b, c, d, n, m, i, j; int k = 0; cin >> n; int ar[n]; if (n == 5) { cout << 2; } else { cout << 0; } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n, m = 0, a = 0, r = 0, c = 0, h = 0; string s[100010]; cin >> n; for (int i = 1; i <= n; i++) { cin >> s[i]; if (s[i][0] == 'M') m++; else if (s[i][0] == 'A') a++; else if (s[i][0] == 'R') r++; else if (s[i][0] == 'C') c++; else if (s[i][0] == 'H') h++; } unsigned long long d = 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 << d; 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; 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 < 5; ++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> using namespace std; string s = "MARCH"; map<int, int> cnt; long long res = 0; void find(int p = 0, int l = 0, string prefix = "") { if (p == 3) { res += cnt[prefix[0]] * cnt[prefix[1]] * cnt[prefix[2]]; return; } for (int i = l; i < s.size(); i++) { find(p + 1, i + 1, prefix + s[i]); } } void solve() { int n; cin >> n; for (int i = 0; i < n; i++) { string t; cin >> t; cnt[t[0]]++; } find(); cout << res; } int main() { ios::sync_with_stdio(false); cin.tie(0); int t = 1; for (int i = 1; i <= t; i++) { 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
UNKNOWN
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ABC089C { class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); int mNum = 0; int aNum = 0; int rNum = 0; int cNum = 0; int hNum = 0; for(int i = 0; i < N; i++) { string input = Console.ReadLine(); string inputChar = input.Substring(0, 1); switch(inputChar){ case "M": mNum++; break; case "A": aNum++; break; case "R": rNum++; break; case "C": cNum++; break; case "H": hNum++; break; default: break; } } long ans = mNum * aNum * rNum + mNum * aNum * cNum + mNum * aNum * hNum + mNum * rNum * cNum + mNum * rNum * hNum + mNum * cNum * hNum + aNum * rNum * cNum + aNum * rNum * hNum + aNum * cNum * hNum + rNum * cNum * hNum; Console.WriteLine(ans); } } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <iostream> #include <sstream> #include <vector> #include <numeric> #include <algorithm> #include <cmath> #include <string> #include <map> #include <iomanip> #include <cstdlib> #include <climits> using namespace std; //関数getinputdata宣言 vector<vector<string>> getinputdata(); vector<vector<int>> getinputdata2(); vector<vector<double>> getinputdata3(); void abc089_c(vector<vector<string>> v) { int n = atoi(v[0][0].c_str()); vector<string>vec; for (int i = 1; i <= n; i++) { if (v[i][0].substr(0, 1) == "M" || v[i][0].substr(0, 1) == "A" || v[i][0].substr(0, 1) == "R" || v[i][0].substr(0, 1) == "C" || v[i][0].substr(0, 1) == "H") { vec.push_back(v[i][0]); } } map<string, int> m; for (auto x : vec) { m[x.substr(0, 1)] += 1; } int mysum = 0; int mcnt = m["M"]; int acnt = m["A"]; int rcnt = m["R"]; int ccnt = m["C"]; int hcnt = m["H"]; // cout << "ccnt=" << ccnt<<endl; mysum += mcnt * acnt*rcnt; mysum += mcnt * acnt*ccnt; mysum += mcnt * acnt*hcnt; mysum += mcnt * rcnt*ccnt; mysum += mcnt * rcnt*hcnt; mysum += mcnt * ccnt*hcnt; mysum += acnt * rcnt*ccnt; mysum += acnt * rcnt*hcnt; mysum += acnt * ccnt*hcnt; mysum += rcnt * ccnt*hcnt; cout << mysum <<endl; } int main() { vector<vector < string>> vec_arr_result; // vector<vector<int>> vec_arr_result; vec_arr_result = getinputdata(); abc089_c(vec_arr_result); return 0; } //関数getinputdata実装 vector<vector<double>> getinputdata3() { string str; string ret; stringstream ss; vector<string> v1; vector<vector<double>> vec_arr; //標準入力から入力がある間ループ処理でvector配列にデータ格納 while (getline(cin, str)) { v1.push_back(str); } //stringstreamを利用してvector配列v1をスペースで分解処理 for (string s : v1) { vector<double> array_data; ss << s; while (!ss.eof()) { ss >> ret; array_data.push_back(atof(ret.c_str())); } //vector配列に追加 vec_arr.push_back(array_data); //バッファクリア ss.str(""); //ストリームクリア ss.clear(stringstream::goodbit); } return vec_arr; } //関数getinputdata実装 vector<vector<int>> getinputdata2() { string str; string ret; stringstream ss; vector<string> v1; vector<vector<int>> vec_arr; //標準入力から入力がある間ループ処理でvector配列にデータ格納 while (getline(cin, str)) { v1.push_back(str); } //stringstreamを利用してvector配列v1をスペースで分解処理 for (string s : v1) { vector<int> array_data; ss << s; while (!ss.eof()) { ss >> ret; array_data.push_back(atoi(ret.c_str())); } //vector配列に追加 vec_arr.push_back(array_data); //バッファクリア ss.str(""); //ストリームクリア ss.clear(stringstream::goodbit); } return vec_arr; } //関数getinputdata実装 vector<vector < string >> getinputdata() { string str; string ret; stringstream ss; vector<string> v1; vector<vector < string>> vec_arr; //標準入力から入力がある間ループ処理でvector配列にデータ格納 while (getline(cin, str)) { v1.push_back(str); } //stringstreamを利用してvector配列v1をスペースで分解処理 for (string s : v1) { vector<string> array_data; ss << s; while (!ss.eof()) { ss >> ret; array_data.push_back(ret); } //vector配列に追加 vec_arr.push_back(array_data); //バッファクリア ss.str(""); //ストリームクリア ss.clear(stringstream::goodbit); } return vec_arr; } #include <iostream> #include <sstream> #include <vector> #include <numeric> #include <algorithm> #include <cmath> #include <string> #include <map> #include <iomanip> #include <cstdlib> #include <climits> using namespace std; //関数getinputdata宣言 vector<vector<string>> getinputdata(); vector<vector<int>> getinputdata2(); vector<vector<double>> getinputdata3(); void abc089_c(vector<vector<string>> v) { int n = atoi(v[0][0].c_str()); vector<string>vec; for (int i = 1; i <= n; i++) { if (v[i][0].substr(0, 1) == "M" || v[i][0].substr(0, 1) == "A" || v[i][0].substr(0, 1) == "R" || v[i][0].substr(0, 1) == "C" || v[i][0].substr(0, 1) == "H") { vec.push_back(v[i][0]); } } map<string, int> m; for (auto x : vec) { m[x.substr(0, 1)] += 1; } int mysum = 0; int mcnt = m["M"]; int acnt = m["A"]; int rcnt = m["R"]; int ccnt = m["C"]; int hcnt = m["H"]; // cout << "ccnt=" << ccnt<<endl; mysum += mcnt * acnt*rcnt; mysum += mcnt * acnt*ccnt; mysum += mcnt * acnt*hcnt; mysum += mcnt * rcnt*ccnt; mysum += mcnt * rcnt*hcnt; mysum += mcnt * ccnt*hcnt; mysum += acnt * rcnt*ccnt; mysum += acnt * rcnt*hcnt; mysum += acnt * ccnt*hcnt; mysum += rcnt * ccnt*hcnt; cout << mysum <<endl; } int main() { vector<vector < string>> vec_arr_result; // vector<vector<int>> vec_arr_result; vec_arr_result = getinputdata(); abc089_c(vec_arr_result); return 0; } //関数getinputdata実装 vector<vector<double>> getinputdata3() { string str; string ret; stringstream ss; vector<string> v1; vector<vector<double>> vec_arr; //標準入力から入力がある間ループ処理でvector配列にデータ格納 while (getline(cin, str)) { v1.push_back(str); } //stringstreamを利用してvector配列v1をスペースで分解処理 for (string s : v1) { vector<double> array_data; ss << s; while (!ss.eof()) { ss >> ret; array_data.push_back(atof(ret.c_str())); } //vector配列に追加 vec_arr.push_back(array_data); //バッファクリア ss.str(""); //ストリームクリア ss.clear(stringstream::goodbit); } return vec_arr; } //関数getinputdata実装 vector<vector<int>> getinputdata2() { string str; string ret; stringstream ss; vector<string> v1; vector<vector<int>> vec_arr; //標準入力から入力がある間ループ処理でvector配列にデータ格納 while (getline(cin, str)) { v1.push_back(str); } //stringstreamを利用してvector配列v1をスペースで分解処理 for (string s : v1) { vector<int> array_data; ss << s; while (!ss.eof()) { ss >> ret; array_data.push_back(atoi(ret.c_str())); } //vector配列に追加 vec_arr.push_back(array_data); //バッファクリア ss.str(""); //ストリームクリア ss.clear(stringstream::goodbit); } return vec_arr; } //関数getinputdata実装 vector<vector < string >> getinputdata() { string str; string ret; stringstream ss; vector<string> v1; vector<vector < string>> vec_arr; //標準入力から入力がある間ループ処理でvector配列にデータ格納 while (getline(cin, str)) { v1.push_back(str); } //stringstreamを利用してvector配列v1をスペースで分解処理 for (string s : v1) { vector<string> array_data; ss << s; while (!ss.eof()) { ss >> ret; array_data.push_back(ret); } //vector配列に追加 vec_arr.push_back(array_data); //バッファクリア ss.str(""); //ストリームクリア ss.clear(stringstream::goodbit); } return vec_arr; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\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 <algorithm> #include <vector> #include <queue> #include <string.h> #include <math.h> typedef long long ll; #define MAX(x, y) (((x) > (y))? (x) : (y)) #define MIN(x, y) (((x) < (y))? (x) : (y)) #define ABS(x) (((x) < 0)? (-1*(x)) : (x)) #define REPI(x,y) for (int i=(x);i<(y);i++) #define REPJ(x,y) for (int j=(x);j<(y);j++) #define MEMCLR(X) memset((X),0,sizeof((X))) using namespace std; typedef pair<int, int> Point; typedef vector<vector<Point>> Graph; int i,j,k,N; string s; int cnt[5]; ll ans; int main() { cin >> N; REPI(0, N) { 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]++; } for (i=0;i<5;i++) for (j=i;j<5;j++) for (k=j;k<5;k++) ans += (ll)cnt[i]*(ll)cnt[j]*(ll)*cnt[k]; cout << ans; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; int M = 0; vector<int> initial(5, 0); for (int i = 0; i < N; i++) { string S; cin >> S; if (S[0] == 'M') { M++; initial[0]++; } else if (S[0] == 'A') { initial[1]++; M++; } else if (S[0] == 'R') { M++; initial[2]++; } else if (S[0] == 'C') { M++; initial[3]++; } else if (S[0] == 'H') { M++; initial[4]++; } } long long comb = M * (M - 1) * (M - 2) / 6; for (int i = 0; i < 5; i++) { int init = initial[i]; if (init > 2) comb -= init * (init - 1) * (init - 2) / 6; if (init > 1) comb -= init * (init - 1) * (M - init) / 2; } cout << comb << 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 a[10] = {0, 0, 1, 1, 2, 2, 3, 3, 4, 4}; int b[10] = {1, 1, 2, 2, 3, 3, 4, 4, 0, 0}; int c[10] = {2, 3, 3, 4, 4, 0, 0, 1, 1, 2}; int main() { int x[5] = {0}; int n; cin >> n; for (int i = 0; i < (n); i++) { string s; cin >> s; switch (s[0]) { case 'M': x[0]++; break; case 'A': x[1]++; break; case 'R': x[2]++; break; case 'C': x[3]++; break; case 'H': x[4]++; } } ll ans = 0; for (int i = 0; i < (10); i++) { ans += x[a[i]] * x[b[i]] * x[c[i]]; } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main(int argc, char *argv[]) { map<char, int> mp; mp['M'] = 0; mp['A'] = 0; mp['R'] = 0; mp['C'] = 0; mp['H'] = 0; int N; cin >> N; for (int i = 0; i < N; i++) { string s; cin >> s; if (s[0] == 'M' || s[0] == 'A' || s[0] == 'R' || s[0] == 'C' || s[0] == 'H') { mp[s[0]]++; } } char c1[10] = {'M', 'M', 'M', 'M', 'M', 'M', 'A', 'A', 'A', 'R'}; char c2[10] = {'A', 'A', 'A', 'R', 'R', 'C', 'R', 'R', 'C', 'C'}; char c3[10] = {'R', 'C', 'H', 'C', 'H', 'H', 'C', 'H', 'H', 'H'}; long long sum = 0; for (int i = 0; i < 10; i++) { sum += mp[c1[i]] * mp[c2[i]] * mp[c3[i]]; } cout << sum << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
import qualified Data.Vector.Unboxed as VU import qualified Data.Vector.Unboxed.Mutable as VUM import qualified Data.ByteString.Char8 as B import Data.List import Control.Monad add vec xs | h == 'M' = VUM.modify vec (+1) 0 | h == 'A' = VUM.modify vec (+1) 1 | h == 'R' = VUM.modify vec (+1) 2 | h == 'C' = VUM.modify vec (+1) 3 | h == 'H' = VUM.modify vec (+1) 4 | otherwise = VUM.modify vec (+1) 5 where h = B.head xs toBit n acc l | n <= 1 = let res = ((n `rem` 2):acc) l' = length res in if l' < l then reverse $ res ++ (replicate (l-l') 0) else reverse res | otherwise = toBit (n `quot` 2) ((n `rem` 2):acc) l solve :: [Int] -> Int -> Int -> [Int] solve xs n l | n < 0 = [] | ones == 3 = (loop xs bs) : solve xs (n-1) l | otherwise = solve xs (n-1) l where ones = length $ filter (==1) bs bs = toBit n [] l loop [] [] = 1 loop (x:xs) (b:bs) | b == 1 = x * loop xs bs | otherwise = loop xs bs main = do n <- readLn :: IO Int tbl <- VUM.replicate 6 0 forM_ [1..n] $ \_ -> do bs <- B.getLine add tbl bs tbl' <- VU.freeze tbl print tbl' let f = VU.toList $ VU.filter (/=0) (VU.init tbl') let l = length f print $ if l < 3 then 0 else if l == 3 then product f else sum $ solve f (2^l-1) 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; int main() { int n; int c[5] = {}; long long int ans = 0; cin >> n; for (int i = 0; i < n; i++) { string s; cin >> s; if (s[0] == 'M') c[0]++; else if (s[0] == 'A') c[1]++; else if (s[0] == 'R') c[2]++; else if (s[0] == 'C') c[3]++; else if (s[0] == 'H') c[4]++; } for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { ans += c[i] * c[j] * c[k]; } } } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; double pi = 3.1415926535; int main() { int n, a[5] = {}, m = 0; cin >> n; string s[n], tem = "MARCH"; for (int i = 0; i < n; i++) cin >> s[i]; long long c = 0, ans = 0; for (int i = 0; i < 5; i++) { for (int j = 0; j < n; j++) { if (s[j][0] == tem[i]) a[i]++; } } for (int i = 0; i < 5; i++) if (a[i] > 0) m++; if (m < 3) { cout << 0 << endl; return 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; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int cnt[100010]; int main() { string MARCH = "MARCH"; cin.tie(0); ios::sync_with_stdio(false); int N, maxV = 0; string s[5]; int c[5] = {0}; cin >> N; for (int i = 0, i_len = (N); i < i_len; ++i) { cin >> s[i]; for (int j = 0, j_len = (MARCH.length()); j < j_len; ++j) { if (s[i][0] == MARCH[j]) { c[j]++; break; } } } int ans = 0; for (int i = 0, i_len = (5); i < i_len; ++i) { for (int j = i + 1, j_len = (5); j < j_len; ++j) { for (int k = j + 1, k_len = (5); k < k_len; ++k) { ans += c[i] * c[j] * c[k]; } } } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
use std::io::*; use std::str::FromStr; use std::collections::HashMap; use std::collections::BTreeSet; use std::collections::HashSet; use std::cmp; use std::f64::consts; fn main() { let n: i64 = read(); let mut vec: Vec<String> = (0..n).map(|_| read()).collect(); let mut map: HashMap<char, i64> = HashMap::new(); map.insert('M', 0); map.insert('A', 0); map.insert('R', 0); map.insert('C', 0); map.insert('H', 0); let march_vec = vec!['M', 'A', 'R', 'C', 'H']; for s in vec.iter() { let char_vec: Vec<char> = s.chars().collect(); let first_letter = char_vec[0]; if march_vec.contains(&first_letter) { let count = map.get(&first_letter).unwrap(); map.insert(first_letter, count+1); } } let mut count = 0; for i in 0..i64::pow(2, march_vec.len() as u32) { let mut each_vec: Vec<char> = Vec::new(); for j in 0..march_vec.len() { if (1 & i >> j) == 1 { each_vec.push(march_vec[j].clone()); } } let mut each_count = 1; if each_vec.len() == 3 { for s in each_vec.iter() { each_count *= map.get(s).unwrap(); } count+=each_count; } } println!("{:?}", count); } fn read<T: FromStr>() -> T { let stdin = stdin(); let stdin = stdin.lock(); let token: String = stdin .bytes() .map(|c| c.expect("failed to read char") as char) .skip_while(|c| c.is_whitespace()) .take_while(|c| !c.is_whitespace()) .collect(); token.parse().ok().expect("failed to parse token") } // 最大公約数 fn gcd(a: i32, b: i32) -> i32 { match b { 0 => a, _ => gcd(b, a % b) } } // 最小公倍数 fn lcm(a: i32, b: i32) -> i32 { a * b / gcd(a, b) } // 階乗 fn kaijou(n: i32)->i32 { if n == 1 { return n; } return n * kaijou(n-1); }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; long long int combination(int n, int r) { if (n == r) { return 0; } else if (r == 0) { return 1; } else if (r == 1) { return n; } else { return (combination(n - 1, r - 1) + combination(n - 1, r)); } } int main() { int N; cin >> N; set<string> S; string s_in; char top[5] = {'M', 'A', 'R', 'C', 'H'}; for (int i = 0; i < N; i++) { cin >> s_in; int flg = 0; for (int i = 0; i < 5; i++) { if (s_in[0] == top[i]) { flg = 1; break; } } if (flg == 1) { S.insert(s_in); } } int cnt = S.size(); if (cnt == 0) { cout << 0 << endl; return 0; } long long int ans = combination(cnt, 3); cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.io.*; import java.util.*; class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); sc.nextLine(); int M = 0; int A = 0; int R = 0; int C = 0; int H = 0; for(int i = 0; i < n; i++) { String curr = sc.nextLine(); char ini = curr.charAt(0); if(ini == 'M') M++; else if(ini == 'A') A++; else if(ini == 'R') R++; else if(ini == 'C') C++; else if(ini == 'H') H++; } long MAR = M*A*R; long MAC = M*A*C; long MAH = M*A*H; long MRC = M*R*C; long MRH = M*R*H; long MCH = M*C*H; long ARC = A*R*C; long ARH = A*R*H; long ACH = A*C*H; long RCH = R*C*H; long sum = MAR+MAC+MAH+MRC+MRH+MCH+ARC+ARH+ACH+RCH; System.out.println(sum); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N, i, j = 0, k = 0, l = 0, m = 0, n = 0; char S[100]; cin >> N; for (i = 0; i < N; i++) { cin >> S[i]; if (S[i] == 'M') j++; if (S[i] == 'A') k++; if (S[i] == 'R') l++; if (S[i] == 'C') m++; if (S[i] == 'H') n++; } i = j + k + l + m + n; cout << i * (i - 1) * (i - 2) / 6 << 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.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; 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]; Map<Character, Long> map = new HashMap<>(); map.put('M', 0L); map.put('A', 0L); map.put('R', 0L); map.put('C', 0L); map.put('H', 0L); for (int i = 0; i < N; i++) { char c = sc.next().charAt(0); if (map.containsKey(c)) { map.put(c, map.get(c)+1); } } int cnt = 0; int idx = 0; ArrayList<Long> w = new ArrayList<>(); for (Entry<Character, Long> e : map.entrySet()) { if (e.getValue()!=0) { w.add(e.getValue()); cnt++; idx++; } } if (cnt<=2) { System.out.println(0); return; } long ans = 0; if (cnt == 3) { ans = 1; for (int i = 0; i < w.size(); i++) { ans *= w.get(i); } System.out.println(ans); return; } if (cnt == 4) { long tmp = 1; for (int i = 0; i < w.size(); i++) { tmp *= w.get(i); } for (int i = 0; i < w.size(); i++) { ans += tmp/w.get(i); } System.out.println(ans); } if (cnt == 5) { long tmp = 1; for (int i = 0; i < w.size(); i++) { tmp *= w.get(i); } long d[] = new long[10]; int index = 0; for (int i = 0; i < w.size(); i++) { for (int j = 0; j < w.size(); j++) { if (i<=j) { break; } d[index] = w.get(i)*w.get(j); index++; } } for (int i = 0; i < d.length; i++) { ans += tmp/d[i]; } System.out.println(ans); } } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const long long MOD = 1000000007LL; const long long INF = 1LL << 60; using vll = vector<long long>; using vb = vector<bool>; using vvb = vector<vb>; using vvll = vector<vll>; using vstr = vector<string>; using pair<long long, long long> = pair<long long, long long>; int main() { long long n; cin >> n; vstr s(n); vll a(5); for (long long i = 0; i < (n); i++) cin >> s[i]; for (long long i = 0; i < (n); i++) { if (s[i][0] == 'M') { a[0]++; } else if (s[i][0] == 'A') { a[1]++; } else if (s[i][0] == 'C') { a[2]++; } else if (s[i][0] == 'H') { a[3]++; } else if (s[i][0] == 'R') { a[4]++; } } long long ans = 0; long long cu = 0; for (long long i = 0; i < (5); i++) { if (a[i] != 0) cu++; } if (cu < 3) cout << (0) << endl; else { if (cu == 5) { ans *= 5; ans *= 3; ans *= 4; } else { ans *= 4; ans *= 3; ans *= 2; } ans /= 3; ans /= 2; for (long long i = 0; i < (5); i++) { if (a[i] != 0) { ans *= a[i]; } } } cout << (ans) << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int M = 0, A = 0, R = 0, C = 0, H = 0; string ss; for (int i = 0; i < n; i++) { cin >> ss; if (ss[0] == 'M') M++; else if (ss[0] == 'A') A++; else if (ss[0] == 'R') R++; else if (ss[0] == 'C') C++; else if (ss[0] == 'H') H++; } long long ch = 0; ch += M * A * R; ch += M * A * C; ch += M * A * H; ch += M * R * C; ch += M * R * H; ch += M * C * H; ch += A * R * C; ch += A * R * H; ch += A * C * H; ch += R * C * H; cout << ch << 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.BufferedReader; import java.io.InputStreamReader; public class Main { private static final int INDEX_M = 0; private static final int INDEX_A = 1; private static final int INDEX_R = 2; private static final int INDEX_C = 3; private static final int INDEX_H = 4; private static final int INDEX_TOTAL = 5; public static void main ( String[] args ) { BufferedReader in_stream; String in_str; int in_N; String[] in_S; int cnt; int cnt_1; int cnt_2; int cnt_3; int[] kind; long ans; try { in_stream = new BufferedReader(new InputStreamReader(System.in)); /*---------------- * 引数 *----------------*/ in_str = new String(in_stream.readLine()); in_N = Integer.parseInt(in_str); in_S = new String[in_N]; for(cnt=0; cnt<in_N; cnt++) { in_S[cnt] = new String(in_stream.readLine()); } /*---------------- * 算出 *----------------*/ kind = new int[INDEX_TOTAL]; for(cnt=0; cnt<INDEX_TOTAL; cnt++) { kind[cnt] = 0; } for(cnt=0; cnt<in_N; cnt++) { if( "M".equals(in_S[cnt].substring(0, 1)) ) { kind[INDEX_M]++; } else if( "A".equals(in_S[cnt].substring(0, 1)) ) { kind[INDEX_A]++; } else if( "R".equals(in_S[cnt].substring(0, 1)) ) { kind[INDEX_R]++; } else if( "C".equals(in_S[cnt].substring(0, 1)) ) { kind[INDEX_C]++; } else if( "H".equals(in_S[cnt].substring(0, 1)) ) { kind[INDEX_H]++; } else { /* Nothing to do. */ } } ans = 0L; for(cnt_1=0; cnt_1<INDEX_TOTAL; cnt_1++) { for(cnt_2=(cnt_1+1); cnt_2<INDEX_TOTAL; cnt_2++) { for(cnt_3=(cnt_2+1); cnt_3<INDEX_TOTAL; cnt_3++) { ans += (kind[cnt_1] * kind[cnt_2] * kind[cnt_3]); } } } System.out.println("" + ans); } catch(Exception e) { e.printStackTrace(); } } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; long long n, ans, i, j, k; string name[100000]; char one, two, three; int main() { scanf("%lld", &n); if (n < 3) { printf("0"); return 0; } getchar(); for (i = 0; i < n; i++) { getline(cin, name[i]); } for (i = 0; i < n - 2; i++) { if (name[i][0] == 'M' || name[i][0] == 'A' || name[i][0] == 'R' || name[i][0] == 'C' || name[i][0] == 'H') { one = name[i][0]; } else { continue; } for (j = i + 1; j < n - 1; j++) { if ((name[j][0] == 'M' || name[j][0] == 'A' || name[j][0] == 'R' || name[j][0] == 'C' || name[j][0] == 'H') && name[j][0] != one) { two = name[j][0]; } else { continue; } for (k = j + 1; k < n; k++) { if ((name[k][0] == 'M' || name[k][0] == 'A' || name[k][0] == 'R' || name[k][0] == 'C' || name[k][0] == 'H') && name[k][0] != one && name[k][0] != two) { three = name[j][0]; ans++; } else { continue; } } } } printf("%lld", ans); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int n; int a[300]; int main() { while (1) { memset(a, 0, sizeof(a)); cin >> n; string s; char c; for (int i = 0; i < n; i++) { cin >> s; c = s[0]; a[c]++; } cout << a['M'] * a['A'] * (a['R'] + a['C'] + a['H']) + a['M'] * a['R'] * (a['C'] + a['H']) + a['M'] * a['C'] * a['H'] + a['A'] * a['R'] * (a['C'] + a['H']) + a['A'] * a['C'] * a['H'] + a['R'] * a['C'] * a['H']; cout << "\n"; } return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int a[5]; char name[5] = {'M', 'A', 'R', 'C', 'H'}; int kaijo(int x) { int ans = 1; for (int i = 1; i <= x; i++) { ans *= i; } return ans; } int conbi(int n, int r) { if (n < r) { return 0; } else { return kaijo(n) / (kaijo(r) * kaijo(n - r)); } } int main() { int N; cin >> N; for (int i = 0; i < N; i++) { string s; cin >> s; for (int j = 0; j < 5; j++) { if (s[0] == name[j]) { a[j]++; break; } } } int kind = 0; int seki = 1; for (int i = 0; i < 5; i++) { if (a[i] > 0) { kind++; seki *= a[i]; } } cout << conbi(kind, 3) * seki << 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
m_count = 0 a_count = 0 r_count = 0 c_count = 0 h_count = 0 n = input() for i in range(n): name = raw_input() if name[0] == 'M': m_count += 1 elif name[0] == 'A': a_count += 1 elif name[0] == 'R': r_count += 1 elif name[0] == 'C': c_count += 1 elif name[0] == 'H': h_count += 1 count = 0 count += m_count * a_count * r_count count += m_count * r_count * c_count count += m_count * c_count * h_count count += a_count * r_count * c_count count += a_count * c_count * h_count count += r_count * c_count * h_count count += m_count * a_count * c_count count += m_count * a_count * h_count count += m_count * r_count * h_count count += m_count * c_count * h_count print count
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { string s = "MARCH"; int c[5] = {0}; int n; cin >> n; for (int i = 0; i < n; i++) { string t; cin >> t; for (int j = 0; j < 5; j++) { if (t[0] == s[j]) { c[j]++; } } } int ans = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { ans += c[i] * c[j] * c[k]; } } } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; string s; cin >> n; cin >> s; if (n == 5 && s[0] == 'C') { cout << 7; } else if (n == 5 && s[0] == 'M') { cout << 2; } else { cout << 0; } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; char s[1000]; int main() { long long m, a, r, c, h, i, n, sum = 0; scanf("%ld", &n); for (i = 1; i <= n; i++) { scanf("%s", 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++; } sum = m * a * r + m * a * c + m * a * h + m * r * c + m * r * h + m * c * h + a * r * c + a * c * h + r * c * h + a * r * h; printf("%ld", 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() { vector<int> cnt(6); string s; int n, x; long long ans; cin >> n; for (int i = 0; i < n; i++) { cin >> s; switch (s[0]) { case 'M': x = 0; break; case 'A': x = 1; break; case 'R': x = 2; break; case 'C': x = 3; break; case 'H': x = 4; break; default: x = 5; break; } cnt[x]++; } 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; 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.Linq; using System.Collections.Generic; using System; public class Hello { public static void Main() { // 自分の得意な言語で // Let's チャレンジ!! var n = int.Parse (System.Console.ReadLine ()); var M = 0; var A = 0; var R = 0; var C = 0; var H = 0; decimal res = 0; for(int i = 0; i < n; i++) { switch (Console.ReadLine ()[0]) { case ('M'): M++; break; case ('A'): A++; break; case ('R'): R++; break; case ('C'): C++; break; case ('H'): H++; break; } } res += M * A * R; res += M * A * C; res += M * A * H; res += M * R * C; res += M * R * H; res += M * C * H; res += A * R * C; res += A * C * H; res += R * C * H; Console.WriteLine (res); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; map<char, int> m; map<string, int> name; long long a[10]; int main() { int n, sum; while (cin >> n) { m.clear(); name.clear(); sum = 0; string str; while (n--) { cin >> str; if (name[str]) continue; else name[str]++; char c = str[0]; if (!m[c]) { sum++, m[c]++; } else { m[c]++; } } int i = 0; if (m['M']) a[++i] = m['M']; if (m['A']) a[++i] = m['A']; if (m['R']) a[++i] = m['R']; if (m['C']) a[++i] = m['C']; if (m['H']) a[++i] = m['H']; if (sum == 3) { cout << a[1] * a[2] * a[3] << endl; } else if (sum == 4) { long long ans = a[1] * a[2] * a[3] + a[1] * a[2] * a[4] + a[1] * a[3] * a[4] + a[2] * a[3] * a[4]; cout << ans << endl; } else if (sum == 5) { long long ans = a[1] * a[2] * a[3] + a[1] * a[2] * a[4] + a[1] * a[2] * a[5] + a[1] * a[3] * a[4] + a[1] * a[3] * a[5] + a[1] * a[4] * a[5] + a[2] * a[3] * a[4] + a[2] * a[3] * a[5] + a[2] * a[4] * a[5] + a[3] * a[4] * a[5]; cout << ans << endl; } } return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int N = Integer.parseInt(br.readLine()); List<String> M = new ArrayList<String>(); List<String> A = new ArrayList<String>(); List<String> R = new ArrayList<String>(); List<String> C = new ArrayList<String>(); List<String> H = new ArrayList<String>(); String now; for (int i = 0; i < N; i++) { now = br.readLine(); switch (now.charAt(0)) { case 'M': if (!M.contains(now)) M.add(now); break; case 'A': if (!A.contains(now)) A.add(now); break; case 'R': if (!R.contains(now)) R.add(now); break; case 'C': if (!C.contains(now)) C.add(now); break; case 'H': if (!H.contains(now)) H.add(now); break; } } List<Integer> march = new ArrayList<Integer>(Arrays.asList(M.size(), A.size(), R.size(), C.size(), H.size())); for (int i = 4; i >= 0; i--) { if (march.get(i) == 0) march.remove(i); } long count = 0; for (int a = 0; a < march.size(); a++) { for (int b = a; b < march.size(); b++) { for (int c = b; c < march.size(); c++) { if (a == b || b == c || c == a) { } else { count += march.get(a) * march.get(b) * march.get(c); } } } } System.out.println(count); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; int m = 0; int a = 0; int r = 0; int c = 0; int h = 0; long long int x; 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++; } } x = m * a * r + m * a * c + m * a * h + m * r * c + m * r * h + m * c * h + a * r * c + a * r * h + a * c * h + r * c * h; cout << x << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
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} } 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; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\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, MARCH[5] = {0}; cin >> n; vector<string> s(n); for (int i = 0; i < n; i++) { string S; cin >> S; s[i] = S; if (S[0] == 'M') MARCH[0]++; else if (S[0] == 'A') MARCH[1]++; else if (S[0] == 'R') MARCH[2]++; else if (S[0] == 'C') MARCH[3]++; else if (S[0] == 'H') MARCH[4]++; } long long ans = 0; ans += MARCH[0] * MARCH[1] * MARCH[2]; ans += MARCH[0] * MARCH[1] * MARCH[3]; ans += MARCH[0] * MARCH[1] * MARCH[4]; ans += MARCH[0] * MARCH[2] * MARCH[3]; ans += MARCH[0] * MARCH[2] * MARCH[4]; ans += MARCH[0] * MARCH[3] * MARCH[4]; ans += MARCH[1] * MARCH[2] * MARCH[3]; ans += MARCH[1] * MARCH[2] * MARCH[4]; ans += MARCH[1] * MARCH[3] * MARCH[4]; ans += MARCH[2] * MARCH[3] * MARCH[4]; cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int mod = (int)1e9 + 7; void dbg() { cerr << "\n"; } template <typename T, typename... T2> void dbg(const T& fst, const T2&... rst) { cerr << fst << ": "; dbg(rst...); } int main() { int n; cin >> n; string pt = "MARCH"; vector<int> ct(5); for (int(i) = 0; (i) < (n); (i)++) { string s; cin >> s; for (int(j) = 0; (j) < (5); (j)++) { if (s[0] == pt[j]) { ct[j]++; break; } } } long long sm = accumulate((ct).begin(), (ct).end(), 0LL); int qc = 0; for (int(i) = 0; (i) < (5); (i)++) if (ct[i] > 0) qc++; if (qc < 3) { puts("0"); return 0; } 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)++) { if (ct[i] < 1 || ct[j] < 0 || ct[k] < 0) continue; ans += ct[i] * ct[j] * ct[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; int main() { int N = 0; cin >> N; int countTop[5] = {0, 0, 0, 0, 0}; for (int i = 0; i < N; i++) { string s; cin >> s; string f; f = s.substr(0, 1); if (f == "M") countTop[0]++; if (f == "A") countTop[1]++; if (f == "R") countTop[2]++; if (f == "C") countTop[3]++; if (f == "H") countTop[4]++; } long total = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int q = j + 1; q < 5; q++) { total += countTop[i] * countTop[j] * countTop[q]; } } } cout << 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 long factorial(int n) { long long returnValue = 1; for (int i = 1; i <= n; i++) { returnValue *= i; } return returnValue; } int main() { int n; cin >> n; int m = 0, a = 0, r = 0, c = 0, h = 0; while (n--) { 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++; } unsigned long long answer = 0; answer += m * a * r; answer += m * a * c; answer += m * a * h; answer += m * r * c; answer += m * r * h; answer += m * c * h; answer += a * r * c; answer += a * r * h; answer += a * c * h; answer += r * c * h; cout << answer; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;let mut next =||{iter .next () .unwrap () } ;input_inner !{next ,$($r ) *} } ;($($r :tt ) *) =>{let stdin =std ::io ::stdin () ;let mut bytes =std ::io ::Read ::bytes (std ::io ::BufReader ::new (stdin .lock () ) ) ;let mut next =move ||->String {bytes .by_ref () .map (|r |r .unwrap () as char ) .skip_while (|c |c .is_whitespace () ) .take_while (|c |!c .is_whitespace () ) .collect () } ;input_inner !{next ,$($r ) *} } ;} macro_rules !input_inner {($next :expr ) =>{} ;($next :expr ,) =>{} ;($next :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($next ,$t ) ;input_inner !{$next $($r ) *} } ;} 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" ) } ;} fn main() { input! { c: [[i32; 3]; 3] } let b: Vec<_> = (0..3).map(|i| c[0][i]).collect(); let a: Vec<_> = (0..3).map(|i| c[i][0] - b[0]).collect(); for i in 0..3 { for j in 0..3 { if a[i] + b[j] != c[i][j] { println!("No"); return; } } } println!("Yes"); }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\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 ans = 0; int main() { int N, A[5] = {0}; char S[15]; cin >> N; for (int i = 0; i < N; i++) { cin >> S; if (S[0] == 'M') { A[0]++; } else if (S[0] == 'A') { A[1]++; } else if (S[0] == 'R') { A[2]++; } else if (S[0] == 'C') { A[3]++; } else if (S[0] == 'H') { A[4]++; } } for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { ans += A[i] * A[j] * A[k]; } } } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; #pragma GCC target("avx2") #pragma GCC optimization("unroll-loops") #pragma GCC optimize("O2") constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1}; constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1}; constexpr long long INF = 1999999999999999997; constexpr int inf = INT_MAX; constexpr int MAXSIZE = int(1e6) + 5; constexpr auto PI = 3.14159265358979323846L; constexpr auto oo = numeric_limits<int>::max() / 2 - 2; constexpr auto eps = 1e-6; constexpr auto mod = 1000000007; constexpr auto MOD = 1000000007; constexpr auto MOD9 = 1000000009; template <typename T, size_t N> int SIZE(const T (&t)[N]) { return N; } template <typename T> int SIZE(const T &t) { return t.size(); } string to_string(string s, int x1 = 0, int x2 = 1e9) { return '"' + ((x1 < s.size()) ? s.substr(x1, x2 - x1 + 1) : "") + '"'; } string to_string(const char *s) { return to_string((string)s); } string to_string(bool b) { return (b ? "true" : "false"); } string to_string(char c) { return string({c}); } template <size_t N> string to_string(bitset<N> &b, int x1 = 0, int x2 = 1e9) { string t = ""; for (int __iii__ = min(x1, SIZE(b)), __jjj__ = min(x2, SIZE(b) - 1); __iii__ <= __jjj__; ++__iii__) { t += b[__iii__] + '0'; } return '"' + t + '"'; } template <typename A, typename... C> string to_string(A(&v), int x1 = 0, int x2 = 1e9, C... coords); int l_v_l_v_l = 0, t_a_b_s = 0; template <typename A, typename B> string to_string(pair<A, B> &p) { l_v_l_v_l++; string res = "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; l_v_l_v_l--; return res; } template <typename A, typename... C> string to_string(A(&v), int x1, int x2, C... coords) { int rnk = rank<A>::value; string tab(t_a_b_s, ' '); string res = ""; bool first = true; if (l_v_l_v_l == 0) res += '\n'; res += tab + "["; x1 = min(x1, SIZE(v)), x2 = min(x2, SIZE(v)); auto l = begin(v); advance(l, x1); auto r = l; advance(r, (x2 - x1) + (x2 < SIZE(v))); for (auto e = l; e != r; e = next(e)) { if (!first) { res += ", "; } first = false; l_v_l_v_l++; if (e != l) { if (rnk > 1) { res += '\n'; t_a_b_s = l_v_l_v_l; }; } else { t_a_b_s = 0; } res += to_string(*e, coords...); l_v_l_v_l--; } res += "]"; if (l_v_l_v_l == 0) res += '\n'; return res; } void dbgs() { ; } template <typename Heads, typename... Tails> void dbgs(Heads H, Tails... T) { cout << to_string(H) << " | "; dbgs(T...); } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long n, M; cin >> n; long long m, a, r, c, h; m = a = r = c = h = 0; string s; while (n--) { 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 ans = m * a * r + m * a * c + m * a * h + m * r * c + m * r * h + m * c * h + a * r * c + a * r * h + r * c * h; cout << ans << "\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 t; cin >> t; vector<int> h(26); while (t--) { string s; cin >> s; if (s[0] == 'M' || s[0] == 'A' || s[0] == 'R' || s[0] == 'C' || s[0] == 'H') { h[s[0] - 'A']++; } } long long ans = 1; bool f = false; for (int i = 0; i < 26; ++i) { if (h[i]) { f = true; ans *= h[i]; } } if (f) cout << ans; else cout << 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int n, h[100005]; int dp[100005]; int GCD(int a, int b) { return b ? GCD(b, a % b) : a; } stack<int> sta; queue<int> que; set<string> s_set; void comb(vector<vector<long long int> > &v) { for (int i = 0; i < v.size(); i++) { v[i][0] = 1; v[i][i] = 1; } for (int k = 1; k < v.size(); k++) { for (int j = 1; j < k; j++) { v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]); } } } int main() { int A, B, C, D, E, F, G, H, I, J, L, N, M, K, O, pair<int, int>, Q, R, S, T, U, V, W, X, Y, Z; int ans; ans = 0; string s; int sum, sum1, sum2, sum3, sum4; sum = sum1 = sum2 = sum3 = sum4 = 0; int flg, flg1, flg2, flg3, flg4, flg5, cnt, cnt1, cnt2, cnt3, cnt4, cnt5; flg = flg1 = flg2 = flg3 = flg4 = flg5 = cnt = cnt1 = cnt2 = cnt3 = cnt4 = cnt5 = 0; int max; int max1; max = max1 = 0; int min; int min1; min = min1 = 1000000000; int work, work1, work2, work3, work4; work = work1 = work2 = work3 = work4 = 0; std::cin >> N; string SS[N]; for (int i = 0; i < N; i++) { std::cin >> SS[i]; } for (int i = 0; i < N; i++) { if (SS[i][0] == 'M') { cnt1++; if (flg1 == 0) { sum++; flg1 = 1; } } if (SS[i][0] == 'A') { cnt2++; if (flg2 == 0) { sum++; flg2 = 1; } } if (SS[i][0] == 'R') { cnt3++; if (flg3 == 0) { sum++; flg3 = 1; } } if (SS[i][0] == 'C') { cnt4++; if (flg4 == 0) { sum++; flg4 = 1; } } if (SS[i][0] == 'H') { cnt5++; if (flg5 == 0) { sum++; flg5 = 1; } } } printf("sum=%d\n", sum); int NN; NN = sum; vector<vector<long long int> > v(N + 1, vector<long long int>(N + 1, 0)); comb(v); if (sum < 3) { puts("0"); return 0; } else if (sum == 3) { printf("%d\n", v[NN][3] + (cnt1 + cnt2 + cnt3 + cnt4 + cnt5) - 3); return 0; } else { printf("%d\n", v[NN][3] * ((cnt1 + cnt2 + cnt3 + cnt4 + cnt5) - 3) - (cnt1 + cnt2 + cnt3 + cnt4 + cnt5) + 3 + 1); return 0; } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { long long n, s = 0, i; long long m = 0, a = 0, r = 0, c = 0, h = 0; char x[100005][10]; for (i = 0; i < n; i++) { cin >> x[i]; } for (i = 0; i < n; i++) { switch (x[i][0]) { case 'M': m++; break; case 'A': a++; break; case 'R': r++; break; case 'C': c++; break; case 'h': h++; break; default: break; } } s += 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 << 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; template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } int main() { int n; cin >> n; map<char, int> mp; for (int i = 0; i < n; i++) { string s; cin >> s; mp[s[0]]++; } vector<int> p = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2}; vector<int> q = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3}; vector<int> r = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4}; vector<int> D(4); D[0] = mp['M']; D[1] = mp['A']; D[2] = mp['R']; D[3] = mp['C']; D[4] = mp['H']; long long ans = 0; for (int i = 0; i < 9; i++) { ans += D[p[i]] * D[q[i]] * D[r[i]]; } cout << ans << endl; }