zscoder's blog

By zscoder, 11 years ago, In English

Excuse me, how can I generate large inputs to hack solutions?

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

»
11 years ago, # |
  Vote: I like it +2 Vote: I do not like it

You should write a program that generates large input? open "generated input" tab on the hack dialog and submit the program instead of the input.

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

    I mean how could I possibly write it.

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

      What is it exactly that you're asking about? This way, it sounds as if you don't think you can write any working program at all...

      There is no special trick to writing an input generator, it's just straightforward implementation. Get a suitable random number generator (in C++, srand(seed) and rand()), and print an input in the format described in the problem statement. You can set some bounds (N etc.) to your chosen constant values or generate them randomly...

      Watch out, though: CF input files can only have up to 256 kB, so sometimes you could end up with a useless input!

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

        Oh, it's just like this. Thanks!

      • »
        »
        »
        »
        11 years ago, # ^ |
        Rev. 12   Vote: I like it -8 Vote: I do not like it
        256 kB

        u sure?

        256KB=256000B ~(assuming large ints and one space after a number) 16000 numbers.

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

          In hacks, yes. And that's my point: very often, you can't hack just by taking the largest input, because it exceeds this limit.

          16000 is an underestimate. Integers in CF inputs don't exceed 10 digits, so 23000 with a whitespace after every 10 digits. Even that is an underestimate — most integers will be much smaller. If we take an average of 5 digits+whitespace, we get 42000 numbers, which is not that far from the frequently used bound of 105.