답안 #116873

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
116873 2019-06-14T03:11:20 Z MrUnknown Lozinke (COCI17_lozinke) C++11
100 / 100
544 ms 16728 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);
  ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 896 KB Output is correct
2 Correct 3 ms 896 KB Output is correct
3 Correct 3 ms 1024 KB Output is correct
4 Correct 4 ms 1152 KB Output is correct
5 Correct 12 ms 1280 KB Output is correct
6 Correct 19 ms 1256 KB Output is correct
7 Correct 24 ms 2048 KB Output is correct
8 Correct 49 ms 2836 KB Output is correct
9 Correct 93 ms 2724 KB Output is correct
10 Correct 212 ms 7800 KB Output is correct
11 Correct 154 ms 4472 KB Output is correct
12 Correct 535 ms 16728 KB Output is correct
13 Correct 320 ms 2808 KB Output is correct
14 Correct 330 ms 14968 KB Output is correct
15 Correct 544 ms 16560 KB Output is correct
16 Correct 324 ms 1144 KB Output is correct
17 Correct 88 ms 896 KB Output is correct
18 Correct 65 ms 988 KB Output is correct
19 Correct 317 ms 8632 KB Output is correct
20 Correct 142 ms 1016 KB Output is correct