题目链接:http://118.190.20.162/view.page?gpid=T72
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
using namespace std;
int n,L,t;
bool run_direction[105];
int ball[105];
void run(){
for(int i=0;i<n;i++){
if(run_direction[i]){
ball[i]+=1;
if(ball[i]==L){
run_direction[i]=!run_direction[i];
}
} else{
ball[i]-=1;
if(ball[i]==0){
run_direction[i]=!run_direction[i];
}
}
}
}
void change_direct(){
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
if(ball[i]==ball[j]){
swap(run_direction[i],run_direction[j]);
}
}
}
}
int main() {
cin>>n>>L>>t;
memset(run_direction,true,sizeof(run_direction));
for(int i=0;i<n;i++){
cin>>ball[i];
}
for(int i=0;i<t;i++){
run();
change_direct();
}
for(int j=0;j<n;j++){
cout<<ball[j]<<" ";
}
cout<<endl;
return 0;
}