#include <stdio.h>
#include <string.h>
#define N 1010
int A[N], B[N], a[N];
int move[N], flag[N];
int main(){
memset(A, 0, sizeof(A)); memset(B, 0, sizeof(B)); memset(move, 0, sizeof(move));
int n, L, t, i, k;
scanf("%d%d%d", &n, &L, &t);
for(i=1; i<=n; ++i){
scanf("%d", &a[i]); B[a[i]] = 1; flag[i] = 1;
}
B[0] = 2; B[L] = 2;
for(k=1; k<=t; ++k){
for(int j=0; j<=L; ++j) { A[j] = B[j]; B[j] = 0;}
B[0] = 2; B[L] = 2;
for(i=1; i<=n; ++i){
if(A[a[i]+move[i]]==3 || A[a[i]+move[i]]==2){
flag[i] = -flag[i];
}
if(flag[i] > 0) move[i]++;
else move[i]–;
}
for(i=1; i<=n; ++i){
B[a[i] + move[i]]++;
}
}
for(i=1; i<=n; ++i){
printf("%d ", a[i]+move[i]);
}
return 0;
}
————————————————
版权声明:本文为CSDN博主「WOSHILURENJI」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/WOSHILURENJI/article/details/104651403