Submission #226073

#TimeUsernameProblemLanguageResultExecution timeMemory
226073AaronNaiduArranging Shoes (IOI19_shoes)C++14
50 / 100
1096 ms3200 KiB
#include <bits/stdc++.h> using namespace std; int n; long long counter = 0; long long count_swaps(vector<int> s) { n = s.size()/2; for (int i = 0; i < n; i++) { int x = -s[2 * i]; int pos = -1; for (int j = 2 * i + 1; j < 2 * n; j++) { if (s[j] == x) { pos = j; break; } } for (int j = pos; j > 2 * i + 1; j--) { swap(s[j], s[j-1]); counter++; } if (x < 0) { counter++; } //cout << "After pair " << i << " count is " << counter << "\n"; } return counter; }
#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...