Submission #368101

#TimeUsernameProblemLanguageResultExecution timeMemory
368101leinad2Arranging Shoes (IOI19_shoes)C++17
10 / 100
1086 ms2668 KiB
#include "shoes.h" #include<bits/stdc++.h> using namespace std; long long count_swaps(vector<int>s) { long long ans=0; int i, j; for(i=0;i<s.size();i++) { if(i%2==0) { if(s[i]<0)continue; for(j=i+1;j<s.size();j++) { if(s[j]<0)break; } while(j>i) { swap(s[j], s[j-1]); ans++; j--; } } else { if(s[i]==-s[i-1])continue; for(j=i+1;j<s.size();j++) { if(s[j]==-s[i-1])break; } while(j>i) { swap(s[j], s[j-1]); ans++; j--; } } } return ans; }

Compilation message (stderr)

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