| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 80253 | MatheusLealV | Lozinke (COCI17_lozinke) | C++17 | 632 ms | 15788 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define N 20050
using namespace std;
typedef long long ll;
int n;
ll ans;
unordered_map<string, int> mapa;
string v[N];
int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	cin>>n;
	for(int t = 1; t <= n; t++)
	{
		string s;
		unordered_set<string> ss;
		cin>>s;
    v[t] = s;
		ans += (ll)mapa[s];
		for(int i = 0; i < s.size(); i++)
		{
			string aux;
			for(int j = i; j < s.size(); j++)
			{
				aux.push_back(s[j]);
				ss.insert(aux);
			}
		}
		for(auto x: ss) mapa[x] ++;
	}
  mapa.clear();
  for(int t = n; t >= 1; t--)
	{
		string s = v[t];
		unordered_set<string> ss;
		ans += (ll)mapa[s];
		for(int i = 0; i < s.size(); i++)
		{
			string aux;
			for(int j = i; j < s.size(); j++)
			{
				aux.push_back(s[j]);
				ss.insert(aux);
			}
		}
		for(auto x: ss) mapa[x] ++;
	}
	cout<<ans<<"\n";
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
