# Fun With Rotation(WA)

, ,

#include<stdio.h>

int main(){

``````  long n,m,i=0,k=0,j=0;

long long A;

char a;

scanf("%ld%ld",&n,&m);

for(i=0;i<n;i++){

scanf("%ld",A+i);

}

i=0;j=n-1;

while(m-- > 0){

fflush(stdin);
scanf("%c%ld",&a,&k);

if(a== 'C'){
i=(i+k)%n;
j=(j+k)%n;
// printf("i=%ld j=%ld\n",i,j);
}
else if (a=='A'){
i=(i+n-k)%n;
j=(j+n-k)%n;
//    printf("i=%ld j=%ld\n",i,j);
}
else{
// printf("i=%ld j=%ld\n",i,j);
printf("%lld\n",A[(i+k-1)%n]);
}

//printf("The value of m:%ld\n",m);
}
``````

//getch();
return 0;

}

You are getting wrong answer for the following testcase:

``````5 10
5 6 1 2 5
R 5
C 1
A 3
A 5
R 4
R 1
A 5
R 1
R 1
R 3
``````

See here.

``````5
6
2
2
2
5
``````
1 Like

your sample case is giving the correct ans.I have checked it myself just now

It may be correct on your machine but not on Codechef. See output section in the ideone link. This is the output of your solution on codechef. Codechef’s online judge and Ideone’s judge are same.

your link is showing the one of the value if ans is 9!
But i m getting all the ans correct

yes, that’s right. One extra 9 is printed which is not expected in output. That’s why WA. I’m trying to check few more things. I will reply in few minutes.