Submission #889478

#TimeUsernameProblemLanguageResultExecution timeMemory
889478Lincito_31Arranging Shoes (IOI19_shoes)C++14
15 / 100
15 ms2520 KiB
#include <bits/stdc++.h> #include "shoes.h" using namespace std; long long x=0; long long count_swaps(vector<int> s) { bool s3=true; bool s4=true; vector<int> xd_po; vector<int> xd_ne; int tam=s.size(); tam/=2; for(int i=0;i<2*tam;i++){ if(i<tam/2){ if(s[i]!=-s[tam+i]){ s4=false; } } if(i<2*tam-1){ if(!(s[i]==s[i+1] || s[i]==-s[i+1])){ s3=false; } } if(s[i]<0){ if(i%2!=0){ xd_ne.push_back(i); } }else{ if(i%2==0){ xd_po.push_back(i); } } } if(s4){ x=tam; x*=tam-1; x/=2; return x; }else if(s3){ for(int i=0;i<xd_po.size();i++){ if(xd_po[i]>xd_ne[i]){ x+=xd_po[i]-xd_ne[i]; }else{ x+=xd_ne[i]-xd_po[i]; } } return x; }else{ while(!s.empty()){ int temp=s[0]; if(temp<0){ for(int i=1;i<s.size();i++){ if(s[i]==-temp){ x+=i-1; s.erase(s.begin()+i); break; } } s.erase(s.begin()); }else{ for(int i=1;i<s.size();i++){ if(s[i]==-temp){ x+=i; s.erase(s.begin()+i); break; } } s.erase(s.begin()); } } return x; } }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:39:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |         for(int i=0;i<xd_po.size();i++){
      |                     ~^~~~~~~~~~~~~
shoes.cpp:51:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |                 for(int i=1;i<s.size();i++){
      |                             ~^~~~~~~~~
shoes.cpp:60:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |                 for(int i=1;i<s.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...