Ladislaus, do you or anyone else know the name of the late encyclical or address of Pius XII where he "decreed" that even if all the Cardinals are heretics they can still elect a valid Pope? If you accept Pius XII as Pope, this will create big problems for you. For me it is just another strike against him, showing that even during his pontificate, he was already establishing bulwarks to protect the future usurpers.
No, I don't know the encyclical you mention.
That's where "sedeprivationism" might hold the key. They do hold that the jurisdiction could pass on materially even through formal heretics.