QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#486954#7926. Color Inversion on a Huge ChessboardteamJZW#RE 0ms0kbC++171.0kb2024-07-22 13:43:472024-07-22 13:43:48

Judging History

你现在查看的是最新测评结果

  • [2024-07-22 13:43:48]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-07-22 13:43:47]
  • 提交

answer

#include<bits/stdc++.h>
#define rep(a,b,c) for(int c(a);c<=(b);++c)
#define drep(a,b,c) for(int c(a);c>=(b);--c)
using namespace std;
inline int read()
{
	int res;char ch=getchar();while(ch<'0'||ch>'9')ch=getchar();
	while(ch<='9'&&ch>='0')res=res*10+(ch^48),ch=getchar();return res;
}
const int N=1e6+10;char op[10];int n,a[2][N];
inline void opr(int *a,int x)
{
	if(n==1)
	{
		a[0]=1;
		return;
	}
	if(x-1>0&&x+1<=n)
	{
		if(a[x+1]==a[x-1])
		{
			if(a[x+1]==a[x])
			{
				a[0]+=2;
			}
			else
			{
				a[0]-=2;
			}
		}
		
	}
	else if(x-1>0&&x+1>n)
	{
		if(a[x-1]==a[x])
		{
			a[0]++;
		}
		else
		{
			a[0]--;
		}
	}
	else if(x-1<=0&&x+1<=n)
	{
		if(a[x+1]==a[x])
		{
			a[0]++;
		}
		else
		{
			a[0]--;
		}
	}
	a[x]^=1;
}
int main()
{
	n=read();int Q=read();
	a[0][0]=a[1][0]=1;
	for(int i=1;i<=n;i+=2)
	{
		opr(a[0],i);
	}
	for(int i=2;i<=n;i+=2)
	{
		opr(a[1],i);
	}
	while(Q--)
	{
		scanf("%s",op+1);
		opr(a[op[1]=='R'],read());
		printf("%lld\n",1ll*a[0][0]*a[1][0]);
	}
	
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

input:

3 3
ROW 2
COLUMN 3
ROW 2

output:


result: