QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#627481#9449. New School TermzhouhuanyiCompile Error//C++232.0kb2024-10-10 16:05:252024-10-10 16:05:25

Judging History

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

  • [2024-10-10 16:05:25]
  • 评测
  • [2024-10-10 16:05:25]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<vector>
#define N 10000
#define M 1000000
#define mod 998244353
using namespace std;
int read()
{
	char c=0;
	int sum=0;
	while (c<'0'||c>'9') c=getchar();
	while ('0'<=c&&c<='9') sum=sum*10+c-'0',c=getchar();
	return sum;
}
void Adder(int &x,int d)
{
	x=x+d>=mod?x+d-mod:x+d;
	return;
}
void Adder2(int &x,int d)
{
	x=x+d<0?x+d+mod:x+d;
	return;
}
struct reads
{
	int num,data;
};
int n,m,cnt,res,cl[N+1],rt[N+1],dp[N+1],A[M+1],B[M+1],delta[N+1];
bool used[N+1];
vector<reads>E[N+1];
void add(int x,int y,int z)
{
	E[x].push_back((reads){y,z}),E[y].push_back((reads){x,z});
	return;
}
int find(int x)
{
	if (rt[x]==x) return x;
	return rt[x]=find(rt[x]);
}
void unionn(int x,int y)
{
	rt[x]=y;
	return;
}
void adder(int x,int d)
{
	if (x)
	{
		if (d==1)
		{
			res+=x;
			for (int i=(n<<1);i>=x;--i) Adder(dp[i],dp[i-x]);
		}
		else
		{
			res-=x;
			for (int i=x;i<=(n<<1);++i) Adder2(dp[i],-dp[i-x]);
		}
	}
	return;
}
void dfs(int x)
{
	if (!cl[x]) cnt++;
	else cnt--;
	used[x]=1;
	for (int i=0;i<E[x].size();++i)
		if (!used[E[x][i].num])
			cl[E[x][i].num]=cl[x]^E[x][i].data,dfs(E[x][i].num);
	return;
}
void solve(int x,int y)
{
	if (find(x)!=find(y))
	{
		a=delta[find(x)],b=delta[find(y)];
		adder(delta[find(x)],-1),adder(delta[find(y)],-1),add(x,y,1);
		for (int i=1;i<=(n<<1);++i) used[i]=0;
		cnt=0,dfs(x),cnt=abs(cnt),adder(cnt,1);
		if (!dp[res>>1])
		{
			for (int i=1;i<=(n<<1);++i) used[i]=0;
			adder(cnt,-1),cnt=E[x].back().data=E[y].back().data=0,dfs(x),cnt=abs(cnt),adder(cnt,1);
		}
		unionn(find(x),find(y)),delta[find(x)]=cnt;
	}
	return;
}
int main()
{
	n=read(),m=read(),dp[0]=1;
	for (int i=1;i<=(n<<1);++i) rt[i]=i,delta[i]=1;
	for (int i=1;i<=m;++i) A[i]=read(),B[i]=read();
	for (int i=1;i<=(n<<1);++i) adder(1,1);
	for (int i=m;i>=1;--i) solve(A[i],B[i]);
	for (int i=1;i<=(n<<1);++i) solve(1,i);
	for (int i=1;i<=(n<<1);++i) printf("%d",cl[i]);
	puts("");
	return 0;
}

详细

answer.code: In function ‘void solve(int, int)’:
answer.code:79:17: error: ‘a’ was not declared in this scope
   79 |                 a=delta[find(x)],b=delta[find(y)];
      |                 ^
answer.code:79:34: error: ‘b’ was not declared in this scope
   79 |                 a=delta[find(x)],b=delta[find(y)];
      |                                  ^