이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include "shoes.h"
using namespace std;
#define all(x) x.begin(), x.end()
#define pb push_back
#define ll long long
#define vout(v) for(int i=0; i<v.size(); i++) cout<<v[i]<<' ';
int tt[10];
long long count_swaps(vector<int> a){
int n = a.size();
if(n == 2){
if(a[0] > 0){
return 1;
}
else{
return 0;
}
}
if(false){
vector<int> q, qq;
for(int i=0; i<n; i++){
qq.pb(a[i]);
}
sort(all(qq));
for(int i=0; i<n/2; i++){
q.pb(abs(qq[i]));
}
sort(all(q));
ll ans=1e18;
//vout(q);
do{
for(int i=0; i<n; i++){
qq[i] = a[i];
}
ll res=0;
//ll k=0;
for(int i=0; i<n/2; i++){
for(int j=i * 2; j<n; j++){
if(qq[j] == -q[i]){
for(int k=j; k>i * 2; k--){
swap(qq[k], qq[k-1]);
res++;
}
break;
}
}
for(int j=i * 2 + 1; j<n; j++){
if(qq[j] == q[i]){
for(int k=j; k>i * 2 + 1; k--){
swap(qq[k], qq[k-1]);
res++;
}
break;
}
}
}
ans = min(ans, res);
}while(next_permutation(all(q)));
return ans;
}
int ok1 = 1, k1=abs(a[0]);
for(int i=1; i<n; i++){
if(k1 != abs(a[i])) ok1 = 0;
}
if(ok1){
int ls = 1;
int ans=0;
for(int i=0; i<n; i++){
if(a[i] > 0){
ans += abs(i - ls);
ls += 2;
}
}
return ans;
}
return 0;
}
| # | 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... |