Submission #217478

#TimeUsernameProblemLanguageResultExecution timeMemory
217478papaTrener (COCI20_trener)C++14
110 / 110
114 ms20284 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; //au majko sta odradi ova unordered mapa //ekstra bas lep zadatak - uradjen // :)))) int n; int k; ll sol; ll mod; vector<int> spusta[100005]; ll dp[100005]; vector<string> b[55]; unordered_map<string,ll> mp; set<string> vec; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cerr.tie(0); cin >> n >> k; mod = (ll)(1e9)+7; sol = 0; for(int i=1;i<=n;i++) { for(int qq=1;qq<=k;qq++) { string s; cin >> s; if(s.size()==1) mp[s]++; else { string s1 = s.substr(0,i-1); string s2 = s.substr(1,i-1); if(s1!=s2) mp[s] = ((mp[s] + mp[s.substr(0,i-1)])%mod + mp[s.substr(1,i-1)])%mod; else mp[s] = (mp[s] + mp[s1])%mod; if(i==n) vec.insert(s); } } } for(string ss : vec) sol = (sol+mp[ss])%mod; cout << sol; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...