QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#673776#997. 2-SAT 问题lyccWA 36ms16016kbC++202.3kb2024-10-25 10:04:372024-10-25 10:04:38

Judging History

This is the latest submission verdict.

  • [2024-10-25 10:04:38]
  • Judged
  • Verdict: WA
  • Time: 36ms
  • Memory: 16016kb
  • [2024-10-25 10:04:37]
  • Submitted

answer

#include <bits/stdc++.h>
#define int long long
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define pb emplace_back
#define For(i, x, y) for (int i = (x); i <= (y); i ++)
#define rep(i, x, y) for (int i = (x); i >= (y); i --)
#define pii pair<int, int>
#define all(v) v.begin(), v.end()
#define sz(v) (int)((v).size())
#define ull unsigned long long
#define ls (p << 1)
#define rs (p << 1 | 1)
#define mp make_pair
#define i128 __int128
#define db long double
#define vi vector< int >
#define mem(v, x) memset(v, x, sizeof(v))
#define A3 array< int, 3 >
#define A4 array< int, 4 >
#define vpii vector< pair< int, int > >
using namespace std;
mt19937_64 rnd(time(0));
template< typename T > void cmin(T &x, T y) { return x = min(x, y), void(); }
template< typename T > void cmax(T &x, T y) { return x = max(x, y), void(); }
int ksm(int x, int y, int p) {
    int v = 1; x %= p;
    while (y) v = 1ll * v * ((y & 1) ? x : 1) % p, x = 1ll * x * x % p, y >>= 1;
    return (v % p + p) % p;
}
bool MemoryST;
const int N = 2e5 + 5;
const int mod = 998244353;
const long long INF = 1e18;
const int base = 13131;
int n, m;
vi e[N];
int f(int x, int y) {
	return y * n + x;
}
int dfn[N], low[N], num;
stack< int > st;
bool flag[N];
int tot, scc[N];
void dfs(int x) {
	dfn[x] = low[x] = ++ num; st.push(x); flag[x] = 1;
	for (int y : e[x])
		if (!dfn[y]) dfs(y), cmin(low[x], low[y]);
		else if (flag[y]) cmin(low[x], dfn[y]);
	if (dfn[x] == low[x]) {
		tot ++;
		while (sz(st)) {
			int y = st.top(); st.pop();
			scc[y] = tot; flag[y] = 0;
			if (x == y) return;
		}
	}
	return;
}
void Main() {
	cin >> n >> m;
	For (i, 1, m) {
		int a, b, c, d; cin >> a >> b >> c >> d;
		e[f(a, b ^ 1)].pb(f(c, d));
		e[f(c, d ^ 1)].pb(f(a, b));
	}
	For (i, 1, 2 * n) if (!dfn[i]) dfs(i);
	For (i, 1, n) if (scc[i] == scc[i + n]) return cout << "No", void();
	cout << "Yes\n";
	For (i, 1, n) cout << (scc[i] < scc[i + n]) << ' ';
    return;
}
bool MemoryED;
signed main() {
    ios :: sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cerr << fixed << setprecision(6) << (&MemoryST - &MemoryED) / 1048576.0 << "MB\n";
    int TESTCNT = 1;
    // cin >> TESTCNT;
    while (TESTCNT --) Main();
    cerr << endl << 1e3 * clock() / CLOCKS_PER_SEC << "ms"; 
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 36ms
memory: 16016kb

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)