Problem:
Problem C:
カードゲーム
ねこのゲイツとジャッキーは、2人で遊ぶカードゲームのルールを考えた。そのルールとは次のようなものである。
まず、1から18の数字が書かれたカードをシャッフルし、それぞれのプレーヤーに9枚ずつ配る。両者は同時に1枚のカードを同時に出し、その値によってスコアを得る。値の大きいカードを出したプレーヤーは、大きい方の値と小さい方の値の和を自分のスコアに加える。その際、値の小さいカードを出したプレーヤーはスコアを得られない。また、一度場に出されたカードは二度と使うことはできない。カードをすべて使い終わった後にスコアが大きかったプレーヤーの勝ちとする。
ゲイツとジャッキーは互いに無作為にカードを選んで出してみることにした。最初に配られたカードが与えられたとき、ゲイツとジャッキーが勝つ確率をそれぞれ求めよ。
Input
ゲイツ、ジャッキーそれぞれの手札は、9個の整数からなる。両プレーヤーの手札は1から18までの互いに異なる整数である。入力の1行目にはゲイツの手札を表す9個の整数が与えられ、2行目にはジャッキーの手札を表す9個の整数が与えられる。整数と整数の間は空白1個で区切られる。
Output
ゲイツ、ジャッキーが勝つ確率をそれぞれ、スペースで区切って小数点以下5桁まで出力せよ。 10
-5
以内の誤差は許容されるが、0未満あるいは1を越える値を出力してはならない。
Notes on Submission
上記形式で複数のデータセットが与えられます。入力データの 1 行目にデータセットの数が与えられます。各データセットに対する出力を上記形式で順番に出力するプログラムを作成して下さい。
Sample Input
2
1 3 5 7 9 11 13 15 17
2 4 6 8 10 12 14 16 18
1 5 7 9 11 13 15 17 18
2 3 4 6 8 10 12 14 16
Output for the Sample Input
0.30891 0.69109
0.92747 0.07253

Submitted solutions:

code_snippet: #include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;

vector<int> a(9),b(9);
int aw=0,bw=0;

void ck(int k,int usd,int as,int bs){
  for(int i=0;i<9;i++){
    if((usd&(1<<i))!=0) continue;
    //cout << k << " " << i << endl;
    int usd1=(usd|(1<<i));
    int as1=as,bs1=bs;
    if(a[k]>b[i]) as1+=(a[k]+b[i]);
    else bs1+=(a[k]+b[i]);
    
    if(k==8){
     (as1>bs1 ? aw++ : bw++);
      return;
    }

    ck(k+1,usd1,as1,bs1);
    
  }
  return;
}

int main(){

  int n;
  cin >> n;
  for(int s=0;s<n;s++){
    for(int &x:a) cin >> x;
    for(int &x:b) cin >> x;

    aw=0;bw=0;
    vector<int> c(9);
    ck(0,0,0,0);
    //cout << aw << " " << aw+bw << endl;
    cout << fixed << setprecision(5) << (double)aw/(aw+bw) << " " << (double)bw/(aw+bw) << endl;

  }
  return 0;
}
accuracy: 1
time_ms: 190
memory_kb: 3500
final_rank: 5

code_snippet: #include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;

vector<int> a(9),b(9);
int aw=0,bw=0;

void ck(int k,int usd,vector<int> c){
  vector<int> c1;
  for(int i=0;i<9;i++){
    if((usd&(1<<i))!=0) continue;
    //cout << k << " " << i << endl;
    int usd1=(usd|(1<<i));
    c1=c;
    c1[k]=i;
    if(k==8){
        int as=0,bs=0;
        for(int j=0;j<9;j++){ 
          if(a[j]>b[c1[j]]) as+=(a[j]+b[c1[j]]);
          //bs+=(a[j]+b[c1[j]]);
        }
        //cout << as << " " << bs << endl;
     (as>85 ? aw++ : bw++);
      return;
    }

    ck(k+1,usd1,c1);
    
  }
  return;
}

int main(){

  int n;
  cin >> n;
  for(int s=0;s<n;s++){
    for(int &x:a) cin >> x;
    for(int &x:b) cin >> x;
    sort(b.begin(),b.end());

    aw=0;bw=0;
    vector<int> c(9);
    ck(0,0,c);
    //cout << aw << " " << aw+bw << endl;
    cout << fixed << setprecision(5) << (double)aw/(aw+bw) << " " << (double)bw/(aw+bw) << endl;

  }
  return 0;
}
accuracy: 1
time_ms: 900
memory_kb: 3472
final_rank: 18

code_snippet: #include <algorithm>
#include <cstdlib>
#include <iostream>
using namespace std;

int main() {
  int n;
  cin >> n;
  for (int l = 0; l < n; l++) {
    int a[2][9];
    double winrate1 = 0, winrate2 = 0;

    for (int j = 0; j < 2; j++)
      for (int k = 0; k < 9; k++)
        cin >> a[j][k];

    sort(a[1], a[1] + 9);
    do {
      int geitu = 0, jacky = 0;
      for (int z = 0; z < 9; z++) {
        if (a[0][z] > a[1][z])
          geitu += a[0][z] + a[1][z];
        else
          jacky += a[0][z] + a[1][z];
      }
      if (geitu > jacky)
        winrate1++;
      else if (geitu < jacky)
        winrate2++;
    } while (next_permutation(a[1], a[1] + 9));

    double ans, ans2;
    ans = winrate1 / 362880;
    ans *= 100000;
    ans += 0.5;
    ans = int(ans);
    ans /= 100000;
    ans2 = winrate2 / 362880;
    ans2 *= 100000;
    ans2 += 0.5;
    ans2 = int(ans2);
    ans2 /= 100000;
    cout << ans << " " << ans2 << "\n";
  }
  return 0;
}
accuracy: 1
time_ms: 120
memory_kb: 3172
final_rank: 1

code_snippet: #include <cstdlib>
#include <iostream>
using namespace std;
int main() {
  int n;
  cin >> n;
  for (int l = 0; l < n; l++) {
    int num[2][9], a[2][9], geitu, jacky;
    double winrate1 = 0, winrate2 = 0;
    for (int j = 0; j < 2; j++) {
      for (int k = 0; k < 9; k++)
        cin >> a[j][k];
    }
    for (int z = 0; z < 9; z++) {
      num[0][0] = 0;
      num[1][0] = 0;
      if (a[0][0] > a[1][z])
        num[0][0] = (a[0][0] + a[1][z]);
      else
        num[1][0] = (a[0][0] + a[1][z]);
      for (int b = 0; b < 9; b++) {
        if (b == z)
          continue;
        num[0][1] = 0;
        num[1][1] = 0;
        if (a[0][1] > a[1][b])
          num[0][1] = (a[0][1] + a[1][b]);
        else
          num[1][1] = (a[0][1] + a[1][b]);
        for (int c = 0; c < 9; c++) {
          if (c == z || c == b)
            continue;
          num[0][2] = 0;
          num[1][2] = 0;
          if (a[0][2] > a[1][c])
            num[0][2] = (a[0][2] + a[1][c]);
          else
            num[1][2] = (a[0][2] + a[1][c]);
          for (int d = 0; d < 9; d++) {
            if (d == z || d == b || d == c)
              continue;
            num[0][3] = 0;
            num[1][3] = 0;
            if (a[0][3] > a[1][d])
              num[0][3] = (a[0][3] + a[1][d]);
            else
              num[1][3] = (a[0][3] + a[1][d]);
            for (int e = 0; e < 9; e++) {
              if (e == z || e == b || e == c || e == d)
                continue;
              num[0][4] = 0;
              num[1][4] = 0;
              if (a[0][4] > a[1][e])
                num[0][4] = (a[0][4] + a[1][e]);
              else
                num[1][4] = (a[0][4] + a[1][e]);
              for (int f = 0; f < 9; f++) {
                if (f == z || f == b || f == c || f == d || f == e)
                  continue;
                num[0][5] = 0;
                num[1][5] = 0;
                if (a[0][5] > a[1][f])
                  num[0][5] = (a[0][5] + a[1][f]);
                else
                  num[1][5] = (a[0][5] + a[1][f]);
                for (int g = 0; g < 9; g++) {
                  if (g == z || g == b || g == c || g == d || g == e || g == f)
                    continue;
                  num[0][6] = 0;
                  num[1][6] = 0;
                  if (a[0][6] > a[1][g])
                    num[0][6] = (a[0][6] + a[1][g]);
                  else
                    num[1][6] = (a[0][6] + a[1][g]);
                  for (int h = 0; h < 9; h++) {
                    if (h == z || h == b || h == c || h == d || h == e ||
                        h == f || h == g)
                      continue;
                    num[0][7] = 0;
                    num[1][7] = 0;
                    if (a[0][7] > a[1][h])
                      num[0][7] = (a[0][7] + a[1][h]);
                    else
                      num[1][7] = (a[0][7] + a[1][h]);
                    for (int i = 0; i < 9; i++) {
                      if (i == z || i == b || i == c || i == d || i == e ||
                          i == f || i == g || i == h)
                        continue;
                      num[0][8] = 0;
                      num[1][8] = 0;
                      if (a[0][8] > a[1][i])
                        num[0][8] = (a[0][8] + a[1][i]);
                      else
                        num[1][8] = (a[0][8] + a[1][i]);
                    }
                    geitu = 0;
                    jacky = 0;
                    for (int m = 0; m < 9; m++) {
                      geitu += num[0][m];
                      jacky += num[1][m];
                    }
                    if (geitu > jacky)
                      winrate1++;
                    else if (geitu < jacky)
                      winrate2++;
                  }
                }
              }
            }
          }
        }
      }
    }
    double ans, ans2;
    ans = winrate1 / 362880;
    ans *= 100000;
    ans += 0.5;
    ans = int(ans);
    ans /= 100000;
    ans2 = winrate2 / 362880;
    ans2 *= 100000;
    ans2 += 0.5;
    ans2 = int(ans2);
    ans2 /= 100000;
    cout << ans << " " << ans2 << "\n";
  }
  return 0;
}
accuracy: 1
time_ms: 740
memory_kb: 3184
final_rank: 8

code_snippet: #include <cstdlib>
#include <iostream>
using namespace std;

void calculateWinRate(int index, int permutation[], double& winrate1, double& winrate2, int a[][9]) {
  if (index == 9) {
    int num[2][9] = {{0}};
    for (int i = 0; i < 9; i++) {
      if (a[0][i] > a[1][permutation[i]])
        num[0][i] = (a[0][i] + a[1][permutation[i]]);
      else
        num[1][i] = (a[0][i] + a[1][permutation[i]]);
    }
    int geitu = 0, jacky = 0;
    for (int m = 0; m < 9; m++) {
      geitu += num[0][m];
      jacky += num[1][m];
    }
    if (geitu > jacky)
      winrate1++;
    else if (geitu < jacky)
      winrate2++;
  } else {
    for (int i = 0; i < 9; i++) {
      bool found = false;
      for (int j = 0; j < index; j++) {
        if (permutation[j] == i) {
          found = true;
          break;
        }
      }
      if (!found) {
        permutation[index] = i;
        calculateWinRate(index + 1, permutation, winrate1, winrate2, a);
      }
    }
  }
}

int main() {
  int n;
  cin >> n;
  for (int l = 0; l < n; l++) {
    int a[2][9];
    for (int j = 0; j < 2; j++) {
      for (int k = 0; k < 9; k++)
        cin >> a[j][k];
    }
    double winrate1 = 0, winrate2 = 0;
    int permutation[9];
    calculateWinRate(0, permutation, winrate1, winrate2, a);
    double ans = winrate1 / 362880;
    double ans2 = winrate2 / 362880;
    cout << fixed;
    cout.precision(5);
    cout << ans << " " << ans2 << "\n";
  }
  return 0;
}
accuracy: 1
time_ms: 1430
memory_kb: 3276
final_rank: 20

