# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
889473 | Lincito_31 | Arranging Shoes (IOI19_shoes) | C++14 | 16 ms | 2520 KiB |
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"
using namespace std;
long long x=0;
long long count_swaps(vector<int> s) {
bool s3=true;
bool s4=true;
vector<int> xd_po;
vector<int> xd_ne;
int tam=s.size();
tam/=2;
for(int i=0;i<tam;i++){
if(s[i]!=-s[tam+i]){
s4=false;
}
if(!(s[i]==s[i+1] || s[i]==-s[i+1])){
s3=false;
}
if(s[i]<0){
if(i%2!=0){
xd_ne.push_back(i);
}
}else{
if(i%2==0){
xd_po.push_back(i);
}
}
}
for(int i=tam;i<2*tam;i++){
if(i<2*tam-1){
if(!(s[i]==s[i+1] || s[i]==-s[i+1])){
s3=false;
}
}
if(s[i]<0){
if(i%2!=0){
xd_ne.push_back(i);
}
}else{
if(i%2==0){
xd_po.push_back(i);
}
}
}
if(s4){
x=tam;
x*=tam-1;
x/=2;
}else if(s3){
for(int i=0;i<xd_po.size();i++){
if(xd_po[i]>xd_ne[i]){
x+=xd_po[i]-xd_ne[i];
}else{
x+=xd_ne[i]-xd_po[i];
}
}
}else{
while(!s.empty()){
int temp=s[0];
if(temp<0){
for(int i=1;i<s.size();i++){
if(s[i]==-temp){
x+=i-1;
s.erase(s.begin()+i);
break;
}
}
s.erase(s.begin());
}else{
for(int i=1;i<s.size();i++){
if(s[i]==-temp){
x+=i;
s.erase(s.begin()+i);
break;
}
}
s.erase(s.begin());
}
}
}
return x;
}
Compilation message (stderr)
# | 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... |