# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
475220 | keta_tsimakuridze | Anagramistica (COCI21_anagramistica) | C++14 | 5 ms | 6476 KiB |
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 f first
#define s second
#define int long long
#define pii pair<int,int>
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7; // !
int t,n,k,dp[N];
map<string,int> cnt;
string s[N];
main(){
cin >> n >> k;
for(int i = 1; i <= n; i++) {
cin >> s[i];
sort(s[i].begin(),s[i].end());
cnt[s[i]]++;
}
dp[0] = 1;
for(int i = 1; i <= n; i++) {
for(int j = k; j >= 0; j--) {
for(int p = 1; p <= min(j,cnt[s[i]]); p++)
dp[j] = (dp[j] + dp[j - p]) % mod;
}
cnt[s[i]] = 0;
}
cout << dp[k];
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |