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 1028. Stars

why wa?
Posted by chenweida 14 Jul 2011 16:38
var
        s:array[1..32000]of longint;
        ans:array[0..15000]of longint;
        n,i,x,y,t,k:longint;
begin
        readln(n);
        for i:=1 to n do
         begin
                readln(x,y);
                t:=0; inc(x); k:=x;
                while k>0 do
                 begin
                        t:=t+s[k];
                        k:=k-k and (k xor (k-1));
                 end;
                ans[t]:=ans[t]+1;
                k:=x;
                while k<=32000 do
                 begin
                        s[k]:=s[k]+1;
                        k:=k+k and (k xor (k-1));
                 end;
         end;
        for i:=0 to n-1 do writeln(ans[i]);
end.