Submission #845225

#TimeUsernameProblemLanguageResultExecution timeMemory
845225vjudge1Trener (COCI20_trener)C++17
110 / 110
303 ms32252 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define endl "\n" #define all(aa) aa.begin(), aa.end() const int mod=1e9+7; int main(){ int n, k; cin>>n>>k; int ans; map<string, ll> dp, cnt; for(int j=0; j<k; j++){ string s; cin>>s; dp[s]=1; cnt[s]++; } for(int i=1; i<n; i++){ ans=0; for(int j=0; j<k; j++){ string s; cin>>s; cnt[s]++; string a(s.begin(), s.end()-1), b(s.begin()+1, s.end()); if(a==b) dp[s]=dp[a]*cnt[a]%mod; else dp[s]=(dp[a]*cnt[a]%mod+dp[b]*cnt[b]%mod)%mod; ans=(ans+dp[s])%mod; } } cout<<ans<<endl; }

Compilation message (stderr)

trener.cpp: In function 'int main()':
trener.cpp:5:14: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
    5 | #define endl "\n"
      |              ^~~~
trener.cpp:14:6: note: 'ans' was declared here
   14 |  int ans;
      |      ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...