Search is not available for this dataset
name
stringlengths
2
88
description
stringlengths
31
8.62k
public_tests
dict
private_tests
dict
solution_type
stringclasses
2 values
programming_language
stringclasses
5 values
solution
stringlengths
1
983k
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<string> s; vector<int> num(5, 0); for (int i = 0; i < n; i++) { string tmp_s; cin >> tmp_s; if (tmp_s.at(0) == 'M' || tmp_s.at(0) == 'A' || tmp_s.at(0) == 'R' || tmp_s.at(0) == 'C' || tmp_s.at(0) == 'H') { s.push_back(tmp_s); if (tmp_s.at(0) == 'M') num[0]++; else if (tmp_s.at(0) == 'A') num[1]++; else if (tmp_s.at(0) == 'R') num[2]++; else if (tmp_s.at(0) == 'C') num[3]++; else if (tmp_s.at(0) == 'H') num[4]++; } } long long ans = 0; ans += num[0] * num[1] * num[2] * 1 * 1; ans += num[0] * num[1] * 1 * num[3] * 1; ans += num[0] * 1 * num[2] * num[3] * 1; ans += 1 * num[1] * num[2] * num[3] * 1; ans += num[0] * num[1] * 1 * 1 * num[4]; ans += num[0] * 1 * num[2] * 1 * num[4]; ans += 1 * num[1] * num[2] * 1 * num[4]; ans += num[0] * 1 * 1 * num[3] * num[4]; ans += 1 * num[1] * 1 * num[3] * num[4]; ans += 1 * 1 * num[2] * num[3] * num[4]; cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { long long n, ans = 0; cin >> n; vector<int> x(5, 0); for (int(i) = 0; i < (n); i++) { string s, m = "MARCH"; cin >> s; for (int(j) = 0; j < (5); j++) if (s.at(0) == m.at(j)) x.at(j)++; } for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 4; j++) { for (int k = j + 1; k < 5; k++) { ans += x.at(i) * x.at(j) * x.at(k); } } } cout << ans; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n, c[5] = {0}; cin >> n; string s = "MARCH"; for (int i = 0; i < n; i++) { string t; cin >> t; for (int j = 0; j < 5; j++) { if (t[0] == s[j]) { c[j]++; } } } int ans = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { ans += c[i] * c[j] * c[k]; } } } cout << (long long)ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include <bits/stdc++.h> int main() { int n; long long int ans; scanf("%d", &n); int i; long m = 0, a = 0, r = 0, c = 0, h = 0; char s[n + 1][12]; for (i = 0; i <= n; i++) gets(s[i]); for (i = 0; i <= n; i++) { switch (s[i][0]) { case 'M': m++; break; case 'A': a++; break; case 'R': r++; break; case 'C': c++; break; case 'H': h++; break; } } ans = m * a * r + m * a * c + m * a * h + m * r * c + m * r * h + m * c * h + a * r * c + a * r * h + a * c * h + r * c * h; printf("%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
cpp
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; string s; long long MARCH[5] = {}; for (long long i = 0; i < n; i++) { cin >> s; switch (s[0]) { case 'M': MARCH[0]++; break; case 'A': MARCH[1]++; break; case 'R': MARCH[2]++; break; case 'C': MARCH[3]++; break; case 'H': MARCH[4]++; break; } } long long ans = 0; for (long long i = 0; i < n; i++) { for (long long j = i + 1; j < n; j++) { for (long long k = j + 1; k < n; k++) { ans += MARCH[i] * MARCH[j] * MARCH[k]; } } } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int INF = 1e9 + 7; int main() { int n; cin >> n; string s; int m = 0, a = 0, r = 0, c = 0, h = 0; 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++; } cout << long long(m * a * r + m * a * c + m * a * h + m * r * c + m * r * h + m * c * h + a * r * c + a * r * h + a * c * h + r * c * h) << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); String[] s = new String[N]; for (int i = 0; i < s.length; i++) { s[i] = sc.next(); } int[] data = new int[5]; for (int i = 0; i < s.length; i++) { String x = String.valueOf(s[i].charAt(0)); if (x.equals("M")) { data[0]++; } else if (x.equals("A")) { data[1]++; } else if (x.equals("R")) { data[2]++; } else if (x.equals("C")) { data[3]++; } else if (x.equals("H")) { data[4]++; } } int cnt = 0; for(int i = 0; i < 5; i++) { for(int j = i; j < 5; j++) { for(int k = j; k < 5; k++) { if((i == j) || (i == k) || (j == k)) { } else { cnt += data[i] * data[j] * data[k]; } } } } System.out.println(cnt); sc.close(); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int INF = 999999999; const int MOD = 1000000007; int dy[] = {0, 0, 1, -1}; int dx[] = {1, -1, 0, 0}; int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } int n, d[5] = {}; const char march[] = {'M', 'A', 'R', 'C', 'H'}; int main() { cin >> n; for (int i = 0; i < 5; i++) d[i] = 0; for (int i = 0; i < n; i++) { string s; cin >> s; for (int j = 0; j < 5; j++) { if (s[0] == march[j]) d[j]++; } } long long ans = 0LL; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { ans += d[i] * d[j] * d[k]; } } } printf("%lld\n", ans); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; public static class Program { public static void Main(params string[] args) { var ary = "MARCH".ToArray(); var hash = new HashSet<Char>(ary); var n = int.Parse(Console.ReadLine()); var d = Enumerable .Range(0, n) .Select(x => Console.ReadLine()) .Where(x => hash.Contains(x[0])) .GroupBy(x => x[0]) .ToDictionary(x => x.Key, x => x.Count()); var r = 0; for (int i = 0; i < ary.Length; i++) { for (int j = i + 1; j < ary.Length; j++) { for (int k = j + 1; k < ary.Length; k++) { if (d.TryGetValue(ary[i], out var v1) && d.TryGetValue(ary[j], out var v2) && d.TryGetValue(ary[k], out var v3)) { r += v1 * v2 * v3; } } } } Console.WriteLine(r); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int n; cin >> n; vector<int> s(5); for (int i = 0; i < n; i++) { string k; cin >> k; if (k[0] == 'M') s[0]++; if (k[0] == 'A') s[1]++; if (k[0] == 'R') s[2]++; if (k[0] == 'C') s[3]++; if (k[0] == 'H') s[4]++; } ll total = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { total += s[i] * s[j] * s[k]; } } } 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 <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; string S; int m = 0, a = 0, r = 0, c = 0, h = 0; for (int i = 0; i < N; i++) { cin >> S; if (S.at(0) == 'M') { m++; } if (S.at(0) == 'A') { a++; } if (S.at(0) == 'R') { r++; } if (S.at(0) == 'C') { c++; } if (S.at(0) == 'H') { h++; } } 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 + a * c * h << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vvi = vector<vi>; using pii = pair<int, int>; using tiii = tuple<int, int, int>; const ll mod = 1e9 + 7; const int INF = (1 << 30) - 1; const ll INFLL = (1LL << 62) - 1; const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } int main() { string MARCH = "MARCH"; int c[5] = {0}; int N; cin >> N; for (int i = (0); i < ((N)); ++i) { string S; cin >> S; for (int j = (0); j < ((5)); ++j) { if (S[0] == MARCH[j]) { c[j]++; } } } for (int i = (0); i < ((5)); ++i) { cout << "c[i]" << " = " << (c[i]) << endl; ; } 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; 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; void init(int* a) { for (int i = 0; i < sizeof(a) / sizeof(int); i++) { a[i] = 0; } } int main() { int n; long long int ans = 0; int mch[5]; cin >> n; string name[n]; for (int i = 0; i < 5; i++) { mch[i] = 0; } for (int i = 0; i < n; i++) { cin >> name[i]; if (name[i][0] == 'M') { mch[0]++; } else if (name[i][0] == 'A') { mch[1]++; } else if (name[i][0] == 'R') { mch[2]++; } else if (name[i][0] == 'C') { mch[3]++; } else if (name[i][0] == 'H') { mch[4]++; } } for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { for (int k = j + 1; k < n; k++) { ans += mch[i] * mch[j] * mch[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> #pragma GCC optimize("O3") using namespace std; struct point_t { int x; int y; }; const int maxH = 3e2, maxW = maxH; const int maxA = 9e4; const int maxQ = 10e5; int H, W, D; int Q; point_t A[maxH * maxW + 1]; int L, R; inline int magic(int i, int j, int x, int y) { return abs(x - i) + abs(y - j); } inline void findsq(int val, int& x, int& y) { x = A[val].x; y = A[val].y; } void solve(int L, int R) { int i, j, previ, prevj; long long sum = 0; findsq(L, previ, prevj); for (; L != R; L += D) { findsq(L + D, i, j); sum += magic(previ, prevj, i, j); previ = i; prevj = j; } cout << sum << endl; } int main() { int val; scanf("%d %d %d", &H, &W, &D); for (int i = 1; i <= H; ++i) { for (int j = 1; j <= W; ++j) { scanf("%d", &val); A[val] = {i, j}; } } scanf("%d", &Q); for (int i = 1; i <= Q; ++i) { scanf("%d %d", &L, &R); solve(L, R); } return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner((System.in)); int n = sc.nextInt(); String[] s = new String[n]; int m = 0, a = 0, r = 0, c = 0, h = 0, each = 0; long ans = 0; for (int i = 0; i < n; i++) { s[i] = sc.next(); if (s[i].startsWith("M")) { each += m == 0 ? 1 : 0; m++; } else if (s[i].startsWith("A")) { each += a == 0 ? 1 : 0; a++; } else if (s[i].startsWith("R")) { each += r == 0 ? 1 : 0; r++; } else if (s[i].startsWith("C")) { each += c == 0 ? 1 : 0; c++; } else if (s[i].startsWith("H")) { each += h == 0 ? 1 : 0; h++; } } if (each == 3) { ans = 1; if (m != 0) { ans *= m; } if (a != 0) { ans *= a; } if (r != 0) { ans *= r; } if (c != 0) { ans *= c; } if (h != 0) { ans *= h; } } else if (each > 3) { ans = each; ans += m > 1 ? (each - 1) * (m - 1) : 0; ans += a > 1 ? (each - 1) * (a - 1) : 0; ans += r > 1 ? (each - 1) * (r - 1) : 0; ans += c > 1 ? (each - 1) * (c - 1) : 0; ans += h > 1 ? (each - 1) * (h - 1) : 0; } System.out.println(ans); sc.close(); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; template <class T> void cou(vector<vector<T>> a) { long long b = a.size(); long long c = a[0].size(); for (long long i = 0; i < b; i++) { for (long long j = 0; j < c; j++) { cout << a[i][j]; if (j == c - 1) cout << endl; else cout << ' '; } } } long long wari(long long a, long long b) { if (a % b == 0) return a / b; else return a / b + 1; } long long keta(long long a) { double b = a; b = log10(b); long long c = b; return c + 1; } long long souwa(long long a) { return a * (a + 1) / 2; } bool prime(long long a) { if (a < 2) return false; else if (a == 2) return true; else if (a % 2 == 0) return false; double b = sqrt(a); for (long long i = 3; i <= b; i += 2) { if (a % i == 0) { return false; } } return true; } struct Union { vector<long long> par; Union(long long a) { par = vector<long long>(a, -1); } long long find(long long a) { if (par[a] < 0) return a; else return par[a] = find(par[a]); } bool same(long long a, long long b) { return find(a) == find(b); } long long Size(long long a) { return -par[find(a)]; } void unite(long long a, long long b) { a = find(a); b = find(b); if (a == b) return; if (Size(b) > Size(a)) swap<long long>(a, b); par[a] += par[b]; par[b] = a; } }; long long ketas(long long a) { string b = to_string(a); long long c = 0; for (long long i = 0; i < keta(a); i++) { c += b[i] - '0'; } return c; } long long gcm(long long a, long long b) { if (b == 0) return a; return gcm(b, a % b); } long long lcm(long long a, long long b) { return a / gcm(a, b) * b; } signed main() { long long a, e = 0; cin >> a; string b; vector<char> c(a); vector<long long> d(5, 0); for (long long i = 0; i < a; i++) { cin >> b; c[i] = b[0]; } for (long long i = 0; i < a; i++) { if (c[i] == 'M') d[0]++; if (c[i] == 'A') d[1]++; if (c[i] == 'R') d[2]++; if (c[i] == 'C') d[3]++; if (c[i] == 'H') d[4]++; } if (d[0] + d[1] + d[2] + d[3] + d[4] < 3) cout << 0 << endl; else { for (long long i = 0; i < 5; i++) { if (d[i] > 0) e++; } if (e < 3) cout << 0 << endl; if (e == 3) { sort(d.begin(), d.end()); cout << d[2] * d[3] * d[4] << endl; } if (e == 4) { sort(d.begin(), d.end()); cout << d[1] * d[2] * d[3] + (d[1] * d[2] + d[2] * d[3] + d[1] * d[3]) * d[4] << endl; } if (e == 5) { sort(d.begin(), d.end()); long long f = d[1] * d[2] * d[3] + (d[1] * d[2] + d[2] * d[3] + d[1] * d[3]) * d[4]; long long g = 0; for (long long i = 1; i < 5; i++) { for (long long j = i + 1; j < 5; j++) { g += d[i] * d[j]; } } g *= d[0]; cout << f * g << 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; string s[n]; int a[5] = {}; string march = "MARCH"; for (int i = 0; i < n; i++) { cin >> s[i]; for (int j = 0; j < 5; j++) if (s[i].at(0) == march[j]) a[j]++; } long long 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]; cerr << ans << endl; } cout << ans; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n, a[5]; long long ans = 0; cin >> n; string s[n]; for (int i = 0; i < 5; i++) { a[i] = 0; } for (long long i = 0; i < n; i++) { cin >> s[i]; if (s[i][0] == 'A') { a[0]++; } if (s[i][0] == 'C') { a[1]++; } if (s[i][0] == 'H') { a[2]++; } if (s[i][0] == 'M') { a[3]++; } if (s[i][0] == 'R') { a[4]++; } } for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { ans += a[i] * a[j] * a[k]; } } } cout << ans; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; string s; int num[200]; long long sum = 0; int main() { int n; scanf("%d", &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
python3
from collections import Counter, deque # import copy # from fractions import gcd # from functools import reduce # from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product # import math # import numpy as np import sys sys.setrecursionlimit(10 ** 5 + 10) # input = sys.stdin.readline def resolve(): N=int(input()) S=[str(input())[0] for i in range(N)] for i in S: if i != 'M' and i != 'A' and i != 'R' and i != 'C' and i != 'H': S.remove(i) SS=Counter(S) SSS=SS.items() from operator import mul from functools import reduce # 未読 def comb(n, r): if n < r: return 0 else: r = min(n - r, r) if r == 0: return 1 over = reduce(mul, range(n, n - r, -1)) under = reduce(mul, range(1, r + 1)) return over // under ans=comb(len(SSS),3) cnt=0 for i in SSS: if i[1]!=1: ans*=i[1] cnt+=1 minus=comb(len(SSS)-cnt,3) ans-=minus print(ans) resolve()
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\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 = 1e3 + 10; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; int m[5]; for (int(i) = 0; (i) < (5); ++(i)) m[i] = 0; for (int(i) = 0; (i) < (n); ++(i)) { string s; cin >> 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]++; } int cnt = 0; for (int(i) = 0; (i) < (5); ++(i)) { if (m[i] == 0) cnt++; } long long ans = 0; if (cnt > 2) cout << (0) << endl; else { for (int(i) = 0; (i) < (5); ++(i)) for (int(j) = i; (j) < (5); ++(j)) for (int(k) = j; (k) < (5); ++(k)) { if (i == j || j == k || k == i) continue; ans += m[i] * m[j] * m[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> const int INF = 1e5; const int MOD = 1e9 + 7; using namespace std; int main() { int n; cin >> n; string s; string F = "MARCH"; long long ans = 0; int count[5] = {}; for (int i = 0; i < (n); i++) { cin >> s; for (int j = 0; j < (5); j++) { if (s[0] == F[j]) { count[j]++; } } } for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 4; j++) { for (int k = j + 1; k < 5; k++) { ans += count[i] * count[j] * count[k]; } } } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; long long int a = 0, b = 0, c = 1, x = 0, y = 0, z = 0, maxy = -1, mini = 9999, counter = 0, startp = 0, endp = 0, checker = 0; std::vector<unsigned long long int> vec{}, vecsec{}; int iremono[100001]; std::vector<long long int> kinds{}, ans{}, kaku{}; char moji, moji2; bool okada = false, okada2 = false; std::string output, output2, input, one, two; char cutcount[201]; int kakunou2[50][50] = {}; int M, A, R, C, H; int ctoi(const char c) { if ('0' <= c && c <= '9') return (c - '0'); return -1; } unsigned long long int LCM(unsigned long long int a, unsigned long long int b) { unsigned long long int i, j; i = a; j = b; while (true) { c = i % j; i = j; if (c != 0) { j = c; } else { break; } } return j * (a / j) * (b / j); } int main() { cin >> a; for (long long i = 0; i < a; i++) { cin >> one; if (one[0] == 'M') { M++; } if (one[0] == 'A') { A++; } if (one[0] == 'R') { R++; } if (one[0] == 'C') { C++; } if (one[0] == 'H') { H++; } } cout << M * A * R + M * A * C + M * A * H + M * R * C + M * R * H + M * C * H + A * R * C + A * R * H + A * C * H + R * C * H << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int N; int march[5]; char pattern[5] = {'M', 'A', 'R', 'C', 'H'}; long long ans = 0; int main() { cin >> N; for (int i = 0; i < N; ++i) { string S; cin >> S; for (int i = 0; i < 5; ++i) { if (S[0] == pattern[i]) { ++march[i]; break; } } } for (int a = 0; a < 5; ++a) { for (int b = a + 1; b < 5; ++b) { for (int c = b + 1; c < 5; ++c) { ans += march[a] * march[b] * march[c]; } } } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> const int INF = 2147483647; const long long int MOD = 1000000007; using namespace std; using ll = long long; using P = pair<int, int>; template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } int main() { int n; cin >> n; vector<int> ini(5, 0); for (long long i = 0; i < (n); ++i) { string s; cin >> s; if (s[0] == 'M') ini[0]++; if (s[0] == 'A') ini[1]++; if (s[0] == 'R') ini[2]++; if (s[0] == 'C') ini[3]++; if (s[0] == 'H') ini[4]++; } ll res = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { res += ini[i] * ini[j] * ini[k]; } } } cout << res << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<string> S(N); for (int i = 0; i < N; i++) cin >> S[i]; set<string> m_name, a_name, r_name, c_name, h_name; for (int i = 0; i < N; i++) { if (S[i].front() == 'M') m_name.insert(S[i]); if (S[i].front() == 'A') a_name.insert(S[i]); if (S[i].front() == 'R') r_name.insert(S[i]); if (S[i].front() == 'C') c_name.insert(S[i]); if (S[i].front() == 'H') h_name.insert(S[i]); } cout << m_name.size() * a_name.size() * r_name.size() + m_name.size() * a_name.size() * c_name.size() + m_name.size() * a_name.size() * h_name.size() + m_name.size() * r_name.size() * c_name.size() + m_name.size() * r_name.size() * h_name.size() + m_name.size() * c_name.size() * h_name.size() + a_name.size() * r_name.size() * c_name.size() + a_name.size() * r_name.size() * h_name.size() + r_name.size() * c_name.size() * h_name.size() << 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 import collections N = int(input()) seq = [] for i in range(N): s = input() if s[0] in ["M","A","R","C","H"]: seq.append(s) a = [] for i in list(itertools.combinations(seq,3)): temp = [i[0][0],i[1][0],i[2][0]] countdict = collections.Counter(temp) if len(countdict) == 3: a.append(i) print(len(a))
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; char s[1000]; int main() { int m, a, r, c, h, i, n, sum = 0; scanf("%d", &n); for (i = 1; i <= n; i++) { scanf("%s", 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++; } sum = m * a * r + m * a * c + m * a * h + m * r * c + m * r * h + m * c * h + a * r * c + a * c * h + r * c * h + a * r * h; printf("%d", 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 tests(int a, int b) { return (a == 0) ? 1 : b; } int main() { long int NNN; cin >> NNN; string temp; long int memo[5] = {0}; for (int i = 0; i < NNN; i++) { cin >> temp; if (temp[0] == 'M') { memo[0]++; } else if (temp[0] == 'A') { memo[1]++; } else if (temp[0] == 'R') { memo[2]++; } else if (temp[0] == 'C') { memo[3]++; } else if (temp[0] == 'H') { memo[4]++; } } long int ans = 0; long int bit = 0; long int bits[5] = {0}; long int tbit = 0; bool check = true; while (bit < 32) { tbit = bit; check = true; for (int i = 0; i < 5; i++) { bits[i] = tbit % 2; tbit = (tbit - tbit % 2) / 2; } if (bits[0] + bits[1] + bits[2] + bits[3] + bits[4] != 3) { bit++; continue; } else { for (int i = 0; i < 5; i++) { if (bits[i] == 1 && memo[i] == 0) { check = false; } } if (check) { ans = ans + tests(bits[0], memo[0]) * tests(bits[1], memo[1]) * tests(bits[2], memo[2]) * tests(bits[3], memo[3]) * tests(bits[4], memo[4]); } } bit++; } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
'use strict' function main(s) { s = s.split('\n'); const n = Number(s[0]); const names = s.slice(1, -1); let ans = 0; const bfs = (i, list) => { if (i === n || list.length === 3) { const has = [0, 0, 0, 0, 0]; for (const name of list) { if (name.charAt(0) === 'M') has[0] += 1; if (name.charAt(0) === 'A') has[1] += 1; if (name.charAt(0) === 'R') has[2] += 1; if (name.charAt(0) === 'C') has[3] += 1; if (name.charAt(0) === 'H') has[4] += 1; } const num = has.filter(c => c === 1).length; const sum = has.reduce((a, b) => a + b);n if (num === 3 && sum === 3) ans += 1; return; } bfs(i + 1, [...list, names[i]]); bfs(i + 1, list); return; } bfs(0, []); console.log(ans); } 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; struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast; using ll = long long; using ull = unsigned long long; using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>; using pii = pair<int, int>; using D = double; using P = complex<D>; using vs = vector<string>; template <typename T> using PQ = priority_queue<T>; template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>; const int INF = 1001001001; const ll LINF = 1001001001001001001ll; const int MOD = 1e9 + 7; const D EPS = 1e-9; const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1}; inline bool inside(int y, int x, int H, int W) { return y >= 0 && x >= 0 && y < H && x < W; } inline int in() { int x; cin >> x; return x; } inline ll IN() { ll x; cin >> x; return x; } inline vs split(const string& t, char c) { vs v; stringstream s(t); string b; while (getline(s, b, c)) v.emplace_back(b); return v; } template <typename T> inline bool chmin(T& a, const T& b) { if (a > b) a = b; return a > b; } template <typename T> inline bool chmax(T& a, const T& b) { if (a < b) a = b; return a < b; } template <typename T, typename S> inline void print(const pair<T, S>& p) { cout << p.first << " " << p.second << endl; } template <typename T> inline void print(const T& x) { cout << x << '\n'; } template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) { for (auto&& p : v) print(p); } template <typename T> inline void print(const vector<T>& v, string s = " ") { for (ll i = (0); i < (ll)(v.size()); ++i) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n"); } int rec(int i) { if (i == 1) return 1; else return i * rec(i - 1); } signed main() { int n; cin >> n; string s[n]; ll cnt = 0; ll m = 0, a = 0, r = 0, c = 0, h = 0; for (ll i = (0); i < (ll)(n); ++i) { cin >> s[i]; if (s[i] == "M") m++; else if (s[i] == "A") a++; else if (s[i] == "R") r++; else if (s[i] == "C") c++; else if (s[i] == "H") h++; } cnt += m * a * r; cnt += m * a * c; cnt += m * a * h; cnt += m * r * c; cnt += m * r * h; cnt += m * c * h; cnt += a * r * c; cnt += a * r * h; cnt += a * c * h; cnt += r * c * h; cout << cnt << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include <bits/stdc++.h> int main() { int n; char s[11]; int mozi[5] = {0}; int ans = 1; int zenbu = 0; int i, j, k; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%s", s); if (s[0] == 'M') mozi[0]++; else if (s[0] == 'A') mozi[1]++; else if (s[0] == 'R') mozi[2]++; else if (s[0] == 'C') mozi[3]++; else if (s[0] == 'H') mozi[4]++; } for (i = 0; i < 3; i++) { for (j = i + 1; j < 4; j++) { for (k = j + 1; k < 5; k++) { ans = mozi[i] * mozi[j] * mozi[k]; zenbu += ans; } } } printf("%d", 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
UNKNOWN
n = gets.chop.to_i s = [] n.times { s << gets.to_s } combi = [] s.combination(3) {|a, b, c| combi.push([a,b,c]) if a[0] + b[0] + c[0] =~ /[MARCH]{3}/ && [a[0],b[0],c[0]].uniq.length == 3 } p combi.length
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\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 march = "MARCH"; int main() { int n; scanf("%d", &n); int d[5]; for (int i = 0; i < 5; i++) { d[i] = 0; } string str; for (int i = 0; i < n; i++) { cin >> str; for (int j = 0; j < 5; j++) { if (str[0] == march[j]) { d[j]++; break; } } } long sum = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { sum += d[i] * d[j] * d[k]; } } } printf("%ld\n", sum); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 7, MOD = 1e9 + 7; const long long LINF = 1e18; int main() { int n, cntt = 0, cnt[5] = {}; long long ans = 1; bool f[5]; for (int i = 0; i < 5; i++) { f[i] = false; } cin >> n; for (int i = 0; i < n; i++) { string s; cin >> s; if (s[0] == 'M') { cnt[0]++; f[0] = true; } else if (s[0] == 'A') { cnt[1]++; f[1] = true; } else if (s[0] == 'R') { cnt[2]++; f[2] = true; } else if (s[0] == 'C') { cnt[3]++; f[3] = true; } else if (s[0] == 'H') { cnt[4]++; f[4] = true; } } for (int i = 0; i < 5; i++) { if (f[i] == true) { cntt++; } } if (cntt < 3) { cout << 0 << endl; } else if (cntt == 3) { int tmp = cntt * (cntt - 1) * (cntt - 2) / 6; for (int i = 0; i < 5; i++) { if (cnt[i]) { tmp *= cnt[i]; } } cout << tmp << endl; } else if (cntt == 4) { int tmp = cntt * (cntt - 1) * (cntt - 2) / 6; for (int i = 0; i < 5; i++) { if (cnt[i]) { tmp--; tmp *= cnt[i]; tmp++; } } cout << tmp << endl; } else if (cntt == 5) { int tmp = cntt * (cntt - 1) * (cntt - 2) / 6; for (int i = 0; i < 5; i++) { if (cnt[i]) { tmp -= 3; tmp *= cnt[i]; tmp += 3; } } } return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; string str("MRACH"); vector<string> name(N); int countM = 0; int countR = 0; int countA = 0; int countC = 0; int countH = 0; int all; for(int i = 0; i < N; i++){ cin >> name.at(i); char I = name.at(i).at(0); for(int j = 0; j < 5; j++){ if(I == str(j)){ countM++; }else if(I == str.at(j)){ countR++; }else if(I == str.at(j)){ countA++; }else if(I == str.at(j)){ countC++; }else if(I == str.at(j)){ countH++; } } if(countM == 0){ countM++; }else if(countR == 0){ countR++; }else if(countA == 0){ countA++; }else if(countC == 0){ countC++; }else if(countH == 0){ countH++; } } if(countM+countR+countA+countC+countH <= 7){ all = 0; }else{ all = countM*countR*countA*countC*countH; } cout << all << 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 <cstdlib> #include <climits> #include <iostream> #include <cstdint> #include <vector> #include <string> #include <complex> #include <bitset> #include <queue> #include <deque> #include <stack> #include <utility> #include <set> #include <map> #include <unordered_set> #include <unordered_map> #include <boost/lexical_cast.hpp> #include <boost/algorithm/string.hpp> #include <boost/multi_array.hpp> using namespace std; template <typename Tlist, typename Tfunc> void __combination( Tlist const& list, typename Tlist::size_type const n, Tfunc const& func, Tlist& tmp, typename Tlist::size_type const i, typename Tlist::size_type const j) { if (i == n) { func(tmp); return; } for (typename Tlist::size_type k = j; k != list.size() + (1 + i- n); ++k) { tmp[i] = list[k]; __combination(list, n, func, tmp, i + 1, k + 1); } } template <typename Tlist, typename Tfunc> void combination( Tlist const& list, typename Tlist::size_type const n, Tfunc const& func) { Tlist tmp(n); __combination(list, n, func, tmp, 0, 0); } int main() { uint64_t N; std::cin >> N; std::vector<int> inis(5); for (size_t i = 0; i < N; ++i) { std::string s; std::cin >> s; char c = s[0]; switch (c) { case 'M': inis[0]++; break; case 'A': inis[1]++; break; case 'R': inis[2]++; break; case 'C': inis[3]++; break; case 'H': inis[4]++; break; default: break; } } int sum = 0; combination(inis, 3, [&sum](auto& v) { sum += std::accumulate(std::begin(v), std::end(v), 1, [](int acc, int nn) { return acc*nn; }); }); 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; long long ans; int n, cnt[5]; string s; int p[10] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2}; int q[10] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3}; int r[10] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4}; int main() { cin >> n; for (int i = 0; i < n; ++i) { cin >> s; switch (s[0]) { case 'M': cnt[0]++; break; case 'A': cnt[1]++; break; case 'R': cnt[2]++; break; case 'C': cnt[3]++; break; case 'H': cnt[4]++; break; } } for (int i = 0; i < 10; ++i) ans += cnt[p[i]] * cnt[q[i]] * cnt[r[i]]; cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { return abs(a * b) / gcd(a, b); } int n, ans = 0; int a[10] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2}, b[10] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3}, c[10] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4}; std::vector<int> d(5, 0); int main() { cin >> n; for (size_t i = 0; i < n; i++) { string temp; cin >> temp; if (temp[0] == 'M') d[0]++; if (temp[0] == 'A') d[1]++; if (temp[0] == 'R') d[2]++; if (temp[0] == 'C') d[3]++; if (temp[0] == 'H') d[4]++; } for (size_t i = 0; i < 10; i++) { ans += d[a[i]] * d[b[i]] * d[c[i]]; } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using unit = unsigned; using vl = vector<ll>; using ull = unsigned long long; using vvi = vector<vi>; using P = pair<int, int>; using vvl = vector<vl>; using vp = vector<P>; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); } template <class T> string join(const vector<T> &v) { stringstream s; for (int i = (int)(0); i < (int)(((int)(v).size())); ++i) s << ' ' << v[i]; return s.str().substr(1); } template <class T> istream &operator>>(istream &i, vector<T> &v) { for (auto &x : v) { i >> v; } return i; } template <class T> ostream &operator<<(ostream &o, const vector<T> &v) { o << "["; for (auto &x : v) o << x << ","; o << "]"; return o; } template <class T> ostream &operator<<(ostream &o, const deque<T> &v) { o << "deq["; for (auto &x : v) o << x << ","; o << "]"; return o; } template <class T> ostream &operator<<(ostream &o, const set<T> &v) { o << "{"; for (auto &x : v) o << x << ","; o << "}"; return o; } template <class T> ostream &operator<<(ostream &o, const unordered_set<T> &v) { o << "{"; for (auto &x : v) o << x << ","; o << "}"; return o; } template <class T> ostream &operator<<(ostream &o, const multiset<T> &v) { o << "{"; for (auto &x : v) o << x << ","; o << "}"; return o; } template <class T> ostream &operator<<(ostream &o, const unordered_multiset<T> &v) { o << "{"; for (auto &x : v) o << x << ","; o << "}"; return o; } template <class T1, class T2> ostream &operator<<(ostream &o, const pair<T1, T2> &p) { o << "(" << p.first << "," << p.second << ")"; return o; } template <class TK, class TV> ostream &operator<<(ostream &o, const map<TK, TV> &m) { o << "{"; for (auto &x : m) o << x.first << "=>" << x.second << ","; o << "}"; return o; } template <class TK, class TV> ostream &operator<<(ostream &o, const unordered_map<TK, TV> &m) { o << "{"; for (auto &x : m) o << x.first << "=>" << x.second << ","; o << "}"; return o; } template <class T> void YES(T c) { if (c) cout << "YES" << endl; else cout << "NO" << endl; } template <class T> void Yes(T c) { if (c) cout << "Yes" << endl; else cout << "No" << endl; } template <class T> void POSS(T c) { if (c) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; } template <class T> void Poss(T c) { if (c) cout << "Possible" << endl; else cout << "Impossible" << endl; } template <class T> void chmax(T &a, const T &b) { if (a < b) a = b; } template <class T> void chmin(T &a, const T &b) { if (b < a) a = b; } template <class T> T gcd(T a, T b) { return (b == 0) ? a : gcd(b, a % b); } template <class T> T lcm(T a, T b) { return a * (b / gcd(a, b)); } const double EPS = 1e-10; const double PI = acos(-1.0); const int INF = INT_MAX / 2; const ll INFL = 1LL << 60; const int dx[] = {-1, 0, 1, 0, -1, -1, 1, 1}; const int dy[] = {0, 1, 0, -1, -1, 1, -1, 1}; void _main() { string march = "MARCH"; int cnt[5] = {}; int N; cin >> N; for (int i = (int)(0); i < (int)(N); ++i) { string s; cin >> s; for (int j = (int)(0); j < (int)(5); ++j) if (s[0] == march[j]) ++cnt[j]; } ll ans = 0; for (int i = (int)(0); i < (int)(N); ++i) for (int j = (int)(i + 1); j < (int)(N); ++j) for (int k = (int)(j + 1); k < (int)(N); ++k) { ans += cnt[i] * cnt[j] * cnt[k]; } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int P[10] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2}; int Q[10] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3}; int R[10] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4}; int main() { int n; cin >> n; long long m, a, r, c, h; for (int i = 0; i < n; i++) { string name; cin >> name; if (name[0] == 'M') { m++; } else if (name[0] == 'A') { a++; } else if (name[0] == 'R') { r++; } else if (name[0] == 'C') { c++; } else if (name[0] == 'H') { h++; } } long long result = 0; long long v[5] = {m, a, r, c, h}; for (int i = 0; i < 10; i++) { result += v[P[i]] * v[Q[i]] * v[R[i]]; } cout << result << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; ll calcNumOfCombination(ll n, ll r) { ll num = 1; for (ll i = 1; i <= r; i++) { num = num * (n - i + 1) / i; } return num; } int main() { ll n; cin >> n; map<char, ll> s; for (long long i = 0; i < (int)(n); i++) { string tmp; cin >> tmp; if (tmp[0] == 'M' or tmp[0] == 'A' or tmp[0] == 'R' or tmp[0] == 'C' or tmp[0] == 'H') s[tmp[0]]++; } ll ans = 0, sum = 0; for (auto x : s) sum += x.second; ans = calcNumOfCombination(sum, 3); for (auto x : s) { if (x.second == 2) { ans -= s.size() - 1; } else if (x.second >= 3) { ans -= s.size(); } } cout << fixed << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int n, ans = 1; bool exist = false; int s[100]; int main() { ios::sync_with_stdio(false); cin >> n; for (int i = 0; i < n; i++) { string t; cin >> t; if (t[0] == 'M' || t[0] == 'A' || t[0] == 'R' || t[0] == 'C' || t[0] == 'H') s[t[0]]++, exist = true; } for (int i = 65; i <= 90; i++) { if (s[i] > 0) ans *= s[i]; } if (exist) cout << ans << endl; else cout << 0 << 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 tests(int a, int b) { return (a == 0) ? 1 : b; } int main() { int NNN; cin >> NNN; string temp; int memo[5] = {0}; for (int i = 0; i < NNN; i++) { cin >> temp; if (temp[0] == 'M') { memo[0]++; } else if (temp[0] == 'A') { memo[1]++; } else if (temp[0] == 'R') { memo[2]++; } else if (temp[0] == 'C') { memo[3]++; } else if (temp[0] == 'H') { memo[4]++; } } long int ans = 0; int bit = 0; int bits[5] = {0}; int tbit = 0; bool check = true; while (bit < 32) { tbit = bit; check = true; for (int i = 0; i < 5; i++) { bits[i] = tbit % 2; tbit = (tbit - tbit % 2) / 2; } if (bits[0] + bits[1] + bits[2] + bits[3] + bits[4] != 3) { bit++; continue; } else { for (int i = 0; i < 5; i++) { if (bits[i] == 1 && memo[i] == 0) { check = false; } } if (check) { ans = ans + tests(bits[0], memo[0]) * tests(bits[1], memo[1]) * tests(bits[2], memo[2]) * tests(bits[3], memo[3]) * tests(bits[4], memo[4]); } } bit++; } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <iostream> using namespace std; int main(){ int N,set; char head; int node[5]=0; string S; cin>>N; for(int i=0;i<N;i++){ cin>>S; head=S[0]; if(head=='M') node[0]=1; if(head=='A') node[1]+=1; if(head=='R') node[2]+=1; if(head=='C') node[3]+=1; if(head=='H') node[4]+=1; } set=0; for(int i=0;i<5,i++){ for(int j=0;j<i,j++){ for(int k=0;j>k,k++){ set+=node[i]*node[j]*node[k]; } } } cout<< set <<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() { int N, i; scanf("%d", &N); int a[5] = {0}; char name[10]; for (i = 0; i < N; i++) { scanf("%s", name); if (name[0] == 'M') a[0]++; if (name[0] == 'A') a[1]++; if (name[0] == 'R') a[2]++; if (name[0] == 'C') a[3]++; if (name[0] == 'H') a[4]++; } long num = 0; num += a[0] * a[1] * a[2]; num += a[0] * a[1] * a[3]; num += a[0] * a[1] * a[4]; num += a[0] * a[2] * a[3]; num += a[0] * a[2] * a[4]; num += a[0] * a[3] * a[4]; num += a[1] * a[2] * a[3]; num += a[1] * a[2] * a[4]; num += a[1] * a[3] * a[4]; num += a[2] * a[3] * a[4]; printf("%ld\n", 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
java
import java.util.*; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int N = sc.nextInt(); ArrayList<String> x = new ArrayList<String>(); int i; int count = 0, countM = 0, countA = 0, countR = 0, countC = 0, countH = 0; for(i = 0; i < N; i++){ String name = sc.next(); char c = name.charAt(0); if(c == 'M'){ countM++; count++; }else if(c == 'A'){ countA++; count++; }else if(c == 'R'){ countR++; count++; }else if(c == 'C'){ countC++; count++; }else if(c == 'H'){ countH++; count++; } } if(count == 0){ System.out.println(0); }else{ int ans = countM * (countA *(countR + countC + countH) + countR *(countC + countH) + countC * countH) + countA *(countR * (countC + countH) + countC * countH) + countR * countC * countH; 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; using ll = long long; char chars[10][3] = { {'M', 'A', 'R'}, {'M', 'A', 'C'}, {'M', 'A', 'H'}, {'M', 'R', 'C'}, {'M', 'R', 'H'}, {'M', 'C', 'H'}, {'A', 'R', 'C'}, {'A', 'R', 'H'}, {'A', 'R', 'H'}, {'R', 'C', 'H'}, }; int main() { int N; cin >> N; unordered_map<char, ll> mp; for (int i = 0; i <= N - 1; ++i) { string s; cin >> s; mp[s[0]]++; } ll ans = 0; for (int i = 0; i <= 9; ++i) { ll comb = 1; for (int j = 0; j <= 2; ++j) { comb *= mp[chars[i][j]]; } ans += comb; } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const double pie = acos(-1.0); long long gcd(long long a, long long b) { if (a % b == 0) { return (b); } else { return (gcd(b, a % b)); } } long long lcm(long long a, long long b) { return a * b / gcd(a, b); } bool is_prime(const unsigned n) { switch (n) { case 0: case 1: return false; case 2: case 3: return true; } if (n % 2 == 0 || n % 3 == 0) return false; for (unsigned i = 5; i * i <= n; i += 6) { if (n % i == 0) return false; if (n % (i + 2) == 0) return false; } return true; } void solve() { long long n; cin >> n; long long 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++; if (s[0] == 'A') a++; if (s[0] == 'R') r++; if (s[0] == 'C') c++; if (s[0] == 'H') h++; } cout << m * a * r + m * a * c + m * a * h + m * r * c + m * r * h + a * r * c + a * r * h + r * c * h << endl; } int main() { cin.tie(0); ios::sync_with_stdio(false); solve(); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
using System; using System.Linq; using System.Collections.Generic; using static System.Console; class Program { internal static void Main(string[] args) { var N = int.Parse(ReadLine()); var S = new Dictionary<String, int>(); for (int i = 0; i < N; i++) { var str = ReadLine().Substring(0, 1); switch (str) { case "M": case "A": case "R": case "C": case "H": if (S.ContainsKey(str)) { S[str]++; } else { S.Add(str, 1); } break; } } int hoge = 0; int fuga = 0; switch (S.Count) { case 5: hoge = 4; fuga = 6; break; case 4: hoge = 1; fuga = 3; break; case 3: hoge = 0; fuga = 1; break; default: WriteLine(0); return; } long ans = fuga; foreach (var kvp in S) { for (int i = 1; i < kvp.Value; i++) { ans *= 2; } } WriteLine(ans + hoge); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\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, set; char head; int node[5] = {0, 0, 0, 0, 0}; string S; cin >> N; for (int i = 0; i < N; i++) { cin >> S; head = S[0]; if (head == 'M') node[0] = 1; if (head == 'A') node[1] += 1; if (head == 'R') node[2] += 1; if (head == 'C') node[3] += 1; if (head == 'H') node[4] += 1; } set = 0; for (int i = 0; i < 5; i++) { for (int j = 0; j < i; j++) { for (int k = 0; k < j; k++) { set += node[i] * node[j] * node[k]; } } } cout << set << 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 scan = new Scanner(System.in); // input int num = scan.nextInt(); long[] initial = new int[5]; for(int i = 0; i < num; i++){ String temp = scan.next(); switch(temp.charAt(0)){ case 'M': initial[0] += 1; break; case 'A': initial[1] += 1; break; case 'R': initial[2] += 1; break; case 'C': initial[3] += 1; break; case 'H': initial[4] += 1; } } // search long sum = 0; for(int a = 0; a < 3; a++){ for(int b = a + 1; b < 4; b++){ for(int c = b + 1; c < 5; c++){ if(initial[a] == 0 || initial[b] == 0 || initial[c] == 0){ continue; } sum += initial[a] * initial[b] * initial[c]; } } } // answer System.out.println(sum); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
n=int(input()) s=[input() for _ in range(n)] #march="MARCH" march=["M","A","R","C","H"] count=[0]*5 for i in range(n): for j in range(5): if s[i][0]==march[j]: count[j]+=1 def f(a,b,c): return a*b*c c0=count[0] c1=count[1] c2=count[2] c3=count[3] c4=count[4] ans=f(c0,c1,(c2+c3+c4))+f((c0+c1),c2,(c3+c4))+f((c0+c2),c3,c4)+f(c1,c2,c4) print(ans)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main(void) { int n; cin >> n; vector<string> s(n); vector<set<string>> vmp(5); for (long long i = 0; i < (long long)n; ++i) cin >> s[i]; for (long long i = 0; i < (long long)n; ++i) { if (s[i][0] == 'M') vmp[0].insert(s[i]); if (s[i][0] == 'A') vmp[1].insert(s[i]); if (s[i][0] == 'R') vmp[2].insert(s[i]); if (s[i][0] == 'C') vmp[3].insert(s[i]); if (s[i][0] == 'H') vmp[4].insert(s[i]); } int a[5]; for (long long i = 0; i < (long long)n; ++i) a[i] = vmp[i].size(); long long ans = 0; for (long long i = 0; i < (long long)3; ++i) { for (long long j = i + 1; j < (long long)4; ++j) { for (long long k = j + 1; k < (long long)5; ++k) ans += a[i] * a[j] * a[k]; } } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const long double PI = 3.14159265358979323846264338327950288419716939937510582097; const long long INFLL = 0x3f3f3f3f3f3f3f3f; const int INF = 0x3f3f3f3f; const long double EPS = 1e-10; int read() { int x = 0; char ch = ' '; bool flag = false; while (ch < '0' || ch > '9') { if (ch == '-') flag = true; ch = getchar(); } while (ch >= '0' && ch <= '9') { x = (x << 3) + (x << 1) + ch - '0'; ch = getchar(); } return flag ? -x : x; } const string str = "MARCH"; int rec[5]; int main() { int n; cin >> n; for (int i = 0; i < (n); i++) { string s; cin >> s; if (str.find(s[0]) != string::npos) rec[str.find(s[0])]++; } int ans = 0; for (int i = 0; i < ((1 << 5)); i++) { if (__builtin_popcount(i) == 3) { int cnt = 1; for (int j = 0; j < (5); j++) if (i & (1 << j)) cnt *= rec[j]; ans += cnt; } } 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; int counter = 0; vector<string> data; string temp; cin >> N; for (int i = 0; i < N; i++) { cin >> temp; if (temp[0] == 'M' || temp[0] == 'A' || temp[0] == 'R' || temp[0] == 'C' || temp[0] == 'H') { data.push_back(temp); } } if (data.size() < 3) { cout << counter << endl; } else { for (vector<string>::size_type i = 0; i < data.size() - 2; i++) { for (vector<string>::size_type j = i + 1; j < data.size() - 1; j++) { for (vector<string>::size_type k = j + 1; k < data.size(); k++) { if (data[i][0] != data[j][0] && data[k][0] != data[j][0] && data[i][0] != data[k][0]) { counter++; } } } } cout << counter << 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 fac(int n) { if (n == 0) return 1; else return fac(n - 1) * n; } int main() { int n; cin >> n; vector<int> a(5, 0); string s; for (int i = 0; i < n; i++) { cin >> s; if (s.at(0) == 'M') a.at(0)++; else if (s.at(0) == 'A') a.at(1)++; else if (s.at(0) == 'R') a.at(2)++; else if (s.at(0) == 'C') a.at(3)++; else if (s.at(0) == 'H') a.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 += a.at(i) * a.at(j) * a.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
#include <bits/stdc++.h> using namespace std; int main() { int N, i, M, A, R, C, H; string Name; M = 0; A = 0; R = 0; C = 0; H = 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++; } } cout << M * A * R + M * A * C + M * A * H + M * R * C + M * R * H + M * C * H + A * R * C + A * R * H + A * C * H + R * C * H << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\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 i[0] == j[0] || i[0] == k[0] || j[0] == k[0] cnt += 1 end end p s.combination(3).size - 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; const int N = 100010; int mod = 1000000007; char s[22]; int main() { int T, n, k; while (~scanf("%d", &n)) { char rec[256] = {0}; for (int i = 0; i < n; i++) { scanf("%s", s); rec[s[0]]++; } char cs[] = "MARCH"; long long ans = 0; for (int i = 0; i < 32; i++) { int cnt = 0; for (int j = 0; j < 5; j++) cnt += (i >> j) & 1; if (cnt == 3) { long long t = 1; for (int j = 0; j < 5; j++) if ((i >> j) & 1) t *= rec[cs[j]]; ans += t; } } 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> #define rep(i,n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int,int>; int main(){ int n; cin >> n; string s; vector<ll> b(5); rep(i, 5) b.at(i) = 0; rep(i, n){ cin >> s; a[s.at(0)]++; if(s.at(0) == 'M') b.at(0)++; if(s.at(0) == 'A') b.at(1)++; if(s.at(0) == 'R') b.at(2)++; if(s.at(0) == 'C') b.at(3)++; if(s.at(0) == 'H') b.at(4)++; } ll ans = 0; ans += b.at(0)*b.at(1)*b.at(2); ans += b.at(1)*b.at(2)*b.at(3); ans += b.at(2)*b.at(3)*b.at(4); ans += b.at(3)*b.at(4)*b.at(0); ans += b.at(4)*b.at(0)*b.at(1); ans += b.at(0)*b.at(2)*b.at(3); ans += b.at(1)*b.at(3)*b.at(4); ans += b.at(2)*b.at(4)*b.at(0); ans += b.at(3)*b.at(0)*b.at(1); ans += b.at(4)*b.at(1)*b.at(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
n = gets.chomp.to_i s = [] n.times do s.push gets.chomp end h = Hash.new(0) s.each do |name| if %w[M A R C H].include?(name[0]) h[name[0]] += 1 end end if h.empty? puts 0 else puts h.to_a.map{ |e| e.last }.combination(3).to_a.map { |e| e.reduce(1) { |mul, c| mul * c }}.reduce(:+) end
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int N; long long ans; char march[5] = {'M', 'A', 'R', 'C', 'H'}; int cnt[5], sum; int main() { cin >> N; string s; for (int i = 0; i < N; i++) { cin >> s; for (int j = 0; j < 5; j++) { if (s[0] == march[j]) { cnt[j]++; sum++; } } } for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { ans += cnt[i] * cnt[j] * cnt[k]; } } } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main(int argc, char *argv[]) { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); map<char, int> mp; int n; cin >> n; for (int i = 0; i < n; i++) { string s; cin >> s; mp[s[0]]++; } string march = "MARCH"; long long res = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { res += mp[march[i]] * mp[march[j]] * mp[march[k]]; } } } cout << res << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.*; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int N = sc.nextInt(); String s[] = new String[N]; int m = 0; int a = 0; int r = 0; int c = 0; int h = 0; for(int i=0; i<N; i++){ s[i] = sc.next(); char head = s[i].charAt(0); if(head=='M')m++; else if(head=='A')a++; else if(head=='R')r++; else if(head=='C')c++; else if(head=='H')h++; } long total = 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(total); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#[allow(unused_macros)] macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes .by_ref() .map(|r|r.unwrap() as char) .skip_while(|c|c.is_whitespace()) .take_while(|c|!c.is_whitespace()) .collect() }; input_inner!{next, $($r)*} }; } #[allow(unused_macros)] macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; } #[allow(unused_macros)] macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; } fn main() { input! { n: usize, s: [String; n], } let chars = vec!["M", "A", "R", "C", "H"]; let mut count = vec![0; 5]; for i in 0..5 { for sj in s.iter() { if sj.starts_with(chars[i]) { count[i] += 1; } } } let mut ans = 0; for i in 0..5 { for j in 0..i { for k in 0..j { ans += count[i] * count[j] * count[k]; } } } println!("{}", ans); }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (a < b) { return gcd(b, a); } else if (a % b) { return gcd(b, a % b); } else { return b; } } int main() { long long N; cin >> N; vector<string> S(N); long long m = 0; long long a = 0; long long r = 0; long long c = 0; long long h = 0; for (int i = 0; i < N; ++i) { cin >> S[i]; if (S[i].at(0) == 'M') { m++; } if (S[i].at(0) == 'A') { a++; } if (S[i].at(0) == 'R') { r++; } if (S[i].at(0) == 'C') { c++; } if (S[i].at(0) == 'H') { h++; } } int ans = 0; if (m > 0 && a > 0 && r > 0) { ans += m * a * r; } if (m > 0 && a > 0 && h > 0) { ans += m * a * h; } if (m > 0 && a > 0 && c > 0) { ans += m * a * c; } if (m > 0 && c > 0 && r > 0) { ans += m * c * r; } if (m > 0 && h > 0 && r > 0) { ans += m * h * r; } if (m > 0 && h > 0 && c > 0) { ans += m * h * c; } if (a > 0 && r > 0 && c > 0) { ans += c * a * r; } if (a > 0 && r > 0 && h > 0) { ans += h * a * r; } if (a > 0 && c > 0 && h > 0) { ans += h * a * r; } if (r > 0 && c > 0 && h > 0) { ans += h * c * r; } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { long long int a, b, c, x, y, cp, mx, mn, p = 999999999, i, q[5]; cin >> a >> b >> c >> x >> y; mn = min(x, y); mx = max(x, y); cp = 2 * (x + y); q[0] = (c * cp); q[1] = (c * mx * 2); q[2] = (a * x) + (b * y); q[3] = (c * mn * 2) + (a * (mx - mn)); q[4] = (c * mn * 2) + (b * (mx - mn)); for (i = 0; i < 5; i++) { if (p > q[i]) p = q[i]; } cout << p << 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; #define pb push_back #define mp make_pair #define int long long int q[200]; main(){ int n,i,c,k,l=0; cin>>n; string s; for (i=0;i<n;++i){ cin>>s; q[s[0]]++; } int r=1; c=q['M']+q['A']+q['R']+q['C']+q['H']; if (q['M']>1){ l+=q['A']+q['R']+q['C']+q['H']; } if (q['A']>1){ l+=q['M']+q['R']+q['C']+q['H']; } if (q['R']>1){ l+=q['M']+q['A']+q['C']+q['H']; } if (q['C']>1){ l+=q['M']+q['A']+q['R']+q['H']; } if (q['H']>1){ l+=q['M']+q['A']+q['R']+q['C']; } if (c-3>3){ k=1; for (i=c-2;i<=c;++i){ k*=i; } r=6; } else { k=1; for (i=4;i<=c;++i){ k*=i; } for (i=2;i<=c-3;++i){ r*=i; } } cout <<k/r-l; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\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 N, i, j, k; long CNT[5] = {0, 0, 0, 0, 0}; char S[10]; long ans = 0; scanf("%d", &N); for (i = 0; i < N; i++) { scanf("%s", S); if (S[0] == 'M') CNT[0]++; if (S[0] == 'A') CNT[1]++; if (S[0] == 'R') CNT[2]++; if (S[0] == 'C') CNT[3]++; if (S[0] == 'H') CNT[4]++; } for (i = 0; i < 3; i++) { for (j = i + 1; j < 4; j++) { for (k = j + 1; k < 5; k++) { ans += CNT[i] * CNT[j] * CNT[k]; } } } printf("%ld", ans); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const long long int INF = 1e18; const long long int mod = 1e9 + 7; struct Edge { long long int to, weight; Edge(long long int t, long long int w) : to(t), weight(w) {} }; using graph = vector<vector<long long int>>; using Graph = vector<vector<Edge>>; long long int gcd(long long int a, long long int b) { if (b == 0) { return a; } else { return gcd(b, a % b); } } long long int lcm(long long int a, long long int b) { return a / gcd(a, b) * b; } long long int keta(long long int N) { int tmp{}; while (N > 0) { tmp += (N % 10); N /= 10; } N = tmp; return N; } bool kai(string S) { bool flag = true; for (long long int i = 0; i < S.size() / 2; ++i) { if (S[i] != S[S.size() - i - 1]) { flag = false; break; } } return flag; } int main() { long long int n; cin >> n; long long int m = 0, a = 0, r = 0, c = 0, h = 0; for (long long int i = 0; i < n; ++i) { string s; cin >> s; char t = s[0]; if (t == 'M') { m++; } else if (t == 'A') { a++; } else if (t == 'R') { r++; } else if (t == 'C') { c++; } else if (t == 'H') { h++; } } long long int ans = 0; ans += m * a * r; ans += m * a * c; ans += m * a * h; ans += m * r * c; ans += m * r * h; ans += r * c * h; ans += a * r * c; ans += a * r * h; ans += a * c * h; ans += r * c * h; cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { enum Index { M = 0, A, R, C, H, Max }; int count[5] = {0}; int P[] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2}; int Q[] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3}; int K[] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4}; int N; scanf(" %d", &N); for (int i = 0; i < N; i++) { string s; cin >> s; switch (s[0]) { case 'M': { count[Index::M]++; break; } case 'A': { count[Index::A]++; break; } case 'R': { count[Index::R]++; break; } case 'C': { count[Index::C]++; break; } case 'H': { count[Index::H]++; break; } } } int res = 0; for (int i = 0; i < 10; i++) { res += count[P[i]] * count[Q[i]] * count[K[i]]; } printf("%d\n", res); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n, k, m, a, r, c, h; m = a = r = c = h = 0; cin >> n; do { string x, ch; cin >> x; ch = x[0]; if (ch == "M") m = m + 1; else if (ch == "A") a = a + 1; else if (ch == "R") r = r + 1; else if (ch == "C") c = c + 1; else if (ch == "H") h = h + 1; n = n - 1; } while (n >= 1); unsigned long long l = 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 << l; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main(int argc, const char* argv[]) { int N; cin >> N; string s; int a[5] = {0, 0, 0, 0, 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 cnt = 0; for (int i = 0; i < 5; i++) { if (a[i] != 0) { cnt++; } } long long int sum = 0; if (cnt < 3) { cout << sum << endl; } else { for (int i = 0; i < 5; i++) { if (a[i] != 0) { for (int j = i + 1; j < 5; j++) { if (a[j] != 0 && i != j) { for (int k = j + 1; k < 5; k++) { if (a[k] != 0 && j != k && i != k) { long long int x = 1; x = a[i] * a[j] * a[k]; sum += x; } } } } } } cout << sum << endl; } return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
using System; using System.Collections; using System.Collections.Generic; using System.Text; using System.IO; using System.Linq; using System.Diagnostics; using System.Globalization; using static System.Console; using static System.Math; namespace abc90_c { class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); List<string> list = new List<string>(); int M=0; int A=0; int R=0; int C=0; int H=0; for(int i=0; i<n; i++) { list.Add(ReadLine().Substring(0,1)); } List<string> operatedList = new List<string>(list); foreach(var item in list) { switch(item) { case ("M"): M++; break; case ("A"): A++; break; case ("R"): R++; break; case ("C"): C++; break; case ("H"): H++; break; default: operatedList.Remove(item); break; } } int count = operatedList.Count; if(count == 0) { WriteLine(count); return; } long sum = M*A*R+M*A*C+M*A+H+M*R*C+M*R*H+M*C*H+A*R*C+A*R*H+A*C*H+R*C*H; WriteLine(sum); } } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Scanner; import java.util.Set; public class Main { public static void main(String[] args) { // new Main().solveA(); // new Main().solveB(); new Main().solveC(); // new Main().solveD(); // new Main().solveE(); // new Main().solveF(); } private void solveA() { Scanner scanner = null; int numN = 0; try { scanner = new Scanner(System.in); numN = scanner.nextInt(); System.out.println(numN / 3); } finally { if (scanner != null) { scanner.close(); } } } private void solveB() { Scanner scanner = null; int numN = 0; try { scanner = new Scanner(System.in); numN = scanner.nextInt(); Set<String> wkSet = new HashSet<String>(); for (int i = 0; i < numN; i++) { wkSet.add(scanner.next()); } System.out.println(wkSet.size() == 3 ? "Three" : "Four"); } finally { if (scanner != null) { scanner.close(); } } } private void solveC() { Scanner scanner = null; int numN = 0; try { scanner = new Scanner(System.in); numN = scanner.nextInt(); String[] wk = new String[numN]; Map<String, Integer> wkMap = new HashMap<String, Integer>(); wkMap.put("M", 0); wkMap.put("A", 0); wkMap.put("R", 0); wkMap.put("C", 0); wkMap.put("H", 0); for (int i = 0; i < wk.length; i++) { wk[i] = scanner.next(); if (wk[i].startsWith("M")) { wkMap.put("M", wkMap.get("M") + 1); } else if (wk[i].startsWith("A")) { wkMap.put("A", wkMap.get("A") + 1); } else if (wk[i].startsWith("R")) { wkMap.put("R", wkMap.get("R") + 1); } else if (wk[i].startsWith("C")) { wkMap.put("C", wkMap.get("C") + 1); } else if (wk[i].startsWith("H")) { wkMap.put("H", wkMap.get("H") + 1); } } long res = 0; res += wkMap.get("M") * wkMap.get("A") * wkMap.get("R"); res += wkMap.get("M") * wkMap.get("A") * wkMap.get("C"); res += wkMap.get("M") * wkMap.get("A") * wkMap.get("H"); res += wkMap.get("M") * wkMap.get("R") * wkMap.get("C"); res += wkMap.get("M") * wkMap.get("R") * wkMap.get("H"); res += wkMap.get("M") * wkMap.get("C") * wkMap.get("H"); res += wkMap.get("A") * wkMap.get("R") * wkMap.get("C"); res += wkMap.get("A") * wkMap.get("R") * wkMap.get("H"); res += wkMap.get("A") * wkMap.get("C") * wkMap.get("H"); res += wkMap.get("R") * wkMap.get("C") * wkMap.get("H"); System.out.println(res); } finally { if (scanner != null) { scanner.close(); } } } private void solveD() { Scanner scanner = null; int numN = 0; int numK = 0; int numS = 0; try { scanner = new Scanner(System.in); numN = scanner.nextInt(); System.out.println(""); } finally { if (scanner != null) { scanner.close(); } } } private void solveE() { Scanner scanner = null; int numN = 0; int numK = 0; int numS = 0; try { scanner = new Scanner(System.in); numN = scanner.nextInt(); System.out.println(""); } finally { if (scanner != null) { scanner.close(); } } } private void solveF() { Scanner scanner = null; int numN = 0; int numK = 0; int numS = 0; try { scanner = new Scanner(System.in); numN = scanner.nextInt(); System.out.println(""); } finally { if (scanner != null) { scanner.close(); } } } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int n; unordered_map<char, int> cnt; unordered_map<int, char> mpi2c; int k = 3; int ans; int next_combination(int sub) { int x = sub & -sub, y = sub + x; return (((sub & ~y) / x) >> 1) | y; } int main(void) { scanf("%d", &n); for (int i = 0; i < n; ++i) { string s; cin >> s; if (s[0] == 'M' || s[0] == 'A' || s[0] == 'R' || s[0] == 'C' || s[0] == 'H') cnt[s[0]] += 1; } mpi2c[0] = 'M'; mpi2c[1] = 'A'; mpi2c[2] = 'R'; mpi2c[3] = 'C'; mpi2c[4] = 'H'; for (int bit = (1 << k) - 1; bit < (1 << cnt.size()); bit = next_combination(bit)) { vector<int> s; for (int i = 0; i < cnt.size(); ++i) { if (bit & (1 << i)) { s.push_back(i); } } int tmp = 1; for (int i = 0; i < s.size(); ++i) { tmp *= cnt[mpi2c[s[i]]]; } ans += tmp; } printf("%d\n", ans); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int INF = 1e9 + 7; int main() { int n; cin >> n; string s; int m = 0, a = 0, r = 0, c = 0, h = 0; 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++; } cout << m * a * r + m * a * c + m * a * h + m * r * c + m * r * h + m * c * h + a * r * c + a * r * h + a * c * h + r * c * h << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.io.BufferedReader; import java.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; for(int i = 0; i < N; i++) { String Si = sc.next(); switch(Si.substring(0, 1)) { case "M": M++; break; case "A": A++; break; case "R": R++; break; case "C": C++; break; case "H": H++; break; } } int answer = 0; answer = M*A*R; answer += M * A * C; answer += M * A * H; answer += M * R * C; answer += M * R * H; answer += M * C * H; answer += A * R * C; answer += A * R * H; answer += A * C * H; answer += R * C * H; 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
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using unit = unsigned; using vl = vector<ll>; using ull = unsigned long long; using vvi = vector<vi>; using P = pair<int, int>; using vvl = vector<vl>; using vp = vector<P>; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); } template <class T> string join(const vector<T> &v) { stringstream s; for (int i = (int)(0); i < (int)(((int)(v).size())); ++i) s << ' ' << v[i]; return s.str().substr(1); } template <class T> istream &operator>>(istream &i, vector<T> &v) { for (auto &x : v) { i >> v; } return i; } template <class T> ostream &operator<<(ostream &o, const vector<T> &v) { o << "["; for (auto &x : v) o << x << ","; o << "]"; return o; } template <class T> ostream &operator<<(ostream &o, const deque<T> &v) { o << "deq["; for (auto &x : v) o << x << ","; o << "]"; return o; } template <class T> ostream &operator<<(ostream &o, const set<T> &v) { o << "{"; for (auto &x : v) o << x << ","; o << "}"; return o; } template <class T> ostream &operator<<(ostream &o, const unordered_set<T> &v) { o << "{"; for (auto &x : v) o << x << ","; o << "}"; return o; } template <class T> ostream &operator<<(ostream &o, const multiset<T> &v) { o << "{"; for (auto &x : v) o << x << ","; o << "}"; return o; } template <class T> ostream &operator<<(ostream &o, const unordered_multiset<T> &v) { o << "{"; for (auto &x : v) o << x << ","; o << "}"; return o; } template <class T1, class T2> ostream &operator<<(ostream &o, const pair<T1, T2> &p) { o << "(" << p.first << "," << p.second << ")"; return o; } template <class TK, class TV> ostream &operator<<(ostream &o, const map<TK, TV> &m) { o << "{"; for (auto &x : m) o << x.first << "=>" << x.second << ","; o << "}"; return o; } template <class TK, class TV> ostream &operator<<(ostream &o, const unordered_map<TK, TV> &m) { o << "{"; for (auto &x : m) o << x.first << "=>" << x.second << ","; o << "}"; return o; } template <class T> void YES(T c) { if (c) cout << "YES" << endl; else cout << "NO" << endl; } template <class T> void Yes(T c) { if (c) cout << "Yes" << endl; else cout << "No" << endl; } template <class T> void POSS(T c) { if (c) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; } template <class T> void Poss(T c) { if (c) cout << "Possible" << endl; else cout << "Impossible" << endl; } template <class T> void chmax(T &a, const T &b) { if (a < b) a = b; } template <class T> void chmin(T &a, const T &b) { if (b < a) a = b; } template <class T> T gcd(T a, T b) { return (b == 0) ? a : gcd(b, a % b); } template <class T> T lcm(T a, T b) { return a * (b / gcd(a, b)); } const double EPS = 1e-10; const double PI = acos(-1.0); const int INF = INT_MAX / 2; const ll INFL = 1LL << 60; const int dx[] = {-1, 0, 1, 0, -1, -1, 1, 1}; const int dy[] = {0, 1, 0, -1, -1, 1, -1, 1}; void _main() { string march = "MARCH"; int cnt[5] = {}; int N; cin >> N; for (int i = (int)(0); i < (int)(N); ++i) { string s; cin >> s; for (int j = (int)(0); j < (int)(5); ++j) if (s[0] == march[j]) ++cnt[j]; } ll 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) { cout << "i,j,k: " << i << ", " << j << ", " << k << endl; ans += (ll)cnt[i] * cnt[j] * cnt[k]; } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; int num[5] = {}; cin >> n; for (int i = 0; i < n; i++) { string str; cin >> str; switch (str[0]) { case 'M': num[0]++; break; case 'A': num[1]++; break; case 'R': num[2]++; break; case 'C': num[3]++; break; case 'H': num[4]++; break; default: break; } } long long int sum = 0; for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 4; j++) { for (int k = j + 1; k < 5; k++) { sum += num[i] * num[j] * num[k]; } } } cout << sum << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; string s[10001]; char h[5] = {'M', 'A', 'R', 'C', 'H'}; long long a, b, c, d, e, ans = 0; void f(int i, int m) { for (int j = i + 1; j < a; j++) { for (int q = m + 1; q < 5; q++) { if (s[j][0] == h[q]) { for (int z = j + 1; z < a; z++) { for (int x = q + 1; x < 5; x++) { if (s[z][0] == h[x]) { ans++; } } } } } } } int main() { cin >> a; for (int i = 0; i < a; i++) { cin >> s[i]; s[i] = s[i][0]; } for (int i = 0; i < a - 2; i++) { for (int j = 0; j < 5; j++) { if (s[i][0] == h[j]) { f(i, j); j = 5; } } } 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 scala.io.StdIn object Main extends App { val n = StdIn.readLine().toInt val linse = (0 until n).map(_ => StdIn.readLine()) val members = linse.filter{p => p.charAt(0) == 'M' || p.charAt(0) == 'A' || p.charAt(0) == 'R' || p.charAt(0) == 'C' || p.charAt(0) == 'H' }.groupBy(name => name.charAt(0)) val combi = members.keys.toList.combinations(3) //println(combi.mkString(" ")) val result = combi.foldLeft(0L){ (acc, l) => acc + members(l(0)).size * members(l(1)).size * members(l(2)).size } println(result) }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
n = int(input()) coum = 0 coua = 0 cour = 0 couc = 0 couh = 0 for i in range(n): a = input() if a[0] == "M": coum +=1 if a[0] == "A": coua +=1 if a[0] == "R": cour += 1 if a[0] == "C": couc += 1 if a[0] == "H": couh += 1 an = coum + coua + cour + couc + couh su = 0 # print(coum,coua,cour,couc,couh) mm = 0 aa = 0 rr = 0 cc = 0 hh = 0 for m in range(an): su += m if coum > 1: if coua + cour + couc + couh < 3: mm = coua + cour + couc + couh mm *= coum else: for m in range(coum): mm += m+1 if coua > 1: if coum + cour + couc + couh < 3: aa = coum + cour + couc + couh aa *= coua else: for m in range(coua): aa += m+1 if cour > 1: if coum + coua + couc + couh < 3: rr = coum + coua + couc + couh rr *= cour else: for m in range(cour): rr += m+1 if couc > 1: if coum + coua + cour + couh < 3: cc = coum + coua + cour + couh cc *= couc else: for m in range(couc): cc += m+1 if couh > 1: if coum + coua + cour + couc < 3: hh = coum + coua + cour + couc hh *= couh else: for m in range(couh): hh += m+1 print(su-(mm + aa + rr + cc + hh))
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\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 { @SuppressWarnings("resource") public static void main(String args[]) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int march[] = new int[5]; for (int i = 0; i < n; i++) { String s = scanner.next(); if (s.charAt(0) == 'M') march[0]++; else if (s.charAt(0) == 'A') march[1]++; else if (s.charAt(0) == 'R') march[2]++; else if (s.charAt(0) == 'C') march[3]++; else if (s.charAt(0) == 'H') march[4]++; } long cnt = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { cnt += (long)(march[i] * march[j] * march[k]); } } } System.out.println(cnt); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
n = int(input()) s = [list(input())[0] for i in range(n)] ans = 0 for i, j in enumerate(s): if j not in list('MARCH'): del s[i] s = sorted([[i, s.count(i)] for i in set(s) if s.count(i) >= 1]) for i in range(len(s)): for j in range(i + 1, len(s)): for k in range(j + 1, len(s)): ans += s[i][1] * s[j][1] * s[k][1] print(ans)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include<bits/stdc++.h> using namespace std; #define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++) #define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++) #define MOD 1000000007 #define int int64_t #define ALL(a) (a).begin(),(a).end() signed main(){ int N; cin>>N; vi A(5); rep(i,0,N){ string S; cin>>S; if(S[0]=='M') A[0]++; else if(S[0]=='A') A[1]++; else if(S[0]=='R') A[2]++; else if(S[0]=='C') A[3]++; else if(S[0]=='H') A[4]++; } int ans=0; rep(i,0,3){ rep(j,i+1,4){ rep(k,j+1,5) ans+=A[i]*A[j]*A[k]; } } cout<<ans<<endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; template <class T> void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()) { v.assign(a, vector<T>(b, t)); } template <class F, class T> void convert(const F &f, T &t) { stringstream ss; ss << f; ss >> t; } struct UnionFind { vector<int> data; UnionFind(int sz) { data.assign(sz, -1); } bool unite(int x, int y) { x = find(x), y = find(y); if (x == y) return (false); if (data[x] > data[y]) swap(x, y); data[x] += data[y]; data[y] = x; return (true); } int find(int k) { if (data[k] < 0) return (k); return (data[k] = find(data[k])); } int size(int k) { return (-data[find(k)]); } bool same(int x, int y) { return find(x) == find(y); } }; string op(int sign) { return sign == 0 ? "+" : "-"; } static const string MARCH("MARCH"); bool IsMarch(char c) { for (auto i : MARCH) { if (i == c) return true; } return false; } char ItoC(int i) { return MARCH[i]; } int main() { int N; cin >> N; string S; map<char, int> m; for (int i = 0; i < int(N); ++i) { cin >> S; if (IsMarch(S[0])) { ++m[S[0]]; } } long long ans = 0; if (m.size() >= 3) { for (int bits = 0; bits < (1 << 5); ++bits) { bitset<5> bs(bits); if (bs.count() != 3) continue; bool ok = true; int num = 1; for (int i = 0; i < 5; ++i) { if (bs[i] != 0) { num *= m[ItoC(i)]; } } ans += num; } } 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
0
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { vector<string> a; int b, h = 0; int c = 0, d = 0, e = 0, f = 0, g = 0; cin >> b; for (int i = 0; i < b; i++) cin >> a[i]; for (int i = 0; i < b; i++) { if (a[i].find("M") == 0) c++; if (a[i].find("A") == 0) d++; if (a[i].find("R") == 0) e++; if (a[i].find("C") == 0) f++; if (a[i].find("H") == 0) g++; } h = c * d * e + c * d * f + c * d * g + d * e * f + d * e * g + e * f * g; cout << h << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int x, m; char n[100000][10]; int i, j, k; int d[5]; int h = 0; cin >> x; for (i = 0; i < x; i++) cin >> n[i]; for (i = 0; i < 5; i++) d[i] = 0; for (i = 0; i < x; i++) { if (n[i][0] == 'M') d[0]++; if (n[i][0] == 'A') d[1]++; if (n[i][0] == 'R') d[2]++; if (n[i][0] == 'C') d[3]++; if (n[i][0] == 'H') d[4]++; } for (i = 0; i < 5; i++) if (d[i] > 0) h++; int sum = 0; for (i = 0; i < 3; i++) { for (j = i + 1; j < 4; j++) { for (k = j + 1; k < 5; k++) { sum += d[i] * d[j] * d[k]; } } } cout << sum; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; map<char, int> counter; counter['M'] = counter['A'] = counter['R'] = counter['C'] = counter['H'] = 0; for (int i = (0); i < (N); ++i) { string s; cin >> s; ++counter[s[0]]; } char combination[10][3] = {{'M', 'A', 'R'}, {'M', 'A', 'C'}, {'M', 'A', 'H'}, {'M', 'R', 'C'}, {'M', 'R', 'H'}, {'M', 'C', 'H'}, {'A', 'R', 'C'}, {'A', 'R', 'H'}, {'A', 'C', 'H'}, {'R', 'C', 'H'}}; long long res = 0; for (int i = (0); i < (10); ++i) res += counter[combination[i][0]] * counter[combination[i][1]] * counter[combination[i][2]]; cout << res << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { vector<int> cnt(6); string s; int n, x, ans; cin >> n; for (int i = 0; i < n; i++) { cin >> s; switch (s[0]) { case 'M': x = 0; break; case 'A': x = 1; break; case 'R': x = 2; break; case 'C': x = 3; break; case 'H': x = 4; break; default: x = 5; break; } cnt[x]++; } ans = 0; for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 4; j++) { for (int k = j + 1; k < 5; k++) { ans += cnt[i] * cnt[j] * cnt[k]; } } } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { unsigned int i, ans = 1, x = 0; unsigned int ini[5] = {0}; string name[1000000]; cin >> i; for (; i > 0; i--) { cin >> name[i]; if (name[i][0] == 'M' || name[i][0] == 'A' || name[i][0] == 'R' || name[i][0] == 'C' || name[i][0] == 'H') { x++; } if (name[i][0] == 'M') { ini[0]++; } if (name[i][0] == 'A') { ini[1]++; } if (name[i][0] == 'R') { ini[2]++; } if (name[i][0] == 'C') { ini[3]++; } if (name[i][0] == 'H') { ini[4]++; } } for (; x > 3; x--) { ans *= x; } ans /= 2; for (int j = 0; j < 5; j++) { if (ini[j] > 1) ans -= 4; } cout << ans; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { string march = "MARCH"; vector<char> s; string t; int n; cin >> n; for (int i = 0; i < n; i++) { cin >> t; if (march.find(t[0]) == string::npos) continue; s.push_back(t[0]); } int sum = 0; vector<int> v(s.size()); for (int i = s.size() - 1; i > s.size() - 4; i--) { v[i] = 1; } if (s.size() < 3) { cout << 0; } else { do { set<char> m; for (int i = 0; i < s.size(); i++) { if (v[i] == 0) continue; m.insert(s[i]); } if (m.size() == 3) { sum++; } } while (next_permutation(v.begin(), v.end())); cout << sum; } cout << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; int T[5] = {0}; for (int i = 0; i < N; i++) { string S; cin >> S; switch (S.at(0)) { case 'M': T[0]++; break; case 'A': T[1]++; break; case 'R': T[2]++; break; case 'C': T[3]++; break; case 'H': T[4]++; break; default: break; } } unsigned long long sum = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { sum += T[i] * T[j] * T[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
python2
m = a = r = c = h = 0 for i in xrange(input()): s = raw_input() if s[0] == "M": m += 1 elif s[0] == "A": a += 1 elif s[0] == "R": r += 1 elif s[0] == "C": c += 1 elif s[0] == "H": h += 1 ans = 1 if m: ans *= m if a: ans *= a if r: ans *= r if c: ans *= c if h: ans *= h print ans
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
n = int(input()) names = [] for i in range(n): names.append(input()) names = [i[0] for i in names] nm = ["M","A","R","C","H"] ks = [names.count(nm[i]) for i in range(5)] ans = 0 for i in range(3): for j in range(i+1,4): for k in range(j+1,5): ans += i*j*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
java
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] list = new int[5]; for(int i = 0; i < 5; i++) { list[i] = 0; } for(int i = 0; i < n; i++) { String s = sc.next(); if(s.charAt(0) == 'M') list[0]++; else if(s.charAt(0) == 'A') list[1]++; else if(s.charAt(0) == 'R') list[2]++; else if(s.charAt(0) == 'C') list[3]++; else if(s.charAt(0) == 'H') list[4]++; } long ans = 0; for(int i = 0; i < 5; i++) { for(int j = i + 1; j < 5; j++) { for(int k = j + 1; k < 5; k++) { ans += list[i] + list[j] + list[k]; } } } System.out.println(ans); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.HashSet; import java.util.Set; import java.util.StringTokenizer; public class Main { public static void main(String[] args) { FastReader sc = new FastReader(); int n = sc.nextInt(); int[] dp = new int[5]; // For counting 'm', 'a', 'r', 'c', 'h'. // Choose three from five, there is total ten patterns. int[] p = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2}; int[] q = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3}; int[] r = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4}; int res = 0; for (int i = 0; i < n; i++) { String s = sc.next(); if (s.charAt(0) == 'M') { dp[0]++; } else if (s.charAt(0) == 'A') { dp[1]++; } else if (s.charAt(0) == 'R') { dp[2]++; } else if (s.charAt(0) == 'C') { dp[3]++; } else if (s.charAt(0) == 'H') { dp[4]++; } } for (int i = 0; i < 10; i++) { res += (dp[p[i]] * dp[q[i]] * dp[r[i]]); } System.out.println(res); } static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try{ str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } } }