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; constexpr long long MOD = (1e9 + 7); constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; } template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } long long factorial(long long n, long long m = 2) { m = max(2LL, m); long long rtn = 1; for (long long i = m; i <= n; i++) { rtn = (rtn * i) % MOD; } return rtn; } long long modinv(long long a, long long m) { long long b = m, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= m; if (u < 0) u += m; return u; } long long modpow(long long a, long long n) { long long res = 1; while (n > 0) { if (n & 1) res = res * a % MOD; a = a * a % MOD; n >>= 1; } return res; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; vector<int> march(5); int flag = 0; for (int i = 0; i < n; ++i) { string s; cin >> s; toupper(s[0]); if (s[0] == 'M') march[0]++; else if (s[0] == 'A') march[1]++; else if (s[0] == 'R') march[2]++; else if (s[0] == 'C') march[3]++; else if (s[0] == 'H') march[4]++; else flag++; } if (flag == n) cout << 0 << endl; else { int p[10] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2}; int q[10] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3}; int r[10] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4}; int cnt = 0; for (int i = 0; i < 10; ++i) { cnt += march[p[i]] * march[q[i]] * march[r[i]]; } cout << cnt << endl; } return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.*; public class Main{ public static void main(String args[]){ Scanner sc = new Scanner(System.in); int N = sc.nextInt(); String[] S = new String[N]; for(int i = 0; i < N; i++){ S[i] = sc.next(); } sc.close(); long m = 0; long a = 0; long r = 0; long c = 0; LongSummaryStatistics= 0; for(int i = 0; i < N; i++){ if(S[i].charAt(0) == 'M') m++; if(S[i].charAt(0) == 'A') a++; if(S[i].charAt(0) == 'R') r++; if(S[i].charAt(0) == 'C') c++; if(S[i].charAt(0) == 'H') h++; } long sum = 0; sum += m*a*r + m*a*c + m*a*h + m*r*c + m*r*h + m*c*h + a*r*c + a*r*h + a*c*h + r*c*h; System.out.println(sum); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
fun main(args: Array<String>) { val N = readLine()!!.toInt() val ss = (1..N).map { readLine()!! } val march = "MARCH".toCharArray() val counts: Map<Char, Int> = march.associateBy({it}, { ss.count {x -> x[0]==it} }) val ans = arrayOf( "MAR", "MAC", "MAH", "MRC", "MRH", "MCH", "ARC", "ARH", "ACH", "RCH" ).map { // println(it.map { x -> counts[x] }) it.map { x -> counts[x] }.fold(1) { x,y -> x * if(y==null) 0 else y } }.sum() println(ans) }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int MOD = (int)1e9 + 7; const int INF = 999999999; int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; vector<int> num(5, 0); for (int i = 0; i < (N); i++) { string s; cin >> s; switch (s[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; } } long long ans = 0; for (int i = 0; i < (3); i++) for (int j = i + 1; j < (5); j++) for (int k = j + 1; k < (5); k++) { ans += num[i] * num[j] * num[k]; } cout << ans << "\n"; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const long double PI = acos(-1); long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } long long lcm(long long a, long long b) { return a * b / gcd(a, b); } int main() { long long n; cin >> n; string s[n]; for (long long i = 0; i < n; i++) cin >> s[i]; int x[10] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2}; int y[10] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3}; int z[10] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4}; vector<long long> march(5, 0); for (long long i = 0; i < n; i++) { if (s[i][0] == 'M') { march[0]++; } if (s[i][0] == 'A') { march[1]++; } if (s[i][0] == 'R') { march[2]++; } if (s[i][0] == 'C') { march[3]++; } if (s[i][0] == 'H') { march[4]++; } } int ans = 0; for (long long i = 0; i < 10; i++) { ans += march[x[i]] * march[y[i]] * march[z[i]]; } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
using System; using System.Linq; class Problem_C { public static void Main(string[] args) { var n = int.Parse(Console.ReadLine()); int mNum = 0, aNum = 0, rNum = 0, cNum = 0, hNum = 0; for (var i = 0; i < n; i++) { var name = Console.ReadLine(); if (name.First() == 'M') { mNum++; } else if (name.First() == 'A') { aNum++; } else if (name.First() == 'R') { rNum++; } else if (name.First() == 'C') { cNum++; } else if (name.First() == 'H') { hNum++; } } long ans = (mNum * aNum * rNum) + (mNum * aNum * cNum) + (mNum * aNum * hNum) + (mNum * rNum * cNum) + (mNum * rNum * hNum) + (mNum * cNum * hNum) + (aNum * rNum * cNum) + (aNum * rNum * hNum) + (aNum * cNum * hNum) + (rNum * cNum * hNum); Console.WriteLine($"{ans}"); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; constexpr long long int INFLL = 1001001001001001LL; constexpr int INFI = 1000000007; int main() { int N; cin >> N; vector<int> S(5, 0); for (int i = 0; i < N; i++) { string s; cin >> s; if (s[0] == 'M') { S[0]++; } if (s[0] == 'A') { S[1]++; } if (s[0] == 'R') { S[2]++; } if (s[0] == 'C') { S[3]++; } if (s[0] == 'H') { S[4]++; } } int sum = 0; for (int bit = 0; bit < (1 << 5); bit++) { if (__builtin_popcount(bit) != 3) { continue; } int p = 1; for (int i = 0; i < 5; i++) { if (bit & (1 << i)) { p *= S[i]; } } sum += p; } 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; int main() { std::vector<string> dict; int n; scanf("%d", &n); string str; int countM = 0; int countA = 0; int countR = 0; int countC = 0; int countH = 0; for (int i = 0; i < n; i++) { cin >> str; if (str[0] == 'M') { countM++; } if (str[0] == 'A') { countA++; } if (str[0] == 'R') { countR++; } if (str[0] == 'C') { countC++; } if (str[0] == 'H') { countH++; } } unsigned long long sum = 0; sum += countM * countA * countR; sum += countM * countA * countC; sum += countM * countA * countH; sum += countM * countR * countC; sum += countM * countR * countH; sum += countM * countC * countH; sum += countA * countR * countC; sum += countA * countR * countH; sum += countA * countC * countH; sum += countR * countC * countH; printf("%llu", sum); }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
/* ---------- STL Libraries ---------- */ // IO library #include <cstdio> #include <fstream> #include <iomanip> #include <ios> #include <iostream> // algorithm library #include <algorithm> #include <cmath> #include <numeric> #include <random> // container library #include <array> #include <bitset> #include <deque> #include <map> #include <queue> #include <set> #include <string> #include <tuple> #include <vector> /* ---------- Namespace ---------- */ using namespace std; /* ---------- Type Abbreviation ---------- */ template <typename T> using PQ = priority_queue<T>; template <typename T> using GPQ = priority_queue<T, vector<T>, greater<T>>; using ll = long long; #define fst first #define snd second #define mp make_pair #define mt make_tuple /* ---------- conversion ---------- */ #define INT(c) static_cast<int>(c) #define CHAR(n) static_cast<char>(n) #define LL(n) static_cast<ll>(n) #define DOUBLE(n) static_cast<double>(n) /* ---------- container ---------- */ #define ALL(v) (v).begin(), (v).end() #define SIZE(v) (LL((v).size())) #define FIND(v, k) (v).find(k) != (v).end() #define VFIND(v, k) find(ALL(v), k) != (v).end() #define gsort(b, e) sort(b, e, greater<decltype(*b)>()) /* ----------- debug ---------- */ template <class T> ostream& operator<<(ostream& os, vector<T> v) { os << "["; for (auto vv : v) os << vv << ","; return os << "]"; } template <class T> ostream& operator<<(ostream& os, set<T> v) { os << "["; for (auto vv : v) os << vv << ","; return os << "]"; } template <class L, class R> ostream& operator<<(ostream& os, pair<L, R> p) { return os << "(" << p.fst << "," << p.snd << ")"; } /* ---------- Constants ---------- */ // const ll MOD = 1e9 + 7; // const int INF = 1 << 25; // const ll INF = 1LL << 50; // const double PI = acos(-1); // const double EPS = 1e-10; // mt19937 mert(LL(time(0))); /* ---------- Short Functions ---------- */ template <typename T> T sq(T a) { return a * a; } template <typename T> T gcd(T a, T b) { if (a > b) return gcd(b, a); return a == 0 ? b : gcd(b % a, a); } template <typename T, typename U> T mypow(T b, U n) { if (n == 0) return 1; if (n == 1) return b /* % MOD */; if (n % 2 == 0) { return mypow(b * b /* % MOD */, n / 2); } else { return mypow(b, n - 1) * b /* % MOD */; } } ll pcnt(ll b) { return __builtin_popcountll(b); } // const ll dx[4] = {0, -1, 1, 0}; // const ll dy[4] = {-1, 0, 0, 1}; // const ll dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1}; // const ll dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1}; /* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */ int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; int cnt_M = 0, cnt_A = 0, cnt_R = 0, cnt_C = 0, cnt_H = 0; REP(i, N) { char S; cin >> S; if (S[0] == 'M') cnt_M++; else if (S[0] == 'A') cnt_A++; else if (S[0] == 'R') cnt_R++; else if (S[0] == 'C') cnt_C++; else if (S[0] == 'H') cnt_H++; } cout << cnt_M * cnt_A*cnt_R*cnt_C*cnt_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; signed main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; int cnt[5] = {}; for (int i = 0; i < (n); ++i) { string s; cin >> s; if (s[0] == 'M') cnt[0]++; if (s[0] == 'A') cnt[1]++; if (s[0] == 'R') cnt[2]++; if (s[0] == 'C') cnt[3]++; if (s[0] == 'H') cnt[4]++; } long long ans = 0; for (int i = 0; i < (5); ++i) for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < n; k++) { ans += cnt[i] * cnt[j] * cnt[k]; } } cout << ans << '\n'; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> name(5, 0); for (int i = 0; i < N; i++) { string tmp; cin >> tmp; if (tmp[0] == 'M') name[0]++; else if (tmp[0] == 'A') name[1]++; else if (tmp[0] == 'R') name[2]++; else if (tmp[0] == 'C') name[3]++; else if (tmp[0] == 'H') name[4]++; } int64_t 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++) { if (i != j && j != k && k != i) { res += (name[i] * name[j] * name[k]); } } } } cout << res << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { set<char> march({'M', 'A', 'R', 'C', 'H'}); vector<char> s; string t; int n; cin >> n; for (int i = 0; i < n; i++) { cin >> t; s.push_back(t[0]); } int sum = 0; vector<int> v(n); for (int i = n - 1; i > n - 4; i--) { v[i] = 1; } if (s.size() < 3) { cout << 0; } else { do { set<char> m; for (int i = 0; i < n; i++) { if (v[i] == 0) continue; if (march.find(s[i]) == march.end()) 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
UNKNOWN
#include <bits/stdc++.h> int main() { int n, i, counter[5] = {0}; char s[100001][11]; long long ans = 0; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%s", s[i]); } for (i = 0; i < n; i++) { if (s[i][0] == 'M') { counter[0]++; } else if (s[i][0] == 'A') { counter[1]++; } else if (s[i][0] == 'R') { counter[2]++; } else if (s[i][0] == 'C') { counter[3]++; } else if (s[i][0] == 'H') { counter[4]++; } } ans += counter[0] * counter[1] * counter[2]; ans += counter[0] * counter[1] * counter[3]; ans += counter[0] * counter[1] * counter[4]; ans += counter[0] * counter[2] * counter[3]; ans += counter[0] * counter[2] * counter[4]; ans += counter[0] * counter[3] * counter[4]; ans += counter[1] * counter[2] * counter[3]; ans += counter[1] * counter[2] * counter[4]; ans += counter[1] * counter[3] * counter[4]; ans += counter[2] * counter[3] * counter[4]; printf("%lld", ans); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s[10000]; int m = 0, a = 0, r = 0, c = 0, h = 0; for (int i = 0; i < n; i++) { cin >> s[i]; if (s[i][0] == 'M') m++; if (s[i][0] == 'A') a++; if (s[i][0] == 'R') r++; if (s[i][0] == 'C') c++; if (s[i][0] == 'H') h++; } cout << m * a * r + m * a * c + m * a * h + m * r * c + m * r * h + m * c * h + a * r * c + a * r * h + a * c * h + r * c * h << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
n = int(input()) count = [0]*5 d = {'M': 0, 'A': 1, 'R': 2, 'C':3, 'H': 4} for i in range(n): s = input() if s[0] in 'MARCH': count[d[s[0]]] += 1 ans = 0 for i in range(5): for j in range(i+1, 5): for k in range(j+1, 5): ans += count[i] * count[j] * count[k]] print(ans)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int Nmax = 200010; int main() { long long N; cin >> N; string S[Nmax]; char c[Nmax]; int cnt[5] = {}, count = 0; for (int i = 0; i < N; i++) { cin >> S[i]; string str(S[i]); c[i] = str[0]; if (c[i] == 'M') cnt[0]++; if (c[i] == 'A') cnt[1]++; if (c[i] == 'R') cnt[2]++; if (c[i] == 'C') cnt[3]++; if (c[i] == 'H') cnt[4]++; } long long ans = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { ans += 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
UNKNOWN
#include <bits/stdc++.h> int main(void) { int N, i, j, m = 0, a = 0, r = 0, c = 0, h = 0; int count[5] = {0}; long long int sum = 0; char S[12]; scanf("%d", &N); for (i = 0; i < N; i++) { scanf("%s", S); switch (S[0]) { case 'M': count[0]++; case 'A': count[1]++; case 'R': count[2]++; case 'C': count[3]++; case 'H': count[4]++; } } for (i = 0; i < 4; i++) { for (j = i + 1; j < 5; j++) { sum += count[i] * count[j]; } } printf("%lld\n", sum); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") using namespace std; const int INF = 2147483647; using ll = long long; int combination(int n, int k) { int ans; ll a = 1; ll b = 1; for (int i = 0; i < k; i++) { a *= (n - i); b *= (k - i); } return a / b; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<string> s(n); map<char, int> table; int count = 0; for (int i = 0; i < n; ++i) { cin >> s[i]; if (s[i].at(0) == 'M') table['M']++; if (s.at(i).at(0) == 'A') table['A']++; if (s.at(i).at(0) == 'R') table['R']++; if (s.at(i).at(0) == 'C') table['C']++; if (s.at(i).at(0) == 'H') table['H']++; } for (auto i : table) { count += i.second; } if (table.size() <= 2) { cout << 0 << endl; return 0; } int ans = combination(count, 3); int diff; for (auto& i : table) { i.second--; } for (auto i : table) { if (i.second != 0) { int sum = 0; for (auto j : table) { sum += j.second; } sum = sum - i.second + table.size() - 1; cout << sum << endl; diff = i.second * combination(sum, 2); cout << diff << endl; ans -= diff; } } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = Integer.parseInt(sc.next()); int[] a = new int[5]; for (int i = 0; i < n; i++) { String[] s = sc.next().split(""); if (s[0].equals("M")) a[0]++; if (s[0].equals("A")) a[1]++; if (s[0].equals("R")) a[2]++; if (s[0].equals("C")) a[3]++; if (s[0].equals("H")) a[4]++; } long ans = 0; ans += a[0] * a[1] * a[2]; ans += a[1] * a[2] * a[3]; ans += a[2] * a[3] * a[4]; ans += a[0] * a[2] * a[3]; ans += a[0] * a[2] * a[4]; ans += a[0] * a[3] * a[4]; ans += a[0] * a[1] * a[3]; ans += a[0] * a[1] * a[4]; ans += a[1] * a[2] * a[4]; ans += a[1] * a[3] * a[4]; System.out.println(ans); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int n; string s[100000]; int cnt[5] = {0}; long long cal_ans() { long long ans(0); for (int i(0); i < 3; i++) { for (int j(i + 1); j < 4; j++) { for (int k(j + 1); k < 5; k++) { ans += cnt[i] * cnt[j] * cnt[k]; } } } return ans; } int main(void) { cin >> n; for (int i(0); i < n; i++) { cin >> s[i]; } for (int i(0); i < n; i++) { if (s[i][0] == 'M') cnt[0]++; else if (s[i][0] == 'A') cnt[1]++; else if (s[i][0] == 'R') cnt[2]++; else if (s[i][0] == 'C') cnt[3]++; else if (s[i][0] == 'H') cnt[4]++; } cout << cal_ans() << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<string> s(n); vector<int> m(6); for (int i = 0; i < (n); i++) { cin >> s[i]; if (s[i][0] == 'M') m[0]++; if (s[i][0] == 'A') m[1]++; if (s[i][0] == 'R') m[2]++; if (s[i][0] == 'C') m[3]++; if (s[i][0] == 'H') m[4]++; } vector<int> a1 = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2}, a2 = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3}, a3 = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4}; long long ans = 0; for (int i = 0; i < (10); i++) ans += m[a1[i]] * m[a2[i]] * m[a3[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; int main() { int N; long long int group[5] = {}; long long int ans = 0; string tmp; cin >> N; for (int i = 0; i < N; i++) { cin >> tmp; switch (tmp[0]) { case 'M': group[0]++; break; case 'A': group[1]++; break; case 'R': group[2]++; break; case 'C': group[3]++; break; case 'H': group[4]++; break; default: continue; } } for (int i = 0; i < N - 2; i++) { for (int j = i + 1; j < N - 1; j++) { for (int k = j + 1; k < N; k++) { ans += group[i] * group[j] * group[k]; } } } printf("%lld\n", ans); }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; string s[100000]; int counts[5]; int main() { for (size_t i = 0; i < 5; i++) { counts[i] = 0; } int N; cin >> N; string march = "MARCH"; for (size_t i = 0; i < N; i++) { cin >> s[i]; auto p = march.find(s[i][0]); if (p == string::npos) continue; counts[p]++; } long long ans = 0; for (size_t i = 0; i < 5; i++) { for (size_t j = i + 1; j < 5; j++) { for (size_t k = j + 1; k < 5; k++) { ans += counts[i] * counts[j] * counts[k]; } } } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
m=0 a=0 r=0 c=0 h=0 n=int(input()) for i in range(n): s=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 else:pass li=[m,a,r,c,h] ans=0 for ai in range(n): for bi in range(n): for ci in range(n): if ci>bi>ai: ans+=li[ai]*li[bi]*li[ci] print(ans)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static void Main(string[] args) { int n = int.Parse(ReadLine()); List<string> s = new List<string>(); for (int i=0;i<n;i++) { s.Add(ReadLine()); } var hashSet = new HashSet<string>(s); s = hashSet.ToList(); List<int> ans = new List<int>(); for (int i=0;i<5;i++) { ans.Add(0); } for (int i=0;i<s.Count;i++) { if (s[i].Substring(0,1)=="M") { ans[0]+=1; } else if (s[i].Substring(0,1)=="A") { ans[1]+=1; } else if (s[i].Substring(0,1)=="R") { ans[2]+=1; } else if (s[i].Substring(0,1)=="C") { ans[3]+=1; } else if (s[i].Substring(0,1)=="H") { ans[4]+=1; } } int answ=0; for (int i=0;i<5;i++) { for (int j=0;j<5;j++) { for (int k=0;k<5;k++) { //Write(i); //Write(j); //WriteLine(k); if (i!=j && j!=k && i!=k) { answ+=ans[i]*ans[j]*ans[k]; } } } } WriteLine(answ/6); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const long long int MAX_N = 100000; int main(int argc, char const *argv[]) { long long int N; vector<string> S(MAX_N); map<char, int> mp; char march[5] = {'M', 'A', 'R', 'C', 'H'}; for (int i = 0; i < 5; i++) { mp[march[i]] = 0; } int P[10] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2}; int Q[10] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3}; int R[10] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4}; cin >> N; for (long long int i = 0; i < N; i++) { cin >> S[i]; mp[S[i][0]]++; } int D[5]; for (int i = 0; i < 5; i++) { D[i] = mp[march[i]]; } long long int ans = 0; for (int d = 0; d < 10; d++) ans += D[P[d]] * D[Q[d]] * D[R[d]]; cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include <stdio.h> #include <stdlib.h> #include <string.h> int main(void) { char buffer[15]; if (fgets(buffer, 15, stdin) == NULL) { return 1; } int N = atoi(buffer); char (* names)[11] = malloc(sizeof(char*)*N); for (int i = 0; i < N; i++) { if (fgets(names[i], 11, stdin) == NULL) { return 1; } names[i][strlen(names[i])-1] = '\0'; } long pattern_sum = 0; const char* MARCH = "MARCH"; char *ff = NULL, *sf = NULL, *tf = NULL; for (int f = 0; f < N; f++) { for (int s = f+1; s < N; s++) { for (int t = s+1; t < N; t++) { if ((names[f][0] != names[s][0]) && (names[f][0] != names[t][0]) && (names[s][0] != names[t][0])) { ff = index(MARCH, names[f][0]); sf = index(MARCH, names[s][0]); tf = index(MARCH, names[t][0]); if (ff != NULL && sf != NULL && tf != NULL) { pattern_sum += 1.0; } } } } } printf("%ld", pattern_sum); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main(void) { int n; cin >> n; int march[5] = {0}; for (int i = 0; i < n; i++) { string s; cin >> s; if (s[0] == 'M') march[0]++; if (s[0] == 'A') march[1]++; if (s[0] == 'R') march[2]++; if (s[0] == 'C') march[3]++; if (s[0] == 'H') march[4]++; } long ans = 0; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { for (int k = j + 1; k < n; k++) { ans += march[i] * march[j] * march[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; using ll = long long; using P = pair<int, int>; using Graph = vector<vector<int>>; template <class t, class u> void chmax(t& a, u b) { if (a < b) a = b; } template <class t, class u> void chmin(t& a, u b) { if (b < a) a = b; } const int INF = 1e9 + 5; int one[] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2}; int two[] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3}; int thr[] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4}; int main() { int n; cin >> n; vector<string> s(n); for (int i = 0; i < (n); ++i) cin >> s[i]; map<char, int> m; for (int i = 0; i < (n); ++i) { if (s[i][0] == 'M' || s[i][0] == 'A' || s[i][0] == 'R' || s[i][0] == 'C' || s[i][0] == 'H') { m[s[i][0]]++; } } ll res = 0; vector<ll> d(5, 0); int index = 0; for (auto ma : m) { d[index] = (ll)ma.second; index++; } for (int i = 0; i < (10); ++i) res += (d[one[i] * d[two[i]]] * d[thr[i]]); cout << res << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <iostream> using namespace std; int count(int H, int W, int D, int A[300][300], int L[100000], int R[100000], int k){ int i, j=0,l=0,x[H*W],y[H*W],S=0; return S; } int main(){ int H,W,D,A[H][W],i,j,k,Q,L[Q],R[Q],MP=0; cin >> H >> W >> D; for(i=0;i<H;i++){ for(j=0;j<W;j++){ cin >> A[i][j]; } } cin >> Q; for(i=0;i<Q;i++){ cin >> L[i] >> R[i]; } for(k=0;k<Q;k++){ while(L[k]!=R[k]){ for(i=0;i<H;i++){ if(A[i][j]==L[k]){ x[l]=i; y[l]=j; l++; break; } else{j++;} } L[k] += D; i=0; j=0; } for(i=0;i<l-1;i++){ MP += abs(x[l]-x[l+1])+abs(y[l]-y[l+1]); } } cout << MP << 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
#![allow(unused_imports)] use std::{i32, i64, u32, u64, usize, f64}; use std::cmp::{max, min, Ordering}; use std::collections::*; use std::io::{stdout, Write, BufWriter}; use std::mem::{swap}; use maplit::*; use proconio::marker::{Isize1, Usize1, Bytes, Chars}; #[proconio::fastout] fn main() { proconio::input!{ n: usize, ss: [Chars; n], } let march = ['M', 'A', 'R', 'C', 'H']; let mut map = hashmap!{ 'M' => 0, 'A' => 0, 'R' => 0, 'C' => 0, 'H' => 0, }; for s in ss { let ini = s.first().unwrap(); if march.contains(&ini) { *map.get_mut(ini).unwrap() += 1; } } if map.is_empty() { println!("0"); return; } let m = map[&'M']; let a = map[&'A']; let r = map[&'R']; let c = map[&'C']; let h = map[&'H']; println!("{}", m*(a*(r+c+h)+r*(c+h)+c*h)+a*(r*(c+h)+c*h)+r*c*h); }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; 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; } const long long INF = 1LL << 60; using pll = pair<long long, long long>; void init() { cin.tie(nullptr); ios_base::sync_with_stdio(false); return; } int main() { init(); int n; cin >> n; map<char, int> mp; string tmp; for (int i = 0; i < n; i++) { cin >> tmp; if (tmp[0] == 'M' || tmp[0] == 'A' || tmp[0] == 'R' || tmp[0] == 'C' || tmp[0] == 'H') { ++mp[tmp[0]]; } } long long res = 0; int kinds = mp.size(); vector<int> moji; for (auto x : mp) { moji.push_back(x.second); } if (moji.size() >= 3) { for (size_t i = 0; i < moji.size() - 2; i++) { for (int j = i + 1; j < moji.size(); j++) { for (int z = j + 1; z < moji.size(); z++) { cout << i << " " << j << " " << z << endl; res += moji[i] * moji[j] * moji[z]; } } } } 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; const long long inf = 1e18 + 7; const long long mod = 1e9 + 7; int main() { int n; cin >> n; vector<int> cnt(5); for (long long i = 0; i < (long long)(n); i++) { string s; cin >> s; if (s[0] == 'M') { cnt[0]++; } else if (s[0] == 'A') { cnt[1]++; } else if (s[0] == 'R') { cnt[2]++; } else if (s[0] == 'C') { cnt[3]++; } else if (s[0] == 'H') { cnt[4]++; } } long long ans = 0; for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 4; j++) { for (int k = j + 1; k < 5; k++) { ans += cnt[i] * cnt[j] * cnt[k]; } } } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\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; map<char, int> S; vector<char> H = {'M', 'A', 'R', 'C', 'H'}; vector<string> H_COMB = {"MAR", "MAC", "MAH", "MRC", "MRH", "MCH", "ARC", "ARH", "ACH", "RCH"}; int ans; void solve() { if (S.size() < 3) ans = 0; else { for (string h : H_COMB) { ans += S[h[0]] * S[h[1]] * S[h[2]]; } } cout << ans << endl; } int main() { cin >> N; for (int i = 0; i < N; ++i) { string str; cin >> str; for (char h : H) { if (h == str[0]) { ++S[h]; break; } } } solve(); }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\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 m[200005],a[200005],r[200005],c[200005],h[200005]; void is(char g,int b){ if(g == 'M') m[b]++; else if(g == 'A') a[b]++; else if(g == 'R') r[b]++; else if(g == 'C') c[b]++; else if(g == 'H') h[b]++; } int main(){ long long n; cin >> n; string input; for(long long i = 0; i < n; i++){ cin >> input; is(input[0],i); } for(long long i = n-2; i >= 0; i--){ m[i] += m[i+1]; a[i] += a[i+1]; r[i] += r[i+1]; c[i] += c[i+1]; h[i] += h[i+1]; } long long sol = 0; for(long long i = 0; i < n; i++){ if(x[i][0] == 'M'){ sol += a[i] * r[i]; sol += a[i] * c[i]; sol += a[i] * h[i]; sol += r[i] * c[i]; sol += r[i] * h[i]; sol += c[i] * h[i]; } else if(x[i][0] == 'A'){ sol += m[i] * r[i] + m[i] * c[i] + m[i] * h[i] + r[i] * c[i] + r[i] * h[i] + c[i] * h[i]; } else if(x[i][0] == 'R'){ sol += m[i] * a[i] + m[i] * c[i] + m[i] * h[i] + a[i] * c[i] + a[i] * h[i] + c[i] * h[i]; } else if(x[i][0] == 'C'){ sol += m[i] * a[i] + m[i] * r[i] + m[i] * h[i] + a[i] * r[i] + a[i] * h[i] + r[i] * h[i]; } else if(x[i][0] == 'H'){ sol += m[i] * a[i] + m[i] * r[i] + m[i] * c[i] + a[i] * r[i] + a[i] * c[i] + r[i] * c[i]; } } cout << sol; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\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 MOD = 1000000007; const long long int INF = 1000000000; int main() { int n; cin >> n; long long int a[5] = {}; for (int i = 0; i < n; i++) { string s; cin >> s; if (s[0] == 'M') { a[0]++; } else if (s[0] == 'A') { a[1]++; } else if (s[0] == 'R') { a[2]++; } else if (s[0] == 'C') { a[3]++; } else if (s[0] == 'H') { a[4]++; } } long long int ans = 1; bool f = false; long long int s = 0; long long int su = 0; for (int i = 0; i < 5; i++) { if (a[i] != 0) { su += a[i]; ans *= a[i]; s++; } } if (su < 3) { f = true; } if (f) { ans = 0; } else if (s == 4 || s == 5) { ans = 0; for (int i = 0; i < 3; i++) { for (int j = i; j < 4; j++) { for (int k = j; k < 5; k++) { if (a[i] == 0 || a[j] == 0 || a[k] == 0) { continue; } if (i == j || j == k || i == k) { continue; } ans += a[i] * a[j] * a[k]; } } } } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
from collections import Counter N = int(input()) name = [] for _ in range(N): a = input() name.append(a[0]) name = Counter(name) kouho = [] kouho.append(name["M"]) kouho.append(name["A"]) kouho.append(name["R"]) kouho.append(name["C"]) kouho.append(name["H"]) name = [] for i in kouho: if i == 0: continue name.append(i) total = sum(name) seki = 1 for i in name: seki = seki*i if len(name) < 3: print(0) elif len(name) == 3: print(seki) elif len(name) == 4: ans = seki*4 hiku = total-4 ans = ans-hiku print(ans) else: ans = seki*10 hiku = total-5 ans = ans-hiku print(ans)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<string> s(n); for (int i = 0; i < (n); i++) cin >> s[i]; vector<int> num(5); for (int i = 0; i < (n); i++) { if (s[i][0] == 'M') { num[0]++; } if (s[i][0] == 'A') { num[1]++; } if (s[i][0] == 'R') { num[2]++; } if (s[i][0] == 'C') { num[3]++; } if (s[i][0] == 'H') { num[4]++; } } int 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 += num[i] * num[j] * num[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; using ll = long long; const int INF = 1050000000; const long long LINF = 1LL << 60; const ll MOD = 1e9 + 7; const int MINF = -1050000000; int main() { int n; cin >> n; vector<int> kazu(5, 0); for (int i = (int)0; i < (int)n; ++i) { string st; cin >> st; if (st[0] == 'M') kazu[0]++; if (st[0] == 'A') kazu[1]++; if (st[0] == 'R') kazu[2]++; if (st[0] == 'C') kazu[3]++; if (st[0] == 'H') kazu[4]++; } 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 += kazu[i] * kazu[j] * kazu[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() { int64_t N; cin >> N; int64_t m = 0; int64_t a = 0; int64_t r = 0; int64_t c = 0; int64_t h = 0; for (int i = 0; i < N; i++) { string s; cin >> s; char x = s.at(0); if (x == 'M') m++; if (x == 'A') a++; if (x == 'R') r++; if (x == 'C') c++; if (x == 'H') h++; } int64_t ans = m * a * r * c * h; cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
package main import ( "bufio" "fmt" "os" "strconv" ) var sc = bufio.NewScanner(os.Stdin) func next() string { sc.Scan() return sc.Text() } func nextInt() int { sc.Scan() i, e := strconv.Atoi(sc.Text()) if e != nil { panic(e) } return i } func main() { sc.Split(bufio.ScanWords) N := nextInt() m := map[rune]int{'M': 0, 'A': 1, 'R': 2, 'C': 3, 'H': 4} v := make([]int, 5) for i := 0; i < N; i++ { s := next() v[m[rune(s[0])]]++ } sum := 0 for i := 0; i < 3; i++ { for j := i+1; j < 4; j++ { for k := j+1; k < 5; k++ { sum += v[i] * v[j] * v[k] } } } fmt.Println(sum) }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; const int INF = 1 << 30; const int MOD = (int)1e9 + 7; const int MAX_N = (int)1e5 + 5; template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << p.first << " " << p.second; return os; } template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (int i = 0; i < (int)v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; } template <int mod> struct ModInt { int x; ModInt() : x(0) {} ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {} ModInt &operator+=(const ModInt &p) { if ((x += p.x) >= mod) { x -= mod; } return *this; } ModInt &operator-=(const ModInt &p) { if ((x += mod - p.x) >= mod) { x -= mod; } return *this; } ModInt &operator*=(const ModInt &p) { x = (int)(1LL * x * p.x % mod); return *this; } ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; } ModInt operator-() const { return ModInt(-x); } ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; } ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; } ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; } ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; } bool operator==(const ModInt &p) const { return x == p.x; } bool operator!=(const ModInt &p) const { return x != p.x; } ModInt inverse() const { int a = x, b = mod, u = 1, v = 0; while (b > 0) { int t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); } return ModInt(u); } ModInt pow(int64_t n) const { ModInt res(1), mul(x); while (n > 0) { if (n & 1) { res *= mul; } mul *= mul; n >>= 1; } return res; } friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x; } friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt<mod>(t); return (is); } static int get_mod() { return mod; } }; using modint = ModInt<MOD>; void solve() { int n; cin >> n; map<char, ll> mp; const string key = "MARCH"; for (int i = 0; i < n; i++) { string s; cin >> s; for (int j = 0; j < key.size(); j++) { if (s.front() == key[j]) mp[s.front()]++; } } modint ans = 0; for (int bit = 0; bit < (1 << (int)key.size()); bit++) { if (__builtin_popcount(bit) != 3) continue; modint cnt = 1; for (int i = 0; i < key.size(); i++) { if (bit & (1 << i)) cnt *= (ll)mp[key[i]]; } ans += cnt; } cout << ans << endl; } signed main(void) { 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
#include <bits/stdc++.h> int main() { int n, ini[5] = {}; long int ans1 = 0, ans2 = 0; char name[11]; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%s", name); switch (name[0]) { case 'M': ini[0]++; break; case 'A': ini[1]++; break; case 'R': ini[2]++; break; case 'C': ini[3]++; break; case 'H': ini[4]++; break; default: break; } } for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 4; j++) { for (int k = j + 1; k < 5; k++) { ans2 += ini[i] * ini[j] * ini[k]; ans1 += ans2 / 10000000; ans2 %= 10000000; } } } if (ans1) { printf("%lu%07lu", ans1, ans2); } else { printf("%lu", ans2); } return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vvi = vector<vi>; using pii = pair<int, int>; 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]++; } } } 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
UNKNOWN
extern crate core; use std::io::{self, Read}; fn main() { let mut input = String::new(); io::stdin().read_to_string(&mut input).unwrap(); let output = run(input.trim().to_string()); println!("{}", output); } fn run(input: String) -> String { let mut m = 0; let mut a = 0; let mut r = 0; let mut c = 0; let mut h = 0; for x in input.split("\n").skip(1).map(|x| x.to_string()) { if x.find("M") == Some(0) { m += 1; } else if x.find("A") == Some(0) { a += 1; } else if x.find("R") == Some(0) { r += 1; } else if x.find("C") == Some(0) { c += 1; } else if x.find("H") == Some(0) { h += 1; } } let mut list = vec![]; if m != 0 { list.push(m); } if a != 0 { list.push(a); } if r != 0 { list.push(r); } if c != 0 { list.push(c); } if h != 0 { list.push(h); } //グループの数 let n = list.len(); if n == 3 { list[0] * list[1] * list[2] } else if n == 4 { list[0] * list[1] * list[2] + list[0] * list[1] * list[3] + list[0] * list[2] * list[3] + list[1] * list[2] * list[3] } else if n == 5 { list[0] * list[1] * list[2] + list[0] * list[1] * list[3] + list[0] * list[1] * list[4] + list[0] * list[2] * list[3] + list[0] * list[2] * list[4] + list[0] * list[3] * list[4] + list[1] * list[2] * list[3] + list[0] * list[2] * list[4] + list[1] * list[3] * list[4] + list[2] * list[3] * list[4] } else { 0 }.to_string() } #[test] fn test() { let tests = vec![ ( "5 MASHIKE RUMOI OBIRA HABORO HOROKANAI", "2", ), ( "4 ZZ ZZZ Z ZZZZZZZZZZ", "0", ), ( "5 CHOKUDAI RNG MAKOTO AOKI RINGO", "7", ), ]; for (i, (input, output)) in tests.into_iter().enumerate() { println!("test:{}", i); assert_eq!(run(input.to_string()), output.to_string()); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; int at[6], aq[6]; long long cek() { long long bak = 0; for (int i = 1; i <= 3; i++) { if (aq[i] == 1) for (int j = i + 1; j <= 4; j++) { if (aq[j] == 1) for (int k = j + 1; k <= 5; k++) { if (aq[k] == 1) bak += at[i] * at[j] * at[k]; } } } return bak; } int main() { string A; map<string, int> qqq; int N; while (~scanf(" %d", &N)) { for (int i = 1; i <= 5; i++) { at[i] = 0; aq[i] = 0; } for (int i = 1; i <= N; i++) { cin >> A; qqq[A] += 1; if (A[0] == 'M') { if (A[0] > 1) at[1] += 1; aq[1] = 1; } if (A[0] == 'A') { if (A[0] > 1) at[2] += 1; aq[2] = 1; } if (A[0] == 'R') { if (A[0] > 1) at[3] += 1; aq[3] = 1; } if (A[0] == 'C') { if (A[0] > 1) at[4] += 1; aq[4] = 1; } if (A[0] == 'H') { if (A[0] > 1) at[5] += 1; aq[5] = 1; } } long long sum = 0, flag = 0; for (int i = 1; i <= 5; i++) { if (aq[i] == 1) flag += 1; } if (flag >= 3) sum = cek(); printf("%lld\n", sum); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
import java.io.InputStreamReader import java.io.BufferedReader fun main(args: Array<String>) { val br = BufferedReader(InputStreamReader(System.`in`)) val n = br.readLine().toInt() val ref = "MARCH" val table = LongArray(n) for(i in 1..n) { val s = br.readLine().first() val idx = ref.indexOf(s) if(idx != -1) table[idx]++ } fun compute():Long { var acc = 0L for(i in 0 until n) for(j in i+1 until n) for(k in j+1 until n) { acc += table[i] * table[j] * table[k] } return acc } val ans = compute() println(ans) }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int book[5] = {0}; long long c[100001][4]; long long c0; void C(int n, int m) { for (int i = 0; i <= n; i++) for (int j = 0; j <= m; j++) if (j == 0) c[i][j] = 1; else if (i == 0 && j >= 1) c[i][j] = 0; else c[i][j] = c[i - 1][j] + c[i - 1][j - 1]; } int main() { int N, num = 0; char a[10000][10]; scanf("%d", &N); for (int i = 0; i < N; i++) { scanf("%s", &a[i]); switch (a[i][0]) { case 'M': book[0]++; num++; break; case 'A': book[1]++; num++; break; case 'R': book[2]++; num++; break; case 'C': book[3]++; num++; break; case 'H': book[4]++; num++; break; defaut: break; } } C(num, 3); c0 = c[num][3]; for (int i = 0; i < 5; i++) { if (book[i] == 2) c0 = c0 - c[num - 2][1]; if (book[i] >= 3) c0 = c0 - c[book[i]][3] - c[book[i]][2] * c[num - book[i]][1]; } printf("%lli", c0); }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; vector<string> s(n); int m = 0, a = 0, r = 0, c = 0, h = 0; for (int i = (0); i < (n); ++i) { cin >> s[i]; if (s[i][1] == 'M') m++; if (s[i][1] == 'A') a++; if (s[i][1] == 'R') r++; if (s[i][1] == 'C') c++; if (s[i][1] == 'H') h++; } if (m == 0) m++; if (a == 0) a++; if (r == 0) r++; if (c == 0) c++; if (h == 0) h++; cout << m * a * 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 main() { int n; int a[5] = {0}; char tmp[50]; int count = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> tmp; if (tmp[0] == 'M') a[0]++; if (tmp[0] == 'A') a[1]++; if (tmp[0] == 'R') a[2]++; if (tmp[0] == 'C') a[3]++; if (tmp[0] == 'H') a[4]++; } for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 4; j++) { for (int k = j + 1; k < 5; k++) { count += a[i] * a[j] * a[k]; } } } printf("%d\n", count); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a(5); for (int i = 0; i < n; i++) { string s; cin >> s; if (s[0] == 'M') a[0]++; else if (s[0] == 'A') a[1]++; else if (s[0] == 'R') a[2]++; else if (s[0] == 'C') a[3]++; else if (s[0] == 'H') a[4]++; } long long ans = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { ans += a[i] * a[j] * a[k]; } } } 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; char name[15]; long long a[10]; void solve(char ch) { if (ch == 'M') a[0]++; else if (ch == 'A') a[1]++; else if (ch == 'R') a[2]++; else if (ch == 'C') a[3]++; else if (ch == 'H') a[4]++; } int main() { long long n; long long i; while (scanf("%lld", &n) != EOF) { memset(a, 0, sizeof(a)); for (i = 0; i < n; i++) { scanf("%s", name); solve(name[0]); } long long num1 = 0, num2 = 0, num3 = 0; long long ans = 0, ans2 = 0; for (i = 0; i < 5; i++) { num1 += a[i]; if (a[i] >= 2) num2++; if (a[i] >= 3) num3++; } for (i = 0; i < 5; i++) { if (a[i] >= 2) { ans += (a[i] * a[i] - 1) / 2 * (num1 - a[i]); } if (a[i] >= 3) { ans2 += a[i] * (a[i] - 1) * (a[i] - 2) / 6; } } printf("%lld\n", num1 * (num1 - 1) * (num1 - 2) / 6 - ans - ans2); } 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
<?php fscanf(STDIN,"%d",$n); $chars = array(); $march = array('M','A','R','C','H'); $index = ''; for($i=0;$i<$n;$i++){ $tmp_c = trim(fgets(STDIN)); if(in_array($tmp_c[0],$march)) $chars[$tmp_c[0]]++; } //print_r($chars); $char_count = count($chars); $patern1 = ($char_count*($char_count-1)*($char_count-2))/6; //echo $patern1; foreach($chars as $c){ if($c>=2){ $tmp = ($c-1)*((($char_count-1)*($char_count-2))/2); $patern1 += $tmp; } } echo $patern1;
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
// // main.cpp // CompetitiveProgramming // // Created by Yuma Kikuchi on 2018/03/02. // Copyright © 2018年 yumarimo. All rights reserved. // #include <iostream> #include <cmath> #include <cstdio> #include <algorithm> #include <random> #include <string> #include <bitset> #include <map> #include <vector> #include <stack> #include <queue> #include <list> #include <set> #include <cstring> #include <cstdlib> #include <cctype> #define REP(i, n) for(int i = 0; i < n; ++i) #define REPR(i, n) for(int i = n; i >= 0; --i) #define FOR(i, m, n) for(int i = m; i < n; ++i) #define FORR(i, m, n) for(int i = m; i >= n; --i) #define SORT(v, n) sort(v, v + n); #define VSORT(v) sort(v.begin(), v.end()); #define llong long long #define INF 999999999 using namespace std; typedef pair<int, int> P; typedef pair<llong, llong> LP; typedef pair<int, P> PP; typedef pair<llong, LP> LPP; int dy[] = {0, 0, 1, -1, 0}; int dx[] = {1, -1, 0, 0, 0}; llong pow(int x, int n) { llong ans = x; if (n == 0) return 1; for(int i = 0; i < n - 1; i++) { ans *= x; } return ans; } void swap(int *X, int *Y){ int t = *X; *X = *Y; *Y = t; } string toUpper(string s) { string t = s; REP(i, s.size()) { t[i] = toupper(s[i]); } return t; } string toLower(string s) { string t = s; REP(i, s.size()) { t[i] = tolower(s[i]); } return t; } int dp[100001][100001]; long nCr(int n, int r) { if(n==r) return dp[n][r] = 1; if(r==0) return dp[n][r] = 1; if(r==1) return dp[n][r] = n; if(dp[n][r]) return dp[n][r]; return dp[n][r] = nCr(n-1,r) + nCr(n-1,r-1); } int main() { int n; cin >> n; int N[5] = {0}; string name; bool check[5] = {false}; int cnt = 0; REP(i, n) { cin >> name; if (name[0] == 'M') { N[0]++; check[0] = true; cnt++; } else if (name[0] == 'A') { N[1]++; check[1] = true; cnt++; } else if (name[0] == 'R') { N[2]++; check[2] = true; cnt++; } else if (name[0] == 'C') { N[3]++; check[3] = true; cnt++; } else if (name[0] == 'H') { N[4]++; check[4] = true; cnt++; } else { continue; } } int T = 0; REP(i, 5) { if (check[i]) T++; } if (cnt >= 3 && T >= 3) { int tmp = 0; REP(i, 5) { if (N[i] >= 2) tmp += nCr(N[i], 2) * (cnt - N[i]); } cout << nCr(cnt, 3) - tmp << 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; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } 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 lcm(int a, int b) { return a / gcd(a, b) * b; } int main() { int n; int a[5] = {0, 0, 0, 0, 0}; cin >> n; for (int i = 0; i < n; i++) { string s; cin >> s; if (s[0] == 'M') a[0]++; else if (s[0] == 'A') a[1]++; else if (s[0] == 'R') a[2]++; else if (s[0] == 'C') a[3]++; else if (s[0] == 'H') a[4]++; } long long res = 0; for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 4; j++) { for (int k = j + 1; k < 5; k++) { res += a[i] * a[j] * a[k]; } } } cout << res; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; ll INF = 1e+18; int iINF = 1e9; int main() { int N; cin >> N; vector<int> arr(5); for (ll i = (0); (i) < (N); i++) { string tmp; cin >> tmp; char ini = tmp[0]; if (ini == 'M') arr[0] += 1; if (ini == 'A') arr[1] += 1; if (ini == 'R') arr[2] += 1; if (ini == 'C') arr[3] += 1; if (ini == 'H') arr[4] += 1; } int ans = 0; for (ll i = (0); (i) < (5); i++) { for (ll j = (i + 1); (j) < (5); j++) { for (ll k = (j + 1); (k) < (5); k++) { ans += arr[i] * arr[j] * arr[k]; } } } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include <bits/stdc++.h> int main() { long a[5] = {0, 0, 0, 0, 0}; int N; scanf("%d", &N); int k; for (k = 1; k <= N; k++) ; { char s[11]; scanf("%s", s); if (s[0] == 'M') a[0]++; if (s[0] == 'A') a[1]++; if (s[0] == 'R') a[2]++; if (s[0] == 'C') a[3]++; if (s[0] == 'H') a[4]++; } int O = 0; int s, t, r; for (s = 0; s <= 2; s++) { for (t = s + 1; t <= 3; t++) { for (r = t + 1; r <= 4; r++) { O += a[s] * a[t] * a[r]; } } } printf("%d", O); }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int m, a, r, c, h; int main(void) { int N; long long ans; cin >> N; string s[N]; char S[N]; for (int i = 0; i < N; i++) { cin >> S[i]; if (S[i] == 'M') { m++; } if (S[i] == 'A') { a++; } if (S[i] == 'R') { r++; } if (S[i] == 'C') { c++; } if (S[i] == 'H') { h++; } cin >> s[i]; } ans = m * a * r + m * a * c + m * a * h + m * r * c + m * r * h + m * c * h + a * r * c + a * r * h + a * c * h + r * c * h; cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; long long int ans; int main() { int n, f[10], i, g; ans = g = 0; char a[15]; memset(f, 0, sizeof(f)); scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%s", a); if (a[0] == 'A') f[1] += 1; else if (a[0] == 'M') f[2] += 1; else if (a[0] == 'R') f[3] += 1; else if (a[0] == 'H') f[4] += 1; else if (a[0] == 'C') f[5] += 1; } ans = f[1] * f[2] * f[3] + f[1] * f[2] * f[4] + f[1] * f[2] * f[5] + f[2] * f[3] * f[4] + f[2] * f[3] * f[5] + f[1] * f[3] * f[4] + f[1] * f[3] * f[5] + f[1] * f[4] * f[5] + f[2] * f[4] * f[5] + f[3] * f[4] * f[5]; printf("%lld", ans); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ull = unsigned long long; int main() { int n; cin >> n; vector<string> s(100000); set<char> march; march.insert('M'); march.insert('A'); march.insert('R'); march.insert('C'); march.insert('H'); map<char, ull> memo; memo['M'] = 0; memo['A'] = 0; memo['R'] = 0; memo['C'] = 0; memo['H'] = 0; for (int i = 0; i < n; i++) { cin >> s[i]; char init = s[i].at(0); if (march.count(init)) { memo[init]++; } } ull ans = 0; vector<ull> num(5, 0); num[0] = memo['M']; num[1] = memo['A']; num[2] = memo['R']; num[3] = memo['C']; num[4] = memo['H']; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { for (int k = j + 1; k < n; k++) { ans += num[i] * num[j] * num[k]; } } } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; int count[5] = {0, 0, 0, 0, 0}; for (int i = 0; i < n; i++) { cin >> s; switch (s[0]) { case 'M': count[0]++; break; case 'A': count[1]++; break; case 'R': count[2]++; break; case 'C': count[3]++; break; case 'H': count[4]++; break; } } long long ans = 0; for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 4; j++) { for (int k = j + 1; k < 5; k++) { ans += count[i] * count[j] * count[k]; } } } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <iostream> #include <map> #include <string> using namespace std; int main(){ map<int,int> name; map<char,int> name_to_int; name_to_int["M"]=0; name_to_int["A"]=1; name_to_int["R"]=2; name_to_int["C"]=3; name_to_int["H"]=4; int n; cin>>n; for(int i=0;i<n;i++){ string s; name[name_to_int[s[0]]]+=1; } int ans=0; for(int i=0;i<n;i++){ for(int j=i+1;j<n;j++){ for(int k=j+1;k<n;k++){ ans+=name[i]*name[j]*name[k]; } } } cout<<ans<<endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include<iostream> #include<string> #include<algorithm> using namespace std; string s[100000]; int counts[5]; int main() { for (size_t i = 0; i < 5; i++) { counts[i] = 0; } int N; cin >> N; string march = "MARCH"; for (size_t i = 0; i < N; i++) { cin >> s[i]; auto p = march.find(s[i][0]); if (p==string::npos) countinue; counts[p]++; } long long ans = 0; for (size_t i = 0; i < 5; i++) { for (size_t j = i + 1; j < 5; j++) { for (size_t k = j + 1; k < 5; k++) { ans += counts[i] * counts[j] * counts[k]; } } } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
# ABC089C - March from itertools import combinations as comb def main(): N, *S = open(0).read().split() cnt = [sum(s.startswith(i) for S) for i in "MARCH"] ans = sum(x * y * z for x, y, z in comb(cnt, 3)) print(ans) if __name__ == "__main__": main()
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include <bits/stdc++.h> int main(void) { int m, a, r, c, h; int i, n; char name[10]; unsigned long long num = 0; scanf("%d", &n); for (i = 0, m = 0, a = 0, r = 0, c = 0, h = 0; i < n; i++) { scanf("%s", name); switch (name[0]) { case 'M': m++; break; case 'A': a++; break; case 'R': r++; break; case 'C': c++; break; case 'H': h++; break; } } num += m * a * r; num += m * a * c; num += m * a * h; num += m * r * c; num += m * r * h; num += m * c * h; num += a * r * c; num += a * r * h; num += a * c * h; num += r * c * h; printf("%ld", num); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include <stdio.h> int main(){ int n; scanf("%d¥n",&n); int m=0; int r=0; int c=0; int a=0; int h=0; for(int i = 0;i<n;i++){ char str[64]; scanf("%s¥n",&str); if(str[0] == "M"){m++;} if(str[0] == "C"){c++;} if(str[0] == "A"){a++;} if(str[0] == "R"){r++;} if(str[0] == "H"){h++;} } unsigned long ans; ans = (m+c+a+r+h)*(m+c+a+r+h)*(m+c+a+r+h); ans -= (m+c+a+r+h)*3*a*a-2*a*a; ans -= (m+c+a+r+h)*3*m*m-2*m*m; ans -= (m+c+a+r+h)*3*h*h-2*h*h; ans -= (m+c+a+r+h)*3*r*r-2*r*r; ans -= (m+c+a+r+h)*3*c*c-2*c*c; printf("%lu",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, m = 0, a[5] = {0}; string A = "MARCH"; cin >> N; cin.ignore(); string S[N]; for (int i = 0; i < N; i++) { getline(cin, S[i]); for (int j = 0; j < 5; j++) { if (A[j] == S[i][0]) a[j]++; } } long long ans = 0; for (int i = 0; i < 5; i++) for (int j = i + 1; j < 5; j++) for (int k = j + 1; k < 5; k++) ans += a[i] * a[j] * a[k]; cout << ans << "\n"; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> int main(void) { int n; char name[100001][11]; long long int ans = 0; int m, a, r, c, h; m = a = r = c = h = 0; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%s", name[i]); switch (name[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; ans += m * a * c; ans += m * a * h; ans += m * r * c; ans += m * r * h; ans += m * c * h; ans += a * r * c; ans += a * r * h; ans += a * c * h; ans += r * c * h; printf("%lld\n", ans); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include<bits/stdc++.h> using namespace std; #define ll long long int main(){ int n; cin>>n; string s; ll a[n]={}; for(int i=0;i<n;i++){ cin>>s; char c=s.at(0); if(c=='M') a[0]++; else if(c=='A') a[1]++; else if(c=='R') a[2]++; else if(c=='C') a[3]++; else if(c=='H') a[4]++; } ll c=0; for(int i=0;i<3;i++){ for(int j=i+1;j<4;j++){ for(int k=j+1;k<5;k++){ c+=a[i]*a[j]*a[k]; } } } cout<<c; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
import itertools import math n = int(input()) names = [] for _ in range(n): names.append(input()) #名前にmarchが入っている人をカウント march = {"M":0,"A":0,"R":0,"C":0,"H":0} for name in names: if name[0] in march: march[name[0]]+=1 march_num = 0 for count in march.values(): if count > 0: march_num += 1 if march_num >= 3: ans = math.factorial(march_num)//(math.factorial(march_num-3)*math.factorial(3)) for capital , cnt in march.items(): if cnt > 1: ans += math.factorial(march_num-1)//(math.factorial(march_num-3)*math.factorial(2))*(cnt-1) else: ans = 0 print(ans)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> march(5); int m = 0, a = 0, r = 0, c = 0, h = 0; string s; for (int i = 0; i < (n); ++i) { cin >> s; if (s[0] == 'M') m++; if (s[0] == 'A') a++; if (s[0] == 'R') r++; if (s[0] == 'C') c++; if (s[0] == 'H') h++; } march[0] = m, march[1] = a, march[2] = r, march[3] = c, march[4] = h; long long ans = 0; for (int i = 0; i < (2); ++i) { for (int j = int(i + 1); j < int(5); ++j) { for (int k = int(j + 1); k < int(5); ++k) ans += march[i] * march[j] * march[k]; } } cout << ans; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include <bits/stdc++.h> const int mod = (int)1e09 + 7; int in(void) { int i; scanf("%d", &i); return i; } long long llin(void) { long long i; scanf("%lld", &i); return i; } double din(void) { double i; scanf("%lf", &i); return i; } void chin(char s[]) { scanf("%s", s); } void print(int a) { printf("%d\n", a); } void llprint(long long a) { printf("%lld\n", a); } void dprint(double a) { printf("%.10f\n", a); } void print2(int a, int b) { printf("%d %d\n", a, b); } long long max(long long a, long long b) { return a > b ? a : b; } long long min(long long a, long long b) { return a < b ? a : b; } long long llabs(long long a) { return a > 0 ? a : -a; } double dmax(double a, double b) { return a > b ? a : b; } int cmp(const void *a, const void *b) { return *(long long *)a - *(long long *)b; } int cmp_r(const void *a, const void *b) { return *(long long *)b - *(long long *)a; } int char_cmp(const void *a, const void *b) { return strcmp((char *)a, (char *)b); } int char_cmp_r(const void *a, const void *b) { return strcmp((char *)b, (char *)a); } void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; } long long gcd(long long x, long long y) { return x % y ? gcd(y, x % y) : y; } long long lcm(long long x, long long y) { return x / gcd(x, y) * y; } long long fact_mod(long long x) { if (x <= 1) return 1; return x * fact_mod(x - 1) % mod; } int n; long long t[5]; long long m[3]; long long ans; void search(int i, int k) { if (k == 3) { ans += t[m[0]] * t[m[1]] * t[m[2]]; return; } if (i == n) return; search(i + 1, k); m[k] = i; search(i + 1, k + 1); } int main(void) { int i, j; char s[11]; n = in(); for (i = 0; i < n; i++) { chin(s); switch (s[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; } } search(0, 0); llprint(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
python2
#!/usr/bin/env python # -*- coding: utf-8 -*- N = input() for i in range(N): S = raw_input() if S[:1] == "M": m += 1 elif S[:1] == "A": a += 1 elif S[:1] == "R": r += 1 elif S[:1] == "C": c += 1 elif S[:1] == "H": h += 1 print m*a*r+m*a*c+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+m*c*h+a*r*c+a*r*h+a*c*h+r*c*h
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
import java.io.BufferedReader import java.io.InputStreamReader import java.io.PrintWriter import java.util.* import kotlin.math.min val br = BufferedReader(InputStreamReader(System.`in`)) val out = PrintWriter(System.out) fun main() { br.use { out.use { solve() out.flush() } } } fun solve() { val n = readInteger() val march = listOf('M','A','R','C','H') val sArray = Array(n) { br.readLine()!! } .filter { it.first() in march } .groupBy { it.first() } var ans = 0L for (i in march.indices) { for (j in (i + 1) until march.size) { for (k in (j + 1) until march.size) { val a = sArray[march[i]]?.size ?: 0 val b = sArray[march[j]]?.size ?: 0 val c = sArray[march[k]]?.size ?: 0 ans += a * b * c } } } out.println(ans) } fun readInteger() = Integer.parseInt(br.readLine()) fun readLong() = java.lang.Long.parseLong(br.readLine()) fun readStringList() = br.readLine()!!.split(' ') fun readIntegerList() = readStringList().map(Integer::parseInt) fun readLongList() = readStringList().map(java.lang.Long::parseLong) fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\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 march[5] = {}; int main() { int N; cin >> N; vector<string> S; for (int i = 0; i < N; i++) { string tmp; cin >> tmp; S.push_back(tmp); } for (int i = 0; i < N; i++) { if (S[i][0] == 'M') march[0]++; if (S[i][0] == 'A') march[1]++; if (S[i][0] == 'R') march[2]++; if (S[i][0] == 'C') march[3]++; if (S[i][0] == 'H') march[4]++; } long ans = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { ans += march[i] * march[j] * march[k]; } } } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
using System; using System.Linq; using System.Collections.Generic; using System.Text; using static System.Console; using static System.Math; class Program { static void Main(string[] args) { int N = int.Parse(ReadLine()); int[] names = new int[5]; char[] MARCH = new char[5]{ 'M', 'A', 'R', 'C', 'H' }; for(int i = 0; i < N; i++) { string s = ReadLine(); for(int j = 0; j < 5; j++) { if (s[0] == MARCH[j]) names[j]++; } } long ans = 0; for(int i = 0; i < 3; i++) { for(int j = i + 1; j < 4; j++) { for(int k = j + 1; k < 5; k++) { WriteLine($"{i}{j}{k}"); ans += names[i] * names[j] * names[k]; } } } WriteLine(ans); } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> const int limit = 100000; char s[limit][12]; int main() { int n; long int result = 0; int m = 0, a = 0, r = 0, c = 0, h = 0; scanf("%d\n", &n); for (int i = 0; i < n; i++) { scanf("%s", s[i]); switch (s[i][0]) { case 'M': m++; break; case 'A': a++; break; case 'R': r++; break; case 'C': c++; break; case 'H': h++; break; default: break; } } result += m * a * r; result += m * a * c; result += m * a * h; result += m * r * c; result += m * r * h; result += m * c * h; result += a * r * c; result += a * r * h; result += a * c * h; result += c * r * h; printf("%ld\n", result); return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
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[] array = new int[5]; for(int i=0;i<n;i++) { char[] temp = sc.next().toCharArray(); char top = temp[0]; if(top=='M') array[0]++; if(top=='A') array[1]++; if(top=='R') array[2]++; if(top=='C') array[3]++; if(top=='H') array[4]++; } sc.close(); long ans=0; for(int i=0;i<2;i++) { for(int j=i+1;j<3;j++) { for(int k=j+1;k<4;k++) ans += (long)array[i]*array[j]*array[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.util.HashMap; import java.util.Map; import java.util.Scanner; public class Main { public static void main(String[] args) { // TODO 自動生成されたメソッド・スタブ Scanner sc = new Scanner(System.in); long answer = 0; try { //数取得 int N = sc.nextInt(); Map<Character, Integer> marchList = new HashMap<>(); marchList.put('M', 0); marchList.put('A', 0); marchList.put('R', 0); marchList.put('C', 0); marchList.put('H', 0); for(int i = 0; i < N; i++) { String S = sc.next(); char sHead = S.charAt(0); if(marchList.containsKey(sHead)) { int count = marchList.get(sHead); count++; marchList.replace(sHead, count); } } char[] marList = {'M','A','R','C','H'}; for(int a1 = 0; a1 < marList.length-2; a1++) { for(int a2 = a1 + 1; a2 < marList.length -1; a2++) { for(int a3 = a2 + 1; a3 < marList.length; a3++) { answer += (marchList.get(marList[a1]) * marchList.get(marList[a2]) * marchList.get(marList[a3])); } } } }finally { sc.close(); 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; string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } } string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } } int a = 1, b = 0, c, d, n, k = 0, ans = 0; string s, t; int mod = 1000000007; int tosi = 2019; int main() { cin >> n; map<char, int> march; for (int i = 0; i < n; i++) { cin >> s; march[s[0]]++; } long long ans = 0; ans += march['M'] * march['A'] * march['R']; ans += march['M'] * march['A'] * march['C']; ans += march['M'] * march['A'] * march['H']; ans += march['M'] * march['R'] * march['C']; ans += march['M'] * march['R'] * march['H']; ans += march['M'] * march['C'] * march['H']; ans += march['A'] * march['R'] * march['C']; ans += march['A'] * march['R'] * march['H']; ans += march['A'] * march['C'] * march['H']; ans += march['R'] * march['C'] * march['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 ll = long long; using namespace std; const int INF = 1e9; int main() { int N; cin >> N; ll cnt[5] = {0}; string T = "MARCH"; for (int i = 0; i < N; ++i) { string S; cin >> S; for (int i = 0; i < N; ++i) if (S[0] == T[i]) { ++cnt[i]; break; } } ll ans = 0; for (int i = 0; i < N; ++i) { for (int j = i; j < N; ++j) { for (int k = j; k < N; ++k) { if (i == j || j == k) continue; ans += cnt[i] * cnt[j] * cnt[k]; } } } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; using Graph = vector<vector<int>>; const ll mod = 1000000007; const int MAX_N = 1000; double nCk(int n, int k) { double res = 1.0; for (int i = 0; i < n; i++) { res *= 0.5; } for (int i = 0; i < k; i++) { res *= (double)(n - i); res /= (double)(k - i); } return res; } int main() { ll n; cin >> n; ll a[5] = {}; ll counter = 0; ll i = 0; string s; for (ll k = 0; k < n; k++) { cin >> s; if (s.at(k) == 'M') { a[0]++; } else if (s.at(k) == 'A') { a[1]++; } else if (s.at(k) == 'R') { a[2]++; } else if (s.at(k) == 'C') { a[3]++; } else if (s.at(k) == 'H') { a[4]++; } } for (ll i = 0; i < 5; i++) { for (ll n = i + 1; n < 5; n++) { for (ll m = n + 1; m < 5; m++) { counter += a[i] * a[n] * a[m]; } } } cout << counter << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using ll = long long; using namespace std; int main() { int n; cin >> n; vector<int> check(5); for (int i = 0; i < n; i++) { string s; cin >> s; char c = s[0]; if (c == 'M') check[0]++; else if (c == 'A') check[1]++; else if (c == 'R') check[2]++; else if (c == 'C') check[3]++; else if (c == 'H') check[4]++; } ll ans = 0; for (int a = 0; a < 3; a++) { for (int b = a + 1; b < 4; b++) { for (int c = b + 1; c < 5; c++) { ans += check[a] * check[b] * check[c]; } } } cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int MOD = (int)1e9 + 7; const int INF = 999999999; int main() { cin.tie(0); ios::sync_with_stdio(false); int c[5] = {0}; int N; cin >> N; vector<string> A(N); for (int i = 0; i < (N); i++) { cin >> A[i]; if (A[i][0] == 'M') { c[0]++; } if (A[i][0] == 'A') { c[1]++; } if (A[i][0] == 'R') { c[2]++; } if (A[i][0] == 'C') { c[3]++; } if (A[i][0] == 'H') { c[4]++; } } long long S; S = 0; for (int i = 0; i < (3); i++) { for (int j = 0; j < (3 - i); j++) { for (int k = 0; k < (3 - i - j); k++) { S += c[i] * c[i + j + 1] * c[i + j + 1 + k + 1]; } } } cout << S << "\n"; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main(void) { int N; cin >> N; int M0 = 0; int M1 = 0; int M2 = 0; int M3 = 0; int M4 = 0; string S; for (int i = 0; i < N; i++) { cin >> S; if (S.substr(0, 1) == "M") M0++; if (S.substr(0, 1) == "A") M1++; if (S.substr(0, 1) == "R") M2++; if (S.substr(0, 1) == "C") M3++; if (S.substr(0, 1) == "H") M4++; } cout << M0 * M1 * M2 + M0 * M1 * M3 + M0 * M1 * M4 + M0 * M2 * M3 + M0 * M2 * M4 + M0 * M3 * M4 + M1 * M2 * M3 + M1 * M2 * M4 + M2 * M3 * M4 << 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 num1 = 0; int num2 = 0; int num3 = 0; int num4 = 0; int num5 = 0; for (int i = 0; i < n; i++) { string tmp; cin >> tmp; if (tmp[0] == 'M') { num1 += 1; } else if (tmp[0] == 'A') { num2 += 1; } else if (tmp[0] == 'R') { num3 += 1; } else if (tmp[0] == 'C') { num4 += 1; } else if (tmp[0] == 'H') { num5 += 1; } } vector<long long> ans(10); ans[0] = num1 * num2 * num3; ans[1] = num1 * num2 * num4; ans[2] = num1 * num2 * num5; ans[3] = num1 * num3 * num4; ans[4] = num1 * num3 * num5; ans[5] = num1 * num4 * num5; ans[6] = num2 * num3 * num4; ans[7] = num2 * num3 * num5; ans[8] = num2 * num4 * num5; ans[9] = num3 * num4 * num5; long long sum = accumulate(ans.begin(), ans.end(), 0LL); cout << sum << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; unsigned long long n, k, a, wynik, roz; int tab[100]; string b; int main() { scanf("%llu", &n); for (int i = 0; n > i; i++) { cin >> b; tab[b[0]]++; } if (tab[77] > 0) wynik++; if (tab[65] > 0) wynik++; if (tab[82] > 0) wynik++; if (tab[67] > 0) wynik++; if (tab[72] > 0) wynik++; roz = wynik * (wynik - 1) * (wynik - 2) / 6; if (roz < 0) roz = 0; if ((tab[77] > 1 and wynik > 2)) roz += (tab[77] - 1) * (((wynik - 1) * (wynik - 2)) / 2); if ((tab[65] > 1 and wynik > 2)) roz += (tab[65] - 1) * (((wynik - 1) * (wynik - 2)) / 2); if ((tab[82] > 1 and wynik > 2)) roz += (tab[82] - 1) * (((wynik - 1) * (wynik - 2)) / 2); if ((tab[67] > 1 and wynik > 2)) roz += (tab[67] - 1) * (((wynik - 1) * (wynik - 2)) / 2); if ((tab[72] > 1 and wynik > 2)) roz += (tab[72] - 1) * (((wynik - 1) * (wynik - 2)) / 2); cout << roz; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using ll = long long; using namespace std; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } int main() { int n; cin >> n; map<char, int> mp; for (ll 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') mp[s[0]]++; } if (mp.size() < 3) cout << 0; else { ll ans = 0; for (auto x : mp) { for (auto y : mp) { for (auto z : mp) { if (!(x.first == y.first || y.first == z.first || z.first == x.first)) { ans += x.second * y.second * z.second; } } } } cout << ans / 6; } cout << "\n"; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include <bits/stdc++.h> int main() { int n, ini[5] = {}; long int ans1 = 0, ans2 = 0; char name[11]; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%s", name); switch (name[0]) { case 'M': ini[0]++; break; case 'A': ini[1]++; break; case 'R': ini[2]++; break; case 'C': ini[3]++; break; case 'H': ini[4]++; break; default: break; } } for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 4; j++) { for (int k = j + 1; k < 5; k++) { ans2 += ini[i] * ini[j] * ini[k]; if (ans2 > 9999999) { ans1 += ans2 / 10000000; ans2 %= 10000000; } } } } if (ans1) { printf("%lu%07lu", ans1, ans2); } else { printf("%lu", ans2); } return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { string s = "MARCH"; int c[5] = {0, 0, 0, 0, 0}; int N; cin >> N; for (int i = 0; i < N; i++) { string t; cin >> t; for (int j = 0; j < 5; j++) { if (t[0] == s[j]) { c[j]++; } } } int ans = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { ans += c[i] * c[j] * c[k]; } } } cout << ans; 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; template <class A> void pr(A a) { cout << (a) << endl; } template <class A, class B> void pr(A a, B b) { cout << a << " "; pr(b); } template <class A, class B, class C> void pr(A a, B b, C c) { cout << a << " "; pr(b, c); } template <class A, class B, class C, class D> void pr(A a, B b, C c, D d) { cout << a << " "; pr(b, c, d); } template <class T> inline bool chmin(T& a, T b) { return a > b ? a = b, true : false; } template <class T> inline bool chmax(T& a, T b) { return a < b ? a = b, true : false; } vector<long long> inv, fact, invfact; void mod_build(int n = 101010) { fact.resize(n + 1); inv.resize(n + 1); invfact.resize(n + 1); fact[0] = inv[0] = invfact[0] = 1; inv[1] = 1; for (int i = 0; i < int(n); ++i) { fact[i + 1] = fact[i] * (i + 1) % ((long long)(1e9 + 7)); if (i > 0) inv[i + 1] = ((long long)(1e9 + 7)) - inv[((long long)(1e9 + 7)) % (i + 1)] * (((long long)(1e9 + 7)) / (i + 1)) % ((long long)(1e9 + 7)); invfact[i + 1] = invfact[i] * inv[i + 1] % ((long long)(1e9 + 7)); } } long long perm(int n, int k) { if (n < 0 || k < 0 || k > n) return 0; return fact[n] * invfact[n - k] % ((long long)(1e9 + 7)); } long long comb(int n, int k) { if (n < 0 || k < 0 || k > n) return 0; return (fact[n] * invfact[n - k] % ((long long)(1e9 + 7))) * invfact[k] % ((long long)(1e9 + 7)); } int main(void) { int N; cin >> N; map<int, long long> s; for (int i = 0; i < int(N); ++i) { string si; cin >> si; switch (si[0]) { case 'M': s[0]++; break; case 'A': s[1]++; break; case 'R': s[2]++; break; case 'C': s[3]++; break; case 'H': s[4]++; break; } } long long ans = 0; int n = s.size(); if (n < 3) { pr(0); return 0; } vector<long long> v(n); int it = 0; for (auto&& si : s) v[it++] = si.second; for (int i = 0; i < int(1 << n); ++i) { if (__builtin_popcount(i) == 3) { long long t = 1; for (int j = 0; j < int(n); ++j) { if (i & (1 << j)) (t *= v[j]) %= ((long long)(1e9 + 7)); } ans += t; } } pr(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> #define rep(i,n) for(int i=0;i<n;i++) #define FOR(i,start,end) for(int i=start;i<=end;i++) const int INF = 1001001001; typedef long long ll; const ll MOD=1000000007; using namespace std; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); } template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); } template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); } template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); } template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); } template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); } int GCD(int a, int b) { return b ? GCD(b, a%b) : a; } int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; } //--------------------------------------------------------------------------------------------------- template<int MOD> struct ModInt { static const int Mod = MOD; unsigned x; ModInt() : x(0) { } ModInt(signed sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; } ModInt(signed long long sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; } int get() const { return (int)x; } ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; } ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; } ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; } ModInt &operator/=(ModInt that) { return *this *= that.inverse(); } ModInt operator+(ModInt that) const { return ModInt(*this) += that; } ModInt operator-(ModInt that) const { return ModInt(*this) -= that; } ModInt operator*(ModInt that) const { return ModInt(*this) *= that; } ModInt operator/(ModInt that) const { return ModInt(*this) /= that; } ModInt inverse() const { long long a = x, b = MOD, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b; std::swap(a, b); u -= t * v; std::swap(u, v); } return ModInt(u); } bool operator==(ModInt that) const { return x == that.x; } bool operator!=(ModInt that) const { return x != that.x; } ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; } }; template<int MOD> ostream& operator<<(ostream& st, const ModInt<MOD> a) { st << a.get(); return st; }; template<int MOD> ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) { ModInt<MOD> r = 1; while (k) { if (k & 1) r *= a; a *= a; k >>= 1; } return r; } template<typename T, int FAC_MAX> struct Comb { vector<T> fac, ifac; Comb(){fac.resize(FAC_MAX,1);ifac.resize(FAC_MAX,1);FOR(i,1,FAC_MAX-1)fac[i]=fac[i-1]*i; ifac[FAC_MAX-1]=T(1)/fac[FAC_MAX-1];for(int i=FAC_MAX-2;i>=1;i--)ifac[i]=ifac[i+1]*T(i+1);} T aPb(int a, int b) { if (b < 0 || a < b) return T(0); return fac[a] * ifac[a - b]; } T aCb(int a, int b) { if (b < 0 || a < b) return T(0); return fac[a] * ifac[a - b] * ifac[b]; } T nHk(int n, int k) { if (n == 0 && k == 0) return T(1); if (n <= 0 || k < 0) return 0; return aCb(n + k - 1, k); } // nHk = (n+k-1)Ck : n is separator T pairCombination(int n) {if(n%2==1)return T(0);return fac[n]*ifac[n/2]/(T(2)^(n/2));} // combination of paris for n }; typedef ModInt<1000000007> mint; int main(void){ // Your code here! int n;cin >> n; map<char,int> mp; rep(i,n) { string s;cin >> s; mp[s[0]]++; } ll ans = mp['M']*mp['A']*mp['R']; ans += mp['M']*mp['A']*mp['C']; ans += mp['M']*mp['C']*mp['R']; ans += mp['M']*mp['A']*mp['H']; ans += mp['M']*mp['H']*mp['R']; ans += mp['M']*mp['C']*mp['H']; ans += mp['A']*mp['R']*mp['C']; ans += mp['A']*mp['R']*mp['H']; ans += mp['R']*mp['C']*mp['H']; cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; const int E5 = 1e5; void solve() { ll N; cin >> N; char lets[5] = {'M', 'A', 'R', 'C', 'H'}; map<char, ll> mp; for (int i = 0; i < N; ++i) { string s; cin >> s; mp[s[0]]++; } ll ans = 0; for (int mask = 0; mask < (1 << 5); ++mask) { int add = 1; int cnt = 0; for (int i = 0; i < 5; ++i) { if (mask & (1 << i)) { ++cnt; add *= mp[lets[i]]; } } if (cnt == 3) ans += add; } cout << ans << '\n'; } int main() { ios::sync_with_stdio(false); cin.tie(NULL); 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
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; int name[5] = {}; for (int i = 0; i < n; i++) { cin >> s; switch (s[0]) { case 'M': name[0]++; break; case 'A': name[1]++; break; case 'R': name[2]++; break; case 'C': name[3]++; break; case 'H': name[4]++; break; } } long long ans = 0; for (int i = 0; i < 5; i++) { for (int j = i + 1; j < 5; j++) { for (int k = j + 1; k < 5; k++) { ans += name[i] * name[j] * name[k]; } } } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> long long INF = 1e18; const int MOD = 1e9 + 7; using namespace std; int main() { int n; int ar[5] = {}; long long ans = 0; cin >> n; vector<string> vi(n); for (int i = (0); i < (n); ++i) cin >> vi[i]; for (int i = (0); i < (n); ++i) { if (vi[i][0] == 'M') ++ar[0]; else if (vi[i][0] == 'A') ++ar[1]; else if (vi[i][0] == 'R') ++ar[2]; else if (vi[i][0] == 'C') ++ar[3]; else if (vi[i][0] == 'H') ++ar[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 += ar[i] * ar[j] * ar[k]; } } } cout << ans << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int N = 3e4 + 5; long long a[100]; int main() { int n; while (~scanf("%d", &n)) { memset(a, 0, sizeof(a)); string s; for (int i = 0; i < n; i++) { cin >> s; if (s[0] == 'M') a[1]++; else if (s[0] == 'A') a[2]++; else if (s[0] == 'R') a[3]++; else if (s[0] == 'C') a[4]++; else if (s[0] == 'H') a[5]++; } int sum = 0, ans = 0, k = 0; for (int i = 1; i < 6; i++) { if (a[i] == 1) sum++; else if (a[i] != 0) ans++; k += a[i]; if (a[i] >= 2) a[i * 10 + 3] = a[i] * (a[i] - 1) * (a[i] - 2) / 6; a[i * 10 + 2] = a[i] * (a[i] - 1) / 2; } if (ans + sum < 3 || n < 3) printf("0\n"); else { long long cnt = k * (k - 1) * (k - 2) / 6; for (int i = 1; i < 6; i++) { cnt = cnt - a[i * 10 + 3]; cnt -= sum * a[i * 10 + 2]; } for (int i = 1; i < 6; i++) { for (int j = 1; j < 6 && i != j && a[i] != 1 && a[j] != 1; j++) { cnt -= a[i] * a[j * 10 + 2]; } } printf("%lld\n", cnt); } } }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; long long m, a, r, c, h = 0; for (int i = 0; i < n; i++) { cin >> s; if (s[0] == 'M') m++; if (s[0] == 'A') a++; if (s[0] == 'R') r++; if (s[0] == 'C') c++; if (s[0] == 'H') h++; } long long ans = 0; ans = ans + m * a * r; ans = ans + m * a * c; ans = ans + m * a * h; ans = ans + m * r * c; ans = ans + m * r * h; ans = ans + m * c * h; ans = ans + a * r * c; ans = ans + a * c * h; ans = ans + a * r * h; ans = ans + r * c * h; cout << ans << endl; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; set<string> s[5]; int main(void) { int n; cin >> n; string x; int a, b, c, d, e; for (int i = 0; i < n; ++i) { cin >> x; if (x[0] == 'M') { s[0].insert(x); } if (x[0] == 'A') { s[1].insert(x); } if (x[0] == 'R') { s[2].insert(x); } if (x[0] == 'C') { s[3].insert(x); } if (x[0] == 'H') { s[4].insert(x); } } a = s[0].size(); b = s[1].size(); c = s[2].size(); d = s[3].size(); e = s[4].size(); cout << a * b * c + a * b * d + a * b * e + a * c * d + a * c * e + a * d * e + b * c * d + b * c * e + b * d * e + c * d * e << endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> int main() { int n; std::vector<char> s; std::cin >> n; std::string b; std::cin.ignore(); int m[5] = {}; for (int i = 0; i < n; i++) { std::getline(std::cin, b); if (b[0] == 'M') m[0]++; if (b[0] == 'A') m[1]++; if (b[0] == 'R') m[2]++; if (b[0] == 'C') m[3]++; if (b[0] == 'H') m[4]++; } long ans = 0; for (int i = 2; i < 5; i++) { for (int j = 1; j < i; j++) { for (int k = 0; k < j; k++) { ans += m[i] * m[j] * m[k]; } } } std::cout << ans << std::endl; return 0; }
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
p$<.grep(/^[MARCH]/).group_by{|e|e[0]}.map{|k,v|v.size}.combination(3).map{|e|e.inject:*}.sum||0