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>
#include <deque>
#include <cmath>
using namespace std;
#define ll long long
/*freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);*/
long long m , s1 , s2 , y ;
long long count_swaps ( vector < int > s ) {
long long n = s . size ( ) ;
if ( n == 2 ) {
if ( s [ 0 ] < s [ 1 ] ) return 0 ;
else return 1 ;
}
long long x = 0 ;
for ( long long i = 1 ; i < n ; i ++ ) {
if ( abs ( s [ i ] ) == abs ( s [ 0 ] ) ) x ++ ;
}
if ( x + 1 == n ) {
long long y = 0 ;
long long z = 0 ;
for ( long long i = 0 ; i < n ; i ++ ) {
if ( s [ i ] < 0 ) {
z += abs ( i - y ) ;
y += 2 ;
}
}
return z ;
}
if ( n <= 2000 ) {
for ( int i = 0 ; i < n ; i += 2 ) {
for ( int j = i + 1 ; j < n ; j ++ ) {
if ( ( -1 ) * s [ i ] == s [ j ] ) {
for ( int l = j ; l >= i + 2 ; l -- ) {
y = s [ l ] ;
s [ l ] = s [ l - 1 ] ;
s [ l - 1 ] = y ;
x ++ ;
}
break;
}
}
if ( s [ i ] > s [ i + 1 ] ) {
x ++ ;
}
}
return x ;
}
x = ( n / 2 ) * ( n / 2 - 1 ) / 2 ;
return x ;
}
# | 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... |