Submission #116859

# Submission time Handle Problem Language Result Execution time Memory
116859 2019-06-14T02:55:27 Z nhimnam120 Lozinke (COCI17_lozinke) C++14
25 / 100
379 ms 17392 KB
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
map<string, long long> cnt;
vector<pair<long long,string> > inpp;
set<string> inp;
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	long long n;
	cin >> n;
	for(int i=0;i<n;i++){
		string a;
		cin >> a;
		cnt[a]++;
		inp.insert(a);
	}
	long long ans=0;
	for(auto x: inp){
		inpp.push_back({x.size(),x});
	}
	sort(inpp.begin(),inpp.end());
	for(int i=0;i<inpp.size();i++){
		long long pos=0;
		string a=inpp[i].se;
		ans=ans+(cnt[a]*(cnt[a]-1));
		string c;
		for(int j=1;j<inpp[i].fi;j++){
			for(int k=0;k<inpp[i].fi-j+1;k++){
				c=a.substr(k,j);
				ans=ans+cnt[a]*cnt[c];
			}
		}
	}
	cout << ans;
}

Compilation message

lozinke.cpp: In function 'int main()':
lozinke.cpp:24:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<inpp.size();i++){
              ~^~~~~~~~~~~~
lozinke.cpp:25:13: warning: unused variable 'pos' [-Wunused-variable]
   long long pos=0;
             ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Incorrect 2 ms 384 KB Output isn't correct
3 Incorrect 3 ms 384 KB Output isn't correct
4 Incorrect 2 ms 384 KB Output isn't correct
5 Incorrect 10 ms 768 KB Output isn't correct
6 Incorrect 14 ms 896 KB Output isn't correct
7 Incorrect 22 ms 1656 KB Output isn't correct
8 Correct 26 ms 2424 KB Output is correct
9 Incorrect 98 ms 2868 KB Output isn't correct
10 Correct 148 ms 7988 KB Output is correct
11 Incorrect 140 ms 4976 KB Output isn't correct
12 Correct 357 ms 17260 KB Output is correct
13 Incorrect 222 ms 3568 KB Output isn't correct
14 Incorrect 372 ms 16232 KB Output isn't correct
15 Correct 379 ms 17392 KB Output is correct
16 Incorrect 31 ms 768 KB Output isn't correct
17 Correct 4 ms 384 KB Output is correct
18 Incorrect 4 ms 384 KB Output isn't correct
19 Incorrect 242 ms 9404 KB Output isn't correct
20 Incorrect 37 ms 768 KB Output isn't correct