Submission #428120

#TimeUsernameProblemLanguageResultExecution timeMemory
428120HazemArranging Shoes (IOI19_shoes)C++14
10 / 100
1092 ms1860 KiB
#include "shoes.h" #include <bits/stdc++.h> #define LL long long using namespace std; long long count_swaps(std::vector<int> s) { LL n = s.size()/2,ans = 0; int cnt = 0; for(int i=0;i<n*2;i++){ if(s[i]<0){ for(int j=i;j>cnt*2;j--) swap(s[j],s[j-1]),ans++; int idx = find(s.begin()+cnt*2,s.end(),-s[cnt*2])-s.begin(); assert(idx>cnt*2); for(int j = idx;j>cnt*2+1;j--) swap(s[j],s[j-1]),ans++; cnt++; } } return 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...