Submission #314572

#TimeUsernameProblemLanguageResultExecution timeMemory
314572baibhav26062008Arranging Shoes (IOI19_shoes)C++14
0 / 100
1 ms256 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; ll count_swaps(std::vector<int> s) { int n = s.size()/2; ll ans,found; for(ll i=0;i<2*n;i+=2) { for(ll j=i+1;j<2*n;j++) { if(abs(s[j])==abs(s[i])) found=j; if (s[j] > s[i]) ans++; } for(ll j=found;j>=i+1;j--) swap(s[j],s[j-1]); ans+= (found - i - 1); } return ans; }

Compilation message (stderr)

shoes.cpp: In function 'll count_swaps(std::vector<int>)':
shoes.cpp:20:9: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   20 |  return ans;
      |         ^~~
shoes.cpp:7:9: warning: 'found' may be used uninitialized in this function [-Wmaybe-uninitialized]
    7 |  ll ans,found;
      |         ^~~~~
#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...