Submission #631758

#TimeUsernameProblemLanguageResultExecution timeMemory
631758StavabArranging Shoes (IOI19_shoes)C++14
50 / 100
1088 ms3112 KiB
#include <vector> using namespace std; long long count_swaps(vector<int> S) { long long sum = 0; int temp; for(int i = 0; i < S.size() - 1; i += 2) { temp = 0; for(int j = i + 1; j < S.size(); j++) { if(temp) swap(temp, S[j]); else temp = S[j]; if(temp == -S[i]) { if(temp < 0) sum += j - i; else sum += j - i - 1; break; } } } return sum; }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:10:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for(int i = 0; i < S.size() - 1; i += 2)
      |                    ~~^~~~~~~~~~~~~~
shoes.cpp:13:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |         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...