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> int main() { char name[11]; int n; long int m = 0, a = 0, r = 0, c = 0, h = 0; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%s", name); if (name[0] == 'M') { m++; } else if (name[0] == 'A') { a++; } else if (name[0] == 'R') { r++; } else if (name[0] == 'C') { c++; } else if (name[0] == 'H') { h++; } } printf("%d %d %d %d %d\n", m, a, r, c, h); printf("%ld\n", m * a * r + m * a * c + m * a * h + m * r * c + m * r * h + m * c * h + a * r * c + a * r * h + a * c * h + r * c * h); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include<map> #include<set> #include<stack> #include<cmath> #include<queue> #include<cstdio> #include<string> #include<vector> #include<cstring> #include<iostream> #include<algorithm> #define inf 0x3f3f3f3f using namespace std; long long a[5], ans; int main() { int n; char s[11]; scanf_s("%d", &n); for (int i = 1; i <= n; i++) { scanf("%s", 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 <= 2; i++) for (int j = i + 1; j <= 3; j++) for (int k = j + 1; k <= 4; k++) ans += a[i] * a[j] * a[k]; printf("%lld", ans); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> int main() { int num; std::cin >> num; std::string name; char ini; int list[5] = {}; for (int i = 0; i < num; i++) { std::cin >> name; ini = name[0]; if (ini == 'M') { list[0] += 1; } else if (ini == 'A') { list[1] += 1; } else if (ini == 'R') { list[2] += 1; } else if (ini == 'C') { list[3] += 1; } else if (ini == 'H') { list[4] += 1; } else { ; } } int cnt = 0; for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 4; j++) { for (int k = j + 1; k < 5; k++) { cnt += list[i] * list[j] * list[k]; } } } std::cout << cnt; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include <bits/stdc++.h> int main(int argc, char const *argv[]) { int n = 0; char c = 0; char name[16]; int names[5] = {}; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%s", name); switch (*name) { case 'M': names[0]++; break; case 'A': names[1]++; break; case 'R': names[2]++; break; case 'C': names[3]++; break; case 'H': names[4]++; break; } } int sum = 0; for (int i = 0; i <= 2; i++) { for (int j = i + 1; j <= 3; j++) { for (int k = j + 1; k <= 4; k++) { sum += names[i] * names[j] * names[k]; } } } printf("%d\n", sum); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const long long LLINF = 9223372036854775807; const int MOD = 1000000007; int main() { int N; cin >> N; int a[5] = {}; for (int i = 0; i < (int)N; i++) { string name; cin >> name; if (name[0] == 'M') a[0]++; else if (name[0] == 'A') a[1]++; else if (name[0] == 'R') a[2]++; else if (name[0] == 'C') a[3]++; else a[4]++; } int result = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) result += a[i] * a[j] * a[k]; } } cout << result << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } int g[15][15]; const int INF = 1001001001; const int dx[4] = {-1, 0, 1, 0}; const int dy[4] = {0, -1, 0, 1}; long long gcd(long long x, long long y) { return y ? gcd(y, x % y) : x; } long long lcm(long long x, long long y) { if (x == 0 || y == 0) return 0; return (x / gcd(x, y) * y); } vector<pair<long long, int>> factorize(long long n) { vector<pair<long long, int>> res; for (long long i = 2; i * i <= n; ++i) { if (n % i) continue; res.emplace_back(i, 0); while (n % i == 0) { n /= i; res.back().second++; } } if (n != 1) res.emplace_back(n, 1); return res; } int dp[1010][1010]; int bingo[3][3]; bool flag[3][3]; int I[100][20]; char s[100][100]; int main() { long long n; cin >> n; vector<int> name(5, 0); for (int i = 0; i < n; ++i) { string s; cin >> s; if (s[0] == 'M') name[0]++; else if (s[0] == 'A') name[1]++; else if (s[0] == 'R') name[2]++; else if (s[0] == 'C') name[3]++; else if (s[0] == 'H') name[4]++; } long long ans = 0; for (int i = 0; i < 5; ++i) { for (int j = i + 1; j < 5; ++j) { for (int k = j + 1; k < 5; ++k) { ans += name[i] * name[j] * name[k]; } } } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; string S; int a[5] = {0}; for (int i = 0; i < N; i++) { cin >> S; if (S[0] == 'M') ++a[0]; else if (S[0] == 'A') ++a[1]; else if (S[0] == 'R') ++a[2]; else if (S[0] == 'C') ++a[3]; else if (S[0] == 'H') ++a[4]; } long long Ans = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { Ans += a[i] * a[j] * a[k]; } } } 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
python3
N = int(input()) nM = 0 nA = 0 nR = 0 nC = 0 nH = 0 for i in range(N): S = input() if S[0] == "M": nM += 1 if S[0] == "A": nA += 1 if S[0] == "R": nR += 1 if S[0] == "C": nC += 1 if S[0] == "H": nH += 1 r = 0 r += nM*nA*nR r += nM*nA*nC r += nM*nA*nH r += nM*nR*nC r += nM*nR*nH r += nA*nR*nC r += nA*nR*nH r += nA*nC*nH r += nR*nC*nH print(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 <iomanip> #include <sstream> #include <vector> #include <string> #include <set> #include <map> #include <stack> #include <queue> #include <deque> #include <algorithm> #include <functional> #include <iterator> #include <limits> #include <numeric> #include <utility> #include <cmath> #include <cassert> #include <cstdio> // #include <unordered_set> // #include <unordered_map> #define rep(i, a, n) for(int i = a; i < n; ++i) #define REP(i, n) rep(i, 0, n) #define repb(i, a, b) for(int i = a; i >= b; i--) #define all(a) a.begin(), a.end() #define SORT(c) sort((c).begin(),(c).end()) #define RSORT(c) sort((c).rbegin(),(c).rend()) #define pb push_back #define mp make_pair int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;} int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;} typedef std::pair<int, int> P; typedef long long ll; typedef long double ld; const int MOD = 1000000007; const int INF = 1e9; const ll LINF = INF * 1ll * INF; const ld DINF = 1e200; const double EPS = 1e-10; const double PI = acos(-1.0); using namespace std; #define int long long signed main(){ int n; cin>>n; int initials[n]={0}; REP(i,n){ string tmp; cin>>tmp; //march if(tmp[0]=='M'){ initials[0]++; }else if(tmp[0]=='A'){ initials[1]++; }else if(tmp[0]=='R'){ initials[2]++; }else if(tmp[0]=='C'){ initials[3]++; }else if(tmp[0]=='H'){ initials[4]++; } } int m=initials[0]; int a=initials[1]; int r=initials[2]; int c=initials[3]; int h=initials[4]; int ans=0; // cout<<m<<a<<r<<c<<h<<endl; REP(i,2){ REP(j,2){ REP(k,2){ REP(l,2){ REP(o,2){ int sum=i+j+k+l+o; if(sum==3){ // cout<<i<<j<<k<<l<<o<<endl; int tmp=1; if(i)tmp*=m; if(j)tmp*=a; if(k)tmp*=r; if(l)tmp*=c; if(o)tmp*=h; 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
java
import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); sc.nextLine(); int[] map = new int[26]; for (int i = 0; i < N; i++) { char S = sc.nextLine().charAt(0); switch(S) { case 'M': case 'A': case 'R': case 'C': case 'H': map[(int) S - 65] += 1; break; default: break; } } Arrays.sort(map); int[] march = Arrays.copyOfRange(map, 21, 26); 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]; } } } 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
UNKNOWN
#include <bits/stdc++.h> int max(int a, int b) { return a >= b ? a : b; } int min(int a, int b) { return b >= a ? a : b; } int sei(int a) { return a > 0 ? a : 0; } int factorial(int n) { if (n > 0) return n * factorial(n - 1); else return 1; } int compare_up_int(const void *a, const void *b) { return *(int *)a - *(int *)b; } int compare_down_int(const void *a, const void *b) { return *(int *)b - *(int *)a; } int euclid(int a, int b) { if (a < b) { int tmp = a; a = b; b = tmp; } int r = a % b; if (r < 0) r += b; while (r != 0) { a = b; b = r; r = a % b; if (r < 0) r += b; } return b; } int main() { long int N, count = 0, c[5] = {0, 0, 0, 0, 0}; scanf("%ld", &N); char s[N]; for (int i = 0; i < N; i++) scanf("%s\n", &s[i]); for (int i = 0; i < N; i++) { if (s[i] == 'M') c[0] += 1; else if (s[i] == 'A') c[1] += 1; else if (s[i] == 'R') c[2] += 1; else if (s[i] == 'C') c[3] += 1; else if (s[i] == 'H') c[4] += 1; } count += c[0] * c[1] * c[2]; count += c[0] * c[1] * c[3]; count += c[0] * c[1] * c[4]; count += c[0] * c[2] * c[3]; count += c[0] * c[2] * c[4]; count += c[0] * c[3] * c[4]; count += c[1] * c[2] * c[3]; count += c[1] * c[2] * c[4]; count += c[1] * c[3] * c[4]; count += c[2] * c[3] * c[4]; printf("%ld", count); 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, su = 0; map<char, int> m; string s; cin >> n; getchar(); for (int i = 0; i < n; i++) { cin >> s; if (s[0] == 'M' || s[0] == 'A' || s[0] == 'R' || s[0] == 'C' || s[0] == 'H') { m[s[0]]++; } } if (m['M'] != 0 && m['A'] != 0 && m['R'] != 0) { su += (m['M'] * m['A'] * m['R']); } if (m['M'] != 0 && m['C'] && m['H']) { su += (m['M'] * m['C'] * m['H']); } if (m['M'] != 0 && m['A'] && m['H']) { su += (m['M'] * m['A'] * m['H']); } if (m['M'] != 0 && m['R'] && m['H']) { su += (m['M'] * m['H'] * m['R']); } if (m['M'] != 0 && m['R'] && m['C']) { su += (m['M'] * m['R'] * m['C']); } if (m['M'] != 0 && m['C'] && m['A']) { su += (m['M'] * m['C'] * m['A']); } if (m['R'] != 0 && m['A'] != 0 && m['C'] != 0) { su += (m['A'] * m['R'] * m['C']); } if (m['A'] != 0 && m['R'] && m['H']) { su += (m['A'] * m['R'] * m['H']); } if (m['C'] != 0 && m['A'] != 0 && m['H'] != 0) { su += (m['A'] * m['C'] * m['H']); } if (m['H'] != 0 && m['C'] != 0 && m['R'] != 0) { su += (m['R'] * m['C'] * m['H']); } { cout << su << endl; } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> name_type(5, 0); for (int i = 0; i < n; i++) { string name; cin >> name; if (name[0] == 'M') { name_type[0] += 1; } else if (name[0] == 'A') { name_type[1] += 1; } else if (name[0] == 'R') { name_type[2] += 1; } else if (name[0] == 'C') { name_type[3] += 1; } else if (name[0] == 'H') { name_type[4] += 1; } } unsigned long int ans = 0; for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { for (int k = 0; k < 5; k++) { if (i != j && j != k && i != k && name_type[i] != 0 && name_type[j] != 0 && name_type[k] != 0) { ans += name_type[i] * name_type[j] * name_type[k]; } } } } cout << ans / 6 << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int n; string s[100009]; long long dfs(int cnt, int now, string t) { long long f, rec = 0; string temp; if (cnt == 3) return 1; for (int i = now; i < n; i++) { f = 0; for (int j = 0; j < 5; j++) { if (s[i][0] == t[j]) { temp = t; temp[j] = '0'; f++; } } if (f > 0) rec += dfs(cnt + 1, i + 1, temp); } return rec; } int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> s[i]; } cout << dfs(0, 0, "MARCH") << 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 { static int[][] memory; public static void main(String[] args) { // 自分の得意な言語で // Let's チャレンジ!! Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int count = 0; int[] member = new int[5]; for(int i = 0;i<N;i++){ String line = sc.next(); if('M'==line.charAt(0)){ member[0]++; }else if('A'==line.charAt(0)){ member[1]++; }else if('R'==line.charAt(0)){ member[2]++; }else if('C'==line.charAt(0)){ member[3]++; }else if('H'==line.charAt(0)){ member[4]++; } } int ans = result(member,0,0); System.out.println(ans); } private static int result(int[] member,int count,int choise) { int ans=1; if(choise==4) if(count==2) return member[choise]; else if(count==3) return 1; else return 0; if(count<3){ ans *= (result(member,count,choise+1)+result(member,count+1,choise+1)*member[choise]); }else{ ans *= result(member,count,choise+1); } 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
java
import java.util.Scanner; public class Main{ public static void main(String[] args){ Scanner scanner = new Scanner(System.in); int N = scanner.nextInt(); String[] S = new String[N]; int[] count = new int[5]; long ans = 0; for (int i = 0; i < N; i++){ S[i] = scanner.next(); } for (int i = 0; i < N; i++){ if(S[i].charAt(0) == 'M'){ count[0]++; } else if (S[i].charAt(0) == 'A'){ count[1]++; } else if (S[i].charAt(0) == 'R'){ count[2]++; } else if (S[i].charAt(0) == 'C'){ count[3]++; } else if (S[i].charAt(0) == 'H'){ count[4]++; } else {return; } ans = count[0] * count[1] * count[2] + count[0] * count[1]* count[3] + count[0] * count[1]* count[4] + count[0] * count[2]* count[3] + count[0] * count[2]* count[4] + count[0] * count[3]* count[4] + count[1] * count[2]* count[3] + count[1] * count[2]* count[4] + count[1] * count[3]* count[4] + count[2] * count[3]* count[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; int main() { long long N; cin >> N; vector<string> A(N); for (long long i = 0; i < N; i++) { cin >> A[i]; } long long m, a, r, c, h; for (long long 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++; } } long long 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
cpp
// https://atcoder.jp/contests/abc089/tasks/abc089_c #include <iostream> #include <vector> #include <map> #include <set> #include <iterator> #include <algorithm> using namespace std; using namespace std::string_literals; using ll = long long ; class C { public: multimap<char, string> names_{}; vector<char> initials_{}; ll total_{}; vector<char> comb_{}; C(vector<string> values) { for (auto&& v : values) { if (v.find_first_of("MARCH") == 0) { initials_.emplace_back(v[0]); names_.emplace(v[0], std::move(v)); } } initials_.erase(unique(initials_.begin(), initials_.end()), initials_.end()); } ll visit_next(int offset, int k) { if (k == 0) { ll num = 1; for(auto c : comb_) { num *= names_.count(c); } total_ += num; return total_; } for(int i=offset, n=initials_.size(); i < n - k ; ++i) { comb_.emplace_back(initials_[i]); visit_next(i+1, k-1); comb_.pop_back(); } return total_; } }; int main() { ll N; cin >> N; vector<std::string> values{}; values.reserve(N); for (int i =0; i < N; ++i) { string n; cin >> n; values.emplace_back(std::move(n)); } C c{std::move(values)}; auto total = c.visit_next(0, 3); cout << total << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; ll calcNumOfCombination(ll n, ll r) { ll num = 1; for (ll i = 1; i <= r; i++) { num = num * (n - i + 1) / i; } return num; } int main() { ll n; cin >> n; map<char, ll> s; for (long long i = 0; i < (int)(n); i++) { string tmp; cin >> tmp; if (tmp[0] == 'M' or tmp[0] == 'A' or tmp[0] == 'R' or tmp[0] == 'C' or tmp[0] == 'H') s[tmp[0]]++; } ll ans = 0, sum = 0; for (auto x : s) sum += x.second; ans = calcNumOfCombination(sum, 3); for (auto x : s) { if (x.second > 1 and s.size() < 4) { ans -= 2; } else if (x.second > 1) { ll n = x.second - 1; ans -= n * 0.5 * (n + 5); } } cout << fixed << 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(void) { int N; int M = 0, A = 0, R = 0, C = 0, H = 0; long int result = 0; string tmp; cin >> N; for (int i = 0; i < N; i++) { cin >> tmp; if (tmp[0] == 'M') { M++; } else if (tmp[0] == 'A') { A++; } else if (tmp[0] == 'R') { R++; } else if (tmp[0] == 'C') { C++; } else if (tmp[0] == 'H') { H++; } } result = M * A * R + M * A * C + M * A * H + M * R * C + M * R * H; result += M * C * H + A * R * C + A * R * H + A * C * H + R * C * H; cout << result << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; char nm[11]; int ct[5] = {0, 0, 0, 0, 0}; long long k; cin >> n; for (int i = 0; i < n; i++) { cin >> nm; switch (nm[0]) { case 'M': ct[0]++; break; case 'A': ct[1]++; break; case 'R': ct[2]++; break; case 'C': ct[3]++; break; case 'H': ct[4]++; break; } } k = ct[0] * ct[1] * ct[2] + ct[0] * ct[1] * ct[3] + ct[0] * ct[1] * ct[4] + ct[0] * ct[2] * ct[3] + ct[0] * ct[2] * ct[4] + ct[0] * ct[3] * ct[4] + ct[1] * ct[2] * ct[3] + ct[1] * ct[2] * ct[4] + ct[1] * ct[3] * ct[4] + ct[2] * ct[3] * ct[4]; cout << k << 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.HashMap; import java.util.Map; import java.util.Scanner; public class Main { private static Map<Character, Integer> map = new HashMap<Character, Integer>() { { put('M', 0); put('A', 1); put('R', 2); put('C', 3); put('H', 4); } }; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); String[] s = new String[n]; long[] cnt = new long[n]; for (int i = 0; i < n; i++) { s[i] = sc.next(); char c = s[i].charAt(0); if (c == 'M' || c == 'A' || c == 'R' || c == 'C' || c == 'H') { cnt[map.get(c)]++; } } long sum = 0; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { for (int k = j + 1; k < n; k++) { sum += cnt[i] * cnt[j] * cnt[k]; } } } System.out.println(sum); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N = 0; vector<string> M, A, R, C, H; cin >> N; string s; for (int i = 0; i < N; i++) { cin >> s; if (s[0] == 'M') { M.push_back(s); } else if (s[0] == 'A') { A.push_back(s); } else if (s[0] == 'R') { R.push_back(s); } else if (s[0] == 'C') { C.push_back(s); } else if (s[0] == 'H') { H.push_back(s); } } int sum = 0; sum += M.size() * A.size() * R.size(); sum += M.size() * A.size() * C.size(); sum += M.size() * A.size() * H.size(); sum += M.size() * R.size() * C.size(); sum += M.size() * R.size() * H.size(); sum += M.size() * C.size() * H.size(); sum += A.size() * R.size() * C.size(); sum += A.size() * R.size() * H.size(); sum += A.size() * C.size() * H.size(); sum += R.size() * C.size() * H.size(); printf("%d\n", sum); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int dx[] = {1, -1, 0, 0}; const int dy[] = {0, 0, -1, 1}; template <typename T> void printA(vector<T> &printArray, char between = ' ') { int paSize = printArray.size(); for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between; } if (between != '\n') { cerr << endl; } } int main() { int n; cin >> n; int a[5] = {0}; string march = "MARCH"; for (int(i) = (0); (i) < (n); ++(i)) { string s; cin >> s; auto p = march.find(s[0]); if (p == string::npos) continue; a[p]++; } long long sum = 0; for (int(i) = (0); (i) < (5); ++(i)) { for (int(j) = (i + 1); (j) < (5); ++(j)) { for (int(k) = (j + 1); (k) < (5); ++(k)) { sum += a[i] * a[j] * a[k]; } } } cout << sum << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; char ini[256]; int main(void) { long long m[10]; long long n; string name; for (long long i = 0; i < 255; i++) ini[i] = 5; ini['M'] = 0; ini['A'] = 1; ini['R'] = 2; ini['C'] = 3; ini['H'] = 4; for (long long i = 0; i < 5; i++) m[i] = 0; cin >> n; for (long long i = 0; i < n; i++) { cin >> name; m[ini[name[0]]]++; } long long cnt = 0; for (long long i = 0; i < n - 2; i++) { for (long long j = i + 1; j < n - 1; j++) { for (long long k = j + 1; k < n; k++) { cnt += m[i] * m[j] * m[k]; } } } cout << cnt << 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; double const pi = 3.1415926535; int const mod = 1000000007; int const inf = 2147483647; int yesno(bool f, string yes, string no) { if (f) cout << yes << endl; else cout << no << endl; return 0; } int printint(int n) { cout << n << endl; return 0; } int prints(string s) { cout << s << endl; return 0; } int m, a, r, c, h; int main() { string s; int n; cin >> n; long long ans = 0; for (int i = 1; i <= n; i++) { cin >> s; if (s[0] == 'M') m++; else if (s[0] == 'A') a++; else if (s[0] == 'R') r++; else if (s[0] == 'C') c++; else if (s[0] == 'H') h++; } ans += m * a * r; ans += m * a * c; ans += m * a * h; ans += m * r * c; ans += m * r * h; ans += m * c * h; ans += a * r * c; ans += a * r * h; ans += a * c * h; ans += r * c * h; cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include <bits/stdc++.h> int main(void) { int n; scanf("%d", &n); char name[11]; int count[5] = {0}; long ans = 0; for (int i = 0; i < n; i++) { scanf("%s", name); switch (name[0]) { case 'M': count[0] += 1; break; case 'A': count[1] += 1; break; case 'R': count[2] += 1; break; case 'C': count[3] += 1; break; case 'H': count[4] += 1; break; default: break; } } for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 4; j++) { for (int k = j + 1; k < 5; k++) { ans = ans + count[i] * count[j] * count[k]; } } } printf("%ld\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 <iostream> #include <algorithm> #include <queue> #include <vector> #include <set> #include <cmath> #include <string> #define FOR(i,a,b) for(int i=a;i<b;i++) #define ROF(i,a,b) for(int i=b-1;i>=a;i--) #define FI first #define SE second #define VE vector<int> #define PB push_back #define LL long long #define YES(i) cout<<(i?"YES":"NO")<<endl #define Yes(i) cout<<(i?"Yes":"No")<<endl using namespace std; // const int INF=1e9+7; const int MOD=1e9+7; // int main(){ int N; int M,A,R,C,H; cin>>N; FOR(i,0,N){ string S; cin>>S; if(S[0]=='M'){ M++; }else if(S[0]=='A'){ A++; }else if(S[0]=='R'){ R++; }else if(S[0]=='C'){ C++; }else if(S[0]=='H'){ H++; } } LL ans=M*A*R+M*A*C+M*A*H+A*R*C+A*R*H+A**H+R*C*H; cout<<ans<<endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int gcd(int m, int n) { if ((0 == m) || (0 == n)) return 0; while (m != n) { if (m > n) m = m - n; else n = n - m; } return m; } int lcm(int m, int n) { if ((0 == m) || (0 == n)) return 0; return ((m / gcd(m, n)) * n); } int input() { int x; cin >> x; return x; } int abs(int x) { if (x >= 0) { return x; } else { return -x; } } int moji(char in) { int ans = (int)in - (int)'a' + 1; if ((in < 1) || (in > 26)) { ans = 100; } return ans; } const int VV = 10; int cost[VV][VV]; int d[VV]; bool used[VV]; void dijkstra(int s) { fill(d, d + VV, 100000); fill(used, used + VV, false); d[s] = 0; while (true) { int v = -1; for (int u = 0; u < VV; u++) { if (!used[u] && (v == -1 || d[u] < d[v])) v = u; } if (v == -1) break; used[v] = true; for (int u = 0; u < VV; u++) { d[u] = min(d[u], d[v] + cost[v][u]); } } } int compare_int(const void *a, const void *b) { return *(int *)a - *(int *)b; } int main() { int N; cin >> N; string S[N]; int summ = 0; int suma = 0; int sumr = 0; int sumc = 0; int sumh = 0; for (int i = 0; i < N; i++) { cin >> S[i]; if (S[i].at(0) == 'M') { summ++; } else if (S[i].at(0) == 'A') { suma++; } else if (S[i].at(0) == 'R') { sumr++; } else if (S[i].at(0) == 'C') { sumc++; } else if (S[i].at(0) == 'H') { sumh++; } } cout << summ * suma * sumr + summ * suma * sumc + summ * suma * sumh + summ * sumr * sumc + summ * sumr * sumh + summ * sumc * sumh + suma * sumr * sumc + suma * sumr * sumh + suma * sumc * sumh + sumr * sumc * sumh << 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; string a; int b[5] = {0}; cin >> N; while (N--) { cin >> a; if (a[0] == 'M') b[0]++; else if (a[0] == 'A') b[1]++; else if (a[0] == 'R') b[2]++; else if (a[0] == 'C') b[3]++; else if (a[0] == 'H') b[4]++; } int flag = 0; long long s; for (int i = 0; i < 5; i++) if (b[i]) flag++; if (flag < 3) printf("0\n"); else if (flag == 3) { s = 1; for (int i = 0; i < 5; i++) if (b[i]) s *= b[i]; cout << s << endl; } else if (flag >= 4) { s = 0; int x, y, z; for (x = 0; x < 3; x++) for (y = x + 1; y < 4; y++) for (z = y + 1; z < 5; z++) if (b[x] && b[y] && b[z]) s += b[x] * b[y] * b[z]; cout << s << endl; } return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.NoSuchElementException; public class Main { static FastScanner sc = new FastScanner(); static PrintWriter out = new PrintWriter(System.out); public static void main(String[] args) { long N = sc.nextInt(); int march [] = new int [5]; for (int i=0; i<N; i++) { String S = sc.next(); if (S.charAt(0)=='M') { int temp = march [0]; temp++; march [0]=temp; } if (S.charAt(0)=='A') { int temp = march [1]; temp++; march [1]=temp; } if (S.charAt(0)=='R') { int temp = march [2]; temp++; march [2]=temp; } if (S.charAt(0)=='C') { int temp = march [3]; temp++; march [3]=temp; } if (S.charAt(0)=='H') { int temp = march [4]; temp++; march [4]=temp; } } 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]; } } } out.println(ans); out.flush(); } static class FastScanner { private final InputStream in = System.in; private final byte[] buffer = new byte[1024]; private int ptr = 0; private int buflen = 0; private boolean hasNextByte() { if (ptr < buflen) { return true; } else { ptr = 0; try { buflen = in.read(buffer); } catch (IOException e) { e.printStackTrace(); } if (buflen <= 0) { return false; } } return true; } private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1; } private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126; } private void skipUnprintable() { while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; } public boolean hasNext() { skipUnprintable(); return hasNextByte(); } public String next() { if (!hasNext()) throw new NoSuchElementException(); StringBuilder sb = new StringBuilder(); int b = readByte(); while (isPrintableChar(b)) { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } public long nextLong() { if (!hasNext()) throw new NoSuchElementException(); long n = 0; boolean minus = false; int b = readByte(); if (b == '-') { minus = true; b = readByte(); } if (b < '0' || '9' < b) { throw new NumberFormatException(); } while (true) { if ('0' <= b && b <= '9') { n *= 10; n += b - '0'; } else if (b == -1 || !isPrintableChar(b)) { return minus ? -n : n; } else { throw new NumberFormatException(); } b = readByte(); } } public int nextInt() { return (int) nextLong(); } public int[] nextIntArray(int N, boolean oneBased) { if (oneBased) { int[] array = new int[N + 1]; for (int i = 1; i <= N; i++) { array[i] = sc.nextInt(); } return array; } else { int[] array = new int[N]; for (int i = 0; i < N; i++) { array[i] = sc.nextInt(); } return array; } } public long[] nextLongArray(int N, boolean oneBased) { if (oneBased) { long[] array = new long[N + 1]; for (int i = 1; i <= N; i++) { array[i] = sc.nextLong(); } return array; } else { long[] array = new long[N]; for (int i = 0; i < N; i++) { array[i] = sc.nextLong(); } return array; } } } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\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
require "big" class Problem getter :n, :a @n : Int32 @s : Array(String) @cnt : Hash(Char,Int32) def initialize @n = gets.to_s.to_i @s = Array.new(n){ gets.to_s.chomp } @cnt = Hash(Char,Int32).new{|h,k|h[k]=0} @s.each do |s| @cnt[s[0]] += 1 end end def solve ans = 0_i64 ['M','A','R','C','H'].each_combination do |(a,b,c)| next if @cnt[a] == 0 next if @cnt[b] == 0 next if @cnt[c] == 0 ans += @cnt[a] * @cnt[b] * @cnt[c] end ans end def show(ans) puts ans end end Problem.new.try do |b| b.show(b.solve) end
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; string S[110000]; char c[110000]; long long int a = 0; for (int i = 0; i < N; i++) { cin >> S[i]; c[i] = S[i][0]; } for (int i = 0; i < N; i++) { if (c[i] == 'M' || c[i] == 'A' || c[i] == 'R' || c[i] == 'C' || c[i] == 'H') { for (int j = i + 1; j < N; j++) { if (c[j] == 'M' || c[j] == 'A' || c[j] == 'R' || c[j] == 'C' || c[j] == 'H' && c[j] != c[j]) { for (int k = j + 1; k < N; k++) { if (c[k] == 'M' || c[k] == 'A' || c[k] == 'R' || c[k] == 'C' || c[k] == 'H' && c[i] != c[j] && c[i] != c[k] && c[j] != c[k]) { a += 1; } } } } } } cout << a << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.*; public class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long m = 0; long a = 0; long r = 0; long c = 0; long h = 0; for (int i = 0; i < n; i++) { char fc = sc.next().charAt(0); switch (fc) { case 'm': m++; break; case 'a': a++; break; case 'r': r++; break; case 'c': c++; break; case 'h': h++; break; } } System.out.println(r*c*h + a*c*h + a*r*h + a*r*c + m*c*h + m*r*h + m*r*c + m*a*h + m*a*c + m*a*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
UNKNOWN
#include <bits/stdc++.h> int main(void) { int N; scanf("%d", &N); int i, j, k; int c[5] = {0}; for (i = 0; i < N; i++) { char S[20]; scanf("%s", S); if (S[0] == 'M') { c[0]++; } else if (S[0] == 'A') { c[1]++; } else if (S[0] == 'R') { c[2]++; } else if (S[0] == 'C') { c[3]++; } else if (S[0] == 'H') { c[4]++; } } unsigned long long count = 0; for (i = 0; i < 5; i++) { for (j = i; j < 5; j++) { for (k = j; k < 5; k++) { if (i != j && j != k && k != i) { printf("(%d,%d,%d)\n", i, j, k); count += c[i] * c[j] * c[k]; } } } } printf("%llu\n", count); }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; void execute() { int N; cin >> N; long long int countM = 0; long long int countA = 0; long long int countR = 0; long long int countC = 0; long long int countH = 0; for (int i = 0; i < N; i++) { string tmp; cin >> tmp; switch (tmp[0]) { case 'M': countM++; break; case 'A': countA++; break; case 'R': countR++; break; case 'C': countC++; break; case 'H': countH++; break; default: break; } } long long int ans = 0; ans += countM * countA * countR; ans += countM * countA * countC; ans += countM * countA * countH; ans += countM * countR * countC; ans += countM * countR * countH; ans += countA * countR * countC; ans += countA * countR * countH; ans += countA * countC * countH; ans += countR * countC * countH; cout << ans << endl; return; } int main() { cin.tie(0); ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(15); execute(); int stop; cin >> stop; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; const int INF = (int)1e7; using p = pair<char, ll>; int n, m; int main() { cin >> n; auto s = map<string, int>(); for (int i = 0; i < n; i++) { string ss; cin >> ss; if (s.find(ss) != s.end()) { s[ss]++; } else { s[ss] = 0; } } auto m = vector<ll>(5, 0); for (auto i : s) { if (i.first[0] == 'M') { m[0]++; } else if (i.first[0] == 'A') { m[1]++; } else if (i.first[0] == 'R') { m[2]++; } else if (i.first[0] == 'C') { m[3]++; } else if (i.first[0] == 'H') { m[4]++; } } s.clear(); auto _max = 0; if (m[0] != 0 && m[1] != 0 && m[2] != 0) { _max += m[0] * m[1] * m[2]; } if (m[0] != 0 && m[1] != 0 && m[3] != 0) { _max += m[0] * m[1] * m[3]; } if (m[0] != 0 && m[1] != 0 && m[4] != 0) { _max += m[0] * m[1] * m[4]; } if (m[0] != 0 && m[2] != 0 && m[3] != 0) { _max += m[0] * m[2] * m[3]; } if (m[0] != 0 && m[2] != 0 && m[4] != 0) { _max += m[0] * m[2] * m[4]; } if (m[0] != 0 && m[3] != 0 && m[4] != 0) { _max += m[0] * m[3] * m[4]; } if (m[1] != 0 && m[2] != 0 && m[3] != 0) { _max += m[1] * m[2] * m[3]; } if (m[1] != 0 && m[2] != 0 && m[4] != 0) { _max += m[1] * m[2] * m[4]; } if (m[1] != 0 && m[3] != 0 && m[4] != 0) { _max += m[1] * m[3] * m[4]; } if (m[2] != 0 && m[3] != 0 && m[4] != 0) { _max += m[2] * m[3] * m[4]; } cout << _max; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; string S[N]; for (int i = 0; i < N; i++) cin >> S[N]; long long int count[5]; for (int i = 0; i < N; i++) { if (S[i][0] == 'M') { count[0] += 1; } else if (S[i][0] == 'A') { count[1] += 1; } else if (S[i][0] == 'R') { count[2] += 1; } else if (S[i][0] == 'C') { count[3] += 1; } else if (S[i][0] == 'H') { count[4] += 1; } } long long 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 += count[i] * count[j] * count[k]; } } } cout << sum << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { long long c; if (a < b) { c = a; a = b; b = c; } while (b != 0) { c = a % b; a = b; b = c; } return a; } long long lcm(long long a, long long b) { long long c; c = a * b / gcd(a, b); return c; } int sort_greater(int m, int n) { vector<int> a(m); for (int i = 0; i < m; i++) { cin >> a[i]; } sort(a.begin(), a.end(), greater<int>()); for (int i = 0; i < n; i++) { cout << a[i]; } return 0; } int bubblesort(int a[], int n) { int sw = 0; bool flag = 1; for (int i = 0; flag; i++) { flag = 0; for (int j = n - 1; j >= i + 1; j--) { if (a[j] < a[j - 1]) { swap(a[j], a[j - 1]); flag = 1; sw += 1; } } } return sw; } int a_z() { for (int i = 0; i <= ('Z' - 'A'); i++) { cout << (char)('A' + i); } return 0; } int selecttionsort(int a[], int n) { int t, sw = 0, minj; for (int i = 0; i < n - 1; i++) { minj = i; for (int j = 0; j < n - 1; j++) { if (a[j] < a[minj]) { minj = j; } } t = a[i]; a[i] = a[minj]; a[minj] = t; if (i != minj) sw += 1; } return sw; } bool is_prime(int x) { if (x <= 1) return false; for (int i = 2; i * i <= x; i++) { if (x % i == 0) return false; } return true; } const long long mod = 1000000007; map<string, int> memo; using P = pair<long long, long long>; long long findIndex(int value, vector<long long> a) { for (long long i = 0; i < (long long)a.size(); i++) { if (a[i] == value) { return i; } } return -1; } struct mint { long long x; mint(long long x = 0) : x(x % mod) {} mint pow(long long t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } mint inv() const { return pow(mod - 2); } mint& operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint& operator-=(const mint a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; } mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; } mint& operator/=(const mint a) { return (*this) *= a.inv(); } mint operator+(const mint a) const { mint res(*this); return res += a; } mint operator-(const mint a) const { mint res(*this); return res -= a; } mint operator*(const mint a) { mint res(*this); return res *= a; } mint operator/(const mint a) { mint res(*this); return res /= a; } }; struct combination { vector<mint> fact, ifact; combination(long long n) : fact(n + 1), ifact(n + 1) { fact[0] = 1; for (long long i = 1; i <= n; i++) fact[i] = fact[i - 1] * i; ifact[n] = fact[n].inv(); for (long long i = n; i >= 1; i--) { ifact[i - 1] = ifact[i] * i; } } mint operator()(long long n, long long k) { if (k < 0 || k > n) return 0; return fact[n] * ifact[k] * ifact[n - k]; } }; template <typename T> struct BIT { int n; vector<T> d; BIT(int n = 0) : n(n), d(n + 1) {} void add(int i, T x = 1) { for (i++; i <= n; i += i & -i) { d[i] += x; } } T sum(int i) { T x = 0; for (i++; i; i -= i & -i) { x += d[i]; } return x; } T sum(int l, int r) { return sum(r - 1) - sum(l - 1); } }; const int INF = 1001001001; const int M = 1000001; string f(long long n) { if (n == 0) return ""; n--; return f(n / 26) + string(1, 'a' + n % 26); } string x(long long n) { string s = ""; if (n == 0) return ""; n--; s += 'a' + n % 26; return x(n / 26) + s; } long long yakusuu(long long x) { long long anss = 1; vector<long long> a(x + 1); long long num = x; for (long long i = 2; i <= x; i++) { while (num % i == 0) { a.at(i)++; num /= i; } } for (long long i = 2; i <= x; i++) { anss *= a[i] + 1; } return anss; } int main() { int n, m = 0, a = 0, r = 0, c = 0, h = 0; cin >> n; vector<int> cn(5); string ma = "MARCH"; for (long long i = 0; i < (long long)(n); i++) { string s; cin >> s; for (long long i = 0; i < (long long)(5); i++) { if (s[0] == ma[i]) cn[i]++; } } int ans = 0; for (int i = 0; i < (1 << 5); i++) { vector<int> s; for (int j = 0; j < 5; j++) { if (i & (1 << j)) { s.push_back(j); } } if (s.size() != 3) continue; ans += cn[s[0]] * cn[s[1]] * cn[s[2]]; } 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 res; int a[300]; int ans[10], flag[10]; void dfs(int pos, int cnt) { if (pos > 4) { if (cnt == 3) { int sum = 1; for (int i = 0; i < 5; i++) { if (flag[i]) sum *= ans[i]; } res += sum; } return; } if (ans[pos]) { flag[pos] = 1; dfs(pos + 1, cnt + 1); flag[pos] = 0; } dfs(pos + 1, cnt); } int main() { int n; scanf("%d", &n); for (int i = 1; i <= n; i++) { char s[105]; scanf("%s", s); if (s[0] == 'M') ans[0]++; if (s[0] == 'A') ans[1]++; if (s[0] == 'R') ans[2]++; if (s[0] == 'C') ans[3]++; if (s[0] == 'H') ans[4]++; } dfs(0, 0); printf("%d\n", res); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; int c[5] = {0}; string s = "MARCH"; for (int i = 0; i < N; i++) { string str; cin >> str; for (int j = 0; j < 5; j++) { if (str[0] == s[j]) { c[j]++; } } } long long ptn = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { ptn += c[i] * c[j] * c[k]; } } } cout << ptn << 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; //KASRA FOULADI; int main(){ long long int n, ans = 0; cin >> n; int cnt[26] = {}; char s[21]; for(int i = 0; i < n; ++i){ cin >> s; ++cnt[s[0] - 65]; } for(int i = 0; i < 24; ++i) for(int j = i + 1; j < 25; ++j) for(int k = j + 1; k < 26; ++k) ans += cnt[i] cnt[j] cnt[k]; cout << ans << '\n'; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; size_t N; string S; char headc[5] = {'M', 'A', 'R', 'C', 'H'}; vector<long long> head_num(5, 0); void mysort(string s) { for (size_t i = 0; i < 5; i++) { if (s.front() == headc[i]) { head_num[i]++; return; } } return; } int main() { cin >> N; S.resize(N); for (size_t i = 0; i < N; i++) { cin >> S; mysort(S); } sort(head_num.begin(), head_num.end()); int times = 1; int sump = 0; if (head_num[0] > 0) { for (size_t i = 0; i < 4; i++) { for (size_t j = i + 1; j < 5; j++) { for (size_t k = 0; k < 5; k++) { if (k != i || k != j) { times *= head_num[k]; } } sump += times; times = 1; } } cout << sump << endl; } else if (head_num[1] > 0) { for (size_t i = 1; i < 5; i++) { for (size_t k = 1; k < 5; k++) { if (k != i) { times *= head_num[k]; } } sump += times; times = 1; } cout << sump << endl; } else { for (size_t k = 2; k < 5; k++) { times *= head_num[k]; } cout << times << endl; } return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; using Graph = vector<vector<int>>; const ll LINF = 1e18; const int INF = 1e9; const ll MOD = 1000000007; 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; } ll ans = 0; map<char, int> mp; void dfs(vector<string> v, int n) { if (n == 3) { ans++; return; } for (auto x : v) { if (mp[x[0]] != 0) continue; mp[x[0]]++; dfs(v, n + 1); mp[x[0]] = 0; } } int main() { int n; cin >> n; vector<string> name; for (int i = 0; i < n; i++) { string s; cin >> s; switch (s[0]) { case 'M': case 'A': case 'R': case 'C': case 'H': name.push_back(s); break; default: break; } } dfs(name, 0); cout << ans / 6 << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
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]; char[] initial = new char[N]; int m = 0; int a = 0; int r = 0; int c = 0; int h = 0; int march = 0; for(int i=0; i<N; i++) { S[i] = sc.next(); initial[i] = S[i].charAt(0); if(initial[i] == 'M') m++; else if(initial[i] == 'A') a++; else if(initial[i] == 'R') r++; else if(initial[i] == 'C') c++; else if(initial[i] == 'H') h++; } if(m != 0) march += 1; else m+= 1; if(a != 0) march += 1; else a+= 1; if(r != 0) march += 1; else r+= 1; if(c != 0) march += 1; else c+= 1; if(h != 0) march += 1; else h+= 1; //System.out.println(h); //チェック //System.out.println(march); //チェック int ans = 0; ans += march*(march-1)*(march-2)/6; //System.out.println(ans); //チェック ans *= m*a*r*c*h; System.out.println(ans); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
_, *names = readlines.map(&:chomp) marchs = names.select {|n| 'MARCH'.each_char.any?{|c| n.start_with?(c)}} marchs.length == 0 && p(0) && exit x = marchs.reduce(Hash.new {|h, k| h[k]=0}) {|r, n| r[n[0]]+=1; r} p x.keys.combination(3).map {|c| c.reduce(1) {|r, k| r *= x[k]}}.reduce(:+)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\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 pat(int a, int b, int c) { if (a == 0 || b == 0 || c == 0) return 0; return a * b * c; } long long total(int *ini) { long long ans = 0; for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { ans += pat(ini[i], ini[j], ini[k]); } } } return ans; } int main() { long long int N = 0; cin >> N; char moji[5] = {'M', 'A', 'R', 'C', 'H'}; string name; int ini[5]; for (int i = 0; i < 5; i++) ini[i] = 0; for (int i = 0; i < N; i++) { name = "\n"; cin >> name; for (int i = 0; i < 5; i++) { if (name[0] == moji[i]) ini[i]++; } } cout << total(ini) << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int N; int C[5]; signed main() { ios::sync_with_stdio(false); cin.tie(0); cin >> N; for (int i = 0; i < (N); i++) { string s; cin >> s; if (s[0] == 'M') C[0]++; if (s[0] == 'A') C[1]++; if (s[0] == 'R') C[2]++; if (s[0] == 'C') C[3]++; if (s[0] == 'H') C[4]++; } long long s = 0; for (int a = 0; a < (5); a++) for (int b = 0; b < (a); b++) for (int c = 0; c < (b); c++) s += C[a] * C[b] * C[c]; cout << s << "\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() { int n; int mozi[5] = {0}; long long int ans = 1; long long int zenbu = 0; int i, j, k; char s[11]; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%s", s); switch (s[0]) { case 'M': mozi[0]++; break; case 'A': mozi[1]++; break; case 'R': mozi[2]++; break; case 'C': mozi[3]++; break; case 'H': mozi[4]++; break; } } for (i = 0; i < 3; i++) { for (j = i + 1; j < 4; j++) { for (k = j + 1; k < 5; k++) { ans = mozi[i] * mozi[j] * mozi[k]; zenbu += ans; } } } printf("%lld", zenbu); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int n, mark[5]; char s[10000][10]; int select(char ch) { if (ch == 'M' && mark[1] == 0) { mark[0] = 1; return 1; } else if (ch == 'A' && mark[1] == 0) { mark[1] = 1; return 1; } else if (ch == 'R' && mark[2] == 0) { mark[2] = 1; return 1; } else if (ch == 'C' && mark[3] == 0) { mark[3] = 1; return 1; } else if (ch == 'H' && mark[4] == 0) { mark[4] = 1; return 1; } else return 0; } int main(int argc, char *argv[]) { while (cin >> n) { int ans = 0; memset(s, 0, sizeof(s)); memset(mark, 0, sizeof(mark)); for (int i = 0; i < n; i++) cin >> s[i]; for (int i = 0; i < n; i++) for (int j = i + 1; j < n; j++) for (int k = j + 1; k < n; k++) { memset(mark, 0, sizeof(mark)); if (select(s[i][0]) == 0 || select(s[j][0]) == 0 || select(s[k][0]) == 0) continue; ans++; } cout << ans << endl; } return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; constexpr long long MOD = (1e9 + 7); constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; } template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } long long factorial(long long n, long long m = 2) { m = max(2LL, m); long long rtn = 1; for (long long i = m; i <= n; i++) { rtn = (rtn * i) % MOD; } return rtn; } long long modinv(long long a, long long m) { long long b = m, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= m; if (u < 0) u += m; return u; } long long modpow(long long a, long long n) { long long res = 1; while (n > 0) { if (n & 1) res = res * a % MOD; a = a * a % MOD; n >>= 1; } return res; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; vector<int> march(5); for (int i = 0; i < n; ++i) { string s; cin >> s; toupper(s[0]); if (s[0] == 'M') march[0]++; else if (s[0] == 'A') march[1]++; else if (s[0] == 'R') march[2]++; else if (s[0] == 'C') march[3]++; else if (s[0] == 'H') march[4]++; } int p[10] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2}; int q[10] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3}; int r[10] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4}; int cnt = 0; for (int i = 0; i < 10; ++i) { cnt += march[p[i]] * march[q[i]] * march[r[i]]; } cout << cnt << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main(void) { int n; int p[5] = {0}; cin >> n; for (int i = 0; i < n; i++) { string s; cin >> s; if (s[0] == 'M') p[0]++; else if (s[0] == 'A') p[1]++; else if (s[0] == 'R') p[2]++; else if (s[0] == 'C') p[3]++; else if (s[0] == 'H') p[4]++; } long long ans = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { ans += p[i] * p[j] * p[k]; } } } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using Console = System.Console; namespace Atcoder { class Program { static void Main(string[] args) { var N = long.Parse(Console.ReadLine()); long mCount = 0; long aCount = 0; long rCount = 0; long cCount = 0; long hCount = 0; for (long i = 0; i < N; i++) { switch (Console.ReadLine()[0]) { case 'M': mCount++; break; case 'A': aCount++; break; case 'R': rCount++; break; case 'C': cCount++; break; case 'H': hCount++; break; } } long ret = mCount * aCount * rCount + mCount * aCount * cCount + mCount * aCount * hCount + mCount * rCount * cCount + mCount * rCount * hCount + aCount * rCount * cCount + aCount * rCount * hCount + aCount * cCount * hCount + rCount * cCount * hCount; Console.WriteLine(ret); } } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
N= int(input()) S = ['M','A','R','C','H'] C = [0]*5 for _ in range(N): X = (input())[0] if X in S: C[S.index(X)] += 1 print(C) from itertools import permutations, combinations,combinations_with_replacement,product L = list(combinations(range(5), 3)) #nCr ans = 0 for i in L: ans += C[i[0]]*C[i[1]]*C[i[2]] print(ans)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main(void) { long long ans = 0; int march[5] = {}, N; cin >> N; 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]++; } ans += march[0] * march[1] * march[2]; ans += march[0] * march[1] * march[3]; ans += march[0] * march[1] * march[4]; ans += march[0] * march[2] * march[3]; ans += march[0] * march[2] * march[4]; ans += march[0] * march[3] * march[4]; ans += march[1] * march[2] * march[3]; ans += march[1] * march[2] * march[4]; ans += march[1] * march[3] * march[4]; ans += march[2] * march[3] * march[4]; cout << ans; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include <bits/stdc++.h> int combination(int n, int r) { if (r == 0 || r == n) return (1); else if (r == 1) return (n); return (combination(n - 1, r - 1) + combination(n - 1, r)); } int main(void) { int n; char s[1000][20]; int i, j, k; int counta[5]; long int ans = 0; for (i = 0; i < 5; i++) { counta[i] = 0; } scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%s", s[i]); if (s[i][0] == 'M') { counta[0]++; } else if (s[i][0] == 'A') { counta[1]++; } else if (s[i][0] == 'R') { counta[2]++; } else if (s[i][0] == 'C') { counta[3]++; } else if (s[i][0] == 'H') { counta[4]++; } } for (i = 0; i < 3; i++) { for (j = i + 1; j < 4; j++) { for (k = j + 1; k < 5; k++) { ans += counta[i] * counta[j] * counta[k]; } } } printf("%ld\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
java
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Scanner; import java.util.Set; import java.util.HashMap; /** * Built using CHelper plug-in * Actual solution is at the top * * @author AEoui */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; Scanner in = new Scanner(inputStream); PrintWriter out = new PrintWriter(outputStream); TaskC solver = new TaskC(); solver.solve(1, in, out); out.close(); } static class TaskC { public void solve(int testNumber, Scanner in, PrintWriter out) { HashMap<String, Integer> map = new HashMap<>(); int n = in.nextInt(); for (int i = 0; i < n; ++i) { String s = in.next(); if (isOk(s)) { map.put(s.charAt(0) + "", map.getOrDefault(s.charAt(0) + "", 0) + 1); } } if (map.keySet().size() < 3) { out.println(0); } else { int[] arr = new int[map.keySet().size()]; int i = 0; for (String s : map.keySet()) { arr[i++] = map.get(s); } long ans = 0; for (i = 0; i < arr.length; ++i) { for (int j = i + 1; j < arr.length; ++j) { for (int k = j + 1; k < arr.length; ++k) { ans += (long) arr[i] * (long) arr[j] * (long) arr[k]; } } } out.println(ans); } } private boolean isOk(String s) { char c = s.charAt(0); return c == 'M' || c == 'A' || c == 'R' || c == 'C' || 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[5]=0; int sum=0; for(int i=0;i<N;i++){ string S; cin >> S; if(S[0]=='M')m[0]+=1; else if(S[0]=='A')m[1]+=1; else if(S[0]=='R')m[2]+=1; else if(S[0]=='C')m[3]+=1; else if(S[0]=='H')m[4]+=1; } for(int i=0;i<5;i++){ for(int j=0;j<i;j++){ for(int k=0;k<j;k++){ sum+=m[i]*m[j]*m[k]; } } } cout << 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
java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int N = Integer.parseInt(br.readLine()); List<String> M = new ArrayList<String>(); List<String> A = new ArrayList<String>(); List<String> R = new ArrayList<String>(); List<String> C = new ArrayList<String>(); List<String> H = new ArrayList<String>(); String now; for (int i = 0; i < N; i++) { now = br.readLine(); switch (now.charAt(0)) { case 'M': //if (!M.contains(now)) M.add(now); break; case 'A': //if (!A.contains(now)) A.add(now); break; case 'R': //if (!R.contains(now)) R.add(now); break; case 'C': //if (!C.contains(now)) C.add(now); break; case 'H': //if (!H.contains(now)) H.add(now); break; } } List<Integer> march = new ArrayList<Integer>(Arrays.asList(M.size(), A.size(), R.size(), C.size(), H.size())); for (int i = 4; i >= 0; i--) { if (march.get(i) == 0) march.remove(i); } long count = 0; for (int a = 0; a < march.size(); a++) { for (int b = a; b < march.size(); b++) { for (int c = b; c < march.size(); c++) { if (a == b || b == c || c == a) { } else { count += march.get(a) * march.get(b) * march.get(c); } } } } System.out.println(count); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<int, int>; int main() { int n; cin >> n; int count[5] = {}; for (int i = 0; i < (n); i++) { string s; cin >> s; if (s[0] == 'M') count[0]++; if (s[0] == 'A') count[1]++; if (s[0] == 'R') count[2]++; if (s[0] == 'C') count[3]++; if (s[0] == 'H') count[4]++; } ll ans = 0; for (int i = (2); i < (5); i++) ans += count[0] * count[1] * count[i]; for (int i = (3); i < (5); i++) ans += count[0] * count[2] * count[i]; ans += count[0] * count[3] * count[4]; for (int i = (3); i < (5); i++) ans += count[1] * count[2] * count[i]; ans += count[1] * count[2] * count[4]; ans += count[2] * count[3] * count[4]; cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
import sys N=int(input()) S=[] for i in range(N): S.append(input()[0]) Count=[] Count.append(S.count("M")) Count.append(S.count("A")) Count.append(S.count("R")) Count.append(S.count("C")) Count.append(S.count("H")) Zero=Count.count(0) if(Zero>=3):print(0) elif(Zero==2): Count.remove(0) Count.remove(0) pat=1 for i in Count:pat*=i print(pat) elif(Zero==1): Count.remove(0) patA=1 for i in Count:patA*=i pat=0 for i in Count:pat+=patA//i print(pat) elif(Zero==0): patA=1 for i in Count:patA*=i pat=0 for i in range(5): for j in range(5): if(i==j):continue else: pat+=patA//Count[i]//Count[j] print(pat//2) print(Count)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> int main() { int N; scanf("%d", &N); char tmp[15]; int a = 0, b = 0, c = 0, d = 0, e = 0; for (int i = 0; i < N; ++i) { scanf("%s", tmp); if (tmp[0] == 'M') a++; if (tmp[0] == 'A') b++; if (tmp[0] == 'R') c++; if (tmp[0] == 'C') d++; if (tmp[0] == 'H') e++; } long long int answer = a * (b * (c + d + e) + c * (d + e) + d * e) + b * (c * (d + e) + d * e) + c * d * e; printf("%lld\n", 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; int mp[1000]; long long res; int n; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) { char ch[1000]; scanf("%s", ch); mp[ch[0]]++; } int P[5] = {'M', 'A', 'R', 'C', 'H'}; for (int i = 1; i <= 3; i++) for (int j = i + 1; j <= 4; j++) for (int k = j + 1; k <= 5; k++) res += mp[P[i]] * mp[P[j]] * mp[P[k]]; printf("%d\n", res); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
import itertools ans = 0 n = int(input()) group = [] for i in range(n): group.append(input()[0]) group = [x for x in group if x == "M" or x == "A" or x == "R" or x == "C" or x == "H"] for j in itertools.combinations(group,3): ans += 1 print(ans-len(set(group))+1)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
import itertools total = int(input()) lis1 = [] for x in range(total): lis1.append(input()) lis2 = [] for name in lis1: if "M" == name[0] or "A" == name[0] or "R" == name[0] or "C" == name[0] or "H" == name[0]: lis2.append(name) count = 0 for a in itertools.combinations(lis2,3): if a[0][0] != a[1][0] and a[1][0] != a[2][0] and a[0][0] != a[2][0]: count += 1 print(count)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
use std::io::prelude::*; use std::io::stdin; use std::str::FromStr; fn main() { let n: usize = read(); let mut a = [0; 5]; for _ in 0..n { match read::<String>().chars().next().unwrap() { 'M' => a[0] += 1, 'A' => a[1] += 1, 'R' => a[2] += 1, 'C' => a[3] += 1, 'H' => a[4] += 1, _ => (), } } let mut ans = 0; for i in 0..3 { for j in i + 1..4 { for k in j + 1..5 { if i != j && j != k && k != i { ans += a[i] * a[j] * a[k]; } } } } println!("{}", ans); } #[allow(dead_code)] fn read<T: FromStr>() -> T { let stdin = stdin(); let token: String = stdin .lock() .bytes() .map(|b| b.unwrap() as char) .skip_while(|c| c.is_whitespace()) .take_while(|c| !c.is_whitespace()) .collect(); token.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.io.*; import java.lang.reflect.Method; import java.math.BigDecimal; import java.util.*; import static java.lang.Math.*; public class Main { @SuppressWarnings("unchecked") public static void main(String[] args) { new A().S(); } } class A { public static int on = 1; // 0 for small , 1 for big , 2 for stdin public static int mode = 2; public void run(){ int n = ni(); int m = 0; int a = 0; int r= 0; int c = 0; int h = 0; while(n-->0){ String s = ns(); if(s.startsWith("M")){ m++; } if(s.startsWith("A")){ a++; } if(s.startsWith("R")){ r++; } if(s.startsWith("H")){ h++; } if(s.startsWith("C")){ c++; } } pl(m*a*r+m*a*h+m*r*h+a*r*h+c*h*r+c*h*a+c*h*m+c*r*a+c*r*m+c*a*m); } public static String dir = "C:\\Users\\qilu1\\Downloads\\"; public static String si = dir+"D-small-attempt0.in"; public static String so = dir+"rs.out"; public static String bi = dir+"D-large.in"; public static String bo = dir+"rb.out"; public final String[] inputs = new String[]{si,bi}; public final String[] outputs = new String[]{so,bo}; void setInput(){ try{in = new InputReader(new FileInputStream(inputs[mode]));}catch(Exception e){}} void setOutput(){ try{out = new PrintWriter(new FileOutputStream(outputs[mode]));}catch(Exception e){}} private InputReader in = new InputReader(System.in); private PrintWriter out = new PrintWriter(System.out); public void S(){if(mode!=2){setInput();setOutput();}run();out.close(); } public int ni(){return Integer.parseInt(in.ns());} public long nl(){return Long.parseLong(in.ns());} public String ns(){return in.ns();} public char[] nsl(){return in.nsl().toCharArray();} public void p(Object obj){out.print(obj);} public void ps(Object obj){p(obj);p(" ");} public void pl(Object obj){out.println(obj);} public int gcd(int a,int b){ while( b != 0 ) { int t = a % b;a = b;b = t; } return a; } } class B { public static int on = 0; public void run(){ } } class InputReader { private BufferedReader reader; private StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream), 32768); tokenizer = null; } public String nsl(){ try { return reader.readLine(); }catch(IOException e){ throw new RuntimeException(e); } } public String ns() { while (tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new StringTokenizer(reader.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken(); } } class Util{ // z[i] denotes the longest substring begin from i s[i..i+z[i]-1] matches s[0..z[i]-1] static int[] zFunction(String str){ char[] s = str.toCharArray(); int n = s.length; int[] z = new int[n]; z[0] = n; int left = -1; int right = -1; for (int i = 1; i < n; i++) { z[i] = (i >= right) ? 0 : Math.min(right - i, z[i - left]); while (i + z[i] < n && s[z[i]] == s[i + z[i]]) ++z[i]; if (i + z[i] > right) { left = i; right = i + z[i]; } } return z; } // p[i] denotes the longest substring end from i s[i-z[i]+1..i] matches s[0..z[i]-1] static int[] prefixFunction(String str){ char[] s = str.toCharArray(); int n = s.length; int[] p = new int[n]; // p[0] = 1; this should be 0, because we can not use s[0..i] to match s[0..i] int k = 0; for (int i = 1; i < n; i++) { while (k > 0 && s[i] != s[k]) k = p[k - 1]; if (s[i] == s[k]) ++k; p[i] = k; } return p; } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int Nmax = 200010; int nCr(int n, int r) { int ans = 1; for (int i = n; i > n - r; --i) { ans = ans * i; } for (int i = 1; i < r + 1; ++i) { ans = ans / i; } return ans; } int main() { long long N; cin >> N; string S[Nmax]; char c[Nmax]; int cnt[5] = {}, count = 0; for (int i = 0; i < N; i++) { cin >> S[i]; string str(S[i]); c[i] = str[0]; if (c[i] == 'M') { cnt[0]++; count++; } if (c[i] == 'A') { cnt[1]++; count++; } if (c[i] == 'R') { cnt[2]++; count++; } if (c[i] == 'C') { cnt[3]++; count++; } if (c[i] == 'H') { cnt[4]++; count++; } } if (count <= 2) cout << "0" << endl; else { count = 0; int count1 = 0; int n = 1, N = 0; for (int i = 0; i < 5; i++) if (cnt[i] >= 1) { n *= cnt[i]; N += cnt[i]; count++; if (cnt[i] == 1) count1++; } if (count1 >= 3) cout << n * nCr(count, 3) - nCr(count1, 3) << endl; else cout << n + nCr(count, 3) << endl; } return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const int INF = 1e9; int main() { int n; cin >> n; int cnt[5] = {}; for (int i = 0; i < n; i++) { string s; cin >> s; if (s[0] == 'M') cnt[0]++; if (s[0] == 'A') cnt[1]++; if (s[0] == 'R') cnt[2]++; if (s[0] == 'C') cnt[3]++; if (s[0] == 'H') cnt[4]++; } long long ans = 0; for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 4; j++) { for (int k = j + 1; k < 5; k++) { ans += cnt[i] * cnt[j] * cnt[k]; } } } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
from itertools import combinations n=int(input()) cnt=[0]*26 for i in range(n): s=input() cnt[ord(s[0])-ord('A')]+=1 ans=0 mod=10**9+7 for c1,c2,c3 in combinations(["M","A","R","C","H"],3): c1=ord(c1)-ord("A") c2=ord(c2)-ord("A") c3=ord(c3)-ord("A") ans+=cnt[c1]*cnt[c2]*cnt[c3] ans%=mod print(ans)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.io.IOException; import java.io.InputStream; import java.util.NoSuchElementException; public class Main { public static void main(String[] args) { FastScanner sc = new FastScanner(); int N = sc.nextInt(); String[] S = new String[N]; for (int i = 0; i < N; i++) S[i] = sc.next(); int[] a = new int[5]; for (int i = 0; i < N; i++) { if (S[i].charAt(0) == 'M') a[0]++; else if (S[i].charAt(0) == 'A') a[1]++; else if (S[i].charAt(0) == 'R') a[2]++; else if (S[i].charAt(0) == 'C') a[3]++; else if (S[i].charAt(0) == 'H') a[4]++; } int s = 0; s = 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]; System.out.println(s); } //以下、自作ライブラリ //最大公約数 public static long gcd(long a, long b) { if (a < b) return gcd(b, a); long c = 0; c = a % b; if (c == 0) return b; return gcd(b, c); } //最小公倍数 public static long lcm(long m, long n) { return m * n / gcd(m, n); } //素数判定 public static boolean isPrime(int n) { if (n < 2) return false; if (n == 2) return true; if (n % 2 == 0) return false; for (int i = 3; i * i <= n; i += 2) { if (n % i == 0) return false; } return true; } } //以下、高速スキャナークラス class FastScanner { private final InputStream in = System.in; private final byte[] buffer = new byte[1024]; private int ptr = 0; private int buflen = 0; private boolean hasNextByte() { if (ptr < buflen) { return true; } else { ptr = 0; try { buflen = in.read(buffer); } catch (IOException e) { e.printStackTrace(); } if (buflen <= 0) { return false; } } return true; } private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1; } private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126; } public boolean hasNext() { while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte(); } public String next() { if (!hasNext()) throw new NoSuchElementException(); StringBuilder sb = new StringBuilder(); int b = readByte(); while (isPrintableChar(b)) { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } public long nextLong() { if (!hasNext()) throw new NoSuchElementException(); long n = 0; boolean minus = false; int b = readByte(); if (b == '-') { minus = true; b = readByte(); } if (b < '0' || '9' < b) { throw new NumberFormatException(); } while (true) { if ('0' <= b && b <= '9') { n *= 10; n += b - '0'; } else if (b == -1 || !isPrintableChar(b)) { return minus ? -n : n; } else { throw new NumberFormatException(); } b = readByte(); } } public int nextInt() { long nl = nextLong(); if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException(); return (int) nl; } public double nextDouble() { return Double.parseDouble(next()); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int N; int march[5]; char pattern[5] = {'M', 'A', 'R', 'C', 'H'}; long long ans = 0; map<char, long long> m; string march_s = "MARCH"; int main() { cin >> N; for (int i = 0; i < N; ++i) { string S; cin >> S; for (int i = 0; i < N; ++i) m[S[0]]++; } for (int a = 0; a < 5; ++a) { for (int b = a + 1; b < 5; ++b) { for (int c = b + 1; c < 5; ++c) { ans += m[march_s[a]] * m[march_s[b]] * m[march_s[c]]; } } } 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 marchc[5] = {0}, n; long long int ans = 0; char name[11]; cin >> n; for (int i = 0; i < n; i++) { cin >> name; switch (name[0]) { case 'M': marchc[0]++; break; case 'A': marchc[1]++; break; case 'R': marchc[2]++; break; case 'C': marchc[3]++; break; case 'H': marchc[4]++; break; default: break; } } for (int i = 0; i < 5; i++) cout << marchc[i] << endl; for (int i = 0; i <= 2; i++) { for (int j = i + 1; j <= 3; j++) { for (int k = j + 1; k <= 4; k++) { ans += marchc[i] * marchc[j] * marchc[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
n = gets.to_i h = Hash.new(0) n.times do s = gets h[s[0]] += 1 end ans = 0 ans += h['M'] * h['A'] * h['R'] ans += h['M'] * h['A'] * h['C'] ans += h['M'] * h['A'] * h['H'] ans += h['M'] * h['R'] * h['C'] ans += h['M'] * h['R'] * h['H'] ans += h['M'] * h['C'] * h['H'] ans += h['A'] * h['R'] * h['C'] ans += h['A'] * h['C'] * h['H'] ans += h['A'] * h['C'] * h['H'] ans += h['R'] * h['C'] * h['H'] puts 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.*; import static java.lang.System.*; import java.io.*; import java.math.*; public class Main { public static void main(String[] args) { FastScanner sc = new FastScanner(); PrintWriter out = new PrintWriter(System.out); int n = sc.nextInt(); long[] march = new long[5]; long cnt = 0; for(int i = 0; i < n; i++) { char[] c = sc.next().toCharArray(); if (c[0] == 'M') {march[0]++; cnt++;} if (c[0] =='A') {march[1]++; cnt++;} if (c[0] =='R') { march[2]++; cnt++;} if (c[0] =='C') { march[3]++;cnt++;} if (c[0] =='H') { march[4]++;cnt++;} } long ans = combination(cnt,3); //ダブリ検証 for(int i = 0; i < 5; i++) { if (march[i] < 2 )continue; //2人ダブリ int count = 0; for(int j = 0; j < 5; j++) { if (i == j) continue; if(march[j] > 0) count++; } long num = combination(march[i], 2) * count; ans -= num; //3人ダブリ if( march[i] < 3) continue; ans -= combination(march[i], 3); } out.println(ans); out.close(); } //nCrの組み合わせを計算する public static long factorial(long n) { if (n <= 1) return 1; else { return n * factorial(n - 1); } } public static long combination(long n, long r) { long top = n; for (int i = 0; i < r - 1; i++) { top = top * (--n); } long bottom = factorial(r); return top / bottom; } static class FastScanner { private final InputStream in = System.in; private final byte[] buffer = new byte[1024]; private int ptr = 0; private int buflen = 0; private boolean hasNextByte() { if (ptr < buflen) { return true; }else{ ptr = 0; try { buflen = in.read(buffer); } catch (IOException e) { e.printStackTrace(); } if (buflen <= 0) { return false; } } return true; } private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;} private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;} public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();} public String next() { if (!hasNext()) throw new NoSuchElementException(); StringBuilder sb = new StringBuilder(); int b = readByte(); while(isPrintableChar(b)) { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } public long nextLong() { if (!hasNext()) throw new NoSuchElementException(); long n = 0; boolean minus = false; int b = readByte(); if (b == '-') { minus = true; b = readByte(); } if (b < '0' || '9' < b) { throw new NumberFormatException(); } while(true){ if ('0' <= b && b <= '9') { n *= 10; n += b - '0'; }else if(b == -1 || !isPrintableChar(b)){ return minus ? -n : n; }else{ throw new NumberFormatException(); } b = readByte(); } } public int nextInt() { long nl = nextLong(); if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException(); return (int) nl; } public double nextDouble() { return Double.parseDouble(next());} } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<int, int>; template <typename T> void chmin(T &a, T b) { a = min(a, b); } template <typename T> void chmax(T &a, T b) { a = max(a, b); } ll comb_count(int n, int m) { if (m == 0) return 1; if (n == 0) return 0; return (n * comb_count(n - 1, m - 1) / m); } int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; ll ans = 0; vector<int> v(5, 0); for (int i = 0; i < n; i++) { string s; cin >> s; switch (s[0]) { case 'M': v[0]++; break; case 'A': v[1]++; break; case 'R': v[2]++; break; case 'C': v[3]++; break; case 'H': v[4]++; break; default: break; } } int acc = 0, not_zero = 0; for (auto d : v) { acc += d; if (d != 0) not_zero++; } ll all_count = comb_count(acc, 3); ll minus = 0; for (auto d : v) { minus += comb_count(d, 2) * (not_zero - 1); } cout << all_count - 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
java
import java.util.ArrayList; import java.util.Scanner; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); // 人数を取得 Integer n = sc.nextInt(); // 名前を取得 ArrayList<String> m = new ArrayList<String>(); ArrayList<String> a = new ArrayList<String>(); ArrayList<String> r = new ArrayList<String>(); ArrayList<String> c = new ArrayList<String>(); ArrayList<String> h = new ArrayList<String>(); for(int i = 0; i < n ; i++){ String name = sc.next(); if("M".equals(name.substring(0,1))){ m.add(name); }else if("A".equals(name.substring(0,1))){ a.add(name); }else if("R".equals(name.substring(0,1))){ r.add(name); }else if("C".equals(name.substring(0,1))){ c.add(name); }else if("H".equals(name.substring(0,1))){ h.add(name); } } // それぞれの文字から始まる名前の数を集計 Integer mNum = m.size(); Integer aNum = a.size(); Integer rNum = r.size(); Integer cNum = c.size(); Integer hNum = h.size(); ArrayList<Integer> valid = new ArrayList<Integer>(); if(mNum != 0){ valid.add(mNum); } if(aNum != 0){ valid.add(aNum); } if(rNum != 0){ valid.add(rNum); } if(cNum != 0){ valid.add(cNum); } if(hNum != 0){ valid.add(hNum); } // 組み合わせ総数を計算(valid.size()<3の場合は組み合わせが1つも成立しないので更新なし) Integer pair = 0; if(3 == valid.size()){ Integer allMulti = 1; for(int i = 0 ; i < valid.size() ; i++){ allMulti = allMulti * valid.get(i); } pair = allMulti; }else if(4 == valid.size()){ Integer allMulti = 1; for(int i = 0; i < valid.size(); i++){ allMulti = allMulti * valid.get(i); } for(int i = 0; i < valid.size(); i++){ Integer tmp = allMulti/valid.get(i); pair = pair + tmp; } }else if(5 == valid.size()){ Integer allMulti = 1; for(int i = 0; i < valid.size(); i++){ allMulti = allMulti * valid.get(i); } for(int i = 0; i < valid.size(); i++){ Integer tmp = allMulti/valid.get(i); for(int j = 0; j < valid.size(); j++){ if(i >= j ){ tmp = tmp/valid.get(j); pair = pair + tmp; } } } } System.out.println(pair); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\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[4] = {0, 0, 1, -1}; int dx[4] = {1, -1, 0, 0}; int main() { unsigned long long M = 0, A = 0, R = 0, C = 0, H = 0; int N; string s[10001]; cin >> N; for (int i = 0; i < N; i++) cin >> s[i]; for (int i = 0; i < N; i++) { if (s[i][0] == 'M') M++; if (s[i][0] == 'A') A++; if (s[i][0] == 'R') R++; if (s[i][0] == 'C') C++; if (s[i][0] == 'H') H++; } unsigned long long ans = 0; ans = M * A * R + M * A * C + M * A * H + M * R * C + M * R * H + M * C * H + A * R * C + A * R * H + A * C * H + R * C * H; cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; long long n; string s; int a[9]; int b[128]; int main() { b['M'] = 1; b['A'] = 2; b['R'] = 3; b['C'] = 4; b['H'] = 5; scanf("%d", &n); for (int i = 0; i < n; i++) { cin >> s; for (int j = 1; j <= 5; j++) { if (b[s[0]] == j) a[j]++; } } int c[5] = {1, 2, 3, 4, 5}; int sum = 0; do { sum += a[c[0]] * a[c[1]] * a[c[2]]; } while (next_permutation(c, c + 5)); printf("%d", sum / 12); 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; inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } template <class... A> inline void dump() { cout << endl; } template <class... A> inline void dump_rest() { cout << endl; } template <class T, class... A> inline void dump_rest(const T& first, const A&... rest) { cout << endl << first; dump_rest(rest...); } template <class T, class... A> inline void dump(const T& first, const A&... rest) { cout << first; dump_rest(rest...); } template <class... A> inline void debug() { cout << endl; } template <class... A> inline void debug_rest() { cout << endl; } template <class T, class... A> inline void debug_rest(const T& first, const A&... rest) { cout << ',' << first; debug_rest(rest...); } template <class T, class... A> inline void debug(const T& first, const A&... rest) { if (0) cout << first, debug_rest(rest...); } int n; long long ans; array<vector<string>, 4> h; int main() { cin >> n; for (int i = 0; i < n; i++) { string s; cin >> s; if (s[0] == 'M') { h[0].push_back(s); } else if (s[0] == 'A') { h[1].push_back(s); } else if (s[0] == 'R') { h[2].push_back(s); } else if (s[0] == 'C') { h[3].push_back(s); } else if (s[0] == 'H') { h[4].push_back(s); } } for (int i = 0; i < 3; i++) { for (int j = 1 + i; j < 4; j++) { for (int k = 1 + j; k < 5; k++) { debug(h[i].size() * h[j].size() * h[k].size(), i, j, k); ans += h[i].size() * h[j].size() * h[k].size(); } } } dump(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
def get_i() #空白区切の入力を数値(整数)の配列で返す return gets.chomp.split(" ").map(&:to_i) end def get_f() #空白区切の入力を数値(実数)の配列で返す return gets.chomp.split(" ").map(&:to_f) end def get() #空白区切の入力を文字列の配列で返す return gets.chomp.split(" ") end def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す return gets.chomp.split("") end def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する return bool ? y : n end def array(size1,init=nil,size2=1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す if size2==1 return Array.new(size1){init} else return Array.new(size2){Array.new(size1){init}} end end N=gets.to_i s=[] N.times do|i| s_=get_nsp case s_[0] when "M" then s.push(0) when "A" then s.push(1) when "R" then s.push(2) when "C" then s.push(3) when "H" then s.push(4) end end def cal(n) ret=0 n-=2 1.upto(n) do|i| ret+=((i+1)*i/2) end return ret end def cal2(n) return (n-2)*(n-1)/2 end uniqu=array(5,0) s.each do|i| uniqu[i]+=1 end M=s.uniq.size ans=cal(M) if ans.zero? puts 0 exit end uniqu.each do|i| ans+=cal2(M)*(i-1) if i.nonzero? end puts ans
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int INF = 1001001001; int main() { string s = "MARCH"; int c[5] = {0}; int n; cin >> n; for (int i = 0; i < n; ++i) { string t; cin >> t; for (int j = 0; j < 5; ++j) { if (t[0] == s[j]) { c[j]++; } } } int ans = 0; for (int i = 0; i < 5; ++i) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { ans += c[i] * c[j] * c[k]; } } } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include <bits/stdc++.h> int main() { long long int n; char s[10]; int mozi[5] = {}; int ans = 1; int poyo = 0; int zenbu = 0; int i, j, k; scanf("%lld", &n); for (int i = 0; i < n; i++) { scanf("%s", s); if (s[0] == 'M') mozi[0]++; else if (s[0] == 'A') mozi[1]++; else if (s[0] == 'R') mozi[2]++; else if (s[0] == 'C') mozi[3]++; else if (s[0] == 'H') mozi[4]++; } for (int i = 0; i < 5; i++) { if (mozi[i] == 0) poyo++; if (poyo >= 3) { printf("0\n"); return 0; } } for (i = 0; i < 3; i++) { for (j = i + 1; j < 4; j++) { for (k = j + 1; k < 5; k++) { ans = mozi[i] * mozi[j] * mozi[k]; zenbu += ans; } } } printf("%d\n", zenbu); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> const int MGN = 8; const int ARY_SZ_MAX = 10000000; using namespace std; using ll = long long; using ull = unsigned long long; using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>; using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>; using vl = vector<ll>; using vvl = vector<vl>; using vd = vector<double>; using vs = vector<string>; using pii = pair<int, int>; using pll = pair<ll, ll>; void get_combination(vvi& C, const int Size) { C = vvi(Size + 1, vi(Size + 1, 0)); for (int i = int(0); i < int(Size + 1); ++i) { C[i][0] = 1; C[i][i] = 1; } for (int i = int(1); i < int(Size + 1); ++i) { for (int j = int(1); j < int(i); ++j) { C[i][j] = C[i - 1][j - 1] + C[i - 1][j]; } } } int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; vs S(N); for (int i = int(0); i < int(N); ++i) cin >> S[i]; string ptn = "MARCH"; map<char, int> mp; for (string s : S) { if (ptn.find(s[0]) != string::npos) mp[s[0]]++; } ll M = 0; for (char c : ptn) { M += mp[c]; } ll ans = 0; if (M >= 3) { vvi C; get_combination(C, M); ll total = C[M][3]; for (char c : ptn) { int n = mp[c]; if (n >= 3) total -= C[n][3]; if (n >= 2) total -= C[n][2] * C[M - n][1]; } ans = total; } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
one = {'M':0, 'A':0, 'R':0, 'C':0, 'H':0} n=int(input()) for i in range(n): one[input()[0]] += 1 m,a,r,c,h=one['M'],one['A'],one['R'],one['C'],one['H'] print(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; string s; long long A[5] = {0}; int Method[10][3] = {{0, 1, 2}, {0, 1, 3}, {0, 1, 4}, {0, 2, 3}, {0, 2, 4}, {0, 3, 4}, {1, 2, 3}, {1, 2, 4}, {1, 3, 4}, {2, 3, 4}}; int main() { int n; long long ans = 0; scanf("%d", &n); while (n--) { cin >> s; switch (s[0]) { case 'M': A[0]++; break; case 'A': A[1]++; break; case 'R': A[2]++; break; case 'C': A[3]++; break; case 'H': A[4]++; break; } } for (int i = 0; i < 10; i++) { ans += A[Method[i][0]] * A[Method[i][1]] * A[Method[i][2]]; } 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 (){ int N ; cin>>N; int M = 0 ; int A = 0 ; int R = 0 ; int C = 0 ; int H = 0 ; for ( int i = 0 ; i < N ; i++){ string name ; cin>>name; if(name.at(0)=='M'){ M++; } if(name.at(0)=='A'){ A++; } if(name.at(0)=='R'){ R++; } if(name.at(0)=='C'){ C++; } if(name.at(0)=='H'){ H++; } } int answer = 0 ; answer += M*A*R+M*A*C+M*A*H+M*R*C+M*R*H+M*C*H+A*R*C+A*R*H+A*C*H+R*C*H cout<<answer<<endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> int main() { int N, s[5] = {0}; std::string name; std::cin >> N; for (int i = 0; i < N; ++i) { std::cin >> name; char a = name[0]; switch (a) { case 'M': s[0]++; break; case 'A': s[1]++; break; case 'R': s[2]++; break; case 'C': s[3]++; break; case 'H': s[4]++; break; } } 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 += s[i] * s[j] * s[k]; } } std::cout << ans << std::endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.*; public class Main{ public static void main(String args[]){ Scanner sc = new Scanner(System.in); int N = sc.nextInt(); String[] S = new String[N]; for(int i = 0; i < N; i++){ S[i] = sc.next(); } sc.close(); int m = 0; int a = 0; int r = 0; int c = 0; int h = 0; for(int i = 0; i < N; i++){ if(S[i].charAt(0) == 'M') m++; if(S[i].charAt(0) == 'A') a++; if(S[i].charAt(0) == 'R') r++; if(S[i].charAt(0) == 'C') c++; if(S[i].charAt(0) == 'H') h++; } long sum = 0; 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; 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; int a[5] = {}; char str[5] = {'M', 'A', 'R', 'C', 'H'}; while (n--) { string s; cin >> s; for (int i = 0; i < 5; i++) { if (s[0] == str[i]) a[i]++; } } long long ans = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { ans += a[i] * a[j] * a[k]; } } } cout << ans << 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
import java.util.ArrayList fun main(args :Array<String>){ val N :Int = readLine()!!.toInt() val name : ArrayList<String> = ArrayList(N) var m :Int = 0 var a :Int = 0 var r :Int = 0 var c :Int = 0 var h :Int = 0 var sum :Int var ans :Int = 0 repeat(N){ name.add(readLine()!!) } for(i in name.indices){ if(name[i].get(0) == 'M'){ m++ } if(name[i].get(0) == 'A'){ a++ } if(name[i].get(0) == 'R'){ r++ } if(name[i].get(0) == 'C'){ c++ } if(name[i].get(0) == 'H'){ h++ } } //println("$m $a $r $c $h") val march : List<Int> = listOf(m ,a ,r ,c ,h) for(x in march.indices){ for(y in march.indices){ for(z in march.indices){ if(x != y && x != z && y != z){ sum = march[x] * march[y] * march[z] ans += sum sum = 0 } } } } println(ans / 6) }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; vector<char> vec{'M', 'A', 'R', 'C', 'H'}; map<char, int> mp; for (int i = 0; i < n; i++) { cin >> s; for (int j = 0; j < vec.size(); j++) { if (s[0] == vec[j]) mp[vec[j]]++; } } long long ans = 0; for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 4; j++) { for (int l = j + 1; l < 5; l++) { ans += mp[vec[i]] * mp[vec[j]] * mp[vec[l]]; } } } 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
#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; #define rep(N) for (int i = 0; i < N; i++) long get_factorial(long n){ long result = 1; for (long i = 2; i <= n; i++){ result *= i; } return result; } long get_combination(long n, long r){ return get_factorial(n) / (get_factorial(n-r) * get_factorial(r)); } long solve(vector<int> count){ long result = 0; long char_count, elem_combination; bitset<5> combination; for (long i = 0; i < (1 << 5); i++){ char_count = 0; elem_combination = 1; combination = i; for (long j = 0; j < 5; j++){ if (combination[j] == 1){ char_count++; elem_combination *= count[j]; } } if (char_count == 3){ result += elem_combination; } } return result; } int main(){ long N; cin >> N; string str; vector<long> count(5, 0); long answer; for (long i = 0; i < N; i++){ cin >> str; switch (str[0]){ case 'M': count[0]++; break; case 'A': count[1]++; break; case 'R': count[2]++; break; case 'C': count[3]++; break; case 'H': count[4]++; break; } } answer = solve(count); cout << answer << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; using VI = vector<int>; using VVI = vector<vector<int>>; using P = pair<int, int>; int main() { int n; cin >> n; string s; VI march(5, 0); for (int i = 0; i < (int)(n); i++) { cin >> s; switch (s[0]) { case 'M': march[0]++; break; case 'A': march[1]++; break; case 'R': march[2]++; break; case 'C': march[3]++; break; case 'H': march[4]++; break; default: break; } } ll ans = 0; for (int a = 0; a < (int)(3); a++) for (int b = (a + 1); b < (int)(4); b++) for (int c = (b + 1); c < (int)(5); c++) { ans += march[a] * march[b] * march[c]; } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include <bits/stdc++.h> int main() { long a[5] = {0, 0, 0, 0, 0}; int N; scanf("%d", &N); int k; for (k = 1; k <= N; k++) ; { char s[11]; scanf("%s", 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]++; } int O = 0; int s, t, r; for (s = 1; s <= 3; s++) { for (t = s + 1; t <= 4; t++) { for (r = s + 2; r <= 5; r++) { O += a[s] * a[t] * a[r]; } } } printf("%d", O); }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int64_t n, wynik = 0; cin >> n; vector<string> ee; for (int i = 0; i < n; i++) { string pom; cin >> pom; pom.erase(pom.begin() + 1, pom.end()); ee.push_back(pom); } for (int i = 0; i < n; i++) { if (ee[i] == "M") { wynik++; } } for (int i = 0; i < n; i++) { if (ee[i] == "A") { wynik++; } } for (int i = 0; i < n; i++) { if (ee[i] == "R") { wynik++; } } for (int i = 0; i < n; i++) { if (ee[i] == "C") { wynik++; } } for (int i = 0; i < n; i++) { if (ee[i] == "H") { wynik++; } } if (wynik == n) cout << n + (n % 3); if (wynik < n) cout << n - wynik; if (wynik == 0) cout << 0; 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
import scala.io.StdIn object Main extends App { val n = StdIn.readLine().toInt val linse = (0 until n).map(_ => StdIn.readLine()) val d = Array.fill[Int](5)(0) linse.foreach{ l => val idx = l.charAt(0) match { case 'M' => 0 case 'A' => 1 case 'R' => 2 case 'C' => 3 case 'H' => 4 case _ => -1 } if(0 <= idx) d(idx) += 1 } val co = List(0, 1, 2, 3, 4).combinations(3) var r = 0L co.foreach{ p => r += d(p(0))*d(p(1))*d(p(2)) } println(r) }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int n, i, m, a, r, c, h; string s[100000]; int main() { cin >> n; for (i = 0; i < n; i++) { cin >> s[i]; } for (i = 0; i < n; 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("%d", m * a * r + m * a * c + m * a * h + m * r * c + m * r * h + m * c * h + a * r * c + a * r * h + a * c * h + r * c * h); }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int P[10] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2}; int Q[10] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3}; int R[10] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4}; int main() { int n; cin >> n; int m, a, r, c, h = 0; for (int i = 0; i < n; i++) { string name; cin >> name; if (name[0] == 'M') { m++; } else if (name[0] == 'A') { a++; } else if (name[0] == 'R') { r++; } else if (name[0] == 'C') { c++; } else if (name[0] == 'H') { h++; } } int result = 0; int v[5] = {m, a, r, c, h}; for (int i = 0; i < 10; i++) { result += v[P[i]] * v[Q[i]] * v[R[i]]; } cout << result << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; template <class t, class u> void chmax(t& a, u b) { if (a < b) a = b; } template <class t, class u> void chmin(t& a, u b) { if (b < a) a = b; } template <class t> using vc = vector<t>; template <class t> using vvc = vc<vc<t>>; using pi = pair<int, int>; using vi = vc<int>; void yes() { cout << "Yes" << endl; } void no() { cout << "No" << endl; } int SIZE(string s) { return (int)s.size(); } int main() { cout << fixed << setprecision(20); int n; cin >> n; map<char, int> m; vc<char> c = {'M', 'A', 'R', 'C', 'H'}; for (int i = int(0); i < int(n); i++) { string s; cin >> s; m[s[0]]++; } long long ans = 0; for (int i = int(0); i < int(5); i++) { for (int j = int(i + 1); j < int(5); j++) { for (int k = int(j + 1); k < int(5); k++) { ans += m[c[i]] * m[c[j]] * m[c[k]]; } } } cout << ans << endl; return 0; }