Блог пользователя adityav664

Автор adityav664, 18 месяцев назад, По-английски

I'm getting runtime error again and again and i can't seem to find any issue with my code as codeforces custom test compiler is also printing output just fine but when i submit code i get runtime error plz help, these 1 are questions that i'm getting issue with. 1. 120B - Quiz League 178911312

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
18 месяцев назад, # |
  Проголосовать: нравится -9 Проголосовать: не нравится

I suggest that you learn about Undefied Behaviour. On C++ there are some (actually many) operations for which there is not a guaranteed behaviour for all environments. As the C++ committee is not the ones who make compilers, nor ones who make computer architectures, they can't enforce it for every existing compiler or architecture, otherwise it would be a real pain deciding what behaviour is effective for every environment. Thus, they put it as an undefined behaviour, so you cannot ensure them to work the way you expected on every environment.

»
18 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

i am not a pro but i think this question wants input and output from a file. so write this after main function is declared :

#ifndef ONLINE_JUDGE
 
    // For getting input from input.txt file
    freopen("input.txt", "r", stdin);
 
    // Printing the Output to output.txt file
    freopen("output.txt", "w", stdout);
 
#endif

and then when you submit your code, it will throw a time limit exceeded error, which i think you can solve on your own by changing your program.

  • »
    »
    18 месяцев назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Modified submission — 179137435

    • »
      »
      »
      18 месяцев назад, # ^ |
        Проголосовать: нравится -8 Проголосовать: не нравится

      Didn't notice that — you're right. Maybe I forgot that back in the old contests, using STDIN/STDOUT was not very common (or at least that was the case for Korea until 2014)

  • »
    »
    18 месяцев назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    179140457 why do i getting output not found now, and i can't see why i'm getting tle in your submission

    • »
      »
      »
      18 месяцев назад, # ^ |
        Проголосовать: нравится -8 Проголосовать: не нравится

      In this case we do not want the #ifndef, we want the File I/O to run on the online judge. You can change it to #ifdef instead.

      • »
        »
        »
        »
        18 месяцев назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

        Thanks it works, so whenever i have to solve old questions do i have to use this? cause i never encounter this issue till now even solving beta contests from the codeforces beginning why do i get this issue now?

        • »
          »
          »
          »
          »
          18 месяцев назад, # ^ |
            Проголосовать: нравится -8 Проголосовать: не нравится

          Under the time/memory limits there were two lines input:input.txt, output:output.txt so I think you can use File I/O whenever you see this.