Submission #74551

# Submission time Handle Problem Language Result Execution time Memory
74551 2018-09-03T12:43:20 Z ZZangZZang Lozinke (COCI17_lozinke) C++17
100 / 100
682 ms 17172 KB
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <functional>
#include <string>
#include <set>
#include <map>
 
typedef long long ll;
using namespace std;
 
ll n, sol = 0;
string s[20001];
map<string, ll> ms;
 
int main()
{
	scanf("%lld", &n);
	for(ll i=0; i<n; i++)
	{
		char str[20]; scanf("%s", str);
		s[i] = string(str);
        if(ms.find(s[i]) == ms.end()) ms.insert(make_pair(s[i], 1));
        else ms[s[i]]++;
	}
	for(ll k=0; k<n; k++)
	{
		set<string> l;
		vector<string> v;
		for(ll i=0; i<s[k].size(); i++)
		{
			string tmp;
			for(ll j=i; j<s[k].size(); j++)
			{
				tmp += s[k][j];
				if(l.find(tmp) == l.end()) l.insert(tmp), v.push_back(tmp);
			}
		}
		for(ll i=0; i<v.size(); i++)
		{
			if(v[i] == s[k]) sol += (ll)(ms[v[i]] - 1);
			else sol += (ll)(ms[v[i]]);
		}
	}
	printf("%lld", sol);
	return 0;
}

Compilation message

lozinke.cpp: In function 'int main()':
lozinke.cpp:32:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(ll i=0; i<s[k].size(); i++)
               ~^~~~~~~~~~~~
lozinke.cpp:35:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(ll j=i; j<s[k].size(); j++)
                ~^~~~~~~~~~~~
lozinke.cpp:41:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(ll i=0; i<v.size(); i++)
               ~^~~~~~~~~
lozinke.cpp:20:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld", &n);
  ~~~~~^~~~~~~~~~~~
lozinke.cpp:23:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   char str[20]; scanf("%s", str);
                 ~~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 888 KB Output is correct
2 Correct 3 ms 1016 KB Output is correct
3 Correct 3 ms 1192 KB Output is correct
4 Correct 5 ms 1192 KB Output is correct
5 Correct 17 ms 1520 KB Output is correct
6 Correct 27 ms 1520 KB Output is correct
7 Correct 35 ms 2168 KB Output is correct
8 Correct 55 ms 3160 KB Output is correct
9 Correct 144 ms 3160 KB Output is correct
10 Correct 306 ms 8224 KB Output is correct
11 Correct 239 ms 8224 KB Output is correct
12 Correct 657 ms 17172 KB Output is correct
13 Correct 442 ms 17172 KB Output is correct
14 Correct 544 ms 17172 KB Output is correct
15 Correct 682 ms 17172 KB Output is correct
16 Correct 410 ms 17172 KB Output is correct
17 Correct 72 ms 17172 KB Output is correct
18 Correct 54 ms 17172 KB Output is correct
19 Correct 459 ms 17172 KB Output is correct
20 Correct 219 ms 17172 KB Output is correct