Submission #557873

# Submission time Handle Problem Language Result Execution time Memory
557873 2022-05-06T08:11:07 Z FatihSolak W (RMI18_w) C++17
20 / 100
252 ms 21236 KB
#include <bits/stdc++.h>
#define N 300005
using namespace std;
const int mod = 1e9 + 7;
long long fact[N];
long long ifact[N];
long long binpow(long long a,long long b){
	long long ret = 1;
	while(b){
		if(b & 1)
			ret = ret*a%mod;
		a = a*a%mod;
		b >>= 1;
	}
	return ret;
}
long long C(int n,int r){
	return fact[n] * ifact[r]%mod*ifact[n-r]%mod;
}
void solve(){
	int n;
	cin >> n;
	map<int,int> cnt;
	for(int i = 1;i<=n;i++){
		int x;
		cin >> x;
		cnt[x]++;
	}
	vector<int> v;
	for(auto u:cnt)
		v.push_back(u.second);
	if(v[0] < 2 || v[1] < 3){
		cout << 0;
		return;
	}
	cout << C(v[0]-2+1,1) *C(v[1]-3+2,2) %mod;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	#ifdef Local
		freopen("in.txt","r",stdin);
		freopen("out.txt","w",stdout);
	#endif
	fact[0] = ifact[0]= 1;
	for(int i = 1;i<N;i++){
		fact[i] = fact[i-1] * i %mod;
		ifact[i] = binpow(fact[i],mod-2);
	}
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	#ifdef Local
		cout << endl << fixed << setprecision(2) << 1000.0*clock()/CLOCKS_PER_SEC << " milliseconds.";
	#endif
}
# Verdict Execution time Memory Grader output
1 Correct 44 ms 4948 KB Output is correct
2 Correct 43 ms 4888 KB Output is correct
3 Correct 48 ms 4940 KB Output is correct
4 Correct 61 ms 5000 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 44 ms 4892 KB Output isn't correct
2 Incorrect 45 ms 4968 KB Output isn't correct
3 Incorrect 67 ms 6568 KB Output isn't correct
4 Incorrect 100 ms 10320 KB Output isn't correct
5 Incorrect 153 ms 15552 KB Output isn't correct
6 Incorrect 252 ms 21236 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 44 ms 4940 KB Output isn't correct
2 Incorrect 44 ms 4988 KB Output isn't correct
3 Incorrect 43 ms 4992 KB Output isn't correct
4 Incorrect 44 ms 4944 KB Output isn't correct
5 Incorrect 44 ms 4908 KB Output isn't correct
6 Incorrect 44 ms 5244 KB Output isn't correct
7 Incorrect 46 ms 5192 KB Output isn't correct
8 Incorrect 61 ms 4996 KB Output isn't correct
9 Incorrect 77 ms 5020 KB Output isn't correct
10 Incorrect 240 ms 20876 KB Output isn't correct