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() { int n; cin >> n; string s[100100]; int m = 0, a = 0, r = 0, c = 0, h = 0; for (int i = 0; i < n; i++) { cin >> s[i]; if (s[i][0] == 'M') m++; else if (s[i][0] == 'A') a++; else if (s[i][0] == 'R') r++; else if (s[i][0] == 'C') c++; else if (s[i][0] == 'H') h++; } int sum = 0; sum = m * a * r + m * a * c + m * a * h + m * r * c + m * r * h + m * c * h + c * a * r + h * a * r + c * a * h + c * h * r; cout << sum << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
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:Vec<i64> = cs.iter().map(|&c| *map.entry(c).or_insert(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
cpp
#include <bits/stdc++.h> using namespace std; const int INF = 999999999; const int MOD = 1000000007; int dy[] = {0, 0, 1, -1}; int dx[] = {1, -1, 0, 0}; int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } int n, d[5] = {}; const char march[] = {'M', 'A', 'R', 'C', 'H'}; int main() { cin >> n; for (int i = 0; i < 5; i++) d[i] = 0; for (int i = 0; i < n; i++) { string s; cin >> s; for (int j = 0; j < 5; j++) { if (s[0] == march[j]) d[j]++; } } long long ans = 0LL; for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 4; j++) { for (int k = j + 1; k < 5; k++) { ans += d[i] * d[j] * d[k]; } } } printf("%d\n", ans); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int Nmax = 200010; long long nCr(int n, int r) { if (n < r) return 0; long long ans = 1; for (int i = n; i > n - r; --i) { ans = ans * i; } for (int i = 1; i < r + 1; ++i) { ans = ans / i; } return ans; } int main() { long long N; cin >> N; string S[Nmax]; char c[Nmax]; int cnt[5] = {}, count = 0; for (int i = 0; i < N; i++) { cin >> S[i]; string str(S[i]); c[i] = str[0]; if (c[i] == 'M') { cnt[0]++; count++; } if (c[i] == 'A') { cnt[1]++; count++; } if (c[i] == 'R') { cnt[2]++; count++; } if (c[i] == 'C') { cnt[3]++; count++; } if (c[i] == 'H') { cnt[4]++; count++; } } count = 0; int count1 = 0; long long n = 1; for (int i = 0; i < 5; i++) if (cnt[i] >= 1) { n *= cnt[i]; count++; if (cnt[i] == 1) count1++; } cout << n * nCr(count, 3) + (1 - n) * nCr(count1, 3) << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vs = vector<string>; using vvi = vector<vi>; using vll = vector<ll>; using pii = pair<int, int>; using psi = pair<string, int>; const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; const ll mod = 1e9 + 7; int gcd(int a, int b) { if (a % b == 0) { return (b); } else { return (gcd(b, a % b)); } } int lcm(int a, int b) { return a * b / gcd(a, b); } ll N, M, K, H, W, L, R, X; string S, T; int main() { string march = "MARCH"; cin >> N; map<char, int> mp; for (long long i = 0; i < (int)N; i++) { string s; cin >> s; for (long long j = 0; j < (int)5; j++) { if (s[0] == march[j]) { mp[s[0]]++; break; } } } ll ans = 0; ll temp = 1; for (auto itr : mp) temp *= itr.second; int cnt = mp.size(); if (cnt <= 2) { cout << 0 << endl; return 0; } else if (cnt == 3) { cout << temp << endl; return 0; } else if (cnt == 4) { for (auto itr : mp) ans += temp / itr.second; cout << ans << endl; return 0; } else if (cnt == 5) { for (auto itr1 : mp) { for (auto itr2 : mp) { if (itr2 <= itr1) continue; for (auto itr3 : mp) { if (itr3 <= itr2) continue; ans += itr1.second * itr2.second * itr3.second; } } } cout << ans << endl; return 0; } return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using vi = vector<int>; using vvi = vector<vi>; using ll = long long; int MARCH(vector<string> vec, int cnt) { int M = 0, A = 0, R = 0, C = 0, H = 0; for (int i = 0; i < (int)vec.size(); i++) { if (vec.at(i).at(0) == 'M') M++; if (vec.at(i).at(0) == 'A') A++; if (vec.at(i).at(0) == 'R') R++; if (vec.at(i).at(0) == 'C') C++; if (vec.at(i).at(0) == 'H') H++; } if (M > 0) cnt++; if (A > 0) cnt++; if (R > 0) cnt++; if (C > 0) cnt++; if (H > 0) cnt++; return cnt; } int combination(int n, int k) { double ans = 1; if (k == 1) { return n / k; } ans = (double)n / k * combination(n - 1, k - 1); return ans; } int main() { int n; cin >> n; vector<string> vec(n); for (int i = 0; i < n; i++) cin >> vec.at(i); int cnt = 0; cnt = MARCH(vec, cnt); int M = 0, A = 0, R = 0, C = 0, H = 0; for (int i = 0; i < n; i++) { if (vec.at(i).at(0) == 'M') M++; if (vec.at(i).at(0) == 'A') A++; if (vec.at(i).at(0) == 'R') R++; if (vec.at(i).at(0) == 'C') C++; if (vec.at(i).at(0) == 'H') H++; } ll ans = combination(cnt, 3); if (M > 1) ans += combination(cnt - 1, 2) * (M - 1); if (A > 1) ans += combination(cnt - 1, 2) * (A - 1); if (R > 1) ans += combination(cnt - 1, 2) * (R - 1); if (C > 1) ans += combination(cnt - 1, 2) * (C - 1); if (H > 1) ans += combination(cnt - 1, 2) * (H - 1); 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 f[5]; memset(f, 0, sizeof(f)); int N; cin >> N; while (N--) { string buf; cin >> buf; switch (buf[0]) { case 'M': f[0]++; break; case 'A': f[1]++; break; case 'R': f[2]++; break; case 'C': f[3]++; break; case 'H': f[4]++; break; } } cout << (f[0] * f[1] * f[2] + f[0] * f[1] * f[3] + f[0] * f[1] * f[4] + f[0] * f[2] * f[3] + f[0] * f[2] * f[4] + f[0] * f[3] * f[4] + f[1] * f[2] * f[3] + f[1] * f[2] * f[4] + f[1] * f[3] * f[4] + f[2] * f[3] * f[4]) << 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; int names[5] = {0}; string march = "MARCH"; for (int i = 0; i < (int)(N); i++) { string str; cin >> str; for (int j = 0; j < (int)(5); j++) { if (str[0] == march[j]) names[j]++; } } unsigned int comb = 0; for (int i = 0; i < (int)(5); i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { comb += names[i] * names[j] * names[k]; } } } cout << comb << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.*; public class Main { public static void main(String args[]) { // 入力 Scanner sc = new Scanner(System.in); int n = Integer.parseInt(sc.next()); String[] s = new String[n]; for (int i = 0; i < n; i++) { s[i] = sc.next(); } // 主処理 long[] count = new long[5]; for (int i = 0; i < s.length; i++) { if (s[i].startsWith("M")) { count[0]++; } else if (s[i].startsWith("A")) { count[1]++; } else if (s[i].startsWith("R")) { count[2]++; } else if (s[i].startsWith("C")) { count[3]++; } else if (s[i].startsWith("H")) { count[4]++; } } long result; int kind = 0; for (int i = 0; i < count.length; i++) { if (0 < count[i]) { kind++; } } if (3 < kind) { result = calcCombination(kind, 3); for (int i = 0; i < count.length; i++) { while (1 < count[i]) { result += calcCombination(kind, 3) - 1; count[i]--; } } } else if (kind == 3) { result = calcCombination(kind, 3); for (int i = 0; i < count.length; i++) { if (1 < count[i]) { result *= count[i]; } } } else { result = 0; } // 出力 System.out.println(result); sc.close(); } public static long calcCombination(int n, int m) { long c = 1; m = (n - m < m ? n - m : m); for (int ns = n - m + 1, ms = 1; ms <= m; ns++, ms++) { c *= ns; c /= ms; } return 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
python3
import math def combinations_count(n, r): return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) d={'M':0,'A':0,'R':0,'C':0,'H':0} n=int(input()) for i in range(n): word=input() if word[0] in d:d[word[0]]+=1 m = sum(d.values()) max = combinations_count(m,3) if m>=3 else 0 sub = 0 for i in d.values(): if i>2: sub += combinations_count(i, 3) elif i>1: sub += combinations_count(i, 2) * (m-2) print(max - sub)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "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 std::vector<char> chars = {'M', 'A', 'R', 'C', 'H'}; int main() { int N; std::cin >> N; std::vector<int> s(26, 0); for (int i = 0; i < N; i++) { std::string S; std::cin >> S; s[S[0]]++; } int answer = 0; for (int i = 0; i < chars.size(); i++) { for (int j = i + 1; j < chars.size(); j++) { for (int k = j + 1; k < chars.size(); k++) { answer += s[chars[i]] * s[chars[j]] * s[chars[k]]; } } } std::cout << answer << std::endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
using System; using System.Collections.Generic; using System.Linq; class Program { static void Main(string[] args) { var N = int.Parse(Console.ReadLine()); long ms = 0; long As = 0; long rs = 0; long cs = 0; long hs = 0; for (int i = 0; i < N; i++) { string txt = Console.ReadLine(); if (txt[0] == 'M') { ms++; } else if (txt[0] == 'A') { As++; } else if (txt[0] == 'R') { rs++; } else if (txt[0] == 'C') { cs++; } else if (txt[0] == 'H') { hs ++; } } Console.WriteLine(ms*(As*rs+As*cs+As*hs+rs*cs+rs*hs) + As*(rs*cs+rs*hs)+rs*cs*hs); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\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; vector<string> str; for (long long i = 0; i < (long long)(N); i++) { string x; cin >> x; str.push_back(x); } sort(str.begin(), str.end()); str.erase(unique(str.begin(), str.end()), str.end()); for (long long i = 0; i < (long long)(str.size()); i++) { if (str[i][0] == 'M') { m++; } else if (str[i][0] == 'A') { a++; } else if (str[i][0] == 'R') { r++; } else if (str[i][0] == 'C') { c++; } else if (str[i][0] == 'H') { h++; } } long long int ans; ans = m * a * r + m * a * c + m * a * h + m * r * c + m * r * h + m * c * h + a * r * c + a * r * h + a * c * h + r * c * h; cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include <stdio.h> #include <stdlib.h> #include <string.h> int main(void) { char buffer[15]; if (fgets(buffer, 15, stdin) == NULL) { return 1; } int N = atoi(buffer); char (* names)[11] = malloc(sizeof(char*)*N); for (int i = 0; i < N; i++) { if (fgets(names[i], 11, stdin) == NULL) { return 1; } names[i][strlen(names[i])-1] = '\0'; } int pattern_sum = 0; const char* MARCH = "MARCH"; char *ff = NULL, *sf = NULL, *tf = NULL; for (int f = 0; f < N; f++) { for (int s = f+1; s < N; s++) { for (int t = s+1; t < N; t++) { if ((names[f][0] != names[s][0]) && (names[f][0] != names[t][0]) && (names[s][0] != names[t][0])) { ff = index(MARCH, names[f][0]); sf = index(MARCH, names[s][0]); tf = index(MARCH, names[t][0]); if (ff != NULL && sf != NULL && tf != NULL) { pattern_sum += 1; } } } } } printf("%d", pattern_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; long long gcd(long long a, long long b) { long long c; if (a < b) { c = a; a = b; b = c; } while (b != 0) { c = a % b; a = b; b = c; } return a; } long long lcm(long long a, long long b) { long long c; c = a * b / gcd(a, b); return c; } int sort_greater(int m, int n) { vector<int> a(m); for (int i = 0; i < m; i++) { cin >> a[i]; } sort(a.begin(), a.end(), greater<int>()); for (int i = 0; i < n; i++) { cout << a[i]; } return 0; } int bubblesort(int a[], int n) { int sw = 0; bool flag = 1; for (int i = 0; flag; i++) { flag = 0; for (int j = n - 1; j >= i + 1; j--) { if (a[j] < a[j - 1]) { swap(a[j], a[j - 1]); flag = 1; sw += 1; } } } return sw; } int a_z() { for (int i = 0; i <= ('Z' - 'A'); i++) { cout << (char)('A' + i); } return 0; } int selecttionsort(int a[], int n) { int t, sw = 0, minj; for (int i = 0; i < n - 1; i++) { minj = i; for (int j = 0; j < n - 1; j++) { if (a[j] < a[minj]) { minj = j; } } t = a[i]; a[i] = a[minj]; a[minj] = t; if (i != minj) sw += 1; } return sw; } bool is_prime(int x) { if (x <= 1) return false; for (int i = 2; i * i <= x; i++) { if (x % i == 0) return false; } return true; } const long long mod = 1000000007; map<string, int> memo; using P = pair<long long, long long>; long long findIndex(int value, vector<long long> a) { for (long long i = 0; i < (long long)a.size(); i++) { if (a[i] == value) { return i; } } return -1; } struct mint { long long x; mint(long long x = 0) : x(x % mod) {} mint pow(long long t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } mint inv() const { return pow(mod - 2); } mint& operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint& operator-=(const mint a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; } mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; } mint& operator/=(const mint a) { return (*this) *= a.inv(); } mint operator+(const mint a) const { mint res(*this); return res += a; } mint operator-(const mint a) const { mint res(*this); return res -= a; } mint operator*(const mint a) { mint res(*this); return res *= a; } mint operator/(const mint a) { mint res(*this); return res /= a; } }; struct combination { vector<mint> fact, ifact; combination(long long n) : fact(n + 1), ifact(n + 1) { fact[0] = 1; for (long long i = 1; i <= n; i++) fact[i] = fact[i - 1] * i; ifact[n] = fact[n].inv(); for (long long i = n; i >= 1; i--) { ifact[i - 1] = ifact[i] * i; } } mint operator()(long long n, long long k) { if (k < 0 || k > n) return 0; return fact[n] * ifact[k] * ifact[n - k]; } }; template <typename T> struct BIT { int n; vector<T> d; BIT(int n = 0) : n(n), d(n + 1) {} void add(int i, T x = 1) { for (i++; i <= n; i += i & -i) { d[i] += x; } } T sum(int i) { T x = 0; for (i++; i; i -= i & -i) { x += d[i]; } return x; } T sum(int l, int r) { return sum(r - 1) - sum(l - 1); } }; const int INF = 1001001001; const int M = 1000001; string f(long long n) { if (n == 0) return ""; n--; return f(n / 26) + string(1, 'a' + n % 26); } string x(long long n) { string s = ""; if (n == 0) return ""; n--; s += 'a' + n % 26; return x(n / 26) + s; } long long yakusuu(long long x) { long long anss = 1; vector<long long> a(x + 1); long long num = x; for (long long i = 2; i <= x; i++) { while (num % i == 0) { a.at(i)++; num /= i; } } for (long long i = 2; i <= x; i++) { anss *= a[i] + 1; } return anss; } int main() { int n, m = 0, a = 0, r = 0, c = 0, h = 0; cin >> n; vector<int> cn; for (long long i = 0; i < (long long)(n); i++) { string s; cin >> s; if (s[0] == 'M') m++; if (s[0] == 'A') a++; if (s[0] == 'R') r++; if (s[0] == 'C') c++; if (s[0] == 'H') h++; } cn.push_back(m); cn.push_back(a); cn.push_back(r); cn.push_back(c); cn.push_back(h); long long ans = 0; for (int i = 0; i < (1 << 5); i++) { vector<int> s; for (int j = 0; j < 5; j++) { if (i & (1 << j)) { s.push_back(j); } } if (s.size() != 3) continue; ans += cn[s[0]] * cn[s[1]] * cn[s[2]]; } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main(){ int N; cin >> N; int m = 0; int a = 0; int r = 0; int c = 0; int h = 0; int x; string s; for(int i = 0; i < N; i++){ cin >> s; if(s[0] == "M"){ m++; } else if(s[0] == "A"){ a++; } else if(s[0] == "R"){ r++; } else if(s[0] == "C"){ c++; } else if(s[0] == "H"){ h++; } } x = m*a*r + m*a*c + m*a*h + m*r*c + m*r*h + m*c*h + a*r*c + a*r*h + a*c*h + r*c*h; cout << x << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; signed main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; int march[5] = {}; for (int i = (int)0; i < (int)n; ++i) { string s; cin >> s; if (s[0] == 'M') march[0]++; else if (s[0] == 'A') march[1]++; else if (s[0] == 'R') march[2]++; else if (s[0] == 'C') march[3]++; else if (s[0] == 'H') march[4]++; } long long ans = 0; for (int i = (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 = march[i] * march[j] * march[k]; ans += tmp; } } } cout << ans << '\n'; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include<iostream> #include<string> #include<vector> #include<algorithm> #include<bitset> #include<map> #include<stack> #include<queue> #include<iomanip> using namespace std; #define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++) #define rep(i, n) repr(i, 0, n) #define INF 2e9 #define MOD 1e9+7 #define LINF (long long)4e18 int main(){ int N; cin >> N; vector<string> S(N); rep(i,N)cih >> S[i]; long long ans = 0; vector<int> T(5); rep(i,N){ if(S[i][0] == 'M') T[0]++; if(S[i][0] == 'A') T[1]++; if(S[i][0] == 'R') T[2]++; if(S[i][0] == 'C') T[3]++; if(S[i][0] == 'H') T[4]++; } rep(i,3){ repr(j,i+1,4){ repr(k,j+1,5){ ans += (long long)(T[i] * T[j] * T[k]); } } } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; struct mint { long long x; mint(long long x = 0) : x((x % mod + mod) % mod) {} mint operator-() const { return mint(-x); } mint& operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint& operator-=(const mint a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; } mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; } mint operator+(const mint a) const { return mint(*this) += a; } mint operator-(const mint a) const { return mint(*this) -= a; } mint operator*(const mint a) const { return mint(*this) *= a; } mint pow(long long t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } mint inv() const { return pow(mod - 2); } mint& operator/=(const mint a) { return *this *= a.inv(); } mint operator/(const mint a) const { return mint(*this) /= a; } }; istream& operator>>(istream& is, mint& a) { return is >> a.x; } ostream& operator<<(ostream& os, const mint& a) { return os << a.x; } long long kaijou(long long x) { long long sum = 1; for (int i = 1; i <= x; ++i) { sum *= i; } return sum; } int main() { int n; cin >> n; vector<int> a(6); for (int i = 0; i < (n); i++) { string s; cin >> s; char sin = s[0]; if (sin == 'M') a.at(0)++; else if (sin == 'A') a.at(1)++; else if (sin == 'R') a.at(2)++; else if (sin == 'C') a.at(3)++; else if (sin == 'H') a.at(4)++; } long long x = 0; long long y = 0; for (int i = 0; i < (5); i++) { if (a.at(i) != 0) x++; if (a.at(i) > 1) y++; } if (x < 3) { cout << 0 << endl; return 0; } long long ans = 0; for (int i = 0; i < (3); i++) { for (int j = i + 1; j < 4; j++) { for (int k = j + 1; k < 5; k++) { if (a.at(i) == 0 || a.at(j) == 0 || a.at(k) == 0) continue; ans += a.at(i) * a.at(j) * a.at(k); } } } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include<iostream> #include<string.h> using namespace std; int main(){ long long int N; string S[110000]; char c[110000]; int a = 0; for(int i = 0; i < N; i++){ cin >> S[i]; c[i] = S[i][1]; } for(int i = 0; i < N; i++){ if(strcmp(c[i],'M')==0 || strcmp(c[i],'A')==0 || strcmp(c[i],'R')==0 || strcmp(c[i],'C')==0 || strcmp(c[i],'H')==0){ for(int j = i+1; j < N; j++){ if(strcmp(c[j],'M')==0 || strcmp(c[j],'A')==0 || strcmp(c[j],'R')==0 || strcmp(c[j],'C')==0 || strcmp(c[j],'H')==0 && strcmp(c[i],c[j])==0){ for(int k = j+1; k < N; k++){ if(strcmp(c[k],'M')==0 || strcmp(c[k],'A')==0 || strcmp(c[k],'R')==0 || strcmp(c[k],'H')==0 || strcmp(c[k],'C')==0 && strcmp(c[k],c[i])!=0 && strcmp(c[k],c[j])!=0){ a += 1; } } } } } } cout << a << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int N = in.nextInt(); in.nextLine(); int[] ary = new int[5]; while( N-- > 0 ) { char c = in.nextLine().charAt(0); switch(c) { case 'M': ary[0]++; break; case 'A': ary[1]++; break; case 'R': ary[2]++; break; case 'C': ary[3]++; break; case 'H': ary[4]++; break; default: break; } } long total = 0; for( int i = 0; i < 5; i++ ) { for( int j = i+1; j < 5; j++ ) { for( int k = j+1 ; k < 5; k++ ) { total += ary[i]*ary[j]*ary[k]; } } } 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; map<char, int> mp; int main() { int n, i; long long res = 0; string s; cin >> n; for (i = 0; i < n; i++) { cin >> s; mp[s[0]]++; } res = (long long)mp['R'] * mp['C'] * mp['H'] + mp['A'] * mp['C'] * mp['H'] + mp['M'] * mp['C'] * mp['H'] + mp['A'] * mp['R'] * mp['H'] + mp['M'] * mp['R'] * mp['H'] + mp['M'] * mp['A'] * mp['H'] + mp['A'] * mp['R'] * mp['C'] + mp['M'] * mp['R'] * mp['C'] + mp['M'] * mp['A'] * mp['C'] + mp['M'] * mp['A'] * mp['R']; cout << res << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { long ans = 0; int N; cin >> N; string st; vector<pair<char, int> > input(5); (input[0].first, input[0].second) = ('M', 0); input[1].first, input[2].second = ("A", 0); input[2].first, input[2].second = ("R", 0); input[3].first, input[3].second = ("C", 0); input[4].first, input[4].second = ("H", 0); for (int i = 0; i < N; i++) { cin >> st; if (st[0] == 'M') input[0].second++; if (st[0] == 'A') input[1].second++; if (st[0] == 'R') input[2].second++; if (st[0] == 'C') input[3].second++; if (st[0] == 'H') input[4].second++; } for (int i = 0; i <= 2; i++) { for (int j = i + 1; j <= 3; j++) { for (int k = j + 1; k < 4; k++) { ans += input[i].second * input[j].second * input[k].second; } } } 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> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } } int main() { int n; cin >> n; vector<string> s(n); int m = 0, a = 0, r = 0, c = 0, h = 0; for (long long i = 0; i < (long long)(n); ++i) { cin >> s[i]; switch (s[i][0]) { case 'M': m++; break; case 'A': a++; break; case 'R': r++; break; case 'C': c++; break; case 'H': h++; break; default: break; } } int ans = 0; ans += m * a * r; ans += m * a * c; ans += m * a * h; ans += m * r * c; ans += m * r * h; ans += m * c * h; ans += a * r * c; ans += a * r * h; ans += a * c * h; ans += r * c * h; cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
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 }; if (m+a+r+c+h < 3) { Console.WriteLine(0); return; } else { 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
python3
N = int(input()) Sdic = {} L = ["M","A","R","C","H"] for i in L: Sdic[i] = [] tN = N for i in range(N): s = input() if s[0] in L: Sdic[s[0]].append(s) else: tN -= 1 cnt = 0 for val in Sdic.values(): if len(val) == 0: cnt += 1 if cnt >=3: print(0) exit() zen = tN*(tN-1)*(tN-2) / 6 one = 0 for i in ["M","A","R","C","H"]: c = len(Sdic[i]) if c >= 3: one += c * (c-1) * (c-2) / 6 lis = [] for i in range(len(L)): for j in range(len(L)): if i < j: lis.append(len(Sdic[L[i]]) + len(Sdic[L[j]])) two = 0 for c in lis: if c >= 3: two += c * (c-1) * (c-2) / 6 print(int(zen - one - two))
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\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 LINF = 1LL << 60; const int INF = 1001001001; const int MOD = 1000000007; int main() { long long n; cin >> n; vector<int> S(5, 0); for (int i = 0; i < (n); i++) { string t; cin >> t; if (t[0] == 'M') S[0]++; else if (t[0] == 'A') S[1]++; else if (t[0] == 'R') S[2]++; else if (t[0] == 'C') S[3]++; else if (t[0] == 'H') S[4]++; } long long ans = 0; for (int i = 0; i < (3); i++) { for (int j = (i + 1); j < (4); j++) { for (int k = (j + 1); k < (5); k++) { ans += S[i] * S[j] * S[k]; } } } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { set<char> s; string t; map<char, int> m; int n; cin >> n; string march = "MARCH"; for (int i = 0; i < n; i++) { cin >> t; if (march.find(t[0]) == string::npos) continue; if (s.find(t[0]) == s.end()) { s.insert(t[0]); m[t[0]] = 1; } else { m[t[0]] = m[t[0]] + 1; } } vector<char> v(m.size()); int sum = 0; if (m.size() < 3) { cout << 0; } else { for (int i = m.size() - 1; i > int(m.size()) - 4; i--) { v[i] = 1; } vector<int> vec(s.begin(), s.end()); set<string> oc; char cr[3]; do { int tmp = 1; int cnt = 0; for (int i = 0; i < v.size(); i++) { if (v[i] == 0) continue; char c = vec[i]; int mc = m[c]; tmp *= mc; cnt++; cr[i] = c; } sort(cr, cr + 3); if (oc.find(cr) == oc.end()) { sum += tmp; oc.insert(cr); } } while (next_permutation(v.begin(), v.end())); cout << sum; } cout << 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, count[5], ans = 0; string s; for (int i = 0; i < 5; i++) count[i] = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> s; if (s[0] == 'M') count[0]++; if (s[0] == 'A') count[1]++; if (s[0] == 'R') count[2]++; if (s[0] == 'C') count[3]++; if (s[0] == 'H') count[4]++; } for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { ans += count[i] * count[j] * count[k]; } } } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; int N; int m = 0; int a = 0; int r = 0; int c = 0; int h = 0; bool flag = false; int main(void) { cin >> N; for (int i = 0; i < N; i++) { string t; cin >> t; if (t[0] == 'M') m++; if (t[0] == 'A') a++; if (t[0] == 'R') r++; if (t[0] == 'C') c++; if (t[0] == 'H') h++; } long long ans = m * a * r + m * a * c + m * a * h + m * r * c + m * r * h + m * c * h + a * r * c + a * r * h + a * c * h + r * c * h; cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
m,a,r,c,h = [0,0,0,0,0] N = int(input()) for i in range(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 N; cin >> N; string S[100000]; for (int i = 1; i <= N; i++) cin >> S[i]; long res = 0; long march[10]; march[1] = 0; march[2] = 0; march[3] = 0; march[4] = 0; march[5] = 0; for (int i = 1; i <= N; i++) { if (S[i][0] == 'M') march[1]++; if (S[i][0] == 'A') march[2]++; if (S[i][0] == 'R') march[3]++; if (S[i][0] == 'C') march[4]++; if (S[i][0] == 'H') march[5]++; } for (int i = 1; i <= 5; i++) for (int j = i + 1; j <= 5; j++) for (int k = j + 1; k <= 5; k++) res += march[i] * march[j] * march[k]; cout << res << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> int calcpos(char c) { switch (c) { case 'M': return 0; case 'A': return 1; case 'R': return 2; case 'C': return 3; case 'H': return 4; } return -1; } char S[15]; int main() { int counts[5] = {0, 0, 0, 0, 0}; int pos; int N; scanf("%d", &N); for (int i = 1; i <= N && !feof(stdin); ++i) { scanf("%s", S); pos = calcpos(S[0]); if (pos != -1) ++counts[pos]; } long long res = 0; for (int i = 0; i <= 2; ++i) { for (int j = i + 1; j <= 3; ++j) { for (int x = j + 1; x <= 4; ++x) { res += counts[i] * counts[j] * counts[x]; } } } printf("%lld", res); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.Scanner; public class Main { public static void main(String [] args){ Scanner sc =new Scanner(System.in); int N =sc.nextInt(); String s[] = new String[N]; int m=0; int a=0; int r=0; int c=0; int h=0; for (int i=0;i<N;i++) { s[i] = sc.nextLine(); if(s[i].startsWith("M")) { m++; } if(s[i].startsWith("A")) { a++; } if(s[i].startsWith("R")) { r++; } if(s[i].startsWith("C")) { c++; } if(s[i].startsWith("H")) { h++; } } long ans =m*a*r + m*a*c + m*a*h + m*r*c + m*r*h + m*c*h +a*r*c + a*r*h + a*c*h + r*c*h; System.out.println(ans); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; unsigned long long sol = 0; char arr[5] = {'M', 'A', 'R', 'C', 'H'}; void perm(unordered_map<char, int> &ma, vector<char> &ch, int i = 0) { if (ch.size() == 3) { sol += ma[ch[0]] * ma[ch[1]] * ma[ch[2]]; return; } for (; i < 5; i++) { if (ma[arr[i]] > 0) { ch.push_back(arr[i]); perm(ma, ch, i + 1); ch.pop_back(); } } } void solve(int test_case) { int n; cin >> n; unordered_map<char, int> ma; while (n--) { string s; cin >> s; ma[s[0]]++; } vector<char> ch; perm(ma, ch); cout << sol; } int main() { ios::sync_with_stdio(0); cin.tie(0); int t = 1; for (int i = 1; i <= t; i++) { solve(i); } return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <iostream> #include <string> #include <vector> using namespace std; int main() { int n, i, j, k; long long ans = 0; vector<long long> c(5); string s; cin >> n; for (i = 0; i < n; i++) { cin >> s; if (s[0] == 'M') c[0]++; if (s[0] == 'A') c[1]++; if (s[0] == 'R') c[2]++; if (s[0] == 'C') c[3]++; if (s[0] == 'H') c[4]++; } for (i = 0; i < 5; i++) { for (j = i + 1; j < 5; j++) { for (k = j + 1; k < 5; k++) { ans += c[i] * c[j] * c[k]; } } cout << ans << "\n"; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include <bits/stdc++.h> int main(void) { int n; scanf("%d", &n); char name[11]; int count[5]; long ans = 0; for (int i = 0; i < n; i++) { scanf("%s", name); switch (name[0]) { case 'M': count[0] += 1; break; case 'A': count[1] += 1; break; case 'R': count[2] += 1; break; case 'C': count[3] += 1; break; case 'H': count[4] += 1; break; } } 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]; } } } printf("%ld\n", ans); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int a; std::map<char, int> m; cin >> a; string str = "MARCH"; for (int i = 0; i < a; ++i) { string temp; cin >> temp; for (int j = 0; j < 5; ++j) { if (temp[0] == str[j]) { m[temp[0]]++; break; } } } long long int ans = 0; int flag = 1; for (int i = 0; i < 5; ++i) { for (int j = i + 1; j < 5; ++j) { for (int k = j + 1; k < 5; ++k) { ans += m[str[i]] * m[str[j]] * m[str[k]]; } } } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int x; char n[100002][16]; int i, j, k; int d[5]; cin >> x; for (i = 0; i < x; i++) cin >> n[i]; for (i = 0; i < 5; i++) d[i] = 0; for (i = 0; i < x; i++) { if (n[i][0] == 'M') d[0]++; if (n[i][0] == 'A') d[1]++; if (n[i][0] == 'R') d[2]++; if (n[i][0] == 'C') d[3]++; if (n[i][0] == 'H') d[4]++; } int sum = 0; for (i = 0; i < 3; i++) { for (j = i + 1; j < 4; j++) { for (k = j + 1; k < 5; k++) { sum += d[i] * d[j] * d[k]; } } } cout << sum; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } const int64_t INF = 1LL << 60; int main() { int N; cin >> N; int c[5] = {0}; for (int i = 0; i < N; i++) { string s; cin >> s; if (s[0] == 'M') { c[0]++; } if (s[0] == 'A') { c[1]++; } if (s[0] == 'R') { c[2]++; } if (s[0] == 'C') { c[3]++; } if (s[0] == 'H') { c[4]++; } } int ans = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { ans += c[i] * c[j] * c[k]; } } } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include<iostream> using namespace std; int main(){ long long int N; string S[110000]; char c[110000]; int a = 0; for(int i = 0; i < N; i++){ cin >> S[i]; c[i] = S[i][1]; } for(int i = 0; i < N; i++){ if(strcmp(c[i],"M")==0 || strcmp(c[i],"A")==0 || strcmp(c[i],"R")==0 || strcmp(c[i],"C")==0 || strcmp(c[i],"H")==0){ for(int j = i+1; j < N; j++){ if(strcmp(c[j],"M")==0 || strcmp(c[j],"A")==0 || strcmp(c[j],"R")==0 || strcmp(c[j],"C")==0 || strcmp(c[j],"H")==0 && strcmp(c[i],c[j])==0){ for(int k = j+1; k < N; k++){ if(strcmp(c[k],"M")==0 || strcmp(c[k],"A")==0 || strcmp(c[k],"R")==0 || strcmp(c[k],"H")==0 || strcmp(c[k],"C")==0 && strcmp(c[k],c[i])!=0 && strcmp(c[k],c[j])!=0){ a += 1; } } } } } } cout << a << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include <bits/stdc++.h> int main(void) { int N; scanf("%d", &N); int i, j; long ans; char S[11]; int name[5] = {0}; for (i = 0; i < N; i++) { scanf("%s", &S); if (S[0] == 'M') name[0]++; if (S[0] == 'A') name[1]++; if (S[0] == 'R') name[2]++; if (S[0] == 'C') name[3]++; if (S[0] == 'H') name[4]++; } ans = name[0] * name[1] * name[2] + name[0] * name[1] * name[3] + name[0] * name[1] * name[4] + name[0] * name[2] * name[3] + name[0] * name[2] * name[4] + name[0] * name[3] * name[4] + name[1] * name[2] * name[3] + name[1] * name[2] * name[4] + name[1] * name[3] * name[4] + name[2] * name[3] * name[4]; printf("%ld", ans); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s[n]; for (int i = 0; i < (n); i++) cin >> s[i]; int cnt[5] = {}; for (int i = 0; i < (n); i++) { if (s[i][0] == 'M') cnt[0]++; else if (s[i][0] == 'A') cnt[1]++; else if (s[i][0] == 'R') cnt[2]++; else if (s[i][0] == 'C') cnt[3]++; else if (s[i][0] == 'H') cnt[4]++; } long long res = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { res += cnt[i] * cnt[j] * cnt[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
UNKNOWN
#include <bits/stdc++.h> int main() { int N; int i; scanf("%d", &N); char name[N + 1][11]; for (i = 1; i <= N; i++) scanf("%s", &name[i][0]); int countM = 0, countA = 0, countR = 0, countC = 0, countH = 0; for (i = 1; i <= N; i++) { if (name[i][0] == 'M') countM += 1; if (name[i][0] == 'A') countA += 1; if (name[i][0] == 'R') countR += 1; if (name[i][0] == 'C') countC += 1; if (name[i][0] == 'H') countH += 1; } int result; result += countM * countA * (countR + countC + countH); result += countM * countR * (countC + countH); result += countM * countC * countH; result += countA * countR * (countC + countH); result += countA * countC * countH; result += countR * countC * countH; printf("%d", result); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; char table[5] = {'M', 'A', 'R', 'C', 'H'}; int charcount[5] = {0, 0, 0, 0, 0}; string s; for (int i = 0; i < N; i++) { cin >> s; for (int j = 0; j < 5; j++) { if (s[0] == table[j]) charcount[j]++; } } int answer = 0; for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 4; j++) { for (int k = j + 1; k < 5; k++) { answer += charcount[i] * charcount[j] * charcount[k]; } } } cout << answer << 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() { long long n; cin >> n; string s; long long MARCH[5] = {}; for (long long i = 0; i < n; i++) { s = " "; cin >> s; switch (s[0]) { case 'M': MARCH[0]++; break; case 'A': MARCH[1]++; break; case 'R': MARCH[2]++; break; case 'C': MARCH[3]++; break; case 'H': MARCH[4]++; break; } } long long ans = 0; for (long long i = 0; i < n; i++) { for (long long j = i + 1; j < n; j++) { for (long long k = j + 1; k < n; k++) { ans += MARCH[i] * MARCH[j] * MARCH[k]; } } } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
using System; using System.Linq; using System.Collections.Generic; using System.Numerics; namespace AtCoder { class Program { static void Main(string[] args) { MainStream(); } static void MainStream() { Scan sc = new Scan(); write wr = new write(); int[] march = new int[5]; int[] P = { 0, 0, 0, 0, 0, 0, 1, 1, 1, 2 }; int[] Q = { 1, 1, 1, 2, 2, 3, 2, 2, 3, 3 }; int[] R = { 2, 3, 4, 3, 4, 4, 3, 4, 4, 4 }; int n = sc.intarr[0]; for (int i = 0; i < n; i++) { string name = sc.str; char init = name[0]; if (init == 'M') { march[0]++; } else if (init == 'A') { march[1]++; } else if (init == 'R') { march[2]++; } else if (init == 'C') { march[3]++; } else if (init == 'H') { march[4]++; } } BigInteger result = 0; for(int i=0; i<10; i++) { result += march[P[i]] * march[Q[i]] * march[R[i]]; } wr.wri(result); } } class Scan { public string str => Console.ReadLine(); public string[] strarr => str.Split(' '); public long[] longarr => strarr.Select(long.Parse).ToArray(); public int[] intarr => strarr.Select(int.Parse).ToArray(); public char[] chararr => str.ToArray(); } class write { public void wri<Type>(Type x) { Console.WriteLine(x); } } class Method { static public int max(params int[] nums) { int maxx = nums[0]; for (int i = 1; i < nums.Length; i++) { maxx = Math.Max(maxx, nums[i]); } return maxx; } } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "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; std::vector<char> s; std::cin >> n; std::string b; std::cin.ignore(); int m[5] = {}; for (int i = 0; i < n; i++) { std::getline(std::cin, b); if (b[0] == 'M') m[0]++; if (b[0] == 'A') m[1]++; if (b[0] == 'R') m[2]++; if (b[0] == 'C') m[3]++; if (b[0] == 'H') m[4]++; } int ans = 0; for (int i = 2; i < 5; i++) { for (int j = 1; j < i; j++) { for (int k = 0; k < j; k++) { ans += m[i] * m[j] * m[k]; } } } std::cout << ans << std::endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a(5); 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 ans = 0; for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 4; j++) { for (int k = j + 1; k < 5; k++) ans += a[i] * a[j] * a[k]; } } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include<bits/stdc++.h> using namespace std; int main() { int n, M=0, A=0, R=0, C=0, H=0, i; long long s=0LL, a[10]; char L[100009][20]; cin >> n; for (i=0; i<n; i++) { cin >> L[i]; } for (i=0; i<n; i++) { //cin >> L; switch(L[i][0]) { case'M': M++; break; case'A': A++; break; case'R': R++; break; case'C': C++; break; case'H': H++; break; default: break; } } a[0] = long long(M*A*R); a[1] = long long(M*A*C); a[2] = long long(M*A*H); a[3] = long long(M*R*C); a[4] = long long(M*R*H); a[5] = long long(M*C*H); a[6] = long long(A*R*C); a[7] = long long(A*R*H); a[8] = long long(A*C*H); a[9] = long long(R*C*H); for(i=0; i<10; i++) { s+=a[i]; } cout << s << endl; //system("pause"); 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 i, j, k; int n; int num[5] = {0}; int total = 0; string s[100000]; cin >> n; for (i = 0; i < n; i++) { cin >> s[i]; if (s[i][0] == 'M') num[0]++; if (s[i][0] == 'A') num[1]++; if (s[i][0] == 'R') num[2]++; if (s[i][0] == 'C') num[3]++; if (s[i][0] == 'H') num[4]++; } int keta = 0; for (i = 0; i < 5; i++) { if (num[i] > 0) keta++; } if (keta < 3) { cout << "0" << endl; getchar(); getchar(); return 0; } int cnt = 0; int sum[99999] = {0}; for (i = 0; i < 5; i++) { if (num[i] == 0) continue; total = num[i]; int total1 = total; for (j = i + 1; j < 5; j++) { if (num[j] == 0) continue; total = total1 * num[j]; int total2 = total; for (k = j + 1; k < 5; k++) { if (num[k] == 0) continue; total = total * num[k]; sum[cnt] = total; cnt++; total = total2; } } } int sum2 = 0; for (i = 0; i < cnt; i++) { sum2 = sum2 + sum[i]; } cout << sum2 << endl; getchar(); getchar(); 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; map<char, int> mp; for (int(i) = 0; (i) < (int)(N); ++(i)) { string a; cin >> a; mp[a[0]]++; } long long ans = 0; string march("MARCH"); sort(march.begin(), march.end()); do { ans += (mp[march[0]] * mp[march[1]] * mp[march[2]]); } while (next_permutation(march.begin(), march.end())); cout << ans / 12 << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; int int_len(int n) { int s = 0; while (n != 0) s++, n /= 10; return s; } int int_sum(int n) { int m = 0, s = 0, a = n; while (a != 0) s++, a /= 10; for (int i = s - 1; i >= 0; i--) m += n / ((int)pow(10, i)) - (n / ((int)pow(10, i + 1))) * 10; return m; } long long int gcd(long long int a, long long int b) { long long int r, tmp; if (a < b) { tmp = a; a = b; b = tmp; } r = a % b; while (r != 0) { a = b; b = r; r = a % b; } return b; } int fac(int n) { int m = 1; while (n >= 1) m *= n, n--; return m; } int vec_sum(vector<int> v) { int n = 0; for (int i = 0; i < v.size(); i++) n += v[i]; return n; } int main() { int n, ans = 0, count = 0, c[5]; cin >> n; for (int i = 0; i < (n); i++) { string s; cin >> s; if (s[0] == 'M') { c[0]++; } else if (s[0] == 'A') { c[1]++; } else if (s[0] == 'R') { c[2]++; } else if (s[0] == 'C') { c[3]++; } else if (s[0] == 'H') { c[4]++; } } for (int i = 0; i < (5); i++) if (c[i] > 0) count++; if (count <= 2) { cout << 0 << endl; return 0; } for (int p = 0; p < 3; p++) { for (int q = p + 1; q < 4; q++) { for (int r = q + 1; r < 5; r++) { ans += c[p] * c[q] * c[r]; } } } 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 combination(long long n, long long k) { long long r = 1; for (long long d = 1; d <= k; ++d) { r *= n--; r /= d; } return r; } int main() { int N; cin >> N; vector<char> chars = {'M', 'A', 'R', 'C', 'H'}; map<char, int> n_persons; string name; for (int i = 0; i < N; i++) { cin >> name; for (int j = 0; j < chars.size(); j++) { if (name.at(0) == chars.at(j)) { n_persons[chars.at(j)]++; } } } long long pattern = 0; for (int i = 0; i < chars.size() - 2; i++) { char ic = chars.at(i); for (int j = i + 1; j < chars.size() - 1; j++) { char jc = chars.at(j); for (int k = j + 1; k < chars.size(); k++) { char kc = chars.at(k); pattern += n_persons[ic] * n_persons[jc] * n_persons[kc]; } } } cout << pattern << 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
import sys from collections import deque import copy import math def get_read_func(fileobject): if fileobject == None : return raw_input else: return fileobject.readline def is_tasai(S): appare_set = set([]) for s in S: if s in appare_set: return False appare_set.add(s) return True table = {} def comb(n, r): if (n, r) in table: return table[(n, r)] if n == r: table[(n, r)] = 1L return 1L if r == 0: table[(n, r)] = 1L return 1L if n == 0: return 0L table[(n, r)] = comb(n-1, r-1)+ comb(n-1, r) return table[(n, r)] def main(): if len(sys.argv) > 1: f = open(sys.argv[1]) else: f = None read_func = get_read_func(f); input_raw = read_func().strip().split() [N] = [int(input_raw[0])] initial_dict = {} initial_dict["M"] = 0 initial_dict["A"] = 0 initial_dict["R"] = 0 initial_dict["C"] = 0 initial_dict["H"] = 0 for i in range(N): input_raw = read_func().strip().split() if input_raw[0][0] in initial_dict: initial_dict[input_raw[0][0]] += 1 M = 0 for s in initial_dict: M += initial_dict[s] remove_num = 0L for s in initial_dict: remove_num += comb(initial_dict[s], 2) * (M - initial_dict[s]) remove_num += comb(initial_dict[s], 3) print comb(M, 3) - remove_num if __name__ == '__main__': main()
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> #pragma GCC optimize("O0") using namespace std; int N; char S[15]; int main() { scanf("%d", &N); int counts[5] = {0, 0, 0, 0, 0}; int hashcode; for (int i = 1; i <= N; ++i) { scanf("%s", S); if (S[0] == 'M') counts[0]++; if (S[0] == 'A') counts[1]++; if (S[0] == 'R') counts[2]++; if (S[0] == 'C') counts[3]++; if (S[0] == 'H') counts[4]++; } long long res = counts[0] * counts[1] * counts[2] + counts[0] * counts[1] * counts[3] + counts[0] * counts[1] * counts[4] + counts[0] * counts[2] * counts[3] + counts[0] * counts[2] * counts[4] + counts[0] * counts[3] * counts[4] + counts[1] * counts[2] * counts[3] + counts[1] * counts[2] * counts[4] + counts[1] * counts[3] * counts[4] + counts[2] * counts[3] * counts[4]; cout << res; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int N; int march[5]; char pattern[5] = {'M', 'A', 'R', 'C', 'H'}; vector<int> perm = {0, 1, 2, 3, 4}; int ans = 0; int main() { cin >> N; for (int i = 0; i < N; ++i) { string S; cin >> S; for (int i = 0; i < 5; ++i) { if (S[0] == pattern[i]) { ++march[i]; } } } do { ans += march[perm[0]] * march[perm[1]] * march[perm[2]]; } while (next_permutation(perm.begin(), perm.end())); cout << ans / 12 << 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(void) { int n; int ini[5] = {0, 0, 0, 0, 0}; double conb = 0; scanf("%d", &n); (void)getchar(); std::string a; for (int i = 0; i < n; i++) { std::getline(std::cin, a); if (a[0] == 'M') ini[0]++; if (a[0] == 'A') ini[1]++; if (a[0] == 'R') ini[2]++; if (a[0] == 'C') ini[3]++; if (a[0] == 'H') ini[4]++; } int i, j, k; for (i = 1; i <= 3; i++) { for (j = i + 1; j <= 4; j++) { for (k = j + 1; k <= 5; k++) { conb += ini[i - 1] * ini[j - 1] * ini[k - 1]; } } } printf("%.0lf\n", conb); 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
#60 C - March import collections N = int(input()) S = [input() for _ in range(N)] S = [s[0] for s in S if s[0] == 'M' or s[0] == 'A' or s[0] == 'R' or s[0] == 'C' or s[0] == 'H'] cnt = collections.Counter(S) n = len(cnt) ans = ((n*(n-1)*(n-2))//(3*2)) if ans == 1: for i in cnt.values(): if i>=2: ans *= i else: for i in cnt.values(): if i>=2: ans += (n- (((n-1)*(n-2)*(n-3))//(3*2)))*(i-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; string str; int m = 0; int a = 0; int r = 0; int c = 0; int h = 0; for (int i = 0; i < n; i++) { cin >> str; if (str[0] == 'M') { m++; } else if (str[0] == 'A') { a++; } else if (str[0] == 'R') { r++; } else if (str[0] == 'C') { c++; } else if (str[0] == 'H') { h++; } } unsigned long answer = 0; answer = m * a * r + m * a * c + m * a * h + m * r * c + m * r * h + m * c * h + a * r * c + a * r * h + a * c * h + r * c * h; cout << answer << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; map<char, long long int> mp; for (int i = 0; i < n; i++) { string tmp; cin >> tmp; if (tmp[0] != 'M' && tmp[0] != 'A' && tmp[0] != 'R' && tmp[0] != 'C' && tmp[0] != 'H') { } else { mp[tmp[0] - 'A']++; } } vector<long long int> arr; for (auto itr : mp) { arr.push_back(itr.second); } long long int ans = 0; if (arr.size() < 3) { ans = 0; } else { for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { ans += arr[i] * arr[j] * arr[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() { string s = "MARCH"; int c[5] = {0}; int N; cin >> N; for (int i = 0; i < N; i++) { string t; cin >> t; for (int j = 0; j < 5; j++) { if (t[0] == s[j]) { c[j]++; } } } int ans = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { cout << c[i] * c[j] * c[k] << endl; ans += c[i] * c[j] * c[k]; } } } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include<iostream> #include<string> #include<cmath> #include<algorithm> using namespace std; int main(){ int n; cin>>n; string s[10000]; unsignedd long long m=0,a=0,r=0,c=0,h=0; for(int i=0;i<n;i++){ cin>>s[i]; if(s[i][0]=='M') m++; if(s[i][0]=='A') a++; if(s[i][0]=='R') r++; if(s[i][0]=='C') c++; if(s[i][0]=='H') h++; } cout<<m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*r*h+a*c*h+r*c*h<<endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using P = pair<ll, ll>; int main() { ll N; vector<string> v; string s; cin >> N; for (ll i = 0; i < (ll)N; i++) { cin >> s; if (s[0] == 'M' || s[0] == 'A' || s[0] == 'R' || s[0] == 'C' || s[0] == 'H') v.push_back(s); } sort(v.begin(), v.end()); for (ll i = 1; i < (ll)v.size(); i++) { if (v[i] == v[i - 1]) v.erase(v.begin() + i); i--; } ll res = 0; if (v.size() >= 3) res = v.size() * (v.size() - 1) * (v.size() - 2) / 3 / 2; cout << res << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main(int argc, char const *argv[]) { int n; std::cin >> n; std::vector<int> v(5, 0); string march = "MARCH"; for (size_t i = 0; i < n; i++) { string temp; std::cin >> temp; for (size_t im = 0; im < march.size(); im++) { if (temp[0] == march[im]) { v[im]++; } } } long long ans = 0; for (size_t i = 0; i < v.size() - 2; i++) { for (size_t j = i + 1; j < v.size() - 1; j++) { for (size_t k = j + 1; k < v.size(); k++) { ans = ans + v[i] * v[j] * v[k]; } } } std::cout << ans << '\n'; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
# マップでカウントしておく # 頭文字の組み合わせそれぞれに対して頭文字それぞれの数を掛ける # なので組み合わせさえ出せれば解ける n = gets.chomp.to_i arr = [] table = {} n.times do name = gets.chomp if !(arr.include?(name)) && (name[0] == "M" || name[0] == "A" || name[0] == "R" || name[0] == "C" || name[0] == "H") arr << name[0] if table.has_key?(name[0]) table[name[0]] += 1 else table[name[0]] = 1 end end end @data = [] def perm(i, arr, source_arr, limit, length) if arr.size == limit @data << arr else i.upto(length) do |j| next if i==j perm(j, arr.clone<<source_arr[j-1], source_arr, limit, length) end end end @values = table.values perm(0, [], table.keys, 3, @values.size) ans = 0 @data.each do |d| ans += table[d[0]]*table[d[1]]*table[d[2]] end puts ans
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
import numpy as np from functools import reduce from collections import defaultdict N = int(input()) d = defaultdict(int) for i in range(N): c = input() if c[0] in ('M', 'A', 'R', 'C', 'H'): d[c[0]] += 1 l = len(d) if l < 3: print(0) else: if l == 3: ans = reduce(np.multiply, d.values()) elif l >= 4: ans = 0 t = reduce(np.multiply, d.values()) for v in d.values(): ans += t / v print(ans)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
import itertools import math N = int(input()) S_list = [] for i in range(N): S_list.append(input()) count_M = 0 count_A = 0 count_R = 0 count_C = 0 count_H = 0 for l in S_list: if l.startswith('M'): count_M += 1 elif l.startswith('A'): count_A += 1 elif l.startswith('R'): count_R += 1 elif l.startswith('C'): count_C += 1 elif l.startswith('H'): count_H += 1 count = [count_M,count_A,count_R,count_C,count_H] a = sum(count) x = a*(a-1)*(a-2)/math.factorial(3) for c in count: if c > 2: x -= c*(c-1)*(c-2)/math.factorial(3) elif c == 2: x -= (a-2) print(int(x))
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; string s; long long ans = 0; int co[5] = {}; cin >> n; for (int i = 0; i < n; i++) { cin >> s; if (s[0] == 'M') co[0]++; else if (s[0] == 'A') co[1]++; else if (s[0] == 'R') co[2]++; else if (s[0] == 'C') co[3]++; else if (s[0] == 'H') co[4]++; } for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { ans += co[i] * co[j] * co[k]; } } } cout << ans << '\n'; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include <bits/stdc++.h> int main(void) { int n; int m = 0; int a = 0; int r = 0; int c = 0; int h = 0; long long int ans = 0; char s[100001][11]; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%s", s[i]); switch (s[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)) + ((a) * (c) * (h)) + ((r) * (c) * (h)); printf("%lld", ans); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
import sys n=int(input()) s=[input()[0] for i in range(n)] m,a,r,c,h=0,0,0,0,0 for i in range(n): if s[i]=="M": m+=1 elif s[i]=="A": a+=1 elif s[i]=="R": r+=1 elif s[i]=="C": c+=1 elif s[i]=="H": h+=1 t=sorted([m,a,r,c,h]) if t[2]==0: print(0) sys.exit() if t[1]==0: print(t[2]*t[3]*t[4]) sys.exit() if t[0]==0: t[1],t[2],t[3],t[4]=a,b,c,d print(a*b*c+a*b*d+a*c*d+b*c*d) sys.exit() else: t[0],t[1],t[2],t[3],t[4]=a,b,c,d,e x=a*b*c+a*b*d+a*b*e+a*c*d+a*c*e+a*d*e y=b*c*d+b*c*e+b*d*e+c*d*e print(x+y)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { long long N; long long count[5] = {}; char S[10000][11]; cin >> N; for (int i = 0; i < N; i++) { cin >> S[i]; if (S[i][0] == 'M') count[0]++; else if (S[i][0] == 'A') count[1]++; else if (S[i][0] == 'R') count[2]++; else if (S[i][0] == 'C') count[3]++; else if (S[i][0] == 'H') count[4]++; } cout << count[0] * count[1] * count[2] + count[0] * count[1] * count[3] + count[0] * count[1] * count[4] + count[0] * count[2] * count[3] + count[0] * count[2] * count[4] + count[0] * count[3] * count[4] + count[1] * count[2] * count[3] + count[1] * count[2] * count[4] + count[1] * count[3] * count[4] + count[2] * count[3] * count[4] << 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; map<char, long long int> u; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long int n, m, i, j, k, p, q, o, l, s, t, z; string a; cin >> n; for (i = 0; i < n; i++) { cin >> a; u[a[0]]++; } cout << (u['M'] * u['A'] * u['R']) + (u['M'] * u['A'] * u['C']) + (u['M'] * u['A'] * u['H']) + (u['M'] * u['R'] * u['C']) + (u['M'] * u['R'] * u['H']) + (u['M'] * u['C'] * u['H']) + (u['A'] * u['R'] * u['C']) + (u['A'] * u['R'] * u['H']) + (u['A'] * u['C'] * u['H']) << "\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, march[5] = {}; int num = 0; cin >> n; long long int ans; string s[n]; for (int i = 0; i < n; i++) { cin >> s[i]; } for (int i = 0; i < n; i++) { if (s[i][0] == 'M') { march[0]++; } if (s[i][0] == 'A') { march[1]++; } if (s[i][0] == 'R') { march[2]++; } if (s[i][0] == 'C') { march[3]++; } if (s[i][0] == 'H') { march[4]++; } } for (int i = 0; i < 5; i++) { if (march[i]) num++; } int tmp = 1; for (int i = num; i > num - 3; i--) { tmp *= i; } ans = tmp / 6; for (int i = 0; i < 5; i++) { if (march[i]) { ans *= march[i]; } } if (num > 3) { for (int i = 0; i < 5; i++) { if (march[i] > 1) { ans -= march[i] - 1; } } } 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.HashSet; import java.util.Map; import java.util.Scanner; import java.util.Set; public class Main { public static void main(String[] args) { // new Main().solveA(); // new Main().solveB(); new Main().solveC(); // new Main().solveD(); // new Main().solveE(); // new Main().solveF(); } private void solveA() { Scanner scanner = null; int numN = 0; try { scanner = new Scanner(System.in); numN = scanner.nextInt(); System.out.println(numN / 3); } finally { if (scanner != null) { scanner.close(); } } } private void solveB() { Scanner scanner = null; int numN = 0; try { scanner = new Scanner(System.in); numN = scanner.nextInt(); Set<String> wkSet = new HashSet<String>(); for (int i = 0; i < numN; i++) { wkSet.add(scanner.next()); } System.out.println(wkSet.size() == 3 ? "Three" : "Four"); } finally { if (scanner != null) { scanner.close(); } } } private void solveC() { Scanner scanner = null; int numN = 0; try { scanner = new Scanner(System.in); numN = scanner.nextInt(); String[] wk = new String[numN]; Map<String, Integer> wkMap = new HashMap<String, Integer>(); wkMap.put("M", 0); wkMap.put("A", 0); wkMap.put("R", 0); wkMap.put("C", 0); wkMap.put("H", 0); for (int i = 0; i < wk.length; i++) { wk[i] = scanner.next(); if (wk[i].startsWith("M")) { wkMap.put("M", wkMap.get("M") + 1); } else if (wk[i].startsWith("A")) { wkMap.put("A", wkMap.get("A") + 1); } else if (wk[i].startsWith("R")) { wkMap.put("R", wkMap.get("R") + 1); } else if (wk[i].startsWith("C")) { wkMap.put("C", wkMap.get("C") + 1); } else if (wk[i].startsWith("H")) { wkMap.put("H", wkMap.get("H") + 1); } } long res = wkMap.get("M") * wkMap.get("A") * wkMap.get("R"); res += wkMap.get("M") * wkMap.get("A") * wkMap.get("C"); res += wkMap.get("M") * wkMap.get("A") * wkMap.get("H"); res += wkMap.get("M") * wkMap.get("R") * wkMap.get("C"); res += wkMap.get("M") * wkMap.get("R") * wkMap.get("H"); res += wkMap.get("M") * wkMap.get("C") * wkMap.get("H"); res += wkMap.get("A") * wkMap.get("R") * wkMap.get("C"); res += wkMap.get("A") * wkMap.get("R") * wkMap.get("H"); res += wkMap.get("R") * wkMap.get("C") * wkMap.get("H"); System.out.println(res); } finally { if (scanner != null) { scanner.close(); } } } private void solveD() { Scanner scanner = null; int numN = 0; int numK = 0; int numS = 0; try { scanner = new Scanner(System.in); numN = scanner.nextInt(); System.out.println(""); } finally { if (scanner != null) { scanner.close(); } } } private void solveE() { Scanner scanner = null; int numN = 0; int numK = 0; int numS = 0; try { scanner = new Scanner(System.in); numN = scanner.nextInt(); System.out.println(""); } finally { if (scanner != null) { scanner.close(); } } } private void solveF() { Scanner scanner = null; int numN = 0; int numK = 0; int numS = 0; try { scanner = new Scanner(System.in); numN = scanner.nextInt(); System.out.println(""); } finally { if (scanner != null) { scanner.close(); } } } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { char X[5] = {'M', 'A', 'R', 'C', 'H'}; int a[5] = {0, 0, 0, 0, 0}; int k; k = 0; long long ans; int N; cin >> N; string S[N]; for (int i = 0; i < N; i++) { cin >> S[i]; for (int j = 0; j < 5; j++) { if (S[i][0] == X[j]) { a[j]++; } } } for (int i = 0; i < 5; i++) { if (a[i] > 0) { k++; } } int sum1 = 0; int sum2 = 0; int sum3 = 0; for (int i = 0; i < N; i++) { sum1 += a[i]; sum2 += a[i] * a[i]; sum3 += a[i] * a[i] * a[i]; } cout << (sum1 * sum1 * sum1 + 2 * sum3 - 3 * sum1 * sum2) / 6 << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; int group[5] = {}; long long int ans = 0; string tmp; cin >> N; for (int i = 0; i < N; i++) { cin >> tmp; switch (tmp[0]) { case 'M': group[0]++; break; case 'A': group[1]++; break; case 'R': group[2]++; break; case 'C': group[3]++; break; case 'H': group[4]++; break; default: continue; } } for (int i = 0; i < N - 2; i++) { for (int j = i + 1; j < N - 1; j++) { for (int k = j + 1; k < N; k++) { ans += group[i] * group[j] * group[k]; } } } printf("%lld\n", 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 i, j, k; int n; int num[5] = {0}; int total = 0; string s[100000]; cin >> n; for (i = 0; i < n; i++) { cin >> s[i]; if (s[i][0] == 'M') num[0]++; if (s[i][0] == 'A') num[1]++; if (s[i][0] == 'R') num[2]++; if (s[i][0] == 'C') num[3]++; if (s[i][0] == 'H') num[4]++; } int keta = 0; for (i = 0; i < 5; i++) { if (num[i] > 0) keta++; } if (keta < 3) { cout << "0" << endl; getchar(); getchar(); return 0; } int cnt = 0; int sum[9999999] = {0}; for (i = 0; i < 5; i++) { if (num[i] == 0) continue; total = num[i]; int total1 = total; for (j = i + 1; j < 5; j++) { if (num[j] == 0) continue; total = total1 * num[j]; int total2 = total; for (k = j + 1; k < 5; k++) { if (num[k] == 0) continue; total = total * num[k]; sum[cnt] = total; cnt++; total = total2; } } } long sum2 = 0; for (i = 0; i < cnt; i++) { sum2 = sum2 + (long)sum[i]; } cout << sum2 << endl; getchar(); getchar(); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
n = int(input()) s = [] for _ in range(n): s.append(input()) march=[0]*5 string="MARCH" for i in range(n): for j in range(5): if s[i][0]==string[j]: march[j] +=1 if march.count(0)>=3: print(0) exit() while march.count(0): march.remove(0) ans=1 for i_0 in range(len(march)): for i_1 in range(i_0+1,len(march)): for i_2 in range(i_1+1,len(march)): ans = march[i_0]*march[i_1]*march[i_2] print(ans)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.*; public class Main{ public static void main(String[]args){ Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int m=0,a=0, r=0,c=0, h=0; for(int i=0;i<n;i++){ String s=sc.next().substring(0,1); if(s.equals("M"))m++; else if(s.equals("A"))a++; else if(s.equals("R"))r++; else if(s.equals("C"))c++; else if(s.equals("H"))h++; } System.out.println(m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*r*h+a*c*h+r*c*h); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { string a[100000]; int b, h = 0; int c = 0, d = 0, e = 0, f = 0, g = 0; cin >> b; for (int i = 0; i < b; i++) cin >> a[i]; for (int i = 0; i < b; i++) { if (a[i].find("M") == 0) c++; if (a[i].find("A") == 0) d++; if (a[i].find("R") == 0) e++; if (a[i].find("C") == 0) f++; if (a[i].find("H") == 0) g++; } h = c * d * e + c * d * f + c * d * g + d * e * f + d * e * g + e * f * g; cout << h << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<string> S(N); for (int i = 0; i < N; ++i) cin >> S[i]; map<char, int> cnt; for (int i = 0; i < N; ++i) { if (S[i][0] == 'M' || S[i][0] == 'A' || S[i][0] == 'R' || S[i][0] == 'C' || S[i][0] == 'H') { cnt[S[i][0]]++; } } int ans = 0; for (auto itr = cnt.begin(); itr != cnt.end(); ++itr) { for (auto itr2 = next(itr, 1); itr2 != cnt.end(); ++itr2) { for (auto itr3 = next(itr2, 1); itr3 != cnt.end(); ++itr3) { ans += itr->second * itr2->second * itr3->second; } } } 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
# coding: utf-8 # Your code here! import math from collections import Counter def P(n, r): return math.factorial(n)//math.factorial(n-r) def C(n, r): return P(n, r)//math.factorial(r) N = int(input()) arr = [input() for i in range(N)] mar_arr = [j for j in arr if j[0] == "M" or j[0] == "A" or j[0] == "R" or j[0] == "C" or j[0] == "H"] ini_arr = [k[0] for k in mar_arr] dic = Counter(ini_arr) key_num = len(dic) val_num = sum(v for v in dic.values()) if key_num < 3: print(0) else: total = C(len(ini_arr), 3) for i in dic.values(): if i == 2: total -= C(val_num - i, 1) elif i >= 3: total -= C(i, 2) * C(val_num - i, 1) + C(i, 3) print(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 ll = long long; ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); } template <int id> struct CompTupleBy { template <class T> bool operator()(const T& a, const T& b) const { return std::get<id>(a) < std::get<id>(b); } }; using namespace std; int main() { int n; cin >> n; map<string, int> mp; mp["M"] = 0; mp["A"] = 0; mp["R"] = 0; mp["C"] = 0; mp["H"] = 0; for (int(i) = 0; (i) < (n); (i)++) { string tmp; cin >> tmp; char first_ch = tmp[0]; if (first_ch == 'M') { mp["M"] += 1; } else if (first_ch == 'A') { mp["A"] += 1; } else if (first_ch == 'R') { mp["R"] += 1; } else if (first_ch == 'C') { mp["C"] += 1; } else if (first_ch == 'H') { mp["H"] += 1; } } ll ans = 0; ans += mp["M"] * mp["A"] * mp["R"]; ans += mp["M"] * mp["A"] * mp["C"]; ans += mp["M"] * mp["A"] * mp["H"]; ans += mp["M"] * mp["R"] * mp["C"]; ans += mp["M"] * mp["R"] * mp["H"]; ans += mp["M"] * mp["C"] * mp["H"]; ans += mp["A"] * mp["R"] * mp["C"]; ans += mp["A"] * mp["R"] * mp["H"]; ans += mp["A"] * mp["C"] * mp["H"]; ans += mp["R"] * mp["C"] * mp["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
program ABC_089_C_March implicit none integer N, i, j, k, a(1:5) integer(8)countN character(1) c, m(1:5) character(10), allocatable :: S(:) read(*, *) N allocate(S(1: N)) do i = 1, N read(*, *) S(i) end do m(1) = 'M' m(2) = 'A' m(3) = 'R' m(4) = 'C' m(5) = 'H' a(:) = 0 do j = 1, 5 do i = 1, N read(S(i), '(a1)') c if( c == m(j) ) then a(j) = a(j) + 1 end if end do end do countN = 0 do k = 1, 3 do j = k, 3 do i = j, 3 countN = countN + a(k)*a(j+1)*a(i+2) end do end do end do write(*, *) countN end program ABC_089_C_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; int main() { long long N, c_m, c_a, c_r, c_c, c_h; long long ans; string tmp; cin >> N; for (int i = 0; i < (int)(N); i++) { cin >> tmp; if (tmp.at(0) == 'M') c_m++; if (tmp.at(0) == 'A') c_a++; if (tmp.at(0) == 'R') c_r++; if (tmp.at(0) == 'C') c_c++; if (tmp.at(0) == 'H') c_h++; } ans = c_m * c_a * c_r + c_m * c_a * c_c + c_m * c_a * c_h + c_m * c_r * c_c + c_m * c_r * c_h + c_m * c_c * c_h + c_a * c_r * c_c + c_a * c_r * c_h + c_a * c_c * c_h + c_r * c_c * 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; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; } int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; vector<string> S(N); for (int i = 0; i < (int)(N); i++) cin >> S[i]; vector<int> check(5, 0); for (int i = 0; i < (int)(N); i++) { if (S[i][0] == 'M') check[0]++; if (S[i][0] == 'A') check[1]++; if (S[i][0] == 'R') check[2]++; if (S[i][0] == 'C') check[3]++; if (S[i][0] == 'H') check[4]++; } long long ans = 0; for (int i = 0; i <= 2; i++) { for (int j = i + 1; j <= 3; j++) { for (int k = j + 1; k <= 4; k++) { ans += check[i] * check[j] * check[k]; } } } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const string march = "MARCH"; vector<tuple<char, char, char>> combinations; void create_combinations(int depth, vector<char> now = {}) { if (now.size() == 3) { combinations.push_back(make_tuple(now[0], now[1], now[2])); return; } if (depth == march.length()) return; create_combinations(depth + 1, now); vector<char> tmp = now; tmp.push_back(march[depth]); create_combinations(depth + 1, tmp); } int main() { create_combinations(0); map<char, int> cnt; for (char ch : march) cnt[ch] = 0; long long N; cin >> N; for (long long i = 0; i < N; i++) { string tmp; cin >> tmp; for (auto p : cnt) { if (p.first == tmp[0]) { cnt[p.first]++; } } } long long ans = 0; for (auto e : combinations) { ans += cnt[get<0>(e)] * cnt[get<1>(e)] * cnt[get<2>(e)]; } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int INF = 1e9, MOD = 1e9 + 7; const long long LINF = 1e18; long long int n, cnt = 0, ans = 0, a = 0, b, c = 0, cmp, cmpp, cmppp, qq, data, m = 0, h = 0, w, x, xx, xxx, xxxx, xxxxx, y, xcmp, ycmp, sum = 0, r = 0; string s; vector<int> z; int main(void) { cin.tie(0); ios::sync_with_stdio(false); cin >> n; cmp = n; cmpp = n; for (long long int(i) = 0; (i) < (int)(n); (i)++) { cin >> s; if (s[0] != 'M' && s[0] != 'A' && s[0] != 'R' && s[0] != 'C' && s[0] != 'H') { cmp--; cmpp--; } if (s[0] == 'M') { m++; x = 1; } else if (s[0] == 'A') { a++; xx = 1; } else if (s[0] == 'R') { r++; xxx = 1; } else if (s[0] == 'C') { c++; xxxx = 1; } else if (s[0] == 'H') { h++; xxxxx = 1; } } cmppp = x + xx + xxx + xxxx + xxxxx; if (cmppp < 3) { cout << (0) << endl; return 0; } if (m != 1 && m != 0) { cnt = m; qq += cmpp - m; } if (a != 1 && a != 0) { cnt += a; qq = cmpp - a; } if (r != 1 && r != 0) { cnt += r; qq += cmpp - r; } if (c != 1 && c != 0) { cnt += c; qq += cmpp - c; } if (h != 1 && h != 0) { cnt += h; qq += cmpp - h; } cmp = cmp * (cmp - 1) * (cmp - 2); cmp /= 6; cout << (cmp - qq) << 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 P = pair<int, int>; int main() { int n; cin >> n; string name[114514]; for (int i = 0; i < n; i++) cin >> name[i]; int c[5] = {}; for (int i = 0; i < n; i++) { if (name[i][0] == 'M') c[0]++; if (name[i][0] == 'A') c[1]++; if (name[i][0] == 'R') c[2]++; if (name[i][0] == 'C') c[3]++; if (name[i][0] == 'H') c[4]++; } long long ans = 0; ans += c[0] * c[1] * c[2] + c[0] * c[1] * c[3] + c[0] * c[1] * c[4] + c[0] * c[2] * c[3] + c[0] * c[2] * c[4] + c[0] * c[3] * c[4] + c[1] * c[2] * c[3] + c[1] * c[2] * c[4] + c[1] * c[3] * c[4] + c[2] * c[3] * c[4]; cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 7, MOD = 1e9 + 7; const long long LINF = 1e18; int main() { int n, cntt = 0, cnt[5] = {}; bool f[5]; for (int i = 0; i < 5; i++) { f[i] = false; } cin >> n; for (int i = 0; i < n; i++) { string s; cin >> s; if (s[0] == 'M') { cnt[0]++; f[0] = true; } else if (s[0] == 'A') { cnt[1]++; f[1] = true; } else if (s[0] == 'R') { cnt[2]++; f[2] = true; } else if (s[0] == 'C') { cnt[3]++; f[3] = true; } else if (s[0] == 'H') { cnt[4]++; f[4] = true; } } for (int i = 0; i < 5; i++) { if (f[i] == true) { cntt++; } } if (cntt < 3) { cout << 0 << endl; } else if (cntt == 3) { long long tmp = cntt * (cntt - 1) * (cntt - 2) / 6; for (int i = 0; i < 5; i++) { if (cnt[i]) { tmp *= cnt[i]; } } cout << tmp << endl; } else if (cntt == 4) { long long tmp = cntt * (cntt - 1) * (cntt - 2) / 6; for (int i = 0; i < 5; i++) { if (cnt[i]) { tmp--; tmp *= cnt[i]; tmp++; } } cout << tmp << endl; } else if (cntt == 5) { long long tmp = cntt * (cntt - 1) * (cntt - 2) / 6; for (int i = 0; i < 5; i++) { if (cnt[i]) { tmp -= 3; tmp *= cnt[i]; tmp += 3; } } cout << tmp << endl; } return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int EPS = 1e-9; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; while (cin >> n) { ; vector<int> names(5); for (int i = 0; i < (n); i++) { string name; cin >> name; if (name[0] == 'M') names[0]++; else if (name[0] == 'A') names[1]++; else if (name[0] == 'R') names[2]++; else if (name[0] == 'C') names[3]++; else if (name[0] == 'H') names[4]++; }; long long ans = 0; vector<int> con[3]; con[0] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2}; con[1] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3}; con[2] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4}; for (int i = 0; i < (10); i++) { ans += names[con[0][i]] * names[con[1][i]] * names[con[2][i]]; } cout << ans << endl; ; } return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> name(5); for (int i = 0; i < N; i++) { string tmp; cin >> tmp; if (tmp[0] == 'M') name[0]++; else if (tmp[0] == 'A') name[1]++; else if (tmp[0] == 'R') name[2]++; else if (tmp[0] == 'C') name[3]++; else if (tmp[0] == 'H') name[4]++; } long long res = 0; for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { for (int k = 0; k < 5; k++) { if (i != j && j != k && k != i) { res += (name[i] * name[j] * name[k]); } } } } res /= 6; 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.Scanner; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); sc.nextLine(); int[] march = new int[5]; String l; int i; while(n-- > 0){ l = sc.nextLine(); i = getInd(l.charAt(0)); if(i != -1){ march[i]++; } } int res = 0; for(i = 0; i < 3; i++){ for(int j = i+1; j < 4; j++){ for(int k = j+1; k < 5; k++) res += march[i]* march[j]*march[k]; } } System.out.println(res); } private static int getInd(char c){ if(c == 'M') return 0; else if(c == 'A') return 1; else if(c == 'R') return 2; else if(c == 'C') return 3; else if(c == 'H') return 4; return -1; } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include<iostream> #include<string> #include <cmath> #include <algorithm> #include <vector> #include <cstdint> #include <map> #define MOD 1000000007 using namespace std; typedef long long ll; int main(){ ll n; cin >> n; string s; ll MARCH[5] = {}; for(ll i = 0; i<n; i++){ s =nil; cin >> s; switch ( s[0] ) { case 'M': MARCH[0]++; break; case 'A': MARCH[1]++; break; case 'R': MARCH[2]++; break; case 'C': MARCH[3]++; break; case 'H': MARCH[4]++; break; } } ll ans = 0; for(ll i = 0; i<n; i++){ for(ll j = i+1; j < n;j++){ for(ll k = j+1; k < n;k++){ ans += MARCH[i]* MARCH[j]* MARCH[k]; } } } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); } } fast; int main() { int n; string s; cin >> n; map<char, int> cnt; for (int i = 0; i < n; i++) { cin >> s; cnt[s[0]]++; } cout << cnt['M'] * cnt['A'] * cnt['R'] + cnt['M'] * cnt['A'] * cnt['C'] + cnt['M'] * cnt['A'] * cnt['H'] + cnt['M'] * cnt['R'] * cnt['C'] + cnt['M'] * cnt['R'] * cnt['H'] + cnt['M'] * cnt['C'] * cnt['H'] + cnt['A'] * cnt['R'] * cnt['C'] + cnt['A'] * cnt['R'] * cnt['H'] + cnt['A'] * cnt['C'] * cnt['H'] + cnt['R'] * cnt['C'] * cnt['H'] << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; unsigned long long pat(int a, int b, int c) { if (a == 0 || b == 0 || c == 0) return 0; return a * b * c; } unsigned long long total(int *ini) { unsigned long long ans = 0; for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { ans += pat(ini[i], ini[j], ini[k]); } } } return ans; } int main() { long long int N = 0; cin >> N; char moji[5] = {'M', 'A', 'R', 'C', 'H'}; string name; int ini[5]; for (int i = 0; i < 5; i++) ini[i] = 0; for (int i = 0; i < N; i++) { name = "\n"; cin >> name; for (int i = 0; i < 5; i++) { if (name[0] == moji[i]) ini[i]++; } } cout << total(ini) << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
fun main(args: Array<String>) { val n = readLine()!!.toInt() val s = (1..n).map { readLine()!!.first() } .filter { it in "MARCH" }.groupBy { it }.map { it.value.size.toInt() } var ans = 0L for (i in 0 until s.size-2) for (j in i+1 until s.size-1) for (k in j+1 until s.size) { ans += s[i]*s[j]*s[k] } println(ans) }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int m, a, r, c, h; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) { string s; cin >> s; if (s[0] == 'M') m++; if (s[0] == 'A') a++; if (s[0] == 'R') r++; if (s[0] == 'C') c++; if (s[0] == 'H') h++; } long long s = m * a * h + m * a * c + m * a * r + m * r * c + m * r * h + m * c * h + a * r * c + a * r * h + a * c * h + r * c * h; cout << 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; int main() { long n, a[5] = {0, 0, 0, 0, 0}, r = 0, adb; scanf("%ld", &n); for (int i = 0; i < n; i++) { char s[5]; scanf("%s", s); if (s[0] == 'M') { a[0]++; } else if (s[0] == 'A') { a[1]++; } else if (s[0] == 'R') { a[2]++; } else if (s[0] == 'C') { a[3]++; } else if (s[0] == 'H') { a[4]++; } } for (int z = 0; z < 3; z++) { for (int c = z + 1; c < 4; c++) { for (int v = c + 1; v < 5; v++) { adb = a[z] * a[c] * a[v]; } } } cout << adb << endl; return 0; }