# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
959442 | NemanjaSo2005 | Arranging Shoes (IOI19_shoes) | C++17 | 17 ms | 3164 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>
#define ll long long
using namespace std;
const int maxn=2e5+5;
ll N,niz[maxn];
ll res=0;
int prvalev(){
for(int i=1;i<=N;i++)
if(niz[i]<0)
return i;
}
int parod(int x){
for(int i=1;i<=N;i++)
if(niz[i]==-x)
return i;
}
void zamena(int y,int x){
for(int i=y;i>x;i--){
res++;
swap(niz[i],niz[i-1]);
}
}
ll count_swaps(vector<int> s) {
N=s.size();
N/=2;
return N*(N-1)/2;
for(int i=0;i<N;i++)
niz[i+1]=s[i];
for(int i=1;i<=N;i+=2){
int pl=prvalev();
zamena(pl,i);
int pd=parod(niz[i]);
// cout<<pl<<" "<<pd<<endl;
zamena(pd,i+1);
niz[i]=niz[i+1]=0;
}
return res;
}
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... |