QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#481614 | #997. 2-SAT 问题 | chroneZ# | WA | 32ms | 19848kb | C++17 | 1.2kb | 2024-07-17 11:41:15 | 2024-07-17 11:41:15 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int N = 2e5 + 5, M = 5e5 + 5;
vector<int> G[N];
int dfn[N], low[N], dn;
int stc[N], top; bool ins[N];
vector<vector<int>> scc; int col[N];
inline void form(int u) {
vector<int> C;
for(int x = stc[top--]; ; x = stc[top--]) {
C.push_back(x), col[x] = scc.size();
if(x == u) break;
}
scc.push_back(C);
}
inline void tarjan(int u) {
ins[stc[++top] = u] = true;
dfn[u] = low[u] = ++dn;
for(auto v : G[u]) {
if(!dfn[v]) tarjan(v), low[u] = min(low[u], low[v]);
else if(ins[v]) low[u] = min(low[u], dfn[v]);
}
if(dfn[u] == low[u]) form(u);
}
int n, m;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
cin >> n >> m;
for(int i = 1; i <= m; i++) {
int a, b, c, d; cin >> a >> b >> c >> d;
G[a + b * n].push_back(c + !d * n);
G[c + d * n].push_back(a + !b * n);
}
for(int i = 1; i <= n * 2; i++) {
if(!dfn[i]) tarjan(i);
}
for(int i = 1; i <= n; i++) {
if(col[i] == col[i + n]) return cout << "No\n", 0;
}
cout << "Yes\n";
for(int i = 1; i <= n; i++) {
cout << (col[i] < col[i + n]) << " \n"[i == n];
}
}
详细
Test #1:
score: 0
Wrong Answer
time: 32ms
memory: 19848kb
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:
No
result:
wrong answer You didn't find a solution but jury did.