Search is not available for this dataset
name
stringlengths
2
88
description
stringlengths
31
8.62k
public_tests
dict
private_tests
dict
solution_type
stringclasses
2 values
programming_language
stringclasses
5 values
solution
stringlengths
1
983k
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { 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]++; } } } long long ans = 0; for (int i = 0; i < 5; ++i) { for (int j = i + 1; j < 5; ++j) { for (int k = j + 1; k < 5; ++k) { ans += c[i] * c[j] * c[k]; } } } cout << ans << endl; 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> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } int N, cnt[5]; char check[5] = {'M', 'A', 'R', 'C', 'H'}; int main() { cin >> N; string S[N]; for (int i = 0; i < (int)(N); i++) { cin >> S[i]; for (int j = 0; j < (int)(5); j++) { if (S[i][0] == check[j]) { cnt[j]++; } } } int sum = 0; for (int i = 0; i < (int)(5); i++) { sum += cnt[i]; } if (sum < 3) { cout << 0 << endl; } else { int ans = 1; for (int i = 0; i < (int)(5); i++) { if (cnt[i]) ans *= cnt[i]; } cout << ans << endl; } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int march[5] = {}; for (int i = 0; i < n; i++) { string s; cin >> 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; 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[i] * march[j] * march[k]; } } } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; signed main() { long long N; string S[114514]; long long Ans = 0; long long m[5] = {}; long long sum = 0; cin >> N; for (long long i = 0; i < (N); i++) { cin >> S[i]; if (S[i][0] == 'M') { m[0]++; } else if (S[i][0] == 'A') { m[1]++; } else if (S[i][0] == 'R') { m[2]++; } else if (S[i][0] == 'C') { m[3]++; } else if (S[i][0] == 'H') { m[4]++; } } for (long long i = 0; i < (5); i++) { sum += m[i]; } Ans += m[0] * m[1] * m[2]; Ans += m[0] * m[1] * m[3]; Ans += m[0] * m[1] * m[4]; Ans += m[0] * m[2] * m[3]; Ans += m[0] * m[2] * m[4]; Ans += m[0] * m[3] * m[4]; Ans += m[1] * m[2] * m[3]; Ans += m[1] * m[2] * m[4]; Ans += m[1] * m[3] * m[4]; Ans += m[1] * m[3] * m[4]; Ans += 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; 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', 'N', 'C', 'N', 'N', 'C', 'N', 'N', 'N'}; 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
cpp
#include<iostream> #include<string> #include<algorithm> #include<vector> #include<iomanip> #include<math.h> #include<complex> #include<queue> #include<deque> #include<stack> #include<map> #include<set> #include<bitset> #include<functional> #include<assert.h> #include<numeric> using namespace std; #define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i ) #define rep(i,n) REP(i,0,n) #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() using ll = long long; const int inf=1e9+7; const ll longinf=1LL<<60 ; const ll mod=1e9+7 ; using namespace std; struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast; template<typename ...Ts> void show(Ts... ts){ cout<<"#:"; auto print=[](auto v){cout<<v<<" ";}; initializer_list<int>{(void(print(ts)),0)...}; cout<<endl; } vector<int> subv(vector<int> s,int n,int d){ vector<int> rt; rep(i,d)rt.push_back(s[n+i]); return rt; } void solve(vector<int> a){ int n=a.size()-2; int len=0; rep(i,n+1){ len+=abs(a[i+1]-a[i]); } REP(i,1,n+1){ int diff=abs(a[i+1]-a[i-1]) - ( abs(a[i]-a[i-1])+abs(a[i+1]-a[i]) ); cout<<len+diff<<endl; } return; } int main(void){ int n,ans=0; string s; cin>>n; vector<int> t(5,0); map<char, int> mp; rep(i,n){ cin>>s; mp[s[0]]++; } int c=0; for(auto i:"MARCH"){ t[c]=mp[i]; c++; //cout<<i<<mp[i]<<endl; } n=5; rep(i,n){ //ans+=t[i]*(t[i]-1)*(t[i]-2)/6; REP(j,i+1,n+1){ //ans+=t[i]*(t[i]-1)*t[j]/3; REP(k,j+1,n+1){ ans+=t[i]*t[j]*t[k]; } } } cout<<ans<<endl; //solve(t); }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "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 <= 2) cout << 0 << 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; string s[100000]; int counts[5]; int main() { for (size_t i = 0; i < 5; i++) { counts[i] = 0; } int N; cin >> N; string march = "MARCH"; for (size_t i = 0; i < N; i++) { cin >> s[i]; for (size_t j = 0; j < 5; j++) { if (s[i][0] == march[j]) { counts[j]++; } } } long long ans = 0; for (size_t i = 0; i < 5; i++) { for (size_t j = i + 1; j < 5; j++) { for (size_t k = j + 1; k < 5; k++) { ans += counts[i] * counts[j] * counts[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
from collections import Counter from itertools import combinations N = int(input()) S = [input()[0] for _ in range(N)] cnt = Counter(S) ans = 0 for elem in combinations(list('MARCH'), 3): ans += cnt[elem[0]]*cnt[elem[1]]*cnt[elem[2]] print(ans)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
import collections import itertools N = int(input()) s = "MARCH" lst = [] for i in range(N): begin = list(input())[0] if begin in list(s): lst.append(begin) ans = 0 for i in list(itertools.combinations(lst,3)): if (len(set(i)) == 3): ans += 1 print(ans)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
5 MASHIKE RUMOI OBIRA HABORO HOROKANAI
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
N = int(input()) S = [input() for _ in range(N)] m = 0 a = 0 r = 0 c = 0 h = 0 for t in S: if t[0] == "M": m += 1 elif t[0] == "A": a += 1 elif t[0] == "R": r += 1 elif t[0] == "C": c += 1 elif t[0] == "H": h += 1 if m == 0: m = 1 if a == 0: a = 1 if r == 0: r = 1 if c == 0: c = 1 if h == 0: h = 1 print(m*a*r*c*h)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; int M = 0, A = 0, R = 0, C = 0, H = 0; string S; while (N--) { cin >> S; switch (S[0]) { case 'M': M++; break; case 'A': A++; break; case 'R': R++; break; case 'C': C++; break; case 'H': H++; break; } } cout << M * A * R + M * A * C + M * A * H + M * R * C + M * R * H + M * C * H + A * R * C + A * R * H + A * C * H + R * C * H; 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() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; string name; int count[5] = {}; int pattern = 0; for (int i = 0; i < n; i++) { cin >> name; if (name.find("M") == 0) { count[0]++; } if (name.find("A") == 0) { count[1]++; } if (name.find("R") == 0) { count[2]++; } if (name.find("C") == 0) { count[3]++; } if (name.find("H") == 0) { count[4]++; } } for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { if (count[i] + count[j] + count[k] >= 3) { pattern += count[i] * count[j] * count[k]; } } } } cout << pattern << "\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 argc, const char *argv[]) { array<long long, 256> cnts{0}; int n; cin >> n; for (int i = 0; i < n; ++i) { string s; cin >> s; cnts[s[0]]++; } string chs = "MARCH"; long long ans; for (int i = 0; i < chs.size() - 2; ++i) { for (int j = i + 1; j < chs.size() - 1; ++j) { for (int k = j + 1; k < chs.size(); ++k) { ans += cnts[chs[i]] * cnts[chs[j]] * cnts[chs[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<iostream> #include<string> #include<vector> #include<stdio.h> #include<algorithm> #include<math.h> #include<numeric> #include<iomanip> #include<deque> #include<tuple> #include<queue> #include<map> #include<cstdint> #include<unordered_map> #include<boost/multiprecision/cpp_int.hpp> #define rep(i, n) for(int i = 0; i < (int)(n); i++) #define FOR(i,a,b) for(int i=(a);i<(b);i++) #define vi vector<int> #define all(x) (x).begin(),(x).end() #define Endl endl #define F first #define S second namespace mp = boost::multiprecision; using cpp_int = mp::cpp_int; using ll = long long; using namespace std; int main() { int n; cin >> n; vector<int>MARCH(5); rep(i, n) { string s; cin >> 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]++; } } int i = 1; ll ans = 0; while (i < pow(2, 5)) { int count = 0; int tmp = 1; rep(k, 5) { if (i&(1 << k)) { count++; tmp *= MARCH[k]; } } if (count == 3) { ans += tmp; } 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, i; cin >> n; int m = 0, a = 0, r = 0, c = 0, h = 0; string temp; for (i = 0; i < n; ++i) { cin >> temp; if (temp.at(0) == 'M') { ++m; } if (temp.at(0) == 'A') { ++a; } if (temp.at(0) == 'R') { ++r; } if (temp.at(0) == 'C') { ++c; } if (temp.at(0) == 'H') { ++h; } } long long ans = m * a * r + m * a * c + m * a * h + m * r * c + m * r * h + m * c * h + a * r * c + a * r * h + a * c * h + r * c * h; cout << ans << endl; 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 sys import itertools sys.setrecursionlimit(1000000000) from heapq import heapify,heappop,heappush,heappushpop import math import collections import copy mod = 10**9 + 7 def combi(n,r): x = math.factorial(n)%mod y = math.factorial(r) y = pow(y,mod-2,mod) return x*y%mod if __name__ == "__main__": n = int(input()) S = [input() for i in range(n)] koho = [] for i in range(n): if S[i][0] == "M" or S[i][0] == "A" or S[i][0] == "R" or S[i][0] == "C" or S[i][0] == "H": koho.append(S[i]) c = list(itertools.combinations(koho,3)) cnt = 0 for name1,name2,name3 in c: if name1[0] != name2[0] and name1[0] != name3[0] and name2[0] != name3[0]: cnt+=1 print(cnt)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); size_t n; cin >> n; map<char, size_t> names; for (size_t i = 0; i < n; ++i) { string s; cin >> s; if (s.find_first_of("MARCH") == 0) { ++names[s.front()]; } } cout << names['M'] * names['A'] * names['R'] + names['M'] * names['A'] * names['C'] + names['M'] * names['A'] * names['H'] + names['M'] * names['R'] * names['C'] + names['M'] * names['R'] * names['H'] + names['A'] * names['R'] * names['C'] + names['A'] * names['R'] * names['H'] + names['R'] * names['C'] * names['H'] << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; char chars[10][3] = { {'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', 'R', 'H'}, {'R', 'C', 'H'}, }; int main() { int N; cin >> N; unordered_map<char, set<string>> mp; for (int i = 0; i <= N - 1; ++i) { string s; cin >> s; mp[s[0]].insert(s); } ll ans = 0; for (int i = 0; i <= 9; ++i) { ll comb = 1; for (int j = 0; j <= 2; ++j) { comb *= mp[chars[i][j]].size(); } ans += comb; } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); StringBuilder sb = new StringBuilder(); int n = sc.nextInt(); int[] a = new int[5];//m a r c h String str; for (int i = 0; i < n; i++) { str = sc.next(); if (str.startsWith("M")) { a[0]++; } else if (str.startsWith("A")) { a[1]++; } else if (str.startsWith("R")) { a[2]++; } else if (str.startsWith("C")) { a[3]++; } else if (str.startsWith("H")) { a[4]++; } } int sum = 0; for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 4; j++) { for (int k = j + 1; k < 5; k++) { sum += a[i] * a[j] * a[k]; } } } System.out.println(sum); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<string> name(n); vector<int> ncount(5); for (int i = 0; i < (int)(n); ++i) cin >> name[i]; sort(name.begin(), name.end()); for (int i = 0; i < (int)(n); ++i) { switch (name[i][0]) { case 'M': ncount[0] += 1; break; case 'A': ncount[1] += 1; break; case 'R': ncount[2] += 1; break; case 'C': ncount[3] += 1; break; case 'H': ncount[4] += 1; break; } } int ans = 0; for (int i = 0; i < 1 << 5; i++) { int cnt = 0; int ansi = 1; for (int j = 0; j < 5; j++) { if (i & (1 << j)) { ansi *= ncount[j]; cnt += 1; } } if (cnt == 3) ans += ansi; } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int maxn = 10001; string s[maxn]; int n; char name[5] = {'M', 'A', 'R', 'C', 'H'}; int cnt[5]; int vis[5]; long long total = 0; void dfs(int cur, int temp, int pos) { if (cur == 3) { total += temp; return; } for (int i = pos; i < 5; i++) { if (cnt[i] && !vis[i]) { vis[i] = 1; temp *= cnt[i]; dfs(cur + 1, temp, i + 1); temp /= cnt[i]; vis[i] = 0; } } } int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> s[i]; for (int j = 0; j < 5; j++) { if (s[i][0] == name[j]) { cnt[j]++; break; } } } dfs(0, 1, 0); cout << total; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python2
# -*- coding: utf-8 -*- import itertools def filter_name(n): return n == "M" or n == "A" or n == "R" or n == "C" or n == "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 if dic[i[0:1]] >= 2: return False return True n = input() a = [] for i in range(n): b = raw_input() if filter_name(b[0:1]): a.append(b) a = list(itertools.combinations(a, 3)) a = filter(filter_ok, a) print len(a)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.io.*; import java.util.*; /** * @author baito */ public class Main { static StringBuilder sb = new StringBuilder(); static FastScanner sc = new FastScanner(System.in); static int INF = 10000; static long MOD = 1000000007; static long[] f;//factorial static int[] y4 = {0, 1, 0, -1}; static int[] x4 = {1, 0, -1, 0}; static int[] y8 = {0, 1, 0, -1, -1, 1, 1, -1}; static int[] x8 = {1, 0, -1, 0, 1, -1, 1, -1}; static int N; static int m, a, r, c, h; public static void main(String[] args) { m = a = r = c = h = 0; N = sc.nextInt(); //longを忘れるなオーバーフローするぞ for (int i = 0; i < N; i++) { char te = sc.next().toCharArray()[0]; switch (te) { case 'M': m++; break; case 'A': a++; break; case 'R': r++; break; case 'C': c++; break; case 'H': h++; break; } } int types = 0; if (m > 0) types++; if (a > 0) types++; if (r > 0) types++; if (c > 0) types++; if (h > 0) types++; if (types < 3) { System.out.println("0"); return; } long ans = 0; long comb = ncr(types, 3); long pieces = comb * 3 / types; ans = comb + pieces * (m + a + r + c + h - types); System.out.println(ans); } //次の順列に書き換える、最大値ならfalseを返す public static boolean nextPermutation(int A[]) { int len = A.length; int pos = len - 2; for (; pos >= 0; pos--) { if (A[pos] < A[pos + 1]) break; } if (pos == -1) return false; //posより大きい最小の数を二分探索 int ok = pos + 1; int ng = len; while (Math.abs(ng - ok) > 1) { int mid = (ok + ng) / 2; if (A[mid] > A[pos]) ok = mid; else ng = mid; } swap(A, pos, ok); reverse(A, pos + 1, len - 1); return true; } //次の順列に書き換える、最小値ならfalseを返す public static boolean prevPermutation(int A[]) { int len = A.length; int pos = len - 2; for (; pos >= 0; pos--) { if (A[pos] > A[pos + 1]) break; } if (pos == -1) return false; //posより小さい最大の数を二分探索 int ok = pos + 1; int ng = len; while (Math.abs(ng - ok) > 1) { int mid = (ok + ng) / 2; if (A[mid] < A[pos]) ok = mid; else ng = mid; } swap(A, pos, ok); reverse(A, pos + 1, len - 1); return true; } //↓nCrをmod計算するために必要。 ***factorial(N)を呼ぶ必要がある*** static long ncr(int n, int r) { factorial(n); return f[n] / (f[n - r] * f[r]); } static long modNcr(int n, int r) { long result = f[n]; result = result * modInv(f[n - r]) % MOD; result = result * modInv(f[r]) % MOD; return result; } static long modInv(long n) { return modPow(n, MOD - 2); } static void factorial(int n) { f = new long[n + 1]; f[0] = f[1] = 1; for (int i = 2; i <= n; i++) { f[i] = (f[i - 1] * i) % MOD; } } static long modPow(long x, long n) { long res = 1L; while (n > 0) { if ((n & 1) == 1) { res = res * x % MOD; } x = x * x % MOD; n >>= 1; } return res; } //↑nCrをmod計算するために必要 static int gcd(int n, int r) { return r == 0 ? n : gcd(r, n % r); } static long gcd(long n, long r) { return r == 0 ? n : gcd(r, n % r); } static <T> void swap(T[] x, int i, int j) { T t = x[i]; x[i] = x[j]; x[j] = t; } static void swap(int[] x, int i, int j) { int t = x[i]; x[i] = x[j]; x[j] = t; } public static void reverse(int[] x) { int l = 0; int r = x.length - 1; while (l < r) { int temp = x[l]; x[l] = x[r]; x[r] = temp; l++; r--; } } public static void reverse(int[] x, int s, int e) { int l = s; int r = e; while (l < r) { int temp = x[l]; x[l] = x[r]; x[r] = temp; l++; r--; } } static int length(int a) { int cou = 0; while (a != 0) { a /= 10; cou++; } return cou; } static int length(long a) { int cou = 0; while (a != 0) { a /= 10; cou++; } return cou; } static int countC2(char[][] a, char c) { int co = 0; for (int i = 0; i < a.length; i++) for (int j = 0; j < a[0].length; j++) if (a[i][j] == c) co++; return co; } static void fill(int[][] a, int v) { for (int i = 0; i < a.length; i++) for (int j = 0; j < a[0].length; j++) a[i][j] = v; } static int max(int a, int b, int c) { return Math.max(a, Math.max(b, c)); } static int abs(int a) { return Math.abs(a); } static class FastScanner { private BufferedReader reader = null; private StringTokenizer tokenizer = null; public FastScanner(InputStream in) { reader = new BufferedReader(new InputStreamReader(in)); tokenizer = null; } public String next() { if (tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new StringTokenizer(reader.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken(); } /*public String nextChar(){ return (char)next()[0]; }*/ public String nextLine() { if (tokenizer == null || !tokenizer.hasMoreTokens()) { try { return reader.readLine(); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken("\n"); } public long nextLong() { return Long.parseLong(next()); } public int nextInt() { return Integer.parseInt(next()); } public double nextDouble() { return Double.parseDouble(next()); } public int[] nextIntArray(int n) { int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = nextInt(); } return a; } public int[][] nextIntArray2(int h, int w) { int[][] a = new int[h][w]; for (int hi = 0; hi < h; hi++) { for (int wi = 0; wi < w; wi++) { a[hi][wi] = nextInt(); } } return a; } public int[] nextIntArray21(int n, int scalar) { int[] a = new int[n]; for (int i = 0; i < n; i++) a[i] = nextInt() * scalar + nextInt(); return a; } public Integer[] nextIntegerArray(int n) { Integer[] a = new Integer[n]; for (int i = 0; i < n; i++) { a[i] = nextInt(); } return a; } public char[] nextCharArray(int n) { char[] a = next().toCharArray(); return a; } public char[][] nextCharArray2(int h, int w) { char[][] a = new char[h][w]; for (int i = 0; i < h; i++) { a[i] = next().toCharArray(); } return a; } //スペースが入っている場合 public char[][] nextCharArray2s(int h, int w) { char[][] a = new char[h][w]; for (int i = 0; i < h; i++) { a[i] = nextLine().replace(" ", "").toCharArray(); } return a; } public char[][] nextWrapCharArray2(int h, int w, char c) { char[][] a = new char[h + 2][w + 2]; //char c = '*'; int i; for (i = 0; i < w + 2; i++) a[0][i] = c; for (i = 1; i < h + 1; i++) { a[i] = (c + next() + c).toCharArray(); } for (i = 0; i < w + 2; i++) a[h + 1][i] = c; return a; } //スペースが入ってる時用 public char[][] nextWrapCharArray2s(int h, int w, char c) { char[][] a = new char[h + 2][w + 2]; //char c = '*'; int i; for (i = 0; i < w + 2; i++) a[0][i] = c; for (i = 1; i < h + 1; i++) { a[i] = (c + nextLine().replace(" ", "") + c).toCharArray(); } for (i = 0; i < w + 2; i++) a[h + 1][i] = c; return a; } public long[] nextLongArray(int n) { long[] a = new long[n]; for (int i = 0; i < n; i++) { a[i] = nextLong(); } return a; } public long[][] nextLongArray2(int h, int w) { long[][] a = new long[h][w]; for (int hi = 0; hi < h; hi++) { for (int wi = 0; wi < h; wi++) { a[h][w] = nextLong(); } } return a; } } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
package main import ( "fmt" ) // var sc = bufio.NewScanner(os.Stdin) // func nextInt() int { // sc.Scan() // i, e := strconv.Atoi(sc.Text()) // if e != nil { // panic(e) // } // return i // } // func nextLine() string { // sc.Scan() // return sc.Text() // } func main() { // sc.Split(bufio.ScanWords) var n int fmt.Scan(&n) m := map[string]int{} // sc := bufio.NewScanner(os.Stdin) for i := 0; i < n; i++ { var s string fmt.Scan(&s) m[s[:1]]++ } march := []string{"M", "A", "R", "C", "H"} ans := 0 for i := 0; i < n; i++ { for j := i + 1; j < n; j++ { for k := j + 1; k < n; k++ { ans += m[march[i]] * m[march[j]] * m[march[k]] } } } fmt.Println(ans) }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
import sys import os import math import bisect import collections import itertools import heapq ii = lambda: int(sys.stdin.buffer.readline().rstrip()) il = lambda: list(map(int, sys.stdin.buffer.readline().split())) fl = lambda: list(map(float, sys.stdin.buffer.readline().split())) iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)] iss = lambda: sys.stdin.buffer.readline().decode().rstrip() sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split())) isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)] lcm = lambda x, y: x * y / math.gcd(x, y) MOD = 10 ** 9 + 7 MAX = float('inf') def main(): if os.getenv("LOCAL"): sys.stdin = open("input.txt", "r") N = ii() name = isn(N) ret = 0 s = ['M', 'A', 'R', 'C', 'H'] for i in itertools.combinations(name, 3): if i[0][0] != i[1][0] != i[2][0] and i[0][0] in s and i[1][0] in s and i[2][0] in s: ret += 1 print(ret) if __name__ == '__main__': main()
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main(void) { long long n; cin >> n; vector<string> s(n); vector<long long> vmp(5, 0); for (long long i = 0; i < (long long)n; ++i) cin >> s[i]; for (long long i = 0; i < (long long)n; ++i) { if (s[i][0] == 'M') vmp[0]++; if (s[i][0] == 'A') vmp[1]++; if (s[i][0] == 'R') vmp[2]++; if (s[i][0] == 'C') vmp[3]++; if (s[i][0] == 'H') vmp[4]++; } long long ans = 0; for (long long i = 0; i < (long long)3; ++i) { for (long long j = i + 1; j < (long long)4; ++j) { for (long long k = j + 1; k < (long long)5; ++k) { ans += vmp[i] * vmp[j] * vmp[k]; cout << i << " " << j << " " << k << 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> int ones_num(int bit) { int ans = 0; for (int i = 0; i <= 4; i++) { if (((bit >> i) & 0x01) == 1) ans += 1; } return ans; } void select(int bit, long long* ans, int cnt[5], int sou) { int tmp = 1; int mask; if (sou >= 5) { return; } else if (ones_num(bit) == 3) { for (int i = 0; i <= 4; i++) { if (((bit >> i) & 0x01) == 1) tmp *= cnt[i]; } *ans += tmp; return; } mask = (1 << (sou + 1)) & 0x1F; select(bit &= ~mask, ans, cnt, sou + 1); select(bit |= mask, ans, cnt, sou + 1); } int main(void) { char S[10]; int N; int cnt[5] = {0, 0, 0, 0, 0}; long long ans = 0; scanf("%d", &N); fflush(stdin); for (int i = 0; i <= N - 1; i++) { scanf("%s", S); if (S[0] == 'M') cnt[0]++; else if (S[0] == 'A') cnt[1]++; else if (S[0] == 'R') cnt[2]++; else if (S[0] == 'C') cnt[3]++; else if (S[0] == 'H') cnt[4]++; } select(0, &ans, cnt, 0); select(1, &ans, cnt, 0); printf("%d\n", ans); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main(void) { int n; cin >> n; string a[100000]; int b[5] = {0}; int sum = 0; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n; i++) { if (a[i][0] == 'M') b[0]++; if (a[i][0] == 'A') b[1]++; if (a[i][0] == 'R') b[2]++; if (a[i][0] == 'C') b[3]++; if (a[i][0] == 'H') b[4]++; } for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { sum += b[i] * b[j] * b[k]; } } } cout << sum << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; inline long long read() { long long f = 1, sum = 0; char c = getchar(); while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar(); } while (c >= '0' && c <= '9') { sum = sum * 10 + c - '0'; c = getchar(); } return sum * f; } const int MAXN = 15; char s[MAXN]; map<char, int> mmp; int a[MAXN]; int main() { int n; mmp['M'] = 1; mmp['A'] = 2; mmp['R'] = 3; mmp['C'] = 4; mmp['H'] = 5; scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%s", s + 1); a[mmp[s[1]]]++; } long long ans = 0; for (int i = 1; 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; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { long n, a[5]={0,0,0,0,0}, r = 0, adb; scanf("%ld", &n); for (int i = 0; i < n; i++) { char s[5]; scanf("%s", s); if (s[0] == 'M'){ a[0]++; } else if (s[0] == 'A') { a[1]++; } else if (s[0] == 'R') { a[2]++; } else if (s[0] == 'C') { a[3]++; } else if (s[0] == 'H') { a[4]++; } } for ( int z = 0; z < 3; z++) { for ( int c = z+1; c < 4; c++){ for ( int v = c+1; v < 5; v++){ a[z]*a[c]*z[v] = adb;}}} 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> CC(5, 0); for (int i = 0; i < (N); ++i) { string S; cin >> S; switch (S[0]) { case 'M': CC[0]++; break; case 'A': CC[1]++; break; case 'R': CC[2]++; break; case 'C': CC[3]++; break; case 'H': CC[4]++; break; default: break; } } long long ans = 0; for (int i = 0; i < (5); ++i) { for (int j = i + 1; j < (5); ++j) { for (int k = j + 1; k < (5); ++k) { ans += CC[i] * CC[j] * CC[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
#![allow(unused_mut)] #![allow(non_snake_case)] #![allow(unused_imports)] use std::collections::HashSet; use std::collections::HashMap; use std::collections::BTreeSet; use std::cmp::{max, min}; #[allow(unused_macros)] macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); input_inner!{iter, $($r)*} }; ($($r:tt)*) => { let s = { use std::io::Read; let mut s = String::new(); std::io::stdin().read_to_string(&mut s).unwrap(); s }; let mut iter = s.split_whitespace(); input_inner!{iter, $($r)*} }; } #[allow(unused_macros)] macro_rules! input_inner { ($iter:expr) => {}; ($iter:expr, ) => {}; ($iter:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($iter, $t); input_inner!{$iter $($r)*} }; } #[allow(unused_macros)] macro_rules! read_value { ($iter:expr, ( $($t:tt),* )) => { ( $(read_value!($iter, $t)),* ) }; ($iter:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>() }; ($iter:expr, chars) => { read_value!($iter, String).chars().collect::<Vec<char>>() }; ($iter:expr, usize1) => { read_value!($iter, usize) - 1 }; ($iter:expr, $t:ty) => { $iter.next().unwrap().parse::<$t>().expect("Parse error") }; } fn main() { input! { n: usize, s:[chars; n], } let mut d = vec![0; 5]; for i in 0..n { if s[i][0] == 'M' {d[0]+=1;} if s[i][0] == 'A' {d[1]+=1;} if s[i][0] == 'R' {d[2]+=1;} if s[i][0] == 'C' {d[3]+=1;} if s[i][0] == 'H' {d[4]+=1;} } let mut res = 0; for first in 0..3 { for second in first+1..4 { for third in second+1..5 { res += d[first] * d[second] * d[third]; } } } println!("{}", res); }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include <bits/stdc++.h> int main() { int i, j, n; scanf("%d", &n); char s[n], S[10]; int m = 0, a = 0, r = 0, c = 0, h = 0; scanf("%c", &s[0]); for (i = 0; i < n; i++) { for (j = 0; j < 10; j++) { scanf("%c", &s[j]); if (s[j] == '\n') break; } if (s[0] == 'M') m++; if (s[0] == 'A') a++; if (s[0] == 'R') r++; if (s[0] == 'C') c++; if (s[0] == 'H') h++; } long long x = 0; 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; printf("%lld", x); 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 C[100001][100001]; void Comb(long long a){ for(int i=0;i<=a;i++){ for(int j=0;j<=i;j++){ if(j==0 || j==i){ C[i][j]=1; }else{ C[i][j]=C[i-1][j-1]+C[i-1][j]; } } } } int main(){ long long n; cin>>n; long long cm=0,ca=0,cr=0,cc=0,ch=0; bool fm=false,fa=false,fr=false,fc=false,fh=false; for(long long i=0;i<n;i++){ string x; cin>>x; char c=x.at(0); if(c=='M'){ cm++; fm=true; }else if(c=='A'){ ca++; fa=true; }else if(c=='R'){ cr++; fr=true; }else if(c=='C'){ cc++; fc=true; }else if(c=='H'){ ch++; fh=true; } } long long z=0,base=cm+ca+cr+cc+ch,minus=0; if(base<3){ cout<<0<<endl; return 0; } Comb(base+1); if(cm>1){ if(fa) z++; if(fr) z++; if(fc) z++; if(fh) z++; minus+=z*C[cm][2]; }if(ca>1){ z=0; if(fm) z++; if(fr) z++; if(fc) z++; if(fh) z++; minus+=z*C[ca][2]; }if(cr>1){ z=0; if(fm) z++; if(fa) z++; if(fc) z++; if(fh) z++; minus+=z*C[cr][2]; }if(cc>1){ z=0; if(fm) z++; if(fr) z++; if(fa) z++; if(fh) z++; minus+=z*C[cc][2]; }if(ch>1){ z=0; if(fm) z++; if(fr) z++; if(fc) z++; if(fa) z++; minus+=z*C[ch][2]; } cout<<C[base][3]-minus<<endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
N = int(input()) L = [input() for i in range(N)] M,A,R,C,H = 0,0,0,0,0 Set = [] for i in range(N): if L[i][0] == 'M': M += 1 Set.append('M') if L[i][0] == 'A': A += 1 Set.append('A') if L[i][0] == 'R': R += 1 Set.append('R') if L[i][0] == 'C': C += 1 Set.append('C') if L[i][0] == 'H': H += 1 Set.append('H') Set = set(Set) List = [] if 'M' in Set: List.append(M) if 'A' in Set: List.append(A) if 'R' in Set: List.append(R) if 'C' in Set: List.append(C) if 'H' in Set: List.append(H) if len(Set) == 5: print(List[0]*List[1]*List[2] + List[0]*List[1]*List[3] + List[0]*List[1]*List[4] +List[0]*List[2]*List[3] + List[0]*List[3] + List[4] + List[0]*List[2]*List[4] + List[1]*List[2]*List[3] + List[1]*List[2]*List[4] + List[2]*List[3]*List[4] + List[1]*List[3]*List[4]) elif len(Set) == 4: print(List[0] * List[1] * List[2] + List[1] * List[2] * List[3] + List[0] * List[2] * List[3] + List[0] * List[1] * List[3]) elif len(Set) == 3: print (List[0] * List[1] * List[2]) 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
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> march(5); long long m = 0, a = 0, r = 0, c = 0, h = 0; string s; for (int i = 0; i < (n); ++i) { cin >> s; if (s[0] == 'M') m++; if (s[0] == 'A') a++; if (s[0] == 'R') r++; if (s[0] == 'C') c++; if (s[0] == 'H') h++; } march[0] = m, march[1] = a, march[2] = r, march[3] = c, march[4] = h; long long ans = 0; for (int i = 0; i < (3); ++i) { for (int j = int(i + 1); j < int(4); ++j) { for (int k = int(j + 1); k < int(5); ++k) { ans += march[i] * march[j] * march[k]; } } } cout << ans; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); String[] S = new String[N]; int M = 0; int A = 0; int R = 0; int C = 0; int H = 0; for(int i = 0; i < N; i++) { S[i] = sc.next(); if(S[i].charAt(0) == 'M') { M++; } else if(S[i].charAt(0) == 'A') { A++; } else if(S[i].charAt(0) == 'R') { R++; } else if(S[i].charAt(0) == 'C') { C++; } else if(S[i].charAt(0) == '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 RCH = R * C * H; long total = MAR + MAC + MAH + MRC + MRH + MCH + ARC + ARH + RCH; System.out.println(total); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> int main(void) { long a = 0, m = 0, r = 0, c = 0, h = 0, i, num; long answer; scanf("%d", &num); char array[10]; for (i = 1; i <= num; i++) { scanf("%s", array); if (array[0] == 'M') m++; if (array[0] == 'A') a++; if (array[0] == 'R') r++; if (array[0] == 'C') c++; if (array[0] == 'H') h++; } answer = 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("%d", 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
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using pint = pair<int, int>; using pll = pair<ll, ll>; using pld = pair<ld, ld>; const int INF=1e9+7; const ll LINF=1LL<<60; const ll MOD=1e9+7; const ld PI=acos(-1); const ld EPS = 1e-9; //微調整用(EPSより小さいと0と判定など) //MODINT //変数名.nでint型の数値を受け取る struct mint { int n; mint(int n_ = 0) : n(n_) {} }; mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; } mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; } mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; } mint &operator+=(mint &a, mint b) { return a = a + b; } mint &operator-=(mint &a, mint b) { return a = a - b; } mint &operator*=(mint &a, mint b) { return a = a * b; } int ii() { int x; scanf("%d", &x); return x; } long long il() { long long x; scanf("%lld", &x); return x; } string is() { string x; cin >> x; return x; } char ic() { char x; cin >> x; return x; } void oi(int x) { printf("%d ", x); } void ol(long long x) { printf("%lld ", x); } void od(double x) { printf("%.15f ", x); } void os(const string &s) { printf("%s ", s.c_str()); } void oc(const char &c) { printf("%c ", c); } auto op = [&](auto p) -> void{ cout << p; }; auto ov = [&](auto vec) -> void{ cout << vec; }; void br() { putchar('\n'); } #define gcd __gcd //llは受け取ってくれない int lcm(int a, int b){return a / gcd(a, b) * b;} #define ALL(a) a.begin(),a.end() //sort(ALL(vec)); #define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i ) #define rep(i,n) REP(i,0,n) #define MP(a,b) make_pair(a,b) #define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end())))) #define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin()) #define PB push_back #define SZ(x) ((int)(x).size) //size()がunsignedなのでエラー避けに //4近傍(上下左右) vector<int> dx_4 = {1, 0, -1, 0}; vector<int> dy_4 = {0, 1, 0, -1}; // coutによるpairの出力(空白区切り) template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << " " << p.second << ")";} // 空白区切りだけ --> return s << "(" << p.first << " " << p.second << ")"; // 見やすくしたいとき --> return s << "(" << p.first << " " << p.second << ")"; // coutによるvectorの出力(空白区切り) template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) { int len = v.size(); for (int i = 0; i < len; ++i) { s << v[i]; if (i < len - 1) s << " "; //"\t"に変えるとTabで見やすく区切る } return s; } // coutによる多次元vectorの出力(空白区切り) template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) { int len = vv.size(); for (int i = 0; i < len; ++i) { s << vv[i] << endl; } return s; } //最大値、最小値を更新する。aよりbのが大きい(小さい)か等しければaを更新してtrueを返す。そうでなければ何もせずfalseを返す chmax(nowmax,x); template<typename T> bool chmax(T& a, T b){return (a = max(a, b)) == b;} template<typename T> bool chmin(T& a, T b){return (a = min(a, b)) == b;} // ------------ template - // // - global -------------- // ll ans = 0; vector<int> nums(5, 0); // -------------- global - // // - library ------------- // void recursive_comb(int *indexes, int s, int rest, function<void(int *)> f) { if (rest == 0) { f(indexes); } else { if (s < 0) return; recursive_comb(indexes, s - 1, rest, f); indexes[rest - 1] = s; recursive_comb(indexes, s - 1, rest - 1, f); } } // nCkの組み合わせに対して処理を実行する void foreach_comb(int n, int k, function<void(int *)> f) { int indexes[k]; recursive_comb(indexes, n - 1, k, f); } // ------------- library - // int main() { ll N = il(); string s; int m = 0; int a = 1; int r = 2; int c = 3; int h = 4; rep(i, N){ s = is(); if (s[0] == 'M'){ nums[m] += 1; } else if (s[0] == 'A'){ nums[a] += 1; } else if (s[0] == 'R'){ nums[r] += 1; } else if (s[0] == 'C'){ nums[c] += 1; } else if (s[0] == 'H'){ nums[h] += 1; } } //下の関数はmain()の外だから、変数のスコープに注意 foreach_comb(5, 3, [](int *indexes) { ans += nums[indexes[0]] * nums[indexes[1]] * nums[indexes[2]]; }); ol(ans); // -- main() end -- // }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; vector<string> s(n); vector<int> p(5); for (int i = 0; i < (int)(n); i++) { cin >> s.at(i); if (s.at(i).at(0) == 'M') { p.at(0)++; } if (s.at(i).at(0) == 'A') { p.at(1)++; } if (s.at(i).at(0) == 'R') { p.at(2)++; } if (s.at(i).at(0) == 'C') { p.at(3)++; } if (s.at(i).at(0) == 'H') { p.at(4)++; } } long long ans = 0; int i, j, k; for (i = 0; i < 3; i++) { for (j = i + 1; j < 4; j++) { for (k = j + 1; k < 5; k++) { ans += p.at(i) * p.at(j) * p.at(k); } } } cout << ans; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { string name; int chance = 0; char front[100000]; int n, x; int urut = 1; int y, z; cin >> n; for (x = 1; x <= n; x++) { cin >> name; if (name[0] == 'C' || name[0] == 'M' || name[0] == 'A' || name[0] == 'R' || name[0] == 'H') { front[urut] = name[0]; urut++; } } for (x = 1; x <= urut - 3; x++) { for (y = x + 1; y <= urut - 2; y++) { for (z = y + 1; z <= urut - 1; z++) { if (front[x] != front[y] && front[y] != front[z] && front[x] != front[z]) { chance++; } } } } cout << chance << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main(void) { int N; cin >> N; string S[N]; for (int i = 0; i < N; i++) cin >> S[i]; map<char, int> m; for (int i = 0; i < N; i++) if (S[i][0] == 'M' || S[i][0] == 'A' || S[i][0] == 'R' || S[i][0] == 'C' || S[i][0] == 'H') m[S[i][0]]++; long long ans = 0; char str[] = {'M', 'A', 'R', 'C', 'H'}; for (int i = 0; i < 5; i++) for (int j = i + 1; j < 5; j++) for (int k = j + 1; k < 5; k++) ans += m[str[i]] * m[str[j]] * m[str[k]]; cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<string> v(N); int a = 0; int b = 0; int c = 0; int d = 0; int e = 0; for (int i = 0; i < N; i++) { cin >> v[i]; if (v[i][0] == 'M') a++; if (v[i][0] == 'A') b++; if (v[i][0] == 'R') c++; if (v[i][0] == 'C') d++; if (v[i][0] == 'H') e++; } cout << a * b * (c + d + e) + a * c * (d + e) + a * d * e + b * c * (d + e) + b * d * e + c * d * e << 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 void chmax(T& a, T b) { if (a < b) { a = b; } } template <class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } } template <class T> inline T gcd(T x, T y) { if (y == 0) { return x; } else if (x == 0) { return y; } return gcd(y, x % y); } template <class T> inline T lcm(T x, T y) { return (x * y) / gcd(x, y); } template <class T> inline void print_vector(vector<T> vec) { for (int i = 0; i < vec.size(); i++) { cout << vec[i] << " "; } cout << endl; } const long long MOD = 1e9 + 7; const long long LLINF = 1LL << 60; const int INF = 1 << 30; enum { M, A, R, C, H }; map<char, int> dict{make_pair('M', M), make_pair('A', A), make_pair('R', R), make_pair('C', C), make_pair('H', H)}; int main(void) { int N; cin >> N; vector<int> S(5); for (int i = 0; i < N; i++) { string s; cin >> s; if (s[0] == 'M' or s[0] == 'A' or s[0] == 'R' or s[0] == 'C' or s[0] == 'H') { S[dict[s[0]]]++; } } long long ans = 0; for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 4; j++) { for (int k = j + 1; k < 5; k++) { ans += S[i] * S[j] * S[k]; } } } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin>>n; vector<string> s(n); int aa=0,bb=0,cc=0,dd=0,ee=0; char x; for(int i=0;i<n;i++){ x=s.at(i)[0]; if(x=='M'){ aa++; } if(x=='R'){ bb++; } if(x=='C'){ cc++; } if(x=='A'){ dd++; } if(x=='H'){ ee++; } } long long ans=0; ans+=aa*bb*cc; ans+=aa*bb*dd; ans+=aa*bb*ee; ans+=aa*cc*dd; ans+=aa*cc*ee; ans+=aa*dd*ee; ans+=bb*cc*dd; ans+=bb*cc*ee; ans+=bb*dd*ee; ans+=cc*dd*ee; cout<<and<<endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; public static class Program { public static void Main(params string[] args) { var ary = "MARCH".ToArray(); var hash = new HashSet<Char>(ary); var n = int.Parse(Console.ReadLine()); var d = Enumerable .Range(0, n) .Select(x => Console.ReadLine()) .Where(x => hash.Contains(x[0])) .GroupBy(x => x[0]) .ToDictionary(x => x.Key, x => x.Count()); var r = 0; for (int i = 0; i < ary.Length; i++) { for (int j = i + 1; j < ary.Length; j++) { for (int k = j + 1; k < ary.Length; k++) { int v1, v2, v3; if (d.TryGetValue(ary[i], out v1) && d.TryGetValue(ary[j], out v2) && d.TryGetValue(ary[k], out v3)) { r += v1 * v2 * v3; } } } } Console.WriteLine(r); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <iostream> #include <map> #include <string> using namespace std; int main(){ map<int,int> name; map<char,int> name_to_int; name_to_int["M"]=0; name_to_int["A"]=1; name_to_int["R"]=2; name_to_int["C"]=3; name_to_int["H"]=4; int n; cin>>n; for(int i=0;i<n;i++){ string s; cin>>s; name[name_to_int[s[0]]]+=1; } int ans=0; for(int i=0;i<n;i++){ for(int j=i+1;j<n;j++){ for(int k=j+1;k<n;k++){ ans+=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
UNKNOWN
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Text; namespace ABC089C { class Program { static void Solve(Input input) { var keys = "MARCH"; var n = input.NextInt(); var map = keys.ToDictionary(x => x, _ => 0); for (int i = 0; i < n; i++) { var s = input.Next(); if (map.ContainsKey(s[0])) { map[s[0]]++; } } var p = (long)map.Count(x => x.Value > 0); // pC3 * map[i].Value(>0) long pat = 0; if (p >= 3) { for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { pat += map[keys[i]] * map[keys[j]] * map[keys[k]]; } } } } Console.WriteLine(pat); } #region Competitive Template static readonly int MOD = (int)1e9 + 7; public static void Main(string[] args) { // 出力が少ないときはこれをセットする方が時間かかるけれど // その場合は出力がボトルネックになっていないので、まあ良しとする var needsFlushOutput = true; if (needsFlushOutput) { // 細かく出力しないようにする var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); } // 通常は引数無しで、ファイルから読み出したい場合はpath指定する var input = new Input(); // 仮想的に標準入力をセットする //input.SetText(""); Solve(input); Console.Out.Flush(); } class Input { // 変な改行コードがたまに混じっているので、一応セパレート指定する // スペース単独指定の方がもちろん早い static readonly char[] separator = { ' ', '\r', '\n' }; Queue<string> q { get; set; } StreamReader sr; /// <summary> /// 特定のファイルから読み出したい場合はpath指定する /// </summary> /// <param name="path"></param> public Input(string path = "") { q = new Queue<string>(); if (string.IsNullOrEmpty(path)) { sr = new StreamReader(Console.OpenStandardInput()); } else { sr = new StreamReader(path); } } /// <summary> /// 入力予約 /// </summary> /// <param name="items"></param> public void SetText(IEnumerable<string> items) { foreach (var item in items) { SetText(item); } } /// <summary> /// 入力予約 /// </summary> /// <param name="s"></param> /// <returns></returns> public bool SetText(string s) { if (s == null) return false; foreach (var elem in s.Trim().Split(separator, StringSplitOptions.RemoveEmptyEntries)) { q.Enqueue(elem); } return true; } /// <summary> /// 内部queueに入力からの値をsplitして格納する /// </summary> /// <returns></returns> bool read() { var s = sr.ReadLine(); if (s == null) return false; foreach (var elem in s.Trim().Split(separator, StringSplitOptions.RemoveEmptyEntries)) { q.Enqueue(elem); } if (!q.Any()) return read(); return true; } /// <summary> /// 次のstringを一つ読み込む /// </summary> /// <returns></returns> public string Next() { if (!q.Any()) { if (!read()) { return ""; } } return q.Dequeue(); } /// <summary> /// 指定個数queueにたまるまでenqueueし続ける /// </summary> /// <param name="n"></param> /// <returns></returns> bool accumulate(int n) { while (q.Count() < n) { if (!read()) return false; } return true; } public int NextInt() => int.Parse(Next()); public long NextLong() => long.Parse(Next()); public double NextDouble() => double.Parse(Next()); /// <summary> /// n個の要素をparseして、それぞれにoffsetをaddした配列を返す /// </summary> /// <typeparam name="T"></typeparam> /// <param name="n"></param> /// <param name="offset"></param> /// <param name="parse"></param> /// <param name="add"></param> /// <returns></returns> T[] NextT<T>(int n, T offset, Func<string, T> parse, Func<T, T, T> add) { if (!accumulate(n)) return null; var a = new T[n]; for (int i = 0; i < n; i++) a[i] = add(parse(q.Dequeue()), offset); return a; } public string[] Next(int n) => NextT(n, "", x => x, (x, y) => x); public int[] NextInt(int n, int offset = 0) => NextT(n, offset, int.Parse, (x, y) => x + y); public long[] NextLong(int n, long offset = 0) => NextT(n, offset, long.Parse, (x, y) => x + y); public double[] NextDouble(int n, double offset = 0.0) => NextT(n, offset, double.Parse, (x, y) => x + y); } static class Utils { public static void Print<T>(IEnumerable<T> ie, string sep = " ") => Console.WriteLine(string.Join(sep, ie)); public static void Print<T>(params T[] objs) => Print(objs); public static T Max<T>(params T[] objs) => objs.Max(); public static T Min<T>(params T[] objs) => objs.Min(); public static void Swap<T>(ref T x, ref T y) where T : struct { var t = x; x = y; y = t; } public static void Swap<T>(IList<T> list, int i, int j) where T : struct { var t = list[i]; list[i] = list[j]; list[j] = t; } /// <summary> /// vでfillされたT[d1][d2]配列を作成する /// </summary> /// <typeparam name="T"></typeparam> /// <param name="d1"></param> /// <param name="d2"></param> /// <param name="v"></param> /// <returns></returns> public static T[][] Create2DArray<T>(int d1, int d2, T v = default(T)) { return Enumerable.Repeat(0, d1).Select(_ => Enumerable.Repeat(v, d2).ToArray()).ToArray(); } /// <summary> /// vでfillされたT[d1][d2][d3]配列を作成する /// </summary> /// <typeparam name="T"></typeparam> /// <param name="d1"></param> /// <param name="d2"></param> /// <param name="d3"></param> /// <param name="v"></param> /// <returns></returns> public static T[][][] Create3DArray<T>(int d1, int d2, int d3, T v = default(T)) { return Enumerable.Repeat(0, d1).Select(_ => Enumerable.Repeat(0, d2).Select(__ => Enumerable.Repeat(v, d3).ToArray()).ToArray()).ToArray(); } } #endregion } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\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_l = [0]*5 for _ in range(n): s = input() s0 = s[0] if s0 == 'M': march_l[0] += 1 elif s0 == 'A': march_l[1] += 1 elif s0 == 'R': march_l[2] += 1 elif s0 == 'C': march_l[3] += 1 elif s0 == 'H': march_l[4] += 1 march_cnt = [i for i in march_l if i != 0] ans = 0 prod = 1 for i in march_cnt: prod *= i if len(march_cnt) > 3: for i in march_cnt: ans += prod//i elif len(march_cnt) == 3: ans = prod else: ans = 0 print(ans)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
using System; using System.Linq; using System.Collections.Generic; using System.Text; using static System.Console; using static System.Math; class Program { static void Main(string[] args) { int N = int.Parse(ReadLine()); int[] names = new int[5]; char[] MARCH = new char[5]{ 'M', 'A', 'R', 'C', 'H' }; for(int i = 0; i < N; i++) { string s = ReadLine(); for(int j = 0; j < 5; j++) { if (s[0] == MARCH[j]) names[j]++; } } 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 += names[i] * names[j] * names[k]; } } } WriteLine(ans); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<int, int>; int main() { int n; cin >> n; vector<int> dp(5); ll ans = 0; for (int i = 0; i < (n); i++) { string s; cin >> s; if (s[0] == 'M') dp[0]++; else if (s[0] == 'A') dp[1]++; else if (s[0] == 'R') dp[2]++; else if (s[0] == 'C') dp[3]++; else if (s[0] == 'H') dp[4]++; } ans += (dp[0] * dp[1] * dp[2] + dp[0] * dp[1] * dp[3] + dp[0] * dp[1] * dp[4]); ans += (dp[0] * dp[2] * dp[3] + dp[0] * dp[2] * dp[4]); ans += dp[0] * dp[3] * dp[4]; ans += (dp[1] * dp[2] * dp[3] + dp[1] * dp[2] * dp[4] + dp[1] * dp[3] * dp[4]); ans += dp[2] * dp[3] * dp[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
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 vec: Vec<String> = (0..n).map(|_| read()).collect(); let mut count = 0; for i in 0..i64::pow(2, n as u32) { let mut each_vec: Vec<String> = Vec::new(); for j in 0..n { if (1 & i >> j) == 1 { each_vec.push(vec[j as usize].clone()); } } let mut march_vec: Vec<char> = vec!['M', 'A', 'R', 'C', 'H']; if each_vec.len() == 3 { for s in each_vec.iter() { let char_vec: Vec<char> = s.chars().collect(); let first_letter = char_vec[0].clone(); if march_vec.contains(&first_letter) { let index = march_vec.iter().position(|&r| r==first_letter).unwrap(); march_vec.remove(index); if march_vec.len() == 2 { count+=1; break; } } else { break; } } } } 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
clude<iostream> #include<vector> typedef long long ll; using namespace std; int main() {ll N; cin >> N; vector<string> A(N); for(ll i = 0; i < N; i++) {cin >> A[i];} ll m ,a, r, c, h; for(ll i = 0; i < N; i++) {if(A[i][0] = 'M'){m++;} else if(A[i][0] = 'A'){a++;} else if(A[i][0] = 'R'){r++;} else if(A[i][0] = 'C'){c++;} else if(A[i][0] = 'H'){h++;} } ll X = m*a*r + m*a*c + m*a*h + m*r*c + m*r*h + m*c*h + a*r*c + a*r*h + a*c*h + r*c*h; cout << X << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
N = int(input()) S = [] for i in range(N): s = input() if s[0] in [ 'M','A','R','C','H' ]: S.append(s) S = list(set(S)) N = len(S) selected = [""] * 2 cnt = 0 for i in range(N): selected[0] = S[i][0] for k in range(i+1, N): if selected[0] == S[k][0]: continue selected[1] = S[k][0] for t in range(k+1, N): if selected[1] == S[t][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()) m,a,r,c,h=0,0,0,0,0 for i in range(N): ch=input()[0] if ch=='M': m+=1 elif ch=='A': a+=1 elif ch=='R': r+=1 elif ch=='C': c+=1 elif ch=='H': h+=1 ans=m*a*(r+c+h)+m*r*(c+h)+a*r*(c+h)+r*c*h print(ans)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N, A[5] = {0}; char S[15]; scanf("%d", &N); for (int i = 0; i < N; i++) { scanf("%s", S); if (S[0] == 'M') { A[0]++; } else if (S[0] == 'A') { A[1]++; } else if (S[0] == 'R') { A[2]++; } else if (S[0] == 'C') { A[3]++; } else if (S[0] == 'H') { A[4]++; } } long ans = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { ans += A[i] * A[j] * A[k]; } } } printf("%ld", 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; template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } int main() { int64_t N; cin >> N; map<char, int64_t> d; for (int64_t i = 0; i < N; i++) { string s; cin >> s; if (d.count(s[0]) > 0) { d[s[0]] = d[s[0]] + 1; } else { d[s[0]] = 1; } } int64_t initial_count = 0; for (auto c : d) { if (c.first == 'M' || c.first == 'A' || c.first == 'R' || c.first == 'C' || c.first == 'H') { initial_count++; } } if (initial_count < 3) { cout << 0 << endl; } else { int64_t kizyun = (initial_count * (initial_count - 1) * (initial_count - 2)) / (3 * 2 * 1); int64_t hikukazu = (initial_count - 1) * (initial_count - 2) * (initial_count - 3) / (3 * 2 * 1); int64_t bun = 0; for (auto c : d) { if (c.first == 'M' || c.first == 'A' || c.first == 'R' || c.first == 'C' || c.first == 'H') { if (c.second > 1) { bun += (kizyun - hikukazu) * c.second; } } } cout << hikukazu + bun << endl; } return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int m = 0; int a = 0; int r = 0; int c = 0; int h = 0; unsigned long long res = 0; string str; for (int i = 0; i < n; i++) { cin >> str; switch (str[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 * r * h; res += a * c * h; res += r * c * h; cout << res << "\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> int main(void) { char s[100001][11]; int n, i, m, a, r, c, h; long long int z; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%s", &s[i]); if (s[i][0] == 'M') m = m + 1; if (s[i][0] == 'A') a = a + 1; if (s[i][0] == 'R') r = r + 1; if (s[i][0] == 'C') c = c + 1; if (s[i][0] == 'H') h = h + 1; } z = m * a * r + m * a * c + m * a * h + m * r * c + m * r * h + m * c * h + a * r * c + a * r * h + a * c * h + r * c * h; printf("%lld\n", z); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.*; public class Main { public static void main(String args[]) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); Map<String, Long> map = new HashMap<>(); map.put("M",0); map.put("A",0); map.put("R",0); map.put("C",0); map.put("H",0); String[] march ={"M", "A", "R", "C", "H"}; for(int i = 0; i < n; i++){ String str = scanner.next(); str = str.substring(0,1); int v; if(str.equals("M") || str.equals("A") || str.equals("R") || str.equals("C") || str.equals("H")) { if (map.containsKey(str)) { v = map.get(str) + 1; } else { v = 1; } map.put(str,v); } } long ans = map.get(march[0]) * map.get(march[1]) * map.get(march[2]); ans += map.get(march[0]) * map.get(march[1]) * map.get(march[3]); ans += map.get(march[0]) * map.get(march[1]) * map.get(march[4]); ans += map.get(march[0]) * map.get(march[2]) * map.get(march[3]); ans += map.get(march[0]) * map.get(march[2]) * map.get(march[4]); ans += map.get(march[0]) * map.get(march[3]) * map.get(march[4]); ans += map.get(march[1]) * map.get(march[2]) * map.get(march[3]); ans += map.get(march[1]) * map.get(march[2]) * map.get(march[4]); ans += map.get(march[1]) * map.get(march[3]) * map.get(march[4]); ans += map.get(march[2]) * map.get(march[3]) * map.get(march[4]); 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; 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; } const int64_t INF = 1LL << 60; int main() { int N; cin >> N; vector<string> s(N); int c[5] = {0}; for (int i = 0; i < N; i++) { cin >> s[i]; if (s[i][0] == 'M') { c[0]++; } if (s[i][0] == 'A') { c[1]++; } if (s[i][0] == 'R') { c[2]++; } if (s[i][0] == 'C') { c[3]++; } if (s[i][0] == 'H') { c[4]++; } } int ans = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { ans += c[i] * c[j] * c[k]; } } } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
use std::str::FromStr; use std::io::*; fn main() { let i = stdin(); run(&mut i.lock(), &mut stdout()); } fn run(i: &mut BufRead, o: &mut Write) { let n: usize = read(i); let mut ss = Vec::new(); for _ in 0..n { let s = read_line(i); if b"MARCH".contains(&h(&s)) { ss.push(s); } } fn h(s: &String) -> u8 { s.as_bytes()[0] } fn c1(ss: &[String], h0: u8) -> usize { let mut c = 0; for i in 0..ss.len() { let h1 = h(&ss[i]); if h1 == h0 { continue; } c += c2(&ss[(i + 1)..], h0, h1) } c } fn c2(ss: &[String], h0: u8, h1: u8) -> usize { ss.iter() .filter(|s| { let h2 = h(&s); h0 != h2 && h1 != h2 }) .count() } let mut c = 0; for i in 0..ss.len() { c += c1(&ss[(i + 1)..], h(&ss[i])); } writeln!(o, "{}", c).unwrap(); } fn read_line(i: &mut BufRead) -> String { let mut line = String::new(); i.read_line(&mut line).unwrap(); line.trim().to_string() } fn read<T: FromStr>(i: &mut BufRead) -> T { read_line(i).parse().ok().unwrap() }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.*; public class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int N = Integer.parseInt(sc.next()); String S[] = new String[N]; int num[] = new int[5]; Arrays.fill(num, 0); for(int i = 0; i < N; i++) { S[i] = sc.next(); if(S[i].substring(0, 1).equals("M")) { num[0]++; } if(S[i].substring(0, 1).equals("A")) { num[1]++; } if(S[i].substring(0, 1).equals("R")) { num[2]++; } if(S[i].substring(0, 1).equals("C")) { num[3]++; } if(S[i].substring(0, 1).equals("H")) { num[4]++; } } int ans = 0; int P[] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2}; int Q[] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3}; int R[] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4}; for(int i = 0; i < 10; i++) { ans += num[P[i]] * num[Q[i]] * num[R[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
import itertools def main(): N = int(input().strip()) S = [input().strip() for _ in range(N)] MARCH_S = [x[0] for x in S if x[0] in ['M','A','R','C','H']] if not MARCH_S: return 0 pat = list(itertools.combinations(MARCH_S, 3)); pat_len = len(pat) for x in ['M','A','R','C','H']: pat_len -= len([p for p in pat if p.count(x) > 1]) return pat_len 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; int main() { int N; cin >> N; long long A[5]; for (int i = 0; i < N; i++) { string S; cin >> S; if (S.at(i) == 'M') A[0]++; if (S.at(i) == 'A') A[1]++; if (S.at(i) == 'R') A[2]++; if (S.at(i) == 'C') A[3]++; if (S.at(i) == 'H') A[4]++; } cout << A[0] * A[1] * A[2] + A[0] * A[1] * A[3] + A[0] * A[1] * A[4] + A[0] * A[2] * A[3] + A[0] * A[2] * A[4] + A[0] * A[3] * A[4] + A[1] * A[2] * A[3] + A[1] * A[2] * A[4] + A[1] * A[3] * A[4] + A[2] * A[3] * A[4] << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int n; string s; int k[30]; int w[] = {0, 2, 7, 12, 17}; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> s; k[s[0] - 'A']++; } int sol = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int l = j + 1; l < 5; l++) { sol += k[w[i]] * k[w[j]] * k[w[l]]; } } } cout << sol; 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.ArrayList; import java.util.List; import java.util.Scanner; public class Main { private static Scanner sc; public static void main(String[] args) { sc = new Scanner(System.in); new Main().solve(); } private void solve() { int N = sc.nextInt(); List<String> mList = new ArrayList<String>(); List<String> aList = new ArrayList<String>(); List<String> rList = new ArrayList<String>(); List<String> cList = new ArrayList<String>(); List<String> hList = new ArrayList<String>(); for (int i = 0; i < N; i++) { String name = sc.next(); if (name.startsWith("M")) { mList.add(name); } else if (name.startsWith("A")) { aList.add(name); } else if (name.startsWith("R")) { rList.add(name); } else if (name.startsWith("C")) { cList.add(name); } else if (name.startsWith("H")) { hList.add(name); } } long res = 0; for (int i = 0; i <= mList.size(); i++) { boolean mnz = false; if (i != 0) { mnz = true; } for (int j = 0; j <= aList.size(); j++) { boolean anz = false; if (j != 0) { anz = true; } for (int k = 0; k <= rList.size(); k++) { boolean rnz = false; if (k != 0) { rnz = true; } for (int k2 = 0; k2 <= cList.size(); k2++) { boolean cnz = false; if (k2 != 0) { cnz = true; } for (int k3 = 0; k3 <= hList.size(); k3++) { boolean hnz = false; if (k3 != 0) { hnz = true; } int cnt = 0; if (mnz) { cnt++; } if (anz) { cnt++; } if (rnz) { cnt++; } if (cnz) { cnt++; } if (hnz) { cnt++; } if (cnt == 3) { res++; } hnz = false; } cnz = false; } rnz = false; } anz = false; } mnz = false; } System.out.println(res); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n, i, b[10] = {0}, j, k; long long t; char a[1000]; cin >> n; while (n--) { cin >> a; if (a[0] == 'M') b[0]++; else if (a[0] == 'A') b[1]++; else if (a[0] == 'R') b[2]++; else if (a[0] == 'C') b[3]++; else if (a[0] == 'H') b[4]++; } for (int i = 0; i < 5; ++i) { for (int j = i + 1; j < 5; ++j) { for (int k = j + 1; k < 5; ++k) { t += b[i] * b[j] * b[k]; } } } cout << t << 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.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); Set<String> set = new HashSet<>(); for (int i = 0; i < n; i++){ set.add(sc.next()); } Map<String, Integer> map = new HashMap<>(); map.put("M",0); map.put("A",0); map.put("R",0); map.put("C",0); map.put("H",0); for (String s: set){ String _s = String.valueOf(s.charAt(0)); if (map.containsKey(_s)) { map.put(_s, map.get(_s) + 1); } } long sum = 0; sum += map.get("M")*map.get("A")*map.get("R"); sum += map.get("M")*map.get("A")*map.get("C"); sum += map.get("M")*map.get("A")*map.get("H"); sum += map.get("M")*map.get("R")*map.get("C"); sum += map.get("M")*map.get("R")*map.get("H"); sum += map.get("M")*map.get("C")*map.get("H"); sum += map.get("A")*map.get("R")*map.get("C"); sum += map.get("A")*map.get("R")*map.get("H"); sum += map.get("A")*map.get("C")*map.get("H"); sum += map.get("R")*map.get("C")*map.get("H"); 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; unsigned long long combination(unsigned long long t, unsigned long long r) { if (t == r || r == 0) return 1; else return combination(t, r - 1) * (t - r + 1) / r; } 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]; } cout << ans1 + ans2 << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; map<char, int> mp; int arr[5] = {0}; int main() { mp['M'] = 0; mp['R'] = 1; mp['A'] = 2; mp['C'] = 3; mp['H'] = 4; int n; cin >> n; string s; for (int i = 0; i < n; i++) { cin >> s; if (mp.count(s[0])) arr[mp[s[0]]]++; } int sum = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int z = j + 1; z < 5; z++) { sum += arr[i] * arr[j] * arr[z]; } } } cout << sum << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
using System; using System.Collections; using System.Collections.Generic; using System.Text; using System.IO; using System.Linq; using System.Diagnostics; using System.Globalization; using static System.Console; using static System.Math; namespace abc90_c { class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); long M=0; long A=0; long R=0; long C=0; long H=0; for(int i=0; i<n; i++) { var s = ReadLine().Substring(0,1); switch(s) { case ("M"): M++; break; case ("A"): A++; break; case ("R"): R++; break; case ("C"): C++; break; case ("H"): H++; break; default: break; } } long sum = M*A*R+M*A*C+M*A+H+M*R*C+M*R*H+M*C*H+A*R*C+A*R*H+A*C*H+R*C*H; WriteLine(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
UNKNOWN
import sequtils,strutils var n = readLine(stdin).parseInt s:seq[string] = @[] M:seq[string] = @[] A:seq[string] = @[] R:seq[string] = @[] C:seq[string] = @[] H:seq[string] = @[] for i in 1..n: s.add($readLine(stdin)) proc main():int = for i in s: case i[0] of 'M': M.add(i) of 'A': A.add(i) of 'R': R.add(i) of 'C': C.add(i) of 'H': H.add(i) else: discard for i in M: for j in A: for k in R: result += 1 for k in C: result += 1 for k in H: result += 1 for j in R: for k in C: result += 1 for k in H: result += 1 for j in C: for k in H: result += 1 for i in A: for j in R: for k in C: result += 1 for k in H: result += 1 for j in C: for k in H: result += 1 for i in R: for j in C: for k in H: result += 1 echo 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 int MAX = 510000; const int MOD = 1000000007; long long fac[MAX], finv[MAX], inv[MAX]; void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } long long COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } int main() { int N; cin >> N; map<char, int> mp; for (int i = 0; i < N; i++) { string S; cin >> S; if (S[0] == 'M') mp['M'] = mp['M'] + 1; if (S[0] == 'A') mp['A'] = mp['A'] + 1; if (S[0] == 'R') mp['R'] = mp['R'] + 1; if (S[0] == 'C') mp['C'] = mp['C'] + 1; if (S[0] == 'H') mp['H'] = mp['H'] + 1; } int count = 0; int ans = 0; for (auto p : mp) { auto key = p.first; auto n = p.second; count += n; } COMinit(); ans = COM(count, 3); for (auto p : mp) { auto key = p.first; auto n = p.second; if (n > 1) ans -= (count - n); } cout << max(ans, 0) << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N, cnt[5] = {0}, ans = 0; char str[16]; cin >> N; for (int i = 0; i < N; i++) { scanf("%s", str); switch (str[0]) { case 'M': cnt[0]++; break; case 'A': cnt[1]++; break; case 'R': cnt[2]++; break; case 'C': cnt[3]++; break; case 'H': cnt[4]++; break; default: break; } } 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 += cnt[i] * cnt[j] * cnt[k]; } } } cout << ans << "\n"; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; long long ans, cnt; int main() { cin.tie(0); ios::sync_with_stdio(false); long long N; string s; map<char, int> m; string march = "MARCH"; for (long long i = 0; i < (long long)(march.size()); ++i) { m[march[i]] = 0; } cin >> N; for (long long i = 0; i < (long long)(N); ++i) { cin >> s; m[s[0]]++; } ans += m['M'] * m['A'] * (m['R'] + m['C'] + m['H']); ans += m['A'] * m['R'] * (m['C'] + m['H']); ans += m['M'] * m['R'] * (m['C'] + m['H']); ans += m['C'] * m['H'] * (m['M'] + m['A'] + m['R']); 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
from itertools import combinations from collections import Counter n=int(input()) s=Counter for i in range(n): s[input()[0]]+=1 print(sum([s[a]*s[b]*s[c] for a,b,c in combinations("MARCH",3)]))
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int dy[] = {0, 0, 1, -1, 0}; int dx[] = {1, -1, 0, 0, 0}; long long pow(int x, int n) { long long ans = x; if (n == 0) return 1; for (int i = 0; i < n - 1; i++) { ans *= x; } return ans; } void swap(int *X, int *Y) { int t = *X; *X = *Y; *Y = t; } string toUpper(string s) { string t = s; for (int i = 0; i < s.size(); ++i) { t[i] = toupper(s[i]); } return t; } string toLower(string s) { string t = s; for (int i = 0; i < s.size(); ++i) { t[i] = tolower(s[i]); } return t; } int main() { int n; cin >> n; int N[5] = {0}; string name; bool check[5] = {false}; int cnt = 0; for (int i = 0; i < n; ++i) { cin >> name; if (name[0] == 'M') { N[0]++; check[0] = true; cnt++; } else if (name[0] == 'A') { N[1]++; check[1] = true; cnt++; } else if (name[0] == 'R') { N[2]++; check[2] = true; cnt++; } else if (name[0] == 'C') { N[3]++; check[3] = true; cnt++; } else if (name[0] == 'H') { N[4]++; check[4] = true; cnt++; } else { continue; } } long long ans = 0; for (int i = 0; i < 5; ++i) { for (int j = i + 1; j < 5; ++j) { for (int k = j + 1; k < 5; ++k) { ans += N[i] * N[j] * N[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; long long MOD = 1e9 + 7; long long A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z; string S; long long ans = 0; int main() { cin >> N; vector<char> march = {'M', 'A', 'R', 'C', 'H'}; vector<int> marchN(5, 0); for (int i = 0; i < N; i++) { cin >> S; for (int j = 0; j < 5; j++) { if (S[0] == march[j]) marchN[j]++; } } for (int bit = 0; bit < (1 << 5); bit++) { int flag = 0; int tmp = 1; for (int i = 0; i < 5; i++) { if (bit & (1 << i)) { flag++; tmp *= marchN[i]; } } if (flag == 3) ans += tmp; } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { string s; ll N, m = 0, a = 0, r = 0, c = 0, h = 0, count = 0; cin >> N; int D[5]; int P[10] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2}; int Q[10] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3}; int R[10] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4}; for (int i = 0; i < N; i++) { cin >> s; if (s[0] == 'M') { m++; } if (s[0] == 'A') { a++; } if (s[0] == 'R') { r++; } if (s[0] == 'C') { c++; } if (s[0] == 'H') { h++; } } D[0] = m, D[1] = a, D[2] = r, D[3] = c, D[4] = h; for (int i = 0; i < 10; i++) { count += D[P[i]] * D[Q[i]] * D[R[i]]; } cout << count << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int m, a, r, c, h; int main() { int n, flag = 0; char b[11]; cin >> n; for (int i = 0; i < n; i++) { scanf(" %s", b); if (b[0] == 'M') m++; if (b[0] == 'A') a++; if (b[0] == 'R') r++; if (b[0] == 'C') c++; if (b[0] == 'H') h++; } long long x = 1, y = 0; if (m != 0) flag++; if (a != 0) flag++; if (r != 0) flag++; if (c != 0) flag++; if (h != 0) flag++; if (m != 0) x = x * m; if (a != 0) x = x * a; if (r != 0) x = x * r; if (c != 0) x = x * c; if (h != 0) x = x * h; if (flag <= 2) { printf("0\n"); return 0; } if (flag == 3) { printf("%I64d\n", x); return 0; } if (flag == 4) { if (m != 0) y += x / m; if (a != 0) y += x / a; if (r != 0) y += x / r; if (c != 0) y += x / c; if (h != 0) y += x / h; printf("%I64d\n", y); return 0; } y = x / m / a + x / m / r + x / m / c + x / m / h + x / a / r + x / a / c + x / a / h + x / r / c + x / r / h + x / c / h; printf("%I64d\n", y); 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 n, i, m, a, r, c, h; string s[100000]; int main() { cin >> n; for (i = 0; i < n; i++) { cin >> s[i];  if (strncmp("M", &s[i][0], 1) == 0) { m++; } if (strncmp("A", &s[i][0], 1) == 0) { a++; } if (strncmp("R", &s[i][0], 1) == 0) { r++; } if (strncmp("C", &s[i][0], 1) == 0) { c++; } if (strncmp("H", &s[i][0], 1) == 0) { h++; } } printf("%lld", m * a * r + m * a * c + m * a * h + m * r * c + m * r * h + m * c * h + a * r * c + a * r * h + a * c * h + r * c * h); }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<string> s(n); for (int i = 0; i < n; i++) cin >> s[i]; vector<int> m(5); for (int i = 0; i < n; i++) { char f = s[i][0]; switch (f) { 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; } } sort(m.begin(), m.end(), greater<int>()); long long size = 0; for (int i = 0; i < 5; i++) { if (m[i] != 0) size++; } if (size < 3) { cout << 0 << endl; return 0; } long long five = 10; long long four = 4; long long three = 1; if (size == 3) { cout << m[0] * m[1] * m[2] << endl; } else if (size == 4) { cout << four * m[0] - (m[1] * m[2] * m[3]) << endl; } else { cout << (five * m[0]) - (four * m[1]) - (m[2] * m[3] * m[4]) << endl; } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
n=int(input()) m=[0,0,0,0,0] for i in range(n): s=input() if s[0]=="M": m[0]+=1 elif s[0]=="A": m[1]+=1 elif s[0]=="R": m[2]+=1 elif s[0]=="C": m[3]+=1 elif s[0]=="H": m[4]+=1 ans=0 for i in range(3): for j in range(i,4): for k in range(j,5): ans+=m[i]*m[j]*m[k] print(ans)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; long long ans = 0; int m = 0, a = 0, r = 0, c = 0, h = 0; for (int i = 0; i < n; i++) { cin >> s; if (s[0] == 'M') m++; if (s[0] == 'A') a++; if (s[0] == 'R') r++; if (s[0] == 'C') c++; if (s[0] == 'H') h++; } ans += m * a * r; ans += m * a * c; ans += m * a * h; ans += m * r * c; ans += m * r * h; ans += m * c * h; ans += a * r * c; ans += a * r * h; ans += a * c * h; ans += r * c * h; cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <iostream> #include <cmath> #include <vector> #include <map> #include <iomanip> #include <algorithm> #include <sstream> #include <string> #include <math.h> #include <set> using namespace std; typedef long long ll; int main() { ios::sync_with_stdio(false); cin.tie(0); int n , m = 0 , a = 0 , r = 0 , c = 0 , h = 0; cin >> n; string a[n]; for( int i = 0 ; i < n ; i++ ) cin >> a[i]; for( int i = 0 ; i < n ; i++ ) { if( a[i][0] == 'M' ) m++; else if( a[i][0] == 'A' ) a++; else if( a[i][0] == 'R' ) r++; else if( a[i][0] == 'C' ) c++; else if( a[i][0] == 'H' ) h++; } if( m != 0 ) x++; else m++; if( a != 0 ) x++; else a++; if( r != 0 ) x++; else r++; if( c != 0 ) x++; else c++; if( h != 0 ) x++; else h++; if( x < 3 ) cout << 0; else cout << m * a * r * c * h; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; long long int group[5] = {}; long long int ans = 0; string tmp; cin >> N; for (int i = 0; i < N; i++) { cin >> tmp; switch (tmp[0]) { case 'M': group[0]++; break; case 'A': group[1]++; break; case 'R': group[2]++; break; case 'C': group[3]++; break; case 'H': group[4]++; break; } } for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 4; j++) { for (int k = j + 1; 5; k++) { ans += group[i] * group[j] * group[k]; } } } printf("%lld\n", ans); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using Graph = vector<vector<int>>; const long long MOD = 1e9 + 7; int main() { int n; cin >> n; vector<int> march(5, 0); string s = "MARCH"; for (int i = 0; i < (int)(n); i++) { string t; cin >> t; for (int j = 0; j < (int)(5); j++) if (t[0] == s[j]) march[j]++; } long long ans = 0; for (int i = 0; i < 5; ++i) { for (int j = i + 1; j < 5; ++j) { for (int k = j + 1; k < 5; ++k) { ans += march[i] * march[j] * march[k]; } } } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; char c[5] = {'M', 'A', 'R', 'C', 'H'}; int main() { int n; cin >> n; map<char, int> mp; for (int i = 0; i < n; i++) { string s; cin >> s; for (int i = 0; i < 5; i++) { if (s[0] == c[i]) mp[s[0]]++; } } long long ans = 0; for (int i = 0; i < mp.size() - 2; i++) { for (int j = i + 1; j < mp.size() - 1; j++) { for (int k = j + 1; k < mp.size(); k++) { ans += mp[i] * mp[j] * mp[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; long long r = 0; cin >> N; vector<int> v(5, 0); for (int i = 0; i < N; ++i) { cin >> S; if (S[0] == 'M') v[0] += 1; else if (S[0] == 'A') v[1] += 1; else if (S[0] == 'R') v[2] += 1; else if (S[0] == 'C') v[3] += 1; else if (S[0] == 'H') v[4] += 1; } for (int i = 0; i < 5; ++i) { for (int j = i + 1; j < 5; ++j) { if (j == 5) break; for (int k = j + 1; k < 5; ++k) { if (k == 5) break; r += v[i] * v[j] * v[k]; } } } cout << r << 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() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; char c[10]; int t[5] = {}; for (int i = 0; i < N; ++i) { cin >> c; if (c[0] == 'M') t[0]++; else if (c[0] == 'A') t[1]++; else if (c[0] == 'R') t[2]++; else if (c[0] == 'C') t[3]++; else if (c[0] == 'H') t[3]++; } long long ans = 0; for (int i = 0; i < 5; ++i) { for (int j = i; j < 5; ++j) { if (i == j) continue; long long tmp = 1; for (int k = 0; k < 5; ++k) { if (k == i | k == j) continue; else if (t[k] == 0) tmp = 0; tmp *= t[k]; } ans += tmp; } } 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
UNKNOWN
using System; using System.Collections.Generic; using System.Linq; class Program { static void Main(string[] args) { var n = int.Parse(Console.ReadLine()); var dict = new Dictionary<char, int>(); for (int i = 0; i < n; i++) { var c = Console.ReadLine()[0]; switch (c) { case 'M': case 'A': case 'R': case 'C': case 'H': if (dict.ContainsKey(c)) { dict[c]++; } else { dict[c] = 1; } break; } } var d = dict.Values.ToArray(); var ans = dfs(0, 3, d); Console.WriteLine(ans); } static int dfs(int i, int n, int[] d) { if (n == 0) { return 1; } var ans = 0; for (; i <= d.Length - n; i++) { ans += d[i] * dfs(i + 1, n - 1, d); } return ans; } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int MARCH[5] = {}; for (int i = 0; i < n; i++) { string s; cin >> s; switch (s[0]) { case 'M': MARCH[0]++; break; case 'A': MARCH[1]++; break; case 'R': MARCH[2]++; break; case 'C': MARCH[3]++; break; case 'H': MARCH[4]++; break; } } long long ans = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { ans += MARCH[i] * MARCH[j] * MARCH[k]; } } } cout << ans << endl; 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 int getValue(vector<long long int> dp, int index) { return dp[index] == 0 ? 1 : dp[index]; } int main() { long long int n; cin >> n; vector<long long int> dp(26, 0); for (int i = 0; i < n; i++) { string element; cin >> element; dp[element[0] - 'A']++; } vector<int> result; result.push_back(dp[12]); result.push_back(dp[0]); result.push_back(dp[17]); result.push_back(dp[2]); result.push_back(dp[7]); long long int finalresult = 0; for (int i = 0; i < 5; i++) { long long int temp = 1; for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { temp = result[i] * result[j] * result[k]; finalresult += temp; } } } cout << finalresult; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int n, a[10]; string s; int main() { 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]++; } cout << a[0] * a[1] * a[2] + a[0] * a[1] * a[3] + a[0] * a[1] * a[4] + a[0] * a[2] * a[3] + a[0] * a[2] * a[4] + a[0] * a[3] * a[4] + a[1] * a[2] * a[3] + a[1] * a[2] * a[4] + a[1] * a[3] * a[4] + a[2] * a[3] * a[4] << 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()) pp=1 pt=0 ptpt=1 ss=[] def fact(n): if n==0: print(1) return n*fact(n-1) for i in range(N): s=list(input()) ss.append(s[0]) for j in "MARCH": if j in ss: pt+=1 pp *= ss.count(j) if pt>=3: for k in range(pt - 3): ptpt *= pt-k print(ptpt*pp) 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
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<string> s(n); for (int i = 0; i < n; i++) cin >> s[i]; vector<pair<char, int> > p(5); p[0] = make_pair('M', 0); p[1] = make_pair('A', 0); p[2] = make_pair('R', 0); p[3] = make_pair('C', 0); p[4] = make_pair('H', 0); int use = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < 5; j++) { if (s[i].at(0) == p[j].first) { if (p[j].second == 0) use++; p[j].second++; } } } int ans = 0; if (use >= 3) { for (int i = 0; i < 5; i++) { if (p[i].second > 1 && use > 3) ans += (p[i].second - 1) * 3; else if (p[i].second > 1 && use == 3) ans += p[i].second - 1; } if (use == 3) ans += 1; if (use == 4) ans += 4; if (use == 5) ans += 10; } else { cout << 0 << endl; return 0; } std::cout << ans << '\n'; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
using System; class prog{ static void Main(string[] args){ int N =int.Parse(Console.ReadLine().Split(' ')); int count=0; for(int i=0;i<N;i++){ string name=Console.ReadLine(); string march="march"; foreach(char c in march){ if(name[0] == c){ count++; break; } } } Console.WriteLine(count*(count -1)*(count-2)/1/2/3); } }