_KameHameha_'s blog

By _KameHameha_, history, 11 years ago, In English

Hello I need some help about the problem 368B (link : http://codeforces.me/problemset/problem/368/B) My solution is : http://codeforces.me/contest/368/submission/14799431

and it works perfectly on codeblocks but giving wrong answer in Codeforces. Can anyone please explain why ? Thanks in advance.

  • Vote: I like it
  • +3
  • Vote: I do not like it

| Write comment?
»
11 years ago, hide # |
← Rev. 2  
Vote: I like it +3 Vote: I do not like it
  1. One should not disable synchronization between C++ and C-style I/O with ios_base::sync_with_stdio(0) and then mix cin with scanf. That's exactly why synchronization is enabled by default in the first place: to allow you to use them simultaneously. You should either avoid disabling synchronization at all or stick to cin or scanf only in your solution.
  2. int x[] = { 0 } does not do what you think it does — it only specifies the first element to be zero, and the remaining elements to be default values for int (which happens to be zero). Example. Note that local variables and arrays of primitive types are not guaranteed to be filled with zeros, so int x[] = {} and int x[] are different (the first one fills array with zeros, the second does not). However, when variables/arrays of primitive types are declared global, they are guaranteed to be zero-initialized after the program starts.