darkcry's blog

By darkcry, history, 4 years ago, In English

So i am solving a question named verse for santa of educational codeforces round 79. I have written my code using binary search https://codeforces.net/contest/1279/submission/79356510 The problem is for the testcases give in the question my code is giving the correct answer on my system(I code on jdoodle Online C++ 14 Compiler IDE), but giving different answer when i am submitting it to codeforces. Please help!

  • Vote: I like it
  • -10
  • Vote: I do not like it

| Write comment?
»
4 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Did you consider different sizes of data types on your system and codeforces?

  • »
    »
    4 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    what do you mean?

    • »
      »
      »
      4 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Maybe your system is 64-bit while codeforces is 32-bit (actually I know nothing about codeforces, just a guess).

»
4 years ago, # |
  Vote: I like it 0 Vote: I do not like it

I guess your variable 'ma' has not been assigned yet.

  • »
    »
    4 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    No i checked it is fine.

    • »
      »
      »
      4 years ago, # ^ |
      Rev. 2   Vote: I like it 0 Vote: I do not like it

      when i > 0, you compare v[i] and ma. But in this case, ma has no assigned value. It may lead to 'undefined behavior'

      • »
        »
        »
        »
        4 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        but before that i am assigning a value to ma when i=0. So there is no undefined behavior. If you still have doubt copy my code, run on your system for the first test case .

        • »
          »
          »
          »
          »
          4 years ago, # ^ |
            Vote: I like it +1 Vote: I do not like it

          How to say??? You declare int ma, index; inside the loop. Thus, once you iterate i, the variable 'ma' is declared again. Plzz

        • »
          »
          »
          »
          »
          4 years ago, # ^ |
            Vote: I like it +1 Vote: I do not like it

          ma is redefined on each iteration and has no assigned value on iterations 1+.

        • »
          »
          »
          »
          »
          4 years ago, # ^ |
            Vote: I like it +1 Vote: I do not like it

          you should declare 'ma' outside the loop!

          • »
            »
            »
            »
            »
            »
            4 years ago, # ^ |
              Vote: I like it +1 Vote: I do not like it

            Yes apologies. I was wrong . It solved the problem. Thnak you!!! :)

»
3 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Same problem for me in this submission: 134321653. When I build and run this code in geany on ubuntu I get correct output, but when I submit it on codeforces it looks like I didn't output anything.

  • »
    »
    3 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Don't use ios_base and cin.tie(0) with scanf together.

    • »
      »
      »
      3 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Wow that was fast reply! Thank you so much, you solved my issue. :D

»
6 months ago, # |
Rev. 2   Vote: I like it -11 Vote: I do not like it

hey, I am also getting the same issue in Codeforces Round 944 (Div. 4), for Eth problem on 21th testcase I am getting wrong output but when I run it on some other compiler for the same testcases it shows correct output, this is my submission 260484076

please help

»
6 months ago, # |
  Vote: I like it 0 Vote: I do not like it

same shit bro, i already write blog about it some time ago, and not one gived clear solution