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>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define pb push_back
#define popb pop_back
#define ff first
#define ss second
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
ll count_swaps(vi s)
{
int n =s.size()/2;
if(n == 1)
{
if(s[0] <= 0)
return 0;
else
return 1;
}
else
{
queue<int> pos[n+1];
ll ans = 0;
for(int i = n; i < 2 *n; i ++)
{
pos[s[i]].push(i);
}
for(int i= 0; i < n; i ++)
{
ans += pos[-s[i]].front() - 2 * i - 1;
pos[-s[i]].pop();
}
return ans;
}
return 1;
}
# | 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... |