QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#463421 | #997. 2-SAT 问题 | crazy_sea# | WA | 26ms | 11760kb | C++14 | 931b | 2024-07-04 20:16:29 | 2024-07-04 20:16:29 |
Judging History
answer
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=2e6+10;
struct edge{
int next,to;
}e[N];
int first[N],len,cnt,dfn[N],low[N],t[N],col[N],tot;
void add(int a,int b)
{
e[++len]=edge{first[a],b};
first[a]=len;
}
void dfs(int x)
{
dfn[x]=low[x]=++cnt;
t[++len]=x;
for(int i=first[x],y;i;i=e[i].next)
{
y=e[i].to;
if(col[y]) continue;
if(!dfn[y]) dfs(y);
low[x]=min(low[x],low[y]);
}
if(dfn[x]==low[x])
{
tot++;
while(1)
{
col[t[len]]=tot;
if(t[len--]==x) return;
}
}
}
int n,m,x,y,a,b;
int main()
{
scanf("%d%d",&n,&m);
for(int i=1;i<=m;i++)
{
scanf("%d%d%d%d",&x,&a,&y,&b);
add(x+n*a,y+n*(b^1));
add(y+n*b,x+n*(a^1));
}
len=0;
for(int i=1;i<=2*n;i++)
if(!dfn[i]) dfs(i);
for(int i=1;i<=n;i++)
if(col[i]==col[i+n]) {printf("NO");return 0;}
printf("YES\n");
for(int i=1;i<=n;i++) printf("%d ",col[i]<col[i+n]);
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 26ms
memory: 11760kb
input:
86354 86418 14615 0 14903 1 13605 0 4458 0 15604 0 77112 0 52311 1 64996 0 22711 1 74245 1 39042 1 57372 1 2994 1 84183 1 80574 0 58791 1 27780 1 9336 1 61809 0 7216 0 71113 0 42287 1 20073 0 72448 0 73840 0 77048 0 28955 0 4165 0 16322 1 14075 1 43512 0 58600 1 45219 0 53858 0 14919 0 22576 0 16594...
output:
YES 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
wrong answer You didn't find a solution but jury did.