QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#129627#997. 2-SAT 问题yllcm#WA 27ms15976kbC++171.7kb2023-07-22 21:34:022023-07-22 21:34:05

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-22 21:34:05]
  • Judged
  • Verdict: WA
  • Time: 27ms
  • Memory: 15976kb
  • [2023-07-22 21:34:02]
  • Submitted

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.