ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1090. In the Army Now

fenwick tree rulezzz!!! :-)
Posted by Ilya Mitin (1) 5 Jun 2008 16:38
Re: fenwick tree rulezzz!!! :-)
Posted by Valentin (PSU) 1 Sep 2010 14:45
I agree :)
Re: fenwick tree rulezzz!!! :-)
Posted by slipstak2 2 Feb 2011 16:53
oh, YES! This is brilliant data structure =)
Re: fenwick tree rulezzz!!! :-)
Posted by waterlink 10 Apr 2011 18:27
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!!! :-)
Posted by watashi 3 Aug 2011 00:26
it's the number of swaps in a bull sort.

Edited by author 03.08.2011 02:27