# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
808750 | KemalK | Arranging Shoes (IOI19_shoes) | C++17 | 컴파일 에러 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "shoes.h"
#include <bits/stdc++.h>
#include "ext/pb_ds/assoc_container.hpp"
using namespace std;
using namespace __gnu_pbds;
template<typename T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
typedef long long int ll;
int n;
long long count_swaps(std::vector<int> s) {
int n = s.size();
ordered_set <pair<int, int>> st;
ll ans = 0;
map <int, vector <int>> pos_right;
map <int, vector <int>> pos_left;
for (int i = n - 1; i >= 0; i--)
{
st.insert({i, s[i]});
if (s[i] > 0)
pos_right[s[i]].push_back(i);
else
pos_left[s[i]].push_back(i);
}
while(!st.empty()){
pair<int, int> nd = *st.begin();
int value = nd.second;
int pos = nd.first;
int find_element;
if (value > 0){
// right
pos_right[value].pop_back();
find_element = {pos_left[-value].back(), -value};
pos_left[-value].pop_back();
}
else{
// left
pos_left[value].pop_back();
find_element = {pos_right[-value].back(), -value};
pos_right[-value].pop_back();
}
ans += st.order_of_key(find_element);
if (value > 0){
ans++;
}
st.erase(st.begin());
st.erase(find_element);
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
shoes.cpp: In function 'long long int count_swaps(std::vector<int>)': shoes.cpp:31:51: error: cannot convert '<brace-enclosed initializer list>' to 'int' in assignment 31 | find_element = {pos_left[-value].back(), -value}; | ^ shoes.cpp:37:52: error: cannot convert '<brace-enclosed initializer list>' to 'int' in assignment 37 | find_element = {pos_right[-value].back(), -value}; | ^ shoes.cpp:40:26: error: cannot convert 'int' to '__gnu_pbds::tree_order_statistics_node_update<__gnu_pbds::detail::bin_search_tree_const_node_it_<__gnu_pbds::detail::rb_tree_node_<std::pair<int, int>, long unsigned int, std::allocator<char> >, __gnu_pbds::detail::bin_search_tree_const_it_<__gnu_pbds::detail::rb_tree_node_<std::pair<int, int>, long unsigned int, std::allocator<char> >*, std::pair<int, int>, std::pair<int, int>*, const std::pair<int, int>*, std::pair<int, int>&, const std::pair<int, int>&, true, std::allocator<char> >, __gnu_pbds::detail::bin_search_tree_const_it_<__gnu_pbds::detail::rb_tree_node_<std::pair<int, int>, long unsigned int, std::allocator<char> >*, std::pair<int, int>, std::pair<int, int>*, const std::pair<int, int>*, std::pair<int, int>&, const std::pair<int, int>&, true, std::allocator<char> >, std::allocator<char> >, __gnu_pbds::detail::bin_search_tree_const_node_it_<__gnu_pbds::detail::rb_tree_node_<std::pair<int, int>, long unsigned int, std::allocator<char> >, __gnu_pbds::detail::bin_search_tree_const_it_<__gnu_pbds::detail::rb_tree_node_<std::pair<int, int>, long unsigned int, std::allocator<char> >*, std::pair<int, int>, std::pair<int, int>*, const std::pair<int, int>*, std::pair<int, int>&, const std::pair<int, int>&, true, std::allocator<char> >, __gnu_pbds::detail::bin_search_tree_const_it_<__gnu_pbds::detail::rb_tree_node_<std::pair<int, int>, long unsigned int, std::allocator<char> >*, std::pair<int, int>, std::pair<int, int>*, const std::pair<int, int>*, std::pair<int, int>&, const std::pair<int, int>&, true, std::allocator<char> >, std::allocator<char> >, std::less<std::pair<int, int> >, std::allocator<char> >::key_const_reference' {aka 'const std::pair<int, int>&'} 40 | ans += st.order_of_key(find_element); | ^~~~~~~~~~~~ | | | int In file included from /usr/include/c++/10/ext/pb_ds/tree_policy.hpp:149, from /usr/include/c++/10/ext/pb_ds/detail/standard_policies.hpp:48, from /usr/include/c++/10/ext/pb_ds/assoc_container.hpp:47, from shoes.cpp:3: /usr/include/c++/10/ext/pb_ds/detail/tree_policy/order_statistics_imp.hpp:79:34: note: initializing argument 1 of '__gnu_pbds::tree_order_statistics_node_update<Node_CItr, Node_Itr, Cmp_Fn, _Alloc>::size_type __gnu_pbds::tree_order_statistics_node_update<Node_CItr, Node_Itr, Cmp_Fn, _Alloc>::order_of_key(__gnu_pbds::tree_order_statistics_node_update<Node_CItr, Node_Itr, Cmp_Fn, _Alloc>::key_const_reference) const [with Node_CItr = __gnu_pbds::detail::bin_search_tree_const_node_it_<__gnu_pbds::detail::rb_tree_node_<std::pair<int, int>, long unsigned int, std::allocator<char> >, __gnu_pbds::detail::bin_search_tree_const_it_<__gnu_pbds::detail::rb_tree_node_<std::pair<int, int>, long unsigned int, std::allocator<char> >*, std::pair<int, int>, std::pair<int, int>*, const std::pair<int, int>*, std::pair<int, int>&, const std::pair<int, int>&, true, std::allocator<char> >, __gnu_pbds::detail::bin_search_tree_const_it_<__gnu_pbds::detail::rb_tree_node_<std::pair<int, int>, long unsigned int, std::allocator<char> >*, std::pair<int, int>, std::pair<int, int>*, const std::pair<int, int>*, std::pair<int, int>&, const std::pair<int, int>&, true, std::allocator<char> >, std::allocator<char> >; Node_Itr = __gnu_pbds::detail::bin_search_tree_const_node_it_<__gnu_pbds::detail::rb_tree_node_<std::pair<int, int>, long unsigned int, std::allocator<char> >, __gnu_pbds::detail::bin_search_tree_const_it_<__gnu_pbds::detail::rb_tree_node_<std::pair<int, int>, long unsigned int, std::allocator<char> >*, std::pair<int, int>, std::pair<int, int>*, const std::pair<int, int>*, std::pair<int, int>&, const std::pair<int, int>&, true, std::allocator<char> >, __gnu_pbds::detail::bin_search_tree_const_it_<__gnu_pbds::detail::rb_tree_node_<std::pair<int, int>, long unsigned int, std::allocator<char> >*, std::pair<int, int>, std::pair<int, int>*, const std::pair<int, int>*, std::pair<int, int>&, const std::pair<int, int>&, true, std::allocator<char> >, std::allocator<char> >; Cmp_Fn = std::less<std::pair<int, int> >; _Alloc = std::allocator<char>; __gnu_pbds::tree_order_statistics_node_update<Node_CItr, Node_Itr, Cmp_Fn, _Alloc>::size_type = long unsigned int; __gnu_pbds::tree_order_statistics_node_update<Node_CItr, Node_Itr, Cmp_Fn, _Alloc>::key_const_reference = const std::pair<int, int>&]' 79 | order_of_key(key_const_reference r_key) const | ~~~~~~~~~~~~~~~~~~~~^~~~~ shoes.cpp:45:24: error: no matching function for call to 'erase(int&)' 45 | st.erase(find_element); | ^ In file included from /usr/include/c++/10/ext/pb_ds/detail/container_base_dispatch.hpp:85, from /usr/include/c++/10/ext/pb_ds/assoc_container.hpp:48, from shoes.cpp:3: /usr/include/c++/10/ext/pb_ds/detail/rb_tree_map_/erase_fn_imps.hpp:57:1: note: candidate: '__gnu_pbds::detail::rb_tree_set<Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc>::iterator __gnu_pbds::detail::rb_tree_set<Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc>::erase(__gnu_pbds::detail::rb_tree_set<Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc>::iterator) [with Key = std::pair<int, int>; Mapped = __gnu_pbds::null_type; Cmp_Fn = std::less<std::pair<int, int> >; Node_And_It_Traits = __gnu_pbds::detail::tree_traits<std::pair<int, int>, __gnu_pbds::null_type, std::less<std::pair<int, int> >, __gnu_pbds::tree_order_statistics_node_update, __gnu_pbds::rb_tree_tag, std::allocator<char> >; _Alloc = std::allocator<char>; __gnu_pbds::detail::rb_tree_set<Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc>::iterator = __gnu_pbds::detail::bin_search_tree_const_it_<__gnu_pbds::detail::rb_tree_node_<std::pair<int, int>, long unsigned int, std::allocator<char> >*, std::pair<int, int>, std::pair<int, int>*, const std::pair<int, int>*, std::pair<int, int>&, const std::pair<int, int>&, true, std::allocator<char> >]' (near match) 57 | PB_DS_CLASS_C_DEC:: | ^ /usr/include/c++/10/ext/pb_ds/detail/rb_tree_map_/erase_fn_imps.hpp:57:1: note: conversion of argument 1 would be ill-formed: shoes.cpp:45:12: error: invalid conversion from 'int' to '__gnu_pbds::detail::rb_tree_node_<std::pair<int, int>, long unsigned int, std::allocator<char> >*' [-fpermissive] 45 | st.erase(find_element); | ^~~~~~~~~~~~ | | | int In file included from /usr/include/c++/10/ext/pb_ds/detail/bin_search_tree_/traits.hpp:44, from /usr/include/c++/10/ext/pb_ds/detail/branch_policy/traits.hpp:45, from /usr/include/c++/10/ext/pb_ds/assoc_container.hpp:49, from shoes.cpp:3: /usr/include/c++/10/ext/pb_ds/detail/bin_search_tree_/point_iterators.hpp:117:52: note: initializing argument 1 of '__gnu_pbds::detail::bin_search_tree_const_it_<Node_Pointer, Value_Type, Pointer, Const_Pointer, Reference, Const_Reference, Is_Forward_Iterator, _Alloc>::bin_search_tree_const_it_(Node_Pointer) [with Node_Pointer = __gnu_pbds::detail::rb_tree_node_<std::pair<int, int>, long unsigned int, std::allocator<char> >*; Value_Type = std::pair<int, int>; Pointer = std::pair<int, int>*; Const_Pointer = const std::pair<int, int>*; Reference = std::pair<int, int>&; Const_Reference = const std::pair<int, int>&; bool Is_Forward_Iterator = true; _Alloc = std::allocator<char>]' 117 | bin_search_tree_const_it_(const Node_Pointer p_nd = 0) | ~~~~~~~~~~~~~~~~~~~^~~~~~~~ In file included from /usr/include/c++/10/ext/pb_ds/detail/container_base_dispatch.hpp:85, from /usr/include/c++/10/ext/pb_ds/assoc_container.hpp:48, from shoes.cpp:3: /usr/include/c++/10/ext/pb_ds/detail/rb_tree_map_/erase_fn_imps.hpp:73:1: note: candidate: '__gnu_pbds::detail::rb_tree_set<Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc>::reverse_iterator __gnu_pbds::detail::rb_tree_set<Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc>::erase(__gnu_pbds::detail::rb_tree_set<Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc>::reverse_iterator) [with Key = std::pair<int, int>; Mapped = __gnu_pbds::null_type; Cmp_Fn = std::less<std::pair<int, int> >; Node_And_It_Traits = __gnu_pbds::detail::tree_traits<std::pair<int, int>, __gnu_pbds::null_type, std::less<std::pair<int, int> >, __gnu_pbds::tree_order_statistics_node_update, __gnu_pbds::rb_tree_tag, std::allocator<char> >; _Alloc = std::allocator<char>; __gnu_pbds::detail::rb_tree_set<Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc>::reverse_iterator = __gnu_pbds::detail::bin_search_tree_const_it_<__gnu_pbds::detail::rb_tree_node_<std::pair<int, int>, long unsigned int, std::allocator<char> >*, std::pair<int, int>, std::pair<int, int>*, const std::pair<int, int>*, std::pair<int, int>&, const std::pair<int, int>&, false, std::allocator<char> >]' (near match) 73 | PB_DS_CLASS_C_DEC:: | ^ /usr/include/c++/10/ext/pb_ds/detail/rb_tree_map_/erase_fn_imps.hpp:73:1: note: conversion of argument 1 would be ill-formed: shoes.cpp:45:12: error: invalid conversion from 'int' to '__gnu_pbds::detail::rb_tree_node_<std::pair<int, int>, long unsigned int, std::allocator<char> >*' [-fpermissive] 45 | st.erase(find_element); | ^~~~~~~~~~~~ | | | int In file included from /usr/include/c++/10/ext/pb_ds/detail/bin_search_tree_/traits.hpp:44, from /usr/include/c++/10/ext/pb_ds/detail/branch_policy/traits.hpp:45, from /usr/include/c++/10/ext/pb_ds/assoc_container.hpp:49, from shoes.cpp:3: /usr/include/c++/10/ext/pb_ds/detail/bin_search_tree_/point_iterators.hpp:117:52: note: initializing argument 1 of '__gnu_pbds::detail::bin_search_tree_const_it_<Node_Pointer, Value_Type, Pointer, Const_Pointer, Reference, Const_Reference, Is_Forward_Iterator, _Alloc>::bin_search_tree_const_it_(Node_Pointer) [with Node_Pointer = __gnu_pbds::detail::rb_tree_node_<std::pair<int, int>, long unsigned int, std::allocator<char> >*; Value_Type = std::pair<int, int>; Pointer = std::pair<int, int>*; Const_Pointer = const std::pair<int, int>*; Reference = std::pair<int, int>&; Const_Reference = const std::pair<int, int>&; bool Is_Forward_Iterator = false; _Alloc = std::allocator<char>]' 117 | bin_search_tree_const_it_(const Node_Pointer p_nd = 0) | ~~~~~~~~~~~~~~~~~~~^~~~~~~~ shoes.cpp:26:7: warning: unused variable 'pos' [-Wunused-variable] 26 | int pos = nd.first; | ^~~