|
|
back to boardfenwick tree rulezzz!!! :-) Re: fenwick tree rulezzz!!! :-) I agree :) Re: fenwick tree rulezzz!!! :-) oh, YES! This is brilliant data structure =) Re: fenwick tree rulezzz!!! :-) goood thing ) horrible code: #pragma comment(linker,"/stack:3000000") #include <iostream> int X[10100],n,k,r,h=1e9,g,x,i,j,l; int main(){ if(!j)for(i=n;i;X[i--]=0); if(!l&!j)std::cin>>n>>k; if(l<k){ std::cin>>x; for(i=x;i;r+=X[i],i-=i&-i); for(;x<=n;X[x]++,x+=x&-x); ++j==n?++l,(r<h?h=r,g=l:0),j=r=0:0; main(); } else std::cout<<g; } Edited by author 10.04.2011 19:41 Re: fenwick tree rulezzz!!! :-) it's the number of swaps in a bull sort. Edited by author 03.08.2011 02:27 |
|
|