Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
freem
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Openai/6943ca25-5f58-8006-882b-41249eb1ca7a
(section)
Add languages
Page
Discussion
English
Read
Edit
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==== I derived and verified a linear-time DP in NNN for a single mmm, but that’s too slow for many distinct mmm. ==== However, because cold positions jump by ≈m\approx m≈m, the number of cold values ≤10610^6106 is only about 106/(m+1)10^6/(m+1)106/(m+1). Summed over many different mmm, this behaves like a harmonic series and is actually feasible if we build only cold positions, not full DP. ===== For each distinct mmm appearing in the input: ===== # If n≤mn\le mn≤m: immediate win → YES. # Else if v2(m+1)v_2(m+1)v2(m+1) even: use modulo rule. # Else (odd case): generate cold positions starting at m+1m+1m+1 by testing whether c+(m+1)c+(m+1)c+(m+1) is cold (else c+(m+2)c+(m+2)c+(m+2)) until exceeding the maximum queried nnn for that mmm. Store cold positions in a boolean array (or hash set). Then answer each query by lookup. Because consecutive cold positions differ by m+1m+1m+1 or m+2m+2m+2, you only generate O(#cold) per mmm, which is about 106/(m+1)10^6/(m+1)106/(m+1). Across up to 10410^4104 queries, this is typically fine in 4 seconds in C++.
Summary:
Please note that all contributions to freem are considered to be released under the Creative Commons Attribution-ShareAlike 4.0 (see
Freem:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)