TSORT: getting abnormal behaviour in ideone

c-plus-plus
ideone
practice
tsort

#1

when i run the following code on ideone it gave me time exceeded error and on codechef it runs fine!!
Since both codechef and ideone use s same sphere online judge i don’t understand the difference in such a behaviour

#include<stdio.h>

int arr[1000001];


void init()
{
    for(int i=0; i<1000001; i++)
        arr* = 0;
}

// testing new implementation
int main()
{
    int t, no_char, j, num = 0;
    char buffer[10000];
    scanf("%d

“, &t);
while(t)
{
no_char = fread(buffer, sizeof(char), 10000, stdin);
for(j=0; j<no_char; j++)
{
if(buffer[j] == ’
')
{
arr[num]++;
t–;
num = 0;
}
else
{
num = num * 10 + buffer[j] - ‘0’;
}
}
}
for(int i=0; i<1000001; i++)
{
while(arr*–)
printf(”%d
", i);
}
return 0;
}

is it because of ’
’ use in scanf. Because when i remove it, it runs on ideone but gives me wrong answer


#2

Hello @vijay40,

Actually, IDEone has some restrictions that can be a bit “tighter” than one can expect, i.e., what runs fine here might give some troubles on IDEone…

I recommend you read the IDEone FAQ, in order to have an idea of what is, or is not allowed:

Ideone FAQ

I hope this can help you,

Bruno