Advertisement
shawon_majid

codechef

Jul 5th, 2020
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.25 KB | None | 0 0
  1. //Bismillahir Rahman-ir Rahim
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4. #define MAX 1000000
  5. #define PI acos(-1)
  6. #define debug(x) cout << '>' << #x << " : " << x << endl;
  7. #define all(c) c.begin(), c.end()
  8. #define F first
  9. #define S second
  10. #define pb push_back
  11. #define mp make_pair
  12.  
  13. typedef unsigned long long ull;
  14. typedef long long ll;
  15. typedef vector< int > vi;
  16.  
  17.  
  18. int char_to_num(char c){
  19.     return c - '0';
  20. }
  21.  
  22. int sod(string str){
  23.     int sum = 0;
  24.     for(int i = 0; i < str.size(); i++){
  25.         sum += char_to_num(str[i]);
  26.     }
  27.     return sum;
  28. }
  29.  
  30.  
  31. int main()
  32. {
  33.     //freopen("input.txt", "r", stdin);
  34.     //freopen("output.txt", "w", stdout);
  35.    
  36.     int T;
  37.     cin >> T;
  38.     while(T--) {
  39.         int n, nA = 0, nB = 0;
  40.         cin >> n;
  41.         string A, B;
  42.         for(int i = 0; i < n; i++){
  43.             cin >> A >> B;
  44.             if(sod(A) > sod(B)) nA++;
  45.             else if(sod(A) < sod(B)) nB++;
  46.             else{
  47.                 nA++;
  48.                 nB++;
  49.             }
  50.         }
  51.         if(nA > nB){
  52.             cout << 0 << ' ' << nA << endl;
  53.         }
  54.         else if(nA < nB){
  55.             cout << 1 << ' ' << nB << endl;
  56.         }
  57.         else cout << 2 <<' ' <<nA << endl;
  58.     }
  59.    
  60.     return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement