MiracleInLife's blog

By MiracleInLife, history, 19 months ago, In English

Hello everyone, can you guys help me solve this trouble please?

My story is I'm was doing this problem by using Haskell.

At first, with my submission #168264592, it got compiler error. I think because the current GHC version I use is 8.10.7, meanwhile codeforces's GHC version is 8.10.1 so it does not have module 'Data.HashMap.Strict'.

So I switch to use Data.Map.Strict which codeforces'GHC suggests, however my submission #168266690 got wrong answers. Here's the weird part: My results and the jury's result is the same, so I do not know why I got it wrong??

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

| Write comment?
»
19 months ago, # |
  Vote: I like it +13 Vote: I do not like it

Your output looks the same as the jury's, but they're different! In this problem input lines are separated by "\r\n", not just "\n". If you read the documentation for B.lines, you'll see that it ignores "\r", so that "abacaba" you're printing is actually "abacaba\r"! You could use B.strip to remove the "\r", but apparently Codeforces' GHC doesn't have that... B.stripSuffix works though

I think in recent problems lines are separated by "\n", but I'm not sure

  • »
    »
    19 months ago, # ^ |
      Vote: I like it +5 Vote: I do not like it

    Thank you for your insight man! I figure out "\r\n" is for terminate & then newline, it is often used in Window systems, meanwhile Unix-like OS only require "\n" (Source)

    Your way of using B.stripSuffix is quite interesting. In addition, I have another way to deal with this, which is using B.words instead of B.lines.

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

I think because the current GHC version I use is 8.10.7, meanwhile codeforces's GHC version is 8.10.1 so it does not have module 'Data.HashMap.Strict'.

This has nothing to do with the compiler version. Data.HashMap.Strict is in the unordered-containers package, which you may have on your system but is not available on Codeforces. The only packages available on CF to my knowledge are the ones that come with GHC, you can find a list here for example, for 8.10.1.