Блог пользователя shankysodhi

Автор shankysodhi, 13 лет назад, По-английски

Hi everybody .

I participated in the CodeChef's June Cook Off challenge ... or should i say i tried to participate in it . The reason being ,i got stuck at the very first problem . Every time i submit the solution i got TLE. The frustration continued for about 2 hrs with no luck what so ever. I asked the problem setters/testers there to please explain what was the problem but got no response (even after the contest was over). So i was hoping u guys could help me . Its not much of a problem (that was the frustrating part).

The problem is available at :

http://www.codechef.com/problems/KNIGHTMV/

I have my solutions as : ( in the order .... lastest solution to the oldest solution )

http://www.codechef.com/viewsolution/578839
http://www.codechef.com/viewsolution/578334
http://www.codechef.com/viewsolution/578234
http://www.codechef.com/viewsolution/578111

I am no expert in programming (as reflected in the color of my handle) ... so i guess the error(if any) will be minor.

If you got time ....please go through it .. will appreciate any help .... Thanks. :)

Полный текст и комментарии »

  • Проголосовать: нравится
  • +6
  • Проголосовать: не нравится

Автор shankysodhi, 13 лет назад, По-английски

Hi guys,

I was just trying random problems from the topcoder archive when i came across the following problem

http://www.topcoder.com/stat?c=problem_statement&pm=1918&rd=5006

It seemed a little weird to me , the problem statement itself. According to the tutorials and stats its an easy  problem .
I am not able to get it .

I have my solution below ( incorrect of course ) ... It passes all the basics tests in the arena . but fails at system test very badly . Could someone please explain the problems statement or point to the flaw int my code
( warning : it is very messy code .... please dont judge me by it :)) ... )

public int[] getOrdering(int[] height, int[] bloom, int[] wilt)
    {
        for(int i=0;i<height.length-1;i++)
            {
            int val=height[i];
            int index=i;
            for(int j=i;j<height.length;j++)
            {
                if(val<height[j])
                {
                    val=height[j];
                    index=j;
                }
               
            }
            int temp;
            temp=height[index];
            height[index]=height[i];
            height[i]=temp;
           
            temp=bloom[index];
            bloom[index]=bloom[i];
            bloom[i]=temp;
           
            temp=wilt[index];
            wilt[index]=wilt[i];
            wilt[i]=temp;
           
            }
           
            int out[]=new int[height.length];
            for(int i=0;i<height.length;i++)
                out[i]=height[i];
            for(int i=1;i<height.length;i++)
            {
                int numi=out[i];
                int indi=i;
                for(int k=0;k<height.length;k++)
                    if(height[k]==numi)
                    {
                        indi=k;
                        break;
                    }
                for(int j=0;j<i;j++)
                {
                    int num=out[j];
                    int indj=j;
                    for(int k=0;k<height.length;k++)
                        if(height[k]==num)
                        {
                            indj=k;
                            break;
                        }
                    if(bloom[indi]<=wilt[indj]&&bloom[indj]<=wilt[indi])
                    {
                        for(int p=i-1;p>=j;p--)
                            out[p+1]=out[p];
                        out[j]=numi;
                        break;
                    }
                }
            }
            return out;
    }

Полный текст и комментарии »

  • Проголосовать: нравится
  • -17
  • Проголосовать: не нравится

Автор shankysodhi, 13 лет назад, По-английски
Hi,

Quite a no of times when i am participating in the contests, i come across the problem where i have to sort 2 or 3 arrays according to a condition applied only on one of them .

For eg :

Cordinates of a point in 3d space are given as (x,y,z)

Now the input comes as (X[], Y[], Z[] .... are different arrays)

X[j]      Y[j]       Z[j]
j

0          7         2            1
1          3         2            5
2          4         9            2
3          5         4            3 
4          5         3            3
..          ..          ..           ..
..          ..          ..           ..
1000 terms

Now suppose i want to sort the co-ordinates in the ascending order of the x co-ordinate. Obviously i have to sort y and z accordingly too , preserving the relative position ....

Is there any easy way to do it (maybe using library function ... preferably in java).. ?? Or do i have to go for simultaneous bubble sort or some other sort every time ...??

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

Автор shankysodhi, 13 лет назад, По-английски
Why are there no new contests ?

And shouldn't the schedule be prepared beforehand . I mean even if the problems are not prepared , on every given day the schedule of the next 30 days should be visible ( and i mean with contest details .... not the blank calendar ) .
When all the world topmost programmers are available under one roof , bringing out a calendar functionality shouldnt be much harder ... i guess.

Also, when most of the people like codeforces stating the reason that the number of contest here are more than topcoder . Why are the reasons taken away from them . :(

I would like to request the codeforces admins ( if they are reading ) to please bring out new contest as soon as possible . I know that the major contest (TCO, codejam and ICPC) are in progress , but that shouldnt be the reason to keep general public (like me ...:) ) away from the wonderful world of programming contests ...hehe. No, seriously , please please provide new contests asap ....

Eagerly waiting ..... Big fan .

Полный текст и комментарии »

  • Проголосовать: нравится
  • +1
  • Проголосовать: не нравится

Автор shankysodhi, 14 лет назад, По-английски

Hi Everyone.

I know i shouldn't have written a blog post for this . But since there is no other way . I am doing it here .

I am (like most/or at least some other people here) new to this fantastic world of problem/puzzle solving programming . And i face a very serious problem here.

Most of the time when i start solving a problem. I start coding .. submit it .. and then find out that my solution exceeds the time limit.

For example :

I was participating in the topcoder SRM 504.5 in div 2(obviously). And i was trying to solve the jackpot problem.

the problem statement is at :

http://www.topcoder.com/stat?c=problem_statement&pm=11432

Now during the course of 75 mins i was unable to solve even this basic(now i know) problem, spending all the time to find an effective and fast way to solve it. I was shocked to look at the possible solution . It was straightforward.

highlight to reveal :

while(jackpot>0)
{
sort(ALL(money));
money[0]++;
jackpot--;
}
sort(ALL(money));
return money;



Now most of the people here (red violet yellow and even others)  , i suppose, figure out whether their solution is gonna work or not before they even start coding . They (You - if you can do it too) can figure out the complexity of the problem and given the limits of the input are aware of the effectiveness of their solution.

I have been trying to learn complexity for quite some time. But still hasn't succeeded in it yet. So could please someone of you, take some time of their precious time to explain it in details (with examples) . Or if not could someone please refer blogs, posts or web links of something that can be useful .

I know their are a lot of people out there like me who face the same problem . It would be so grateful of you.

Thanks.

Полный текст и комментарии »

  • Проголосовать: нравится
  • +5
  • Проголосовать: не нравится