Pit_____Experience Summary 2.0

Entering the university, I reopened an experience summary. Not only the content of the competition, but also the things that I usually pay attention to when writing code.

  • Some questions pay attention to taking the modulus as required.
    One area that is very hidden and often forgotten to take the modulus is when the answer is processed at the end. Example (click to enter the question) : I
    ans=ksm(2,N); ans-=ss;
    remember to take the modulus everywhere in the previous Bailaixing algorithm, but in the end, I didn’t take the modulus here, which led to a few WA shots at that time... It should be like this:
    ans=ksm(2,N); ans-=ss; ans=(ans%Ha+Ha)%Ha;

  • Pay attention and check the collection. Don't miss anything. Poor maintenance may make mistakes.

        for (auto E: connections) {
    
    
            int fu=Fa(E[0]);
            int fv=Fa(E[1]);
            if (fu!=fv) {
    
    
                f[fu]=fv;
            }
        }
		
		for (int i=0; i<n; i++) {
    
    
			f[i]=Fa(i);
		}

Guess you like

Origin blog.csdn.net/jackypigpig/article/details/111756572