QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#342816#997. 2-SAT 问题Ishy#WA 28ms14116kbC++142.8kb2024-03-01 17:12:362024-03-01 17:12:39

Judging History

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

  • [2024-03-01 17:12:39]
  • 评测
  • 测评结果:WA
  • 用时:28ms
  • 内存:14116kb
  • [2024-03-01 17:12:36]
  • 提交

answer

// Sea, You & Me
#include<bits/stdc++.h>
#define LL long long
#define DB double
#define MOD 998244353
#define ls(x) (x << 1)
#define rs(x) (x << 1 | 1)
#define lowbit(x) ((-x) & x)
#define MP make_pair
#define MT make_tuple
#define VI vector<int>
#define VL vector<LL>
#define VII VI::iterator
#define VLI VL::iterator
#define all(x) x.begin(), x.end()
#define EB emplace_back
#define PII pair<int, int>
#define SI set<int>
#define SII SI::iterator
#define fi first
#define se second
using namespace std;
template<typename T> void chkmn(T &a, const T b) { (a > b) && (a = b); }
template<typename T> void chkmx(T &a, const T b) { (a < b) && (a = b); }
void Inc(int &a, const int &b) { ((a += b) >= MOD) && (a -= MOD); }
void Dec(int &a, const int &b) { ((a -= b) < 0) && (a += MOD); }
void Mul(int &a, const int &b) { a = 1LL * a * b % MOD; }
void Sqr(int &a) { a = 1LL * a * a % MOD; }
int inc(const int &a, const int &b) { return (a + b >= MOD) ? a + b - MOD : a + b; }
int dec(const int &a, const int &b) { return (a - b < 0) ? a - b + MOD : a - b; }
int mul(const int &a, const int &b) { return 1LL * a * b % MOD; }
int sqr(const int &a) { return 1LL * a * a % MOD; }
int qwqmi(int x, int k = MOD - 2)
{
	int res = 1;
	while(k)
	{
		if(k & 1) Mul(res, x);
		k >>= 1, Sqr(x);
	}
	return res;
}
template<typename T> void read(T &x)
{
	x = 0;
	int f = 1;
	char ch = getchar();
	while(!isdigit(ch))
	{
		if(ch == '-')
			f = -1;
		ch = getchar();
	}
	while(isdigit(ch))
	{
		x = (x << 1) + (x << 3) + (ch ^ 48);
		ch = getchar();
	}
	x = x * f;
}
const int N = 2e5 + 5;
int n, m, ans[N];
vector<int> G[N];
void add(int x, int y)
{
	G[x].EB(y);
}
stack<int> stk;
bool instack[N];
int dfn[N], low[N], timestamp;
int colcnt, color[N];
void tarjan(int u)
{
	stk.push(u), instack[u] = 1;
	dfn[u] = low[u] = ++timestamp;
	for(auto v : G[u])
	{
		if(!dfn[v])
		{
			tarjan(v);
			chkmn(low[u], low[v]);
		}
		else if(instack[v])
			chkmn(low[u], dfn[v]);
	}
	if(low[u] == dfn[u])
	{
		++colcnt;
		int v = -1;
		while(v != u)
		{
			v = stk.top();
			stk.pop();
			instack[v] = 0;
			color[v] = colcnt;
		}
	}
}
int main()
{
	read(n), read(m);
	for(int i = 1; i <= m; ++i)
	{
		int a, b, c, d;
		read(a), read(b), read(c), read(d);
		if(b == 0 && d == 0) add(a, c + n), add(c, a + n);
		if(b == 0 && d == 1) add(a, c), add(c + n, a + n);
		if(b == 1 && d == 0) add(a + n, c + n), add(c, a);
		if(b == 1 && d == 1) add(a + n, c), add(c + n, a);
	}
	for(int i = 1; i <= 2 * n; ++i)
		if(!dfn[i]) tarjan(i);
	for(int i = 1; i <= n; ++i)
		if(color[i] == color[i + n])
			return puts("No"), 0;
	puts("Yes");
	for(int i = 1; i <= n; ++i)
		ans[i] = (color[i] > color[i + n]);
	for(int i = 1; i <= n; ++i)
		printf("%d ", ans[i]);
	return 0;
}




Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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 #1.(i = 14615, a = 0, j = 14903, b = 1)