QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#670957 | #997. 2-SAT 问题 | yhddd | WA | 19ms | 23108kb | C++20 | 2.0kb | 2024-10-24 09:12:57 | 2024-10-24 09:12:58 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define mod 998244353ll
#define pii pair<int,int>
#define fi first
#define se second
#define mems(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define db double
using namespace std;
const int maxn=500010;
const int inf=1e18;
inline int read(){
int x=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+(ch-48);ch=getchar();}
return x*f;
}
bool Mbe;
int n,m;
int head[maxn],tot;
struct nd{
int nxt,to;
}e[maxn<<1];
void add(int u,int v){e[++tot]={head[u],v};head[u]=tot;}
int id(int u,int op){return u+op*n;}
int dfn[maxn],lw[maxn],idx;
int st[maxn],tp;
int scc[maxn],scct;
void tar(int u){
dfn[u]=lw[u]=++idx,st[++tp]=u;
for(int i=head[u];i;i=e[i].nxt){
int v=e[i].to;
if(!dfn[v]){
tar(v);
lw[u]=min(lw[u],lw[v]);
}
else if(!scc[v])lw[u]=min(lw[u],dfn[v]);
}
if(dfn[u]==lw[u]){
scc[st[tp]]=++scct;
while(st[tp--]!=u)scc[st[tp]]=scct;
}
}
vector<int> g[maxn];
int d[maxn];
queue<int> q;
int rnk[maxn],tim;
void work(){
n=read();m=read();
for(int i=1;i<=m;i++){
int u=read(),a=read(),v=read(),b=read();
add(id(u,a^1),id(v,b)),add(id(v,b^1),id(u,a));
}
for(int i=1;i<=2*n;i++)if(!dfn[i])tar(i);
for(int i=1;i<=n;i++)if(scc[id(i,0)]==scc[id(i,1)]){puts("No");return ;}
for(int u=1;u<=n;u++){
for(int i=head[u];i;i=e[i].nxt){
int v=e[i].to;
if(scc[u]!=scc[v])g[scc[u]].pb(scc[v]),d[scc[v]]++;
}
}
while(!q.empty()){
int u=q.front();q.pop();rnk[++tim]=u;
for(int v:g[u]){
d[v]--;
if(!d[v])q.push(v);
}
}
puts("Yes");
for(int i=1;i<=n;i++){
if(rnk[id(i,0)]>rnk[id(i,1)])printf("1 ");
else printf("0 ");
}
}
// \
444
bool Med;
int T;
signed main(){
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
// ios::sync_with_stdio(0);
// cin.tie(0);cout.tie(0);
// cerr<<(&Mbe-&Med)/1048576.0<<" MB\n";
T=1;
while(T--)work();
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 19ms
memory: 23108kb
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 #5.(i = 22711, a = 1, j = 74245, b = 1)