# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1061885 | Petrix | Arranging Shoes (IOI19_shoes) | C++17 | 1 ms | 348 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 <iostream>
#include <vector>
#include <map>
#include <deque>
#include "shoes.h"
using namespace std;
long long count_swaps(vector<int> s){
int n=s.size();
map<int,deque<int>> np;
vector<int> a;
long long i,j,aux,rasp=0;
for(i=0;i<n;i++){
if(np[-s[i]].empty()){
np[s[i]].push_back(j);
for (j=i+1;j<=n;j+=(i+1)&(-(i+1)))
a[j]++;
}else{
aux=np[-s[i]].front();np[-s[i]].pop_front();
rasp+=i;
for(j=aux;j;j-=aux&(-aux))
rasp-=a[j];
if(s[i]<0) rasp++;
for(j=aux;j<=n;j+=aux&(-aux))
a[j]++;
}
}
return rasp;
}
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... |