QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#378026#6670. NiznvujicaCompile Error//C++142.5kb2024-04-05 22:45:262024-04-05 22:45:28

Judging History

你现在查看的是最新测评结果

  • [2024-04-05 22:45:28]
  • 评测
  • [2024-04-05 22:45:26]
  • 提交

answer

#include <bits/stdc++.h>

#define ll long long
#define fi first
#define se second

using namespace std;

const int maxn = 1e6 + 10, B1 = 31337, B2 = 137, mod1 = 1e9 + 7, mod2 = 1e9 + 9;

int n;
ll ans = 0;
int arr[maxn];
int maks[maxn];
int h1[maxn];
int h2[maxn];
unordered_map <pair<pair<int, int>, ll>, int> l;
unordered_map <pair<pair<int, int>, ll>, int> r;
int pref1[maxn];
int pref2[maxn];
int pot1[maxn];
int pot2[maxn];
ll sum[maxn];

int add1(int a, int b){
	return (a + b) % mod1;
}

int mul1(int a, int b){
	return ((ll)a * b) % mod1;
}

int sub1(int a, int b){
	return (a - b + mod1) % mod1;
}

int add2(int a, int b){
	return (a + b) % mod2;
}

int mul2(int a, int b){
	return ((ll)a * b) % mod2;
}

int sub2(int a, int b){
	return (a - b + mod2) % mod2;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	pot1[0] = 1;
	pot2[0] = 1;	
	
	for(int i = 1; i < maxn; i++){
		pot1[i] = mul1(pot1[i - 1], B1);
		pot2[i] = mul2(pot2[i - 1], B2);
	}
	
	for(int i = 2; i < maxn; i++){
		pref1[i] = add1(pref1[i - 1], pot1[i]);
		pref2[i] = add2(pref2[i - 1], pot2[i]);
	}
	
	cin >> n;
	
	for(int i = 1; i <= n; i++){
		cin >> arr[i];
	}
	
	for(int i = 1; i <= n; i++){
		if(arr[i] != 1) continue;
		
//		cout << i << endl;
		
		ans++;
		maks[i] = 1;
		h1[i] = 0;
		h2[i] = 0;
		l.clear();
		r.clear();
		l[{{0, 0}, 0}] = 1;
		r[{{0, 0}, 0}] = 1;
		
		for(int j = i - 1; j >= 1; j--){
			if(arr[j] == 1) break;
			
			sum[j] = sum[j + 1] + arr[j];
			maks[j] = max(maks[j + 1], arr[j]);
			h1[j] = add1(h1[j + 1], pot1[arr[j]]);
			h2[j] = add2(h2[j + 1], pot2[arr[j]]);
			l[{{h1[j], h2[j]}, sum[j]}]++;
		}
		
		for(int j = i + 1; j <= n; j++){
			if(arr[j] == 1) break;
			
			sum[j] = sum[j - 1] + arr[j];
			maks[j] = max(maks[j - 1], arr[j]);
			h1[j] = add1(h1[j - 1], pot1[arr[j]]);
			h2[j] = add2(h2[j - 1], pot2[arr[j]]);
			r[{{h1[j], h2[j]}, sum[j]}]++;
			
			ans += l[{{sub1(pref1[maks[j]], h1[j]), sub2(pref2[maks[j]], h2[j])}, (ll)maks[j] * (maks[j] + 1) / 2 - 1 - sum[j]}];
//			cout << "r: " << j << "  +" << l[sub(pref[maks[j]], h[j])] << ' ' << sub(pref[maks[j]], h[j]) << endl;
		}
		
		for(int j = i - 1; j >= 1; j--){
			if(arr[j] == 1) break;
			
			ans += r[{{sub1(pref1[maks[j]], h1[j]), sub2(pref2[maks[j]], h2[j])}, (ll)maks[j] * (maks[j] + 1) / 2 - 1 - sum[j]}];
			
//			cout << "l: " << j << "  +" << r[sub(pref[maks[j]], h[j])] << endl;
		}
	}
	
	cout << ans;
	
	return 0;
}

Details

answer.code:17:47: error: use of deleted function ‘std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<std::pair<int, int>, long long int>; _Tp = int; _Hash = std::hash<std::pair<std::pair<int, int>, long long int> >; _Pred = std::equal_to<std::pair<std::pair<int, int>, long long int> >; _Alloc = std::allocator<std::pair<const std::pair<std::pair<int, int>, long long int>, int> >]’
   17 | unordered_map <pair<pair<int, int>, ll>, int> l;
      |                                               ^
In file included from /usr/include/c++/13/unordered_map:41,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:188,
                 from answer.code:1:
/usr/include/c++/13/bits/unordered_map.h:148:7: note: ‘std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<std::pair<int, int>, long long int>; _Tp = int; _Hash = std::hash<std::pair<std::pair<int, int>, long long int> >; _Pred = std::equal_to<std::pair<std::pair<int, int>, long long int> >; _Alloc = std::allocator<std::pair<const std::pair<std::pair<int, int>, long long int>, int> >]’ is implicitly deleted because the default definition would be ill-formed:
  148 |       unordered_map() = default;
      |       ^~~~~~~~~~~~~
/usr/include/c++/13/bits/unordered_map.h:148:7: error: use of deleted function ‘std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<std::pair<int, int>, long long int>; _Value = std::pair<const std::pair<std::pair<int, int>, long long int>, int>; _Alloc = std::allocator<std::pair<const std::pair<std::pair<int, int>, long long int>, int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<std::pair<int, int>, long long int> >; _Hash = std::hash<std::pair<std::pair<int, int>, long long int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]’
In file included from /usr/include/c++/13/bits/unordered_map.h:33:
/usr/include/c++/13/bits/hashtable.h:530:7: note: ‘std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<std::pair<int, int>, long long int>; _Value = std::pair<const std::pair<std::pair<int, int>, long long int>, int>; _Alloc = std::allocator<std::pair<const std::pair<std::pair<int, int>, long long int>, int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<std::pair<int, int>, long long int> >; _Hash = std::hash<std::pair<std::pair<int, int>, long long int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]’ is implicitly deleted because the default definition would be ill-formed:
  530 |       _Hashtable() = default;
      |       ^~~~~~~~~~
/usr/include/c++/13/bits/hashtable.h:530:7: error: use of deleted function ‘std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<std::pair<int, int>, long long int>; _Value = std::pair<const std::pair<std::pair<int, int>, long long int>, int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<std::pair<int, int>, long long int> >; _Hash = std::hash<std::pair<std::pair<int, int>, long long int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]’
In file included from /usr/include/c++/13/bits/hashtable.h:35:
/usr/include/c++/13/bits/hashtable_policy.h:1710:7: note: ‘std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<std::pair<int, int>, long long int>; _Value = std::pair<const std::pair<std::pair<int, int>, long long int>, int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<std::pair<int, int>, long long int> >; _Hash = std::hash<std::pair<std::pair<int, int>, long long int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]’ is implicitly deleted because the default definition would be ill-formed:
 1710 |       _Hashtable_base() = default;
      |       ^~~~~~~~~~~~~~~
/usr/include/c++/13/bits/hashtable_policy.h:1710:7: error: use of deleted function ‘std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<std::pair<int, int>, long long int>; _Value = std::pair<const std::pair<std::pair<int, int>, long long int...