Submission #411989

#TimeUsernameProblemLanguageResultExecution timeMemory
411989dolijanArranging Shoes (IOI19_shoes)C++14
10 / 100
515 ms1048580 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; long long cnt=0; void resi(int l,int r,int n,std::vector<int> s) { if(l>=r) return; int prva=s[l]; for(int i=l+1;i<=r;i++) { if(s[i]==(prva*(-1))) { if(prva<0) { cnt+=(i-(l+1)); swap(s[i],s[l+1]); } else { cnt+=(i-l); swap(s[i],s[l+1]); swap(s[l],s[l+1]); } break; } } resi(l+2,r,n,s); } long long count_swaps(std::vector<int> s) { int n=s.size(); int l=0; int r=n-1; resi(l,r,n,s); return cnt; }
#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...