| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1177767 | alwaus424 | Arranging Shoes (IOI19_shoes) | C++17 | 0 ms | 324 KiB |
#include <bits/stdc++.h>
using namespace std;
int64_t count_swaps(vector<int> S) {
int n = S.size() / 2;
vector<int> misplaced_pos, misplaced_neg;
// Identify misplaced elements
for (int i = 0; i < 2 * n; i++) {
if (i % 2 == 0 && S[i] == -1) misplaced_neg.push_back(i); // Should be positive
if (i % 2 == 1 && S[i] > 0) misplaced_pos.push_back(i); // Should be negative
}
// The number of swaps is the sum of absolute differences
int64_t swaps = 0;
for (int i = 0; i < misplaced_pos.size(); i++) {
swaps += abs(misplaced_pos[i] - misplaced_neg[i]);
}
return swaps;
}
| # | 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... | ||||
