Submission #1077484

#TimeUsernameProblemLanguageResultExecution timeMemory
1077484IgnutArranging Shoes (IOI19_shoes)C++17
30 / 100
1092 ms5948 KiB
// Ignut #include <bits/stdc++.h> using namespace std; using ll = long long; const int INF = 1e9 + 123; ll count_swaps(vector<int> S) { ll res = INF; int n = S.size(); vector<int> vec = S; sort(vec.begin(), vec.end()); for (int i = 1; i <= n / 2; i ++) vec.pop_back(); do { vector<int> s = S; vector<int> t; for (int val : vec) { t.push_back(val); t.push_back(-val); } int ans = 0; for (int i = 0; i < n; i ++) { int j; for (j = i; j < n; j ++) if (s[j] == t[i]) break; while (j > i) { swap(s[j - 1], s[j]); j --; ans ++; } } // for (int val : t) cout << val << ' '; // cout << " : " << ans << '\n'; res = min(res, 1ll * ans); } while (next_permutation(vec.begin(), vec.end())); return res; }
#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...