| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1187093 | GoBananas69 | Arranging Shoes (IOI19_shoes) | C++20 | 1096 ms | 1964 KiB |
#include <algorithm>
#include <cmath> // for std::abs
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
ll count_swaps(vector<int> s) {
int m = s.size();
ll res = 0;
for (int i = 0; i < m; i += 2) {
int k = abs(s[i]);
int idx_neg = -1;
for (int j = i; j < m; ++j) {
if (s[j] == -k) {
idx_neg = j;
break;
}
}
res += idx_neg - i;
for (int j = idx_neg; j > i; --j) {
swap(s[j], s[j - 1]);
}
int idx_pos = -1;
for (int j = i + 1; j < m; ++j) {
if (s[j] == k) {
idx_pos = j;
break;
}
}
res += idx_pos - (i + 1);
for (int j = idx_pos; j > i + 1; --j) {
swap(s[j], s[j - 1]);
}
}
// for (int x : s) {
// cout << x << ' ';
// }
// cout << '\n';
return res;
}| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
