Submission #185301

#TimeUsernameProblemLanguageResultExecution timeMemory
185301RiscadoAArranging Shoes (IOI19_shoes)C++14
10 / 100
3 ms504 KiB
#include "shoes.h" long long count_swaps(std::vector<int> s) { int c = 0; for (int i = 0; i < s.size() - 1; ++i) { int j = i + 1; for (; j < s.size(); ++j) { if (s[j] == -s[i]) { break; } } s.erase(s.begin() + j); if (s[i] < 0) { c += j - i - 1; s.insert(s.begin() + i + 1, -s[i]); } else { c += j - i; s.insert(s.begin() + i, -s[i]); } } return c; }

Compilation message (stderr)

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