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
python3
import numpy as np from scipy.special import comb n = int(input()) a = [] for _ in range(n): b = list(map(str,input())) a.append(b) ans = [0]*5 for i in range(n): tmp = a[i][0] if tmp == "M": ans[0] += 1 elif tmp == "A": ans[1] += 1 elif tmp == "R": ans[2] += 1 elif tmp == "C": ans[3] += 1 elif tmp == "H": ans[4] += 1 else: continue cnt = [] for j in range(len(ans)): if ans[j] == 0: continue else: cnt.append(ans[j]) l = 0 for k in range(len(cnt)): if cnt[k] > 1: l += cnt[k] - 1 cnt.sort() print(cnt) if len(cnt) <= 2: print(0) elif len(cnt) == 3: print(np.prod(cnt)) elif len(cnt) == 4: print((cnt[0]*cnt[1]*cnt[2])+(3*cnt[3])) else: print((cnt[0]*cnt[1]*cnt[2])+(3*cnt[3])+(6*cnt[4]))
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int N; cin >> N; string ma = "MARCH"; int c[5] = {0}; for (int i = 0; i < (N); ++i) { string S; cin >> S; for (int j = 0; j < 5; ++j) { if (S[0] == ma[j]) { c[j]++; } } } ll ans = 0; for (int i = 0; i < 5; ++i) { for (int j = i + 1; j < 5; ++j) { for (int k = j + 1; k < 5; ++k) { ans += c[i] * c[j] * c[k]; } } } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; string name; map<char, int> mp; cin >> n; char cc[] = {'M', 'A', 'R', 'C', 'H'}; mp['M'] = 0; mp['A'] = 0; mp['R'] = 0; mp['C'] = 0; mp['H'] = 0; for (int i = 0; i < n; i++) { cin >> name; if (name[0] == 'M' || name[0] == 'A' || name[0] == 'R' || name[0] == 'C' || name[0] == 'H') { mp[name[0]]++; } } unsigned long long sum = 0; for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 4; j++) { for (int k = j + 1; k < 5; k++) { int a = mp[cc[i]] * mp[cc[j]] * mp[cc[k]]; sum += a; } } } cout << sum << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; unordered_map<char, int> counter; for (int(i) = 0; (i) < (n); (i)++) { string s; cin >> s; counter[s[0]]++; } vector<int> cnt = {counter['M'], counter['A'], counter['R'], counter['C'], counter['H']}; int ans = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { ans += cnt[i] * cnt[j] * cnt[k]; } } } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#pragma GCC optimize "-O3" #pragma GCC target ("avx") #define _USE_MATH_DEFINES #include<bits/stdc++.h> #define int long long #define rep(i,n) for(int i=0;i!=n;++i) #define vi vector<int> #define vvi vector<vi> #define pb push_back #define pi pair<int,int> #define vp vector<pair<int,int>> #define mp make_pair #define all(v) (v).begin(),(v).end() #define fi first #define se second #define MEMSET(a) memset(a,0,sizeof(a)) #define inf (1ll<<60) #define SORT(v) sort(all(v)) #define RSORT(v) sort(all(v),greater<int>()) signed gcd(int a, int b){return b?gcd(b,a%b):a;} using namespace std; const int mod=1e9+7; void run(); int fact(int n); int combi(int n, int r); void init() { ios::sync_with_stdio(false); cin.tie(0); cout<<fixed<<setprecision(12); } signed main(){ init(); run(); return 0; } void run(){ int n; cin >> n; vi march(n,0); string s; rep(i,n) { cin >> s; if(s[0]!='M'&&s[0]!='A'&&s[0]!='R'&&s[0]!='C'&&s[0]!='H')continue; if(s[0]=='M')++march[0]; if(s[0]=='A')++march[1]; if(s[0]=='R')++march[2]; if(s[0]=='C')++march[3]; if(s[0]=='H')++march[4]; } int ans=0; rep(i,5) { if(march[i]>=1)++ans; } ans = combi(ans,3); rep(i,5) { if(march[i]>=1)ans*=march[i]; } cout << ans << endl; } //階乗を計算してくれる関数 int fact(int n){ int sum=1; for(int i = 1; i <= n; ++i) { sum*=i; } return sum; } //n個からr個を選ぶ選び方の数を計算してくれる関数 int combi(int n,int r){ int num=1; num = fact(n)/fact(r)/fact(n-r); return num; } #pragma GCC optimize "-O3" #pragma GCC target ("avx") #define _USE_MATH_DEFINES #include<bits/stdc++.h> #define int long long #define rep(i,n) for(int i=0;i!=n;++i) #define vi vector<int> #define vvi vector<vi> #define pb push_back #define pi pair<int,int> #define vp vector<pair<int,int>> #define mp make_pair #define all(v) (v).begin(),(v).end() #define fi first #define se second #define MEMSET(a) memset(a,0,sizeof(a)) #define inf (1ll<<60) #define SORT(v) sort(all(v)) #define RSORT(v) sort(all(v),greater<int>()) signed gcd(int a, int b){return b?gcd(b,a%b):a;} using namespace std; const int mod=1e9+7; void run(); int fact(int n); int combi(int n, int r); void init() { ios::sync_with_stdio(false); cin.tie(0); cout<<fixed<<setprecision(12); } signed main(){ init(); run(); return 0; } void run(){ int n; cin >> n; vi march(n,0); string s; rep(i,n) { cin >> s; if(s[0]!='M'&&s[0]!='A'&&s[0]!='R'&&s[0]!='C'&&s[0]!='H')continue; if(s[0]=='M')++march[0]; if(s[0]=='A')++march[1]; if(s[0]=='R')++march[2]; if(s[0]=='C')++march[3]; if(s[0]=='H')++march[4]; } int ans=0; rep(i,5) { if(march[i]>=1)++ans; } ans = combi(ans,3); rep(i,5) { if(march[i]>=1)ans*=march[i]; } cout << ans << endl; } //階乗を計算してくれる関数 int fact(int n){ int sum=1; for(int i = 1; i <= n; ++i) { sum*=i; } return sum; } //n個からr個を選ぶ選び方の数を計算してくれる関数 int combi(int n,int r){ int num=1; num = fact(n)/fact(r)/fact(n-r); return num; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\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 cnt[5] = {0}; unsigned long int ans = 0; int main() { int N; char s[11] = {0}; scanf("%d", &N); for (int i = 0; i < N; i++) { scanf("%s", s); if (s[0] == 'M') cnt[0]++; else if (s[0] == 'A') cnt[1]++; else if (s[0] == 'R') cnt[2]++; else if (s[0] == 'C') cnt[3]++; else if (s[0] == 'H') cnt[4]++; } int num = 5; for (int i = 0; i < 5; i++) { if (cnt[i] == 0) num--; } if (num < 3) { printf("%lu\n", ans); return 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 += cnt[i] * cnt[j] * cnt[k]; } } } printf("%lu\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> int main(void) { int N; scanf("%d", &N); char S[N][10]; int sum[5] = {}; for (int i = 0; i < N; i++) { scanf("%s", S[i]); if (S[i][0] == 'M') { sum[0]++; } if (S[i][0] == 'A') { sum[1]++; } if (S[i][0] == 'R') { sum[2]++; } if (S[i][0] == 'C') { sum[3]++; } if (S[i][0] == 'H') { sum[4]++; } } int x = sum[0] + sum[1] + sum[2] + sum[3] + sum[4]; long long int y[5]; for (int i = 0; i < 5; i++) { y[i] = sum[i] * (sum[i] - 1) * (x - sum[i]) / 2; } long long int ans = x * (x - 1) * (x - 2) / 6 - y[0] - y[1] - y[2] - y[3] - y[4]; printf("%lld", ans); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N, i, M, A, R, C, H, variety, combo, ans; string Name; M = 0; A = 0; R = 0; C = 0; H = 0; variety = 0; cin >> N; for (i = 0; i < N; i++) { cin >> Name; if (Name[0] == 'M') { M++; } else if (Name[0] == 'A') { A++; } else if (Name[0] == 'R') { R++; } else if (Name[0] == 'C') { C++; } else if (Name[0] == 'H') { H++; } } if (M > 0) { variety++; } if (A > 0) { variety++; } if (R > 0) { variety++; } if (C > 0) { variety++; } if (H > 0) { variety++; } if (variety < 3) { combo = 0; } if (variety == 3) { combo = 1; } if (variety == 4) { combo = 3; } if (variety == 5) { combo = 9; } if (M == 0) { M = 1; } if (A == 0) { A = 1; } if (R == 0) { R = 1; } if (C == 0) { C = 1; } if (H == 0) { H = 1; } ans = M * A * R * C * H * combo; 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
extern crate core; use std::io::{self, Read}; fn main() { let mut input = String::new(); io::stdin().read_to_string(&mut input).unwrap(); let output = run(input.trim().to_string()); println!("{}", output); } fn run(input: String) -> String { let mut m = 0; let mut a = 0; let mut r = 0; let mut c = 0; let mut h = 0; for x in input.split("\n").skip(1).map(|x| x.to_string()) { if x.find("M") == Some(0) { m += 1; } else if x.find("A") == Some(0) { a += 1; } else if x.find("R") == Some(0) { r += 1; } else if x.find("C") == Some(0) { c += 1; } else if x.find("H") == Some(0) { h += 1; } } let mut list = vec![]; if m != 0 { list.push(m); } if a != 0 { list.push(a); } if r != 0 { list.push(r); } if c != 0 { list.push(c); } if h != 0 { list.push(h); } //グループの数 let n = list.len(); if n == 3 { list[0] * list[1] * list[2] } else if n == 4 { list[0] * list[1] * list[2] + list[0] * list[1] * list[3] + list[0] * list[2] * list[3] + list[1] * list[2] * list[3] } else if n == 5 { list[0] * list[1] * list[2] + list[0] * list[1] * list[3] + list[0] * list[1] * list[4] + list[0] * list[2] * list[3] + list[0] * list[2] * list[4] + list[0] * list[3] * list[4] + list[1] * list[2] * list[3] + list[1] * list[2] * list[4] + list[1] * list[3] * list[4] + list[2] * list[3] * list[4] } else { 0 }.to_string() } #[test] fn test() { let tests = vec![ ( "5 MASHIKE RUMOI OBIRA HABORO HOROKANAI", "2", ), ( "4 ZZ ZZZ Z ZZZZZZZZZZ", "0", ), ( "5 CHOKUDAI RNG MAKOTO AOKI RINGO", "7", ), ]; for (i, (input, output)) in tests.into_iter().enumerate() { println!("test:{}", i); assert_eq!(run(input.to_string()), output.to_string()); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
N = int(input()) S = [] for i in range(N): S.append(input()) all = [] c0 = 0 count = 0 for name0 in S[c0:]: ans = [[],[],[]] cand = ['M','A','R','C','H'] if cand.count(name0[0]): cand.remove(name0[0]) ans[0] = name0 c1 = c0 + 1 for name1 in S[c1:]: if cand.count(name1[0]): cand.remove(name1[0]) ans[1] = name1 c2 = c1 + 1 for name2 in S[c2:]: if cand.count(name2[0]): cand.remove(name2[0]) ans[2] = name2 count += 1 if set(ans) not in all: all.append(set(ans)) print(count+1)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; map<char, int> m; for (int i = 0; i < n; ++i) { string s; cin >> s; m[s[0]]++; } string march = "MARCH"; int sum = 0; for (int mm = 0; mm < 2; ++mm) { for (int a = 0; a < 2; ++a) { for (int r = 0; r < 2; ++r) { for (int c = 0; c < 2; ++c) { for (int h = 0; h < 2; ++h) { if (mm + a + r + c + h == 3) { int xx[5] = {m['M'] * mm, m['A'] * a, m['R'] * r, m['C'] * c, m['H'] * h}; sort(xx, xx + 5); int hoge = xx[4] * xx[3] * xx[2]; sum += hoge; } } } } } } cout << sum << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using uint = unsigned int; using ll = long long; using ull = unsigned long long; template <class T> using V = vector<T>; template <class T> using VV = V<V<T>>; string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; string alphabet_lower = "abcdefghijklmnopqrstuvwxyz"; int keta_sum(int num) { int dig, sum = 0; while (num) { dig = num % 10; sum = sum + dig; num = num / 10; } return sum; } int main(void) { int N, A, B, W, H; cin >> N; string s[N]; int count[5] = {0}; for (int i = 0; i < N; i++) { cin >> s[i]; if (s[i][0] == 'M') count[0]++; if (s[i][0] == 'A') count[1]++; if (s[i][0] == 'R') count[2]++; if (s[i][0] == 'C') count[3]++; if (s[i][0] == 'H') count[4]++; } ull ans = 0; for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 4; j++) { for (int k = j + 1; k < 5; k++) { ans += count[i] * count[j] * count[k]; } } } 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, c[5] = {0}; string a = "MARCH"; cin >> n; for (int i = 0; i < n; i++) { string s; cin >> s; for (int j = 0; j < 5; j++) { if (a[j] == s[0]) { c[j]++; } } } int ans = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { ans += c[i] * c[j] * c[k]; } } } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
n = gets.to_i s = [] a = ['M', 'A', 'R', 'C', 'H'] cnt = 0 n.times do hoge = gets.chomp! s << hoge if a.include?(hoge[0]) end s.combination(3) do |i, j, k| h = [] h.push(i[0], j[0], k[0]) if h.uniq.size == 3 cnt += 1 end end p cnt
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int c[4]; int q, w, e, ans; int main() { int a; cin >> a; string s; for (int i = 0; i < a; 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]++; } sort(c, c + 4); for (int i = 0; i < a; i++) { if (c[i] != 0) { for (q = i; q < a - 2; q++) for (w = 1 + i; w < a - 1; w++) for (e = 2 + i; e < a; e++) ans += c[q] * c[w] * c[e]; break; } } cout << ans; 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 N; cin >> N; vector<int> vec(5); for (int i = 0; i < N; i++) { string S; cin >> S; if (S.at(0) == 'M') vec[0]++; if (S.at(0) == 'A') vec[1]++; if (S.at(0) == 'R') vec[2]++; if (S.at(0) == 'C') vec[3]++; if (S.at(0) == 'H') vec[4]++; } sort(vec.begin(), vec.end()); reverse(vec.begin(), vec.end()); if (vec[0] == 0 || vec[1] == 0 || vec[2] == 0) { cout << 0 << endl; } else if (vec[3] == 0) { cout << vec[0] * vec[1] * vec[2] << endl; } else if (vec[4] == 0) { cout << vec[0] * vec[1] * vec[2] + vec[0] * vec[1] * vec[3] + vec[0] * vec[3] * vec[2] + vec[3] * vec[1] * vec[2] << endl; } else { int S = 0; S += vec[2] * vec[3] * vec[4]; S += vec[1] * vec[3] * vec[4]; S += vec[1] * vec[2] * vec[4]; S += vec[1] * vec[2] * vec[3]; S += vec[0] * vec[3] * vec[4]; S += vec[0] * vec[2] * vec[4]; S += vec[0] * vec[2] * vec[3]; S += vec[0] * vec[1] * vec[4]; S += vec[0] * vec[1] * vec[3]; S += vec[0] * vec[1] * vec[2]; cout << S << endl; } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> num(5); string s; for (int i = 0; i < n; i++) { cin >> s; if (s.at(0) == 'M') num.at(0)++; if (s.at(0) == 'A') num.at(1)++; if (s.at(0) == 'R') num.at(2)++; if (s.at(0) == 'C') num.at(3)++; if (s.at(0) == 'H') num.at(4)++; } long long res = 0; for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 4; j++) { for (int k = j + 1; k < 5; k++) { res += num.at(i) * num.at(j) * num.at(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> using namespace std; int combination(int t, int r) { if (t == r || r == 0) return 1; else return combination(t, r - 1) * (t - r + 1) / r; } int main(void) { int n; int d = 0; int a[5] = {}; cin >> n; for (int i = 0; i < n; i++) { string s; cin >> s; if (s[0] == 'M') a[0]++; if (s[0] == 'A') a[1]++; if (s[0] == 'R') a[2]++; if (s[0] == 'C') a[3]++; if (s[0] == 'H') a[4]++; } for (int i = 0; i < 5; i++) { if (a[i] == 0) { d++; } } if (d >= 3) { cout << '0' << endl; return 0; } int cnt1 = 0; int cnt2 = 0; int cnt3 = 0; for (int i = 0; i < 5; i++) { if (a[i] == 1) cnt1++; if (a[i] != 0) cnt2++; if (a[i] != 0 && a[i] != 1) cnt3++; } int ans1 = 0; if (cnt1 >= 3) ans1 = combination(cnt1, 3); else ans1 = 0; int ans2; if (cnt1 >= 2) ans2 = combination(cnt1, 2); else if (cnt1 == 1 || cnt1 == 0) ans2 = 1; for (int i = 0; i < 5; i++) { if (a[i] != 0) ans2 *= a[i]; } cout << ans1 + ans2 << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const int MOD = 1000000007; int main() { ios_base::sync_with_stdio(false); int n; cin >> n; int a[7]; for (int i = 0; i <= 6; ++i) a[i] = 0; for (int i = 1; i <= n; ++i) { string s; cin >> s; if (s[0] == 'M') a[1]++; if (s[0] == 'A') a[2]++; if (s[0] == 'R') a[3]++; if (s[0] == 'C') a[4]++; if (s[0] == 'H') a[5]++; } vector<pair<int, int> > v; if (a[1]) v.push_back({1, a[1]}); if (a[2]) v.push_back({2, a[2]}); if (a[3]) v.push_back({3, a[3]}); if (a[4]) v.push_back({4, a[4]}); if (a[5]) v.push_back({5, a[5]}); long long ans = 0LL; if ((int)v.size() < 3) { cout << 0 << '\n'; return 0; } int perm = 0; do { ++perm; ans += ((1LL * v[0].second) * (1LL * v[1].second) * (1LL * v[2].second)); } while (next_permutation((v).begin(), (v).end())); ans /= 6LL; 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 S[10000][11]; for (int i = 0; i < N; i++) { scanf("%s", S[i]); } long long int name[5] = {0}; for (int i = 0; i < N; i++) { switch (S[i][0]) { case 'M': name[0]++; break; case 'A': name[1]++; break; case 'R': name[2]++; break; case 'C': name[3]++; break; case 'H': name[4]++; break; } } int P[10] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2}; int Q[10] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3}; int R[10] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4}; long long int ans = 0; for (int i = 0; i < 10; i++) { ans += name[P[i]] * name[Q[i]] * name[R[i]]; } printf("%lld\n", ans); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize(3) template <class T> inline T min(T &x, const T &y) { return x > y ? y : x; } template <class T> inline T max(T &x, const T &y) { return x < y ? y : x; } int read() { int x = 0, f = 1; char c = getchar(); while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar(); } while (c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar(); } return x * f; } struct ios { inline char gc() { static const int IN_LEN = 1 << 18 | 1; static char buf[IN_LEN], *s, *t; return (s == t) && (t = (s = buf) + fread(buf, 1, IN_LEN, stdin)), s == t ? -1 : *s++; } template <typename _Tp> inline ios &operator>>(_Tp &x) { static char ch, sgn; ch = gc(), sgn = 0; for (; !isdigit(ch); ch = gc()) { if (ch == -1) return *this; sgn |= ch == '-'; } for (x = 0; isdigit(ch); ch = gc()) x = (((x << 2) + x) << 1) + (ch ^ '0'); sgn && (x = -x); return *this; } } io; const int maxn = 1e5 + 7; const int mod = 1e9 + 7; int n, m, a, r, c, h; long long ans; string s; int x[6]; int P[10] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2}; int Q[10] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3}; int R[10] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4}; int main() { n = read(); 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[0] = m, x[1] = a, x[2] = r, x[3] = c, x[4] = h; for (int i = 0; i < 5; i++) ans += x[P[i]] * x[Q[i]] * x[R[i]]; cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.Scanner; import java.util.Arrays; import java.util.ArrayDeque; import java.util.Queue; import java.util.LinkedList; public class Main { public static void main(String[] args) { new Main().solve(); } void solve() { Scanner sc = new Scanner(System.in); int N=sc.nextInt(); long a=0; long b=1; long c=0; long d=0; long e=0; String S[]=new String[N]; int s[]=new int[5]; Arrays.fill(s,0); for(int i=0;i<N;i++){ S[i]=sc.next(); } for(int i=0;i<N;i++){ if(S[i].charAt(0)=='M')s[0]++; if(S[i].charAt(0)=='A')s[1]++; if(S[i].charAt(0)=='R')s[2]++; if(S[i].charAt(0)=='C')s[3]++; if(S[i].charAt(0)=='H')s[4]++; } for(int i=0;i<5;i++){ if(s[i]>0)a++; if(s[i]>1){ for(int j=s[i];j>0;j--){ c++; d++; } b=b*c; e=e+d-1; c=0; } } if(a<=3){ System.out.println(C(a)*b); }else{ System.out.println(C(a)*b-e-1); } } long C(long s){ long a=s; for(long i=s-1;i>1;i--){ a=a*i; } return a/6; } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; vector<int> A(5, 0); for (int i = 0; i < n; i++) { string s; cin >> s; if (s[0] == 'M') A[0]++; 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; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
using System; using System.Collections.Generic; using System.Linq; using static Atcoder; using System.Threading.Tasks; using System.ComponentModel; public class Hello { public static void Main() { int N = Cin(); String[] Name = 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++) { Name[i] = Console.ReadLine(); if (Name[i][0] == 'M') M += 1; if (Name[i][0] == 'A') A += 1; if (Name[i][0] == 'R') R += 1; if (Name[i][0] == 'C') C += 1; if (Name[i][0] == 'H') H += 1; } 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; Console.WriteLine(ans); } } public class Atcoder { static void Swap<T>(ref T a, ref T b) { var t = a; a = b; b = t; } public static int LCM(int a, int b) { int c = a * b; if (a < b) Swap(ref a, ref b); int d = a % b; while (d != 0) { a = b; b = d; d = a % b; } return c / b; } public static string strReverce(string s) { return new string(s.Reverse().ToArray()); } public static int Cin() { return int.Parse(Console.ReadLine()); } public static bool IsPrime(int n) { if (n < 2) return false; if (n == 2) return true; if (n % 2 == 0) return false; //double sqrtNum = Math.Sqrt(n); for (int i = 3; i < n; i += 2) { if (n % i == 0) return false; } return true; } public static string[] SpRead(char c) { return Console.ReadLine().Split(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
UNKNOWN
#include <bits/stdc++.h> using namespace std; int dp[5]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n, m, a, r, c, h, cnt = 0; cin >> n; m = a = r = c = h = 0; string str; while (n--) { cin >> str; if (str[0] == 'M') m++; if (str[0] == 'A') a++; if (str[0] == 'R') r++; if (str[0] == 'C') c++; if (str[0] == 'H') h++; } long long res[1 + 10]; res[1] = m * a * r; res[2] = m * a * c; res[3] = m * a * h; res[4] = m * r * c; res[5] = m * r * h; res[6] = m * c * h; res[7] = a * r * c; res[8] = a * r * h; res[9] = a * c * h; res[10] = r * c * h; long long sum = 0; for (int i = 1; i <= 10; i++) sum += res[i]; 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; int main() { int N; string S; int i, j, k; cin >> N; int num[5] = {0}; for (i = 0; i <= N - 1; i++) { cin >> S; if (S.at(0) == 'M') num[0]++; if (S.at(0) == 'A') num[1]++; if (S.at(0) == 'R') num[2]++; if (S.at(0) == 'C') num[3]++; if (S.at(0) == 'H') num[4]++; } int sum = 0; for (i = 0; i <= 2; i++) for (j = i + 1; j <= 3; j++) for (k = j + 1; k <= 4; k++) sum += num[i] * num[j] * num[k]; cout << sum << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
"use strict"; // 組み合わせ(被りなし) const combineWithoutRepetitions = (comboOptions, comboLength) => { if (comboLength === 1) { return comboOptions.map(comboOption => [comboOption]); } // Init combinations array. const combos = []; // Eliminate characters one by one and concatenate them to // combinations of smaller lengths. comboOptions.forEach((currentOption, optionIndex) => { const smallerCombos = combineWithoutRepetitions( comboOptions.slice(optionIndex + 1), comboLength - 1 ); smallerCombos.forEach((smallerCombo) => { combos.push([currentOption].concat(smallerCombo)); }); }); return combos; } const main = arg => { arg = arg.trim().split("\n"); const N = parseInt(arg[0]); const names = arg.slice(1, N + 1).filter(n => { if(n[0] === "M" || n[0] === "A" || n[0] === "R" || n[0] === "C" || n[0] === "H") { return true; } }); if(!names.length) { console.log(0); return; } const initial = names.map(n=>n.split("")[0]); const iniSet = new Set(initial); const duplicate = (names.length - [...iniSet].length) * 2; let allComb = combineWithoutRepetitions(names, 3); console.log(allComb.length - (names.length - duplicate)); } main(require('fs').readFileSync('/dev/stdin', 'utf8'));
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; vector<int> name(5, 0); for (int i = 0; i < (int)(n); i++) { string s; cin >> s; switch (s.at(0)) { case 'M': name.at(0)++; break; case 'A': name.at(1)++; break; case 'R': name.at(2)++; break; case 'C': name.at(3)++; break; case 'H': name.at(4)++; break; } } long long ans = 0; for (int i = 0; i < n - 2; i++) { for (int j = i + 1; j < n - 1; j++) { for (int k = j + 1; k < n; k++) { ans += name.at(i) * name.at(j) * name.at(k); } } } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
//Written by Zhu Zeqi //Come on,baby //Hack,please #include<cmath> #include<math.h> #include<ctype.h> #include<algorithm> #include<bitset> #include<cassert> #include<cctype> #include<cerrno> #include<cfloat> #include<ciso646> #include<climits> #include<clocale> #include<complex> #include<csetjmp> #include<csignal> #include<cstdarg> #include<cstddef> #include<cstdio> #include<cstdlib> #include<cstring> #include<ctime> #include<cwchar> #include<cwctype> #include<deque> #include<exception> #include<fstream> #include<functional> #include<iomanip> #include<ios> #include<iosfwd> #include<iostream> #include<istream> #include<iterator> #include<limits> #include<list> #include<locale> #include<map> #include<memory> #include<new> #include<numeric> #include<ostream> #include<queue> #include<set> #include<sstream> #include<stack> #include<stdexcept> #include<streambuf> #include<string> #include<typeinfo> #include<utility> #include<valarray> #include<vector> #include<string.h> #include<stdlib.h> #include<stdio.h> #define CLR(x) memset(x,0,sizeof x) #define pb push_back #define mp make_pair #define F first #define S second #define pii pair<int,int> #define vi vector<int> #define MAX 1000000000000000000 #define MOD 1000000007 #define PI 3.141592653589793238462 #define INF 0x3f3f3f3f typedef long long ll; //orz yht using namespace std; string i_s(int x){ if(x==0) return "0"; string ret=""; while(x){ ret=ret+(char)(x%10+'0'); x/=10; } reverse(ret.begin(),ret.end()); return ret; } string add(string a,string b){ if(a=="") a="0"; if(b=="") b="0"; if(a.length()<b.length()) swap(a,b); while(b.length()<a.length()){ b='0'+b; } for(int i=0;i<a.length();i++){ a[i]=a[i]+(b[i]-'0'); } bool big=false; for(int i=a.length()-1;i>=0;i--){ if(big){ a[i]++; } big=false; if(a[i]>'9'){ a[i]=a[i]-10; big=true; } } if(big) a='1'+a; return a; } string mul(string a,string b){ vector<int> va,vb; if(a=="0" || b=="0") return "0"; string ans; for(int i=0;i<a.length();i++){ va.push_back(a[i]-'0'); } for(int i=0;i<b.length();i++){ vb.push_back(b[i]-'0'); } reverse(va.begin(),va.end()); reverse(vb.begin(),vb.end()); vector<int> res; res.clear(); res.resize(1005); for(int i=0;i<a.length();i++){ for(int j=0;j<b.length();j++){ res[i+j]+=(va[i]*vb[j]); } } for(int i=0;i<1005;i++){ if(res[i]>9){ res[i+1]+=(res[i]/10); res[i]%=10; } } for(int i=0;i<1005;i++){ ans+=(res[i]+'0'); } reverse(ans.begin(),ans.end()); int k=0; while(ans[k]=='0'){ k++; } ans=ans.substr(k); return ans; } bool is_prime(int n){ if(n<2) return false; for(int i=2;i*i<=n;i++) if(n%i==0) return false; return true; } int c(int n,int k){ if(n==0 || n<k) return 0; if(n==k || k==0) return 1; else return c(n-1,k)+c(n-1,k-1); } int n; string s; int a[10],b[10],ans; int main(){ //freopen("input.in","r",stdin); //freopen("output.out","w",stdout); cin>>n; for(int i=1;i<=n;i++){ cin>>s; if(s[0]=='M') a['M']++; if(s[0]=='A') a['A']++; if(s[0]=='R') a['R']++; if(s[0]=='C') a['C']++; if(s[0]=='H') a['H']++; } b[1]=a['M']; b[2]=a['A']; b[3]=a['R']; b[4]=a['C']; b[5]=a['H']; ans+=c(b[1],3)+c(b[2],3)+c(b[3],3)+c(b[4],3)+c(b[5],3)+ b[1]*b[2]*b[3]+b[1]*b[2]*b[4]+b[1]*b[2]*b[5]+b[1]*b[3]*b[4]+b[1]*b[3]*b[5]+b[1]*b[4]*b[5]+ b[2]*b[3]*b[4]+b[2]*b[3]*b[5]+b[3]*b[4]*b[5]; cout<<ans; //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
UNKNOWN
#include <bits/stdc++.h> int main() { int n; scanf("%d", &n); int m = 0; int a = 0; int r = 0; int c = 0; int h = 0; int P[10] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2}; int Q[10] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3}; int R[10] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4}; char name[11]; for (int i = 0; i < n; ++i) { scanf("%s", name); if (name[0] == 'M') m++; if (name[0] == 'A') a++; if (name[0] == 'R') r++; if (name[0] == 'C') c++; if (name[0] == 'H') h++; } int d[5]; d[0] = m; d[1] = a; d[2] = r; d[3] = c; d[4] = h; long long int ans = 0; for (int i = 0; i < 10; ++i) { ans += d[P[i]] * d[Q[i]] * d[R[i]]; } printf("%d", 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 collections N = int(input()) S = [input() for i in range(N)] print(S) SI = [S[i][0] for i in range(N)] cnt = collections.Counter(SI) n = [cnt["M"],cnt["A"],cnt["R"],cnt["C"],cnt["H"]] ans = 0 for i in range(3): for j in range(i+1,5): for k in range(j+1,5): ans += n[i]*n[j]*n[k] print(ans)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; string S; int a[5] = {0}; for (int i = 0; i < N; i++) { cin >> S; if (S[0] == 'M') ++a[0]; else if (S[0] == 'A') ++a[1]; else if (S[0] == 'R') ++a[2]; else if (S[0] == 'C') ++a[3]; else if (S[0] == 'H') ++a[4]; } int Ans = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { Ans += a[i] * a[j] * a[k]; } } } 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> int main() { int n; scanf("%d", &n); char name[10]; int c[5] = {0, 0, 0, 0, 0}; int i, j, k; for (i = 0; i < n; i++) { scanf("%s", name); switch (name[0]) { case 'M': c[0]++; break; case 'A': c[1]++; break; case 'R': c[2]++; break; case 'C': c[3]++; break; case 'H': c[4]++; break; default: break; } } double ans = 0; for (i = 0; i < 3; i++) { for (j = i + 1; j < 4; j++) { for (k = j + 1; k < 5; k++) { ans += c[i] * c[j] * c[k]; } } } printf("%f\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; long long ans; int n; char name[100005][13]; long long s[1000]; bool vis[300]; char a[15]; char d[15] = {"aMARCH"}; bool v[300][300][300]; void dfs(int k) { if (k == 4) { int h = s[a[1]]; for (int i = 2; i <= 3; i++) { h *= s[a[i]]; } if (v[a[1]][a[2]][a[3]] == 0 && v[a[2]][a[1]][a[3]] == 0 && v[a[3]][a[2]][a[1]] == 0 && v[a[1]][a[3]][a[2]] == 0 && v[a[2]][a[3]][a[1]] == 0 && v[a[3]][a[1]][a[2]] == 0) ans += h; v[a[1]][a[2]][a[3]] == 1; return; } for (int i = 1; i <= 5; i++) { if (vis[i] == 0) { vis[i] = 1; a[k] = d[i]; dfs(k + 1); vis[i] = 0; } } } int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> name[i]; s[name[i][0]]++; } int tot = 0; if (s['M'] == 0) tot++; if (s['A'] == 0) tot++; if (s['R'] == 0) tot++; if (s['C'] == 0) tot++; if (s['H'] == 0) tot++; if (tot == 5) { printf("0\n"); return 0; } dfs(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; void Show(vector<bool>& Ps) { for (int i = 0; i < Ps.size(); i++) { if (Ps[i]) { cout << "T" << endl; } else { cout << "F" << endl; } } } void Show(vector<vector<int>>& Ns) { for (int i = 0; i < Ns.size(); i++) { for (int j = 0; j < Ns[i].size(); j++) { cout << Ns[i][j] << " "; } cout << endl; } } int main() { array<int, 5> MARCH; for (int i = 0; i < 5; i++) { MARCH[i] = 0; } int N; long long Count = 0; cin >> N; string S; for (int i = 0; i < N; i++) { cin >> S; if (S[0] == 'M') MARCH[0]++; if (S[0] == 'A') MARCH[1]++; if (S[0] == 'R') MARCH[2]++; if (S[0] == 'C') MARCH[3]++; if (S[0] == 'H') MARCH[4]++; } for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { int C = 1; for (int k = 0; k < 5; k++) { if (k != i && k != j) { C *= MARCH[k]; } } Count += C; } } cout << endl; Count += MARCH[0] * MARCH[2] * MARCH[4]; cout << Count << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); } const double EPS = 1e-10; const double PI = acos(-1.0); const int INF = INT_MAX / 2; const int MOD = 1000000007; int main() { int N; cin >> N; string s; vector<int> c(5, 0); for (int i = (0); i <= ((N)-1); ++i) { 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]++; } } long long ans = 0; for (int i = (0); i <= (4); ++i) { for (int j = (i + 1); j <= (4); ++j) { for (int k = (j + 1); k <= (4); ++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
java
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); String s[] = new String[n]; int mCount = 0; int aCount = 0; int rCount = 0; int cCount = 0; int hCount = 0; for(int i=0;i<n;i++){ s[i] = scanner.next(); switch(s[i].charAt(0)){ case 'M': mCount++; break; case 'A': aCount++; break; case 'R': rCount++; break; case 'C': cCount++; break; case 'H': hCount++; break; } } int[] d = {mCount,aCount,rCount,cCount,hCount}; int[] x = {0,0,0,0,0,0,1,1,1,2}; int[] y = {1,1,1,2,2,3,2,2,3,3}; int[] z = {2,3,4,3,4,4,3,4,4,4}; int allCount = 0; for(int i=0;i<10;i++){ allCount += d[x[i]] * d[y[i]] * d[z[i]]; } System.out.println(allCount); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 7; const int MOD = 1e9 + 7; int main() { int N; int M, A, R, C, H; cin >> N; for (int i = 0; i < N; i++) { string S; cin >> S; if (S[0] == 'M') { M++; } else if (S[0] == 'A') { A++; } else if (S[0] == 'R') { R++; } else if (S[0] == 'C') { C++; } else if (S[0] == 'H') { H++; } } long long ans = M * A * R + M * A * C + M * A * H * +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
cpp
#include <bits/stdc++.h> using namespace std; using pint = pair<int, int>; const long long INFLL = 1LL << 60; const int INFI = 1000000000; int main() { int N; cin >> N; map<char, int> m{}; for (int i = 0; i < N; i++) { string s; cin >> s; m[s[0]]++; } long long ans = 0; vector<int> v(5); v[0] = m['M']; v[1] = m['A']; v[2] = m['R']; v[3] = m['C']; v[4] = m['H']; for (int i = 0; i <= 4; i++) { for (int j = i + 1; j <= 4; j++) { for (int k = j + 1; k <= 4; k++) { ans += v[i] * v[j] * v[k]; } } } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { long long int N; cin >> N; vector<string> S(N); map<string, long long int> p; int a[5]; for (long long int i = 0; i < N; i++) { cin >> S[i]; } for (long long int i = 0; i < N; i++) { if (S[i].front() == 'M') { a[0] += 1; } else if (S[i].front() == 'A') { a[1] += 1; } else if (S[i].front() == 'R') { a[2] += 1; } else if (S[i].front() == 'C') { a[3] += 1; } else if (S[i].front() == 'H') { a[4] += 1; } } long long int sum = 0; sum += a[0] * a[1] * a[2]; sum += a[0] * a[1] * a[3]; sum += a[0] * a[1] * a[4]; sum += a[0] * a[2] * a[3]; sum += a[0] * a[2] * a[4]; sum += a[0] * a[3] * a[4]; sum += a[1] * a[2] * a[3]; sum += a[1] * a[2] * a[3]; sum += a[1] * a[3] * a[4]; sum += a[2] * a[3] * a[4]; cout << sum; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; int main() { int N; cin >> N; vector<string> S(N); int cnM = 0; int cnA = 0; int cnR = 0; int cnC = 0; int cnH = 0; for (int i = 0; i < (int)(N); i++) { cin >> S[i]; if (S[i][0] == 'M') { cnM++; } else if (S[i][0] == 'A') { cnA++; } else if (S[i][0] == 'R') { cnR++; } else if (S[i][0] == 'C') { cnC++; } else if (S[i][0] == 'H') { cnH++; } } ll ans = 0; ans += cnM * cnA * (cnR + cnC + cnH) + (cnM + cnA + cnR) * (cnC * cnH) + (cnM + cnA) * cnR * (cnC + cnH); cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const long long inf = 1e18; int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; int A[5] = {}; for (int i = (0); i < (N); ++i) { string name; cin >> name; char c = name[0]; if (c == 'M') A[0]++; if (c == 'A') A[1]++; if (c == 'R') A[2]++; if (c == 'C') A[3]++; if (c == 'H') A[4]++; } long long count = 0; count += A[0] * A[1] * A[2]; count += A[0] * A[1] * A[3]; count += A[0] * A[1] * A[4]; count += A[0] * A[2] * A[3]; count += A[0] * A[2] * A[4]; count += A[0] * A[3] * A[4]; count += A[1] * A[2] * A[3]; count += A[1] * A[2] * A[4]; count += A[1] * A[3] * A[4]; count += A[2] * A[3] * A[4]; cout << (count) << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.*; public class Main { public static void main(String args[]) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); Map<String, Integer> map = new HashMap<>(); map.put("M",0); map.put("A",0); map.put("R",0); map.put("C",0); map.put("H",0); String[] march ={"M", "A", "R", "C", "H"}; for(int i = 0; i < n; i++){ String str = scanner.next(); str = str.substring(0,1); int v; if(str.equals("M") || str.equals("A") || str.equals("R") || str.equals("C") || str.equals("H")) { if (map.containsKey(str)) { v = map.get(str) + 1; } else { v = 1; } map.put(str,v); } } long ans = map.get(march[0]) * map.get(march[1]) * map.get(march[2]); ans += map.get(march[0]) * map.get(march[1]) * map.get(march[3]); ans += map.get(march[0]) * map.get(march[1]) * map.get(march[4]); ans += map.get(march[0]) * map.get(march[2]) * map.get(march[3]); ans += map.get(march[0]) * map.get(march[2]) * map.get(march[4]); ans += map.get(march[0]) * map.get(march[3]) * map.get(march[4]); ans += map.get(march[1]) * map.get(march[2]) * map.get(march[3]); ans += map.get(march[1]) * map.get(march[2]) * map.get(march[4]); ans += map.get(march[1]) * map.get(march[3]) * map.get(march[4]); ans += map.get(march[2]) * map.get(march[3]) * map.get(march[4]); System.out.println(ans); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main(void) { int n, aniki[5] = {}; long long billy = 0; cin >> n; for (int i = 0; i < n; i++) { string s; cin >> s; if (s[0] == 'M') aniki[0]++; if (s[0] == 'A') aniki[1]++; if (s[0] == 'R') aniki[2]++; if (s[0] == 'C') aniki[3]++; if (s[0] == 'H') aniki[4]++; } for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { billy += aniki[i] * aniki[j] * aniki[k]; } } } cout << billy << 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 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; const int inf = 1e9 + 7; const long long infll = 1ll << 60ll; const long long mod = 1e9 + 7; constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1}; constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1}; vector<int> cnt(5, 0); long long solve(int a, int b, int c) { return cnt[a] * cnt[b] * cnt[c]; } int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; vector<string> s(n); for (int i = 0; i < n; i++) cin >> s[i]; vector<char> c{'M', 'A', 'R', 'C', 'H'}; for (int i = 0; i < n; i++) { for (int j = 0; j < 5; j++) { if (s[i][0] == c[j]) { cnt[j]++; } } } long long ans = 0; ans += solve(0, 1, 2); ans += solve(0, 1, 3); ans += solve(0, 1, 4); ans += solve(0, 2, 3); ans += solve(0, 2, 4); ans += solve(0, 3, 4); ans += solve(1, 2, 3); ans += solve(1, 2, 4); ans += solve(1, 3, 4); ans += solve(2, 3, 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> int main(void) { int a = 0, m = 0, r = 0, c = 0, h = 0, i, num; int answer; scanf("%d", &num); char array[10]; for (i = 1; i <= num; i++) { scanf("%s", array); if (array[0] == 'M') m++; if (array[0] == 'A') a++; if (array[0] == 'R') r++; if (array[0] == 'C') c++; if (array[0] == 'H') h++; } answer = m * a * r + m * a * c + m * a * h + m * r * c + m * r * h + m * c * h + a * r * c + a * c * h + r * c * h + a * r * h; printf("%ld", answer); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python2
def factorial(n): if n==1 or n==0: return 1 else: return n * factorial(n-1) def combination(n, r): if n<r: print (0) exit() return int(factorial(n)/factorial(n-r)/factorial(r)) N = int(input()) names = [] count = [0] * 5 overlap3 = [0] * 5 overlap2 = [0] * 5 for i in range(N): names.append(input()) if names[i][0] == 'M': count[0] += 1 elif names[i][0] == 'A': count[1] += 1 elif names[i][0] == 'R': count[2] += 1 elif names[i][0] == 'C': count[3] += 1 elif names[i][0] == 'H': count[4] += 1 if sum(count)<3: print (0) exit() for i in range(5): if count[i] > 2: overlap3[i] = combination(count[i], 3) if count[i] == 2: overlap2[i] = combination(count[i], 2) out = combination(sum(count),3) - sum(overlap2)*(sum(count)-2) - sum(overlap3) """ print ('1: ', combination(sum(count),3)) print ('2: ', sum(overlap2)*(sum(count)-2)) print ('3: ', sum(overlap3)) """ if out > 0: print (out) else: print (0)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> cnts(5, 0); vector<char> hs = {'A', 'C', 'H', 'M', 'R'}; for (int(i) = 0; (i) < (N); (i)++) { string s; cin >> s; for (int(j) = 0; (j) < (hs.size()); (j)++) { if (s[0] == hs[j]) { cnts[j]++; } } } long long ans = 0; for (int(i) = 0; (i) < (5); (i)++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { ans += cnts[i] * cnts[j] * cnts[k]; } } } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
import sys sys.setrecursionlimit(10000) def combi(n,k): if n<k: return 0 if k==0 or n==k: return 1 elif k==1: return n else: return combi(n-1, k) + combi(n-1,k-1) n=int(input()) s=[input() for _ in range(n)] march=list(map(lambda i:"MARCH"[i], range(5))) march_names={} for x in march: march_names[x]=[] all_len=0 for x in s: if x[0] in march: all_len+=1 march_names[x[0]].append(x) c=combi(all_len, 3) for k in march_names.keys(): kl=len(march_names[k]) if kl<2: continue else: c-=combi(kl,3)+combi(kl,2)*(all_len-kl) print(c)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; string s; int num[200]; long long sum = 0; int main() { long long n; long long k; scanf("%lld", &n); for (int i = 0; i < n; i++) { cin >> s; if (s[0] == 'M') { num[0]++; } else if (s[0] == 'A') { num[1]++; } else if (s[0] == 'R') num[2]++; else if (s[0] == 'C') num[3]++; else if (s[0] == 'H') num[4]++; } sum += num[0] * num[1] * num[2]; sum += num[0] * num[1] * num[3]; sum += num[0] * num[1] * num[4]; sum += num[0] * num[2] * num[3]; sum += num[0] * num[2] * num[4]; sum += num[0] * num[3] * num[4]; sum += num[1] * num[2] * num[3]; sum += num[1] * num[2] * num[4]; sum += num[1] * num[3] * num[4]; sum += num[2] * num[3] * num[4]; printf("%lld\n", sum); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; vector<int> march(5, 0); for (int i = 0; i < n; i++) { 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; ans += march[0] * march[1] * march[2]; ans += march[0] * march[1] * march[3]; ans += march[0] * march[1] * march[4]; ans += march[0] * march[2] * march[3]; ans += march[0] * march[2] * march[4]; ans += march[0] * march[3] * march[4]; ans += march[1] * march[2] * march[3]; ans += march[1] * march[2] * march[4]; ans += march[1] * march[3] * march[4]; ans += march[2] * march[3] * march[4]; cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
n = int(input()) s = [] for i in range(n): s.append(input()[0]) def qwe(y): m = 0 a = 0 r = 0 c = 0 h = 0 for i in y: if i == 'M': m += 1 elif i == 'A': a += 1 elif i == 'R': r += 1 elif i == 'C': c += 1 elif i == 'H': h += 1 else: pass q = [m,a,r,c,h] return q def qwer(arr): count = 0 coun = 0 for j in arr: if j == 0: count += 1 else: coun += 1 if count == 5: return 0 else: if arr[0] == 0: arr[0] = 1 if arr[1] == 0: arr[1] = 1 if arr[2] == 0: arr[2] = 1 if arr[3] == 0: arr[3] = 1 if arr[4] == 0: arr[4] = 1 if coun == 4: asd = arr[0]*arr[1]*arr[2]*arr[3]*arr[4]*4 - 1 return asd if coun == 5: asd = arr[0]*arr[1]*arr[2]*arr[3]*arr[4]*10 - 4 return asd v = qwe(s) print(qwer(v))
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\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; std::cin >> n; std::vector<string> s(n); for (int i = 0; i < (int)(n); i++) std::cin >> s[i]; std::map<char, int> map; for (int i = 0; i < (int)(n); i++) { if (s[i][0] == 'M' || s[i][0] == 'A' || s[i][0] == 'R' || s[i][0] == 'C' || s[i][0] == 'H') { map[s[i][0]]++; } } int num = 0; for (auto i : map) { num++; } int sum = 0; int num2 = 0; for (auto i : map) { if (i.second > 1) { int tmp = (num - 1) * (num - 2) / 2; if (num - 1 == 2) { tmp = 1; } sum += tmp * i.second; } else { num2++; } } sum += num2 * (num2 - 1) * (num2 - 2) / (3 * 2); std::cout << sum << std::endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N, i, a[5], j, k; cin >> N; string s; for (i = 0; i < 5; i++) { a[i] = 0; } for (i = 0; i < N; i++) { cin >> s; if (s.substr(0, 1) == "M") { a[0] += 1; } else if (s.substr(0, 1) == "A") { a[1] += 1; } else if (s.substr(0, 1) == "R") { a[2] += 1; } else if (s.substr(0, 1) == "C") { a[3] += 1; } else if (s.substr(0, 1) == "H") { a[4] += 1; } } long long n = 0, m = 0; for (i = 0; i < 3; i++) { for (j = i + 1; j < 4; j++) { for (k = j + 1; k < 5; k++) { n += a[i] * a[j] * a[k]; if (n >= 10000000000) { m = n / 10000000000; n = n % 10000000000; } } } } if (m == 0) { cout << n; } else { cout << m << 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> void llswap(long long int *x, long long int *y) { long long int temp; temp = *x; *x = *y; *y = temp; } void swap(int *x, int *y) { int tmp; tmp = *x; *x = *y; *y = tmp; } int rmax(int x, int y) { return x > y ? x : y; } int rmin(int x, int y) { return x > y ? y : x; } long long int llrmax(long long int x, long long int y) { return x > y ? x : y; } long long int llrmin(long long int x, long long int y) { return x > y ? y : x; } int asc(const void *a, const void *b) { return *(int *)a - *(int *)b; } int desc(const void *a, const void *b) { return *(int *)b - *(int *)a; } int llasc(const void *a, const void *b) { return *(long long int *)a - *(long long int *)b; } int lldesc(const void *a, const void *b) { return *(long long int *)b - *(long long int *)a; } int main() { int n; static char s[200000][20]; int cnt[5] = {}; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%s", s[i]); switch (s[i][0]) { case 'M': cnt[0]++; break; case 'A': cnt[1]++; break; case 'R': cnt[2]++; break; case 'C': cnt[3]++; break; case 'H': cnt[4]++; break; } } for (int i = 0; i < 5; i++) { } long long int ans = 0; long long int max = -999999999; for (int i = 0; i < 3; i++) { if (cnt[i] == 0) continue; for (int j = i + 1; j < 4; j++) { if (cnt[j] == 0) continue; for (int k = j + 1; k < 5; k++) { if (cnt[k] == 0) continue; max = -999999999; if (cnt[i] > max) max = cnt[i]; if (cnt[j] > max) max = cnt[j]; if (cnt[k] > max) max = cnt[k]; ans += max; } } } printf("%lld\n", ans); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { long long int n, ans = 0; cin >> n; int cnt[5] = {}; char s[21]; for (int i = 0; i < n; ++i) { cin >> s; if (s[0] == 'M') ++cnt[0]; else if (s[0] == 'A') ++cnt[1]; else if (s[0] == 'R') ++cnt[2]; else if (s[0] == 'C') ++cnt[3]; else if (s[0] == 'H') ++cnt[4]; } for (int i = 0; i < 3; ++i) for (int j = i + 1; j < 4; ++j) for (int k = j + 1; k < 5; ++k) ans += cnt[i] * cnt[j] * cnt[k]; cout << ans << '\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
import Data.List nPr :: Integral a => a -> a -> a nPr n r = product [(n - r + 1)..n] nCr :: Integral a => a -> a -> a nCr n r = nPr n r `div` product [1..r] main :: IO () main = do _ <- getLine s <- filter (`elem` "MARCH") . map head . lines <$> getContents let n = length s m = length . filter (==1) . map length . group . sort $ s print $ n `nCr` 3 - m
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s[n]; long long 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++; } 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 + r * c * h; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include <bits/stdc++.h> int main() { long long int n; int mozi[5] = {0}; long long int ans = 1; long long int zenbu = 0; int i, j, k; char s[11]; scanf("%lld", &n); for (i = 0; i < n; i++) { scanf("%s", s); switch (s[0]) { case 'M': mozi[0]++; break; case 'A': mozi[1]++; break; case 'R': mozi[2]++; break; case 'C': mozi[3]++; break; case 'H': mozi[4]++; break; } } for (i = 0; i < 3; i++) { for (j = i + 1; j < 4; j++) { for (k = j + 1; k < 5; k++) { ans = mozi[i] * mozi[j] * mozi[k]; zenbu += ans; } } } printf("%lld", zenbu); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; using vi = vector<int>; const int mod = 1e9 + 7; const long double pi = 3.141592653589793238462643383279502884197; const long double eps = 1e-7; int main() { int N; cin >> N; int name_count[5]; for (int i = 0; i < (5); i++) name_count[i] = 0; string name; for (int i = 0; i < (N); i++) { cin >> name; switch (name[0]) { case 'M': name_count[0]++; break; case 'A': name_count[1]++; break; case 'R': name_count[2]++; break; case 'C': name_count[3]++; break; case 'H': name_count[4]++; break; } } ll ans = 0; for (int i = (0); i < (3); i++) { for (int j = (i + 1); j < (4); j++) { for (int k = (j + 1); k < (5); k++) { ans += (name_count[i] * name_count[j] * name_count[k]); } } } cout << ans; 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> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define fi first #define se second #define mp make_pair #define pb push_back #define fbo find_by_order #define ook order_of_key typedef long long ll; typedef pair<ll,ll> ii; typedef vector<int> vi; typedef long double ld; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; const long long mod = 1000000007; const long long inf = 1e18; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n; cin>>n; ll ans=1; int m=0,a=0,r=0,c=0,h=0; for(int i=0;i<n;i++){ string s; cin>>s; if(s[0]=='M') m+=1; else if(s[0]=='A') a+=1; else if(s[0]=='R') r+=1; else if(s[0]=='C') c+=1; else if(s[0]=='H') h+=1; } 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
#include <bits/stdc++.h> int main(void) { int N; scanf("%d", &N); char S[10000][11]; for (int i = 0; i < N; i++) { scanf("%s", S[i]); } int name[5] = {0}; for (int i = 0; i < N; i++) { switch (S[i][0]) { case 'M': name[0]++; break; case 'A': name[1]++; break; case 'R': name[2]++; break; case 'C': name[3]++; break; case 'H': name[4]++; break; } } int P[10] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2}; int Q[10] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3}; int R[10] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4}; long long int ans = 0; for (int i = 0; i < N; i++) { ans += name[P[i]] * name[Q[i]] * name[R[i]]; } printf("%lld\n", ans); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; char A[maxn][11]; int at[6], aq[6]; long long cek() { long long bak = 0; for (int i = 1; i <= 3; i++) { if (aq[i] == 1) for (int j = i + 1; j <= 4; j++) { if (aq[j] == 1) for (int k = j + 1; k <= 5; k++) { if (aq[k] == 1) bak += at[i] * at[j] * at[k]; } } } return bak; } int main() { int N; while (~scanf(" %d", &N)) { for (int i = 1; i <= 5; i++) { at[i] = 0; aq[i] = 0; } for (int i = 1; i <= N; i++) { scanf(" %s", A[i]); if (A[i][0] == 'M') { at[1] += 1; aq[1] = 1; } if (A[i][0] == 'A') { at[2] += 1; aq[2] = 1; } if (A[i][0] == 'R') { at[3] += 1; aq[3] = 1; } if (A[i][0] == 'C') { at[4] += 1; aq[4] = 1; } if (A[i][0] == 'H') { at[5] += 1; aq[5] = 1; } } long long sum = 0, flag = 0; for (int i = 1; i <= 5; i++) { if (aq[i] == 1) flag += 1; } if (flag >= 3) sum = cek(); printf("%lld\n", sum); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
# -*- coding: utf-8 -*- N = int(input()) name = [] for i in range(0,N): data = input() name.append(data) check = 0 check_m = 0 check_a = 0 check_r = 0 check_c = 0 check_h = 0 for i in name: if i[0] == "M": if check_m == 0: check += 1 check_m += 1 elif i[0] == "A": if check_a == 0: check += 1 check_a += 1 elif i[0] == "R": if check_r == 0: check += 1 check_r += 1 elif i[0] == "C": if check_c == 0: check += 1 check_c += 1 elif i[0] == "H": if check_h == 0: check += 1 check_h += 1 if check < 3: print(0) elif check == 3: s = [] if check_m != 0: s.append(check_m) if check_a != 0: s.append(check_a) if check_r != 0: s.append(check_r) if check_c != 0: s.append(check_c) if check_h != 0: s.append(check_h) se = 1 for i in s: se = se*i print(int(se)) elif check == 4: s = [] if 1 < check_m: s.append(check_m) if 1 < check_a: s.append(check_a) if 1 < check_r: s.append(check_r) if 1 < check_c: s.append(check_c) if 1 < check_h: s.append(check_h) n = (check*(check-1)*(check-2))/6 if len(s) == 0: print(int(n)) else: se = 1 for i in s: se += i*(n-1) print(int(se)) elif check == 5: s = [] if 1 < check_m: s.append(check_m) if 1 < check_a: s.append(check_a) if 1 < check_r: s.append(check_r) if 1 < check_c: s.append(check_c) if 1 < check_h: s.append(check_h) n = (check*(check-1)*(check-2))/6 if len(s) == 0: print(int(n)) else: se = 2 for i in s: se += i*(n-1) print(int(se))
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<string> S(N); vector<int> march(5); for (int i = 0; i < N; i++) { cin >> S.at(i); if (S.at(i).at(0) == 'M') { march.at(0)++; } else if (S.at(i).at(0) == 'A') { march.at(1)++; } else if (S.at(i).at(0) == 'R') { march.at(2)++; } else if (S.at(i).at(0) == 'C') { march.at(3)++; } else if (S.at(i).at(0) == 'H') { march.at(4)++; } } long long int ans = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { ans += march.at(i) * march.at(j) * march.at(k); } } } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; map<char, int> m; m.clear(); for (int i = 0; i < n; i++) { string s; cin >> s; if (s[0] == 'M' || s[0] == 'A' || s[0] == 'R' || s[0] == 'C' || s[0] == 'H') { m[s[0]]++; } } long long ans = 0; ans += m['M'] * m['A'] * m['R']; ans += m['M'] * m['A'] * m['C']; ans += m['M'] * m['A'] * m['H']; ans += m['M'] * m['R'] * m['C']; ans += m['M'] * m['R'] * m['H']; ans += m['M'] * m['C'] * m['H']; ans += m['A'] * m['R'] * m['C']; ans += m['A'] * m['R'] * m['H']; ans += m['A'] * m['C'] * m['H']; ans += m['R'] * m['C'] * m['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
java
import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); String s[] = new String[N]; Map<Character, Long> map = new HashMap<>(); map.put('M', 0L); map.put('A', 0L); map.put('R', 0L); map.put('C', 0L); map.put('H', 0L); for (int i = 0; i < N; i++) { char c = sc.next().charAt(0); if (map.containsKey(c)) { map.put(c, map.get(c)+1); } } int cnt = 0; int idx = 0; ArrayList<Long> w = new ArrayList<>(); for (Entry<Character, Long> e : map.entrySet()) { if (e.getValue()!=0) { w.add(e.getValue()); cnt++; idx++; } } if (cnt<=2) { System.out.println(0); return; } long ans = 0; if (cnt == 3) { ans = 1; for (int i = 0; i < w.size(); i++) { ans *= w.get(i); } System.out.println(ans); return; } if (cnt == 4) { long tmp = 1; for (int i = 0; i < w.size(); i++) { tmp *= w.get(i); } for (int i = 0; i < w.size(); i++) { ans += tmp/w.get(i); } System.out.println(ans); } 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}; if (cnt == 5) { ans = 1; for (int i = 0; i < 10; i++) { ans = w.get(P[i])*w.get(Q[i])*w.get(R[i]); } System.out.println(ans); } } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
# include <cstdio> # include <iostream> using namespace std ; typedef long long ll ; string s ; int N ; ll m ,a ,r ,c , h ; ll D [5]; int P [10]={0 ,0 ,0 ,0 ,0 ,0 ,1 ,1 ,1 ,2}; int Q [10]={1 ,1 ,1 ,2 ,2 ,3 ,2 ,2 ,3 ,3}; int R [10]={2 ,3 ,4 ,3 ,4 ,4 ,3 ,4 ,4 ,4}; int main () { scanf ("% d " ,& N ); for ( int i =0; i < N ; i ++) { cin > > s ; if ( s [0]== 'M') m ++; if ( s [0]== 'A') a ++; if ( s [0]== 'R') r ++; if ( s [0]== 'C') c ++; if ( s [0]== 'H') h ++; } D[0]= m , D[1]= a , D[2]= r , D[3]= c , D[4]= h ; ll res =0; for ( int d =0; d <10; d ++) { res += D [ P [ d ]]* D [ Q [ d ]]* D [ R [ d ]]; printf ("% lld \ n " , res ) } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int march[5]; for (int i = 0; i < 5; i++) { march[i] = 0; } string name; for (int i = 0; i < 5; i++) { cin >> name; if ('M' == name[0]) { march[0]++; } if ('A' == name[0]) { march[1]++; } if ('R' == name[0]) { march[2]++; } if ('C' == name[0]) { march[3]++; } if ('H' == name[0]) { march[4]++; } } long long sum = 0; for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 4; j++) { for (int k = j + 1; k < 5; k++) { sum = sum + march[i] * march[j] * march[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; const int INF = 100100100; const long long LINF = 1e18 + 100; const int MOD = 1e9 + 7; template <typename Iterator> inline bool next_combination(const Iterator first, Iterator k, const Iterator last) { if ((first == last) || (first == k) || (last == k)) return false; Iterator itr1 = first; Iterator itr2 = last; ++itr1; if (last == itr1) return false; itr1 = last; --itr1; itr1 = k; --itr2; while (first != itr1) { if (*--itr1 < *itr2) { Iterator j = k; while (!(*itr1 < *j)) ++j; iter_swap(itr1, j); ++itr1; ++j; itr2 = k; rotate(itr1, j, last); while (last != j) { ++j; ++itr2; } rotate(k, itr2, last); return true; } } rotate(first, k, last); return false; } int main() { cin.tie(0); ios::sync_with_stdio(false); ; int N; cin >> N; map<char, int> m; for (int i = 0; i < (N); i++) { string s; cin >> s; m[s[0]]++; } long long ans = 0; string a = "MARCH"; for (int i = 0; i < (a.size() - 2); i++) { for (int j = (i + 1); j < (a.size() - 1); j++) { for (int k = (j + 1); k < (a.size()); k++) { if (m[a[i]] && m[a[j]] && m[a[k]]) { ans += m[a[i]] * m[a[j]] * m[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() { unsigned long long N = 0; vector<string> M, A, R, C, H; cin >> N; string s; for (int i = 0; i < N; i++) { cin >> s; if (s[0] == 'M') { M.push_back(s); } else if (s[0] == 'A') { A.push_back(s); } else if (s[0] == 'R') { R.push_back(s); } else if (s[0] == 'C') { C.push_back(s); } else if (s[0] == 'H') { H.push_back(s); } } int sum = 0; sum += M.size() * A.size() * R.size(); sum += M.size() * A.size() * C.size(); sum += M.size() * A.size() * H.size(); sum += M.size() * R.size() * C.size(); sum += M.size() * R.size() * H.size(); sum += M.size() * C.size() * H.size(); sum += A.size() * R.size() * C.size(); sum += A.size() * R.size() * H.size(); sum += A.size() * C.size() * H.size(); sum += R.size() * C.size() * H.size(); printf("%d\n", sum); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using ll = long long; using namespace std; const int INF = 1e9; int main() { int N; cin >> N; ll cnt[5] = {0}; string T = "MARCH"; for (int i = 0; i < N; ++i) { string S; cin >> S; for (int j = 0; j < 5; ++j) if (S[0] == T[j]) { ++cnt[j]; break; } } ll ans = 0; for (int i = 0; i < N; ++i) { for (int j = i + 1; j < N; ++j) { for (int k = j + 1; k < N; ++k) { if (i == j || j == k) continue; ans += cnt[i] * cnt[j] * cnt[k]; } } } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
import itertools N = int(input()) # 頭文字Mグループ、頭文字Aグループ、のように分割する # どの3つのグループから1人選ぶかを考える n_initial_MARCH = [0]*5 match_initial = ["M", "A", "R", "C", "H"] for _ in range(N): s = input() for idx in range(N): if s[0] == match_initial[idx]: n_initial_MARCH[idx] += 1 taken_indices = list(itertools.combinations([idx for idx in range(N) if n_initial_MARCH[idx] > 0], 3)) ans = 0 for groups in taken_indices: ans += n_initial_MARCH[groups[0]] * n_initial_MARCH[groups[1]] * n_initial_MARCH[groups[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
UNKNOWN
#include <bits/stdc++.h> const int MOD = 1000000007; int cmp(const void *a, const void *b) { return *(int *)a - *(int *)b; } int cmp2(const void *a, const void *b) { return *(int *)b - *(int *)a; } int gcd(int a, int b) { if (b != 0) return gcd(b, a % b); return a; } long long Lgcd(long long a, long long b) { if (b != 0) return Lgcd(b, a % b); return a; } int lcm(int a, int b) { return a / gcd(a, b) * b; } long long Llcm(long long a, long long b) { return a / Lgcd(a, b) * b; } int n, s = 0, c[5] = {}, visit[5] = {}; long long ans = 0; long long com(int x) { if (s == 3) { int m = 1; for (int i = 0; i < (5); i++) if (visit[i] == 1) m *= c[i]; ans += m; return 0; } for (int i = x; i < n; i++) { if (visit[i] == 0) { visit[i]++; s++; com(i); visit[i]--; s--; } } return ans; } int main() { char s[100000]; scanf("%d%*c", &n); for (int i = 0; i < (n); i++) { scanf("%s", &s[i]); if (s[i] == 'M') c[0]++; if (s[i] == 'A') c[1]++; if (s[i] == 'R') c[2]++; if (s[i] == 'C') c[3]++; if (s[i] == 'H') c[4]++; } printf("%lld", com(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 ll = long long; map<int, int> mpa, mpb; int main() { int N; cin >> N; int M = 0, A = 0, R = 0, C = 0, H = 0; ll ans = 0; string s; for (int i = 1; i <= N; i++) { cin >> s; if (s[0] == 'M') M++; if (s[0] == 'A') A++; if (s[0] == 'R') R++; if (s[0] == 'C') C++; if (s[0] == 'H') H++; } ans = (M * A * R) + (M * A * C) + (M * A * H) + (A * R * C) + (A * C * H) + (R * C * H) + (M * R * H) + (A * R * H) + (C * H * M) + (C * R * M); cout << ans; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N, cnt = 0; long long M = 0, A = 0, R = 0, C = 0, H = 0; string tmp; cin >> N; for (int i = 0; i < N; i++) { cin >> tmp; if (tmp[0] == 'M') M++; else if (tmp[0] == 'A') A++; else if (tmp[0] == 'R') R++; else if (tmp[0] == 'C') C++; else if (tmp[0] == 'H') H++; } cnt += M * A * R; cnt += A * R * C; cnt += R * C * H; cnt += C * H * M; cnt += H * M * A; cout << cnt << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n, m[5] = {0, 0, 0, 0, 0}; long long ans = 0; char s[20]; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%s", s); if (s[0] == 'M') m[0]++; else if (s[0] == 'A') m[1]++; else if (s[0] == 'R') m[2]++; else if (s[0] == 'C') m[3]++; else if (s[0] == 'H') m[4]++; } for (int j = 0; j < 3; j++) for (int k = j + 1; k < 4; k++) for (int l = k + 1; l < 5; l++) ans += m[j] * m[k] * m[l]; 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(){ cin.tie(0),ios::sync_with_stdio(false); int n; cin>>n; unordered_map<int,int>m; for(int i=0;i<6;++i)m[i]=0; for(int i=0;i<n;++i){ string s; cin>>s; ++m[s.front()%8]; } uint64_t ans=0; for(int i=0;i<6;++i){ for(int j=i+1;j<6;++j){ for(int k=j+1;k<6;++k){ ans+=(int64_t)m[i]*m[j]*m[k]; } } } cout<<ans<<"\n"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 atcoder() { int n; cin >> n; int march[5] = {}; for (int i = 0; i < n; ++i) { string tmp; cin >> tmp; if (tmp[0] == 'M') ++march[0]; else if (tmp[0] == 'A') ++march[1]; else if (tmp[0] == 'R') ++march[2]; else if (tmp[0] == 'C') ++march[3]; else if (tmp[0] == 'H') ++march[4]; } long long ans = 0; for (int i = 0; i < n - 2; ++i) { for (int j = i + 1; j < n - 1; ++j) { for (int k = j + 1; k < n; ++k) ans += march[i] * march[j] * march[k]; } } cout << ans << "\n"; return 0; } int main() { cin.tie(0); ios::sync_with_stdio(false); atcoder(); 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<long long> cnts(5, 0); vector<char> hs = {'A', 'C', 'H', 'M', 'R'}; for (int(i) = 0; (i) < (N); (i)++) { string s; cin >> s; for (int(j) = 0; (j) < (hs.size()); (j)++) { if (s[0] == hs[j]) { cnts[j]++; } } } long long ans = 0; for (int(i) = 0; (i) < (5); (i)++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { ans += cnts[i] * cnts[j] * cnts[k]; cout << i << j << k << endl; } } } 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 maxn = 1e5 + 10; string s[maxn]; long long march[5]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) cin >> s[i]; for (int i = 0; i < n; i++) { switch (s[i][0]) { case 'M': march[0]++; case 'A': march[1]++; case 'R': march[2]++; case 'C': march[3]++; case 'H': march[4]++; } } long long ans = march[0] * march[1] * march[2] + march[0] * march[1] * march[3] + march[0] * march[1] * march[4] + march[0] * march[2] * march[3] + march[0] * march[2] * march[4] + march[0] * march[3] * march[4] + march[1] * march[2] * march[3] + march[1] * march[2] * march[4] + march[1] * march[3] * march[4] + march[2] * march[3] * march[4]; cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> int n; int a[300]; int main() { while (1) { scanf("%d", &n); a['M'] = 0; a['A'] = 0; a['R'] = 0; a['C'] = 0; a['H'] = 0; char s[100]; char c; for (int i = 0; i < n; i++) { scanf("%s", s); c = s[0]; a[c]++; } int ans = 0; ans += a['M'] * a['A'] * (a['R'] + a['C'] + a['H']); ans += a['M'] * a['R'] * (a['C'] + a['H']); ans += a['M'] * a['C'] * a['H']; ans += a['A'] * a['R'] * (a['C'] + a['H']); ans += (a['R'] + a['A']) * a['C'] * a['H']; 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; template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } template <typename T> inline T divrup(T a, T b) { if (a % b) return a / b + 1; else return a / b; } template <typename T> inline string toString(const T& a) { ostringstream oss; oss << a; return oss.str(); } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; string S; map<char, int> mp; for (int i = (0); i < (N); i++) { cin >> S; mp[S[0]]++; } vector<int> MARCH(5); MARCH[0] = mp['M']; MARCH[1] = mp['A']; MARCH[2] = mp['R']; MARCH[3] = mp['C']; MARCH[4] = mp['H']; long long ans = 0; int PATT[10][3] = {{0, 1, 2}, {0, 1, 3}, {0, 1, 4}, {0, 2, 3}, {0, 2, 4}, {0, 3, 4}, {1, 2, 3}, {1, 2, 4}, {1, 3, 4}, {2, 3, 4}}; for (int i = (0); i < (10); i++) { ans += MARCH[PATT[i][0]] * MARCH[PATT[i][1]] * MARCH[PATT[i][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
UNKNOWN
using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using Console = System.Console; namespace Atcoder { class Program { static void Main(string[] args) { var N = int.Parse(Console.ReadLine()); int mCount = 0; int aCount = 0; int rCount = 0; int cCount = 0; int hCount = 0; for (int i = 0; i < N; i++) { switch (Console.ReadLine()[0]) { case 'M': mCount++; break; case 'A': aCount++; break; case 'R': rCount++; break; case 'C': cCount++; break; case 'H': hCount++; break; } } long ret = mCount * aCount * rCount + mCount * aCount * cCount + mCount * aCount * hCount + mCount * rCount * cCount + mCount * rCount * hCount + aCount * rCount * cCount + aCount * rCount * hCount + aCount * cCount * hCount + rCount * cCount * hCount; Console.WriteLine(ret); } } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
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; int a = 0; int r = 0; int c = 0; int h = 0; long n = 0; String S[] = new String [N]; for(int i=0;i<N;i++){ S[i] = String.valueOf(sc.next().charAt(0)); if(S[i].equals("M")) m++; else if(S[i].equals("A")) a++; else if(S[i].equals("R")) r++; else if(S[i].equals("C")) c++; else if(S[i].equals("H")) h++; } // System.out.println(m + " " + a + " "+ r + " "+ c + " "+ h ); n = (long) m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*r*h+a*c*h+r*c*h ; System.out.println(n); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<string> s(n); for (int i = 0; i < (int)(n); i++) cin >> s[i]; vector<int> c(5, 0); for (int i = 0; i < (int)(n); i++) { if (s[i][0] == 'M') c[0]++; if (s[i][0] == 'A') c[1]++; if (s[i][0] == 'R') c[2]++; if (s[i][0] == 'C') c[3]++; if (s[i][0] == 'H') c[4]++; } long long int ans = 0; for (int i = int(0); i < int(5); i++) { for (int j = int(i + 1); j < int(5); j++) { for (int k = int(j + 1); k < int(5); k++) { ans += c[i] * c[j] * c[k]; cout << i << " " << j << " " << k << endl; } } } 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 a[10] = {}; for (int i = 0; i < n; i++) { string s; cin >> s; if (s[0] == 'M') a[1]++; else if (s[0] == 'A') a[2]++; else if (s[0] == 'R') a[3]++; else if (s[0] == 'C') a[4]++; else if (s[0] == 'H') a[5]++; } long long ans = 0; for (int i = 1; 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
python3
import sys readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines def main(): N = int(readline()) S = list(map(lambda x: x.decode("UTF-8"), readlines())) S = list(map(lambda x: x.rstrip('\n'), S)) march = list("MARCH") cnt = [0] * 5 for i in range(N): for j in range(5): if S[i][0] == march[j]: cnt[j] += 1 ans = 0 for i in range(N-2): for j in range(i+1, N-1): for k in range(j+1, N): ans += cnt[i] * cnt[j] * cnt[k] print(ans) main()
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; int a[5] = {0}; char tmp[50]; long long count = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> tmp; if (tmp[0] == 'M') a[0]++; if (tmp[0] == 'A') a[1]++; if (tmp[0] == 'R') a[2]++; if (tmp[0] == 'C') a[3]++; if (tmp[0] == 'H') a[4]++; } for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 4; j++) { for (int k = j + 1; k < 5; k++) { count += a[i] * a[j] * a[k]; } } } printf("%d\n", count); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); //入力 int N = sc.nextInt(); List<String> SList = new ArrayList<String>(); for (int i = 0; i < N; i++) { String S = sc.next(); SList.add(S); } int flagM=0; int countM=0; int flagA=0; int countA=0; int flagR=0; int countR=0; int flagC=0; int countC=0; int flagH=0; int countH=0; Long answer = (long)0; for (int i = 0; i < N; i++) { if (SList.get(i).substring(0,1).equals("M")) { flagM = 1; countM++; } else if (SList.get(i).substring(0,1).equals("A")) { flagA = 1; countA++; } else if (SList.get(i).substring(0,1).equals("R")) { flagR = 1; countR++; } else if (SList.get(i).substring(0,1).equals("C")) { flagC = 1; countC++; } else if (SList.get(i).substring(0,1).equals("H")) { flagH = 1; countH++; } else { } } if (flagM + flagA + flagR + flagC + flagH >2) { answer = answer + ((long)countM * (long)countA * (long)countR) + ((long)countM * (long)countA * (long)countC) + ((long)countM * (long)countA * (long)countH) + ((long)countM * (long)countR * (long)countC) + ((long)countM * (long)countR * (long)countH) + ((long)countM * (long)countC * (long)countH) + ((long)countA * (long)countR * (long)countC) + ((long)countA * (long)countR * (long)countH) + ((long)countR * (long)countC * (long)countH); } System.out.println(answer); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
n=int(input()) s=[] for i in range(n): i=input() s.append(i[0]) import collections c = collections.Counter(s) d=['M','A','R','C','H'] ans=0 for i in range(n-2): for j in range(i+1,n-1): for k in range(j+1,n): ans+=c[d[i]]*c[d[j]]*c[d[k]] print(ans)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { char a[100000][10]; int b; long 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][0] == 'M') c++; if (a[i][0] == 'A') d++; if (a[i][0] == 'R') e++; if (a[i][0] == 'C') f++; if (a[i][0] == 'H') g++; } h = c * d * e + c * d * f + c * d * g + c * e * f + c * e * g + c * f * g + d * e * f + d * e * g + d * f * 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> int q[6]; long long int ans; int main() { int n; char ch[11]; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%s", ch); if (ch[0] == 'M') q[1]++; if (ch[0] == 'A') q[2]++; if (ch[0] == 'R') q[3]++; if (ch[0] == 'C') q[4]++; if (ch[0] == 'H') q[5]++; } for (int i = 1; i <= 3; i++) { for (int j = i + 1; j <= 4; j++) { for (int k = j + 1; k <= 5; k++) { if (q[i] == 0 || q[j] == 0 || q[k] == 0) ; else ans = ans + q[i] * q[j] * q[k]; } } } printf("%lld", ans); }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
import itertools n = int(input()) s = [] for i in range(n): name = input() if name[0] in ["M", "A", "R", "C", "H"]: s.append(name) ptn = list(itertools.combinations(s, 3)) cnt = 0 for j in ptn: if j[0][0] != j[1][0] and j[1][0] != j[2][0] and j[2][0] != j[0][0]: cnt += 1 print(cnt)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> int n, march[5]; char s[16]; int main() { scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%s", s); if (s[0] == 'M') march[0]++; if (s[0] == 'A') march[1]++; if (s[0] == 'R') march[2]++; if (s[0] == 'C') march[3]++; if (s[0] == 'H') march[4]++; } int_fast64_t ans = 0; for (int i = 0; i < 5; i++) for (int j = i + 1; j < 5; j++) for (int k = j + 1; k < 5; k++) { ans += march[i] * march[j] * march[k]; } printf("%ld\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 n; cin >> n; string s[100001]; for (int i = 0; i < n; i++) cin >> s[i]; int count[5] = {0}; int ari = 0; string march = "MARCH"; for (int i = 0; i < n; i++) { for (int j = 0; j < 5; j++) { if (march[j] == s[i][0]) count[j]++; } } long long ans = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { if (i == j) continue; for (int k = j + 1; k < 5; k++) { if (i == k || j == k) continue; 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 <iostream> #include <string.h> using namespace std; typedef long long int ll; int main(){ int N; cin >> N; char s[16]; int p[256] = {}; for (int i = 0; i < n; i++) { cin >> s; p[s[0]]++; } char *c = "MARCH"; int64_t q[5]; for (int i = 0; i < 5; i++) { q[i] = p[c[i]]; } int64_t total = 0; total = q[0] * q[1] * q[2] + q[0] * q[1] * q[3] + q[0] * q[1] * q[4] + q[0] * q[2] * q[3] + q[0] * q[2] * q[4] + q[0] * q[3] * q[4] + q[1] * q[2] * q[3] + q[1] * q[2] * q[4] + q[1] * q[3] * q[4] + q[2] * q[3] * q[4]; cout << total << 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 <vector> #include <map> using namespace std; int main(){ int N; cin >> N; vector<string> name(N); map m<char, int>; for(int i = 0; i < N; i++){ cin >> name[i]; m[name[i][0]]++; } string march = "MARCH"; long long int ans = 0LL; for(int i = 0; i < march.size(); i++){ for(int j = i + 1; j < march.size(); j++){ for(int k = j + 1; k < march.size(); k++){ ans += m[march[i]] * m[march[j]] * m[march[k]]; } } } cout << ans; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
import java.util.* fun main(args: Array<String>) { val sc = Scanner(System.`in`) val n = sc.nextInt() val s = (0 until n).map { sc.next() } println(problem089c(n, s)) } fun problem089c(n: Int, s: List<String>): Long { var count = 0L fun function(s: String) = when (s) { "M", "A", "R", "C", "H" -> true else -> false } for (i in 0 until n) { val si = s[i].take(1) if (!function(si)) continue for (j in i until n) { val sj = s[j].take(1) if (!function(sj)) continue for (k in j until n) { val sk = s[k].take(1) if (!function(sk)) continue if (si != sj && si != sk && sj != sk) { count++ } } } } return count }