Submission #148620

#TimeUsernameProblemLanguageResultExecution timeMemory
148620nandonathanielArranging Shoes (IOI19_shoes)C++14
10 / 100
32 ms1932 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; long long count_swaps(vector<int> s) { int kecil,besar; for(int i=0;i<s.size();i++){ if(s[i]<0)kecil=s[i]; else besar=s[i]; } int ans=0; for(int i=0;i<s.size();i++){ if(i%2==0){ if(s[i]!=kecil)ans++; } else{ if(s[i]!=besar)ans++; } } ans/=2; return ans;; }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:7:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<s.size();i++){
              ~^~~~~~~~~
shoes.cpp:12:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<s.size();i++){
              ~^~~~~~~~~
shoes.cpp:17:4: warning: 'besar' may be used uninitialized in this function [-Wmaybe-uninitialized]
    if(s[i]!=besar)ans++;
    ^~
shoes.cpp:14:4: warning: 'kecil' may be used uninitialized in this function [-Wmaybe-uninitialized]
    if(s[i]!=kecil)ans++;
    ^~
#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...