Skip to content

Commit

Permalink
Merge pull request #1235 from maspypy/1212
Browse files Browse the repository at this point in the history
テストケース追加(issue 1212)
  • Loading branch information
maspypy authored Sep 6, 2024
2 parents f36d589 + 9d59f42 commit 816ea16
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 0 deletions.
37 changes: 37 additions & 0 deletions graph/eulerian_trail_directed/gen/many_same_vertex.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include <cstdio>
#include "random.h"
#include "../params.h"

using namespace std;

int main(int, char* argv[]) {
long long seed = atoll(argv[1]);
auto gen = Random(seed);

int k = seed % 3 + 1;
int n = N_MAX;
assert(k <= n);

vector<pair<int, int>> out;
vector<int> S = gen.choice(k, 0, n - 1);

int t = 1;
int m = M_MAX;
vector<pair<int, int>> edges;
int v = gen.uniform<int>(0, n - 1);
for (int i = 0; i < m; ++i) {
// 確率 1/2 で S を通るようにする
int w = gen.uniform<int>(0, n - 1);
if (gen.uniform<int>(0, 1)) { w = S[gen.uniform<int>(0, k - 1)]; }
int a = v, b = w;
edges.emplace_back(a, b);
v = w;
}
gen.shuffle(edges.begin(), edges.end());
out.emplace_back(n, m);
for (auto& [a, b]: edges) out.emplace_back(a, b);

printf("%d\n", t);
for (auto [a, b]: out) printf("%d %d\n", a, b);
return 0;
}
6 changes: 6 additions & 0 deletions graph/eulerian_trail_directed/hash.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
"example_00.out": "38692d616b7a81c2d1319e9ac01b4ea91d6234d73802097dde19b61123d39366",
"example_01.in": "5cb8d2151b509aec222e8d1b98048500b2e4c6f126921e59e19c1d7259960cd1",
"example_01.out": "03e73e5845ae88e90877acc9f3c61194adbc80bb691441c7a381267eb4a0ab7f",
"many_same_vertex_00.in": "41a6233b9fa487c2f5785c530353f1ccd17a75034ea1724f2081a070029c301a",
"many_same_vertex_00.out": "b69e0f3a7ba5920a59225ecb53ebe8e89744fb76a56421a01b76a4e4f522b606",
"many_same_vertex_01.in": "b8314b938abcc170bc46185f53df413f627ed451753e2a520ae24e1513fa9147",
"many_same_vertex_01.out": "d064ff5903f51a4b2628ce716fd1c2b4a468a5e3c1f3e497f04eb64b01ca75ee",
"many_same_vertex_02.in": "b0dde206467955076b0f546f7ab1fa8ff989bdb04577393430ae5144894637c2",
"many_same_vertex_02.out": "9265ce8c06bd0aa4f8f713aee66204ead90c12fb0f243706e48809e6a642a37e",
"max_random_00.in": "b82a740e06d62cccd8607085b35d49e0610cccb9d5649a222924e8da0c397f6e",
"max_random_00.out": "31375587f8bedb1f33f6eca3d8cee94ab70845a6dd1a7c7eeb929f4aa7dc10ab",
"max_random_01.in": "958049e86371632bc9925d4e2051a684cc7d0d37ce1df5e7f903bb3f96d03777",
Expand Down
4 changes: 4 additions & 0 deletions graph/eulerian_trail_directed/info.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ forum = "https://github.com/yosupo06/library-checker-problems/issues/25"
name = "euler_tour.cpp"
number = 4

[[tests]]
name = "many_same_vertex.cpp"
number = 3

[params]
T_MIN = 1
T_MAX = 100_000
Expand Down
38 changes: 38 additions & 0 deletions graph/eulerian_trail_undirected/gen/many_same_vertex.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include <cstdio>
#include "random.h"
#include "../params.h"

using namespace std;

int main(int, char* argv[]) {
long long seed = atoll(argv[1]);
auto gen = Random(seed);

int k = seed % 3 + 1;
int n = N_MAX;
assert(k <= n);

vector<pair<int, int>> out;
vector<int> S = gen.choice(k, 0, n - 1);

int t = 1;
int m = M_MAX;
vector<pair<int, int>> edges;
int v = gen.uniform<int>(0, n - 1);
for (int i = 0; i < m; ++i) {
// 確率 1/2 で S を通るようにする
int w = gen.uniform<int>(0, n - 1);
if (gen.uniform<int>(0, 1)) { w = S[gen.uniform<int>(0, k - 1)]; }
int a = v, b = w;
if (gen.uniform<int>(0, 1)) swap(a, b);
edges.emplace_back(a, b);
v = w;
}
gen.shuffle(edges.begin(), edges.end());
out.emplace_back(n, m);
for (auto& [a, b]: edges) out.emplace_back(a, b);

printf("%d\n", t);
for (auto [a, b]: out) printf("%d %d\n", a, b);
return 0;
}
6 changes: 6 additions & 0 deletions graph/eulerian_trail_undirected/hash.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
"example_00.out": "de86a20ebef3890b1f2865fd640b49acb3f8a0cfee3dc8edd7ec5d688e5fddb2",
"example_01.in": "1b0bbe2e40ab8800a2b81132c2d5a0674d8af54b8d334669ab7de1a57ce0f162",
"example_01.out": "287581654bd0b0fc833df526a71a264051de78e9bcc1ce6468779a042a80c549",
"many_same_vertex_00.in": "95c4d4d1316f004d1f3401439479590d3d95d4c046205dc26957eeee7b5ae08b",
"many_same_vertex_00.out": "aeaecc6e9023d339b644b1cde0a696fca75e58dfb54c3bc833ec126dd23221ed",
"many_same_vertex_01.in": "40a6b9c19f3144124cfe5cb6edfaac5d720e3c9f25386421ddd7a3913c9a17ab",
"many_same_vertex_01.out": "f0ad7b7737afab69ea444dd5006d7835a2df9a8ef360c2f5cb68d439aa9ff5a6",
"many_same_vertex_02.in": "36984d6ac1ab40cc6b89bdec65252508404ea3cc50b84ad78afc14e87ec84be9",
"many_same_vertex_02.out": "1c2f65e75bd9c40da638cf546ba7eb1cf44ddb8116c829a7734676d0f38bea25",
"max_random_00.in": "b82a740e06d62cccd8607085b35d49e0610cccb9d5649a222924e8da0c397f6e",
"max_random_00.out": "31375587f8bedb1f33f6eca3d8cee94ab70845a6dd1a7c7eeb929f4aa7dc10ab",
"max_random_01.in": "958049e86371632bc9925d4e2051a684cc7d0d37ce1df5e7f903bb3f96d03777",
Expand Down
4 changes: 4 additions & 0 deletions graph/eulerian_trail_undirected/info.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ forum = "https://github.com/yosupo06/library-checker-problems/issues/25"
name = "euler_tour.cpp"
number = 4

[[tests]]
name = "many_same_vertex.cpp"
number = 3

[params]
T_MIN = 1
T_MAX = 100_000
Expand Down

0 comments on commit 816ea16

Please sign in to comment.