void CallHandoverEvent::handleEvent(Base blist[]){
	if(SCHEME == 0)
		scheme0(blist);
	else
		scheme1(blist);
}
Ejemplo n.º 2
0
int main(){
	long T;
	long tn = 1;
	long index;
	scanf("%ld",&T);
	int invert;
	while(tn <= T){
		scanf("%ld %ld",&n,&k);
		scanf("%s",string);

		inversions = 0;
		inversions2 = 0;
		invert = 0;
		for(index = 0; index < n; index++){
			newstring[index] = 0;
		}

		flag0 = 0;
		flag1 = 0;		

		if(k == 1){
			invert = scheme1();
		}
		else{
			scheme2();
		}
		
		if(invert == 0){
			printf("%ld\n", inversions);
			//Straight printing.
			for(index = 0;index < n;index++){
				if(newstring[index] == 0){
					if(string[index] == '1')
						printf("1");
					else
						printf("0");
				}
				else{
					if(string[index] == '1')
						printf("0");
					else
						printf("1");
				}
			}
		}
		
		else{
			//inverted printing.
			printf("%ld\n", inversions2);
			for(index = 0;index < n;index++){
				if(newstring[index] == 1){
					if(string[index] == '1')
						printf("1");
					else
						printf("0");
				}
				else{
					if(string[index] == '1')
						printf("0");
					else
						printf("1");
				}
			}
		}
		printf("\n");
		tn ++;
	}

	return 0;

}
void CallInitiationEvent::handleEvent(Base blist[]){
	if(SCHEME == 0)
		scheme0(blist);
	else
		scheme1(blist);
}