题目传送门:http://codeforces.com/problemset/problem/706/E
官方题解:http://codeforces.com/blog/entry/46510
#include<iostream> #include<cstdio> using namespace std; const int MAXN = 1000+9; int d[MAXN*MAXN],r[MAXN*MAXN],mat[MAXN*MAXN],m,n,q,vout[MAXN][MAXN]; inline int read(){ char c=getchar(); int ret = 0; while (c<'0'||c>'9') c=getchar(); while (c<='9'&&c>='0') ret = ret*10+c-'0', c=getchar(); return ret; } #define id(x, y) ((x)+1 + (y)*(n+2)) inline void change(int x1, int y1, int x2, int y2, int x, int y){ int p1 = id(0,0), p2 = id(0,0); for (int j=1;j<y1;j++) p1 = d[p1]; for (int i=1;i<=x1;i++) p1 = r[p1]; for (int j=1;j<y2;j++) p2 = d[p2]; for (int i=1;i<=x2;i++) p2 = r[p2]; for (int i=1;i<=x;i++) swap(d[p1], d[p2]), p1 = r[p1], p2 = r[p2]; p1 = id(0,0), p2 = id(0,0); for (int j=1;j<y1+y;j++) p1 = d[p1]; for (int i=1;i<=x1;i++) p1 = r[p1]; for (int j=1;j<y2+y;j++) p2 = d[p2]; for (int i=1;i<=x2;i++) p2 = r[p2]; for (int i=1;i<=x;i++) swap(d[p1], d[p2]), p1 = r[p1], p2 = r[p2]; p1 = id(0,0), p2 = id(0,0); for (int i=1;i<x1;i++) p1 = r[p1]; for (int j=1;j<=y1;j++) p1 = d[p1]; for (int i=1;i<x2;i++) p2 = r[p2]; for (int j=1;j<=y2;j++) p2 = d[p2]; for (int j=1;j<=y;j++) swap(r[p1], r[p2]), p1 = d[p1], p2 = d[p2]; p1 = id(0,0), p2 = id(0,0); for (int i=1;i<x1+x;i++) p1 = r[p1]; for (int j=1;j<=y1;j++) p1 = d[p1]; for (int i=1;i<x2+x;i++) p2 = r[p2]; for (int j=1;j<=y2;j++) p2 = d[p2]; for (int j=1;j<=y;j++) swap(r[p1], r[p2]), p1 = d[p1], p2 = d[p2]; } inline void trans(){ int head = id(0,0); for (int j=1;j<=m;j++) { head = d[head]; for (int i=1,w=r[head];i<=n;i++,w=r[w]) vout[i][j] = mat[w]; } for (int j=1;j<=m;j++) {for (int i=1;i<=n;i++) printf("%d ",vout[i][j]); printf("\n");} } int main(){ m = read(); n = read(); q = read(); for (int j=1;j<=m;j++) for (int i=1;i<=n;i++) mat[id(i,j)] = read(); for (int j=0;j<=m+1;j++) for (int i=0;i<=n+1;i++) d[id(i,j)] = id(i,j+1), r[id(i,j)] = id(i+1,j); for (int k=1,x1,x2,y1,y2,lh,lw;k<=q;k++) { y1 = read(), x1 = read(); y2 = read(), x2 = read(); lh = read(), lw = read(); change(x1,y1,x2,y2,lw,lh); } trans(); return 0; }
哇塞,居然是沙发?留个名
283375 783505Its amazing what supplementing can do for your body and your weight lifting goals! 320064
753943 827330A weblog like yours really should be earning a lot dollars from adsense..-., 351846
484765 686250We dont trust this amazing submit. Nevertheless, I saw it gazed for Digg along with Ive determined you can be appropriate so i ended up being imagining within the completely wrong way. Persist with writing top quality stuff along these lines. 245366
Hi there colleagues, how is the whole thing, and what you would like to say on the topic
of this paragraph, in my view its in fact amazing in support of me.
565044 668338Hi. Thank you for producing this internet site . I m working on betting online niche and have located this web site making use of search on bing . Will be certain to look a lot more of your content . Gracias , see ya. :S 576229
I know this web site presents quality dependent content and other material, is there any other web site which offers such stuff
in quality?
Good info. Lucky me I ran across your blog by chance (stumbleupon).
I’ve saved as a favorite for later!
115902 586161Hey there! Great post! Please when I will see a follow up! 47531
I really like it whenever people come together and share thoughts.
Great site, keep it up!
740512 73746Merely wanna input that you have a really nice internet website , I enjoy the pattern it actually stands out. 468232
733561 73038Hi, have you ever before asked yourself to write about Nintendo or PSP? 926499
Good day! This post couldn’t be written any better! Reading through this
post reminds me of my good old room mate!
He always kept chatting about this. I will forward this post
to him. Fairly certain he will have a good read. Many thanks for sharing!
216057 561350It is truly a fantastic and valuable piece of info. Im happy which you just shared this beneficial info with us. Please stay us informed like this. Thank you for sharing. 899909
It’s actually a great and helpful piece of information. I’m happy
that you shared this helpful info with us.
Please stay us up to date like this. Thank you for
sharing.
I’m very pleased to discover this web site.
I want to to thank you for ones time just for this fantastic read!!
I definitely enjoyed every bit of it and I have you saved to fav to see new stuff in your website.
Greetings from Los angeles! I’m bored to death at work so I decided to check out
your site on my iphone during lunch break. I enjoy the knowledge you present here and can’t wait to take
a look when I get home. I’m shocked at how quick your
blog loaded on my phone .. I’m not even using WIFI, just
3G .. Anyways, great site!
Every weekend i used to visit this website, as i wish for enjoyment, as this this web page conations in fact fastidious funny data
too.
Wonderful beat ! I wish to apprentice even as you
amend your website, how could i subscribe for a blog site?
The account aided me a acceptable deal. I have been tiny bit familiar of this your
broadcast offered shiny clear concept
Thanks on your marvelous posting! I really enjoyed reading it,
you are a great author. I will remember to bookmark your blog and may come back at some point.
I want to encourage you continue your great writing, have a
nice holiday weekend!
Thanks for finally writing about >【Codeforces 706E】Working routine –
Qizy’s Database <Liked it!
Nice post. I was checking continuously this blog and I am impressed!
Very helpful info specifically the remaining phase 🙂 I
handle such information much. I used to be looking for this
particular information for a very lengthy time. Thanks and good luck.
This is very interesting, You are a very skilled blogger.
I’ve joined your feed and look forward to seeking more of your wonderful post.
Also, I have shared your website in my social networks!
I really appreciate this post. I have been looking all over for this! Thank goodness I found it on Bing. You have made my day! Thanks again
Hello, I would like to subscribe for this webpage to get newest updates,
thus where can i do it please assist.
I’m not sure why but this blog is loading extremely slow for me.
Is anyone else having this issue or is it a problem on my end?
I’ll check back later on and see if the problem still exists.
Hello, Neat post. There is an issue together with your
site in internet explorer, would test this?
IE still is the marketplace chief and a good element
of other folks will miss your wonderful writing due to this problem.
Aw, this was a really nice post. Taking the time and
actual effort to generate a good article… but
what can I say… I procrastinate a lot and never manage to get anything done.
I like what you guys are up also. Such clever work and reporting! Keep up the superb works guys I¡¦ve incorporated you guys to my blogroll. I think it’ll improve the value of my web site
Hello my friend! I want to say that this article is amazing, nice written and include almost all important infos. I would like to look more posts like this .
Wonderful paintings! This is the kind of info that are meant to be shared around the web. Shame on the search engines for no longer positioning this submit upper! Come on over and discuss with my website . Thank you
Very well written article. It will be supportive to everyone who utilizes it, as well as yours truly 🙂 . Keep up the good work – can’r wait to read more posts.
Hi, Neat post. There’s an issue together with your web site in internet explorer, would test this?
IE still is the marketplace chief and a good element of folks will leave out your fantastic
writing due to this problem.
If you are going for finest contents like me, only go to see this site
daily since it offers quality contents, thanks
You are so interesting! I do not think I have read
a single thing like that before. So wonderful to find someone with genuine thoughts on this
topic. Seriously.. thanks for starting this up. This web site
is one thing that is needed on the web, someone with a
bit of originality!
You have observed very interesting points! ps decent internet site.