結果

問題 No.133 カードゲーム
ユーザー Ksy72413382Ksy72413382
提出日時 2019-03-25 12:17:17
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,246 bytes
コンパイル時間 759 ms
コンパイル使用メモリ 84,384 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 18:29:19
合計ジャッジ時間 1,574 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))


const int MAX_N = 10010, MAX_W = 10010, MAX_V = 10010;

int N;
int A[10], B[10];

int win = 0, lose = 0;

//nは繰り返した回数
void dfs(int n,int win1, vector<int> v)
{
	//全部終わらせたとき勝ってたら
	if (n == N)
	{
		if (win1 > n - win1)
		{
			win++;
		}
		else
		{
			lose++;
		}
		return;
	}

	for (int i = 0; i < N; i++)
	{
		bool hantei = false;
		//if 記憶してある番号だったら飛ばす
		for (int j = 0; j < v.size(); j++)
		{
			if (v[j] == i) hantei = true;
		}
		if (hantei) continue;

		int tmp = win1;

		if (A[n] > B[i]) tmp++;

		
		vector<int> vtmp1 = v;
		vtmp1.push_back(i);

		dfs(n + 1, tmp, vtmp1);
	}
}

int main()
{
	cin >> N;

	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
	}
	for (int i = 0; i < N; i++)
	{
		cin >> B[i];
	}

	vector<int> vtmp;

	dfs(0, 0, vtmp);

	cout << float(win) / (win + lose) << endl;
}
0