QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#626737 | #9449. New School Term | zhouhuanyi | WA | 1ms | 3904kb | C++23 | 1.0kb | 2024-10-10 12:16:48 | 2024-10-10 12:16:48 |
Judging History
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;
}
详细
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.