codechef.com/problems/ICM2004
I am an amateur and need help with this problem.
I don’t understand what I am doing wrong here.
Sample input and some other inputs are giving desired output just as the problem expects.
Time limit is not being exceeded.
Here is my code in C.
#include<stdio.h>
#include<malloc.h>
#define MOD 10000000007
int main()
{
char S,C;
int T,N,Q,L,R,p,q,type,i,tempP,tempQ;
scanf(“%d”,&T);
while(T–)
{
scanf(“%d”,&N);
S=(char)malloc(sizeof(char)*N);
scanf(“%s”,S);
scanf(“%d”,&Q);
while(Q–)
{scanf("%d",&type); if(type==1) { scanf("%d%d\n%c",&L,&R,&C); if(C=='A'||C=='B') { for(i=L;i<=R;i++) S[i-1]=C; } } else { scanf("%d%d%d%d",&L,&R,&p,&q); for(i=L;i<=R;i++) { if(S[i-1]=='A') { tempP=p-q; tempQ=p+q; } else { tempP=p+q; tempQ=q-p; } p=tempP; q=tempQ; } printf("%d %d\n",p%MOD,q%MOD); } } free(S);
}
return 0;
}
Any and all help is appreciated.
Thankyou.