# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
845252 |
2023-09-06T12:49:47 Z |
vjudge1 |
Trener (COCI20_trener) |
C++17 |
|
6 ms |
1628 KB |
#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 time |
Memory |
Grader output |
1 |
Correct |
0 ms |
600 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
1628 KB |
Output is correct |
2 |
Correct |
6 ms |
1628 KB |
Output is correct |
3 |
Correct |
6 ms |
1628 KB |
Output is correct |
4 |
Incorrect |
1 ms |
604 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
600 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
6 ms |
1628 KB |
Output is correct |
6 |
Correct |
6 ms |
1628 KB |
Output is correct |
7 |
Correct |
6 ms |
1628 KB |
Output is correct |
8 |
Incorrect |
1 ms |
604 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |