This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
signed main(){
fastio
int n,k;
cin >> n >> k;
vector<string> v;
for(int i = 0;i < n;i++){
string s;
cin >> s;
sort(s.begin(),s.end());
v.push_back(s);
}
int ans = 0;
for(int i = 0;i < (1<<n);i++){
map<string,int> m;
for(int j = 0;j < n;j++){
if(i&(1<<j)) m[v[j]]++;
}
int tmp = 0;
for(auto [a,b] : m){
tmp += b*(b-1)/2;
}
if(tmp==k) ans++;
}
cout << ans << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |