期望五十分,实际35分求助
查看原帖
期望五十分,实际35分求助
233957
190040257a楼主2020/9/16 17:59

蒟蒻没学过treaptreap,觉得前面50分挺好拿的就想试试,然而前前后后调试了几遍还是只有35分。。。

我想的就是只保存可能会被修改的行和最后一列,其他状态因为不造成影响所以不保存,但不知道哪里出了问题,三个点WA,都是中间某几行答案有问题。。

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstring>
using namespace std;
int n1[501][50007];
int m1[100002];
int N,M,P;
int cun[501][3];
bool sf[50002];
int whe[50002];
int cnt=0;
int main()
{
	cin>>N>>M>>P;
	for(int i=1;i<=P;i++)
	{
		int x,y;
		cin>>x>>y;
		cun[i][1]=x;
		cun[i][2]=y;
		sf[x]=1;
	}
	for(int i=1;i<=N;i++)
	{
		if(sf[i])
		{
			whe[i]=++cnt;
			for(int j=1;j<=M-1;j++)
			{
				n1[whe[i]][j]=(i-1)*M+j;
			}
		}
	}
	for(int i=1;i<=N;i++)
	{
		m1[i]=i*M;
	}
	for(int l=1;l<=P;l++)
	{
		int x=cun[l][1];
		int y=cun[l][2];
		if(y!=M)
		{
			cout<<n1[whe[x]][y]<<endl;
			int here=n1[whe[x]][y];
			for(int i=y;i<M-1;i++)
			{
				n1[whe[x]][i]=n1[whe[x]][i+1];
			}
			n1[whe[x]][M-1]=m1[x];
			for(int j=x;j<N;j++)
			{
				m1[j]=m1[j+1];
			}
			m1[N]=here;
		}
		else if(y==M)
		{
			cout<<m1[x]<<endl;
			int here=m1[x];
			for(int j=x;j<N;j++)
			{
				m1[j]=m1[j+1];
			}
			m1[N]=here;
		}
	}
	return 0;
}
2020/9/16 17:59
加载中...