Submission #751347

#TimeUsernameProblemLanguageResultExecution timeMemory
751347kusmetliqArranging Shoes (IOI19_shoes)C++14
50 / 100
1081 ms11548 KiB
#include "shoes.h" #include<bits/stdc++.h> using namespace std; long long count_swaps(vector<int> a) { int n=a.size()/2; long long ans=0; while(a.size()>0) { map<int,int>m; for(int i=0;i<a.size();i++) { if(m[a[i]]==0)m[a[i]]=i+1; } int minscore=2*n; int scoreval=0; for(int i=1;i<=n+69;i++) { if(m[i]==0)continue; int updscore=0; updscore+=m[i]-1; updscore+=m[-i]-1; if(m[-i]<m[i])updscore--; if(updscore<minscore) { minscore=updscore; scoreval=i; } } ans+=minscore; a.erase(find(a.begin(),a.end(),scoreval)); a.erase(find(a.begin(),a.end(),-scoreval)); } return ans; }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:9:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |         for(int i=0;i<a.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...