제출 #722864

#제출 시각아이디문제언어결과실행 시간메모리
722864GrandTiger1729Arranging Shoes (IOI19_shoes)C++17
30 / 100
1096 ms4676 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; long long count_swaps(vector<int> s){ auto a = s; int N = a.size(), n = N / 2; vector<int> b; for (int i = 0; i < N; i++) if (a[i] < 0) b.push_back(a[i]); sort(b.begin(), b.end()); long long ans = 1ll * N * N; do { long long cnt = 0; vector<int> c(N); for (int i = 0; i < n; i++) c[2 * i] = b[i], c[2 * i + 1] = -b[i]; vector<int> aa = a; for (int i = 0; i < N; i++){ int j = i; while (j < N && aa[j] != c[i]) j++; while (j > i){ swap(aa[j], aa[j - 1]); j--; cnt++; } } ans = min(ans, cnt); }while (next_permutation(b.begin(), b.end())); 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...