Submission #235796

#TimeUsernameProblemLanguageResultExecution timeMemory
235796AASGArranging Shoes (IOI19_shoes)C++17
10 / 100
1099 ms3200 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; long long count_swaps(vector<int> s) { long long r=0; while(s.size()>0){ for(long l=1;l<s.size();l++){ if(abs(s[0])==abs(s[l]) && (s[0]>0 && s[l]<0) || (s[0]<0 && s[l]>0)){ if(s[l]>0)r=r+l-1; else r=r+l; s.erase(s.begin()+l); s.erase(s.begin()); break; } } } return r; }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:7:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(long l=1;l<s.size();l++){
                      ~^~~~~~~~~
shoes.cpp:8:37: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
             if(abs(s[0])==abs(s[l]) && (s[0]>0 && s[l]<0) || (s[0]<0 && s[l]>0)){
                ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
#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...