QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#481609#997. 2-SAT 问题Sktn0089#RE 0ms0kbC++141.1kb2024-07-17 11:31:272024-07-17 11:31:27

Judging History

This is the latest submission verdict.

  • [2024-07-17 11:31:27]
  • Judged
  • Verdict: RE
  • Time: 0ms
  • Memory: 0kb
  • [2024-07-17 11:31:27]
  • Submitted

answer

#include <bits/stdc++.h>
#define ll long long
#define pir pair <ll, ll>
#define mkp make_pair
#define fi first
#define se second
#define pb push_back
using namespace std;
const ll maxn = 1e5 + 10;
ll n, m, a, b, c, d;
ll scc[maxn], cnt, dfn[maxn], low[maxn], ti, stk[maxn], top, vis[maxn];
vector <ll> to[maxn];
void tarjan(ll u) {
	dfn[u] = low[u] = ++ti, vis[stk[++top] = u] = 1;
	for(ll v: to[u])
		if(dfn[v]) {
			if(vis[v]) low[u] = min(low[u], dfn[v]);
		} else {
			tarjan(v); low[u] = min(low[u], low[v]);
		}
	if(dfn[u] == low[u]) {
		++cnt, stk[top + 1] = 0;
		while(stk[top + 1] ^ u) {
			ll x = stk[top--]; vis[x] = 0;
			scc[x] = cnt;
		}
	}
}
int main(){
	scanf("%lld%lld", &n, &m);
	for(ll i = 1; i <= m; i++) {
		scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
		to[a + (b ^ 1) * n].pb(c + d * n);
		to[c + (d ^ 1) * n].pb(a + b * n);
	}
	for(ll i = 1; i <= 2 * n; i++)
		if(!dfn[i]) tarjan(i);
	for(ll i = 1; i <= n; i++)
		if(scc[i] == scc[i + n]) { puts("No"); return 0; }
	puts("Yes");
	for(ll i = 1; i <= n; i++)
		printf("%lld ", (ll) (scc[i] > scc[i + n]));
	return 0;
}

詳細信息

Test #1:

score: 0
Runtime Error

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:


result: