I was solving this problem problem .I encountered a problem while inputting the string . In my first submission i used scanf("%s",arr) which resulted in WA. Then i changed the input method to cin >> arr , then the submission became AC. Submission using scanf -> scanf Submission using cin -> cin
Submission using scanf() worked fine in my pc, but not in codeforces.
Can someone help me why does scanf() doesn't work here? Thanks in advance :)








It is not about your problem but I want to point out something. Instead of writing, bunch of if,else you can use ASCII values of numbers. I mean you can subtract char number from char zero. Thanks to this, you will get intended value.
Example: count += s[i] — ‘0’
The reason your
scanf()is not working is because you actually useios_base::sync_with_stdio(false); cin.tie(NULL);in your code. It speeds up yourcin/coutbut disables the sync withscanf/printfso you cannot use both at the same time.Your code gets AC without
ios_base::sync_with_stdio(false); cin.tie(NULL);: 129651408