Submission #815426

#TimeUsernameProblemLanguageResultExecution timeMemory
815426elotelo966Arranging Shoes (IOI19_shoes)C++17
0 / 100
0 ms296 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; long long count_swaps(std::vector<int> s) { int n=s.size()*2; vector <int> v(n); vector <pair<int,int>> ger; vector <int> cev,cev1; for(int i=0;i<n;i++)v[i]=s[i]; int dizi[n],ind[n]; int tut=0; for(int i=0;i<n;i++){ if(v[i]<0){ dizi[tut]=v[i]; ind[tut]=i; tut+=2; } else{ ger.push_back({v[i],i}); } } sort(ger.begin(),ger.end()); for(int i=0;i<ger.size();i++){ cev.push_back(ger[i].first); cev1.push_back(ger[i].second); //cout<<ger[i].first<<" "<<ger[i].second<<endl; } for(int i=0;i<n;i+=2){ int c=lower_bound(cev.begin(),cev.end(),-dizi[i])-cev.begin(); ind[i+1]=cev1[c]; cev.erase(cev.begin()+c); cev1.erase(cev1.begin()+c); } int ans=0; for(int i=0;i<n;i++){ // cout<<ind[i]<<" "<<abs(ind[i]-i)<<endl; ans+=abs(ind[i]-i); } if((ans/2)%2==0)return ans/2; return ans/2+1; }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:25:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     for(int i=0;i<ger.size();i++){
      |                 ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...