Submission #116848

# Submission time Handle Problem Language Result Execution time Memory
116848 2019-06-14T02:39:15 Z nhimnam120 Lozinke (COCI17_lozinke) C++14
0 / 100
4 ms 640 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;
		scanf("%s", &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));
		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:13:17: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'std::__cxx11::string* {aka std::__cxx11::basic_string<char>*}' [-Wformat=]
   scanf("%s", &a);
               ~~^
lozinke.cpp:22:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<inpp.size();i++){
              ~^~~~~~~~~~~~
lozinke.cpp:13:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%s", &a);
   ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 2 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 2 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 0 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 2 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 2 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 4 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 2 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 2 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 2 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 2 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 2 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 3 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 4 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 2 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 2 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 2 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 2 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Runtime error 2 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Runtime error 2 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)