QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#671006#997. 2-SAT 问题zhenjianuo2025WA 28ms17736kbC++142.2kb2024-10-24 09:48:292024-10-24 09:48:39

Judging History

This is the latest submission verdict.

  • [2024-10-24 09:48:39]
  • Judged
  • Verdict: WA
  • Time: 28ms
  • Memory: 17736kb
  • [2024-10-24 09:48:29]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define piii tuple<int,int,int>
#define mp make_pair
#define mt make_tuple
#define x first
#define y second
#define fi first
#define se second
#define era erase
#define ins insert
#define it iterator
#define lb lower_bound
#define ub upper_bound
#define exc(exp) if(exp)continue;
#define ret(exp) if(exp)return;
#define stop(exp) if(exp)break;
#define quit(sth) {sth;return;}
#define let(var...) int var;tie(var)
#define siz(vec) ((int)((vec).size()))
#define all(vec) (vec).begin(),(vec).end()
#define unq(vec) sort(all(vec)),(vec).erase(unique(all(vec)),(vec).end())
#define deb(var) cerr<<#var<<'='<<(var)<<"; "
#define debl(var) cerr<<#var<<'='<<(var)<<";\n"
#define int long long
#define inf (long long)(1e18)
void Max(int &x,int y){if(x<y)x=y;}
void Min(int &x,int y){if(x>y)x=y;}
const int mod=998244353;
void Add(int &x,int y){x=x+y<mod?x+y:x+y-mod;}
int fpm(int x,int y){
	int ans=1;for(;y;y>>=1,(x*=x)%=mod)if(y&1)(ans*=x)%=mod;return ans;
}

int n,m;
vector<int> g[200010];
void add(int u,int v){
    g[u].pb(v);
}
int dfn[200010],tim,low[200010],sc,scc[200010],inq[200010];stack<int> st;
void dfs(int u){
    dfn[u]=low[u]=++tim;
    st.push(u),inq[u]=1;
    for(auto v:g[u]){
        if(!dfn[v]){
            dfs(v);
            Min(low[u],low[v]);
        }else if(inq[v])Min(low[u],dfn[v]);
    }
    if(dfn[u]==low[u]){
        ++sc;
        while(st.top()!=u){
            scc[st.top()]=sc,inq[st.top()]=0,st.pop();
        }
        scc[u]=sc,inq[u]=0,st.pop();
    }
}
void work(){
    cin>>n>>m;
    for(int i=1,a,x,b,y;i<=m;i++){
        cin>>a>>x>>b>>y;
        add(a+(!x)*n,b+y*n),add(b+(!y)*n,a+x*n);
    }
    for(int i=1;i<=n+n;i++)if(!dfn[i])dfs(i);
    for(int i=1;i<=n;i++){
        if(scc[i]==scc[i+n])quit(cout<<"No\n");
    }                               cout<<"Yes\n";
    for(int i=1;i<=n;i++){
        cout<<(scc[i]<scc[i+n]?"1 ":"0 ");
    }
}

signed main(){
	ios::sync_with_stdio(0),
	cin.tie(0),cout.tie(0);
	int T=1;while(T--)work();
}
/*
 * CONTINUE, NON-STOPPING, FOR THE FAITH
 * START TYPING IF YOU DON'T KNOW WHAT TO DO
 * STOP TYPING IF YOU DON'T KNOW WHAT YOU'RE DOING
 */

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 28ms
memory: 17736kb

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 Your plan didn't satisfy condition #1.(i = 14615, a = 0, j = 14903, b = 1)