Submission #751350

#TimeUsernameProblemLanguageResultExecution timeMemory
751350kusmetliqArranging Shoes (IOI19_shoes)C++14
Compilation error
0 ms0 KiB
#include "shoes.h" #include<bits/stdc++.h> using namespace std; long long count_swaps(vector<int> a) { if(a.size()<=2000) { 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; } else { int n=a.size(); int curcnt=0; long long ans=0; for(int i=0;i<a.size();i++) { if(a[i]<0) { ans+=abs(i-(curcnt*2)); curcnt++; } } return ans; } } int main() { cout<<count_swaps({-1,-4,3,-3,4,-2,2,1})<<endl; return 0; }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:11:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |             for(int i=0; i<a.size(); i++) {
      |                          ~^~~~~~~~~
shoes.cpp:36:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for(int i=0;i<a.size();i++) {
      |                 ~^~~~~~~~~
shoes.cpp:33:13: warning: unused variable 'n' [-Wunused-variable]
   33 |         int n=a.size();
      |             ^
/usr/bin/ld: /tmp/cch1PrMW.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc71e6mX.o:shoes.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status