답안 #116842

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
116842 2019-06-14T02:33:56 Z nhimnam120 Lozinke (COCI17_lozinke) C++14
0 / 100
1000 ms 4344 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(){
	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)/2);
		while(inpp[pos].fi<inpp[i].fi){
			string b=inpp[pos].se;
			for(int k=0;k<inpp[i].fi-inpp[pos].fi+1;k++){
				if(a[k]==b[0]){
					long long test=0;
					for(int j=0;j<inpp[pos].fi;j++){
						if(a[k+j]!=b[j]){
							test=1;
							break;
						}
					}
					if(test==0){
						ans=ans+cnt[a]*cnt[b];
						break;
					}
				}
			}
			pos++;
		}
	}
	cout << ans;
}

Compilation message

lozinke.cpp: In function 'int main()':
lozinke.cpp:22:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<inpp.size();i++){
              ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Incorrect 2 ms 384 KB Output isn't correct
3 Incorrect 5 ms 384 KB Output isn't correct
4 Incorrect 3 ms 384 KB Output isn't correct
5 Incorrect 12 ms 640 KB Output isn't correct
6 Incorrect 20 ms 640 KB Output isn't correct
7 Incorrect 31 ms 768 KB Output isn't correct
8 Incorrect 17 ms 640 KB Output isn't correct
9 Incorrect 304 ms 1760 KB Output isn't correct
10 Incorrect 281 ms 1888 KB Output isn't correct
11 Incorrect 704 ms 2620 KB Output isn't correct
12 Incorrect 557 ms 2740 KB Output isn't correct
13 Execution timed out 1065 ms 3124 KB Time limit exceeded
14 Execution timed out 1067 ms 4344 KB Time limit exceeded
15 Execution timed out 1064 ms 3380 KB Time limit exceeded
16 Incorrect 29 ms 760 KB Output isn't correct
17 Incorrect 10 ms 256 KB Output isn't correct
18 Incorrect 9 ms 256 KB Output isn't correct
19 Execution timed out 1066 ms 2996 KB Time limit exceeded
20 Incorrect 50 ms 768 KB Output isn't correct