Submission #890794

#TimeUsernameProblemLanguageResultExecution timeMemory
890794GabrielPimArranging Shoes (IOI19_shoes)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include <vector> using namespace std; int n,in,fi,a,co=0; vector<pair <int,int> > v,v2,v3,v4; vector<int> s; void bu(void) { //cout<<in<<" "<<v3[in].second<<"\n"; for(int i=v3[in].second;i>in;i--) { swap(s[i],s[i-1]); co++; v3[v4[i].second].second++; } v3[in].second=0; return; } bool c(const pair<int, int>& a, const pair<int, int>& b) { if (a.first < b.first) return true; else if (a.first > b.first) return false; else return a.second < b.second; } bool c2(const pair<int, int>& a, const pair<int, int>& b) { if (a.first > b.first) return true; else if (a.first < b.first) return false; else return a.second < b.second; } int main() { cin>>n; for(int i=0;i<n*2;i++) { cin>>a; s.push_back(a); if(s[i]>0) v.push_back(make_pair(s[i],i)); else v2.push_back(make_pair(s[i],i)); } sort(v.begin(),v.end(),c2); sort(v2.begin(),v2.end(),c); for(int i=0;i<v.size();i++) { v3.push_back(v2[i]); v3.push_back(v[i]); } for(int i=0;i<v3.size();i++) { v4.push_back(make_pair(v3[i].second,i)); } sort(v4.begin(),v4.end()); for(in=0;in<n*2;in++) { if(s[in]!=v3[in].first) break; } for(fi=s.size()-1;fi>=in;fi--) { if(s[fi]!=v3[fi].first) break; } for(in;in<=fi;in++) { bu(); } cout<<co; return 0; }

Compilation message (stderr)

shoes.cpp: In function 'int main()':
shoes.cpp:43: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]
   43 |     for(int i=0;i<v.size();i++)
      |                 ~^~~~~~~~~
shoes.cpp:48: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]
   48 |     for(int i=0;i<v3.size();i++)
      |                 ~^~~~~~~~~~
shoes.cpp:61:9: warning: statement has no effect [-Wunused-value]
   61 |     for(in;in<=fi;in++)
      |         ^~
/usr/bin/ld: /tmp/ccO8gXQQ.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccy3r6oS.o:shoes.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccO8gXQQ.o: in function `main':
grader.cpp:(.text.startup+0x29d): undefined reference to `count_swaps(std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status