Skip to content

Commit 80002ed

Browse files
authored
Merge pull request #1328 from PonderKoKo/master
Add potential TLE testcases for two_sat
2 parents 0de0787 + 8ef43c1 commit 80002ed

3 files changed

Lines changed: 35 additions & 0 deletions

File tree

other/two_sat/gen/long_chain.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include "random.h"
2+
#include <iostream>
3+
4+
using namespace std;
5+
6+
// 1 -> 2, 2 -> 3, ..., n-1 -> n, n -> -n.
7+
// Leads to quadratic runtime when attempting to set variables to true in ascending order.
8+
// Also generates symmetrical testcases that flip each variable or the order.
9+
int main(int, char* argv[]) {
10+
11+
long long seed = atoll(argv[1]);
12+
13+
int n = 500'000;
14+
auto flip = [&] (int i) {
15+
if (seed & 1) i *= -1;
16+
// Map n <-> 1, n - 1 <-> 2, ..., -n <-> -1, -(n - 1) <-> -2, ...
17+
if (seed & 2) i = (i > 0 ? 1 : -1) * (n + 1) - i;
18+
return i;
19+
};
20+
printf("p cnf %d %d\n", n, n);
21+
for (int i = 1; i <= n; i++)
22+
printf("%d %d 0\n", flip(-i), flip(i == n ? -n : i + 1));
23+
return 0;
24+
}

other/two_sat/hash.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@
1717
"max_random_03.out": "ec1f6fbaa5a28ccced08db81ec28e54837b023d01d07306d238c8e251c2d1730",
1818
"max_random_04.in": "89b06ca430c85621fefa5646bdb530499a693ee1b65a77615ff13255e15c983f",
1919
"max_random_04.out": "afa233a49d2e5feacdba78c0b9ce71e5ae415bf516b3503d1697424f68783cfa",
20+
"long_chain_00.in": "f962b54cff18f6cbfb7bcf32ebe2ecac8c09553dccd169037e8c7886086feb3e",
21+
"long_chain_00.out": "f618525e84f0b7c761c566128e8fe6f28471b9d9150594b50ceff4ff976a36a5",
22+
"long_chain_01.in": "1618a29daa67db152d46739a23eb072dee00ebe384352254983bb6bb91f84171",
23+
"long_chain_01.out": "9433dad1a560921b3fda167802d86bf3fdb77125a063765ef84b235edec7555b",
24+
"long_chain_02.in": "c9fad21bd9b8e594990bb48abb5d7fd34d295229fc70b0fe7f42a04487dc0c66",
25+
"long_chain_02.out": "f618525e84f0b7c761c566128e8fe6f28471b9d9150594b50ceff4ff976a36a5",
26+
"long_chain_03.in": "4e0c7c6cc9464c22917812731d5e4a4becc51e09b5d6790fc51501560a42e6a9",
27+
"long_chain_03.out": "9433dad1a560921b3fda167802d86bf3fdb77125a063765ef84b235edec7555b",
2028
"random_00.in": "a029f1e87b4932652a66ce0190cc21cd3d883f8c2e4d6d294294ae00b364d7a5",
2129
"random_00.out": "bde6e1eede96772c07c8ce29fd18088863815bd043aa59a06f11f5838cf8a162",
2230
"random_01.in": "3b705485df2b13619ead244c10c9f9d58c8b9a9dcfea85d7aea1460e6a40fdd3",

other/two_sat/info.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,6 @@ forum = "https://github.com/yosupo06/library-checker-problems/issues/26"
1414
[[tests]]
1515
name = "cycle_unsat.cpp"
1616
number = 2
17+
[[tests]]
18+
name = "long_chain.cpp"
19+
number = 4

0 commit comments

Comments
 (0)