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 1045. Funny Game

Can they fly to the same airport???
Posted by Oscar 14 Mar 2003 18:54
What happens if you got an entry like this one:

5 1
1 2
1 3
1 4
1 1

My program would say that it'll win flying to airport number 2
because I think it's kinda obvious that if the airport is exploted
then it won't be able to land there... but is that really true?
Still getting WA
Posted by Oscar 14 Mar 2003 19:46
I'm still getting WA, can anyone help me?

I haven't found a reason for my program not to work, first I thought
it was because the entry was making a flight to the same airport, now
I fixed that but I still get WA.

If anyone's got interesting test cases please post them.

Or if you can help me find out the weakness of my code I'll really
apreciate it.

/*******************************************************/
#include <stdio.h>

int a[1000][1000];
int suma[1000];
int n, k, i, j, aux1, aux2, local, min, igual;

void main(void)
     {
     min=1500;
     local=0; igual = 0;
     scanf("%d %d", &n,&k);
     for (i=0; i<n+1; i++){
     for (j=0; j<n+1; j++)
          a[i][j]=0;
     suma[i]=0;
     }

     for (i=0; i<n-1; i++)
     {
     scanf("%d %d", &aux1,&aux2);
     a[aux1][aux2]=1;
     a[aux2][aux1]=1;
     if ((aux1 == aux2) && (aux2 == k))
        igual = 1;
     }
     for (i=1; i<n+1; i++)
     {
     for (j=1; j<n+1; j++)
         if (a[i][j] == 1)
         suma[i]++;
     }
   for (i=1; i<n+1; i++)
     {
     if (a[i][k] == 1)
        if (suma[i]==1)
           {
           local=i;
           break;
           }
        else
        if (n%2==0)
        if (suma[i]%2 == 0)
           if (suma[i]<min)
          {
          min = suma[i];
          local=i;
          }
        else
        if (suma[i]%2 == 1)
           if (suma[i]<min)
          {
          min = suma[i];
          local=i;
          }
     }
        if (igual == 1)
        local = k;
        if (local != 0)
        printf("First player wins flying to airport %d",
local);
        else
        printf("First player loses");

     }
my short code has just a DFS...
Posted by Locomotive 14 Mar 2003 22:29
Aidin_n7@hotmail.com