提出 #19114271
ソースコード 拡げる
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
void*wmem;
char memarr[96000000];
template<class T> inline void walloc1d(T **arr, int x, void **mem = &wmem){
static int skip[16] = {0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
(*mem) = (void*)( ((char*)(*mem)) + skip[((unsigned long long)(*mem)) & 15] );
(*arr)=(T*)(*mem);
(*mem)=((*arr)+x);
}
template<class T> inline void walloc1d(T **arr, int x1, int x2, void **mem = &wmem){
walloc1d(arr, x2-x1, mem);
(*arr) -= x1;
}
inline int my_getchar_unlocked(){
static char buf[1048576];
static int s = 1048576;
static int e = 1048576;
if(s == e && e == 1048576){
e = fread_unlocked(buf, 1, 1048576, stdin);
s = 0;
}
if(s == e){
return EOF;
}
return buf[s++];
}
inline void rd(int &x){
int k;
int m=0;
x=0;
for(;;){
k = my_getchar_unlocked();
if(k=='-'){
m=1;
break;
}
if('0'<=k&&k<='9'){
x=k-'0';
break;
}
}
for(;;){
k = my_getchar_unlocked();
if(k<'0'||k>'9'){
break;
}
x=x*10+k-'0';
}
if(m){
x=-x;
}
}
inline void rd(char &c){
int i;
for(;;){
i = my_getchar_unlocked();
if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
break;
}
}
c = i;
}
inline int rd(char c[]){
int i;
int sz = 0;
for(;;){
i = my_getchar_unlocked();
if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
break;
}
}
c[sz++] = i;
for(;;){
i = my_getchar_unlocked();
if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
break;
}
c[sz++] = i;
}
c[sz]='\0';
return sz;
}
inline int rd_int(void){
int x;
rd(x);
return x;
}
struct MY_WRITER{
char buf[1048576];
int s;
int e;
MY_WRITER(){
s = 0;
e = 1048576;
}
~MY_WRITER(){
if(s){
fwrite_unlocked(buf, 1, s, stdout);
}
}
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
MY_WRITER_VAR.s = 0;
}
MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
my_putchar_unlocked(a);
}
inline void wt_L(const char c[]){
int i=0;
for(i=0;c[i]!='\0';i++){
my_putchar_unlocked(c[i]);
}
}
int N;
int F;
char*S;
char C;
int main(){
int Lj4PdHRW;
wmem = memarr;
int r = 0;
walloc1d(&S, -200000, 200000);
N = rd(S);
int KL2GvlyY = rd_int();
for(Lj4PdHRW=(0);Lj4PdHRW<(KL2GvlyY);Lj4PdHRW++){
if(rd_int() == 1){
r ^= 1;
}
else{
rd(F);F += (-1);
rd(C);
if(F==r){
S = S - 1;
S[0] = C;
}
else{
S[N] = C;
}
N++;
}
}
if(r){
reverse(S, S+N);
}
S[N] = '\0';
wt_L(S);
wt_L('\n');
return 0;
}
// cLay version 20201229-1
// --- original code ---
// int N, F;
// char *S, C;
// {
// int r = 0;
// walloc1d(&S, -2d5, 2d5);
// rd(S@N);
// REP(rd_int()){
// if(rd_int() == 1){
// r ^= 1;
// } else {
// rd(F--, C);
// if(F==r){
// S = S - 1;
// S[0] = C;
// } else {
// S[N] = C;
// }
// N++;
// }
// }
// if(r) reverse(S, S+N);
// S[N] = '\0';
// wt(S);
// }
提出情報
ジャッジ結果
| セット名 |
Sample |
All |
| 得点 / 配点 |
0 / 0 |
400 / 400 |
| 結果 |
|
|
| セット名 |
テストケース |
| Sample |
s1.txt, s2.txt, s3.txt |
| All |
01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, s1.txt, s2.txt, s3.txt |
| ケース名 |
結果 |
実行時間 |
メモリ |
| 01.txt |
AC |
8 ms |
3484 KiB |
| 02.txt |
AC |
2 ms |
3584 KiB |
| 03.txt |
AC |
1 ms |
3584 KiB |
| 04.txt |
AC |
2 ms |
3596 KiB |
| 05.txt |
AC |
2 ms |
3548 KiB |
| 06.txt |
AC |
2 ms |
3580 KiB |
| 07.txt |
AC |
5 ms |
3632 KiB |
| 08.txt |
AC |
4 ms |
3584 KiB |
| 09.txt |
AC |
1 ms |
3636 KiB |
| 10.txt |
AC |
2 ms |
3660 KiB |
| 11.txt |
AC |
9 ms |
5136 KiB |
| 12.txt |
AC |
12 ms |
5068 KiB |
| 13.txt |
AC |
9 ms |
5092 KiB |
| 14.txt |
AC |
12 ms |
5120 KiB |
| 15.txt |
AC |
13 ms |
4968 KiB |
| 16.txt |
AC |
14 ms |
5168 KiB |
| 17.txt |
AC |
11 ms |
5156 KiB |
| 18.txt |
AC |
12 ms |
5208 KiB |
| 19.txt |
AC |
11 ms |
5040 KiB |
| 20.txt |
AC |
11 ms |
5008 KiB |
| 21.txt |
AC |
11 ms |
5096 KiB |
| s1.txt |
AC |
2 ms |
3592 KiB |
| s2.txt |
AC |
2 ms |
3584 KiB |
| s3.txt |
AC |
2 ms |
3596 KiB |