QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#626737#9449. New School TermzhouhuanyiWA 1ms3904kbC++231.0kb2024-10-10 12:16:482024-10-10 12:16:48

Judging History

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

  • [2024-10-10 12:16:48]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3904kb
  • [2024-10-10 12:16:48]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<vector>
#define N 10000
#define M 100000
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;
}
int n,m,A[M+1],B[M+1],rt[N+1],cl[N+1];
vector<int>E[N+1];
void add(int x,int y)
{
	E[x].push_back(y),E[y].push_back(x);
	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 dfs(int x)
{
	for (int i=0;i<E[x].size();++i)
		if (!cl[E[x][i]])
			cl[E[x][i]]=cl[x]^3,dfs(E[x][i]);
	return;
}
int main()
{
	n=read(),m=read();
	for (int i=1;i<=(n<<1);++i) rt[i]=i;
	for (int i=1;i<=m;++i) A[i]=read(),B[i]=read();
	for (int i=m;i>=1;--i)
		if (find(A[i])!=find(B[i]))
			add(A[i],B[i]),unionn(find(A[i]),find(B[i]+n)),unionn(find(B[i]),find(A[i]+n));
	for (int i=1;i<=(n<<1);++i)
		if (!cl[i])
			cl[i]=1,dfs(i);
	for (int i=1;i<=(n<<1);++i) printf("%d",cl[i]==1);
	puts("");
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3904kb

input:

2 4
1 3
2 4
1 4
1 2

output:

1001

result:

wrong answer The division is not minimized.