Submission #153723

#TimeUsernameProblemLanguageResultExecution timeMemory
153723redaArranging Shoes (IOI19_shoes)C++14
50 / 100
1072 ms3448 KiB
#include<bits/stdc++.h>
using namespace std ;
long  long count_swaps (vector<int>s)
{
  int  n = s.size();
      long long  ans = 0 ;
      for(int i = 0 ;i < s.size();i+=2)
      {
        int j = i+1;
        while(s[i]!=-s[j])
        {
            j++;
        }
        while (j!=i+1)
        {
            swap(s[j],s[j-1]);
            ans++;
            j--;
        }
        if(s[j]<0)
        {
            swap(s[i],s[j]);
            ans++;
        }
      }
      return ans;
  }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:7:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       for(int i = 0 ;i < s.size();i+=2)
                      ~~^~~~~~~~~~
shoes.cpp:5:8: warning: unused variable 'n' [-Wunused-variable]
   int  n = s.size();
        ^
#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...