Submission #201541

#TimeUsernameProblemLanguageResultExecution timeMemory
201541s_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++){ der = false; if(s[i] > 0) der = true; int pos = s.size() + 1; 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(pos == i + 1 && !der){ i += 2; continue; } if(pos == s.size() + 1) continue; 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:12:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j = i+1; j < s.size(); j++){
                          ~~^~~~~~~~~~
shoes.cpp:23:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(pos == s.size() + 1) continue;
            ~~~~^~~~~~~~~~~~~~~
#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...