# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
845295 |
2023-09-06T13:03:37 Z |
vjudge1 |
Trener (COCI20_trener) |
C++17 |
|
7 ms |
1880 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;
vector < string > v[n+1];
map < string , int > mpa;
for(int i = 1;i<=n;i++){
for(int j = 0;j<k;j++){
string bruh;cin >> bruh;
v[i].push_back(bruh);
}
sort(v[i].begin() , v[i].end());
v[i].resize(unique(v[i].begin() , v[i].end()) - v[i].begin());
//cout << i << " : ";for(auto itr : v[i])cout << itr << " ";cout << endl;
}
for(int i = 0;i<(int)v[1].size();i++)mpa[v[1][i]]++;
for(int i = 2;i<=n;i++){
for(int j = 0;j<(int)v[i].size();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[v[i][j]] + mpa[string(v[i][j].begin() , v[i][j].end()-1)]) % mod;
}
else {
mpa[v[i][j]] = (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;
}
//cout << "string : " << v[i][j] << " " << mpa[v[i][j]] << endl;
//cout << "done" << endl;
}
}
int ans = 0;
for(int i = 0;i<(int)v[n].size();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 |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
1880 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |