結果
| 問題 | No.133 カードゲーム | 
| コンテスト | |
| ユーザー |  ccoffee_addictt | 
| 提出日時 | 2019-06-14 09:25:43 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 5,000 ms | 
| コード長 | 1,349 bytes | 
| コンパイル時間 | 2,519 ms | 
| コンパイル使用メモリ | 165,604 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-11-07 04:16:22 | 
| 合計ジャッジ時間 | 3,424 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 19 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:37:9: warning: ignoring return value of ‘int fscanf(FILE*, const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   37 |   fscanf(stdin, "%d ", &n);
      |   ~~~~~~^~~~~~~~~~~~~~~~~~
main.cpp:38:18: warning: ignoring return value of ‘int fscanf(FILE*, const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   38 |   REP(i,n) fscanf(stdin, "%d ", a+i);
      |            ~~~~~~^~~~~~~~~~~~~~~~~~~
main.cpp:39:18: warning: ignoring return value of ‘int fscanf(FILE*, const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   39 |   REP(i,n) fscanf(stdin, "%d ", b+i);
      |            ~~~~~~^~~~~~~~~~~~~~~~~~~
            
            ソースコード
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,s,e) for(int i=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp make_pair
#define mt make_tuple
#define t0(t) get<0>((t))
#define t1(t) get<1>((t))
#define t2(t) get<2>((t))
typedef long long ll;
const int N = 4;
int n;
int a[N], b[N];
void dfs(int *ab, vector<int> x, vector<vector<int>> &xx, vector<int> p, int k) {
  if (k == n) {
    xx.pb(x);
    return;
  }
  REP(i,n) {
    if (p[i]) continue;
    p[i] = 1;
    x.push_back(ab[i]);
    dfs(ab, x, xx, p, k+1);
    x.pop_back();
    p[i] = 0;
  }
}
int main() {
  fscanf(stdin, "%d ", &n);
  REP(i,n) fscanf(stdin, "%d ", a+i);
  REP(i,n) fscanf(stdin, "%d ", b+i);
//FILE *fp = fopen("133/test/sample-1.in", "r");
//fscanf(fp, "%d ", &n);
//REP(i,n) fscanf(fp, "%d ", a+i);
//REP(i,n) fscanf(fp, "%d ", b+i);
//fclose(fp);
  vector<vector<int>> aa;
  vector<vector<int>> bb;
  vector<int> x, y, p(n);
  dfs(a, x, aa, p, 0);
  fill(all(p), 0);
  dfs(b, y, bb, p, 0);
  int m = aa.size();
  double res = 0;
  REP(i,m) REP(j,m) {
    int w = 0;
    REP(k,n) if (aa[i][k] > bb[j][k]) w++;
    if (w > n/2) res++;
  }
  fprintf(stdout, "%.10f\n", res/(m*m));
  return 0;
}
            
            
            
        