제출 #1331172

#제출 시각아이디문제언어결과실행 시간메모리
1331172rainmar3개의 봉우리 (IOI25_triples)C++20
컴파일 에러
0 ms0 KiB
#include "triples.h"

#include<bits/stdc++.h>
using namespace std;

unordered_set<vector<int>> seen;

long long count_triples(std::vector<int> H) {

  int n = H.size();

  //order is hi, hj, hk.
  
  //case one, hi is the largest value = k-i
  //so hi + i = k;
  //hk = H[k];

  long long sol = 0;

  for(int i = 0; i < n; i++) {
    int k = i + H[i];

    if(k < n) {
      if(H[k] < H[i]) {
        int j = k - H[k];
        if(H[j] + H[k] == H[i]) {
          sol++;
        }

        if(H[k] * 2 != H[i]) { //so that we wont overcount. If i - x  - j - x - k then alr counted
          j = i + H[k];
          if(H[k] + H[j] == H[i]) {
            sol++;
          }
        }
      }
    }
    k = i - H[i];
    if(k >= 0) {
      if(H[k] < H[i]) {
        int j = k + H[k];
        if(H[k] + H[j] == H[i]) {
          sol++;
        }

        if(H[k] * 2 != H[i]) {
          j = i - H[k];
          if(H[j] + H[k] == H[i]) {
            sol++;
          }
        }
      }
    }
  }

  vector<int> b[2 * n + 1];
  for(int i = 0; i < n; i++) {
    b[n + H[i] - i].push_back(i);
  }

  int root = sqrt(n);

  for(int x = 1; x <= 2 * n; x++) {
    if(b[x].size() < root) {
      for(int v1 = 0; v1 < b[x].size(); v1++) {
        int i = b[x][v1];
        for(int v2 = 0; v2 < v1; v2++) {
          int j = b[x][v2];
          int k = j + H[i];
          if (k < n && k > i){
            if (H[i] == (k - j) && H[j] == (k - i) && H[k] == (i - j)){
                sol++;
            }
          }
        }
      }
    } else {
      for (int k = 0; k < n; k++){
        int C = x - n;
        int sum = k - C;
        int diff = H[k];
        
        if (diff % 2 == sum % 2){
            int i = (sum - diff) / 2;
            int j = (sum + diff) / 2;
            
            if (0 <= i && i < n && 0 <= j && j < n && H[i] - i == C && H[j] - j == C){
                sol++;
            }
        }
      }
    }
  }

  return sol;
}

std::vector<int> construct_range(int M, int K) {
  return {1, 1, 1};
}

컴파일 시 표준 에러 (stderr) 메시지

triples.cpp:6:28: error: use of deleted function 'std::unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set() [with _Value = std::vector<int>; _Hash = std::hash<std::vector<int> >; _Pred = std::equal_to<std::vector<int> >; _Alloc = std::allocator<std::vector<int> >]'
    6 | unordered_set<vector<int>> seen;
      |                            ^~~~
In file included from /usr/include/c++/13/unordered_set:41,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:189,
                 from triples.cpp:3:
/usr/include/c++/13/bits/unordered_set.h:142:7: note: 'std::unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set() [with _Value = std::vector<int>; _Hash = std::hash<std::vector<int> >; _Pred = std::equal_to<std::vector<int> >; _Alloc = std::allocator<std::vector<int> >]' is implicitly deleted because the default definition would be ill-formed:
  142 |       unordered_set() = default;
      |       ^~~~~~~~~~~~~
/usr/include/c++/13/bits/unordered_set.h:142:7: error: use of deleted function 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::vector<int>; _Value = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; _ExtractKey = std::__detail::_Identity; _Equal = std::equal_to<std::vector<int> >; _Hash = std::hash<std::vector<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, true, true>]'
In file included from /usr/include/c++/13/bits/unordered_map.h:33,
                 from /usr/include/c++/13/unordered_map:41,
                 from /usr/include/c++/13/functional:63,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:53:
