QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#735735#9482. Count Pseudo-PalindromeszqsCompile Error//C++14984b2024-11-11 21:29:352024-11-11 21:29:36

Judging History

This is the latest submission verdict.

  • [2024-11-11 21:29:36]
  • Judged
  • [2024-11-11 21:29:35]
  • Submitted

answer

#include <cstdio>
#include <random>
#include <set>
#include <unordered_map>
#include <algorithm>
#include <cstring>

typedef unsigned long long ull;
std::mt19937_64 rnd(19410622);
std::unordered_map<ull, int> tab;
std::set<int> s;
int a[1000005], lst[500005], n;
ull hsh[1000005], ans1[1000005], ans2[1000005], b[1000005];
void solve(ull *ans) {
	s.clear(), tab.clear(), tab.insert(0), memset(lst, 0, sizeof lst);
	for (int i = 1; i <= n + n; ++ i) {//r=i;
		hsh[i] = hsh[i - 1] ^ b[a[i]];
		if (lst[a[i]]) s.erase(lst[a[i]]); else s.insert(i), lst[a[i]] = i;
		if (s.size()) {
			int x = *-- s.end();
			ans[x] += tab[hsh[i] ^ b[a[x]]];
		}
		++ tab[hsh[i]];
	}
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++ i) b[i] = rnd();
	for (int i = 1; i <= n + n; ++ i) scanf("%d", a + i);
	solve(ans1), std::reverse(a + 1, a + n + 1), solve(ans2);
	for (int i = 1; i <= n + n; ++ i) printf("%llu ", ans1[i] + ans2[n + n + 1 - i]);
	return 0;
}

详细

answer.code: In function ‘void solve(ull*)’:
answer.code:15:43: error: no matching function for call to ‘std::unordered_map<long long unsigned int, int>::insert(int)’
   15 |         s.clear(), tab.clear(), tab.insert(0), memset(lst, 0, sizeof lst);
      |                                 ~~~~~~~~~~^~~
In file included from /usr/include/c++/13/unordered_map:41,
                 from answer.code:4:
/usr/include/c++/13/bits/unordered_map.h:570:9: note: candidate: ‘template<class _Pair> std::__enable_if_t<std::is_constructible<typename std::_Hashtable<_Key, std::pair<const _Key, _Val>, _Alloc, std::__detail::_Select1st, _Pred, _Hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<std::__not_<std::__and_<std::__is_fast_hash<_Hash>, std::__is_nothrow_invocable<const _Hash&, const _Key&> > >::value, false, true> >::value_type, _Pair&&>::value, std::pair<typename std::_Hashtable<_Key, std::pair<const _Key, _Val>, _Alloc, std::__detail::_Select1st, _Pred, _Hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<std::__not_<std::__and_<std::__is_fast_hash<_Hash>, std::__is_nothrow_invocable<const _Hash&, const _Key&> > >::value, false, true> >::iterator, bool> > std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_Pair&&) [with _Key = long long unsigned int; _Tp = int; _Hash = std::hash<long long unsigned int>; _Pred = std::equal_to<long long unsigned int>; _Alloc = std::allocator<std::pair<const long long unsigned int, int> >]’
  570 |         insert(_Pair&& __x)
      |         ^~~~~~
/usr/include/c++/13/bits/unordered_map.h:570:9: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/13/bits/char_traits.h:50,
                 from /usr/include/c++/13/string:42,
                 from /usr/include/c++/13/random:42,
                 from answer.code:2:
/usr/include/c++/13/type_traits: In substitution of ‘template<bool _Cond, class _Tp> using std::__enable_if_t = typename std::enable_if::type [with bool _Cond = false; _Tp = std::pair<std::__detail::_Node_iterator<std::pair<const long long unsigned int, int>, false, false>, bool>]’:
/usr/include/c++/13/bits/unordered_map.h:570:2:   required by substitution of ‘template<class _Pair> std::__enable_if_t<std::is_constructible<std::pair<const long long unsigned int, int>, _Pair&&>::value, std::pair<std::__detail::_Node_iterator<std::pair<const long long unsigned int, int>, false, false>, bool> > std::unordered_map<long long unsigned int, int>::insert(_Pair&&) [with _Pair = int]’
answer.code:15:36:   required from here
/usr/include/c++/13/type_traits:116:11: error: no type named ‘type’ in ‘struct std::enable_if<false, std::pair<std::__detail::_Node_iterator<std::pair<const long long unsigned int, int>, false, false>, bool> >’
  116 |     using __enable_if_t = typename enable_if<_Cond, _Tp>::type;
      |           ^~~~~~~~~~~~~
/usr/include/c++/13/bits/unordered_map.h:608:9: note: candidate: ‘template<class _Pair> std::__enable_if_t<std::is_constructible<typename std::_Hashtable<_Key, std::pair<const _Key, _Val>, _Alloc, std::__detail::_Select1st, _Pred, _Hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<std::__not_<std::__and_<std::__is_fast_hash<_Hash>, std::__is_nothrow_invocable<const _Hash&, const _Key&> > >::value, false, true> >::value_type, _Pair&&>::value, typename std::_Hashtable<_Key, std::pair<const _Key, _Val>, _Alloc, std::__detail::_Select1st, _Pred, _Hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<std::__not_<std::__and_<std::__is_fast_hash<_Hash>, std::__is_nothrow_invocable<const _Hash&, const _Key&> > >::value, false, true> >::iterator> std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(const_iterator, _Pair&&) [with _Key = long long unsigned int; _Tp = int; _Hash = std::hash<long long unsigned int>; _Pred = std::equal_to<long long unsigned int>; _Alloc = std::allocator<std::pair<const long long unsigned int, int> >]’
  608 |         insert(const_iterator __hint, _Pair&& __x)
      |         ^~~~~~
/usr/include/c++/13/bits/unordered_map.h:608:9: note:   template argument deduction/substitution failed:
answer.code:15:43: note:   candidate expects 2 arguments, 1 provided
   15 |         s.clear(), tab.clear(), tab.insert(0), memset(lst, 0, sizeof lst);
      |                                 ~~~~~~~~~~^~~
/usr/include/c++/13/bits/unordered_map.h:623:9: note: candidate: ‘template<class _InputIterator> void std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator, _InputIterator) [with _Key = long long unsigned int; _Tp = int; _Hash = std::hash<long long unsigned int>; _Pred = std::equal_to<long long unsig...