Here, now, today?
Set all your accounts up with auto-generated passwords, and store the whole lot in a password vault[1]. Don't bring the password vault file with you when you cross the border. Arrange to acquire it after you have entered the country[2].
Now you can honestly say you don't know any of your passwords. If enough people do this, then this law will be pointless.
Also, for the love of god stop bringing your smartphone with you when you travel. Get a $15 quad-band feature phone, and just bring a paper map with you. If you don't need your laptop then leave that behind as well.
[1] As much as I hate password managers and see them as a solution to a problem that shouldn't exist, you should probably be doing this by now anyway.
[2] The details of this can range from a pre-timed email to a physical handover from someone inside the country, depending on whether you think the border police might detain you and attempt to force you to acquire the password vault.