/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::vector<int>; _Value = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; _ExtractKey = std::__detail::_Identity; _Equal = std::equal_to<std::vector<int> >; _Hash = std::hash<std::vector<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, true, 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::vector<int>; _Value = std::vector<int>; _ExtractKey = std::__detail::_Identity; _Equal = std::equal_to<std::vector<int> >; _Hash = std::hash<std::vector<int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, true, true>]'
In file included from /usr/include/c++/13/bits/hashtable.h:35:
/usr/include/c++/13/bits/hashtable_policy.h:1701:7: note: 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::vector<int>; _Value = std::vector<int>; _ExtractKey = std::__detail::_Identity; _Equal = std::equal_to<std::vector<int> >; _Hash = std::hash<std::vector<int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, true, true>]' is implicitly deleted because the default definition would be ill-formed:
 1701 |       _Hashtable_base() = default;
      |       ^~~~~~~~~~~~~~~
/usr/include/c++/13/bits/hashtable_policy.h:1701: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::vector<int>; _Value = std::vector<int>; _ExtractKey = std::__detail::_Identity; _Hash = std::hash<std::vector<int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]'
/usr/include/c++/13/bits/hashtable_policy.h: In instantiation of 'std::__detail::_Hashtable_ebo_helper<_Nm, _Tp, true>::_Hashtable_ebo_helper() [with int _Nm = 1; _Tp = std::hash<std::vector<int> >]':
/usr/include/c++/13/bits/hashtable_policy.h:1301:7:   required from here
/usr/include/c++/13/bits/hashtable_policy.h:1218:49: error: use of deleted function 'std::hash<std::vector<int> >::hash()'
 1218 |       _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { }
      |                                                 ^~~~~
In file included from /usr/include/c++/13/bits/stl_bvector.h:65,
                 from /usr/include/c++/13/vector:67,
                 from triples.h:1,
                 from triples.cpp:1:
/usr/include/c++/13/bits/functional_hash.h:102:12: note: 'std::hash<std::vector<int> >::hash()' is implicitly deleted because the default definition would be ill-formed:
  102 |     struct hash : __hash_enum<_Tp>
      |            ^~~~
/usr/include/c++/13/bits/functional_hash.h:102:12: error: no matching function for call to 'std::__hash_enum<std::vector<int>, false>::__hash_enum()'
/usr/include/c++/13/bits/functional_hash.h:83:7: note: candidate: 'std::__hash_enum<_Tp, <anonymous> >::__hash_enum(std::__hash_enum<_Tp, <anonymous> >&&) [with _Tp = std::vector<int>; bool <anonymous> = false]'
   83 |       __hash_enum(__hash_enum&&);
      |       ^~~~~~~~~~~
/usr/include/c++/13/bits/functional_hash.h:83:7: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/13/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::vector<int>; bool <anonymous> = false]' is private within this context
  102 |     struct hash : __hash_enum<_Tp>
      |            ^~~~
/usr/include/c++/13/bits/functional_hash.h:84:7: note: declared private here
   84 |       ~__hash_enum();
      |       ^
/usr/include/c++/13/bits/hashtable_policy.h:1301:7: note: 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::vector<int>; _Value = std::vector<int>; _ExtractKey = std::__detail::_Identity; _Hash = std::hash<std::vector<int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' is implicitly deleted because the default definition would be ill-formed:
 1301 |       _Hash_code_base() = default;
      |       ^~~~~~~~~~~~~~~
/usr/include/c++/13/bits/hashtable_policy.h:1301:7: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::vector<int> >, true>::~_Hashtable_ebo_helper()'
/usr/include/c++/13/bits/hashtable_policy.h:1215:12: note: 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::vector<int> >, true>::~_Hashtable_ebo_helper()' is implicitly deleted because the default definition would be ill-formed:
 1215 |     struct _Hashtable_ebo_helper<_Nm, _Tp, true>
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/hashtable_policy.h:1215:12: error: use of deleted function 'std::hash<std::vector<int> >::~hash()'
/usr/include/c++/13/bits/functional_hash.h:102:12: note: 'std::hash<std::vector<int> >::~hash()' is implicitly deleted because the default definition would be ill-formed:
  102 |     struct hash : __hash_enum<_Tp>
      |            ^~~~
