Submission #1165839

#TimeUsernameProblemLanguageResultExecution timeMemory
1165839SG2AlokArranging Shoes (IOI19_shoes)C++20
10 / 100
1093 ms1860 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; long long count_swaps(std::vector<int> s) { long long ans = 0; for(int i = 0; i < s.size(); i++){ if(s[i] < 0){ int pos = -1; for(int j = i + 1; j < s.size(); j++){ if(s[j] == -s[i]){ pos = j; break; } } while(pos > i + 1){ swap(s[pos], s[pos - 1]); pos--; ans++; } i++; } else if(s[i] > 0){ int pos = -1; for(int j = i + 1; j < s.size(); j++){ if(s[j] == -s[i]){ pos = j; break; } } while(pos > i){ swap(s[pos], s[pos - 1]); pos--; ans++; } } } 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...