05/22 13:46

# problem

$$n$$个兔子站成一排，每只兔子有自己的位置，有$$m$$次操作，第$$i$$次操作将$$a_i$$以相等的概率挪到关于$$a_{i-1}$$对称的位置或挪到与$$a_{i+1}$$对称的位置。

# solution

$$d_i=a_i-a_{i-1}$$，对于第$$i$$个兔子进行一次操作，就相当于交换了$$d_i$$$$d_{i+1}$$

# code

/*
* @Author: wxyww
* @Date:   2020-05-21 15:53:33
*/
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<queue>
#include<vector>
#include<ctime>
#include<cmath>
using namespace std;
typedef long long ll;
const int N = 200010;
#define int ll
ll x = 0,f = 1;char c = getchar();
while(c < '0' || c > '9') {
if(c == '-') f = -1; c = getchar();
}
while(c >= '0' && c <= '9') {
x = x * 10 + c - '0'; c = getchar();
}
return x * f;
}
int n;
ll tmp[N];
void mul(int *a,int *b) {
for(int i = 1;i <= n;++i) {
tmp[i] = a[b[i]];
}
for(int i = 1;i <= n;++i) a[i] = tmp[i];
}
int a[N],p[N];
void qm(ll y) {
int ret[N];
for(int i = 1;i <= n;++i) ret[i] = i;

for(;y;y >>= 1,mul(p,p))
if(y & 1) mul(ret,p);
for(int i = 1;i <= n;++i) p[i] = ret[i];
}
signed main() {
for(int i = 1;i <= n;++i) {
a[i] = read();p[i] = i;
}

int m = read();ll K = read();

for(int i = n;i >= 1;--i) a[i] -= a[i - 1];

for(int i = 1;i <= m;++i) {
int x = read();
swap(p[x],p[x + 1]);
}

qm(K);

for(int i = 1;i <= n;++i) tmp[i] = a[p[i]];
// for(int i = 1;i <= n;++i) printf("%d ",tmp[i]);
// puts("");
for(int i = 1;i <= n;++i) {
printf("%lld.0\n",tmp[i] += tmp[i - 1]);
}
return 0;
}


0
0 收藏

0 评论
0 收藏
0