Submission #80253

# Submission time Handle Problem Language Result Execution time Memory
80253 2018-10-19T16:51:01 Z MatheusLealV Lozinke (COCI17_lozinke) C++17
100 / 100
632 ms 15788 KB
#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

lozinke.cpp: In function 'int main()':
lozinke.cpp:32:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0; i < s.size(); i++)
                  ~~^~~~~~~~~~
lozinke.cpp:36:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int j = i; j < s.size(); j++)
                   ~~^~~~~~~~~~
lozinke.cpp:57:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0; i < s.size(); i++)
                  ~~^~~~~~~~~~
lozinke.cpp:61:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int j = i; j < s.size(); j++)
                   ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1016 KB Output is correct
2 Correct 3 ms 1016 KB Output is correct
3 Correct 4 ms 1048 KB Output is correct
4 Correct 4 ms 1124 KB Output is correct
5 Correct 15 ms 1380 KB Output is correct
6 Correct 22 ms 1384 KB Output is correct
7 Correct 32 ms 2276 KB Output is correct
8 Correct 44 ms 2980 KB Output is correct
9 Correct 116 ms 2980 KB Output is correct
10 Correct 276 ms 7800 KB Output is correct
11 Correct 203 ms 7800 KB Output is correct
12 Correct 617 ms 15788 KB Output is correct
13 Correct 367 ms 15788 KB Output is correct
14 Correct 423 ms 15788 KB Output is correct
15 Correct 632 ms 15788 KB Output is correct
16 Correct 374 ms 15788 KB Output is correct
17 Correct 160 ms 15788 KB Output is correct
18 Correct 113 ms 15788 KB Output is correct
19 Correct 397 ms 15788 KB Output is correct
20 Correct 221 ms 15788 KB Output is correct