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 "shoes.h"
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
#define dl double long
using namespace std;
const int NN = 1e9 + 7;
const int N = 2e6 + 7;
const int M = 26;
const ll mod = 1e9 + 7;
const ll inf = 1e18 + 7;
const dl rf = 1e-14;
const int B = sqrt(N);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int d[N];
void upd( int x , int y )
{
while( x < N ){
d[x] += y;
x += x & -x;
}
}
int get( int x )
{
int cnt = 0;
while( x > 0 ){
cnt += d[x];
x -= x & -x;
}
return cnt;
}
long long count_swaps(vector<int> s)
{
int n = (int)s.size();
ll ans = 0;
map < int , vector < int > > m;
for( int i = 0; i < n; i += 2 ){
for( int j = i; j < n; j++ ){
if( -s[i] == s[j] ){
for( int h = j; h > i + (s[i] < 0); h-- ){
swap( s[h] , s[h - 1] );
ans += 1;
}
break;
}
}
}
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... |