# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
845255 |
2023-09-06T12:51:00 Z |
vjudge1 |
Trener (COCI20_trener) |
C++17 |
|
6 ms |
1852 KB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mod = 1e9 + 7;
void solve(){
int n,k;cin >> n >> k;
string v[n+1][k];
map < string , int > mpa;
for(int i = 1;i<=n;i++){
for(int j = 0;j<k;j++){
cin >> v[i][j];
}
}
for(int i = 0;i<k;i++)mpa[v[1][i]]++;
for(int i = 2;i<=n;i++){
for(int j = 0;j<k;j++){
if(string(v[i][j].begin() , v[i][j].end()-1) == string(v[i][j].begin()+1 , v[i][j].end()))(mpa[v[i][j]] += mpa[string(v[i][j].begin() , v[i][j].end()-1)] % mod) %= mod;
else (mpa[v[i][j]] += (mpa[string(v[i][j].begin() , v[i][j].end()-1)] + mpa[string(v[i][j].begin()+1 , v[i][j].end())]) % mod) %= mod;
}
}
int ans = 0;
for(int i = 0;i<k;i++)ans = (ans + mpa[v[n][i]]) % mod;
cout << ans << endl ;
}
signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);
int testcase = 1;//cin >> testcase;
while(testcase--)solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
1852 KB |
Output is correct |
2 |
Correct |
5 ms |
1628 KB |
Output is correct |
3 |
Correct |
6 ms |
1660 KB |
Output is correct |
4 |
Incorrect |
1 ms |
604 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |