-
Notifications
You must be signed in to change notification settings - Fork 0
/
CRDGAME.cpp
60 lines (54 loc) · 1.22 KB
/
CRDGAME.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Problem link - https://www.codechef.com/JULY20B/problems/CRDGAME
#include<bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define lli long long int
#define vi vector<int>
#define vll vector<lli>
#define pb push_back
#define all(v) v.begin(),v.end()
lli sumdigits(lli n){
lli sum = 0;
while(n){
sum+=n%10;
n/=10;
}
return sum;
}
void solve(){
lli n,i,chef_rounds=0,morty_rounds=0;
cin >> n;
rep(i,n){
lli t1, t2;
cin >> t1 >> t2;
if(sumdigits(t1) < sumdigits(t2)){
morty_rounds++;
}else if(sumdigits(t2) < sumdigits(t1)){
chef_rounds++;
}else{
morty_rounds++;
chef_rounds++;
}
}
if(morty_rounds < chef_rounds){
cout << 0 << " " << chef_rounds << endl;
}else if(chef_rounds < morty_rounds){
cout << 1 << " " << morty_rounds << endl;
}else{
cout << 2 << " " << chef_rounds << endl;
}
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int test_cases;
//test_cases = 1;
cin >> test_cases;
while(test_cases--){
solve();
}
return 0;
}