This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <limits>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
using namespace std;
using ll = long long;
int64_t count_swaps(vector<int> shoes){
ll length = shoes.size();
vector<bool> list_n(length, 0);
ll total = 0;
for(int i = 0; i < length; i++){
if(list_n[i] == 1){
continue;
}
ll curr_counter = 0;
ll curr_val = shoes[i];
if(curr_val > 0){
curr_counter++;
}
for(int j = i + 1; j < length; j++){
//cout << curr_counter << ", i = " << i << ", j = " << j << endl;
if(shoes[j] == -1 * curr_val && list_n[j] == 0){
list_n[j] = 1;
break;
}else{
if(list_n[j] == 0){
curr_counter++;
}
}
}
list_n[i] = 1;
//cout << "curr_counter = " << curr_counter << ", i = " << i << endl;
total += curr_counter;
/*for(int k = 0; k < length; k++){
cout << list_n[k] << " ";
}
cout << endl;
*/
}
return total;
}
# | 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... |