题目(洛谷)
在说此题之前我们先来看一张图片:
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <climits>
#define ll long long
#define llmax LONG_LONG_MAX
#define llmin LONG_LONG_MIN
#define readf(f) scanf(
#define eps 1e-18
using namespace std;
const int inf=0x3f3f3f3f;
const int N=(1<<11)+5;
inline void init()
{
freopen("phalanx.in","r",stdin);
freopen("phalanx.out","w",stdout);
}
template <class _E> inline void read(_E &e)
{
e=0;bool ck=0;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')ck=1;ch=getchar();}
while(ch>='0'&&ch<='9'){e=e*10+ch-'0';ch=getchar();}
if(ck)e=-e;
}
int n,m,q;
int a[1005][1005];
int cnt;
int main()
{
// init();
read(n),read(m),read(q);
for (int i=1;i<=n;++i)
for (int j=1;j<=m;++j)
a[i][j]=++cnt;
while (q--)
{
int x,y;
read(x),read(y);
int tmp=a[x][y];
a[x][y]=0;
printf(
for (int i=y;i<m;++i)
{
swap(a[x][i],a[x][i+1]);
}
for (int i=x;i<n;++i)
{
swap(a[i][m],a[i+1][m]);
}
a[n][m]=tmp;
}
return 0;
}
100分的做法可以用vector+线段树或树状数组轻松解决,暂时先坑在这里,之后有时间了再来补上
Comments NOTHING