Submission #201540

#TimeUsernameProblemLanguageResultExecution timeMemory
201540s_avila_gArranging Shoes (IOI19_shoes)C++14
10 / 100
5 ms376 KiB
#include <bits/stdc++.h> #include "shoes.h" using namespace std; long long count_swaps(std::vector<int> s) { bool der = false; int ans = 0; for(int i = 0 ; i < s.size(); i++){ if(s[i] > 0) der = true; int pos = 0; for(int j = i+1; j < s.size(); j++){ if(abs(s[i] == abs(s[j]))){ pos = j; s.erase(s.begin() + j); break; } } if(der) ans += abs(i - pos); else ans += abs(i - pos) - 1; } return ans; }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:8:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0 ; i < s.size(); i++){
                     ~~^~~~~~~~~~
shoes.cpp:11:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j = i+1; j < s.size(); j++){
                          ~~^~~~~~~~~~
#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...