Submission #845252

#TimeUsernameProblemLanguageResultExecution timeMemory
845252vjudge1Trener (COCI20_trener)C++17
22 / 110
6 ms1628 KiB
#pragma GCC optimize("unroll-loops,Ofast,O3") #include <bits/stdc++.h> #define pb push_back #define mp make_pair #define spc << " " << #define all(x) x.begin(), x.end() #define ll long long #define int long long #define ii pair<int,int> #define vi vector<int> #define vii vector<ii> #define st first #define nd second #define inf 1000000009 #define MOD 1000000007 using namespace std; void solve(){ int n,k; cin >> n >> k; string arr[n+1][k+1]; for(int i=1; i<=n; i++){ for(int j=1; j<=k; j++) cin >> arr[i][j]; } map<string, int> see; for(int L=n; L>=2; L--){ for(int i=1; i<=k; i++){ string s=arr[L][i]; if(L==n) see[s]=1; see[s.substr(0, L-1)]+=see[s]; if(s.substr(0, L-1) != s.substr(1, L-1))see[s.substr(1, L-1)]+=see[s]; //cerr << s spc "to" spc s.substr(0, L-1) spc s.substr(1, L-1) spc see[s] << endl; } } int ans=0; for(int i=1; i<=k; i++){ //cerr << arr[1][i] spc see[arr[1][i]] << endl; ans+=see[arr[1][i]]; } cout << ans << endl; } signed main(){ ios_base::sync_with_stdio(false);cin.tie(0); #ifdef Local freopen("in.txt","r",stdin); freopen("out","w",stdout); #endif ll t=1; //cin >> t; while(t--) solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...