# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
717504 | josanneo22 | Arranging Shoes (IOI19_shoes) | C++17 | 1081 ms | 2636 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 <deque>
#include <iostream>
using namespace std;
long long count_swaps(std::vector<int> s) {
int n = s.size();
bool sub4=true;
for(int i=0;i<n;i++){
if(s[i]>0) sub4=false;
}
for(int i=n;i<2*n;i++){
if(s[i]<0) sub4=false;
}
if(n == 1){
if(s[0] < 0) return 0;
else return 1;
}
else if(sub4){
long long swaps = 0;
for(int i = 0; i < n; i++) swaps += i;
return swaps;
}
else{
long long count = 0;
deque<int> sc(s.size());
for(int i = 0; i<s.size(); i++)sc[i] = s[i];
while(!sc.empty())
{
int x = sc.front();
sc.pop_front();
int pos = 0;
for(int i = 0; i<sc.size(); i++)
{
if(sc[i] == x*-1)
{
pos = i;
break;
}
}
count+=pos+1;
if(x < 0)count--;
sc.erase(sc.begin()+pos);
}
return count;
}
return 0;
}
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... |