# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1097529 |
2024-10-07T14:36:24 Z |
hiensumi |
Trener (COCI20_trener) |
C++14 |
|
2 ms |
356 KB |
#include <bits/stdc++.h>
using namespace std;
#define fod(i,a,b) for(int i = (int) (a); i <= (int) (b); i++)
#define fok(i,a,b) for(int i = (int) (a); i >= (int) (b); i--)
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define el '\n'
#define ve vector
#define vi ve<int>
#define vll ve<ll>
#define mask(a) (1LL<<(a))
#define BIT(msk,i) (msk>>(i)&1LL)
using namespace std;
template <class T> bool mini(T &a, T b){ return (a > (b)) ? a = (b), 1 : 0; }
template <class T> bool maxi(T &a, T b){ return (a < (b)) ? a = (b), 1 : 0; }
#define name "trener"
const int MOD = 1e9 + 7;
inline void madd(int &a, int b){
a += b;
if(a >= MOD) a -= MOD;
else if(a < 0) a += MOD;
}
int n, k;
unordered_map <string, int> dp;
int main(){
ios_base::sync_with_stdio(false); cin.tie(0);
#ifndef ONLINE_JUDGE
freopen(name".inp", "r", stdin);
// freopen(name".out", "w", stdout);
#endif // ONLINE_JUDGE
cin >> n >> k;
string s;
fod(i,1,k){
cin >> s;
dp[s]++;
}
fod(i,2,n){
unordered_map <string, int> new_dp;
fod(j,1,k){
string s; cin >> s;
new_dp[s]++;
}
unordered_map <string, int> cnt = new_dp;
for(auto &x : new_dp){
x.se = 0;
for(auto y : dp) if(x.fi.find(y.fi) != string::npos){
madd(x.se, 1LL * cnt[x.fi] * y.se % MOD);
}
}
swap(dp, new_dp);
}
int res = 0;
for(auto &x : dp) madd(res, x.se);
cout << res;
return 0;
}
Compilation message
trener.cpp: In function 'int main()':
trener.cpp:37:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
37 | freopen(name".inp", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
356 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |