Submission #18514

# Submission time Handle Problem Language Result Execution time Memory
18514 2016-02-07T07:40:27 Z suhgyuho_william Collider (IZhO11_collider) C++
0 / 100
115 ms 13900 KB
#include <stdio.h>

int N,M,last;
int bucket[1010][2010],cnt[1010];
char s[1000010];

#define MOD 1000

int b,t;
void where(int x){
	int i,sum = 0;

	for(i=0; i<=last; i++){
		if(i == last){
			b = last;
			break;
		}
		sum += cnt[i];
		if(sum+cnt[i+1] > x){
			b = i;
			break;
		}
	}
	sum -= cnt[b];
	t = x-sum-1;
}

void pop(int x,int y){
	int i;

	for(i=y; i<cnt[x]-1; i++){
		bucket[x][i] = bucket[x][i+1];
	}
	cnt[x]--;
}

void push(int x,int y,int v){
	int i;

	for(i=cnt[x]-1; i>=y; i--){
		bucket[x][i+1] = bucket[x][i];
	}
	bucket[x][y] = v;
	cnt[x]++;
}

int tmp[1000010];
void setting(){
	int i,j,rear;

	rear = -1;
	for(i=0; i<=last; i++){
		for(j=0; j<cnt[i]; j++){
			rear++;
			tmp[rear] = bucket[i][j];
		}
		cnt[i] = 0;
	}
	for(i=0; i<=rear; i++){
		bucket[i/MOD][i%MOD] = tmp[i];
		cnt[i/MOD]++;
	}
}

int main(){
	int i,j;
	int x,y;
	int b1,t1,b2,t2,v;
	char op[5];
	//freopen("input.txt","r",stdin);

	scanf("%d %d",&N,&M);
	scanf("%s",s);
	for(i=0; i<N; i++){
		bucket[i/MOD][i%MOD] = s[i]-'x'+1;
		cnt[i/MOD]++;
	}
	last = ((N-1)/MOD);
	for(i=1; i<=M; i++){
		scanf("%s",op);
		if(op[0] == 'a'){
			scanf("%d %d",&x,&y);
			if(x == y) continue;
			where(x);
			b1 = b; t1 = t; v = bucket[b][t];
			where(y);
			b2 = b; t2 = t;
			pop(b1,t1);
			push(b2,t2,v);
		}else{
			scanf("%d",&x);
			where(x);
			printf("%c\n",'w'+bucket[b][t]);
		}
		if(i%MOD == 0) setting();
	}

	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 13900 KB Output isn't correct
2 Incorrect 0 ms 13900 KB Output isn't correct
3 Incorrect 0 ms 13900 KB Output isn't correct
4 Incorrect 36 ms 13900 KB Output isn't correct
5 Incorrect 59 ms 13900 KB Output isn't correct
6 Incorrect 85 ms 13900 KB Output isn't correct
7 Incorrect 89 ms 13900 KB Output isn't correct
8 Incorrect 48 ms 13900 KB Output isn't correct
9 Incorrect 115 ms 13900 KB Output isn't correct
10 Incorrect 83 ms 13900 KB Output isn't correct