Submission #20548467


Source Code Expand

#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define INF 1e10
#define ft first
#define sec second
#define pr pair<int,int>
#define ISCC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
int n ,m ,cnt1[10] ,cnt2[10];
string s ,t;
int main() 
{
	cin >> n;
	getchar(); 
	ll tak = 0 ,aok = 0;
	getline(cin ,s); getline(cin ,t);
	for(int i=0 ;i<4 ;i++)
	{
		cnt1[s[i]-'0']++;
		cnt2[t[i]-'0']++;
	}
	for(int i=1 ;i<10 ;i++)
	{
		tak += pow(10,cnt1[i])*i;
		aok += pow(10,cnt2[i])*i;
	}
	double ans=0;
	for(int i=1 ;i<=9 ;i++)
	{
		int tp1 = tak;
		tp1 -= pow(10,cnt1[i])*i;
		tp1 += pow(10,cnt1[i]+1)*i;
		for(int j=1 ;j<=9 ;j++) if(n-cnt1[i]-cnt2[i] > 0 && n-cnt1[j]-cnt2[j] > 0)
		{
			int tp2 = aok;
			tp2 -= pow(10,cnt2[j])*j;
			tp2 += pow(10,cnt2[j]+1)*j;
			if(tp1 > tp2) 
			{
				double a = 9.0*n - 8;
				ans += ((n - cnt1[i] - cnt2[i]) / a) * 
				((n - cnt1[j] - cnt2[j] - (i==j)) / (a - 1));
			}			
		}
	}
	printf("%.9f" ,ans);
}

Submission Info

Submission Time
Task D - Poker
User ck1080012
Language C++ (GCC 9.2.1)
Score 400
Code Size 1027 Byte
Status AC
Exec Time 7 ms
Memory 4108 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 4
AC × 36
Set Name Test Cases
Sample 01_sample.txt, 02_sample.txt, 03_sample.txt, 04_sample.txt
All 01_sample.txt, 02_sample.txt, 03_sample.txt, 04_sample.txt, 05_hand.txt, 06_hand.txt, 07_random1.txt, 08_random1.txt, 09_random1.txt, 10_random1.txt, 11_random1.txt, 12_random1.txt, 13_random1.txt, 14_random2.txt, 15_random2.txt, 16_random2.txt, 17_random2.txt, 18_random2.txt, 19_random2.txt, 20_random2.txt, 21_random2.txt, 22_random2.txt, 23_random2.txt, 24_random3.txt, 25_random3.txt, 26_random3.txt, 27_random3.txt, 28_random3.txt, 29_random3.txt, 30_random3.txt, 31_random3.txt, 32_random3.txt, 33_random4.txt, 34_random4.txt, 35_random4.txt, 36_random4.txt
Case Name Status Exec Time Memory
01_sample.txt AC 6 ms 4020 KiB
02_sample.txt AC 2 ms 4068 KiB
03_sample.txt AC 3 ms 3972 KiB
04_sample.txt AC 2 ms 4100 KiB
05_hand.txt AC 2 ms 3972 KiB
06_hand.txt AC 2 ms 3984 KiB
07_random1.txt AC 3 ms 3776 KiB
08_random1.txt AC 2 ms 3852 KiB
09_random1.txt AC 2 ms 3860 KiB
10_random1.txt AC 2 ms 3852 KiB
11_random1.txt AC 2 ms 3728 KiB
12_random1.txt AC 3 ms 3672 KiB
13_random1.txt AC 3 ms 3776 KiB
14_random2.txt AC 3 ms 4040 KiB
15_random2.txt AC 3 ms 3720 KiB
16_random2.txt AC 5 ms 4084 KiB
17_random2.txt AC 2 ms 4008 KiB
18_random2.txt AC 2 ms 3776 KiB
19_random2.txt AC 2 ms 3992 KiB
20_random2.txt AC 2 ms 3724 KiB
21_random2.txt AC 2 ms 4024 KiB
22_random2.txt AC 7 ms 4076 KiB
23_random2.txt AC 2 ms 4084 KiB
24_random3.txt AC 2 ms 4092 KiB
25_random3.txt AC 2 ms 3684 KiB
26_random3.txt AC 2 ms 3772 KiB
27_random3.txt AC 2 ms 3988 KiB
28_random3.txt AC 2 ms 3976 KiB
29_random3.txt AC 3 ms 3980 KiB
30_random3.txt AC 2 ms 4092 KiB
31_random3.txt AC 2 ms 4108 KiB
32_random3.txt AC 2 ms 3968 KiB
33_random4.txt AC 2 ms 4088 KiB
34_random4.txt AC 3 ms 4104 KiB
35_random4.txt AC 2 ms 3968 KiB
36_random4.txt AC 3 ms 3980 KiB