Submission #415228

#TimeUsernameProblemLanguageResultExecution timeMemory
415228peuchArranging Shoes (IOI19_shoes)C++17
10 / 100
1087 ms3240 KiB
#include "shoes.h" #include<bits/stdc++.h> using namespace std; long long count_swaps(std::vector<int> s) { long long ans = 0; for(int i = 0; i < s.size(); i++){ for(int j = i; j < s.size(); j++){ if(s[j] < 0){ while(j > i){ swap(s[j], s[j - 1]); j--; ans++; } break; } } int val = abs(s[i]); i++; for(int j = i; j < s.size(); j++){ if(s[j] == val){ while(j > i){ swap(s[j], s[j - 1]); j--; ans++; } break; } } } // for(int i = 0; i < s.size(); i++){ // printf("%d ", s[i]); // } // printf("\n"); return ans; }

Compilation message (stderr)

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