+ 1

program testing

#include <iostream> #include <string> #include <math.h> using namespace std; int main() { // your code goes here int q; cin>>q; while(q--){ int n; cin>>n; string s1,s2; cin>>s1>>s2; int count1=0,count2=0,zero=0; int both=0; for(int i=0;i<n;i++){ if(s1[i]=='1' && s2[i]=='1'){ both++; } else if(s1[i]=='1'){ count1++; } else if(s2[i]=='1'){ count2++; } else{ zero++; } } int minu=n; int count=min(count1,count2); minu-=count*2; minu-=both; int all=min(both,minu); all+=count; cout<<all<<"\n"; } return 0; } This program is running correct and according to all test cases I checked it is correct but giving wrong answer when I submit. Please can anyone check for inputs. This is the question: https://www.codechef.com/COOK132C/problems/TEAMFOR for inputs: 4 3 101 001 4 1010 0110 3 000 110 2 10 11 its correct output: 1 2 0 1

22nd Aug 2021, 6:10 PM
HK Lite
HK Lite - avatar
3 Answers
+ 4
I found multiple wrong test cases: 2 11 11 -> 0 instead of 1 4 1110 1101 -> 1 instead of 2 6 111110 111001 -> 2 instead of 3 6 111100 111100 -> 2 instead of 3 I'd think you are not correctly accounting for the number of pairs formed from students who know both languages. If the number of such students exceeds those who know neither language and the leftover ones knowing one language, they will have to form pairs with one another after all.
22nd Aug 2021, 7:58 PM
Shadow
Shadow - avatar
22nd Aug 2021, 6:12 PM
HK Lite
HK Lite - avatar