#include<stdio.h>
#include<vector>
int buk[1010][2100];
int bs[1010];
char in[1000001];
int main()
{
int n, m;
int i, j, k;
int a, b, bn;
scanf("%d%d", &n, &m);
scanf("%s", in);
j=0;
for(i=0; j<n; i++)
{
for(k=j; k<j+1000 && k<n; k++)
{
buk[i][k-j] = in[k]-'x';
bs[i]++;
}
j = k;
}
for(;m--;)
{
scanf("%s", in);
if(in[0] == 'a')
{
scanf("%d%d", &a, &b); a--; b--;
int t;
bn = 0;
j = 0;
for(i=0; i<a; )
{
if(i+bs[bn] <= a) i+=bs[bn++];
else{i++;j++;}
}
bs[bn]--;
t = buk[bn][j];
for(; j<bs[bn]; j++) buk[bn][j] = buk[bn][j+1];
bn = 0;
j = 0;
for(i=0; i<b; )
{
if(i+bs[bn] <= b) i+=bs[bn++];
else{i++;j++;}
}
bs[bn]++;
for(k=bs[bn]-1; k>j; k--) buk[bn][k] = buk[bn][k-1];
buk[bn][j] = t;
}
else
{
scanf("%d", &a);a--;
bn = 0;
j = 0;
for(i=0; i<a; )
{
if(i+bs[bn] <= a) i+=bs[bn++];
else{i++;j++;}
}
printf("%c\n", buk[bn][j]+'x');
}
if(m%1000 == 0)
{
int l = 0;
for(i=0; i<1010; i++)
{
for(j=0; j<bs[i]; j++) in[l++] = buk[bn][j];
}
j=0;
for(i=0; j<n; i++)
{
bs[i] = 0;
for(k=j; k<j+1000 && k<n; k++)
{
buk[i][k-j] = in[k];
bs[i]++;
}
j = k;
}
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
10348 KB |
Output is correct |
2 |
Incorrect |
23 ms |
10348 KB |
Output isn't correct |
3 |
Incorrect |
15 ms |
10348 KB |
Output isn't correct |
4 |
Incorrect |
26 ms |
10348 KB |
Output isn't correct |
5 |
Incorrect |
59 ms |
10348 KB |
Output isn't correct |
6 |
Incorrect |
67 ms |
10348 KB |
Output isn't correct |
7 |
Incorrect |
72 ms |
10348 KB |
Output isn't correct |
8 |
Incorrect |
31 ms |
10348 KB |
Output isn't correct |
9 |
Incorrect |
81 ms |
10348 KB |
Output isn't correct |
10 |
Incorrect |
61 ms |
10348 KB |
Output isn't correct |