Kaleab_Asfaw's blog

By Kaleab_Asfaw, history, 4 years ago, In English

I have participated in Educational Codeforces Round 92 Editorial and in the hacking phase I was trying to hack 88307545 solution. The input data I used was:

2
1 25
100 250

The code will output (on local PC and on online compiler):

12 24
25 5
25 5
25 5
25 5
125 250

I write the second test case to make codeforces think "the first line from the output is for the first test case and the others are for the second test case", but I got unsuccessful attempt. I didn't understand why this didn't work? Can someone explain to me?

Thanks in Advance!

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

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

How did you get that output data? When I run the solution on Custom Invocation I only get two lines.

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

    I run it on my PC (I use sublime inputf.in and outputf.in) and on this online compiler.

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

      Here is an image from the online compiler...

      Image

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

        I'm confused. In your image it looks like you're just showing the input, which isn't even valid — you have 6 cases but claim you only have 2.

        Can you please try running the solution on Custom Invocation and screenshot that?

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

          Ok I also try it on other online compiler, this one separates the inputs from the outputs.

          Here is the image during the input.

          Here is the output.

          To be sure check it out your self.

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

            First off, your input still doesn't match what you posted in the blog. Now you're claiming there's one test case and then providing two.

            Second, what's wrong with using the Codeforces compiler? That's about as official as you can get for this scenario. Another issue with those online compilers is they don't actually tell you whether they're using GCC or Clang or something else.

            Third, I did some more testing on Custom Invocation and actually read the code you're trying to hack. It seems like ll q=sqrt(r)+(q*q<r); is causing UB since it's referencing q while it's being initialized. On G++ compilers it seems to initialize q to 0, so q*q < r is always true. On Clang++ Diagnostics it crashes with integer overflow, presumably because q is some random junk value which can't be squared safely. On Microsoft Visual C++ it seems that sqrt doesn't have a long long overload.

            In conclusion, just use Codeforces Custom Invocation to test solutions and make sure you're using the same compiler.