Chef and Card Game Problem Code: CRDGAME Solution Codechef

 #include <bits/stdc++.h>
using namespace std;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  int t;
  cin>>t;
  while(t--){
    int n;
    cin>>n;
    int win1=0,win2=0;
    while(n--){
      int curr=0;
      string s;
      cin>>s;
      for(char c:s)
        curr+=c-'0';
      cin>>s;
      for(char c:s)
        curr-=c-'0';
      if(curr)curr>0?win1++:win2++;
      else win1++,win2++;
    }
    int sum=win1-win2;
    if(sum>0)cout<<0<<' '<<win1;
    else if(sum<0)cout<<1<<' '<<win2;
    else cout<<2<<' '<<win1;
    cout<<'\n';
    }
}

Comments