| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1369788 | altayeb_132 | Arranging Shoes (IOI19_shoes) | C++20 | 0 ms | 344 KiB |
#include<bits/stdc++.h>
using namespace std;
long long count_swaps(vector<int> s) {
int n = s.size();
int vis[n] = {};
int ans = 0;
for (int i = 0; i < n; i++) {
for (int j = i - 1; j >= 0; j--) {
if (s[j] == -s[i] && !vis[j]) {
for (int k = j; k < i - 1; k++) {
swap(s[k], s[k + 1]);
}
ans += i - j;
if (s[j] < 0) {
ans--;
swap(s[i - 1], s[i]);
}
vis[i] = 1;
vis[j] = 1;
break;
}
}
}
return ans;
}
#include "shoes.h"
// int main() {int n;assert(1 == scanf("%d", &n));vector<int> S(2 * n);for (int i = 0; i < 2 * n; i++)assert(1 == scanf("%d", &S[i]));fclose(stdin);long long result = count_swaps(S);printf("%lld\n", result);fclose(stdout);return 0;}| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
