QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#480852 | #997. 2-SAT 问题 | mfeitveer# | WA | 20ms | 20832kb | C++14 | 1.9kb | 2024-07-16 19:13:14 | 2024-07-16 19:13:15 |
Judging History
answer
/*
! 以渺小启程,以伟大结束。
! Created: 2024/07/16 19:08:45
*/
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
// #define int long long
#define mp(x, y) make_pair(x, y)
#define eb(...) emplace_back(__VA_ARGS__)
#define fro(i, x, y) for (int i = (x); i <= (y); i++)
#define pre(i, x, y) for (int i = (x); i >= (y); i--)
inline void JYFILE19();
typedef long long i64;
typedef pair<int, int> PII;
bool ST;
const int N = 1e6 + 10;
const int mod = 998244353;
int n, m, ct, tp, tt, head[N];
int dn[N], lw[N], vs[N], st[N], cl[N], id[2][N];
struct edge {
int to, nxt;
} e[N << 1];
inline void add(int x, int y) {
e[++ct] = {y, head[x]}, head[x] = ct;
}
inline void dfs(int x) {
dn[x] = lw[x] = ++ct, vs[x] = 1, st[++tp] = x;
for (int i = head[x]; i; i = e[i].nxt) {
if (!dn[e[i].to]) {
dfs(e[i].to);
lw[x] = min(lw[x], lw[e[i].to]);
} else if (vs[e[i].to]) {
lw[x] = min(lw[x], dn[e[i].to]);
}
}
if (dn[x] == lw[x]) {
++tt;
while (st[tp + 1] != x) {
cl[st[tp]] = tt, vs[st[tp]] = 0, tp--;
}
}
}
signed main() {
JYFILE19();
cin >> n >> m;
fro(i, 1, n) {
id[0][i] = ++ct;
id[1][i] = ++ct;
}
ct = 0;
fro(i, 1, m) {
int a, b, c, d;
cin >> a >> b >> c >> d;
add(id[b ^ 1][a], id[d][c]);
add(id[d ^ 1][c], id[b][a]);
}
ct = 0;
fro(i, 1, n + n)
if (dn[i] == 0) dfs(i);
fro(i, 1, n) {
if (cl[id[0][i]] == cl[id[1][i]])
cout << "No\n", exit(0);
}
cout << "Yes\n";
fro(i, 1, n) {
cout << (cl[id[0][i]] < cl[id[1][i]]) << " \n"[i == n];
}
return 0;
}
bool ED;
inline void JYFILE19() {
// freopen("", "r", stdin);
// freopen("", "w", stdout);
srand(random_device{}());
ios::sync_with_stdio(0), cin.tie(0);
double MIB = fabs((&ED-&ST)/1048576.), LIM = 512;
cerr << "MEMORY: " << MIB << endl, assert(MIB<=LIM);
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 20ms
memory: 20832kb
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)