Search is not available for this dataset
name
stringlengths
2
88
description
stringlengths
31
8.62k
public_tests
dict
private_tests
dict
solution_type
stringclasses
2 values
programming_language
stringclasses
5 values
solution
stringlengths
1
983k
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { string s = "MARCH"; int c[5] = {}; int n; cin >> n; for (int i = 0; i < n; i++) { string t; cin >> t; for (int j = 0; j < 5; j++) { if (t[0] == s[j]) { c[j]++; } } } long long ans = 0LL; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { ans += 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<stdio.h> int main(){ int n,i,M=0,A=0,R=0,C=,H=0; long long ans=0; char na[100000][11]; scanf("%d",n); for(i=0;i<n;i++)scanf("%s",na[i]); for(i=0;i<n;i++){ switch(na[i][0]){ case 'M':M++;break; case 'A':A++;break; case 'R':R++;break; case 'C':C++;break; case 'H':H++;break; } } ans=M*A*R+M*A*C+M*A*H+M*R*C+M*R*H+M*C*H+A*R*C+A*R*H+R*C*H; printf("%lld\n",ans); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> const int INF = 1e5; const int MOD = 1e9 + 7; using namespace std; int main() { int n; cin >> n; string s; string F = "MARCH"; int ans = 0; int count[5] = {}; for (int i = 0; i < (n); i++) { cin >> s; for (int j = 0; j < (5); j++) { if (s[0] == F[j]) { count[j]++; } } } for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 4; j++) { for (int k = j + 1; k < 5; k++) { ans += count[i] * count[j] * count[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; long ans; string s; int i, j, k; int five[5] = {}; for (i = 0; i < n; i++) { s = ""; cin >> s; if (s[0] == 'M') five[0]++; else if (s[0] == 'A') five[1]++; else if (s[0] == 'R') five[2]++; else if (s[0] == 'C') five[3]++; else if (s[0] == 'H') five[4]++; } for (i = 0; i < 3; i++) { for (j = i + 1; j < 4; j++) { for (k = j + 1; k < 5; k++) { ans += five[i] * five[j] * five[k]; } } } cout << ans; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> cnt(5); for (int i = 0; i < n; ++i) { string S; cin >> S; switch (S[0]) { case 'M': ++cnt[0]; break; case 'A': ++cnt[1]; break; case 'R': ++cnt[2]; break; case 'C': ++cnt[3]; break; case 'H': ++cnt[4]; } } long long all = 0; for (int i = 0; i < 5; ++i) all += cnt[i]; long long ans = all * (all - 1) * (all - 2) / 6; for (int i = 0; i < 5; ++i) ans -= cnt[i] * (cnt[i] - 1) / 2 * (all - 2); for (int i = 0; i < 5; ++i) ans += cnt[i] * (cnt[i] - 1) * (cnt[i] - 2) / 6; cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; long long gcd(long long x, long long y) { if (y == 0) return x; else return gcd(y, x % y); } long long lcm(long long x, long long y) { return x / gcd(x, y) * y; } int main() { int n; cin >> n; vector<int> a(5, 0); for (int i = 0; i < (n); i++) { string c; cin >> c; if (c[0] == 'M') a[0]++; else if (c[0] == 'A') a[1]++; else if (c[0] == 'R') a[2]++; else if (c[0] == 'C') a[3]++; else if (c[0] == 'H') a[4]++; } int ans = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { ans += a[i] * a[j] * a[k]; } } } cout << ans; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
from itertools import combinations n = int(input()) s = [input() for _ in range(n)] words = [w for w in s if w[0] in "MARCH"] cnt = 0 for i in combinations(words, 3): if i[0][0] != i[1][0] and i[1][0] != i[2][0] and i[0][0] != i[2][0]: cnt += 1 print(cnt)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; const int INF = (int)1e7; using p = pair<char, ll>; int n, m; 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() { cin >> n; ll mh[5] = {0}; for (int i = 0; i < n; i++) { string s; cin >> s; if (s[0] == 'M') mh[0]++; else if (s[0] == 'A') mh[1]++; else if (s[0] == 'R') mh[2]++; else if (s[0] == 'C') mh[3]++; else if (s[0] == 'H') mh[4]++; } auto _max = 0; for (int i = 0; i < 10; i++) { _max += mh[P[i]] * mh[Q[i]] * mh[R[i]]; } 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; template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } int main() { int n; cin >> n; map<char, int> mp; for (int i = 0; i < n; i++) { string s; cin >> s; mp[s[0]]++; } vector<int> p = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2}; vector<int> q = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3}; vector<int> r = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4}; vector<long long> D(4); D[0] = mp['M']; D[1] = mp['A']; D[2] = mp['R']; D[3] = mp['C']; D[4] = mp['H']; long long ans = 0; for (int i = 0; i < 9; i++) { ans += D[p[i]] * D[q[i]] * D[r[i]]; } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> template <class T> bool umax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool umin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } using namespace std; int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a); } int findGCD(int arr[], int n) { int result = arr[0]; for (int i = 1; i < n; i++) result = gcd(arr[i], result); return result; } int main() { unsigned int N; string S; int v[6] = {0}; cin >> N; for (int i = 0; i < (int)(N); i++) { cin >> S; if (S[0] == 'M') v[0]++; if (S[0] == 'A') v[1]++; if (S[0] == 'R') v[2]++; if (S[0] == 'C') v[3]++; if (S[0] == 'H') v[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 += v[i] * v[j] * v[k]; } } } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include <bits/stdc++.h> long long int compare(const void* a, const void* b) { return *(long long int*)b - *(long long int*)a; } long long int factrial(long long int a) { long long int fact = 1; for (int i = 1; i < a + 1; i++) { fact = fact * i; } return fact; } int main(void) { int n; scanf("%d", &n); char s[100000][20]; for (int i = 0; i < n; i++) { scanf("%s", s[i]); } long int e[26]; for (int i = 0; i < 26; i++) { e[i] = 0; } for (int i = 0; i < n; i++) { e[(int)s[i][0] - 65]++; } long long int f = e[0] + e[2] + e[82 - 65] + e[72 - 65] + e[77 - 65]; if (f == 0) { printf("0"); return 0; } long long int a = factrial(f), b = factrial(f - 3), c = 6, d, l; l = a / b / c; printf("%lld\n", l - (f - 2)); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n, i, m = 0, a = 0, r = 0, c = 0, h = 0; cin >> n; string s; for (i = 0; i < n; i++) { cin >> s; if (s.at(0) == 'M') m++; if (s.at(0) == 'A') a++; if (s.at(0) == 'R') r++; if (s.at(0) == 'C') c++; if (s.at(0) == 'H') h++; } 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; int main() { int N, i, j, k; int count[5] = {0}; long long int sum = 0; string S; cin >> N; for (i = 0; i < N; i++) { cin >> S; switch (S[0]) { case 'M': count[0]++; break; case 'A': count[1]++; break; case 'R': count[2]++; break; case 'C': count[3]++; break; case 'H': count[4]++; break; } } for (i = 0; i < 3; i++) { for (j = i + 1; j < 4; j++) { for (k = j + 1; k < 5; k++) { sum += count[i] * count[j] * count[k]; } } } cout << sum << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; string z; int M, A, R, C, H; long long a, b, c; int main() { while (cin >> z) { if (z[0] == 'M') M++; if (z[0] == 'A') A++; if (z[0] == 'R') R++; if (z[0] == 'C') C++; if (z[0] == 'H') H++; } a = C * H * (M + C + H), b = C * H * (M + A + R), c = (M * (C + H) * (A + R)); cout << a + b + c; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; template <class T, class U> using P = pair<T, U>; template <class T> using Heap = priority_queue<T>; template <class T> using heaP = priority_queue<T, vector<T>, greater<T>>; template <class T, class U> using umap = unordered_map<T, U>; template <class T> using uset = unordered_set<T>; template <class T> bool ChangeMax(T& a, const T& b) { if (a >= b) return false; a = b; return true; } template <class T> bool ChangeMin(T& a, const T& b) { if (a <= b) return false; a = b; return true; } template <class T, size_t N, class U> void Fill(T (&a)[N], const U& v) { fill((U*)a, (U*)(a + N), v); } template <class T> istream& operator>>(istream& is, vector<T>& v) { for (auto& e : v) is >> e; return is; } int main() { int n; cin >> n; ll a[5]; for (int i = 0; i < n; ++i) { string s; cin >> s; switch (s.front()) { 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; } } ll ans = 0; for (int i = 0; i < 5; ++i) { for (int j = i + 1; j < 5; ++j) { for (int k = j + 1; k < 5; ++k) { ans += a[i] * a[j] * a[k]; } } } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.HashMap; import java.util.Map; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); Map<Character,Long> m = new HashMap<Character,Long>(); long one = 1; for(int i=0;i<n;i++) { char[] s = sc.next().toCharArray(); m.merge(s[0], one, Long::sum); } long[] num = new long[5]; char[] march = "MARCH".toCharArray(); long sum =0; long kind =0; long subst =0; if(n<3) { System.out.println(0); return; } for(int i=0;i<5;i++) { if(m.containsKey(march[i])) { num[i] = m.get(march[i]); } if(num[i]>0) { kind++; } sum += num[i]; } if(kind ==0) { System.out.println(0); return; } for(int i=0;i<5;i++) { if(num[i]>0) { subst += num[i]*(num[i]-1)/2*(kind-1); } if(num[i]>=3) { subst += num[i]*(num[i]-1)*(num[i]-2)/6; } } long ret = sum*(sum-1)*(sum-2)/6-subst; System.out.println(ret); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N= sc.nextInt(); int a[]= new int[5]; char c[] = {'M','A','R','C','H'}; long sum =0; for (int i =0;i<N;i++) { String str = sc.next(); for (int j=0;j<c.length;j++) { if (str.charAt(0)==c[j]) { a[j] ++; break; } } } sum +=Main.count(a[0], a[1], a[2]); sum +=Main.count(a[0], a[1], a[3]); sum +=Main.count(a[0], a[1], a[4]); sum +=Main.count(a[0], a[2], a[3]); sum +=Main.count(a[0], a[2], a[4]); sum +=Main.count(a[0], a[3], a[4]); sum +=Main.count(a[1], a[2], a[3]); sum +=Main.count(a[1], a[2], a[4]); sum +=Main.count(a[1], a[3], a[4]); sum +=Main.count(a[2], a[3], a[4]); System.out.println(sum); } private static long count(int a,int b,int c) { return a*b*c; } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include<iostream> #include<string> #include<cstring> using namespace std; int name[5], n; int main(){ cin >> n; memset(name, 0, sizeof(name)); for(int i=0; i<n; i++){ string s; cin >> s; if(s[0] == 'M') name[0]++; else if(s[1] == 'A') name[1]++; else if(s[2] == 'R') name[2]++; else if(s[3] == 'C') name[3]++; else if(s[4] == 'H') name[4]++; } long long ret = 0; for(int i=0; i<5; i++){ for(int j=i+1; j<5; j++){ for(int k=j+1; k<5; k++){ ret += name[i] * name[j] * s[k]; } } } cout << ret << 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 args, char *argv[]) { int N; cin >> N; int x[5] = {0}; for (int i = 0; i < N; i++) { string s; cin >> s; if (s[0] == 'M') { x[0]++; } if (s[0] == 'A') { x[1]++; } if (s[0] == 'R') { x[2]++; } if (s[0] == 'C') { x[3]++; } if (s[0] == 'H') { x[4]++; } } long long ret = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { ret += x[i] * x[j] * x[k]; } } } cout << ret << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main(void) { int N; cin >> N; string S; int CNT[5] = {0}; for (int i = 0; i < N; i++) { cin >> S; if (S[0] == 'M') CNT[0]++; if (S[0] == 'A') CNT[1]++; if (S[0] == 'R') CNT[2]++; if (S[0] == 'C') CNT[3]++; if (S[0] == 'H') CNT[4]++; } 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 += CNT[i] * CNT[j] * CNT[k]; } } } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; template <typename T> inline void print(const T& rhs) { std::cout << " = " << rhs << std::endl; } template <typename T> inline void print(const std::vector<T>& rhs) { std::cout << " = [ "; for (uint32_t i = 0; i < rhs.size(); ++i) { std::cout << rhs[i] << ' '; } std::cout << "]" << std::endl; } template <typename T> inline void print(const std::vector<std::vector<T>>& rhs) { std::cout << " = " << std::endl; std::cout << "[[ "; for (uint32_t p = 0; p < rhs.size(); ++p) { if (p != 0) { std::cout << " [ "; } for (uint32_t q = 0; q < rhs[p].size(); ++q) { std::cout << rhs[p][q] << ' '; } if (p != rhs.size() - 1) { std::cout << "]" << std::endl; } } std::cout << "]]" << std::endl; } template <typename TL, typename TR> inline void print(const std::vector<std::pair<TR, TL>>& rhs) { std::cout << " = ["; uint32_t i = 0; for (; i < rhs.size() - 1; ++i) { std::cout << "[f: " << rhs[i].first << ", s: " << rhs[i].second << "], "; } std::cout << "[f: " << rhs[i].first << ", s: " << rhs[i].second << "]]" << endl; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int N; cin >> N; unordered_map<string, int> ht_M, ht_A, ht_R, ht_C, ht_H; for (int i = 0; i < N; ++i) { string s; cin >> s; if (s[0] == 'M') { ht_M[s] += 1; continue; } if (s[0] == 'A') { ht_A[s] += 1; continue; } if (s[0] == 'R') { ht_R[s] += 1; continue; } if (s[0] == 'C') { ht_C[s] += 1; continue; } if (s[0] == 'H') { ht_H[s] += 1; continue; } } vector<int64_t> v; if (ht_M.size() != 0) { v.push_back(ht_M.size()); } if (ht_A.size() != 0) { v.push_back(ht_A.size()); } if (ht_R.size() != 0) { v.push_back(ht_R.size()); } if (ht_C.size() != 0) { v.push_back(ht_C.size()); } if (ht_H.size() != 0) { v.push_back(ht_H.size()); } int64_t sum = 0; for (uint32_t i = 0; i < (uint32_t)1 << v.size(); ++i) { uint32_t bit = i; if (__builtin_popcount(bit) != 3) { continue; } int mul = 1; for (uint32_t i = 0; i < v.size(); ++i) { if (bit & 1) { mul *= v[i]; } bit >>= 1; } sum += mul; } cout << sum << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
program march implicit none integer :: n, i, j, k integer(8) :: cnt(5) = 0_8, ans = 0_8 character(10) :: s read(*,*) n do i = 1, n read(*,*) s j = f(ichar(s(1:1))-64) cnt(j) = cnt(j)+1_8 end do do concurrent (i = 1:5, j = 1:5, k = 1:5, i < j .and. j < k) ans = ans+cnt(i)*cnt(j)*cnt(k) end do write(*,'(i0)') ans contains integer function f(x) integer, intent(in) :: x f = x if (x == 1 .or. x == 3) return f = (164-8*x)/(28-x) end end program march
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } const long long INF = 1LL << 60; int main() { vector<long long> F(5, 0); int N; cin >> N; for (int i = 0; i < N; i++) { string s; cin >> s; if (s.front() == 'M') F[0]++; if (s.front() == 'A') F[1]++; if (s.front() == 'R') F[2]++; if (s.front() == 'C') F[3]++; if (s.front() == 'H') F[4]++; } long long ans = 0; for (int i = 0; i < N; i++) { for (int j = i + 1; j < N; j++) { for (int k = j + 1; k < N; k++) { ans += F[i] * F[j] * F[k]; } } } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; int n; vector<string> s; const string names = "MARCH"; vector<int> checked; bool checkMarch(int i) { if (checked[i] == 0) { checked[i] = 2; for (auto c : names) { if (s[i][0] == c) checked[i] = 1; } } return checked[i] == 1; } ll march() { sort(s.begin(), s.end(), [](string l, string r) { return l < r; }); ll ways = 0; for (auto i = 0; i < n - 2; i++) { auto &first = s[i]; if (!checkMarch(i)) continue; for (auto j = i + 1; j < n - 1; j++) { auto &second = s[j]; if (!checkMarch(j)) continue; if (first[0] == second[0]) continue; for (auto k = j + 1; k < n; k++) { auto &third = s[k]; if (!checkMarch(k)) continue; if (first[0] == third[0] || second[0] == third[0]) continue; ways++; } } } return ways; } int main(int argc, const char *argv[]) { cin >> n; s.assign(n, " "); for (auto &line : s) { cin >> line; } checked.assign(n, false); cout << march(); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { vector<int> num; int sum; int n; cin >> n; vector<string> s(n); sum = 0; copy_n(istream_iterator<string>(cin), n, (s).begin()); ; num.resize(5); fill(num.begin(), num.end(), 0); for (auto i = (s).begin(); i != (s).end(); i++) { if ((*i)[0] == 'M') num[0]++; else if ((*i)[0] == 'A') num[1]++; else if ((*i)[0] == 'R') num[2]++; else if ((*i)[0] == 'C') num[3]++; else if ((*i)[0] == 'H') num[4]++; } for (int i = 0; i < 33; i++) { int bits = 0; int tmp = i; while (tmp > 0) { bits += tmp & 1; tmp = tmp >> 1; } if (bits != 3) continue; int prod = 1; for (int j = 0; j < 5; j++) { if ((i & (1 << j)) != 0) { prod *= num[j]; } } sum += prod; } 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
python3
n=int(input()) s={"M":0,"A":0,"R":0,"C":0,"H":0} for i in range(n): v=input() if v[0] in s: s[v[0]]+=1 l=list(s.values()) print(l) sum=0 for a in range(5): for b in range(a+1,5): for c in range(b+1,5): sum+=l[a]*l[b]*l[c] print(sum)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const long long INF = 1e18; int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; map<char, int> m; for (int i = (int)0; i < (int)N; i++) { string s; cin >> s; m[s[0]]++; } if (N < 3) { cout << 0 << endl; return 0; } char c[] = {'M', 'A', 'R', 'C', 'H'}; long long rsl = 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++) { long long tmp = m[c[i]] * m[c[j]] * m[c[k]]; rsl += tmp; } cout << rsl << 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
use std::collections::HashMap; fn read<T: std::str::FromStr>() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() } fn read_vec<T: std::str::FromStr>() -> Vec<T> { read::<String>() .split_whitespace() .map(|e| e.parse().ok().unwrap()) .collect() } fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> { (0..n).map(|_| read_vec()).collect() } fn main(){ let n:i64 = read(); let cs = vec!['M','A','R','C','H']; let mut map = HashMap::new(); for _ in 0..n{ *map.entry(read::<String>().chars().nth(0).unwrap()).or_insert(0) += 1; } let master = cs.iter().map(|c| *map.entry(c).or_inser(0)).collect(); let f = vec![0,0,0,0,0,1,1,1,1,2]; let s = vec![1,1,1,2,2,3,2,2,3,3]; let t = vec![2,3,4,3,4,4,3,4,4,4]; let mut ans = 0; for j in 0..10 as usize{ ans += master[f[j]] * master[s[j]] * master[t[j]]; } println!("{}",ans ); }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
n = int(input()) q = [] import sys from collections import Counter import itertools for _ in range(n): s = input() a = s[0] if a =='M' or a =='A' or a =='R' or a =='C' or a =='H': q.append(a) b = Counter(q) m = 0 if len(b) < 3: print(0) sys.exit() else: p = list(itertools.combinations(q,3)) ans = 0 for i in p: if len(Counter(i)) == 3: ans += 1 print(ans)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> vc(5, 0); string s; string march = "MARCH"; for (int i = 0; i < (n); i++) { cin >> s; for (int i = 0; i < (5); i++) { if (s[0] == march[i]) { vc[i]++; break; } } s = ""; } unsigned long long 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 += vc[i] * vc[j] * vc[k]; } } } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } int main() { int N; cin >> N; vector<int> A(5, 0); for (int i = 0; i < N; ++i) { string s; cin >> s; if (s[0] == 'M') A[0]++; else if (s[0] == 'A') A[1]++; else if (s[0] == 'R') A[2]++; else if (s[0] == 'C') A[3]++; else if (s[0] == 'H') A[4]++; } long long ans = 0; ans += A[0] * A[1] * A[2]; ans += A[0] * A[1] * A[3]; ans += A[0] * A[1] * A[4]; ans += A[0] * A[2] * A[3]; ans += A[0] * A[2] * A[4]; ans += A[0] * A[3] * A[4]; ans += A[1] * A[2] * A[3]; ans += A[1] * A[2] * A[4]; ans += A[1] * A[3] * A[4]; ans += A[2] * A[3] * A[4]; cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n, i, m = 0, a = 0, r = 0, c = 0, h = 0; cin >> n; string s; for(i = 0; i < n; i++){ cin >> s; if(s.at(0) == "M") m++; if(s.at(0) == "A") a++; if(s.at(0) == "R") r++; if(s.at(0) == "C") c++; if(s.at(0) == "H") h++; } 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> int main(void) { int N; std::cin >> N; std::vector<std::string> vs(N); for (int i = 0; i < N; i++) { std::string str; std::cin >> str; vs[i] = str; } unsigned long comNum = 0; for (int i = 0; i < N; i++) { for (int j = i + 1; j < N; j++) { for (int k = j + 1; k < N; k++) { int marchFlag[5] = {0}; char march[5] = {'M', 'R', 'A', 'C', 'H'}; for (int l = 0; l < 5; l++) { if (vs[i][0] == march[l]) marchFlag[l] = 1; if (vs[j][0] == march[l]) marchFlag[l] = 1; if (vs[k][0] == march[l]) marchFlag[l] = 1; } int sumFlag = 0; for (int l = 0; l < 5; l++) { sumFlag += marchFlag[l]; } if (sumFlag == 3) comNum++; } } } std::cout << comNum << std::endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
var input = require('fs').readFileSync('/dev/stdin', 'utf8'); var inputList = input.split('\n'); var n = Number(inputList[0]); var capitalWordsList = inputList[1].split(' ').map(i => i.split('')[0]); var mNum = capitalWordsList.filter(s => s === 'M').length; var aNum = capitalWordsList.filter(s => s === 'A').length; var rNum = capitalWordsList.filter(s => s === 'R').length; var cNum = capitalWordsList.filter(s => s === 'C').length; var hNum = capitalWordsList.filter(s => s === 'H').length; var lengthList = [mNum, aNum, rNum, cNum, hNum]; var threeList = []; var chooseThreeFromList = (list) => { for (var i=0;i<5;i++) { var list1 = []; list1.push(list[i]); for (var j=i+1;j<5;j++) { var list2 = list1.slice(); list2.push(list[j]); for (var k=j+1;k<5;k++) { var list3 = list2.slice(); list3.push(list[k]); threeList.push(list3); } } } }; chooseThreeFromList(lengthList); const result = threeList.map((i) => i.reduce((a,b)=>a*b)).reduce((a,b)=>a+b); console.log(result);
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; int a1 = 0, a2 = 0, a3 = 0, a4 = 0, a5 = 0; for (int i = 0; i < n; ++i) { string s; cin >> s; if (s[0] == 'M') a1++; if (s[0] == 'A') a2++; if (s[0] == 'R') a3++; if (s[0] == 'C') a4++; if (s[0] == 'H') a5++; } long long ans = 0; ans += a1 * (a2 * (a3 + a4 + a5) + a3 * (a4 + a5) + a4 * a5); ans += a2 * (a3 * (a4 + a5) + a4 * a5); ans += a3 * a4 * a5; cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner s = new Scanner(System.in); int N = s.nextInt(); String[] strArr = new String[N]; int x = 0; for (int i = 0; i < N; i++) { strArr[i] = s.next(); } for (int i = 0; i < N - 2; i++) { if (strArr[i].substring(0, 1).equals("M") || strArr[i].substring(0, 1).equals("A") || strArr[i].substring(0, 1).equals("R") || strArr[i].substring(0, 1).equals("C") || strArr[i].substring(0, 1).equals("H")) { for (int j = i + 1; j < N - 1; j++) { if (strArr[j].substring(0, 1).equals("M") || strArr[j].substring(0, 1).equals("A") || strArr[j].substring(0, 1).equals("R") || strArr[j].substring(0, 1).equals("C") || strArr[j].substring(0, 1).equals("H")) { for (int k = j + 1; k < N; k++) { if (strArr[k].substring(0, 1).equals("M") || strArr[k].substring(0, 1).equals("A") || strArr[k].substring(0, 1).equals("R") || strArr[k].substring(0, 1).equals("C") || strArr[k].substring(0, 1).equals("H")) { if (strArr[i].substring(0, 1).equals(strArr[j].substring(0, 1)) || strArr[i].substring(0, 1).equals(strArr[k].substring(0, 1)) || strArr[j].substring(0, 1).equals(strArr[k].substring(0, 1))) { }else{ System.out.println("i:"+i+":"+strArr[i]+ " j:"+j+":"+strArr[j]+ " k:"+k+":"+strArr[k]); x++; } } } } } } } System.out.println(x); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> const int MOD = 1e9 + 7; const int dx[] = {1, -1, 0, 0}; const int dy[] = {0, 0, 1, -1}; using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; int cnt[5] = {}; string s = "MARCH"; for (int i = 0; i < n; i++) { string t; cin >> t; for (int j = 0; j < s.size(); j++) { if (t[0] == s[j]) cnt[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 += cnt[i] * cnt[j] * cnt[k]; } } } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const 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 if (name[0] == 'H') a[4]++; } long long result = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) result += 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; int main() { int N; cin >> N; int m = 0, a = 0, r = 0, c = 0, h = 0; for (int i = 0; i < N; i++) { string S; cin >> S; if (S[0] == 'M') m++; else if (S[0] == 'A') a++; else if (S[0] == 'R') r++; else if (S[0] == 'C') c++; else if (S[0] == 'H') h++; else continue; } long long ans = (long long)(m * a * r + m * a * c + m * a * h + m * r * c + m * r * h + m * c * h + a * r * c + a * r * h + r * c * h + a * 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
UNKNOWN
#include <bits/stdc++.h> int main() { long long ans = 0; int march[5] = {0}; int n, sum = 0, el = 0; scanf("%d", &n); char s[15]; for (int i = 0; i < n; i++) { scanf("%s", 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; } } 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]; } } } printf("%lld", ans); }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const long long INF = 1e+9 + 7; long long n, m, l; string s, t; long long d[200010], dp[550][550]; int main() { cin >> n; vector<string> vec; for (long long i = (0); i < (n); i++) { cin >> s; if (s[0] == 'M' || s[0] == 'A' || s[0] == 'R' || s[0] == 'C' || s[0] == 'H') vec.push_back(s); } sort((vec).begin(), (vec).end()); long long box[10], ind = 0; memset((box), (0), sizeof(box)); m = 0; for (long long i = (0); i < (vec.size()); i++) { ind++; if (vec[i][0] != vec[i + 1][0]) { box[m++] = ind; ind = 0; } } if (ind != 0) { box[m + 1] = ind; m++; } long long ans = 0; for (long long i = (0); i < (m); i++) { for (long long j = (i + 1); j < (m); j++) { for (long long k = (j + 1); k < (m); k++) { ans += box[i] * box[j] * box[k]; } } } cout << (ans) << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; long long MOD = 1000000007; int main() { int N; cin >> N; int a[5] = {0}; for (int i = 0; i < N; i++) { string s; cin >> s; if (s[0] == 'M') { a[0]++; } if (s[0] == 'A') { a[1]++; } if (s[0] == 'R') { a[2]++; } if (s[0] == 'C') { a[3]++; } if (s[0] == 'H') { a[4]++; } } 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
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; string list[N]; int count = 0; int M = 0, A = 0, R = 0, C = 0, H = 0; for (int i = 0; i < N; i++) { cin >> list[i]; switch (list[i][0]) { case 'M': M += 1; break; case 'A': A += 1; break; case 'R': R += 1; break; case 'C': C += 1; break; case 'H': H += 1; break; } } count += M * A * R; count += M * A * C; count += M * A * H; count += M * R * C; count += M * R * H; count += M * C * H; count += A * R * C; count += A * R * H; count += A * C * H; count += R * C * H; cout << count << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; string *str; str = new string[N]; int number[5]; for (int i = 0; i < 5; i++) number[i] = 0; for (int i = 0; i < N; i++) { cin >> str[i]; if (str[i][0] == 'M') number[0]++; else if (str[i][0] == 'A') number[1]++; else if (str[i][0] == 'R') number[2]++; else if (str[i][0] == 'C') number[3]++; else if (str[i][0] == 'H') number[4]++; } int p, q, r, s, t; p = number[0]; q = number[1]; r = number[2]; s = number[3]; t = number[4]; long long answer = (long long)(p * (q * (r + s + t) + r * (s + t) + s * t) + q * (r * (s + t) + s * t) + r * s * t); cout << answer << "\n"; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; int a[5]; cin >> n; for (int i = 0; i < 5; i++) a[i] = 0; for (int i = 0; i < n; i++) { string s; cin >> s; if (s[0] == 'M') a[0]++; if (s[0] == 'A') a[1]++; if (s[0] == 'R') a[2]++; if (s[0] == 'C') a[3]++; if (s[0] == 'H') a[4]++; } int num = 0; for (int i = 0; i < 5; i++) { if (a[i] == 0) continue; for (int j = i + 1; j < 5; j++) { if (a[j] == 0) continue; for (int z = j + 1; z < 5; z++) { if (a[z] == 0) continue; num += a[i] * a[j] * a[z]; } } } cout << num << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; long long x[6]; long long fact(long long n) { if (n == 0) { return 1; } return n * fact(n - 1); } int main() { long long n, m, a, b, c = 0; string s; cin >> n; for (int i = 0; i < n; i++) { cin >> s; if (s[0] == 'M') { x[1]++; } if (s[0] == 'A') { x[2]++; } if (s[0] == 'R') { x[3]++; } if (s[0] == 'C') { x[4]++; } if (s[0] == 'H') { x[5]++; } } if (s[s.size() - 1] == 'O') { cout << 7; return 0; } b = fact(x[1] + x[2] + x[3] + x[4] + x[5]); for (int i = 1; i <= 5; i++) { b = b / fact(x[i]); } cout << b / 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
python3
from collections import defaultdict from itertools import combinations N=int(input()) S=[input() for _ in range(N)] c = defaultdict(int) for i in range(N): if S[i][0] in {'M','A','R','C','H'}: c[S[i][0]] += 1 if len(c) < 3: print(0) exit() if len(c)==3: ans=0 for k in c.keys(): ans *= c[k] print(ans) exit() else: ans = 0 l = len(c) keys = list(c.keys()) for C in combinations(range(l),3): tmp = c[keys[C[0]]]*c[keys[C[1]]]*c[keys[C[2]]] ans += tmp print(ans)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
import strutils, sequtils, tables, future let N = stdin.readLine.parseInt let inis = "MARCH" var S = inis.mapIt((it, 0)).toTable for _ in (1..N): let x = stdin.readLine S[x[0]] += 1 var ans = 0 for i in (0..4): for j in ((i + 1)..4): for k in ((j + 1)..4): ans += @[i, j, k].mapIt(inis[it]).mapIt(S[it]).foldl(a * b) echo ans
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<string> s(n); for (int i = 0; i < (int)(n); i++) cin >> s.at(i); vector<int> cnt(5, 0); string march = "MARCH"; for (int i = 0; i < n; i++) { for (int j = 0; j < 5; j++) { if (s.at(i).at(0) == march.at(j)) { cnt.at(j) = cnt.at(j) + 1; } } } int answer = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { answer += cnt.at(i) * cnt.at(j) * cnt.at(k); } } } 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> long long combi(long long a) { return a * (a - 1) * (a - 2) / 6; } int main() { int n; std::cin >> n; std::vector<std::string> s(n); std::map<char, int> t; long long ans = 0; long long sum = 0; t.insert(std::make_pair('M', 0)); t.insert(std::make_pair('A', 0)); t.insert(std::make_pair('R', 0)); t.insert(std::make_pair('C', 0)); t.insert(std::make_pair('H', 0)); for (int i = 0; i < n; i++) { std::cin >> s[i]; if (s[i][0] == 'M' || s[i][0] == 'A' || s[i][0] == 'R' || s[i][0] == 'C' || s[i][0] == 'H') { t[s[i][0]]++; sum++; } } ans += t['M'] * t['A'] * t['R']; ans += t['M'] * t['A'] * t['C']; ans += t['M'] * t['A'] * t['H']; ans += t['M'] * t['R'] * t['C']; ans += t['M'] * t['R'] * t['H']; ans += t['M'] * t['C'] * t['H']; ans += t['A'] * t['R'] * t['C']; ans += t['A'] * t['R'] * t['H']; ans += t['A'] * t['C'] * t['H']; ans += t['R'] * t['C'] * t['H']; std::cout << ans << "\n"; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { long long s = 0; int n, i, a = 0, b = 0, c = 0, d = 0, e = 0; char arr, tmp[100]; scanf("%d", &n); getchar(); for (i = 0; i < n; i++) { scanf("%c", &arr); scanf("%s", tmp); getchar(); if (arr == 'M') e++; if (arr == 'A') a++; if (arr == 'R') b++; if (arr == 'C') c++; if (arr == 'H') d++; } s += a * b * c + a * b * d + a * b * e + a * c * d + a * c * e + a * d * e + b * c * d + b * c * e + b * d * e + c * d * e; printf("%lld", s); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; long long dx[] = {1, 0, -1, 0, 1, -1, -1, 1}; long long dy[] = {0, 1, 0, -1, 1, 1, -1, -1}; pair<long long, long long> a[99000]; long long d[99000]; long long ans[100000]; signed main() { cout << 7 << 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> const int INF = 1e9; const long long LLINF = 1e18; using namespace std; int dy[] = {0, 1, 0, -1}; int dx[] = {1, 0, -1, 0}; int dy8[] = {0, 1, 1, 1, 0, -1, -1, -1}; int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}; int N; string second[10101]; set<string> st[5]; int main() { cin >> N; for (int i = 0; i < N; i++) { cin >> second[i]; if (second[i][0] == 'M') { st[0].insert(second[i]); } else if (second[i][0] == 'A') { st[1].insert(second[i]); } else if (second[i][0] == 'R') { st[2].insert(second[i]); } else if (second[i][0] == 'C') { st[3].insert(second[i]); } else if (second[i][0] == 'H') { st[4].insert(second[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++) { long long tans = (long long)st[i].size() * (long long)st[j].size() * (long long)st[k].size(); ans += tans; } } } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
n=int(input()) s=[] a,b,c,d,e=0,0,0,0,0 for i in range(n): S=input() if S[0]=='M': a+=1 if S[0]=='A': b+=1 if S[0]=='R': c+=1 if S[0]=='C': d+=1 if S[0]=='H': e+=1 print(a*b*c*+a*b*d+a*b*e+a*c*d+a*c*e+a*d*e+b*c*d+b*c*e+b*d*e+c*d*e)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> int main(void) { int N; std::cin >> N; std::vector<std::string> Name; for (int i = 0; i < N; i++) { std::string n; std::cin >> n; Name.push_back(n); } int m = 0, a = 0, r = 0, c = 0, h = 0; for (int i = 0; i < N; i++) { if (Name[i][0] == 'M') { m++; } else if (Name[i][0] == 'A') { a++; } else if (Name[i][0] == 'R') { r++; } else if (Name[i][0] == 'C') { c++; } else if (Name[i][0] == 'H') { h++; } } long long answer; 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 + r * c * h + a * c * h; std::cout << answer << std::endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
n = int(input()) l = ['M','A','R','C','H'] m = [] a = [] r = [] c = [] h = [] for i in range(n): s = input() if not s[0] in l: continue if s[0] == 'M': m.append(s) elif s[0] == 'A': a.append(s) elif s[0] == 'R': r.append(s) elif s[0] == 'C': c.append(s) else: h.append(s) n = sum([len(i) for i in [m,a,r,c,h]]) all = n * (n - 1) * (n - 2) // 6 for t in [m,a,r,c,h]: i = len(t) if i >= 2: k = i * (i -1) // 2 all -= k*(n-2) elif i >= 3: k = i * (i - 1) * (i - 2) // 6 all -= k*1 print(all)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
using System; using System.Linq; using System.Collections.Generic; using System.IO; namespace atcorder2 { class Program { public static long Read() { return long.Parse(Console.ReadLine()); } public static long[] Reads() { return Console.ReadLine().Split().Select(long.Parse).ToArray(); } static void Main(string[] args) { var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; Console.SetOut(sw); var n = Read(); var s = new string[n]; var ch = new char[n][]; for (int i = 0; i < n; i++) { s[i] = Console.ReadLine(); } Array.Sort(s); var count = new int[] { 0, 0, 0, 0, 0 }; for (int i = 0; i < n; i++) { ch[i] = s[i].ToCharArray(); if (ch[i][0] == 'M') count[0]++; if (ch[i][0] == 'A') count[1]++; if (ch[i][0] == 'R') count[2]++; if (ch[i][0] == 'C') count[3]++; if (ch[i][0] == 'H') count[4]++; } 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 += count[i] * count[j] * count[k]; } } } Console.WriteLine(ans); Console.Out.Flush(); } } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include <bits/stdc++.h> int descending_compare(const void *a, const void *b) { if (*(int *)a > *(int *)b) { return -1; } else if (*(int *)a == *(int *)b) { return 0; } else { return 1; } } int ascending_compare(const void *a, const void *b) { if (*(int *)a < *(int *)b) { return -1; } else if (*(int *)a == *(int *)b) { return 0; } else { return 1; } } int lower_bound(int *a, int n, int key) { int ng, mid, ok; ng = -1, ok = n - 1; while (abs(ok - ng) > 1) { mid = (ok + ng) / 2; if (key <= a[mid]) { ok = mid; } else { ng = mid; } } if (a[ok] >= key) return ok; return n; } unsigned long gcd(unsigned long x, unsigned long y) { if (y == 0) { return x; } else if (x > y) { return gcd(y, x % y); } else { return gcd(x, y % x); } } unsigned long lcm(unsigned long x, unsigned long y) { unsigned long g = gcd(x, y); return x * y / g; } long long factorial(int x) { long long rtn = 1; int i; for (i = x; i > 1; i--) { rtn = (rtn * i); } return rtn; } long long mod = 1000000007; long long mod_pow(long long x, long long n) { long long res = 1; for (int i = 0; i < 60; i++) { if (n >> i & 1) res = res * x % mod; x = x * x % mod; } return res; } char name[100005]; int main(void) { char s[15]; int n; char march[10] = {'M', 'A', 'R', 'C', 'H'}; long long candi[5] = {0}; long long ans = 0; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf(" %s", s); for (int j = 0; j < 5; j++) { if (march[j] == s[0]) candi[j]++; } } for (int i = 0; i < 5; i++) { for (int j = i + 1; j < n; j++) { for (int k = j + 1; k < n; k++) { ans += candi[i] * candi[j] * candi[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
def conb(a, b): ans = 1 for i in range(b): ans *= (a - i) ans /= (i + 1) return ans A = {"M":0, "A":0, "R":0, "C":0, "H":0} N = int(input()) S = [input() for i in range(N)] S = [c for c in S if c[0] in A] for c in S: A[c[0]] += 1 N = len(S) if N >= 3: zen = conb(N , 3) for a in A: a = A[a] if a > 2: zen -= conb(a, 3) * (N - a) elif a > 1: zen -= (N - a) print(int(zen)) else: print(0)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; map<char, long long> mp; for (int i = 0; i < (N); ++i) { string name; cin >> name; mp[name[0]]++; } vector<int> cnt(5); string S = "MARCH"; for (int i = 0; i < (5); ++i) cnt[i] = mp[S[i]]; 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
cpp
#pragma warning(disable:4996) #include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (ll i = (ll)(a); i<(ll)(b); i++) #define REP(i,n) FOR(i,0,n) #define ALL(a) begin(a), end(a) #define TPL template #define TNM typename using ll = long long; using ull = unsigned long long; TPL<TNM T> using vec = vector<T>; TPL<TNM T> using vec2 = vec<vec<T>>; TPL<TNM T> using vec3 = vec<vec2<T>>; TPL<TNM T> using vec4 = vec<vec3<T>>; TPL<TNM T> using vec5 = vec<vec4<T>>; TPL<TNM K, TNM V> using umap = unordered_map<K, V>; TPL<TNM K, TNM V> using uset = unordered_set<K, V>; TPL <class T = ll> inline T IN() { T x; cin >> x; return x; } TPL<class T> inline void OUT(const T &x) { cout << x << "\n"; } void YESNO(bool c) { OUT(c ? "YES" : "NO"); }; void YesNo(bool c) { OUT(c ? "Yes" : "No"); }; void bOUT(bool c, string s, string t) { OUT(c ? s : t); } struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(6); } } pre__; TPL<TNM V, TNM H> void resize(vector<V>& v, const H h) { v.resize(h); } TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& v, const H& h, const T ... t) { v.resize(h); for (auto& _v : v) resize(_v, t ...); } TPL<TNM V, TNM T> void fill(V& x, const T& val) { x = val; } TPL<TNM V, TNM T> void fill(vector<V>& vec, const T& val) { for (auto& v : vec) fill(v, val); } TPL<TNM T> vector<T> make_v(size_t a) { return vector<T>(a); } TPL<TNM T, TNM... Ts> auto make_v(size_t a, size_t b, Ts... ts) { return vector<decltype(make_v<T>(b, ts...))>(a, make_v<T>(b, ts...)); } int next_combination(int sub) { int x = sub & -sub, y = sub + x; return (((sub & ~y) / x) >> 1) | y; } int main(void) { vec<int> A(5); int N; cin >> N; REP(i, N) { string S; cin >> S; switch (S[0]) { case 'M': A[0]++; break; case 'A': A[1]++; break; case 'R': A[2]++; break; case 'C': A[3]++; break; case 'H': A[4]++; break; default: break; } } sort(ALL(A)); ll ans = 0; int k = 3; int bit = (1 << k) - 1; for (; bit < (1 << N); bit = next_combination(bit)) { int x = 1; for (int i = 0; i < N; ++i) { if (bit & (1 << i)) { // i が bit に入るかどうか x *= A[i]; } } ans += x; } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> int main() { int n; char name[100000][11]; scanf("%d", &n); int i; int count[5] = {}; for (i = 0; i < n; i++) { scanf("%s", &name[i]); switch (name[i][0]) { case 'M': count[0] = 1; case 'A': count[1] = 1; case 'R': count[2] = 1; case 'C': count[3] = 1; case 'H': count[4] = 1; } } int sum = count[0] + count[1] + count[2] + count[3] + count[4]; printf("%d", sum * (sum - 1) * (sum - 2) / 6); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
5 CHOKUDAI RNG MAKOTO AOKI RINGO
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\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 int n; cin >> n; vector<string> s; string t; for (int i = 0; i < n; i++) { cin >> t; if (t[0] == 'M' || t[0] == 'A' || t[0] == 'R' || t[0] == 'C' || t[0] == 'H') { s.push_back(t); } } sort(s.begin(), s.end()); long long int num[5] = {0, 0, 0, 0, 0}; for (int i = 0; i < s.size(); i++) { if (s[i][0] == 'M') { num[0]++; } else if (s[i][0] == 'A') { num[1]++; } else if (s[i][0] == 'R') { num[2]++; } else if (s[i][0] == 'C') { num[3]++; } else if (s[i][0] == 'H') { num[4]++; } } int c = 0; for (int i = 0; i < 5; i++) { if (num[i] != 0) { c++; } } if (c < 3) { cout << 0 << endl; return 0; } long long int ans = 0; if (c == 3) { ans = 1; for (int i = 0; i < 5; i++) { if (num[i] != 0) { ans *= num[i]; } } } else { for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 4; j++) { for (int k = j + 1; k < 5; k++) { ans += num[i] * num[j] * num[k]; cout << "i:" << i << "j:" << j << "k:" << k << endl; } } } } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
n=int(input()) name={} name["M"]=0 name["A"]=0 name["R"]=0 name["C"]=0 name["H"]=0 for _ in range(n): s=list(input()) if s[0] not in name: name[s[0]]=1 else: name[s[0]]+=1 cnt=[name["M"],name["A"],name["R"],name["C"],name["H"]] ans=0 for i in range(n-2): for j in range(n-i-2): j+=i+1 for k in range(n-j-1): k+=j+1 ans+=cnt[i]*cnt[j]*cnt[k] print(ans)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int name[5] = {0, 0, 0, 0, 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 res = 0; for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 4; j++) { for (int k = j + 1; k < 5; k++) { res += name[i] * name[j] * name[k]; } } } cout << res << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.*; import static java.lang.System.*; class Main { public static final int MOD = 1000000007; public static final int INF = 1000000000; public static void main(String[] args) { Scanner sc = new Scanner(in); int N = sc.nextInt(); String S[] = new String[N]; Integer march[] = new Integer[5]; Arrays.fill(march, 0); for(int i=0; i<N; i++){ S[i] = sc.next(); if(S[i].charAt(0) == 'M') march[0]++; if(S[i].charAt(0) == 'A') march[1]++; if(S[i].charAt(0) == 'R') march[2]++; if(S[i].charAt(0) == 'C') march[3]++; if(S[i].charAt(0) == 'H') march[4]++; } long ans = 0; for(int i=0; i<5; i++){ for(int j=i+1; j<5; j++){ for(int k=j+1; k<5; k++){ ans += march[i] * march[j] * march[k]; } } } out.println(ans); } public static int gcd(int a, int b){ if(b == 0) return a; return gcd(b, a%b); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\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 operator import mul from functools import reduce def cmb(n,r): r = min(n-r,r) if r == 0: return 1 over = reduce(mul, range(n, n - r, -1)) under = reduce(mul, range(1,r + 1)) return over // under n = int(input()) s = [] for _ in range(n): _s = input() if _s[:1] == 'M': s.append('M') elif _s[:1] == 'A': s.append('A') elif _s[:1] == 'R': s.append('R') elif _s[:1] == 'C': s.append('C') elif _s[:1] == 'H': s.append('H') t = cmb(len(s),3) _m = s.count('M') _a = s.count('A') _r = s.count('R') _c = s.count('C') _h = s.count('H') m,a,r,c,h = 0,0,0,0,0 if _m >= 2: m = cmb(_m,2)*(_a+_r+_c+_h) if _a >= 2: a = cmb(_a,2)*(_m+_r+_c+_h) if _r >= 2: r = cmb(_r,2)*(_m+_a+_c+_h) if _c >= 2: c = cmb(_c,2)*(_m+_a+_r+_h) if _h >= 2: h = cmb(_h,2)*(_m+_a+_r+_c) print(t-m-a-r-c-h)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> #define REP(i, n) for(int i = 0;i < n;i++) #define REPR(i, n) for(int i = n;i >= 0;i--) #define FOR(i, m, n) for(int i = m;i < n;i++) #define FORR(i, m, n) for(int i = m;i >= n;i--) #define SORT(v, n) sort(v, v+n); #define VSORT(v) sort(v.begin(), v.end()); #define ll long long #define pb(a) push_back(a) #define INF 999999999 using namespace std; typedef pair<int, int> P; typedef pair<ll, ll> LP; typedef pair<int, P> PP; typedef pair<ll, LP> LPP; int dy[]={0, 0, 1, -1, 0}; int dx[]={1, -1, 0, 0, 0}; int P[10] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2}; int Q[10] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3}; int R[10] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4}; int main() { ll int N; string name; cin >> N; ll int M = 0, A = 0, R = 0, C = 0, H = 0; REP(i,N) { cin >> name; if(name[0] == 'M') ++M; if(name[0] == 'A') ++A; if(name[0] == 'R') ++R; if(name[0] == 'C') ++C; if(name[0] == 'H') ++H; } ll int temp[5]; temp[0] = M; temp[1] = A; temp[2] = R; temp[3] = C; temp[4] = H; ll int ans = 0; REP(i,10) ans += temp[P[i]] * temp[Q[i]] * temp[R[i]]; cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
N=int(input()) S=list(input().split()) m,a,r,c,h = 0,0,0,0,0 for s in S: if 'M' == s[0]: m+=1 elif 'A' == s[0]: a+=1 elif 'R' == s[0]: r+=1 elif 'C' == s[0]: c+=1 elif 'H' == s[0]: h+=1 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
#pragma GCC optimize("O3") #include <iostream> #include <iomanip> #include <cstdio> #include <string> #include <cstring> #include <deque> #include <list> #include <queue> #include <stack> #include <vector> #include <utility> #include <algorithm> #include <map> #include <set> #include <complex> #include <cmath> #include <limits> #include <cfloat> #include <climits> #include <ctime> #include <cassert> #include <numeric> #include <fstream> #include <functional> #include <bitset> using namespace std; using ll = long long; using P = pair<int, int>; using T = tuple<int, int, int>; template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;} template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;} constexpr int MOD = 1e9 + 7; constexpr int inf = 1e9; constexpr long long INF = 1e18; constexpr double pi = acos(-1); constexpr double EPS = 1e-10; int dx[] = {1, 0, -1, 0}; int dy[] = {0, 1, 0, -1}; int main(){ cin.tie(0); ios::sync_with_stdio(false); int n; cin>>n; vector<ll> cnt(5, 0); for(int i=0; i<n; i++){ string s; cin>>s; if(s[0] == 'M') cnt[0]++; if(s[0] == 'A') cnt[1]++; if(s[0] == 'R') cnt[2]++; if(s[0] == 'C') cnt[3]++; if(s[0] == 'H') cnt[4]++; } vector<int> v(5, 0); for(int i=2; i<5; i++) v[i] = 1; ll ans = 0; do{ ll sum = 1; for(int i=0; i<5; i++){ if(v[i]) sum *= cnt[i]; sum %= MOD; } ans += sum; ans %= MOD; }while(next_permutation(v.begin(), v.end())); cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using ll = long long; std::string s; ll n; std::vector<ll> vec(5, 0); int P[10] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2}; int Q[10] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3}; int R[10] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4}; int main() { std::cin >> n; for (int i = 0; i < n; i++) { std::cin >> s; if (s[0] == 'M') vec[0]++; else if (s[0] == 'A') vec[1]++; else if (s[0] == 'R') vec[2]++; else if (s[0] == 'C') vec[3]++; else if (s[0] == 'H') vec[4]++; } ll ans = 0; for (int i = 0; i < 10; i++) { ans += (vec[P[i]] * vec[Q[i]] * vec[R[i]]); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<string> vec(n); vector<string> ans; for (int i = 0; i < n; ++i) { cin >> vec[i]; if (vec[i][0] == 'M' || vec[i][0] == 'A' || vec[i][0] == 'R' || vec[i][0] == 'C' || vec[i][0] == 'H') { ans.push_back(vec[i]); } } int res = 0; for (int i = 0; i < ans.size(); ++i) { for (int j = i + 1; j < ans.size(); ++j) { for (int k = j + 1; k < ans.size(); ++k) { if (i != j && j != k && i != k) { if (ans[i][0] != ans[j][0] && ans[k][0] != ans[i][0] && ans[k][0] != ans[j][0]) { res++; } } } } } cout << res << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
import itertools letters = ['M','A','R','C','H'] N = int(input()) a = [] com_s = [] for i in range(N): x = input() if x[0] in letters: a.append(x) coms = list(itertools.combinations(a,3)) for com in coms: if com[0][0] != com[1][0] and com[1][0] != com[2][0] and com[2][0] != com[0]com[0]: com_s.append(com) print(len(com_s))
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\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 vll = vector<long long>; using sll = set<long long>; template <typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; } int main() { ll n, cnt = 0, size; string input; char comb[2]; cin >> n; set<char> constChar{'M', 'A', 'R', 'C', 'H'}; vector<string> s; for (long i = 0; i < n; i++) { cin >> input; if (constChar.find(input[0]) != constChar.end()) { s.push_back(input); } } size = s.size(); for (long i = 0; i < size - 2; i++) { if (constChar.find(s[i][0]) != constChar.end()) { comb[0] = s[i][0]; for (long j = i + 1; j < size - 1; j++) { if (constChar.find(s[j][0]) != constChar.end() && comb[0] != s[j][0]) { comb[1] = s[j][0]; for (long k = j + 1; k < size; k++) { if (constChar.find(s[k][0]) != constChar.end() && comb[0] != s[k][0] && comb[1] != s[k][0]) { cnt++; } } } } } } cout << cnt << '\n'; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; long long int gcd(long long int a, long long int b) { return b ? gcd(b, a % b) : a; } long long int lcm(long long int a, long long int b) { return a / gcd(a, b) * b; } const long long int INF = 1e8; signed main() { long long int N; cin >> N; string s; map<char, long long int> m; for (long long int i = 0; i < (long long int)(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.size() < 3) cout << 0; else if (m.size() == 3) { long long int ans = 1; for (auto i : m) ans *= i.second; cout << ans; } else if (m.size() == 4) { long long int a = 1; for (auto i : m) a *= i.second; long long int ans = 0; for (auto i : m) ans += a / i.second; cout << ans; } else { char ch[5] = {'M', 'A', 'R', 'C', 'H'}; long long int a = 1; for (auto i : m) a *= i.second; long long int ans = 0; for (long long int i = 0; i < 4; i++) { for (long long int j = i + 1; j < 5; j++) { ans += a / m[ch[i]] / m[ch[j]]; } } cout << ans; } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n, M = 0, A = 0, R = 0, C = 0, H = 0; cin >> n; vector<string> s(n); for (int i = 0; i < n; i++) { cin >> s[i]; if (s[i][0] == 'M') { M++; } if (s[i][0] == 'A') { A++; } if (s[i][0] == 'R') { R++; } if (s[i][0] == 'C') { C++; } if (s[i][0] == 'H') { H++; } } long long ans = M * A * R + M * A * C + M * A * H + M * R * C + M * R * H + M * C * H + A * R * C + A * R * H + A * C * H + R * C * H; cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n, cnt = 0, d[5]; cin >> n; int c[26] = {}; for (int i = 0; i < n; i++) { string s; cin >> s; c[s.at(0) - 65]++; } d[0] = c[0]; d[1] = c[2]; d[2] = c[7]; d[3] = c[12]; d[4] = c[17]; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { cnt += d[i] * d[j] * d[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; using ll = long long; int main() { int N; cin >> N; int M, A, R, C, H; M = 0; A = 0; R = 0; C = 0; H = 0; for (int i = 0; i < N; i++) { string S; cin >> S; char s = S[0]; if (s == 'M') M++; else if (s == 'A') A++; else if (s == 'R') R++; else if (s == 'C') C++; else if (s == 'H') H++; } long long ans; ll x1 = M * A * R; ll x2 = M * A * C; ll x3 = M * A * H; ll x4 = M * R * C; ll x5 = M * R * H; ll x6 = M * C * H; ll x7 = A * R * C; ll x8 = A * C * H; ll x9 = R * C * H; ll x10 = A * R * H; ans = x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10; 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.*; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int N = sc.nextInt(); String[] names = new String[N]; int counterM = 0; int counterA = 0; int counterR = 0; int counterC = 0; int counterH = 0; for(int i = 0; i < N; i++){ String name = sc.next(); names[i] = name; } for(int j = 0; j < N; j++){ if(names[j].startsWith("M")){ counterM++; }else if(names[j].startsWith("A")){ counterA++; }else if(names[j].startsWith("R")){ counterR++; }else if(names[j].startsWith("C")){ counterC++; }else if(names[j].startsWith("H")){ counterH++; } } //MAR int MAR = counterM * counterA * counterR; //MAC int MAC = counterM * counterA * counterC; //MAH int MAH = counterM * counterA * counterH; //MRC int MRC = counterM * counterR * counterC; //MRH int MRH = counterM * counterR * counterH; //MCH int MCH = counterM * counterC * counterH; //ARC int ARC = counterA * counterR * counterC; //ARH int ARH = counterA * counterR * counterH; //ACH int ACH = counterA * counterC * counterH; //RCH int RCH = counterR * counterC * counterH; int total = MAR + MAC + MAH + MRC + MRH + MCH + ARC + ARH + ACH + RCH; System.out.println(total); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n = 0; cin >> n; int m = 0; int a = 0; int r = 0; int c = 0; int h = 0; string s; for (int i = 0; i < n; i++) { cin >> s; switch (s[0]) { case 'M': m++; break; case 'A': a++; break; case 'R': r++; break; case 'C': c++; break; case 'H': h++; break; } } vector<int> v; v.push_back(m); v.push_back(a); v.push_back(r); v.push_back(c); v.push_back(h); sort(v.begin(), v.end()); long long ans = v[0]; for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 4; j++) { for (int k = j + 1; k < 5; k++) { ans += v[i] * v[j] * v[k]; } } } cout << ans << endl; 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; long long A[5] = {0, 0, 0, 0, 0}; cin >> N; vector<string> S(N); for (size_t i = 0; i < N; i++) { cin >> S.at(i); if (S.at(i).at(0) == 'M') { A[0]++; } else if (S.at(i).at(0) == 'A') { A[1]++; } else if (S.at(i).at(0) == 'R') { A[2]++; } else if (S.at(i).at(0) == 'C') { A[3]++; } else if (S.at(i).at(0) == 'H') { A[4]++; } } long long ans = 0; for (size_t i = 0; i < N; i++) { for (size_t j = i + 1; j < N; j++) { for (size_t k = j + 1; k < N; k++) { ans += (A[i]) * A[j] * A[k]; } } } cout << ans; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
using System; using System.Collections; using System.Collections.Generic; using System.Text; using System.IO; using System.Linq; using System.Diagnostics; using System.Globalization; using static System.Console; using static System.Math; namespace abc90_c { class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); List<string> list = new List<string>(); int M=0; int A=0; int R=0; int C=0; int H=0; for(int i=0; i<n; i++) { list.Add(ReadLine()); } List<string> operatedList = new List<string>(list); foreach(var item in list) { switch(item.Substring(0,1)) { case ("M"): M++; break; case ("A"): A++; break; case ("R"): R++; break; case ("C"): C++; break; case ("H"): H++; break; default: operatedList.Remove(item); break; } } int count = operatedList.Count; if(count == 0) { WriteLine(count); return; } int sum = count*(count-1)*(count-2)/6; if(M >= 2) { sum -= (count-M)*M*(M-1)/2; } if(M >= 3) { sum -= M*(M-1)*(M-2)/6; } if(A >= 2) { sum -= (count-A)*A*(A-1)/2; } if(A >= 3) { sum -= A*(A-1)*(A-2)/6; } if(R >= 2) { sum -= (count-R)*R*(R-1)/2; } if(R >= 3) { sum -= R*(R-1)*(R-2)/6; } if(C >= 2) { sum -= (count-C)*C*(C-1)/2; } if(C >= 3) { sum -= C*(C-1)*(C-2)/6; } if(H >= 2) { sum -= (count-H)*H*(H-1)/2; } if(H >= 3) { sum -= (count-H)*(H-1)*(H-2)/6; } WriteLine(sum); } } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
n=int(input()) d={'M':0,'A':0,'R':0,'C':0,'H':0} for i in range(n): s=input() if s[0]=='M': d['M']+=1 if s[0]=='A': d['A']+=1 if s[0]=='R': d['R']+=1 if s[0]=='C': d['C']+=1 if s[0]=='H': d['H']+=1 ans=0 for i,j,k in combinations('MARCH',3): ans+=d[i]*d[j]*d[k] print(ans)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> int main() { using namespace std; int N; cin >> N; vector<string> S(N); for (int i = 0; i < N; i++) cin >> S[i]; vector<char> initials = {'M', 'A', 'R', 'C', 'H'}; vector<int> times(5, 0); for (int i = 0; i < N; i++) { for (int j = 0; j < 5; j++) { if (S[i][0] == initials[j]) times[j]++; } } int ans = 0; for (int a = 0; a < 5; a++) { for (int b = a + 1; b < 5; b++) { for (int c = b + 1; c < 5; c++) { ans += times[a] * times[b] * times[c]; } } } cout << ans; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n, m, a, r, c, h; m = 0; a = 0; r = 0; c = 0; h = 0; cin >> n; string s; for (int i = 0; i < n; i++) { cin >> s; if (s[0] == 'M') m++; if (s[0] == 'A') a++; if (s[0] == 'R') r++; if (s[0] == 'C') c++; if (s[0] == 'H') h++; } cout << m * a * (r + c + h) + m * r * (c + h) + m * c * h + a * r * (c + h) + a * c * h + r * c * h << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
using System; using System.Linq; namespace ABC089_C { class Program { static void Main(string[] args) { var n = int.Parse(Console.ReadLine()); var s = new string[n].Select(x => Console.ReadLine()).Distinct().ToArray(); var m = 0; var a = 0; var r = 0; var c = 0; var h = 0; foreach (var ch in s) { if (ch[0] == 'M') m++; else if (ch[0] == 'A') a++; else if (ch[0] == 'R') r++; else if (ch[0] == 'C') c++; else if (ch[0] == 'H') h++; } long ans = 0; var d = new int[10] { 0, 0, 0, 0, 0, 0, 1, 1, 1, 2 }; var e = new int[10] { 1, 1, 1, 2, 2, 3, 2, 2, 3, 3 }; var f = new int[10] { 2, 3, 4, 3, 4, 4, 3, 4, 4, 4 }; var num = new int[5] { m, a, r, c, h }; for (var i = 0; i < 10; i++) { ans += num[d[i]] * num[e[i]] * num[f[i]]; } Console.WriteLine(ans); } } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int cs[5] = {}; char name[256]; for (int i = 0; i < n; ++i) { cin >> name; switch (name[0]) { case 'M': ++cs[0]; break; case 'A': ++cs[1]; break; case 'R': ++cs[2]; break; case 'C': ++cs[3]; break; case 'H': ++cs[4]; break; } } int r = cs[0] * cs[1] * cs[2] + cs[0] * cs[1] * cs[3] + cs[0] * cs[1] * cs[4] + cs[0] * cs[2] * cs[3] + cs[0] * cs[2] * cs[4] + cs[0] * cs[3] * cs[4] + cs[1] * cs[2] * cs[3] + cs[1] * cs[2] * cs[4] + cs[1] * cs[3] * cs[4] + cs[2] * cs[3] * cs[4]; cout << r << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ll N, x[5] = {0}, sum(0); string s[100]; cin >> N; for (ll i(0); i < N; i++) { cin >> s[i]; if (s[i][0] == 'M') x[0] += 1; else if (s[i][0] == 'A') x[1] += 1; else if (s[i][0] == 'R') x[2] += 1; else if (s[i][0] == 'C') x[3] += 1; else if (s[i][0] == 'H') x[4] += 1; } sum += x[0] * x[1] * x[2]; sum += x[0] * x[1] * x[3]; sum += x[0] * x[1] * x[4]; sum += x[0] * x[2] * x[3]; sum += x[0] * x[2] * x[4]; sum += x[0] * x[3] * x[4]; sum += x[1] * x[2] * x[3]; sum += x[1] * x[2] * x[4]; sum += x[1] * x[3] * x[4]; sum += x[2] * x[3] * x[4]; cout << sum; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; unsigned long long n, k, a, wynik, roz; int tab[100]; string b; int main() { scanf("%llu", &n); for (int i = 0; n > i; i++) { cin >> b; tab[b[0]]++; } if (tab[77] > 0) wynik++; if (tab[65] > 0) wynik++; if (tab[82] > 0) wynik++; if (tab[67] > 0) wynik++; if (tab[72] > 0) wynik++; roz = wynik * (wynik - 1) * (wynik - 2) / 6; if (roz < 0) roz = 0; if ((tab[77] > 1 and wynik > 2)) roz += (tab[77] - 1) * (wynik - 1); if ((tab[65] > 1 and wynik > 2)) roz += (tab[65] - 1) * (wynik - 1); if ((tab[82] > 1 and wynik > 2)) roz += (tab[82] - 1) * (wynik - 1); if ((tab[67] > 1 and wynik > 2)) roz += (tab[67] - 1) * (wynik - 1); if ((tab[72] > 1 and wynik > 2)) roz += (tab[72] - 1) * (wynik - 1); cout << roz; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> const int INF = 1e9; const int MOD = 1e9 + 7; using LL = long long; const LL LINF = 1e18; using namespace std; int main() { int(N); cin >> (N); vector<string> s; for (int a = 0; a < (N); ++a) { string(str); cin >> (str); s.push_back(str); } int cou[5] = {0}; map<char, int> m; for (int a = 0; a < (N); ++a) { char q = s.at(a).at(0); if (q == 'M') { cou[0]++; } if (q == 'A') { cou[1]++; } if (q == 'R') { cou[2]++; } if (q == 'C') { cou[3]++; } if (q == 'H') { cou[4]++; } } cout << (cou[0] * cou[1] * cou[2] + cou[0] * cou[1] * cou[3] + cou[0] * cou[1] * cou[4] + cou[0] * cou[2] * cou[3] + cou[0] * cou[2] * cou[4] + cou[0] * cou[3] * cou[4] + cou[1] * cou[2] * cou[3] + cou[1] * cou[2] * cou[4] + cou[1] * cou[3] * cou[4] * cou[3] * cou[4] * cou[5]) << 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; typedef long long ll; #define REP(i, n) for(int i = 0;i < n;i++) #define REPR(i, n) for(int i = n;i >= 0;i--) #define FOR(i, m, n) for(int i = m;i < n;i++) //* 便利な変数 namespace { int dx4[] = { 1, -1, 0, 0 }; int dy4[] = { 0, 0, 1, -1 }; int dx8[] = { 1, -1, 0, 0, 1, 1, -1, -1 }; int dy8[] = { 0, 0, -1, 1, -1, 1, -1, 1 }; int mDays[] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; ll A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z; const ll MOD_CONST = (ll)(1e9 + 7); } template <typename T> vector<T> INP(ll n) { vector<T> x; REP(i, n) { T tmp; cin >> tmp; x.push_back(tmp); } return move(x); } //* n文字1行の文字列を入力,一文字ごとの配列を返す vector<char> SPRIT_STRING(ll n) { string str; cin >> str; vector<char> cs(n); REP(i, n) cs[i] = str[i]; return move(cs); } //* 文字列中から文字列を検索して別の文字列に置換する void strReplace(std::string& str, const std::string& from, const std::string& to) { std::string::size_type pos = 0; while (pos = str.find(from, pos), pos != std::string::npos) { str.replace(pos, from.length(), to); pos += to.length(); } } //* 素数関連関数 namespace PrimeLib { //* 素数判定 is_prime<unsigned>(N) template<typename T, std::enable_if_t<std::is_unsigned<T>::value, std::nullptr_t> = nullptr> bool is_prime(const T n) { if (n < 4) return n == 2 || n == 3; if (n % 2 == 0 || n % 3 == 0 || (n % 6 != 1 && n % 6 != 5)) return false; for (T i = 5; i * i <= n; i += 6) if (n % i == 0 || n % (i + 2) == 0) return false; return true; } //* 素数テーブル生成 エラトステネスの篩 vector<ll> primeTable(ll n) { vector<bool> table(n - 1); vector<ll> ret; for (ll i = 0; i < n - 1; ++i) { if (table[i] == false) { ll num = i + 2; ret.push_back(i + 2); for (int j = i + num; j < n - 1; j += num) table[j] = true; } } return ret; } } //* 組み合わせ計算 inline unsigned long long NChooseK(const unsigned long long& n, const unsigned long long& k) { if (n < k) return 0; if (0 == n) return 0; if (0 == k) return 1; if (n == k) return 1; if (1 == k) return n; typedef unsigned long long value_type; value_type* table = new value_type[static_cast<std::size_t>(n * n)]; std::fill_n(table, n * n, 0); class n_choose_k_impl { public: n_choose_k_impl(value_type* table, const value_type& dimension) : table_(table), dimension_(dimension) {} inline value_type& lookup(const value_type& n, const value_type& k) { return table_[dimension_ * n + k]; } inline value_type compute(const value_type& n, const value_type& k) { if ((0 == k) || (k == n)) return 1; value_type v1 = lookup(n - 1, k - 1); if (0 == v1) v1 = lookup(n - 1, k - 1) = compute(n - 1, k - 1); value_type v2 = lookup(n - 1, k); if (0 == v2) v2 = lookup(n - 1, k) = compute(n - 1, k); return v1 + v2; } value_type* table_; value_type dimension_; }; value_type result = n_choose_k_impl(table, n).compute(n, k); delete[] table; return result; } //* 座標nx, nyがWidth,Heightの領域内にあるかどうかのチェック inline bool rangeCheck2D(int nx, int ny, int Width, int Height) { return nx >= 0 and nx < Width and ny >= 0 and ny < Height; } //* bit全探索 /* for (int i = 0; i < 1<<N; i++) { REP(j, N) if ((1 & i >> j) == 1) {;} } */ //* 値の二分探索 /* int lb = -1, ub = n; while (ub - lb > 1) { int mid = (lb + ub) / 2; if ( ) { // midが条件を満たす ub = mid; // 解の存在範囲は[lb, mid] } else { lb = mid; // 解の存在範囲は[mid, ub] } } int ans = ub; */ //* グラフのbfs 次のように格納 /* struct edge { int to, cost; }; #define MAX_V 100 vector<edge> graph[MAX_V]; */ //* 最短路 //* ベルマンフォード法 負の経路があっても動作 //* もし負の閉路があればfalseを返す /* */ //* ワーシャル-フロイド法 全点対最短路 DPが基本 負の辺があってもOK(あると) /* const int MAX_V = 101; const int inf = 100000000; // 問題に応じて設定 ll cost[MAX_V][MAX_V]; void warshallInit() { REP(i, N) { REP(j, N) { if (i == j) cost[i][j] = 0; else cost[i][j] = inf; } } } void warshallFloyd() { REP(k, N) { REP(i, N) { REP(j, N) { ll newCost = cost[i][k] + cost[k][j]; if (cost[i][j] > newCost) { cost[i][j] = newCost; } } } } } int main() { warshallInit(); // input warshallFloyd(); return 0; } */ namespace abc080d { void abc080d() { cin >> N >> C; typedef tuple<int, int, int> Show; // channel, start, end vector<Show> shows(N); REP(i, N) { int s, t, c; shows[i] = make_tuple(c, s, t); } sort(shows.begin(), shows.end()); } } namespace agc015b { void agc015b() { string str; cin >> str; ll cnt = 0; REP(i, str.size()) { if (str[i] == 'U') { cnt += 2 * i; cnt += (str.size() - (i + 1)); } else { cnt += i; cnt += 2 * (str.size() - (i + 1)); } } cout << cnt << endl; } } namespace abc088d { void abc088d() { string str; cin >> str; int ans = INT32_MAX; REP(i, str.size()) { if (i == str.size() - 1) continue; if (str[i] == str[i + 1]) continue; int n = i + 1; ans = min(max(n, (int)str.size() - n), ans); } if (ans == INT32_MAX) { cout << str.size() << endl; } else cout << ans << endl; } } namespace abc089d { static char dp[2000][2000]; bool isBlack(int dx, int dy, char c) { return c == dp[dx / K][dy / K]; } void abc089d() { cin >> N >> K; REP(i, 2 * K) { REP(j, 2 * K) { bool bx = (i / K) % 2 == 0; bool by = (j / K) % 2 == 0; if (bx and by) dp[i][j] = 'W'; else if (bx or by) dp[i][j] = 'B'; else dp[i][j] = 'W'; } } vector<pair<pair<int, int>, char>> xyc(N); REP(i, N) { cin >> xyc[i].first.first >> xyc[i].first.second >> xyc[i].second; } int ans = 0; REP(px, 2 *K) { REP(py, 2*K) { int cnt = 0; REP(i, N) { auto t = xyc[i]; if (isBlack(px + t.first.first, py + t.first.second, t.second)) cnt++; } ans = max(ans, cnt); } } cout << ans << endl; } } /* namespace arc063b { void arc063b() { scanf("%d %d %d", &N, &K, &L); static vector<int> pqs[200005]; int p, q, r, s; // リンクをソートしてDFS REP(i, K) { scanf("%d %d", &p, &q); p--; q--; pqs[q].push_back(p); pqs[p].push_back(q); } static vector<int> link[200005]; int link_num = 0; REP(i, L) { scanf("%d %d", &r, &s); r--; s--; link[r].push_back(s); link[s].push_back(r); } static bool visited[200005]; static int linked1[200005], linked2[200005]; queue<int> rest; REP(i, N) { if (visited[i]) continue; linked1[i] = i + 1; rest.push(i); while (not rest.empty()) { int current = rest.front(); rest.pop(); for (int next : pqs[current]) { if (visited[next]) continue; rest.push(next); linked1[next] = i + 1; } visited[current] = true; } } memset(&visited[0], 0, sizeof(visited)); REP(i, N) { if (visited[i]) continue; linked2[i] = i + 1; rest.push(i); while (not rest.empty()) { int current = rest.front(); rest.pop(); for (int next : link[current]) { if (visited[next]) continue; rest.push(next); linked2[next] = i + 1; } visited[current] = true; } } map<pair<int, int>, int> cnt; memset(&visited[0], 0, sizeof(visited)); REP(i, N) REP(j, N) if (not visited[i] and not visited[j] and linked1[i] == linked1[j] and linked2[i] == linked2[j]) { visited[i] = true; visited[j] = true; cnt[make_pair(linked1[i], linked2[i])]++; } REP(i, N) { cout << cnt[make_pair(linked1[i], linked2[i])]; if (i != N - 1) cout << " "; else cout << endl; } } }*/ namespace abc075d { void abc075d() { cin >> N >> K; vector<pair<int, int>> pos(N); REP(i, N) cin >> pos[i].first >> pos[i].second; ll ans = INT64_MAX; REP(i, N) { REP(j, N) { pair<int, int> p1 = pos[i], p2 = pos[j]; int cnt = 0; REP(k, N) { int x = pos[k].first, y = pos[k].second; if (k == i or k == j) cnt++; else { bool ox = false, oy = false; if (p1.first <= p2.first) { if (p1.first <= x and x <= p2.first) ox = true; } else { if (p2.first <= x and x <= p1.first) ox = true; } if (p1.second <= p2.second) { if (p1.second <= y and y <= p2.second) oy = true; } else { if (p2.second <= y and y <= p1.second) oy = true; } if (ox and oy) cnt++; } } if (cnt >= K) ans = min(ans, (ll)(abs(p1.first - p2.first) * abs(p1.second - p2.second))); } } cout << ans << endl; } } namespace abc088c { struct edge { int from, to, cost; }; bool bellmanFord(vector<edge>& es, vector<ll>& ds, int start) { for (auto& d : ds) d = INT64_MAX; ds[start] = 0; for (int n = 0; n < ds.size(); ++n) { for (int i = 0; i < es.size(); ++i) { edge e = es[i]; if (ds[e.from] != INT64_MAX and ds[e.to] > ds[e.from] + e.cost) { ds[e.to] = ds[e.from] + e.cost; if (n == ds.size() - 1) return false; } } } return true; } void abc088c() { cin >> H >> W; vector<string> field(H); vector<edge> es; REP(i, H) cin >> field[i]; REP(i, H) { REP(j, W) { if (j + 1 < W and field[i][j] == '.' and field[i][j + 1] == '.') { int p1 = i * W + j, p2 = p1 + 1; es.push_back(edge{ p1, p2, 1 }); es.push_back(edge{ p2, p1, 1 }); } if (i + 1 < H and field[i][j] == '.' and field[i + 1][j] == '.') { int p1 = i * W + j, p2 = p1 + W; es.push_back(edge{ p1, p2, 1 }); es.push_back(edge{ p2, p1, 1 }); } } } vector<ll> ds(H*W); bellmanFord(es, ds, 0); int cnt = 0; REP(i, H) { REP(j, W) { if (field[i][j] == '.') cnt++; } } if (ds[ds.size() - 1] == INT64_MAX) cout << "-1" << endl; else cout << cnt - 1 - ds[ds.size() - 1] << endl; } } // dpのテーブルが愚直には確保できない namespace abc089c { /*pair<int, int> idxtoxy(int idx) { return make_pair(idx / W, idx % W); } static ll dp[300][300]; static int idx[100000]; ll dfs(int l, int r) { if (l == r) return 0; int next = l + D; if (next > 300) return 0; if (dp[l][next] != -1) return dp[l][next]; else { auto before = idxtoxy(idx[l]); auto after = idxtoxy(idx[next]); ll ans = abs(before.first - after.first) + abs(before.second - after.second); dp[l][next] = ans; ll rest = 0; if (next != r) rest = dfs(next, r); dp[l][r] = ans + rest; return ans + rest; } } void abc089c() { REP(i, 305) { REP(j, 305) { dp[i][j] = -1; } } cin >> H >> W >> D; vector<int> as(H*W); REP(i, H) { REP(j, W) { int a; cin >> a; as[W*i + j] = a; idx[a] = W*i + j; } } cin >> Q; REP(i, Q) { int l, r; cin >> l >> r; cout << dfs(l, r) << endl; } }*/ void abc089c() { cin >> N; vector<int> cnt(5); int p1[] = { 0, 0, 0, 0, 0, 0, 1, 1, 2, 3}; int p2[] = { 1, 1, 1, 2, 2, 3, 2, 2, 3, 4}; int p3[] = { 2, 3, 4, 3, 4, 4, 3, 4, 4, 1}; REP(i, N) { string str; cin >> str; switch (str[0]) { case 'm': cnt[0]++; break; case 'a': cnt[1]++; break; case 'r': cnt[2]++; break; case 'c': cnt[3]++; break; case 'h': cnt[4]++; break; } } ll ans = 0; REP(i, 10) { ans += (ll)cnt[p1[i]] * (ll)cnt[p2[i]] * (ll)cnt[p3[i]]; } cout << ans << endl; } } int main() { cin.tie(0); ios::sync_with_stdio(false); //arc084b::arc084b(); abc089c::abc089c(); //agc007a::agc007a(); 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 N = 1e5; using namespace std; int main() { int n; string s; while (cin >> n) { int a[6] = {0}; for (int i = 1; i <= n; ++i) { cin >> s; if (s[0] == 'M') a[1]++; if (s[0] == 'A') a[2]++; if (s[0] == 'R') a[3]++; if (s[0] == 'C') a[4]++; if (s[0] == 'H') a[5]++; } long long ans = 1, cnt = 0; for (int i = 1; i <= 5; ++i) { if (a[i] != 0) cnt++; else a[i] = 1; } if (cnt <= 2) cout << 0 << endl; else if (cnt == 3) { long long ans = a[1] * a[2] * a[3] * a[4] * a[5]; cout << ans << endl; } else if (cnt == 5) { long long ans = (a[1] * a[2] * a[3]) + (a[1] * a[2] * a[4]) + (a[1] * a[2] * a[5]) + (a[1] * a[3] * a[4]) + (a[1] * a[3] * a[5]) + (a[1] * a[4] * a[5]) + (a[2] * a[3] * a[4]) + (a[2] * a[3] * a[5]) + (a[2] * a[4] * a[5]) + (a[3] * a[4] * a[5]); cout << ans << endl; } else { int m[5], k = 1; for (int i = 1; i <= 5; ++i) { if (a[i] != 0) { m[k] = a[i]; k++; } } long long ans = (m[1] * m[2] * m[3]) + (m[1] * m[2] * m[4]) + (m[1] * m[3] * m[4]) + (m[2] * m[3] * m[4]); cout << ans << endl; } } return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vvi = vector<vi>; using pii = pair<int, int>; const ll LINF = 0x1fffffffffffffff; const int INF = 0x3fffffff; const int MOD = 1000000007; void in() {} template <class T, class... U> void in(T &t, U &...u) { cin >> t; in(u...); } void solve(); int main() { cin.tie(0); ios::sync_with_stdio(0); solve(); } void solve() { int N; in(N); vector<string> S(N); for (auto &x : (S)) in(x); map<char, int> m; for (auto &x : (S)) { char c = x[0]; if (c == 'M' || c == 'A' || c == 'R' || c == 'C' || c == 'H') { m[c]++; } } vi v; for (auto &x : (m)) { v.push_back(x.second); } ll ans = 0; for (int i = (0); i < ((int)v.size() - 2); ++i) { for (int j = (i + 1); j < ((int)v.size() - 1); ++j) { for (int k = (j + 1); k < ((int)v.size()); ++k) { ans += v[i] * v[j] * v[k]; } } } cout << (ans) << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
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; char name[] = {'M', 'A', 'R', 'C', 'H'}; int cnt[5] = {}; cin >> n; for (int i = 0; i < n; i++) { string s; cin >> s; for (int j = 0; j < 5; j++) { if (s[0] == name[j]) { cnt[j]++; } } } long long ans = 0; for (int i = 0; i < 10; i++) { ans += cnt[P[i]] * cnt[Q[i]] * cnt[R[i]]; } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
import itertools n=int(input()) li=[] ans=0 for i in range(n): s=input() if s[0]=="M" or s[0]=="A" or s[0]=="R" or s[0]=="C" or s[0]=="H": li.append(s) tm=(list(itertools.combinations(li,3))) for j in tm: if j[0][0]!=j[1][0] and j[1][0]!=j[2][0] and j[2][0]!=j[0][0]: ans+=1 print(ans)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<string> name(N); map<char, int> m; for (int i = 0; i < N; i++) { cin >> name[i]; m[name[i][0]]++; } string march = "MARCH"; long long int ans = 0LL; for (int i = 0; i < march.size(); i++) { for (int j = i + 1; j < march.size(); j++) { for (int k = j + 1; k < march.size(); k++) { ans += m[march[i]] * m[march[j]] * m[march[k]]; } } } cout << ans; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 7; const int MOD = 1e9 + 7; int main() { int N; int M, A, R, C, H; cin >> N; for (int i = 0; i < N; i++) { string S; cin >> S; if (S[0] == 'M') { M++; } else if (S[0] == 'A') { A++; } else if (S[0] == 'R') { R++; } else if (S[0] == 'C') { C++; } else if (S[0] == 'H') { H++; } } long long ans = M * A * R + M * A * C + M * A * H + A * R * C + A * R * H + A * C * H + R * C * H; cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python2
N = int(raw_input()) lis = [] for i in range(N): te = raw_input() if te[0] == "M" or te[0] == "A" or te[0] == "R" or te[0] == "C" or te[0] == "H": lis.append(te) count = 0 for i in range(len(lis)): if len(lis) >= 3: a = lis[i][0] for j in range(len(lis)): if j<=i: continue if lis[j][0] != a and len(lis)>=3: b = lis[j][0] for k in range(len(lis)): if len(lis)<3: break if k<=i or k<=j: continue if lis[k][0] != a and lis[k][0] != b: c = lis[k][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
using System; using System.Collections.Generic; using System.Linq; namespace AtCoder { class Program { static void Main(string[] args) { var Instance = new Question(); Instance.Exec(); } } public class Question { public void Exec() { List<string> names = new List<string>(); long n = long.Parse(Console.ReadLine()); for (var i = 0; i < n; ++i) { names.Add(Console.ReadLine()); } Func<char, bool> checker = c => { if (c == 'M' || c == 'A' || c == 'R' || c == 'C' || c == 'H') { return true; } else { return false; } }; Func<char, char, char, bool> checker2 = (c0, c1, c2) => { bool ok = checker(c0) && checker(c1) && checker(c2); ok = ok && c0 != c1 && c0 != c2 && c1 != c2; return ok; }; int count = 0; for (var i = 0; i < names.Count; ++i) { for (var j = i + 1; j < names.Count; ++j) { for (var k = j + 1; k < names.Count; ++k) { if (checker2(names[i][0], names[j][0], names[k][0])) { ++count; } } } } Console.WriteLine($"{count}"); Console.ReadKey(); } } }