Submission #201546

#TimeUsernameProblemLanguageResultExecution timeMemory
201546s_avila_gArranging Shoes (IOI19_shoes)C++14
10 / 100
5 ms376 KiB
#include <bits/stdc++.h> #include "shoes.h" using namespace std; long long count_swaps(std::vector<int> s) { bool der = false; int ans = 0; int n = s.size(); for(int i = 0 ; i < n; i++){ der = false; if(s[i] > 0) der = true; int pos = INT_MAX; int m = s.size(); for(int j = i+1; j < m; j++){ if(abs(s[i]) == abs(s[j])){ pos = j; s.erase(s.begin() + j); break; } } //cout<<i<<" "<<pos<<endl; if(pos == INT_MAX) continue; if(der && pos == i+1){ ans += 1; continue; } if(pos == i + 1 && !der){ i += 2; continue; } if(der) ans += abs(i - pos); else ans += abs(i - pos) - 1; } 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...