Fortunately, the original idea of doing the question did not know when it would have formed this idea. It may have been a little more, so I naturally thought of using this method.
There is no reason. Is there any idea? If you have a idea, you can say something more. If you have a idea, then there is nothing to say about it... Let's learn more about the idea of the great gods. Maybe it's a way for cainiao to improve.
# Include <cstdio> # include <cstring> # include <string> # include <iostream> using namespace STD; string S1, S2; int cnt0, cnt1, cnt2; int main () {int t; scanf ("% d", & T); For (INT Kase = 1; Kase <= T; Kase ++) {CIN> S1> S2; cnt0 = cnt1 = cnt2 = 0; int cnt11 = 0, cnt21 = 0; For (INT I = 0; I <s2.size (); I ++) {If (S1 [I] = '? ') Cnt2 ++; If (S1 [I] = '1') cnt11 ++; If (s2 [I] = '1') cnt21 ++; if (s2 [I]! = S1 [I] & S1 [I]! = '? ') {If (s2 [I] = '0') cnt0 ++; If (s2 [I] = '1') cnt1 ++ ;}} if (cnt11> cnt21) {printf ("case % d:-1 \ n", Kase); Continue ;}int ans = 0; If (cnt0 = cnt1) {ans + = cnt0; ans + = cnt2;} If (cnt0> cnt1) {ans + = cnt1; ans + = (cnt0-cnt1); ans + = cnt2 ;} if (cnt0 <cnt1) {ans + = cnt0; ans + = (cnt1-cnt0); ans + = cnt2;} printf ("case % d: % d \ n", Kase, ans);} return 0 ;}
In fact, it can be merged, but I cannot write the merge process at once, and the depth of thinking cannot reach that level. If I think too deeply, I cannot understand it myself, an error occurs.
Think more, think deeply, and clarify your ideas.