QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#921102 | #997. 2-SAT 问题 | gan1234# | WA | 77ms | 34916kb | C++14 | 900b | 2025-02-28 20:09:40 | 2025-02-28 20:09:41 |
Judging History
answer
#include<bits/stdc++.h>
#define MAXN 500005
using namespace std;
int n,m;
vector<int>G[MAXN],id[MAXN];
int S[MAXN],top;
int dfsc,scct;
int dfn[MAXN],low[MAXN],sccno[MAXN];
void dfs(int x){
dfn[x]=low[x]=++dfsc;
S[++top]=x;
for(auto y:G[x]){
if(!dfn[y]){
dfs(y);
low[x]=min(low[x],low[y]);
}else if(!sccno[y])low[x]=min(low[x],dfn[y]);
}
if(low[x]==dfn[x]){
scct++;
while(1){
int y=S[top];top--;
sccno[y]=scct;
if(x==y)break;
}
}
}
int main(){
cin>>n>>m;
int x,a,y,b;
for(int i=1;m>=i;i++){
cin>>x>>a>>y>>b;
G[x+a*n].push_back(y+(b^1)*n);
G[y+b*n].push_back(x+(a^1)*n);
}
for(int i=1;n*2>=i;i++)
if(!dfn[i])dfs(i);
for(int i=1;n>=i;i++)
if(sccno[i]==sccno[i+n]){
cout<<"No"<<endl;
return 0;
}
cout<<"Yes"<<endl;
for(int i=1;n>=i;i++)cout<<(sccno[i]>sccno[i+n])<<" ";
cout<<endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 77ms
memory: 34916kb
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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
wrong answer Your plan didn't satisfy condition #1.(i = 14615, a = 0, j = 14903, b = 1)