Till KTH:s startsida Till KTH:s startsida

Nyhetsflöde

Logga in till din kurswebb

Du är inte inloggad på KTH så innehållet är inte anpassat efter dina val.

I Nyhetsflödet hittar du uppdateringar på sidor, schema och inlägg från lärare (när de även behöver nå tidigare registrerade studenter).

September 2015
Johan Kvastad skrev inlägget 16 september 2015

Johan Kvastad taggade med ncpc15. 16 september 2015

Lärare kommenterade 17 september 2015

You register via the process described there.

 
Johan Kvastad skrev inlägget 9 september 2015

Johan Kvastad taggade med hemtal 1 och aspen. 9 september 2015

kommenterade 9 september 2015

I'm having the same problem with aspen. Kattis won't accept my answer even after rounding exactly like in the examples. Any help would be appreciated!

Lärare kommenterade 10 september 2015

I have double-checked and Kattis does use the stated absolute/relative tolerance.  So printing the answer with 6 digits and rounding either way will be sufficient (and adding a few more digits to the output doesn't hurt).

In other words the output formatting is not the likely culprit, but there is probably some other bug, either in the algorithm, or in its implementation.  I can try to give more concrete hints if I get a Kattis submission ID.

(PS regarding ljutnja I just answered on that post, but do note that what you write here about the answer having to be truncated to a 64-bit integer is not correct.)

kommenterade 10 september 2015

Thank you for the answer!

Could you take a look at ID 766056 then? All the test cases i try just give me correct answers to the last decimal.

Also: I commented the ljutnja post and double checked. There is something strange going on having to do with 64 bit integers, as i can get the correct answers simply by taking mod 2^64 to my existing python algorithm, which otherwise gives "wrong answer" on Kattis.

Lärare kommenterade 10 september 2015

Johan, here is a hint: some parts of the C/C++ standard library do not behave the way you might expect them to, make sure to use the right functions.

kommenterade 10 september 2015

Ok, thank you! I am quite new to c++ so this is very likely.

kommenterade 10 september 2015

TIL i learned that std::abs is very different from abs. Sometimes.

kommenterade 15 september 2015

Per Austrin: I think I have a related issue with the tolerance/precision when running in Java. Could you look into ID 790961?

Lärare kommenterade 15 september 2015

Hi Johan!  Your issue is not related to tolerance/precision.  You should probably try to convince yourself that your algorithm is correct.

 
Johan Kvastad skrev inlägget 11 september 2015

Johan Kvastad taggade med hemtal 1 och spiderman. 11 september 2015

 
Johan Kvastad skrev inlägget 6 september 2015

Johan Kvastad taggade med hemtal 1 och ljutnja. 6 september 2015

Johan Kvastad korrigerade 6 september 2015

I have a question about the problem formulation in problem Ljutnja (https://kth.kattis.com/problems/ljutnja):

There is a note in the output section of the problem "Note: The test cases will ensure that the result fits in a 64-bit unsigned integer.".

Does this mean that the we should give the answer in a 64-bit unsigned integer, or that answers will never overflow if we use 64-bit unsigned integers?

Johan Kvastad korrigerade 6 september 2015

I have a question about the problem formulation in problem Ljutnja (https://kth.kattis.com/problems/ljutnja)

There is a note in the output section of the problem "Note: The test cases will ensure that the result fits in a 64-bit unsigned integer.".

Does this mean that the we should give the answer in a 64-bit unsigned integer, or that answers will never overflow if we use 64-bit unsigned integers?

Lärare kommenterade 10 september 2015

It means that you can assume that the input satisfies the property that the correct answer, which is an integer, lies between 0 and 18446744073709551615 (inclusive).

(I'm not really sure what you mean by "give the answer in a 64-bit unsigned integer": you always give the answer as a string of digits.)

kommenterade 10 september 2015

I might be wrong, let's double check. Compare my submissions id 756596 and 765908:

In both i print the answer using python 3.4 integers which have "unlimited" precision. In one i take the answer mod 2^64. I get correct answer in the one using modulus. I suspect this means that there is a test where the correct answer is larger than 2^64. Such a testcase is possible, e.g. all children want 2*10^9, there are 10^5 children, and only 1 candy, yielding about 22000 times more anger than can fit in a 64 bit unsigned integer. Correct?

Lärare kommenterade 10 september 2015

Good catch, thanks!  The test data for the problem indeed contained some invalid test cases where the correct answer exceeded 64 bits.

I have fixed this, and all old non-Accepted submissions are currently being rejudged -- your initial submissions using unlimited precision will switch state to Accepted in a little while.

 
Johan Kvastad skrev inlägget 3 september 2015

Johan Kvastad taggade med hemtal. 3 september 2015

Lärare kommenterade 4 september 2015

If you have questions about the problem formulations, please ask them here.