kaleabasfaw2010's blog

By kaleabasfaw2010, history, 9 days 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

»
9 days 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.

  • »
    »
    9 days 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.

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

      Here is an image from the online compiler...

      Image

      • »
        »
        »
        »
        9 days 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?

        • »
          »
          »
          »
          »
          9 days ago, # ^ |
          Rev. 3   Vote: I like it 0 Vote: I do not like it

          Sorry for the confusion.

          In the screenshot the first 2 lines are the input:

          2 is the number of test cases.

          and 1 25 is the first test case I haven't input the second test case.

          The rest 5 lines are OUTPUT of the program.

        • »
          »
          »
          »
          »
          9 days 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.

          • »
            »
            »
            »
            »
            »
            8 days 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.

      • »
        »
        »
        »
        9 days ago, # ^ |
        Rev. 3   Vote: I like it 0 Vote: I do not like it

        Sir, in the online compiler, once you enter the first test case, it outputs the answer first, then you have to enter the second test case, that's why I think, it is better to use two different windows: input and output.

        As qpwoeirut said, it gives right answer on Custom Invocation.

        UPD: kaleabasfaw2010, it worked out fine on that compiler: Screenshot