/usr/include/c++/13/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::vector<int>; bool <anonymous> = false]' is private within this context
/usr/include/c++/13/bits/functional_hash.h:84:7: note: declared private here
   84 |       ~__hash_enum();
      |       ^
/usr/include/c++/13/bits/hashtable_policy.h:1701:7: error: use of deleted function 'std::__detail::_Hash_code_base<std::vector<int>, std::vector<int>, std::__detail::_Identity, std::hash<std::vector<int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()'
 1701 |       _Hashtable_base() = default;
      |       ^~~~~~~~~~~~~~~
/usr/include/c++/13/bits/hashtable_policy.h:1279:12: note: 'std::__detail::_Hash_code_base<std::vector<int>, std::vector<int>, std::__detail::_Identity, std::hash<std::vector<int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()' is implicitly deleted because the default definition would be ill-formed:
 1279 |     struct _Hash_code_base
      |            ^~~~~~~~~~~~~~~
/usr/include/c++/13/bits/hashtable_policy.h:1279:12: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::vector<int> >, true>::~_Hashtable_ebo_helper()'
/usr/include/c++/13/bits/hashtable.h:530:7: error: use of deleted function 'std::__detail::_Hashtable_base<std::vector<int>, std::vector<int>, std::__detail::_Identity, std::equal_to<std::vector<int> >, std::hash<std::vector<int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Hashtable_traits<true, true, true> >::~_Hashtable_base()'
  530 |       _Hashtable() = default;
      |       ^~~~~~~~~~
/usr/include/c++/13/bits/hashtable_policy.h:1658:12: note: 'std::__detail::_Hashtable_base<std::vector<int>, std::vector<int>, std::__detail::_Identity, std::equal_to<std::vector<int> >, std::hash<std::vector<int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Hashtable_traits<true, true, true> >::~_Hashtable_base()' is implicitly deleted because the default definition would be ill-formed:
 1658 |     struct _Hashtable_base
      |            ^~~~~~~~~~~~~~~
/usr/include/c++/13/bits/hashtable_policy.h:1658:12: error: use of deleted function 'std::__detail::_Hash_code_base<std::vector<int>, std::vector<int>, std::__detail::_Identity, std::hash<std::vector<int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()'
/usr/include/c++/13/bits/hashtable.h:530:7: error: use of deleted function 'constexpr std::_Enable_default_constructor<false, _Tag>::_Enable_default_constructor() [with _Tag = std::__detail::_Hash_node_base]'
  530 |       _Hashtable() = default;
      |       ^~~~~~~~~~
In file included from /usr/include/c++/13/bits/hashtable.h:36:
/usr/include/c++/13/bits/enable_special_members.h:113:15: note: declared here
  113 |     constexpr _Enable_default_constructor() noexcept = delete;
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/hashtable.h: In instantiation of 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::~_Hashtable() [with _Key = std::vector<int>; _Value = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; _ExtractKey = std::__detail::_Identity; _Equal = std::equal_to<std::vector<int> >; _Hash = std::hash<std::vector<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, true, true>]':
/usr/include/c++/13/bits/unordered_set.h:104:11:   required from here
/usr/include/c++/13/bits/hashtable.h:1610:5: error: use of deleted function 'std::__detail::_Hashtable_base<std::vector<int>, std::vector<int>, std::__detail::_Identity, std::equal_to<std::vector<int> >, std::hash<std::vector<int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Hashtable_traits<true, true, true> >::~_Hashtable_base()'
 1610 |     }
      |     ^
/usr/include/c++/13/bits/hashtable.h:1602:21: error: static assertion failed: Cache the hash code or qualify your functors involved in hash code and bucket index computation with noexcept
 1602 |       static_assert(noexcept(declval<const __hash_code_base_access&>()
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1603 |                         ._M_bucket_index(declval<const __node_value_type&>(),
      |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1604 |                                          (std::size_t)0)),
      |                                          ~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/hashtable.h:1602:21: note: 'false' evaluates to false