Submission #38007837
Source Code Expand
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define f(i,j,k) for(register int i=j;i<=k;++i)
#define g(i,j,k) for(register int i=j;i>=k;--i)
int n,m,s,l;
const int maxn=505050;
const int inf=1e15+225;
struct Splay{
int f[maxn],ch[maxn][2],siz[maxn],mark[maxn],key[maxn],root,sz,m=0;
int data[maxn];
inline int get(int x){return ch[f[x]][1]==x;}
inline void update(int x){siz[x]=siz[ch[x][1]]+siz[ch[x][0]]+1;}
inline void swap(int &x,int &y){int t=x;x=y;y=t;}
inline void pushdown(int x){
if(x&&mark[x]){
mark[ch[x][0]]^=1;
mark[ch[x][1]]^=1;
swap(ch[x][0],ch[x][1]);
mark[x]=0;
}
}
inline void rot(int x){
int k=get(x),fa=f[x],fafa=f[fa];
pushdown(fa);pushdown(x);
ch[fa][k]=ch[x][!k];f[ch[x][!k]]=fa;
ch[x][!k]=fa;f[fa]=x;
f[x]=fafa;
if (fafa) ch[fafa][ch[fafa][1]==fa]=x;
update(fa);update(x);
}
inline void splay(int x,int tar){
for(int fa;(fa=f[x])!=tar;rot(x))
if(f[fa]!=tar)
rot(get(fa)==get(x)?fa:x);
if (!tar)root=x;
}
inline int build(int fa,int l,int r){
if(l>r)return 0;
int mid=(l+r)>>1;
int now=++sz;
key[now]=data[mid],f[now]=fa,mark[now]=0;
ch[now][0]=build(now,l,mid-1);
ch[now][1]=build(now,mid+1,r);
update(now);
return now;
}
inline int findx(int k){
int now=root;
while(1){
pushdown(now);
if (k<=siz[ch[now][0]])
now=ch[now][0];
else{
k-=siz[ch[now][0]]+1;
if (!k) return now;
now=ch[now][1];
}
}
}
inline void print(int now,int*a){
pushdown(now);
if (ch[now][0]) print(ch[now][0],a);
if (key[now]!=-inf && key[now]!=inf)a[++m]=key[now];
if (ch[now][1]) print(ch[now][1],a);
}
inline void init(int n){
for(int i=1;i<=n;i++)data[i+1]=i;
data[1]=-inf,data[n+2]=inf;
root=build(0,1,n+2);
}
inline void fz(int x,int y){
int x1=findx(x),y1=findx(y+2);
splay(x1,0);
splay(y1,x1);
mark[ch[ch[root][1]][0]]^=1;
}
inline void set(int*a){print(root,a);}
}W,H;
int a[maxn],b[maxn];
string c[maxn];
signed main(){
cin>>n>>m;
f(i,1,n)cin>>c[i];
W.init(n);H.init(m);
cin>>s;
int x,y;
f(i,1,s){
scanf("%lld %lld",&x,&y);
W.fz(1,x);W.fz(x+1,n);
H.fz(1,y);H.fz(y+1,m);
}
W.set(a);H.set(b);
f(i,1,n){
f(j,1,m)putchar(c[a[i]][b[j]-1]);
putchar('\n');
}
return 0;
}
Submission Info
Submission Time
2023-01-14 21:28:03+0900
Task
B - Grid Rotations
User
scyxdl
Language
C++ (GCC 9.2.1)
Score
500
Code Size
2539 Byte
Status
AC
Exec Time
387 ms
Memory
35476 KiB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:84:4: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
84 | f(i,1,n)cin>>c[i];
| ^
./Main.cpp:4:35: note: in definition of macro ‘f’
4 | #define f(i,j,k) for(register int i=j;i<=k;++i)
| ^
./Main.cpp:88:4: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
88 | f(i,1,s){
| ^
./Main.cpp:4:35: note: in definition of macro ‘f’
4 | #define f(i,j,k) for(register int i=j;i<=k;++i)
| ^
./Main.cpp:94:4: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
94 | f(i,1,n){
| ^
./Main.cpp:4:35: note: in definition of macro ‘f’
4 | #define f(i,j,k) for(register int i=j;i<=k;++i)
| ^
./Main.cpp:95:5: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
95 | f(j,1,m)putchar(c[a[i]][b[j]-1]);
| ^
./Main.cpp:4:35: note: in definition of macro ‘f’
4 | #define f(i,j,k) for(register int i=j;i<=k;++i)
| ^
./Main.cpp:89:8: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
89 | scanf("%lld %lld",&x,&y);
| ~~~~~^~~~~~~~~~~~~~~~~~~
Judge Result
Set Name
Sample
All
Score / Max Score
0 / 0
500 / 500
Status
Set Name
Test Cases
Sample
01_sample_01.txt, 01_sample_02.txt, 01_sample_03.txt
All
01_sample_01.txt, 01_sample_02.txt, 01_sample_03.txt, 02_small_01.txt, 02_small_02.txt, 02_small_03.txt, 02_small_04.txt, 02_small_05.txt, 02_small_06.txt, 02_small_07.txt, 02_small_08.txt, 02_small_09.txt, 03_rand_01.txt, 03_rand_02.txt, 03_rand_03.txt, 03_rand_04.txt, 03_rand_05.txt, 04_square_01.txt, 04_square_02.txt, 04_square_03.txt, 04_square_04.txt, 04_square_05.txt, 05_max_H_01.txt, 05_max_H_02.txt, 05_max_H_03.txt, 05_max_H_04.txt, 05_max_H_05.txt, 06_max_W_01.txt, 06_max_W_02.txt, 06_max_W_03.txt, 06_max_W_04.txt, 06_max_W_05.txt
Case Name
Status
Exec Time
Memory
01_sample_01.txt
AC
32 ms
19464 KiB
01_sample_02.txt
AC
22 ms
19356 KiB
01_sample_03.txt
AC
16 ms
19456 KiB
02_small_01.txt
AC
17 ms
19364 KiB
02_small_02.txt
AC
22 ms
19460 KiB
02_small_03.txt
AC
18 ms
19364 KiB
02_small_04.txt
AC
16 ms
19436 KiB
02_small_05.txt
AC
16 ms
19492 KiB
02_small_06.txt
AC
19 ms
19336 KiB
02_small_07.txt
AC
20 ms
19436 KiB
02_small_08.txt
AC
17 ms
19488 KiB
02_small_09.txt
AC
18 ms
19456 KiB
03_rand_01.txt
AC
235 ms
19980 KiB
03_rand_02.txt
AC
234 ms
20148 KiB
03_rand_03.txt
AC
184 ms
19588 KiB
03_rand_04.txt
AC
248 ms
20724 KiB
03_rand_05.txt
AC
212 ms
19728 KiB
04_square_01.txt
AC
233 ms
20268 KiB
04_square_02.txt
AC
237 ms
20272 KiB
04_square_03.txt
AC
237 ms
20228 KiB
04_square_04.txt
AC
234 ms
20232 KiB
04_square_05.txt
AC
235 ms
20232 KiB
05_max_H_01.txt
AC
387 ms
35076 KiB
05_max_H_02.txt
AC
381 ms
35088 KiB
05_max_H_03.txt
AC
379 ms
35080 KiB
05_max_H_04.txt
AC
386 ms
35224 KiB
05_max_H_05.txt
AC
384 ms
35080 KiB
06_max_W_01.txt
AC
361 ms
35260 KiB
06_max_W_02.txt
AC
364 ms
35344 KiB
06_max_W_03.txt
AC
361 ms
35340 KiB
06_max_W_04.txt
AC
368 ms
35380 KiB
06_max_W_05.txt
AC
375 ms
35476 KiB