QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#793377#997. 2-SAT 问题zhulexuanWA 16ms15460kbC++142.3kb2024-11-29 19:10:242024-11-29 19:10:25

Judging History

This is the latest submission verdict.

  • [2024-11-29 19:10:25]
  • Judged
  • Verdict: WA
  • Time: 16ms
  • Memory: 15460kb
  • [2024-11-29 19:10:24]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf INT_MAX
#define fr(i,l,r) for (i=(l); i<=(r); i++)
#define rfr(i,l,r) for (i=(l); i>=(r); i--)
template<typename T>inline void read(T &n){
    T w=1; n=0; char ch=getchar();
    while (!isdigit(ch) && ch!=EOF){ if (ch=='-') w=-1; ch=getchar(); }
    while (isdigit(ch) && ch!=EOF){ n=(n<<3)+(n<<1)+(ch&15); ch=getchar(); }
    n*=w;
}
template<typename T>inline void write(T x){
    if (x==0){ putchar('0'); return ; }
    T tmp;
    if (x>0) tmp=x;
    else tmp=-x;
    if (x<0) putchar('-');
    char F[105];
    long long cnt=0;
    while (tmp){
        F[++cnt]=tmp%10+48;
        tmp/=10;
    }
    while (cnt) putchar(F[cnt--]);
}
#define Min(x,y) x = min(x,y)
#define Max(x,y) x = max(x,y)
//基础配置=================================================================================
const ll N = 200005, M = 500005;
ll n,m;
struct edge{
    ll x,y;
};
ll cnt,head[N]; edge e[M+M];
void addedge(ll x,ll y){
    cnt++;
    e[cnt].x = head[x];
    e[cnt].y = y;
    head[x] = cnt;
}
ll tms,dfn[N],low[N];
bool vis[N]; ll top,q[N];
ll cs,id[N];
void tarjan(ll x){
    ll i, go;
    dfn[x] = low[x] = ++tms;
    vis[x] = true, q[++top] = x;
    for (i=head[x]; i; i=e[i].x){
        go = e[i].y;
        if (!dfn[go]){
            tarjan(go);
            Min( low[x] , low[go] );
        }
        else {
            if (vis[go]) Min( low[x] , dfn[go] );
        }
    }
    if (dfn[x]==low[x]){
        cs++;
        ll p;
        do{
            p = q[top--];
            vis[p] = false;
            id[p] = cs;
        }while (p!=x);
    }
}
ll v[N];
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
    ll i,j;
    read(n); read(m);
    fr(i,1,m){
        ll x,y,a,b,xx,yy;
        read(x); read(a); read(y); read(b);
        xx = x+n, yy = y+n;
        if (a==0) swap(x,xx);
        if (b==0) swap(y,yy);
        addedge(x,yy);
        addedge(y,xx);
    }
    fr(i,1,n+n)
        if (!dfn[i]) tarjan(i);
    fr(i,1,n){
        ll x = id[i], y = id[i+n];
        if (x==y){ printf("No\n"); return 0; }
        if (x<y) v[x] = 0; else v[x] = 1;
    }
    printf("Yes\n");
    fr(i,1,n) printf("%lld ",v[i]);
    return 0;
}
//g++ a.cpp -o a -Wall -Wl,--stack=512000000 -std=c++11 -O2

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 16ms
memory: 15460kb

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)