Submission #116871

# Submission time Handle Problem Language Result Execution time Memory
116871 2019-06-14T03:06:28 Z MrUnknown Lozinke (COCI17_lozinke) C++11
10 / 100
15 ms 1792 KB
//#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
//#define f_(i,a,b) for (int i=a;i>=b;i--)
//#define f(i,a,b) for (int i=a;i<=b;i++)
 
int n;
string s[20005];
long long dem=0;
map<string,bool> mb;
map<string,ll> m;
bool cmp(string x,string y) {
  return (x.size()<=y.size()) ;
}
int main() {
//	freopen("","r",stdin);
//	freopen("","w",stdout);
	scanf("%d", &n);
	for (int i=1;i<=n;i++) {
		cin>>s[i];
	}
	sort(s+1,s+1+n,cmp);
	for (int i=1;i<=n;i++) {
		mb.clear();
		for (int j=0;j<s[i].size();j++) {
			string si;
			for (int l=j;l<s[i].size();l++) {
				si=si+s[i][l];
				if (!mb[si]) {
					mb[si]=true;
					dem+=m[si];
				}
			}
		}
		dem+=m[s[i]];
		m[s[i]]++;
	}
	printf("%lld", dem);
	return 0;
}

Compilation message

lozinke.cpp: In function 'int main()':
lozinke.cpp:26:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int j=0;j<s[i].size();j++) {
                ~^~~~~~~~~~~~
lozinke.cpp:28:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for (int l=j;l<s[i].size();l++) {
                 ~^~~~~~~~~~~~
lozinke.cpp:19:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1024 KB Output is correct
2 Runtime error 5 ms 1792 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Correct 3 ms 1024 KB Output is correct
4 Runtime error 4 ms 1664 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 5 ms 1792 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 6 ms 1792 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 7 ms 1792 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 7 ms 1664 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 7 ms 1708 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 7 ms 1664 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 8 ms 1708 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 13 ms 1664 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 11 ms 1664 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 10 ms 1664 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 12 ms 1764 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 11 ms 1664 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 15 ms 1664 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 12 ms 1664 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Runtime error 10 ms 1624 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Runtime error 11 ms 1664 KB Execution killed with signal 11 (could be triggered by violating memory limits)