This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/****Bismillahir rahmanir rahim****/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
#define All(a) a.begin(),a.end()
template <typename T>
void get_vector(T &a)
{
for(auto &e: a) cin >> e;
}
template <typename T>
void put_vector(T a)
{
for(auto e :a)cout << e << " ";
cout << endl;
}
int count_swaps(vector<int> S)
{
int n = S.size();
vector<bool>check(n);
int ans = 0;
for(int i = 0; i<n; i++){
if(check[i])continue;
check[i] = 1;
int x = 0;
if(S[i]>0)x++;
for(int j= i+1; j<n; j++){
if(S[j]==S[i]*(-1)){
check[j] = 1;
ans+=x;
break;
}
if(check[j])continue;
x++;
}
}
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... |