Little Elephant and Broken Sorting 怎么感觉这个状态好难想到啊.. dp[ i ][ j ]表示第 i 个数字比第 j 个数字大的概率.转移好像比较显然. #include<bits/stdc++.h> #define LL long long #define LD long double #define ull unsigned long long #define fi first #define se second #define mk make_pair…
CF258D Little Elephant and Broken Sorting 题意 题意翻译 有一个\(1\sim n\)的排列,会进行\(m\)次操作,操作为交换\(a,b\).每次操作都有\(50\%\)的概率进行. 求进行\(m\)次操作以后的期望逆序对个数. \(n,m\le 1000\) 输入输出格式 输入格式: The first line contains two integers \(n\) and \(m\) \((1\leq n,m\leq 1000,n>1)\) -…
Discription The Little Elephant loves permutations of integers from 1 to n very much. But most of all he loves sorting them. To sort a permutation, the Little Elephant repeatedly swaps some elements. As a result, he must receive a permutation 1, 2, 3…
D. Little Elephant and Broken Sorting 链接 题意: 长度为n的序列,m次操作,每次交换两个位置,每次操作的概率为$\frac{1}{2}$,求m此操作后逆序对的期望. 分析: f[i][j]表示i>i的概率,每次交换的概率为$\frac{1}{2}$,设交换的位置是x,y,那么$f[i][x]=\frac{f[i][x]+f[i][y]}{2}$,分别是不交换和交换后的概率的和除以2. 代码: #include<cstdio> #include<…
D. Bad Luck Island Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/540/problem/D Description The Bad Luck Island is inhabited by three kinds of species: r rocks, s scissors and p papers. At some moments of time two random i…