Submission #1320156

#TimeUsernameProblemLanguageResultExecution timeMemory
1320156marzuq01Arranging Shoes (IOI19_shoes)C++20
0 / 100
0 ms332 KiB
#include "shoes.h"
#include <bits/stdc++.h>
using namespace std;
long long count_swaps(std::vector<int> s) {
	long long int n2 = s.size();
	int count = 0;
	vector<int> checked(n2);
	for (int i = 0; i < n2;i++) {
        checked[i] = 0;
	}
	int l = 0;

	while(l < n2) {
        if (checked[l] == 1) {l++;continue;}
        int tk = 0;
        for (int r = l+1;r < n2;r++) {
            if (checked[r] == 1) {tk++;continue;}
            if (s[l] + s[r] == 0) {
                count += r-l-tk + (s[r] < 0);
                checked[l] = 1; checked[r] = 1;
            }
        }
        l++;
	}
	return count;
}
#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...