Submission #116868

# Submission time Handle Problem Language Result Execution time Memory
116868 2019-06-14T03:03:56 Z MrUnknown Lozinke (COCI17_lozinke) C++11
Compilation error
0 ms 0 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(int x,int y) {
  return (s[x].size()<=s[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++) {
                 ~^~~~~~~~~~~~
In file included from /usr/include/c++/7/bits/stl_algobase.h:71:0,
                 from /usr/include/c++/7/bits/char_traits.h:39,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from lozinke.cpp:2:
/usr/include/c++/7/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_comp_iter<_Compare>::operator()(_Iterator1, _Iterator2) [with _Iterator1 = std::__cxx11::basic_string<char>*; _Iterator2 = std::__cxx11::basic_string<char>*; _Compare = bool (*)(int, int)]':
/usr/include/c++/7/bits/stl_algo.h:1847:14:   required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = std::__cxx11::basic_string<char>*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(int, int)>]'
/usr/include/c++/7/bits/stl_algo.h:1885:25:   required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = std::__cxx11::basic_string<char>*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(int, int)>]'
/usr/include/c++/7/bits/stl_algo.h:1971:31:   required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = std::__cxx11::basic_string<char>*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(int, int)>]'
/usr/include/c++/7/bits/stl_algo.h:4868:18:   required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = std::__cxx11::basic_string<char>*; _Compare = bool (*)(int, int)]'
lozinke.cpp:23:20:   required from here
/usr/include/c++/7/bits/predefined_ops.h:143:18: error: cannot convert 'std::__cxx11::basic_string<char>' to 'int' in argument passing
         { return bool(_M_comp(*__it1, *__it2)); }
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/7/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Val_comp_iter<_Compare>::operator()(_Value&, _Iterator) [with _Value = std::__cxx11::basic_string<char>; _Iterator = std::__cxx11::basic_string<char>*; _Compare = bool (*)(int, int)]':
/usr/include/c++/7/bits/stl_algo.h:1828:20:   required from 'void std::__unguarded_linear_insert(_RandomAccessIterator, _Compare) [with _RandomAccessIterator = std::__cxx11::basic_string<char>*; _Compare = __gnu_cxx::__ops::_Val_comp_iter<bool (*)(int, int)>]'
/usr/include/c++/7/bits/stl_algo.h:1855:36:   required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = std::__cxx11::basic_string<char>*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(int, int)>]'
/usr/include/c++/7/bits/stl_algo.h:1885:25:   required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = std::__cxx11::basic_string<char>*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(int, int)>]'
/usr/include/c++/7/bits/stl_algo.h:1971:31:   required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = std::__cxx11::basic_string<char>*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(int, int)>]'
/usr/include/c++/7/bits/stl_algo.h:4868:18:   required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = std::__cxx11::basic_string<char>*; _Compare = bool (*)(int, int)]'
lozinke.cpp:23:20:   required from here
/usr/include/c++/7/bits/predefined_ops.h:215:11: error: cannot convert 'std::__cxx11::basic_string<char>' to 'int' in argument passing
  { return bool(_M_comp(__val, *__it)); }
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/7/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_comp_val<_Compare>::operator()(_Iterator, _Value&) [with _Iterator = std::__cxx11::basic_string<char>*; _Value = std::__cxx11::basic_string<char>; _Compare = bool (*)(int, int)]':
/usr/include/c++/7/bits/stl_heap.h:133:48:   required from 'void std::__push_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare&) [with _RandomAccessIterator = std::__cxx11::basic_string<char>*; _Distance = long int; _Tp = std::__cxx11::basic_string<char>; _Compare = __gnu_cxx::__ops::_Iter_comp_val<bool (*)(int, int)>]'
/usr/include/c++/7/bits/stl_heap.h:237:23:   required from 'void std::__adjust_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare) [with _RandomAccessIterator = std::__cxx11::basic_string<char>*; _Distance = long int; _Tp = std::__cxx11::basic_string<char>; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(int, int)>]'
/usr/include/c++/7/bits/stl_heap.h:342:22:   required from 'void std::__make_heap(_RandomAccessIterator, _RandomAccessIterator, _Compare&) [with _RandomAccessIterator = std::__cxx11::basic_string<char>*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(int, int)>]'
/usr/include/c++/7/bits/stl_algo.h:1672:23:   required from 'void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = std::__cxx11::basic_string<char>*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(int, int)>]'
/usr/include/c++/7/bits/stl_algo.h:1933:25:   required from 'void std::__partial_sort(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = std::__cxx11::basic_string<char>*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(int, int)>]'
/usr/include/c++/7/bits/stl_algo.h:1948:27:   required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = std::__cxx11::basic_string<char>*; _Size = long int; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(int, int)>]'
/usr/include/c++/7/bits/stl_algo.h:1968:25:   required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = std::__cxx11::basic_string<char>*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(int, int)>]'
/usr/include/c++/7/bits/stl_algo.h:4868:18:   required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = std::__cxx11::basic_string<char>*; _Compare = bool (*)(int, int)]'
lozinke.cpp:23:20:   required from here
/usr/include/c++/7/bits/predefined_ops.h:177:11: error: cannot convert 'std::__cxx11::basic_string<char>' to 'int' in argument passing
  { return bool(_M_comp(*__it, __val)); }
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~
lozinke.cpp:19:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~