# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1145673 | MunkhturErdenebat | Arranging Shoes (IOI19_shoes) | C++20 | 1095 ms | 2632 KiB |
#include "shoes.h"
#include <bits/stdc++.h>
using namespace std;
long long count_swaps(vector<int> s) {
int a = s.size();
vector<int> maa(a, 0); // Initialize array with 0
long long h = 0;
for(int i = 0; i < a; i++) {
if(maa[i] == 1) continue;
int g = -1;
for(int j = i + 1; j < a; j++) {
if(s[j] + s[i] == 0 && maa[j] == 0) {
g = j;
break;
}
}
if (g == -1) continue;
if(s[i]>0){
h++;
}
for(int j = g - 1; j > i; j--) {
if(maa[j] == 0) h++;
}
maa[g] = 1; // Mark the index as used
# | 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... |