Submission #370642

#TimeUsernameProblemLanguageResultExecution timeMemory
370642FatihSolakRima (COCI17_rima)C++17
56 / 140
1087 ms71460 KiB
#include <bits/stdc++.h> #define N 500005 using namespace std; string s[N]; map<string,int> mp; map<string,int> mp2; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); int n; cin >> n; for(int i=0;i<n;i++){ cin >> s[i]; string t = s[i]; reverse(t.begin(), t.end()); mp[t]++; t.pop_back(); mp2[t]++; } int ans = 0; for(int i=0;i<n;i++){ string c = s[i]; reverse(c.begin(), c.end()); string t = c; c.pop_back(); int sum = 0; while(t.size()){ sum += mp2[c]; c.pop_back(); t.pop_back(); if(!mp[t]){ break; } } ans = max(ans,sum); } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...