Submission #135343

#TimeUsernameProblemLanguageResultExecution timeMemory
135343TuGSGeReLSorting (IOI15_sorting)C++17
Compilation error
0 ms0 KiB
#include "sorting.h" #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; #define ll long long #define mp make_pair #define pub push_back #define pob pop_back() #define ss second #define ff first #define mt make_tuple #define pof pop_front() #define fbo find_by_order #define ook order_of_key #define lb lower_bound #define ub upper_bound typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set; using pll = pair <ll, ll>; using pii = pair <int, int>; int erm[200001], aiz[200001], n, x[600001], y[600001], s[200001], data[200001], rdata[200001]; vector <pii> ans; bool can(int k) { ans.clear(); for (int i = 0; i < n; i++) aiz[i] = s[i]; for (int i = 0; i < k; i++) swap(aiz[x[i]], aiz[y[i]]); for (int i = 0; i < n; i++) data[aiz[i]] = i; int p = 0; for (int i = 0; i < n; i++) { if ( aiz[i] != i ) { p++; ans.pub(mp(i, aiz[i])); swap(aiz[data[i]], aiz[data[aiz[i]]]); swap(data[i], data[aiz[i]]); } } if ( p <= k ) return 1; return 0; } int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) { int l = 0, r = M, n = N; for (int i = 0; i < M; i++) { x[i] = X[i]; y[i] = Y[i]; } for (int i = 0; i < n; i++) s[i] = S[i]; while (l + 1 < r) { int mid = (l + r) / 2; if ( can(mid) ) r = mid; else l = mid; } if ( can(l) ) { for (int i = 0; i < ans.size(); i++) { P[i] = ans[i].ff; Q[i] = ans[i].ss; } return l; } else { can(r); for (int i = 0; i < ans.size(); i++) { P[i] = ans[i].ff; Q[i] = ans[i].ss; } return r; } }

Compilation message (stderr)

sorting.cpp: In function 'bool can(int)':
sorting.cpp:39:3: error: reference to 'data' is ambiguous
   data[aiz[i]] = i;
   ^~~~
sorting.cpp:25:67: note: candidates are: int data [200001]
 int erm[200001], aiz[200001], n, x[600001], y[600001], s[200001], data[200001], rdata[200001];
                                                                   ^~~~
In file included from /usr/include/c++/7/string:51:0,
                 from /usr/include/c++/7/bits/locale_classes.h:40,
                 from /usr/include/c++/7/bits/ios_base.h:41,
                 from /usr/include/c++/7/ios:42,
                 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 sorting.cpp:2:
/usr/include/c++/7/bits/range_access.h:318:5: note:                 template<class _Tp> constexpr const _Tp* std::data(std::initializer_list<_Tp>)
     data(initializer_list<_Tp> __il) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:309:5: note:                 template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])
     data(_Tp (&__array)[_Nm]) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:299:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)
     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~
/usr/include/c++/7/bits/range_access.h:289:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)
     data(_Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~
sorting.cpp:49:13: error: reference to 'data' is ambiguous
    swap(aiz[data[i]], aiz[data[aiz[i]]]);
             ^~~~
sorting.cpp:25:67: note: candidates are: int data [200001]
 int erm[200001], aiz[200001], n, x[600001], y[600001], s[200001], data[200001], rdata[200001];
                                                                   ^~~~
In file included from /usr/include/c++/7/string:51:0,
                 from /usr/include/c++/7/bits/locale_classes.h:40,
                 from /usr/include/c++/7/bits/ios_base.h:41,
                 from /usr/include/c++/7/ios:42,
                 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 sorting.cpp:2:
/usr/include/c++/7/bits/range_access.h:318:5: note:                 template<class _Tp> constexpr const _Tp* std::data(std::initializer_list<_Tp>)
     data(initializer_list<_Tp> __il) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:309:5: note:                 template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])
     data(_Tp (&__array)[_Nm]) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:299:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)
     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~
/usr/include/c++/7/bits/range_access.h:289:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)
     data(_Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~
sorting.cpp:49:27: error: reference to 'data' is ambiguous
    swap(aiz[data[i]], aiz[data[aiz[i]]]);
                           ^~~~
sorting.cpp:25:67: note: candidates are: int data [200001]
 int erm[200001], aiz[200001], n, x[600001], y[600001], s[200001], data[200001], rdata[200001];
                                                                   ^~~~
In file included from /usr/include/c++/7/string:51:0,
                 from /usr/include/c++/7/bits/locale_classes.h:40,
                 from /usr/include/c++/7/bits/ios_base.h:41,
                 from /usr/include/c++/7/ios:42,
                 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 sorting.cpp:2:
/usr/include/c++/7/bits/range_access.h:318:5: note:                 template<class _Tp> constexpr const _Tp* std::data(std::initializer_list<_Tp>)
     data(initializer_list<_Tp> __il) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:309:5: note:                 template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])
     data(_Tp (&__array)[_Nm]) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:299:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)
     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~
/usr/include/c++/7/bits/range_access.h:289:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)
     data(_Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~
sorting.cpp:50:9: error: reference to 'data' is ambiguous
    swap(data[i], data[aiz[i]]);
         ^~~~
sorting.cpp:25:67: note: candidates are: int data [200001]
 int erm[200001], aiz[200001], n, x[600001], y[600001], s[200001], data[200001], rdata[200001];
                                                                   ^~~~
In file included from /usr/include/c++/7/string:51:0,
                 from /usr/include/c++/7/bits/locale_classes.h:40,
                 from /usr/include/c++/7/bits/ios_base.h:41,
                 from /usr/include/c++/7/ios:42,
                 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 sorting.cpp:2:
/usr/include/c++/7/bits/range_access.h:318:5: note:                 template<class _Tp> constexpr const _Tp* std::data(std::initializer_list<_Tp>)
     data(initializer_list<_Tp> __il) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:309:5: note:                 template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])
     data(_Tp (&__array)[_Nm]) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:299:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)
     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~
/usr/include/c++/7/bits/range_access.h:289:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)
     data(_Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~
sorting.cpp:50:18: error: reference to 'data' is ambiguous
    swap(data[i], data[aiz[i]]);
                  ^~~~
sorting.cpp:25:67: note: candidates are: int data [200001]
 int erm[200001], aiz[200001], n, x[600001], y[600001], s[200001], data[200001], rdata[200001];
                                                                   ^~~~
In file included from /usr/include/c++/7/string:51:0,
                 from /usr/include/c++/7/bits/locale_classes.h:40,
                 from /usr/include/c++/7/bits/ios_base.h:41,
                 from /usr/include/c++/7/ios:42,
                 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 sorting.cpp:2:
/usr/include/c++/7/bits/range_access.h:318:5: note:                 template<class _Tp> constexpr const _Tp* std::data(std::initializer_list<_Tp>)
     data(initializer_list<_Tp> __il) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:309:5: note:                 template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])
     data(_Tp (&__array)[_Nm]) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:299:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)
     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~
/usr/include/c++/7/bits/range_access.h:289:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)
     data(_Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~
sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:61:20: warning: declaration of 'n' shadows a global declaration [-Wshadow]
  int l = 0, r = M, n = N;
                    ^
sorting.cpp:25:31: note: shadowed declaration is here
 int erm[200001], aiz[200001], n, x[600001], y[600001], s[200001], data[200001], rdata[200001];
                               ^
sorting.cpp:85:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < ans.size(); i++)
                   ~~^~~~~~~~~~~~
sorting.cpp:95:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < ans.size(); i++)
                   ~~^~~~~~~~~~~~