code_snippet: #include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>

int main() {
    int n;
    std::cin >> n;
    std::vector<int> permutation(9);

    for (int i = 0; i < n; i++) {
        int a[2][9];
        for (int j = 0; j < 2; j++)
            for (int k = 0; k < 9; k++)
                std::cin >> a[j][k];

        std::sort(a[0], a[0] + 9);
        std::sort(a[1], a[1] + 9);

        for (int j = 0; j < 9; j++)
            permutation[j] = j;

        double winrate1 = 0, winrate2 = 0;
        do {
            int sum1 = 0, sum2 = 0;
            for (int j = 0; j < 9; j++) {
                if (a[0][j] > a[1][permutation[j]])
                    sum1 += a[0][j] + a[1][permutation[j]];
                else
                    sum2 += a[0][j] + a[1][permutation[j]];
            }
            if (sum1 > sum2)
                winrate1++;
            else if (sum1 < sum2)
                winrate2++;
        } while (std::next_permutation(permutation.begin(), permutation.end()));

        std::cout << std::fixed << std::setprecision(5) << winrate1 / 362880 << " " << winrate2 / 362880 << "\n";
    }

    return 0;
}
accuracy: 1
time_ms: 130
memory_kb: 3232
final_rank: 2

code_snippet: #include <iostream>
using namespace std;
int main() {
  int n;
  cin >> n;
  for (int l = 0; l < n; l++) {
    int num[2][9], a[2][9], geitu, jacky;
    double winrate1 = 0, winrate2 = 0;
    for (int j = 0; j < 2; j++) {
      for (int k = 0; k < 9; k++)
        cin >> a[j][k];
    }
    for (int z = 0; z < 9; z++) {
      num[0][0] = 0;
      num[1][0] = 0;
      if (a[0][0] > a[1][z])
        num[0][0] = (a[0][0] + a[1][z]);
      else
        num[1][0] = (a[0][0] + a[1][z]);
      for (int b = 0; b < 9; b++) {
        if (b == z)
          continue;
        num[0][1] = 0;
        num[1][1] = 0;
        if (a[0][1] > a[1][b])
          num[0][1] = (a[0][1] + a[1][b]);
        else
          num[1][1] = (a[0][1] + a[1][b]);
        for (int c = 0; c < 9; c++) {
          if (c == z || c == b)
            continue;
          num[0][2] = 0;
          num[1][2] = 0;
          if (a[0][2] > a[1][c])
            num[0][2] = (a[0][2] + a[1][c]);
          else
            num[1][2] = (a[0][2] + a[1][c]);
          for (int d = 0; d < 9; d++) {
            if (d == z || d == b || d == c)
              continue;
            num[0][3] = 0;
            num[1][3] = 0;
            if (a[0][3] > a[1][d])
              num[0][3] = (a[0][3] + a[1][d]);
            else
              num[1][3] = (a[0][3] + a[1][d]);
            for (int e = 0; e < 9; e++) {
              if (e == z || e == b || e == c || e == d)
                continue;
              num[0][4] = 0;
              num[1][4] = 0;
              if (a[0][4] > a[1][e])
                num[0][4] = (a[0][4] + a[1][e]);
              else
                num[1][4] = (a[0][4] + a[1][e]);
              for (int f = 0; f < 9; f++) {
                if (f == z || f == b || f == c || f == d || f == e)
                  continue;
                num[0][5] = 0;
                num[1][5] = 0;
                if (a[0][5] > a[1][f])
                  num[0][5] = (a[0][5] + a[1][f]);
                else
                  num[1][5] = (a[0][5] + a[1][f]);
                for (int g = 0; g < 9; g++) {
                  if (g == z || g == b || g == c || g == d || g == e || g == f)
                    continue;
                  num[0][6] = 0;
                  num[1][6] = 0;
                  if (a[0][6] > a[1][g])
                    num[0][6] = (a[0][6] + a[1][g]);
                  else
                    num[1][6] = (a[0][6] + a[1][g]);
                  for (int h = 0; h < 9; h++) {
                    if (h == z || h == b || h == c || h == d || h == e ||
                        h == f || h == g)
                      continue;
                    num[0][7] = 0;
                    num[1][7] = 0;
                    if (a[0][7] > a[1][h])
                      num[0][7] = (a[0][7] + a[1][h]);
                    else
                      num[1][7] = (a[0][7] + a[1][h]);
                    for (int i = 0; i < 9; i++) {
                      if (i == z || i == b || i == c || i == d || i == e ||
                          i == f || i == g || i == h)
                        continue;
                      num[0][8] = 0;
                      num[1][8] = 0;
                      if (a[0][8] > a[1][i])
                        num[0][8] = (a[0][8] + a[1][i]);
                      else
                        num[1][8] = (a[0][8] + a[1][i]);
                      geitu = 0;
                      jacky = 0;
                      for (int m = 0; m < 9; m++) {
                        geitu += num[0][m];
                        jacky += num[1][m];
                      }
                      if (geitu > jacky)
                        winrate1++;
                      else if (geitu < jacky)
                        winrate2++;
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
    double ans, ans2;
    ans = winrate1 / 362880;
    ans *= 100000;
    ans += 0.5;
    ans = int(ans);
    ans /= 100000;
    ans2 = winrate2 / 362880;
    ans2 *= 100000;
    ans2 += 0.5;
    ans2 = int(ans2);
    ans2 /= 100000;
    cout << ans << " " << ans2 << "\n";
  }
  return 0;
}
accuracy: 1
time_ms: 770
memory_kb: 3200
final_rank: 10

code_snippet: #include <cstdlib>
#include <iostream>
using namespace std;
int main() {
  int n;
  cin >> n;
  for (int l = 0; l < n; l++) {
    int num[2][9], a[2][9], geitu, jacky;
    double winrate1 = 0, winrate2 = 0;
    for (int j = 0; j < 2; j++) {
      for (int k = 0; k < 9; k++)
        cin >> a[j][k];
    }
    for (int z = 0; z < 9; z++) {
      num[0][0] = 0;
      num[1][0] = 0;
      if (a[0][0] > a[1][z])
        num[0][0] = (a[0][0] + a[1][z]);
      else
        num[1][0] = (a[0][0] + a[1][z]);
      for (int b = 0; b < 9; b++) {
        if (b == z)
          continue;
        num[0][1] = 0;
        num[1][1] = 0;
        if (a[0][1] > a[1][b])
          num[0][1] = (a[0][1] + a[1][b]);
        else
          num[1][1] = (a[0][1] + a[1][b]);
        for (int c = 0; c < 9; c++) {
          if (c == z || c == b)
            continue;
          num[0][2] = 0;
          num[1][2] = 0;
          if (a[0][2] > a[1][c])
            num[0][2] = (a[0][2] + a[1][c]);
          else
            num[1][2] = (a[0][2] + a[1][c]);
          for (int d = 0; d < 9; d++) {
            if (d == z || d == b || d == c)
              continue;
            num[0][3] = 0;
            num[1][3] = 0;
            if (a[0][3] > a[1][d])
              num[0][3] = (a[0][3] + a[1][d]);
            else
              num[1][3] = (a[0][3] + a[1][d]);
            for (int e = 0; e < 9; e++) {
              if (e == z || e == b || e == c || e == d)
                continue;
              num[0][4] = 0;
              num[1][4] = 0;
              if (a[0][4] > a[1][e])
                num[0][4] = (a[0][4] + a[1][e]);
              else
                num[1][4] = (a[0][4] + a[1][e]);
              for (int f = 0; f < 9; f++) {
                if (f == z || f == b || f == c || f == d || f == e)
                  continue;
                num[0][5] = 0;
                num[1][5] = 0;
                if (a[0][5] > a[1][f])
                  num[0][5] = (a[0][5] + a[1][f]);
                else
                  num[1][5] = (a[0][5] + a[1][f]);
                for (int g = 0; g < 9; g++) {
                  if (g == z || g == b || g == c || g == d || g == e || g == f)
                    continue;
                  num[0][6] = 0;
                  num[1][6] = 0;
                  if (a[0][6] > a[1][g])
                    num[0][6] = (a[0][6] + a[1][g]);
                  else
                    num[1][6] = (a[0][6] + a[1][g]);
                  for (int h = 0; h < 9; h++) {
                    if (h == z || h == b || h == c || h == d || h == e ||
                        h == f || h == g)
                      continue;
                    num[0][7] = 0;
                    num[1][7] = 0;
                    if (a[0][7] > a[1][h])
                      num[0][7] = (a[0][7] + a[1][h]);
                    else
                      num[1][7] = (a[0][7] + a[1][h]);
                    for (int i = 0; i < 9; i++) {
                      if (i == z || i == b || i == c || i == d || i == e ||
                          i == f || i == g || i == h)
                        continue;
                      num[0][8] = 0;
                      num[1][8] = 0;
                      if (a[0][8] > a[1][i])
                        num[0][8] = (a[0][8] + a[1][i]);
                      else
                        num[1][8] = (a[0][8] + a[1][i]);
                      geitu = 0;
                      jacky = 0;
                      for (int m = 0; m < 9; m++) {
                        geitu += num[0][m];
                        jacky += num[1][m];
                      }
                      if (geitu > jacky)
                        winrate1++;
                      else if (geitu < jacky)
                        winrate2++;
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
    double ans, ans2;
    ans = winrate1 / 362880;
    ans *= 100000;
    ans += 0.5;
    ans = int(ans);
    ans /= 100000;
    ans2 = winrate2 / 362880;
    ans2 *= 100000;
    ans2 += 0.5;
    ans2 = int(ans2);
    ans2 /= 100000;
    cout << ans << " " << ans2 << "\n";
  }
  return 0;
}
accuracy: 1
time_ms: 770
memory_kb: 3272
final_rank: 17

code_snippet: #include <cstdlib>
#include <iostream>
using namespace std;
int main() {
  int n;
  cin >> n;
  for (int l = 0; l < n; l++) {
    int num[2][9], a[2][9], geitu, jacky;
    double winrate1 = 0, winrate2 = 0;
    for (int j = 0; j < 2; j++) {
      for (int k = 0; k < 9; k++)
        cin >> a[j][k];
    }
    for (int z = 0; z < 9; z++) {
      num[0][0] = 0;
      num[1][0] = 0;
      if (a[0][0] > a[1][z])
        num[0][0] = (a[0][0] + a[1][z]);
      else
        num[1][0] = (a[0][0] + a[1][z]);
      for (int b = 0; b < 9; b++) {
        if (b == z)
          continue;
        num[0][1] = num[1][1] = 0;
        int ai0 = a[0][1], ai1 = a[1][b];
        if (ai0 > ai1) {
          num[0][1] = ai0 + ai1;
        } else {
          num[1][1] = ai0 + ai1;
        }
        for (int c = 0; c < 9; c++) {
          if (c == z || c == b)
            continue;
          num[0][2] = num[1][2] = 0;
          ai0 = a[0][2], ai1 = a[1][c];
          if (ai0 > ai1) {
            num[0][2] = ai0 + ai1;
          } else {
            num[1][2] = ai0 + ai1;
          }
          for (int d = 0; d < 9; d++) {
            if (d == z || d == b || d == c)
              continue;
            num[0][3] = num[1][3] = 0;
            ai0 = a[0][3], ai1 = a[1][d];
            if (ai0 > ai1) {
              num[0][3] = ai0 + ai1;
            } else {
              num[1][3] = ai0 + ai1;
            }
            for (int e = 0; e < 9; e++) {
              if (e == z || e == b || e == c || e == d)
                continue;
              num[0][4] = num[1][4] = 0;
              ai0 = a[0][4], ai1 = a[1][e];
              if (ai0 > ai1) {
                num[0][4] = ai0 + ai1;
              } else {
                num[1][4] = ai0 + ai1;
              }
              for (int f = 0; f < 9; f++) {
                if (f == z || f == b || f == c || f == d || f == e)
                  continue;
                num[0][5] = num[1][5] = 0;
                ai0 = a[0][5], ai1 = a[1][f];
                if (ai0 > ai1) {
                  num[0][5] = ai0 + ai1;
                } else {
                  num[1][5] = ai0 + ai1;
                }
                for (int g = 0; g < 9; g++) {
                  if (g == z || g == b || g == c || g == d || g == e || g == f)
                    continue;
                  num[0][6] = num[1][6] = 0;
                  ai0 = a[0][6], ai1 = a[1][g];
                  if (ai0 > ai1) {
                    num[0][6] = ai0 + ai1;
                  } else {
                    num[1][6] = ai0 + ai1;
                  }
                  for (int h = 0; h < 9; h++) {
                    if (h == z || h == b || h == c || h == d || h == e ||
                        h == f || h == g)
                      continue;
                    num[0][7] = num[1][7] = 0;
                    ai0 = a[0][7], ai1 = a[1][h];
                    if (ai0 > ai1) {
                      num[0][7] = ai0 + ai1;
                    } else {
                      num[1][7] = ai0 + ai1;
                    }
                    for (int i = 0; i < 9; i++) {
                      if (i == z || i == b || i == c || i == d || i == e ||
                          i == f || i == g || i == h)
                        continue;
                      num[0][8] = num[1][8] = 0;
                      ai0 = a[0][8], ai1 = a[1][i];
                      if (ai0 > ai1) {
                        num[0][8] = ai0 + ai1;
                      } else {
                        num[1][8] = ai0 + ai1;
                      }
                      geitu = jacky = 0;
                      for (int m = 0; m < 9; m++) {
                        geitu += num[0][m];
                        jacky += num[1][m];
                      }
                      if (geitu > jacky)
                        winrate1++;
                      else if (geitu < jacky)
                        winrate2++;
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
    double ans, ans2;
    ans = winrate1 / 362880;
    ans *= 100000;
    ans += 0.5;
    ans = int(ans);
    ans /= 100000;
    ans2 = winrate2 / 362880;
    ans2 *= 100000;
    ans2 += 0.5;
    ans2 = int(ans2);
    ans2 /= 100000;
    cout << ans << " " << ans2 << "\n";
  }
  return 0;
}
accuracy: 1
time_ms: 770
memory_kb: 3124
final_rank: 6

code_snippet: #include <cstdlib>
#include <iostream>
using namespace std;
int main() {
  int n;
  cin >> n;
  for (int l = 0; l < n; l++) {
    int num[2][9], a[2][9], geitu, jacky;
    double winrate1 = 0, winrate2 = 0;
    for (int j = 0; j < 2; j++) {
      for (int k = 0; k < 9; k++)
        cin >> a[j][k];
    }
    for (int z = 0; z < 9; z++) {
      num[0][0] = 0;
      num[1][0] = 0;
      if (a[0][0] > a[1][z])
        num[0][0] = (a[0][0] + a[1][z]);
      else
        num[1][0] = (a[0][0] + a[1][z]);
      for (int b = 0; b < 9; b++) {
        if (b == z)
          continue;
        num[0][1] = 0;
        num[1][1] = 0;
        if (a[0][1] > a[1][b])
          num[0][1] = (a[0][1] + a[1][b]);
        else
          num[1][1] = (a[0][1] + a[1][b]);
        for (int c = 0; c < 9; c++) {
          if (c == z || c == b)
            continue;
          num[0][2] = 0;
          num[1][2] = 0;
          if (a[0][2] > a[1][c])
            num[0][2] = (a[0][2] + a[1][c]);
          else
            num[1][2] = (a[0][2] + a[1][c]);
          for (int d = 0; d < 9; d++) {
            if (d == z || d == b || d == c)
              continue;
            num[0][3] = 0;
            num[1][3] = 0;
            if (a[0][3] > a[1][d])
              num[0][3] = (a[0][3] + a[1][d]);
            else
              num[1][3] = (a[0][3] + a[1][d]);
            for (int e = 0; e < 9; e++) {
              if (e == z || e == b || e == c || e == d)
                continue;
              num[0][4] = 0;
              num[1][4] = 0;
              if (a[0][4] > a[1][e])
                num[0][4] = (a[0][4] + a[1][e]);
              else
                num[1][4] = (a[0][4] + a[1][e]);
              for (int f = 0; f < 9; f++) {
                if (f == z || f == b || f == c || f == d || f == e)
                  continue;
                num[0][5] = 0;
                num[1][5] = 0;
                if (a[0][5] > a[1][f])
                  num[0][5] = (a[0][5] + a[1][f]);
                else
                  num[1][5] = (a[0][5] + a[1][f]);
                for (int g = 0; g < 9; g++) {
                  if (g == z || g == b || g == c || g == d || g == e || g == f)
                    continue;
                  num[0][6] = 0;
                  num[1][6] = 0;
                  if (a[0][6] > a[1][g])
                    num[0][6] = (a[0][6] + a[1][g]);
                  else
                    num[1][6] = (a[0][6] + a[1][g]);
                  for (int h = 0; h < 9; h++) {
                    if (h == z || h == b || h == c || h == d || h == e ||
                        h == f || h == g)
                      continue;
                    num[0][7] = 0;
                    num[1][7] = 0;
                    if (a[0][7] > a[1][h])
                      num[0][7] = (a[0][7] + a[1][h]);
                    else
                      num[1][7] = (a[0][7] + a[1][h]);
                    for (int i = 0; i < 9; i++) {
                      if (i == z || i == b || i == c || i == d || i == e ||
                          i == f || i == g || i == h)
                        continue;
                      num[0][8] = 0;
                      num[1][8] = 0;
                      if (a[0][8] > a[1][i])
                        num[0][8] = (a[0][8] + a[1][i]);
                      else
                        num[1][8] = (a[0][8] + a[1][i]);
                      geitu = num[0][0] + num[0][1] + num[0][2] + num[0][3] + num[0][4] + num[0][5] + num[0][6] + num[0][7] + num[0][8];
                      jacky = num[1][0] + num[1][1] + num[1][2] + num[1][3] + num[1][4] + num[1][5] + num[1][6] + num[1][7] + num[1][8];
                      if (geitu > jacky)
                        winrate1++;
                      else if (geitu < jacky)
                        winrate2++;
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
    double ans, ans2;
    ans = winrate1 / 362880;
    ans *= 100000;
    ans += 0.5;
    ans = int(ans);
    ans /= 100000;
    ans2 = winrate2 / 362880;
    ans2 *= 100000;
    ans2 += 0.5;
    ans2 = int(ans2);
    ans2 /= 100000;
    cout << ans << " " << ans2 << "\n";
  }
  return 0;
}
accuracy: 1
time_ms: 720
memory_kb: 3196
final_rank: 7

code_snippet: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

void playGame(int a[2][9], int z, vector<int>& nums, double& winrate1, double& winrate2) {
    int num[2][9];
    num[0][0] = 0;
    num[1][0] = 0;
    if (a[0][0] > a[1][z])
        num[0][0] = (a[0][0] + a[1][z]);
    else
        num[1][0] = (a[0][0] + a[1][z]);
    for (int i = 1; i < 9; i++) {
        num[0][i] = 0;
        num[1][i] = 0;
    }
    for (int i = 1; i < 9; i++) {
        int j = nums[i - 1];
        if (j <= z)
            j--;
        if (a[0][i] > a[1][j])
            num[0][i] = (a[0][i] + a[1][j]);
        else
            num[1][i] = (a[0][i] + a[1][j]);
    }
    int geitu = 0, jacky = 0;
    for (int i = 0; i < 9; i++) {
        geitu += num[0][i];
        jacky += num[1][i];
    }
    if (geitu > jacky)
        winrate1++;
    else if (geitu < jacky)
        winrate2++;
}

void permute(vector<int>& nums, int l, int r, int a[2][9], double& winrate1, double& winrate2) {
    if (l == r) {
        for (int i = 0; i < 9; i++) {
            playGame(a, i, nums, winrate1, winrate2);
        }
    }
    else {
        for (int i = l; i <= r; i++) {
            swap(nums[l], nums[i]);
            permute(nums, l + 1, r, a, winrate1, winrate2);
            swap(nums[l], nums[i]); // backtrack
        }
    }
}

int main() {
    int n;
    cin >> n;
    for (int l = 0; l < n; l++) {
        int a[2][9];
        for (int j = 0; j < 2; j++) {
            for (int k = 0; k < 9; k++)
                cin >> a[j][k];
        }
        vector<int> nums(8);
        for (int i = 0; i < 8; i++) {
            nums[i] = i + 1;
        }
        double winrate1 = 0, winrate2 = 0;
        permute(nums, 0, 7, a, winrate1, winrate2);
        double ans = winrate1 / 362880;
        ans *= 100000;
        ans += 0.5;
        ans = int(ans);
        ans /= 100000;
        double ans2 = winrate2 / 362880;
        ans2 *= 100000;
        ans2 += 0.5;
        ans2 = int(ans2);
        ans2 /= 100000;
        cout << ans << " " << ans2 << "\n";
    }
    return 0;
}
accuracy: 1
time_ms: 250
memory_kb: 3180
final_rank: 3

code_snippet: #include <cstdlib>
#include <iostream>
using namespace std;

void calculateWinRate(int a[2][9], double& winrate1, double& winrate2) {
    int num[2][9];
    for (int z = 0; z < 9; z++) {
        num[0][0] = 0;
        num[1][0] = 0;
        if (a[0][0] > a[1][z])
            num[0][0] = (a[0][0] + a[1][z]);
        else
            num[1][0] = (a[0][0] + a[1][z]);
        for (int b = 0; b < 9; b++) {
            if (b == z)
                continue;
            num[0][1] = 0;
            num[1][1] = 0;
            if (a[0][1] > a[1][b])
                num[0][1] = (a[0][1] + a[1][b]);
            else
                num[1][1] = (a[0][1] + a[1][b]);
            for (int c = 0; c < 9; c++) {
                if (c == z || c == b)
                    continue;
                num[0][2] = 0;
                num[1][2] = 0;
                if (a[0][2] > a[1][c])
                    num[0][2] = (a[0][2] + a[1][c]);
                else
                    num[1][2] = (a[0][2] + a[1][c]);
                for (int d = 0; d < 9; d++) {
                    if (d == z || d == b || d == c)
                        continue;
                    num[0][3] = 0;
                    num[1][3] = 0;
                    if (a[0][3] > a[1][d])
                        num[0][3] = (a[0][3] + a[1][d]);
                    else
                        num[1][3] = (a[0][3] + a[1][d]);
                    for (int e = 0; e < 9; e++) {
                        if (e == z || e == b || e == c || e == d)
                            continue;
                        num[0][4] = 0;
                        num[1][4] = 0;
                        if (a[0][4] > a[1][e])
                            num[0][4] = (a[0][4] + a[1][e]);
                        else
                            num[1][4] = (a[0][4] + a[1][e]);
                        for (int f = 0; f < 9; f++) {
                            if (f == z || f == b || f == c || f == d || f == e)
                                continue;
                            num[0][5] = 0;
                            num[1][5] = 0;
                            if (a[0][5] > a[1][f])
                                num[0][5] = (a[0][5] + a[1][f]);
                            else
                                num[1][5] = (a[0][5] + a[1][f]);
                            for (int g = 0; g < 9; g++) {
                                if (g == z || g == b || g == c || g == d || g == e || g == f)
                                    continue;
                                num[0][6] = 0;
                                num[1][6] = 0;
                                if (a[0][6] > a[1][g])
                                    num[0][6] = (a[0][6] + a[1][g]);
                                else
                                    num[1][6] = (a[0][6] + a[1][g]);
                                for (int h = 0; h < 9; h++) {
                                    if (h == z || h == b || h == c || h == d || h == e || h == f || h == g)
                                        continue;
                                    num[0][7] = 0;
                                    num[1][7] = 0;
                                    if (a[0][7] > a[1][h])
                                        num[0][7] = (a[0][7] + a[1][h]);
                                    else
                                        num[1][7] = (a[0][7] + a[1][h]);
                                    for (int i = 0; i < 9; i++) {
                                        if (i == z || i == b || i == c || i == d || i == e || i == f || i == g || i == h)
                                            continue;
                                        num[0][8] = 0;
                                        num[1][8] = 0;
                                        if (a[0][8] > a[1][i])
                                            num[0][8] = (a[0][8] + a[1][i]);
                                        else
                                            num[1][8] = (a[0][8] + a[1][i]);
                                        int geitu = 0;
                                        int jacky = 0;
                                        for (int m = 0; m < 9; m++) {
                                            geitu += num[0][m];
                                            jacky += num[1][m];
                                        }
                                        if (geitu > jacky)
                                            winrate1++;
                                        else if (geitu < jacky)
                                            winrate2++;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

int main() {
    int n;
    cin >> n;
    double winrate1 = 0, winrate2 = 0;
    for (int l = 0; l < n; l++) {
        int a[2][9];
        for (int j = 0; j < 2; j++) {
            for (int k = 0; k < 9; k++)
                cin >> a[j][k];
        }
        calculateWinRate(a, winrate1, winrate2);
        double ans, ans2;
        ans = winrate1 / 362880;
        ans *= 100000;
        ans += 0.5;
        ans = int(ans);
        ans /= 100000;
        ans2 = winrate2 / 362880;
        ans2 *= 100000;
        ans2 += 0.5;
        ans2 = int(ans2);
        ans2 /= 100000;
        cout << ans << " " << ans2 << "\n";
        winrate1 = 0;
        winrate2 = 0;
    }
    return 0;
}
accuracy: 1
time_ms: 810
memory_kb: 3192
final_rank: 13

code_snippet: #include <cstdlib>
#include <iostream>
using namespace std;
int main() {
  int n;
  cin >> n;
  for (int l = 0; l < n; l++) {
    int num[2][9], a[2][9], geitu, jacky;
    double winrate1 = 0, winrate2 = 0;
    for (int j = 0; j < 2; j++) {
      for (int k = 0; k < 9; k++)
        cin >> a[j][k];
    }
    for (int z = 0; z < 9; z++) {
      num[0][0] = 0;
      num[1][0] = 0;
      if (a[0][0] > a[1][z])
        num[0][0] = (a[0][0] + a[1][z]);
      else
        num[1][0] = (a[0][0] + a[1][z]);
      for (int b = 0; b < 9; b++) {
        if (b == z)
          continue;
        num[0][1] = num[0][0];
        num[1][1] = num[1][0];
        if (a[0][1] > a[1][b])
          num[0][1] += (a[0][1] + a[1][b]);
        else
          num[1][1] += (a[0][1] + a[1][b]);
        for (int c = 0; c < 9; c++) {
          if (c == z || c == b)
            continue;
          num[0][2] = num[0][1];
          num[1][2] = num[1][1];
          if (a[0][2] > a[1][c])
            num[0][2] += (a[0][2] + a[1][c]);
          else
            num[1][2] += (a[0][2] + a[1][c]);
          for (int d = 0; d < 9; d++) {
            if (d == z || d == b || d == c)
              continue;
            num[0][3] = num[0][2];
            num[1][3] = num[1][2];
            if (a[0][3] > a[1][d])
              num[0][3] += (a[0][3] + a[1][d]);
            else
              num[1][3] += (a[0][3] + a[1][d]);
            for (int e = 0; e < 9; e++) {
              if (e == z || e == b || e == c || e == d)
                continue;
              num[0][4] = num[0][3];
              num[1][4] = num[1][3];
              if (a[0][4] > a[1][e])
                num[0][4] += (a[0][4] + a[1][e]);
              else
                num[1][4] += (a[0][4] + a[1][e]);
              for (int f = 0; f < 9; f++) {
                if (f == z || f == b || f == c || f == d || f == e)
                  continue;
                num[0][5] = num[0][4];
                num[1][5] = num[1][4];
                if (a[0][5] > a[1][f])
                  num[0][5] += (a[0][5] + a[1][f]);
                else
                  num[1][5] += (a[0][5] + a[1][f]);
                for (int g = 0; g < 9; g++) {
                  if (g == z || g == b || g == c || g == d || g == e || g == f)
                    continue;
                  num[0][6] = num[0][5];
                  num[1][6] = num[1][5];
                  if (a[0][6] > a[1][g])
                    num[0][6] += (a[0][6] + a[1][g]);
                  else
                    num[1][6] += (a[0][6] + a[1][g]);
                  for (int h = 0; h < 9; h++) {
                    if (h == z || h == b || h == c || h == d || h == e ||
                        h == f || h == g)
                      continue;
                    num[0][7] = num[0][6];
                    num[1][7] = num[1][6];
                    if (a[0][7] > a[1][h])
                      num[0][7] += (a[0][7] + a[1][h]);
                    else
                      num[1][7] += (a[0][7] + a[1][h]);
                    for (int i = 0; i < 9; i++) {
                      if (i == z || i == b || i == c || i == d || i == e ||
                          i == f || i == g || i == h)
                        continue;
                      num[0][8] = num[0][7];
                      num[1][8] = num[1][7];
                      if (a[0][8] > a[1][i])
                        num[0][8] += (a[0][8] + a[1][i]);
                      else
                        num[1][8] += (a[0][8] + a[1][i]);
                      geitu = num[0][8];
                      jacky = num[1][8];
                      if (geitu > jacky)
                        winrate1++;
                      else if (geitu < jacky)
                        winrate2++;
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
    double ans, ans2;
    ans = winrate1 / 362880;
    ans *= 100000;
    ans += 0.5;
    ans = int(ans);
    ans /= 100000;
    ans2 = winrate2 / 362880;
    ans2 *= 100000;
    ans2 += 0.5;
    ans2 = int(ans2);
    ans2 /= 100000;
    cout << ans << " " << ans2 << "\n";
  }
  return 0;
}
accuracy: 1
time_ms: 770
memory_kb: 3236
final_rank: 14

code_snippet: #include <cstdlib>
#include <iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    for (int l = 0; l < n; l++) {
        int num[2][9], a[2][9], geitu, jacky;
        double winrate1 = 0, winrate2 = 0;
        for (int j = 0; j < 2; j++) {
            for (int k = 0; k < 9; k++)
                cin >> a[j][k];
        }
        for (int z = 0; z < 9; z++) {
            num[0][0] = 0;
            num[1][0] = 0;
            if (a[0][0] > a[1][z])
                num[0][0] = (a[0][0] + a[1][z]);
            else
                num[1][0] = (a[0][0] + a[1][z]);
            for (int b = 0; b < 9; b++) {
                if (b == z)
                    continue;
                num[0][1] = 0;
                num[1][1] = 0;
                if (a[0][1] > a[1][b])
                    num[0][1] = (a[0][1] + a[1][b]);
                else
                    num[1][1] = (a[0][1] + a[1][b]);
                for (int c = 0; c < 9; c++) {
                    if (c == z || c == b)
                        continue;
                    num[0][2] = 0;
                    num[1][2] = 0;
                    if (a[0][2] > a[1][c])
                        num[0][2] = (a[0][2] + a[1][c]);
                    else
                        num[1][2] = (a[0][2] + a[1][c]);
                    for (int d = 0; d < 9; d++) {
                        if (d == z || d == b || d == c)
                            continue;
                        num[0][3] = 0;
                        num[1][3] = 0;
                        if (a[0][3] > a[1][d])
                            num[0][3] = (a[0][3] + a[1][d]);
                        else
                            num[1][3] = (a[0][3] + a[1][d]);
                        for (int e = 0; e < 9; e++) {
                            if (e == z || e == b || e == c || e == d)
                                continue;
                            num[0][4] = 0;
                            num[1][4] = 0;
                            if (a[0][4] > a[1][e])
                                num[0][4] = (a[0][4] + a[1][e]);
                            else
                                num[1][4] = (a[0][4] + a[1][e]);
                            for (int f = 0; f < 9; f++) {
                                if (f == z || f == b || f == c || f == d || f == e)
                                    continue;
                                num[0][5] = 0;
                                num[1][5] = 0;
                                if (a[0][5] > a[1][f])
                                    num[0][5] = (a[0][5] + a[1][f]);
                                else
                                    num[1][5] = (a[0][5] + a[1][f]);
                                for (int g = 0; g < 9; g++) {
                                    if (g == z || g == b || g == c || g == d || g == e || g == f)
                                        continue;
                                    num[0][6] = 0;
                                    num[1][6] = 0;
                                    if (a[0][6] > a[1][g])
                                        num[0][6] = (a[0][6] + a[1][g]);
                                    else
                                        num[1][6] = (a[0][6] + a[1][g]);
                                    for (int h = 0; h < 9; h++) {
                                        if (h == z || h == b || h == c || h == d || h == e ||
                                            h == f || h == g)
                                            continue;
                                        num[0][7] = 0;
                                        num[1][7] = 0;
                                        if (a[0][7] > a[1][h])
                                            num[0][7] = (a[0][7] + a[1][h]);
                                        else
                                            num[1][7] = (a[0][7] + a[1][h]);
                                        for (int i = 0; i < 9; i++) {
                                            if (i == z || i == b || i == c || i == d || i == e ||
                                                i == f || i == g || i == h)
                                                continue;
                                            num[0][8] = 0;
                                            num[1][8] = 0;
                                            if (a[0][8] > a[1][i])
                                                num[0][8] = (a[0][8] + a[1][i]);
                                            else
                                                num[1][8] = (a[0][8] + a[1][i]);
                                            geitu = 0;
                                            jacky = 0;
                                            for (int m = 0; m < 9; m++) {
                                                geitu += num[0][m];
                                                jacky += num[1][m];
                                            }
                                            if (geitu > jacky)
                                                winrate1++;
                                            else if (geitu < jacky)
                                                winrate2++;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        double ans, ans2;
        ans = winrate1 / 362880;
        ans *= 100000;
        ans += 0.5;
        ans = int(ans);
        ans /= 100000;
        ans2 = 1 - ans; // winrate2 = 1 - winrate1, so we can simply calculate this way
        cout << ans << " " << ans2 << "\n";
    }
    return 0;
}
accuracy: 1
time_ms: 760
memory_kb: 3180
final_rank: 9

code_snippet: #include <cstdlib>
#include <iostream>
using namespace std;
int main() {
  int n;
  cin >> n;
  for (int l = 0; l < n; l++) {
    int num[2][9], a[2][9], geitu, jacky;
    double winrate1 = 0, winrate2 = 0;
    for (int j = 0; j < 2; j++) {
      for (int k = 0; k < 9; k++)
        cin >> a[j][k];
    }
    for (int z = 0; z < 9; z++) {
      num[0][0] = 0;
      num[1][0] = 0;
      if (a[0][0] > a[1][z])
        num[0][0] = (a[0][0] + a[1][z]);
      else
        num[1][0] = (a[0][0] + a[1][z]);
      for (int b = 0; b < 9; b++) {
        if (b == z)
          continue;
        num[0][1] = 0;
        num[1][1] = 0;
        if (a[0][1] > a[1][b])
          num[0][1] = (a[0][1] + a[1][b]);
        else
          num[1][1] = (a[0][1] + a[1][b]);
        for (int c = 0; c < 9; c++) {
          if (c == z || c == b)
            continue;
          num[0][2] = 0;
          num[1][2] = 0;
          if (a[0][2] > a[1][c])
            num[0][2] = (a[0][2] + a[1][c]);
          else
            num[1][2] = (a[0][2] + a[1][c]);
          for (int d = 0; d < 9; d++) {
            if (d == z || d == b || d == c)
              continue;
            num[0][3] = 0;
            num[1][3] = 0;
            if (a[0][3] > a[1][d])
              num[0][3] = (a[0][3] + a[1][d]);
            else
              num[1][3] = (a[0][3] + a[1][d]);
            for (int e = 0; e < 9; e++) {
              if (e == z || e == b || e == c || e == d)
                continue;
              num[0][4] = 0;
              num[1][4] = 0;
              if (a[0][4] > a[1][e])
                num[0][4] = (a[0][4] + a[1][e]);
              else
                num[1][4] = (a[0][4] + a[1][e]);
              for (int f = 0; f < 9; f++) {
                if (f == z || f == b || f == c || f == d || f == e)
                  continue;
                num[0][5] = 0;
                num[1][5] = 0;
                if (a[0][5] > a[1][f])
                  num[0][5] = (a[0][5] + a[1][f]);
                else
                  num[1][5] = (a[0][5] + a[1][f]);
                for (int g = 0; g < 9; g++) {
                  if (g == z || g == b || g == c || g == d || g == e || g == f)
                    continue;
                  num[0][6] = 0;
                  num[1][6] = 0;
                  if (a[0][6] > a[1][g])
                    num[0][6] = (a[0][6] + a[1][g]);
                  else
                    num[1][6] = (a[0][6] + a[1][g]);
                  for (int h = 0; h < 9; h++) {
                    if (h == z || h == b || h == c || h == d || h == e ||
                        h == f || h == g)
                      continue;
                    num[0][7] = 0;
                    num[1][7] = 0;
                    if (a[0][7] > a[1][h])
                      num[0][7] = (a[0][7] + a[1][h]);
                    else
                      num[1][7] = (a[0][7] + a[1][h]);
                    for (int i = 0; i < 9; i++) {
                      if (i == z || i == b || i == c || i == d || i == e ||
                          i == f || i == g || i == h)
                        continue;
                      num[0][8] = 0;
                      num[1][8] = 0;
                      if (a[0][8] > a[1][i])
                        num[0][8] = (a[0][8] + a[1][i]);
                      else
                        num[1][8] = (a[0][8] + a[1][i]);
                      geitu = 0;
                      jacky = 0;
                      for (int m = 0; m < 9; m++) {
                        geitu += num[0][m];
                        jacky += num[1][m];
                      }
                      if (geitu > jacky)
                        winrate1++;
                      else if (geitu < jacky)
                        winrate2++;
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
    double ans, ans2;
    ans = winrate1 / 362880.0;
    ans *= 100000.0;
    ans += 0.5;
    ans = int(ans);
    ans /= 100000.0;
    ans2 = winrate2 / 362880.0;
    ans2 *= 100000.0;
    ans2 += 0.5;
    ans2 = int(ans2);
    ans2 /= 100000.0;
    cout << ans << " " << ans2 << "\n";
  }
  return 0;
}
accuracy: 1
time_ms: 770
memory_kb: 3208
final_rank: 11

code_snippet: #include <cstdlib>
#include <iostream>
using namespace std;
int main() {
  int n;
  cin >> n;
  for (int l = 0; l < n; l++) {
    int num[2][9], a[2][9], geitu = 0, jacky = 0;
    double winrate1 = 0, winrate2 = 0;
    for (int j = 0; j < 2; j++) {
      for (int k = 0; k < 9; k++) {
        cin >> a[j][k];
        if (j == 0) {
          num[0][k] = 0;
          num[1][k] = 0;
        }
      }
    }
    for (int z = 0; z < 9; z++) {
      if (a[0][0] > a[1][z]) {
        num[0][0] = (a[0][0] + a[1][z]);
        num[1][0] = 0;
      }
      else {
        num[0][0] = 0;
        num[1][0] = (a[0][0] + a[1][z]);
      }
      for (int b = 0; b < 9; b++) {
        if (b == z)
          continue;
        if (a[0][1] > a[1][b]) {
          num[0][1] = (a[0][1] + a[1][b]);
          num[1][1] = 0;
        }
        else {
          num[0][1] = 0;
          num[1][1] = (a[0][1] + a[1][b]);
        }
        for (int c = 0; c < 9; c++) {
          if (c == z || c == b)
            continue;
          if (a[0][2] > a[1][c]) {
            num[0][2] = (a[0][2] + a[1][c]);
            num[1][2] = 0;
          }
          else {
            num[0][2] = 0;
            num[1][2] = (a[0][2] + a[1][c]);
          }
          for (int d = 0; d < 9; d++) {
            if (d == z || d == b || d == c)
              continue;
            if (a[0][3] > a[1][d]) {
              num[0][3] = (a[0][3] + a[1][d]);
              num[1][3] = 0;
            }
            else {
              num[0][3] = 0;
              num[1][3] = (a[0][3] + a[1][d]);
            }
            for (int e = 0; e < 9; e++) {
              if (e == z || e == b || e == c || e == d)
                continue;
              if (a[0][4] > a[1][e]) {
                num[0][4] = (a[0][4] + a[1][e]);
                num[1][4] = 0;
              }
              else {
                num[0][4] = 0;
                num[1][4] = (a[0][4] + a[1][e]);
              }
              for (int f = 0; f < 9; f++) {
                if (f == z || f == b || f == c || f == d || f == e)
                  continue;
                if (a[0][5] > a[1][f]) {
                  num[0][5] = (a[0][5] + a[1][f]);
                  num[1][5] = 0;
                }
                else {
                  num[0][5] = 0;
                  num[1][5] = (a[0][5] + a[1][f]);
                }
                for (int g = 0; g < 9; g++) {
                  if (g == z || g == b || g == c || g == d || g == e || g == f)
                    continue;
                  if (a[0][6] > a[1][g]) {
                    num[0][6] = (a[0][6] + a[1][g]);
                    num[1][6] = 0;
                  }
                  else {
                    num[0][6] = 0;
                    num[1][6] = (a[0][6] + a[1][g]);
                  }
                  for (int h = 0; h < 9; h++) {
                    if (h == z || h == b || h == c || h == d || h == e ||
                        h == f || h == g)
                      continue;
                    if (a[0][7] > a[1][h]) {
                      num[0][7] = (a[0][7] + a[1][h]);
                      num[1][7] = 0;
                    }
                    else {
                      num[0][7] = 0;
                      num[1][7] = (a[0][7] + a[1][h]);
                    }
                    for (int i = 0; i < 9; i++) {
                      if (i == z || i == b || i == c || i == d || i == e ||
                          i == f || i == g || i == h)
                        continue;
                      if (a[0][8] > a[1][i]) {
                        num[0][8] = (a[0][8] + a[1][i]);
                        num[1][8] = 0;
                      }
                      else {
                        num[0][8] = 0;
                        num[1][8] = (a[0][8] + a[1][i]);
                      }
                      geitu = 0;
                      jacky = 0;
                      for (int m = 0; m < 9; m++) {
                        geitu += num[0][m];
                        jacky += num[1][m];
                      }
                      if (geitu > jacky)
                        winrate1++;
                      else if (geitu < jacky)
                        winrate2++;
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
    double ans, ans2;
    ans = winrate1 / 362880;
    ans *= 100000;
    ans += 0.5;
    ans = int(ans);
    ans /= 100000;
    ans2 = winrate2 / 362880;
    ans2 *= 100000;
    ans2 += 0.5;
    ans2 = int(ans2);
    ans2 /= 100000;
    cout << ans << " " << ans2 << "\n";
  }
  return 0;
}
accuracy: 1
time_ms: 770
memory_kb: 3216
final_rank: 12

code_snippet: #include <cstdlib>
#include <iostream>
using namespace std;
int main() {
  int n;
  cin >> n;
  for (int l = 0; l < n; l++) {
    int num[2][9], a[2][9], geitu, jacky, z, b, c, d, e, f, g, h, i;
    double winrate1 = 0, winrate2 = 0;
    for (int j = 0; j < 2; j++) {
      for (int k = 0; k < 9; k++)
        cin >> a[j][k];
    }
    for (z = 0; z < 9; z++) {
      num[0][0] = 0;
      num[1][0] = 0;
      if (a[0][0] > a[1][z])
        num[0][0] = (a[0][0] + a[1][z]);
      else
        num[1][0] = (a[0][0] + a[1][z]);
      for (b = 0; b < 9; b++) {
        if (b == z)
          continue;
        num[0][1] = 0;
        num[1][1] = 0;
        if (a[0][1] > a[1][b])
          num[0][1] = (a[0][1] + a[1][b]);
        else
          num[1][1] = (a[0][1] + a[1][b]);
        for (c = 0; c < 9; c++) {
          if (c == z || c == b)
            continue;
          num[0][2] = 0;
          num[1][2] = 0;
          if (a[0][2] > a[1][c])
            num[0][2] = (a[0][2] + a[1][c]);
          else
            num[1][2] = (a[0][2] + a[1][c]);
          for (d = 0; d < 9; d++) {
            if (d == z || d == b || d == c)
              continue;
            num[0][3] = 0;
            num[1][3] = 0;
            if (a[0][3] > a[1][d])
              num[0][3] = (a[0][3] + a[1][d]);
            else
              num[1][3] = (a[0][3] + a[1][d]);
            for (e = 0; e < 9; e++) {
              if (e == z || e == b || e == c || e == d)
                continue;
              num[0][4] = 0;
              num[1][4] = 0;
              if (a[0][4] > a[1][e])
                num[0][4] = (a[0][4] + a[1][e]);
              else
                num[1][4] = (a[0][4] + a[1][e]);
              for (f = 0; f < 9; f++) {
                if (f == z || f == b || f == c || f == d || f == e)
                  continue;
                num[0][5] = 0;
                num[1][5] = 0;
                if (a[0][5] > a[1][f])
                  num[0][5] = (a[0][5] + a[1][f]);
                else
                  num[1][5] = (a[0][5] + a[1][f]);
                for (g = 0; g < 9; g++) {
                  if (g == z || g == b || g == c || g == d || g == e || g == f)
                    continue;
                  num[0][6] = 0;
                  num[1][6] = 0;
                  if (a[0][6] > a[1][g])
                    num[0][6] = (a[0][6] + a[1][g]);
                  else
                    num[1][6] = (a[0][6] + a[1][g]);
                  for (h = 0; h < 9; h++) {
                    if (h == z || h == b || h == c || h == d || h == e ||
                        h == f || h == g)
                      continue;
                    num[0][7] = 0;
                    num[1][7] = 0;
                    if (a[0][7] > a[1][h])
                      num[0][7] = (a[0][7] + a[1][h]);
                    else
                      num[1][7] = (a[0][7] + a[1][h]);
                    for (i = 0; i < 9; i++) {
                      if (i == z || i == b || i == c || i == d || i == e ||
                          i == f || i == g || i == h)
                        continue;
                      num[0][8] = 0;
                      num[1][8] = 0;
                      if (a[0][8] > a[1][i])
                        num[0][8] = (a[0][8] + a[1][i]);
                      else
                        num[1][8] = (a[0][8] + a[1][i]);
                      geitu = 0;
                      jacky = 0;
                      for (int m = 0; m < 9; m++) {
                        geitu += num[0][m];
                        jacky += num[1][m];
                      }
                      if (geitu > jacky)
                        winrate1++;
                      else if (geitu < jacky)
                        winrate2++;
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
    double ans, ans2;
    ans = winrate1 / 362880;
    ans *= 100000;
    ans += 0.5;
    ans = int(ans);
    ans /= 100000;
    ans2 = winrate2 / 362880;
    ans2 *= 100000;
    ans2 += 0.5;
    ans2 = int(ans2);
    ans2 /= 100000;
    cout << ans << " " << ans2 << "\n";
  }
  return 0;
}
accuracy: 1
time_ms: 770
memory_kb: 3236
final_rank: 14

code_snippet: #include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  for (int l = 0; l < n; l++) {
    int num[2][9], a[2][9], geitu, jacky;
    double winrate1 = 0, winrate2 = 0;
    for (int j = 0; j < 2; j++) {
      for (int k = 0; k < 9; k++)
        cin >> a[j][k];
    }
    for (int z = 0; z < 9; z++) {
      num[0][0] = 0;
      num[1][0] = 0;
      if (a[0][0] > a[1][z])
        num[0][0] = (a[0][0] + a[1][z]);
      else
        num[1][0] = (a[0][0] + a[1][z]);
      for (int b = 0; b < 9; b++) {
        if (b == z)
          continue;
        num[0][1] = 0;
        num[1][1] = 0;
        if (a[0][1] > a[1][b])
          num[0][1] = (a[0][1] + a[1][b]);
        else
          num[1][1] = (a[0][1] + a[1][b]);
        for (int c = 0; c < 9; c++) {
          if (c == z || c == b)
            continue;
          num[0][2] = 0;
          num[1][2] = 0;
          if (a[0][2] > a[1][c])
            num[0][2] = (a[0][2] + a[1][c]);
          else
            num[1][2] = (a[0][2] + a[1][c]);
          for (int d = 0; d < 9; d++) {
            if (d == z || d == b || d == c)
              continue;
            num[0][3] = 0;
            num[1][3] = 0;
            if (a[0][3] > a[1][d])
              num[0][3] = (a[0][3] + a[1][d]);
            else
              num[1][3] = (a[0][3] + a[1][d]);
            for (int e = 0; e < 9; e++) {
              if (e == z || e == b || e == c || e == d)
                continue;
              num[0][4] = 0;
              num[1][4] = 0;
              if (a[0][4] > a[1][e])
                num[0][4] = (a[0][4] + a[1][e]);
              else
                num[1][4] = (a[0][4] + a[1][e]);
              for (int f = 0; f < 9; f++) {
                if (f == z || f == b || f == c || f == d || f == e)
                  continue;
                num[0][5] = 0;
                num[1][5] = 0;
                if (a[0][5] > a[1][f])
                  num[0][5] = (a[0][5] + a[1][f]);
                else
                  num[1][5] = (a[0][5] + a[1][f]);
                for (int g = 0; g < 9; g++) {
                  if (g == z || g == b || g == c || g == d || g == e || g == f)
                    continue;
                  num[0][6] = 0;
                  num[1][6] = 0;
                  if (a[0][6] > a[1][g])
                    num[0][6] = (a[0][6] + a[1][g]);
                  else
                    num[1][6] = (a[0][6] + a[1][g]);
                  for (int h = 0; h < 9; h++) {
                    if (h == z || h == b || h == c || h == d || h == e ||
                        h == f || h == g)
                      continue;
                    num[0][7] = 0;
                    num[1][7] = 0;
                    if (a[0][7] > a[1][h])
                      num[0][7] = (a[0][7] + a[1][h]);
                    else
                      num[1][7] = (a[0][7] + a[1][h]);
                    for (int i = 0; i < 9; i++) {
                      if (i == z || i == b || i == c || i == d || i == e ||
                          i == f || i == g || i == h)
                        continue;
                      num[0][8] = 0;
                      num[1][8] = 0;
                      if (a[0][8] > a[1][i])
                        num[0][8] = (a[0][8] + a[1][i]);
                      else
                        num[1][8] = (a[0][8] + a[1][i]);
                      geitu = 0;
                      jacky = 0;
                      for (int m = 0; m < 9; m++) {
                        geitu += num[0][m];
                        jacky += num[1][m];
                      }
                      if (geitu > jacky)
                        winrate1++;
                      else if (geitu < jacky)
                        winrate2++;
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
    double ans, ans2;
    ans = winrate1 / 362880;
    ans *= 100000;
    ans += 0.5;
    ans = int(ans);
    ans /= 100000;
    ans2 = winrate2 / 362880;
    ans2 *= 100000;
    ans2 += 0.5;
    ans2 = int(ans2);
    ans2 /= 100000;
    cout << ans << " " << ans2 << "\n";
  }
  return 0;
}
accuracy: 1
time_ms: 770
memory_kb: 3256
final_rank: 16

code_snippet: #pragma region templates
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using db = double;
using ld = long double;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<vector<T>>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using PQR = priority_queue<T, vector<T>, greater<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))
#define all(v) (v).begin(), (v).end()
#define siz(v) (ll)(v).size()
#define rep(i, a, n) for (ll i = a; i < (ll)(n); ++i)
#define repr(i, a, n) for (ll i = n - 1; (ll)a <= i; --i)
#define pw2(n) (1ll << (n))
#define pcntl(x) __builtin_popcountll(x)
#define ENDL '\n'
typedef pair<int, int> Pi;
typedef pair<ll, ll> PL;
constexpr ll mod = 1000000007; // 998244353;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 + 99);
constexpr ll dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1};
template <typename T, typename U> inline bool chmin(T &t, const U &u) {
  if (t > u) {
    t = u;
    return 1;
  }
  return 0;
}
template <typename T, typename U> inline bool chmax(T &t, const U &u) {
  if (t < u) {
    t = u;
    return 1;
  }
  return 0;
}
template <typename T> inline T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
inline void Yes() { cout << "Yes" << ENDL; }
inline void No() { cout << "No" << ENDL; }
inline void YES() { cout << "YES" << ENDL; }
inline void NO() { cout << "NO" << ENDL; }

template <typename T, typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for (; n; n >>= 1) {
    if (n & 1)
      res = res * a;
    a = a * a;
  }
  return res;
}

template <typename T> vector<T> finddivisor(T x) { //整数xの約数(xを含む)
  vector<T> divisor;
  for (T i = 1; (i * i) <= x; i++) {
    if (x % i == 0) {
      divisor.push_back(i);
      if (i * i != x) {
        divisor.push_back(x / i);
      }
    }
  }
  sort(divisor.begin(), divisor.end());
  return divisor;
}

template <typename T> V<T> prefix_sum(const V<T> &v) {
  int n = v.size();
  V<T> ret(n + 1);
  rep(i, 0, n) ret[i + 1] = ret[i] + v[i];
  return ret;
}

template <typename T> void get_unique(V<T> &v) {
  sort(all(v));
  v.erase(unique(all(v)), v.end());
  return;
}

template <typename T> T rand(T l, T r) {
  static random_device rd;
  static mt19937 g(rd());
  return uniform_int_distribution<T>(l, r)(g);
} //[]

template <typename T> istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &&x : vec)
    is >> x;
  return is;
}

template <typename T, typename Y>
ostream &operator<<(ostream &os, const pair<T, Y> &p) {
  return os << "{" << p.fs << "," << p.sc << "}";
}

template <typename T> ostream &operator<<(ostream &os, const V<T> &v) {
  os << "{";
  for (auto e : v)
    os << e << ",";
  return os << "}";
}

#ifdef LOCAL
template <typename... Args> void debug(Args &...args) {
  for (auto const &x : {args...}) {
    cerr << x << ' ';
  }
  cerr << ENDL;
}
#else
template <typename... Args> void debug(Args &...args) { return; }
#endif
#pragma endregion templates

signed main() {
  cin.tie(0);
  cerr.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  int qq;
  cin >> qq;
  while (qq--) {
    V<ll> a(9), b = a;
    cin >> a >> b;

    map<PL, pair<db, db>> ma;

    auto dfs = [&](auto self, ll bit, ll res) -> pair<db, db> {
      if (ma.count(mp(bit, res))) {
        return ma[mp(bit, res)];
      }

      pair<db, db> ret = {0, 0};
      int r = __builtin_popcountll(bit);
      if (r == 9) {
        if (res > 0)
          ret.fs += 1;
        else if (res < 0)
          ret.sc += 1;
        ma[mp(bit, res)] = ret;
        return ret;
      }

      rep(i, 0, 9) {
        if (bit & pw2(i))
          continue;

        ll nres = res;
        if (a[i] > b[r])
          nres += a[i] + b[r];
        else
          nres -= a[i] + b[r];
        auto tmp = self(self, bit | pw2(i), nres);
        ret.fs += tmp.fs;
        ret.sc += tmp.sc;
      }

      ma[mp(bit, res)] = ret;
      return ret;
    };

    pair<db, db> p = dfs(dfs, 0, 0);
    rep(i,1,10){
      p.fs/=(db)i;
      p.sc/=(db)i;
    }
    cout << p.fs << " " << p.sc << ENDL;
  }
}
//(・_・)(・_・)(・_・)(・_・)
// CHECK overflow,what to output?
// any other simpler approach?
accuracy: 1
time_ms: 160
memory_kb: 4572
final_rank: 19

code_snippet: #line 2 "/home/yuruhiya/programming/library/template/template.cpp"
#include <bits/stdc++.h>
#line 6 "/home/yuruhiya/programming/library/template/constants.cpp"
using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rfor(i, m, n) for (int i = (m); i >= (n); --i)
#define unless(c) if (!(c))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define range_it(a, l, r) (a).begin() + (l), (a).begin() + (r)

using namespace std;
using ll = long long;
using LD = long double;
using VB = vector<bool>;
using VVB = vector<VB>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VS = vector<string>;
using VD = vector<LD>;
using PII = pair<int, int>;
using VP = vector<PII>;
using PLL = pair<ll, ll>;
using VPL = vector<PLL>;
template <class T> using PQ = priority_queue<T>;
template <class T> using PQS = priority_queue<T, vector<T>, greater<T>>;
constexpr int inf = 1e9;
constexpr long long inf_ll = 1e18, MOD = 1000000007;
constexpr long double PI = 3.14159265358979323846, EPS = 1e-12;
#line 7 "/home/yuruhiya/programming/library/template/Input.cpp"
using namespace std;

#ifdef _WIN32
#define getchar_unlocked _getchar_nolock
#define putchar_unlocked _putchar_nolock
#define fwrite_unlocked fwrite
#define fflush_unlocked fflush
#endif
class Input {
	static int gc() {
		return getchar_unlocked();
	}
	template <class T> static void read(T& v) {
		cin >> v;
	}
	static void read(char& v) {
		while (isspace(v = gc()))
			;
	}
	static void read(bool& v) {
		v = read<char>() != '0';
	}
	static void read(string& v) {
		v.clear();
		for (char c = read<char>(); !isspace(c); c = gc()) v += c;
	}
	static void read(int& v) {
		v = 0;
		bool neg = false;
		char c = read<char>();
		if (c == '-') {
			neg = true;
			c = gc();
		}
		for (; isdigit(c); c = gc()) v = v * 10 + (c - '0');
		if (neg) v = -v;
	}
	static void read(long long& v) {
		v = 0;
		bool neg = false;
		char c = read<char>();
		if (c == '-') {
			neg = true;
			c = gc();
		}
		for (; isdigit(c); c = gc()) v = v * 10 + (c - '0');
		if (neg) v = -v;
	}
	static void read(double& v) {
		v = 0;
		double dp = 1;
		bool neg = false, after_dp = false;
		char c = read<char>();
		if (c == '-') {
			neg = true;
			c = gc();
		}
		for (; isdigit(c) || c == '.'; c = gc()) {
			if (c == '.') {
				after_dp = true;
			} else if (after_dp) {
				v += (c - '0') * (dp *= 0.1);
			} else {
				v = v * 10 + (c - '0');
			}
		}
		if (neg) v = -v;
	}
	static void read(long double& v) {
		v = 0;
		long double dp = 1;
		bool neg = false, after_dp = false;
		char c = read<char>();
		if (c == '-') {
			neg = true;
			c = gc();
		}
		for (; isdigit(c) || c == '.'; c = gc()) {
			if (c == '.') {
				after_dp = true;
			} else if (after_dp) {
				v += (c - '0') * (dp *= 0.1);
			} else {
				v = v * 10 + (c - '0');
			}
		}
		if (neg) v = -v;
	}
	template <class T, class U> static void read(pair<T, U>& v) {
		read(v.first);
		read(v.second);
	}
	template <class T> static void read(vector<T>& v) {
		for (auto& e : v) read(e);
	}
	template <size_t N = 0, class T> static void read_tuple_impl(T& v) {
		if constexpr (N < tuple_size_v<T>) {
			read(get<N>(v));
			read_tuple_impl<N + 1>(v);
		}
	}
	template <class... T> static void read(tuple<T...>& v) {
		read_tuple_impl(v);
	}
	struct ReadVectorHelper {
		int n;
		ReadVectorHelper(int _n) : n(_n) {}
		template <class T> operator vector<T>() {
			vector<T> v(n);
			read(v);
			return v;
		}
	};
	struct Read2DVectorHelper {
		int n, m;
		Read2DVectorHelper(const pair<int, int>& nm) : n(nm.first), m(nm.second) {}
		template <class T> operator vector<vector<T>>() {
			vector<vector<T>> v(n, vector<T>(m));
			read(v);
			return v;
		}
	};

public:
	static string read_line() {
		string v;
		for (char c = read<char>(); c != '\n' && c != '\0'; c = gc()) v += c;
		return v;
	}
	template <class T> static T read() {
		T v;
		read(v);
		return v;
	}
	template <class T> operator T() const {
		return read<T>();
	}
	int operator--(int) const {
		return read<int>() - 1;
	}
	ReadVectorHelper operator[](int n) const {
		return ReadVectorHelper(n);
	}
	Read2DVectorHelper operator[](const pair<int, int>& nm) const {
		return Read2DVectorHelper(nm);
	}
	void operator()() const {}
	template <class H, class... T> void operator()(H&& h, T&&... t) const {
		read(h);
		operator()(forward<T>(t)...);
	}

private:
	template <template <class...> class, class...> struct Multiple;
	template <template <class...> class V, class Head, class... Tail>
	struct Multiple<V, Head, Tail...> {
		template <class... Args> using vec = V<vector<Head>, Args...>;
		using type = typename Multiple<vec, Tail...>::type;
	};
	template <template <class...> class V> struct Multiple<V> { using type = V<>; };
	template <class... T> using multiple_t = typename Multiple<tuple, T...>::type;
	template <size_t N = 0, class T> void multiple_impl(T& t) const {
		if constexpr (N < tuple_size_v<T>) {
			auto& vec = get<N>(t);
			using V = typename remove_reference_t<decltype(vec)>::value_type;
			vec.push_back(read<V>());
			multiple_impl<N + 1>(t);
		}
	}

public:
	template <class... T> auto multiple(int h) const {
		multiple_t<T...> result;
		while (h--) multiple_impl(result);
		return result;
	}
} in;
#define inputs(T, ...) \
	T __VA_ARGS__;     \
	in(__VA_ARGS__)
#define ini(...) inputs(int, __VA_ARGS__)
#define inl(...) inputs(long long, __VA_ARGS__)
#define ins(...) inputs(string, __VA_ARGS__)
#line 7 "/home/yuruhiya/programming/library/template/Output.cpp"
#include <charconv>
#line 10 "/home/yuruhiya/programming/library/template/Output.cpp"
using namespace std;

struct BoolStr {
	const char *t, *f;
	BoolStr(const char* _t, const char* _f) : t(_t), f(_f) {}
} Yes("Yes", "No"), yes("yes", "no"), YES("YES", "NO"), Int("1", "0");
struct DivStr {
	const char *d, *l;
	DivStr(const char* _d, const char* _l) : d(_d), l(_l) {}
} spc(" ", "\n"), no_spc("", "\n"), end_line("\n", "\n"), comma(",", "\n"),
    no_endl(" ", "");
class Output {
	BoolStr B{Yes};
	DivStr D{spc};

public:
	void put(int v) const {
		char buf[12]{};
		if (auto [ptr, e] = to_chars(begin(buf), end(buf), v); e == errc{}) {
			fwrite(buf, sizeof(char), ptr - buf, stdout);
		} else {
			assert(false);
		}
	}
	void put(long long v) const {
		char buf[21]{};
		if (auto [ptr, e] = to_chars(begin(buf), end(buf), v); e == errc{}) {
			fwrite(buf, sizeof(char), ptr - buf, stdout);
		} else {
			assert(false);
		}
	}
	void put(bool v) const {
		put(v ? B.t : B.f);
	}
	void put(char v) const {
		putchar_unlocked(v);
	}
	void put(const char* v) const {
		fwrite_unlocked(v, 1, strlen(v), stdout);
	}
	void put(double v) const {
		printf("%.20f", v);
	}
	void put(long double v) const {
		printf("%.20Lf", v);
	}
	template <class T> void put(const T& v) const {
		cout << v;
	}
	template <class T, class U> void put(const pair<T, U>& v) const {
		put(v.first);
		put(D.d);
		put(v.second);
	}
	template <class InputIterater>
	void put_range(const InputIterater& begin, const InputIterater& end) const {
		for (InputIterater i = begin; i != end; ++i) {
			if (i != begin) put(D.d);
			put(*i);
		}
	}
	template <class T> void put(const vector<T>& v) const {
		put_range(v.begin(), v.end());
	}
	template <class T, size_t N> void put(const array<T, N>& v) const {
		put_range(v.begin(), v.end());
	}
	template <class T> void put(const vector<vector<T>>& v) const {
		for (size_t i = 0; i < v.size(); ++i) {
			if (i) put(D.l);
			put(v[i]);
		}
	}

	Output() = default;
	Output(const BoolStr& _boolstr, const DivStr& _divstr) : B(_boolstr), D(_divstr) {}
	Output& operator()() {
		put(D.l);
		return *this;
	}
	template <class H> Output& operator()(H&& h) {
		put(h);
		put(D.l);
		return *this;
	}
	template <class H, class... T> Output& operator()(H&& h, T&&... t) {
		put(h);
		put(D.d);
		return operator()(forward<T>(t)...);
	}
	template <class InputIterator>
	Output& range(const InputIterator& begin, const InputIterator& end) {
		put_range(begin, end);
		put(D.l);
		return *this;
	}
	template <class T> Output& range(const T& a) {
		range(a.begin(), a.end());
		return *this;
	}
	template <class... T> void exit(T&&... t) {
		operator()(forward<T>(t)...);
		std::exit(EXIT_SUCCESS);
	}
	Output& flush() {
		fflush_unlocked(stdout);
		return *this;
	}
	Output& set(const BoolStr& b) {
		B = b;
		return *this;
	}
	Output& set(const DivStr& d) {
		D = d;
		return *this;
	}
	Output& set(const char* t, const char* f) {
		B = BoolStr(t, f);
		return *this;
	}
} out;
#line 3 "/home/yuruhiya/programming/library/template/Step.cpp"
using namespace std;

template <class T> struct Step {
	using value_type = T;

	class iterator {
		value_type a, b, c;

	public:
		constexpr iterator() : a(value_type()), b(value_type()), c(value_type()) {}
		constexpr iterator(value_type _b, value_type _c, value_type _s)
		    : a(_b), b(_c), c(_s) {}
		constexpr iterator& operator++() {
			--b;
			a += c;
			return *this;
		}
		constexpr iterator operator++(int) {
			iterator tmp = *this;
			--b;
			a += c;
			return tmp;
		}
		constexpr const value_type& operator*() const {
			return a;
		}
		constexpr const value_type* operator->() const {
			return &a;
		}
		constexpr bool operator==(const iterator& i) const {
			return b == i.b;
		}
		constexpr bool operator!=(const iterator& i) const {
			return !(b == i.b);
		}
		constexpr value_type start() const {
			return a;
		}
		constexpr value_type size() const {
			return b;
		}
		constexpr value_type step() const {
			return c;
		}
	};
	constexpr Step(value_type b, value_type c, value_type s) : be(b, c, s) {}
	constexpr iterator begin() const {
		return be;
	}
	constexpr iterator end() const {
		return en;
	}
	constexpr value_type start() const {
		return be.start();
	}
	constexpr value_type size() const {
		return be.size();
	}
	constexpr value_type step() const {
		return be.step();
	}
	constexpr value_type sum() const {
		return start() * size() + step() * (size() * (size() - 1) / 2);
	}
	operator vector<value_type>() const {
		return to_a();
	}
	auto to_a() const {
		vector<value_type> result;
		result.reserve(size());
		for (auto i : *this) {
			result.push_back(i);
		}
		return result;
	}

private:
	iterator be, en;
};
template <class T> constexpr auto step(T a) {
	return Step<T>(0, a, 1);
}
template <class T> constexpr auto step(T a, T b) {
	return Step<T>(a, b - a, 1);
}
template <class T> constexpr auto step(T a, T b, T c) {
	return Step<T>(a, a < b ? (b - a - 1) / c + 1 : 0, c);
}
#line 8 "/home/yuruhiya/programming/library/template/Ruby.cpp"
using namespace std;

template <class F> struct Callable {
	F func;
	Callable(const F& f) : func(f) {}
};
template <class T, class F> auto operator|(const T& v, const Callable<F>& c) {
	return c.func(v);
}

struct Sort_impl {
	template <class F> auto operator()(F&& f) {
		return Callable([&](auto v) {
			sort(begin(v), end(v), f);
			return v;
		});
	}
	template <class T> friend auto operator|(T v, [[maybe_unused]] const Sort_impl& c) {
		sort(begin(v), end(v));
		return v;
	}
} Sort;
struct SortBy_impl {
	template <class F> auto operator()(F&& f) {
		return Callable([&](auto v) {
			sort(begin(v), end(v),
			     [&](const auto& i, const auto& j) { return f(i) < f(j); });
			return v;
		});
	}
} SortBy;
struct RSort_impl {
	template <class F> auto operator()(F&& f) {
		return Callable([&](auto v) {
			sort(rbegin(v), rend(v), f);
			return v;
		});
	}
	template <class T> friend auto operator|(T v, [[maybe_unused]] const RSort_impl& c) {
		sort(rbegin(v), rend(v));
		return v;
	}
} RSort;
struct RSortBy_impl {
	template <class F> auto operator()(F&& f) {
		return Callable([&](auto v) {
			sort(begin(v), end(v),
			     [&](const auto& i, const auto& j) { return f(i) > f(j); });
			return v;
		});
	}
} RSortBy;
struct Reverse_impl {
	template <class T> friend auto operator|(T v, const Reverse_impl& c) {
		reverse(begin(v), end(v));
		return v;
	}
} Reverse;
struct Unique_impl {
	template <class T> friend auto operator|(T v, const Unique_impl& c) {
		v.erase(unique(begin(v), end(v), end(v)));
		return v;
	}
} Unique;
struct Uniq_impl {
	template <class T> friend auto operator|(T v, const Uniq_impl& c) {
		sort(begin(v), end(v));
		v.erase(unique(begin(v), end(v)), end(v));
		return v;
	}
} Uniq;
struct Rotate_impl {
	auto operator()(int&& left) {
		return Callable([&](auto v) {
			int s = static_cast<int>(size(v));
			assert(-s <= left && left <= s);
			if (0 <= left) {
				rotate(begin(v), begin(v) + left, end(v));
			} else {
				rotate(begin(v), end(v) + left, end(v));
			}
			return v;
		});
	}
} Rotate;
struct Max_impl {
	template <class F> auto operator()(F&& f) {
		return Callable([&](auto v) { return *max_element(begin(v), end(v), f); });
	}
	template <class T> friend auto operator|(T v, const Max_impl& c) {
		return *max_element(begin(v), end(v));
	}
} Max;
struct Min_impl {
	template <class F> auto operator()(F&& f) {
		return Callable([&](auto v) { return *min_element(begin(v), end(v), f); });
	}
	template <class T> friend auto operator|(T v, const Min_impl& c) {
		return *min_element(begin(v), end(v));
	}
} Min;
struct MaxPos_impl {
	template <class T> friend auto operator|(T v, const MaxPos_impl& c) {
		return max_element(begin(v), end(v)) - begin(v);
	}
} MaxPos;
struct MinPos_impl {
	template <class T> friend auto operator|(T v, const MinPos_impl& c) {
		return min_element(begin(v), end(v)) - begin(v);
	}
} MinPos;
struct MaxBy_impl {
	template <class F> auto operator()(F&& f) {
		return Callable([&](auto v) {
			auto max_it = begin(v);
			auto max_val = f(*max_it);
			for (auto it = next(begin(v)); it != end(v); ++it) {
				if (auto val = f(*it); max_val < val) {
					max_it = it;
					max_val = val;
				}
			}
			return *max_it;
		});
	}
} MaxBy;
struct MinBy_impl {
	template <class F> auto operator()(F&& f) {
		return Callable([&](auto v) {
			auto min_it = begin(v);
			auto min_val = f(*min_it);
			for (auto it = next(begin(v)); it != end(v); ++it) {
				if (auto val = f(*it); min_val > val) {
					min_it = it;
					min_val = val;
				}
			}
			return *min_it;
		});
	}
} MinBy;
struct MaxOf_impl {
	template <class F> auto operator()(F&& f) {
		return Callable([&](auto v) {
			auto max_val = f(*begin(v));
			for (auto it = next(begin(v)); it != end(v); ++it) {
				if (auto val = f(*it); max_val < val) {
					max_val = val;
				}
			}
			return max_val;
		});
	}
} MaxOf;
struct MinOf_impl {
	template <class F> auto operator()(F&& f) {
		return Callable([&](auto v) {
			auto min_val = f(*begin(v));
			for (auto it = next(begin(v)); it != end(v); ++it) {
				if (auto val = f(*it); min_val > val) {
					min_val = val;
				}
			}
			return min_val;
		});
	}
} MinOf;
struct Count_impl {
	template <class V> auto operator()(const V& val) {
		return Callable([&](auto v) { return count(begin(v), end(v), val); });
	}
} Count;
struct CountIf_impl {
	template <class F> auto operator()(const F& f) {
		return Callable([&](auto v) { return count_if(begin(v), end(v), f); });
	}
} CountIf;
struct Index_impl {
	template <class V> auto operator()(const V& val) {
		return Callable([&](auto v) -> optional<int> {
			auto result = find(begin(v), end(v), val);
			return result != end(v) ? optional(result - begin(v)) : nullopt;
		});
	}
} Index;
struct IndexIf_impl {
	template <class F> auto operator()(const F& f) {
		return Callable([&](auto v) -> optional<int> {
			auto result = find_if(begin(v), end(v), f);
			return result != end(v) ? optional(result - begin(v)) : nullopt;
		});
	}
} IndexIf;
struct FindIf_impl {
	template <class F> auto operator()(const F& f) {
		return Callable([&](auto v) -> optional<typename decltype(v)::value_type> {
			auto result = find_if(begin(v), end(v), f);
			return result != end(v) ? optional(*result) : nullopt;
		});
	}
} FindIf;
struct Sum_impl {
	template <class F> auto operator()(F&& f) {
		return Callable([&](auto v) {
			return accumulate(next(begin(v)), end(v), f(*begin(v)),
			                  [&](const auto& a, const auto& b) { return a + f(b); });
		});
	}
	template <class T> friend auto operator|(T v, const Sum_impl& c) {
		return accumulate(begin(v), end(v), typename T::value_type{});
	}
} Sum;
struct Includes {
	template <class V> auto operator()(const V& val) {
		return Callable([&](auto v) { return find(begin(v), end(v), val) != end(v); });
	}
} Includes;
struct IncludesIf_impl {
	template <class F> auto operator()(const F& f) {
		return Callable([&](auto v) { return find_if(begin(v), end(v), f) != end(v); });
	}
} IncludesIf;
struct RemoveIf_impl {
	template <class F> auto operator()(const F& f) {
		return Callable([&](auto v) {
			v.erase(remove_if(begin(v), end(v), f), end(v));
			return v;
		});
	}
} RemoveIf;
struct Each_impl {
	template <class F> auto operator()(F&& f) {
		return Callable([&](auto v) {
			for (const auto& i : v) {
				f(i);
			}
		});
	}
} Each;
struct Select_impl {
	template <class F> auto operator()(F&& f) {
		return Callable([&](auto v) {
			using value_type = typename decltype(v)::value_type;
			vector<value_type> result;
			for (const auto& i : v) {
				if (f(i)) result.push_back(i);
			}
			return result;
		});
	}
} Select;
struct Map_impl {
	template <class F> auto operator()(F&& f) {
		return Callable([&](auto v) {
			using result_type = invoke_result_t<F, typename decltype(v)::value_type>;
			vector<result_type> result;
			result.reserve(size(v));
			for (const auto& i : v) {
				result.push_back(f(i));
			}
			return result;
		});
	}
} Map;
struct Indexed_impl {
	template <class T> friend auto operator|(const T& v, Indexed_impl& c) {
		using value_type = typename T::value_type;
		vector<pair<value_type, int>> result;
		result.reserve(size(v));
		int index = 0;
		for (const auto& i : v) {
			result.emplace_back(i, index++);
		}
		return result;
	}
} Indexed;
struct AllOf_impl {
	template <class F> auto operator()(F&& f) {
		return Callable([&](auto v) {
			for (const auto& i : v) {
				if (!f(i)) return false;
			}
			return true;
		});
	}
} AllOf;
struct AnyOf_impl {
	template <class F> auto operator()(F&& f) {
		return Callable([&](auto v) {
			for (const auto& i : v) {
				if (f(i)) return true;
			}
			return false;
		});
	}
} AnyOf;
struct NoneOf_impl {
	template <class F> auto operator()(F&& f) {
		return Callable([&](auto v) {
			for (const auto& i : v) {
				if (f(i)) return false;
			}
			return true;
		});
	}
} NoneOf;

struct Tally_impl {
	template <class F> auto operator()(size_t max_val) {
		return Callable([&](auto v) {
			vector<size_t> result(max_val);
			for (const auto& i : v) {
				result[static_cast<size_t>(i)]++;
			}
			return result;
		});
	}
	template <class T, class value_type = typename T::value_type>
	friend auto operator|(const T& v, Tally_impl& c) {
		map<value_type, size_t> result;
		for (const auto& i : v) {
			result[i]++;
		}
		return result;
	}
} Tally;

template <class T> auto operator*(const vector<T>& a, size_t n) {
	T result;
	for (size_t i = 0; i < n; ++i) {
		result.insert(result.end(), a.begin(), a.end());
	}
	return result;
}
auto operator*(string a, size_t n) {
	string result;
	for (size_t i = 0; i < n; ++i) {
		result += a;
	}
	return result;
}
template <class T, class U> auto& operator<<(vector<T>& a, const U& b) {
	a.insert(a.end(), all(b));
	return a;
}
template <class T> auto& operator<<(string& a, const T& b) {
	a.insert(a.end(), all(b));
	return a;
}
template <class T, class U> auto operator+(vector<T> a, const U& b) {
	a << b;
	return a;
}
template <class T> auto operator+(string a, const T& b) {
	a << b;
	return a;
}
#line 6 "/home/yuruhiya/programming/library/template/functions.cpp"
using namespace std;

template <class T> int sz(const T& v) {
	return v.size();
}
template <class T, class U> int lower_index(const T& a, const U& v) {
	return lower_bound(all(a), v) - a.begin();
}
template <class T, class U> int upper_index(const T& a, const U& v) {
	return upper_bound(all(a), v) - a.begin();
}
template <class T> auto Slice(const T& v, size_t i, size_t len) {
	return i < v.size() ? T(v.begin() + i, v.begin() + min(i + len, v.size())) : T();
}
template <class T> T div_ceil(T n, T m) {
	return (n + m - 1) / m;
}
template <class T> T div_ceil2(T n, T m) {
	return div_ceil(n, m) * m;
}
template <class T> T triangle(T n) {
	return (n & 1) ? (n + 1) / 2 * n : n / 2 * (n + 1);
}
template <class T> T nC2(T n) {
	return (n & 1) ? (n - 1) / 2 * n : n / 2 * (n - 1);
}
template <class T> T middle(const T& l, const T& r) {
	return l + (r - l) / 2;
}
template <class T> bool chmax(T& a, const T& b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
template <class T> bool chmin(T& a, const T& b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template <class T> bool in_range(const T& v, const T& min, const T& max) {
	return min <= v && v < max;
}
template <class T> bool in_square(T n) {
	T s = sqrt(n);
	return s * s == n || (s + 1) * (s + 1) == n;
}
template <class T = long long> T BIT(int b) {
	return T(1) << b;
}
template <class T, class U = typename T::value_type> U Gcdv(const T& v) {
	return accumulate(next(v.begin()), v.end(), U(*v.begin()), gcd<U, U>);
}
template <class T, class U = typename T::value_type> U Lcmv(const T& v) {
	return accumulate(next(v.begin()), v.end(), U(*v.begin()), lcm<U, U>);
}
template <class T, class U> T Pow(T a, U n) {
	T result = 1;
	while (n > 0) {
		if (n & 1) {
			result *= a;
			n--;
		} else {
			a *= a;
			n >>= 1;
		}
	}
	return result;
}
template <class T, class U> T Powmod(T a, U n, T mod) {
	T result = 1;
	while (n > 0) {
		if (n & 1) {
			result = result * a % mod;
			n--;
		} else {
			a = a * a % mod;
			n >>= 1;
		}
	}
	return result;
}
namespace internal {
	template <class T, size_t N> auto make_vector(vector<int>& sizes, const T& init) {
		if constexpr (N == 1) {
			return vector(sizes[0], init);
		} else {
			int size = sizes[N - 1];
			sizes.pop_back();
			return vector(size, make_vector<T, N - 1>(sizes, init));
		}
	}
}  // namespace internal
template <class T, size_t N>
auto make_vector(const int (&sizes)[N], const T& init = T()) {
	vector s(rbegin(sizes), rend(sizes));
	return internal::make_vector<T, N>(s, init);
}
#line 9 "/home/yuruhiya/programming/library/template/template.cpp"
#if __has_include(<library/dump.hpp>)
#include <library/dump.hpp>
#define LOCAL
#else
#define dump(...) ((void)0)
#endif

template <class T> constexpr T oj_local(const T& oj, const T& local) {
#ifndef LOCAL
	return oj;
#else
	return local;
#endif
}
#line 2 "a.cpp"

void solve() {
	int n = 9;
	VI a = in[n], b = in[n];

	ll win_a = 0, win_b = 0, cnt = 0;
	sort(all(b));
	do {
		ll sum_a = 0, sum_b = 0;
		rep(i, n) {
			(a[i] > b[i] ? sum_a : sum_b) += a[i] + b[i];
		}
		win_a += sum_a > sum_b;
		win_b += sum_a < sum_b;
		cnt++;
	} while (next_permutation(all(b)));
	printf("%.5f %.5f\n", 1.0 * win_a / cnt, 1.0 * win_b / cnt);
}

int main() {
	for (int t = in; t--;) {
		solve();
	}
}
accuracy: 1
time_ms: 110
memory_kb: 3500
final_rank: 4