# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
769186 | Andrey | Arranging Shoes (IOI19_shoes) | C++14 | 0 ms | 0 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 <bits/stdc++.h>
using namespace std;
long long haha[200001][19];
void add(long long a) {
for(long long i = 0; i < 19; i++) {
a-=(a%(1 << i));
haha[a][i]++;
}
}
long long calc(long long a, long long b) {
long long j = 0;
long long ans = 0;
while(a < b) {
j = 0;
while(a%(1 << j) == 0 && a+(1 << j) <= b) {
j++;
}
j--;
ans+=haha[a][j];
a+=(1 << j);
}
return ans+haha[b][0];
}
long long count_swaps(int[] s) {
const long long y = 100000;
long long n = (*(&s + 1) - s)/2,p,a,ans = 0;