Submission #223290

#TimeUsernameProblemLanguageResultExecution timeMemory
223290dantoh000Trener (COCI20_trener)C++14
22 / 110
16 ms3200 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int mod = 1000000007; int n,k; unordered_map<string,int> ct[2]; 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); string Y = a[i][j].substr(0,a[i][j].size()-1); //cout << a[i][j] << " " << X << " " << Y; int res = ct[1-i&1][X]; if (X != Y) res += ct[1-i&1][Y]; //printf("%d %d\n",ct[X],ct[Y]); ct[i&1][a[i][j]] += res; ct[i&1][a[i][j]] %= mod; if (i == n) ans += res; } ct[1-i&1].clear(); } printf("%d",ans%mod); }

Compilation message (stderr)

trener.cpp: In function 'int main()':
trener.cpp:22:27: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
             int res = ct[1-i&1][X];
                          ~^~
trener.cpp:23:36: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
             if (X != Y) res += ct[1-i&1][Y];
                                   ~^~
trener.cpp:29:13: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
         ct[1-i&1].clear();
            ~^~
trener.cpp:31:24: warning: format '%d' expects argument of type 'int', but argument 2 has type 'll {aka long long int}' [-Wformat=]
     printf("%d",ans%mod);
                 ~~~~~~~^
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...