You are not logged in. Please login at www.codechef.com to post your questions!

×

XOR on Segment - interesting trick

For this question on codeforces, where the intended solution is using segment tree, I found some naive solution which are getting accepted.

1) sol-1 2) sol-2

Can someone explain me how these codes are passing all the test cases and what is the optimisation used here?

MY Reference

asked 09 Sep '17, 18:20

skyhavoc's gravatar image

4★skyhavoc
1616
accept rate: 0%

edited 10 Sep '17, 01:44


The solutions are passing because the timelimit/tesetcases are not strict enough. The only trick in these brute force solutions is to use integers inistead of long long for accumulating (possibly a time win of 50%). Only when the integer might overflow a long long is used to store the complete sum.

link

answered 10 Sep '17, 04:02

ceilks's gravatar image

7★ceilks
1.8k9
accept rate: 36%

so, processing on integer data type is faster than Long Long data type, and we are processing on long long data type only when it is needed?

(10 Sep '17, 11:18) skyhavoc4★
toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×1,912
×682
×234
×99

question asked: 09 Sep '17, 18:20

question was seen: 623 times

last updated: 10 Sep '17, 04:02