10107 WA, why??
Posted: Wed Feb 14, 2007 6:03 pm
My OS is windows XP SP2
I use DEV-C to compile
It seems right
But when I transfered on ACM, I got WA
I try mant sample input, and the answer is right
I use DEV-C to compile
It seems right
But when I transfered on ACM, I got WA
I try mant sample input, and the answer is right
Code: Select all
#include <stdio.h>
#include <stdlib.h>
typedef struct node
{
long long int data;
struct node *next;
}root;
main()
{
int i,flag,count;
root *list; root *firstNode; root *insertNode; root *head;
i=1;
list=(root*)malloc(sizeof(struct node));
head=(root*)malloc(sizeof(struct node));
list->data=-1;
head->data=-1;
firstNode=(root*)malloc(sizeof(struct node));
while(scanf("%lld",&firstNode->data)==1)
{if(0<=firstNode->data) break;}
printf("%lld\n",firstNode->data);
firstNode->next=NULL;
list->next=firstNode;
head->next=firstNode;
i++;
while(i<=10000)
{
flag=1; count=0;
insertNode=(root*)malloc(sizeof(struct node));
while(scanf("%lld",&insertNode->data)==1)
{if(0<=insertNode->data) break;}
insertNode->next=NULL;
list=head;
if(list->next!=NULL)
{
while(((list->next)->data)<(insertNode->data))
{
list=list->next;
if(list->next==NULL)
{
list->next=insertNode;
flag=0;
}
}
if(flag)
{
insertNode->next=list->next;
list->next=insertNode;
}
}
else
list->next=insertNode;
list=head;
while(count<((i+1)/2)) {list=list->next; count++;}
if(i&0x00000001==1)
printf("%lld\n",list->data);
else
printf("%lld\n",((list->data+(list->next)->data)/2));
i++;
}
}