Submission #152511

#TimeUsernameProblemLanguageResultExecution timeMemory
152511petar_vitoracArranging Shoes (IOI19_shoes)C++14
50 / 100
1051 ms1920 KiB
#include "shoes.h" #include <bits/stdc++.h> bool negative(int x){ if(abs(x)==x){ return false; } else{ return true; } } long long count_swaps(std::vector<int> s) { //int n=s.size()/2; int result=0; for(int i=0;i<s.size()-1;i++){ int found=-1; int j=i+1; while(found==-1){ if(s[j]==-s[i]){ found=j; } j++; } if(negative(s[i])){ result+=(found-i-1); } else{ result+=(found-i); } s.erase(s.begin()+found); } return result; }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:18:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<s.size()-1;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...