QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#92074#997. 2-SAT 问题zhaohaikun#WA 74ms14208kbC++141.5kb2023-03-30 10:18:282023-03-30 10:18:32

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-30 10:18:32]
  • 评测
  • 测评结果:WA
  • 用时:74ms
  • 内存:14208kb
  • [2023-03-30 10:18:28]
  • 提交

answer

#include <bits/stdc++.h>
#define SZ(x) (int) x.size() - 1
#define all(x) x.begin(), x.end()
#define ms(x, y) memset(x, y, sizeof x)
#define F(i, x, y) for (int i = (x); i <= (y); i++)
#define DF(i, x, y) for (int i = (x); i >= (y); i--)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
template <typename T> void read(T &x) {
	x = 0; int f = 1; char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
const int N = 2e5 + 10;
int n, m, dfn[N], low[N], sccnum[N], scccnt, dfscnt, sta[N], stacnt;
vector <int> v[N];
void dfs(int x) {
	low[x] = dfn[x] = ++dfscnt;
	sta[stacnt++] = x;
	for (int i: v[x])
		if (!dfn[i]) {
			dfs(i);
			chkmin(low[x], low[i]);
		} else if (!sccnum[i]) {
			chkmin(low[x], dfn[i]);
		}
	if (low[x] == dfn[x]) {
		scccnt++;
		do {
			sccnum[sta[--stacnt]] = scccnt;
		} while (sta[stacnt] != x);
	}
}
signed main() {
	read(n); read(m);
	F(i, 1, m) {
		int x, y, a, b; read(x); read(a); read(y); read(b);
		v[x + (a ^ 1) * n].push_back(y + b * n);
		v[y + (b ^ 1) * n].push_back(x + a * n);
	}
	F(i, 1, 2 * n)
		if (!dfn[i]) dfs(i);
	F(i, 1, n)
		if (sccnum[i] == sccnum[i + n]) return puts("No"), 0;
	puts("Yes");
	F(i, 1, n) cout << (sccnum[i] < sccnum[i + n]) << " ";
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 74ms
memory: 14208kb

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)