QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#129627 | #997. 2-SAT 问题 | yllcm# | WA | 27ms | 15976kb | C++17 | 1.7kb | 2023-07-22 21:34:02 | 2023-07-22 21:34:05 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define db double
#define ldb long double
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define FR first
#define SE second
using namespace std;
inline int read() {
int x = 0; bool op = 0;
char c = getchar();
while(!isdigit(c))op |= (c == '-'), c = getchar();
while(isdigit(c))x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
return op ? -x : x;
}
const int N = 2e5 + 10;
int n, m, tot, cnt, c_scc, top;
int id[N][2], dfn[N], low[N], scc[N], on[N], stk[N];
vector<int> G[N];
void tarjan(int u) {
dfn[u] = low[u] = ++cnt; on[u] = true; stk[++top] = u;
for(int v : G[u]) {
if(dfn[v] == 0) {
tarjan(v);
low[u] = min(low[u], low[v]);
}
else if(on[v])low[u] = min(low[u], dfn[v]);
}
if(dfn[u] == low[u]) {
c_scc++;
do {
int cur = stk[top];
scc[cur] = c_scc; on[cur] = false;
}while(stk[top--] != u);
}
return ;
}
int main() {
n = read(); m = read();
for(int i = 1; i <= n; i++)
for(int o = 0; o < 2; o++)
id[i][o] = ++tot;
for(int i = 1; i <= n; i++) {
int a = read(), b = read(), c = read(), d = read();
G[id[a][!b]].pb(id[c][d]);
G[id[c][!d]].pb(id[a][b]);
}
for(int i = 1; i <= n; i++)if(dfn[i] == 0)tarjan(i);
for(int i = 1; i <= n; i++)
if(scc[id[i][0]] == scc[id[i][1]])
return puts("No"), 0;
puts("Yes");
for(int i = 1; i <= n; i++)printf("%d ", (scc[id[i][1]] < scc[id[i][0]]));
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 27ms
memory: 15976kb
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.