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

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

Edited by author 03.08.2011 02:27