Submission #223306

#TimeUsernameProblemLanguageResultExecution timeMemory
223306dantoh000Trener (COCI20_trener)C++14
110 / 110
254 ms16120 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int mod = 1000000007; int n,k; map<string,int> ct[55]; string a[55][1505]; int main(){ scanf("%d%d",&n,&k); for (int i = 1; i <= n; i++){ for (int j = 1; j <= k; j++){ cin >> a[i][j]; } } ll ans = 0; ct[0][""]++; for (int i = 1; i <= n; i++){ for (int j = 1; j <= k; j++){ string X = a[i][j].substr(1,a[i][j].size()-1); string Y = a[i][j].substr(0,a[i][j].size()-1); //cout << a[i][j] << " " << X << " " << Y; int res = 0; if (ct[i-1].find(X) != ct[i-1].end()) res += ct[i-1][X]; if (X != Y && ct[i-1].find(Y) != ct[i-1].end()) res += ct[i-1][Y]; res %= mod; //printf("%d %d\n",ct[X],ct[Y]); ct[i][a[i][j]] += res; ct[i][a[i][j]] %= mod; } } for (auto x : ct[n]){ ans += x.second; } printf("%lld",ans%mod); }

Compilation message (stderr)

trener.cpp: In function 'int main()':
trener.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&k);
     ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...