You are not logged in. Please login at 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


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);
        no_char = fread(buffer, sizeof(char), 10000, stdin);
        for(j=0; j<no_char; j++)
            if(buffer[j] == '\n')
                num = 0;
                num = num * 10 + buffer[j] - '0';
    for(int i=0; i<1000001; 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

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,



answered 21 Feb '13, 21:02

kuruma's gravatar image

accept rate: 8%

toggle preview

Follow this question

By Email:

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



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "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:


question asked: 21 Feb '13, 10:05

question was seen: 1,663 times

last updated: 21 Feb '13, 21:02