Submission #431865

#TimeUsernameProblemLanguageResultExecution timeMemory
431865JUANDI321Arranging Shoes (IOI19_shoes)C++17
50 / 100
1022 ms3948 KiB
#include "shoes.h" #include <vector> #include <deque> #include <iostream> using namespace std; long long count_swaps(vector<int> s) { long long count = 0; deque<int> sc(s.size()); for(int i = 0; i<s.size(); i++)sc[i] = s[i]; while(!sc.empty()) { int x = sc.front(); sc.pop_front(); int pos = 0; for(int i = 0; i<sc.size(); i++) { if(sc[i] == x*-1) { pos = i; break; } } count+=pos+1; if(x < 0)count--; sc.erase(sc.begin()+pos); } return count; }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:11:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |  for(int i = 0; i<s.size(); i++)sc[i] = s[i];
      |                 ~^~~~~~~~~
shoes.cpp:17:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |   for(int i = 0; i<sc.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...