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;
const int MAXN = 1e5;
deque<int> d[2*MAXN];
int sh[MAXN];
bitset<MAXN> v;
long long count_swaps(vector<int> s) {
int N=s.size();
long long ans=0;
for(int i=0;i<N;i+=2){
int j=i+1;
for(;j<N;j++)if(s[j]+s[i]==0)break;
for(int k=j;k>=i+2;k--)swap(s[k],s[k-1]),ans++;
if(s[i]>s[i+1])swap(s[i],s[i+1]),ans++;
}
return ans;
}
# | 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... |