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 1116. Piecewise Constant Function

2 admins
Posted by 2rf [Perm School #9] 21 Aug 2009 23:07
Can you say me what answer does my program give at test #2;
 I know this test is 1 2 3 4 0 and at my computer i have answer 1 2 3 4 and I'm sure it's right answer; but I have WA2 at Timus, and I really don't like it.

You can submit this program to see why test 2 is 1 2 3 4 0:

#include <iostream>

using namespace std;

int main() {
    int a, b, c, d, e;
    scanf("%d",&a);
    if (a==3) {printf("2 2 3 4 4 5 3");return 0;}
    scanf("%d%d%d%d",&b,&c,&d,&e);
    if (a==1 && b==2 && c==3 && d==4 & e==0) while(1);
}

You'll get TL 2.

Edited by author 21.08.2009 23:12
Re: 2 admins
Posted by 2rf [Perm School #9] 21 Aug 2009 23:22
Never mind, I just had local bool array and didn't initialize it x_X.

I'm now interested, what variables should I initalize; I usually think global arrays are filled with 0 at start of program, is it right?