This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#include "shoes.h"
const int N = 300000;
long long count_swaps(std::vector<int> s) {
int n = s.size();
int cnt = 0;
for(int i = 0; i < n;i+=2){
int k = -69;
for(int j = i+1; j < n;j++){
if(s[i] == -s[j]){k = j;break;}
}
// printf("for %d, we found %d\n",i,k);
while(k != i+1){
swap(s[k],s[k-1]);
k--;
cnt++;
}
if(s[i] > 0){
swap(s[i],s[i+1]);cnt++;
}
}
return cnt;
}
// int main() {
// int n;
// scanf("%d", &n);
// vector<int> S(2 * n);
// for(int i = 0; i < 2 * n; i++)
// scanf("%d", &S[i]);
// long long result = count_swaps(S);
// printf("%lld\n", result);
// return 0;
// }
# | 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... |