# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
895800 | ozner77 | Arranging Shoes (IOI19_shoes) | C++17 | 15 ms | 3676 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 "shoes.h"
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <string>
using namespace std;
long long count_swaps(std::vector<int> s) {
int a,b,c,d,e=s.size(),xd=-1,jsjs=0;
bool fua=true;
long long swaps=0;
a=s[0];
b=s[0];
for(int k=0;k<e;k+=2){
a=s[k];
b=s[k];
for(int i=k;i<e;i++){
if(s[i]<0){
jsjs++;
while(true){
xd++;
if(s[i+xd]+s[i]==0){
fua=false;
break;
}else if(i-xd==k){
break;
}else if(s[i-xd]+s[i]==0 && i-xd>=k+1){
swaps++;
fua=false;
break;
}
}
if(!fua && jsjs==s.size()/2){
fua=true;
}
if(fua){
swaps++;
if(s[i]==s[k]){
swaps--;
}
s[k]=s[i];
s[i]=a;
c=s[k+1];
d=s[k+1];
for(int j=k+1;j<e;j++){
if(s[j]+s[k]==0){
swaps++;
if(s[j]==s[k+1]){
swaps--;
}
s[k+1]=s[j];
s[j]=c;
break;
}else if(i>=k+2){
swaps++;
d=s[j];
s[j]=c;
c=d;
}
}
break;
}
}else if(i>=k+1){
swaps++;
b=s[i];
s[i]=a;
a=b;
}
}
}
return swaps;
}
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... |