Submission #845295

#TimeUsernameProblemLanguageResultExecution timeMemory
845295vjudge1Trener (COCI20_trener)C++17
0 / 110
7 ms1880 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...