QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#493649#6970. 地震后的幻想乡Gemini7X100 ✓38ms4212kbC++141.3kb2024-07-27 11:21:522024-07-27 11:21:56

Judging History

你现在查看的是最新测评结果

  • [2024-07-27 11:21:56]
  • 评测
  • 测评结果:100
  • 用时:38ms
  • 内存:4212kb
  • [2024-07-27 11:21:52]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &x)
{
	T sgn = 1;
	char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') sgn = -1;
	for (x = 0; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
	x *= sgn;
}
int n, m, g[10][10], deg[1 << 10];
double C[46][46];
double f[50][1 << 10];
int main()
{
	read(n); read(m);
	for (int i = 1, a, b; i <= m; i++)
	{
		read(a); read(b); a--; b--;
		g[a][b] = g[b][a] = 1;
	}
	for (int s = 0; s < (1 << n); s++)
		for (int i = 0; i < n; i++) if ((s >> i) & 1)
			for (int j = i + 1; j < n; j++) if ((s >> j) & 1)
				deg[s] += g[i][j];
	C[0][0] = 1;
	for (int i = 1; i <= m; i++)
	{
		C[i][0] = C[i][i] = 1;
		for (int j = 1; j < i; j++)
			C[i][j] = C[i - 1][j] + C[i - 1][j - 1];
	}
	for (int i = 0; i <= m; i++)
	{
		for (int s = 1; s < (1 << n); s++)
		{
			int id = __builtin_ctz(s);
			for (int t = s & (s - 1); t; t = s & (t - 1)) if ((t >> id) & 1)
			{
				for (int j = 0; j <= i; j++)
				{
					f[i][s] += C[deg[s ^ t]][i - j] * (C[deg[t]][j] - f[j][t]);
				}
			}
		}
	}
	double ans = 0;
	for (int i = 0; i <= m; i++)
	{
		ans += f[i][(1 << n) - 1] / C[deg[(1 << n) - 1]][i];
	}
	printf("%.6lf\n", ans / (m + 1));
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Pretests


Final Tests

Test #1:

score: 5
Accepted
time: 0ms
memory: 3896kb

input:

2 1
2 1

output:

0.500000

result:

ok single line: '0.500000'

Test #2:

score: 5
Accepted
time: 0ms
memory: 3744kb

input:

3 2
2 1
3 2

output:

0.666667

result:

ok single line: '0.666667'

Test #3:

score: 5
Accepted
time: 0ms
memory: 3884kb

input:

3 3
2 1
3 1
3 2

output:

0.500000

result:

ok single line: '0.500000'

Test #4:

score: 5
Accepted
time: 3ms
memory: 3980kb

input:

10 10
2 1
4 1
4 3
6 2
7 3
7 4
9 3
9 5
9 8
10 5

output:

0.881818

result:

ok single line: '0.881818'

Test #5:

score: 5
Accepted
time: 3ms
memory: 3840kb

input:

10 10
2 1
5 2
5 4
6 1
7 3
7 5
8 3
8 5
9 7
10 5

output:

0.872727

result:

ok single line: '0.872727'

Test #6:

score: 5
Accepted
time: 3ms
memory: 4048kb

input:

10 10
6 5
7 2
8 1
8 4
8 6
9 1
9 3
9 5
10 6
10 7

output:

0.863636

result:

ok single line: '0.863636'

Test #7:

score: 5
Accepted
time: 38ms
memory: 4212kb

input:

10 45
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4
6 1
6 2
6 3
6 4
6 5
7 1
7 2
7 3
7 4
7 5
7 6
8 1
8 2
8 3
8 4
8 5
8 6
8 7
9 1
9 2
9 3
9 4
9 5
9 6
9 7
9 8
10 1
10 2
10 3
10 4
10 5
10 6
10 7
10 8
10 9

output:

0.274864

result:

ok single line: '0.274864'

Test #8:

score: 5
Accepted
time: 8ms
memory: 4116kb

input:

9 36
2 1
3 1
3 2
4 1
4 2
4 3
5 1
5 2
5 3
5 4
6 1
6 2
6 3
6 4
6 5
7 1
7 2
7 3
7 4
7 5
7 6
8 1
8 2
8 3
8 4
8 5
8 6
8 7
9 1
9 2
9 3
9 4
9 5
9 6
9 7
9 8

output:

0.294173

result:

ok single line: '0.294173'

Test #9:

score: 5
Accepted
time: 0ms
memory: 3920kb

input:

5 7
2 1
3 1
4 2
4 3
5 1
5 2
5 4

output:

0.545238

result:

ok single line: '0.545238'

Test #10:

score: 5
Accepted
time: 0ms
memory: 3920kb

input:

5 7
3 2
4 1
4 2
4 3
5 1
5 3
5 4

output:

0.561905

result:

ok single line: '0.561905'

Test #11:

score: 5
Accepted
time: 0ms
memory: 3864kb

input:

5 8
3 1
4 1
4 2
4 3
5 1
5 2
5 3
5 4

output:

0.511905

result:

ok single line: '0.511905'

Test #12:

score: 5
Accepted
time: 0ms
memory: 3852kb

input:

5 8
3 1
3 2
4 1
4 2
5 1
5 2
5 3
5 4

output:

0.492063

result:

ok single line: '0.492063'

Test #13:

score: 5
Accepted
time: 1ms
memory: 3796kb

input:

8 15
3 1
4 1
4 2
4 3
5 1
5 2
6 2
6 3
7 1
7 4
8 1
8 3
8 4
8 6
8 7

output:

0.558508

result:

ok single line: '0.558508'

Test #14:

score: 5
Accepted
time: 1ms
memory: 3876kb

input:

8 15
2 1
3 1
5 1
5 2
5 4
6 1
6 2
7 1
7 2
7 3
7 5
8 2
8 3
8 4
8 5

output:

0.570480

result:

ok single line: '0.570480'

Test #15:

score: 5
Accepted
time: 1ms
memory: 3968kb

input:

8 18
3 1
4 3
5 4
6 2
6 4
6 5
7 1
7 2
7 3
7 4
7 5
8 1
8 2
8 3
8 4
8 5
8 6
8 7

output:

0.482269

result:

ok single line: '0.482269'

Test #16:

score: 5
Accepted
time: 1ms
memory: 3964kb

input:

8 18
2 1
3 2
4 2
4 3
5 2
5 3
5 4
6 2
6 3
7 1
7 2
7 3
7 4
7 5
7 6
8 1
8 3
8 5

output:

0.489007

result:

ok single line: '0.489007'

Test #17:

score: 5
Accepted
time: 11ms
memory: 4000kb

input:

10 22
2 1
4 1
5 1
5 2
6 1
6 2
6 5
7 1
7 2
7 4
7 6
8 3
8 4
8 6
9 3
9 4
9 7
10 1
10 2
10 4
10 6
10 8

output:

0.548805

result:

ok single line: '0.548805'

Test #18:

score: 5
Accepted
time: 7ms
memory: 3928kb

input:

10 22
3 1
3 2
4 3
5 3
6 2
6 3
6 4
7 1
7 2
7 4
7 5
7 6
8 4
9 1
9 3
9 4
9 6
10 1
10 2
10 3
10 7
10 8

output:

0.559280

result:

ok single line: '0.559280'

Test #19:

score: 5
Accepted
time: 13ms
memory: 4084kb

input:

10 25
3 1
4 1
5 2
5 3
5 4
6 1
6 4
6 5
7 2
7 4
8 1
8 3
8 5
8 7
9 1
9 2
9 4
9 6
9 7
10 2
10 3
10 6
10 7
10 8
10 9

output:

0.447754

result:

ok single line: '0.447754'

Test #20:

score: 5
Accepted
time: 13ms
memory: 4172kb

input:

10 25
3 2
4 3
5 1
5 2
5 4
6 3
6 4
7 1
7 5
8 1
8 3
8 4
8 6
8 7
9 1
9 2
9 3
9 4
9 6
9 7
10 2
10 4
10 5
10 6
10 8

output:

0.452142

result:

ok single line: '0.452142'