Submission #601670

#TimeUsernameProblemLanguageResultExecution timeMemory
601670chirathnirodhaArranging Shoes (IOI19_shoes)C++17
50 / 100
1080 ms1876 KiB
#include "shoes.h" #include<bits/stdc++.h> using namespace std; #define MP make_pair #define PB push_back long long count_swaps(vector<int> s){ int ans=0; int n=s.size()/2; for(int i=0;i<2*n;i+=2){ if(s[i]<0 && s[i]==-s[i+1])continue; int pos; for(int j=i+1;j<2*n;j++){ if(s[i]==-s[j]){pos=j;break;} } for(int j=pos;j>i+1;j--){ swap(s[j],s[j-1]); ans++; } if(s[i]<0)continue; swap(s[i],s[i+1]); ans++; } return ans; }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:17:12: warning: 'pos' may be used uninitialized in this function [-Wmaybe-uninitialized]
   17 |    swap(s[j],s[j-1]);
      |            ^
#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...