Submission #1045478

#TimeUsernameProblemLanguageResultExecution timeMemory
1045478vjudge1Arranging Shoes (IOI19_shoes)C++17
Compilation error
0 ms0 KiB
#include "shoes.h" #include<bits/extc++.h> #include<bits/stdc++.h> using namespace __gnu_pbds; using namespace std; queue<int> otherpos[100100]; long long calc(vector<int>v){ long long ans=0; int K=0; tree<int,null_type,less<>,rb_tree_tag,tree_order_statistics_node_update>st; for(auto i:v) { st.insert(i); ans+=K++-st.order_of_key(i); } return ans; } long long count_swaps(std::vector<int> s) { long long ans=1e9; int n=s.size()>>1; vector<int>sup; vector<int>CR(2*n); int CC=0; for(int i=0;i<n*2;i++) if(s[i]<0) otherpos[-s[i]].push(i); CC=0; vector<pair<int,int>> thgs; for(int i=0;i<n*2;i++) if(s[i]>0) { int x=otherpos[s[i]].front(); thgs.push_back({x,i}); otherpos[s[i]].pop(); } int ans=0; for(auto&[i,j]:thgs) if(i>j) ans++,swap(i,j); sort(thgs.begin(),thgs.end()); for(auto[i,j]:thgs) sup.push_back(i), sup.push_back(j); return ans+calc(sup); }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:32:6: error: conflicting declaration 'int ans'
   32 |  int ans=0;
      |      ^~~
shoes.cpp:18:15: note: previous declaration as 'long long int ans'
   18 |     long long ans=1e9;
      |               ^~~