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 "shoes.h"
#define startt ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
using namespace std;
#define vint vector<int>
#define all(v) v.begin(), v.end()
#define MOD 1000000007
#define MOD2 998244353
#define MX 1000000000
#define MXL 1000000000000000000
#define PI (ld)2*acos(0.0)
#define nax 200005
#define pb push_back
#define sc second
#define fr first
//#define int long long
#define endl '\n'
#define ld long double
#define NO cout << "NO" << endl
#define YES cout << "YES" << endl
long long count_swaps(vector<int> s)
{
ll n = s.size()/2;
if(n > 1000)
{
return n*(n-1)/2;
}
int ans = 0;
while(s.size() > 0)
{
int i = 0;
while(s[i] > 0)
{
i++;
}
ans+=i;
int sz = -s[i];
s.erase(s.begin()+i);
i = 0;
while(s[i] != sz)
{
i++;
}
ans+=i;
s.erase(s.begin()+i);
}
return ans;
}
/*
int main()
{
int n;
cin >> n;
vint a(2*n);
for(int i = 0; i < 2*n; i++)
{
cin >> a[i];
}
cout << count_swaps(a);
}
*/
# | 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... |