Submission #1311203

#TimeUsernameProblemLanguageResultExecution timeMemory
1311203dimitri.shengeliaArranging Shoes (IOI19_shoes)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "shoes.h" using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; map <int, vector <int>> mp; int count_swaps ( vector <int> a ) { int n = a.size(); ordered_set <int> st; vector <bool> visited( n, false ); int answer = 0; for ( int i = 0; i < n; i++ ) { mp[a[i]].push_back( i ); } for ( int i = 0; i < n; i++ ) { if ( visited[i] == true ) { continue; } int j = i; int x = a[i], y = -1 * a[i]; int z = mp[y][0]; visited[z] = true; auto it = st.lower_bound( z ); if ( it == st.end() ) { z -= st.size(); } else { z -= st.order_of_key( *it ); } it = st.lower_bound( i ); if ( it == st.end() ) { j -= st.size(); } else { j -= st.order_of_key( *it ); } answer += z - j - 1; if ( x > 0 ) { answer++; } st.insert( i ); st.insert( z ); mp[x].erase( mp[x].begin() ); mp[y].erase( mp[y].begin() ); } return answer; } /* //#include "shoes.h" #include <cstdio> #include <cassert> using namespace std; int main() { int n; assert(1 == scanf("%d", &n)); vector<int> S(2 * n); for (int i = 0; i < 2 * n; i++) assert(1 == scanf("%d", &S[i])); fclose(stdin); long long result = count_swaps(S); printf("%lld\n", result); fclose(stdout); return 0; }*/

Compilation message (stderr)

shoes.cpp:15:5: error: ambiguating new declaration of 'int count_swaps(std::vector<int>)'
   15 | int count_swaps ( vector <int> a ) {
      |     ^~~~~~~~~~~
In file included from shoes.cpp:2:
shoes.h:7:11: note: old declaration 'long long int count_swaps(std::vector<int>)'
    7 | long long count_swaps(std::vector<int> S);
      |           ^~~~~~~~~~~