You are not logged in. Please login at www.codechef.com to post your questions!

×

TSORT: getting abnormal behaviour in ideone

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[i] = 0;
}

// testing new implementation
int main()
{
    int t, no_char, j, num = 0;
    char buffer[10000];
    scanf("%d\n", &t);
    while(t)
    {
        no_char = fread(buffer, sizeof(char), 10000, stdin);
        for(j=0; j<no_char; j++)
        {
            if(buffer[j] == '\n')
            {
                arr[num]++;
                t--;
                num = 0;
            }
            else
            {
                num = num * 10 + buffer[j] - '0';
            }
        }
    }
    for(int i=0; i<1000001; i++)
    {
        while(arr[i]--)
            printf("%d\n", i);
    }
    return 0;
}

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

asked 21 Feb '13, 10:05

vijay40's gravatar image

3★vijay40
1112
accept rate: 0%


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

link

answered 21 Feb '13, 21:02

kuruma's gravatar image

3★kuruma
17.7k72143209
accept rate: 8%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×1,912
×554
×46
×38

question asked: 21 Feb '13, 10:05

question was seen: 1,663 times

last updated: 21 Feb '13, 21:02