# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
984510 | SzymonKrzywda | Arranging Shoes (IOI19_shoes) | C++17 | 1050 ms | 3252 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>
using namespace std;
const int base = 2<<18;
int tree[base*2+7];
void edit(int n){
n+=base;
while (n>0){
tree[n] += 1;
n/=2;
}
}
int query(int a,int b){
a+=base-1;
b+=base+1;
int wynik=0;
while (a/2 != b/2){
if (a%2==0) wynik += tree[a+1];
if (b%2==1) wynik += tree[b-1];
a/=2;
b/=2;
}
return wynik;
}
long unsigned int count_swaps(vector<int>S){
long unsigned int wynik = 0,len=S.size(),idx_1,akt_liczba;
for (long unsigned int i=0; i<len; i+=2){
for (long unsigned int j=i; j<len; j++){
if (S[j]<0){
idx_1 = j;
akt_liczba = -S[j];
break;
}
}
for (int j=idx_1; j>i; j--){
swap(S[j],S[j-1]);
wynik+=1;
}
for (long unsigned int j=i+1; j<len; j++){
if (S[j]==akt_liczba){
idx_1 = j;
break;
}
}
for (int j=idx_1; j>i+1; j--){
swap(S[j],S[j-1]);
wynik +=1;
}
}
//cout << S[0] << " " << S[1] << " " << S[2] << " " << endl;
return wynik;
}
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... |