QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#340919 | #997. 2-SAT 问题 | orz_z# | WA | 31ms | 32260kb | C++14 | 1.5kb | 2024-02-29 14:07:04 | 2024-02-29 14:07:05 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
// #define int long long
#define F(i, l, r) for(int i = (l); i <= (r); ++i)
#define dF(i, r, l) for(int i = (r); i >= (l); --i)
int ri() {
int x = 0, f = 1;
char c = getchar();
while(c < '0' || c > '9') {
if(c == '-') f = -1;
c = getchar();
}
while(c >= '0' && c <= '9') {
x = x* 10 + c - 48;
c = getchar();
} return x * f;
}
const int _ = 1e6 + 5;
vector<int> d[_];
int cnt, dfn[_], low[_], Id[_], n, m;
int id(int x, int y) {
return x + y * (n + 1);
}
void add(int u, int v) {
d[u].push_back(v);
}
stack<int> st;
int cntn;
void tarjan(int u) {
dfn[u] = low[u] = ++cnt;
st.push(u);
for(int v : d[u]) if(!dfn[v]) {
tarjan(v);
low[u] = min(low[u], low[v]);
} else if(!Id[v]) low[u] = min(low[u], dfn[v]);
if(low[u] == dfn[u]) {
++cntn;
while(1) {
int nw = st.top();
st.pop();
Id[nw] = cnt;
if(nw == u) break;
}
}
}
signed main() {
n = ri(), m = ri();
F(i, 1, m) {
int a = ri(), b = ri(), c = ri(), d = ri();
add(id(a, !b), id(c, d));
add(id(c, !d), id(a, b));
}
F(i, 1, n + n + 1) if(!dfn[i]) tarjan(i);
F(i, 1, n) if(Id[i] == Id[i + n + 1]) {
puts("NO");
return 0;
}
puts("YES");
F(i, 1, n) if(Id[i] < Id[i + n + 1]) {
cout << 0 << ' ';
} else cout << 1 << ' ';
cout << '\n';
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 31ms
memory: 32260kb
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 You didn't find a solution but jury did.