Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix constraints of vertex_add_path_sum #247

Merged
merged 2 commits into from
Jan 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions datastructure/vertex_add_path_sum/gen/almost_line.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "random.h"
#include <iostream>
#include "../params.h"
#include "random.h"

using namespace std;

Expand All @@ -8,11 +9,11 @@ int main(int, char* argv[]) {
long long seed = atoll(argv[1]);
auto gen = Random(seed);

int n = 500'000;
int q = 500'000;
int n = N_AND_Q_MAX;
int q = N_AND_Q_MAX;
printf("%d %d\n", n, q);
for (int i = 0; i < n; i++) {
printf("%d", gen.uniform(0, 1'000'000'000));
printf("%d", gen.uniform<int>(0, A_AND_X_MAX));
if (i != n - 1) printf(" ");
}
printf("\n");
Expand Down Expand Up @@ -44,7 +45,7 @@ int main(int, char* argv[]) {
printf("%d ", t);
if (t == 0) {
int p = gen.uniform(0, n - 1);
int x = gen.uniform(0, 1'000'000'000);
int x = gen.uniform<int>(0, A_AND_X_MAX);
printf("%d %d\n", p, x);
} else {
auto u = gen.uniform(0, n - 1);
Expand Down
11 changes: 6 additions & 5 deletions datastructure/vertex_add_path_sum/gen/line.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "random.h"
#include <iostream>
#include "../params.h"
#include "random.h"

using namespace std;

Expand All @@ -8,11 +9,11 @@ int main(int, char* argv[]) {
long long seed = atoll(argv[1]);
auto gen = Random(seed);

int n = 500'000;
int q = 500'000;
int n = N_AND_Q_MAX;
int q = N_AND_Q_MAX;
printf("%d %d\n", n, q);
for (int i = 0; i < n; i++) {
printf("%d", gen.uniform(0, 1'000'000'000));
printf("%d", gen.uniform<int>(0, A_AND_X_MAX));
if (i != n - 1) printf(" ");
}
printf("\n");
Expand Down Expand Up @@ -40,7 +41,7 @@ int main(int, char* argv[]) {
printf("%d ", t);
if (t == 0) {
int p = gen.uniform(0, n - 1);
int x = gen.uniform(0, 1'000'000'000);
int x = gen.uniform<int>(0, A_AND_X_MAX);
printf("%d %d\n", p, x);
} else {
auto u = gen.uniform(0, n - 1);
Expand Down
7 changes: 4 additions & 3 deletions datastructure/vertex_add_path_sum/gen/max_random.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "random.h"
#include <iostream>
#include "../params.h"
#include "random.h"

using namespace std;

Expand All @@ -12,7 +13,7 @@ int main(int, char* argv[]) {
int q = 500'000;
printf("%d %d\n", n, q);
for (int i = 0; i < n; i++) {
printf("%d", gen.uniform(0, 1'000'000'000));
printf("%d", gen.uniform<int>(0, A_AND_X_MAX));
if (i != n - 1) printf(" ");
}
printf("\n");
Expand Down Expand Up @@ -40,7 +41,7 @@ int main(int, char* argv[]) {
printf("%d ", t);
if (t == 0) {
int p = gen.uniform(0, n - 1);
int x = gen.uniform(0, 1'000'000'000);
int x = gen.uniform<int>(0, A_AND_X_MAX);
printf("%d %d\n", p, x);
} else {
auto u = gen.uniform(0, n - 1);
Expand Down
9 changes: 5 additions & 4 deletions datastructure/vertex_add_path_sum/gen/random.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "random.h"
#include <iostream>
#include "../params.h"

using namespace std;

Expand All @@ -8,11 +9,11 @@ int main(int, char* argv[]) {
long long seed = atoll(argv[1]);
auto gen = Random(seed);

int n = gen.uniform(1, 500'000);
int q = gen.uniform(1, 500'000);
int n = gen.uniform<int>(1, N_AND_Q_MAX);
int q = gen.uniform<int>(1, N_AND_Q_MAX);
printf("%d %d\n", n, q);
for (int i = 0; i < n; i++) {
printf("%d", gen.uniform(0, 1'000'000'000));
printf("%d", gen.uniform<int>(0, A_AND_X_MAX));
if (i != n - 1) printf(" ");
}
printf("\n");
Expand Down Expand Up @@ -40,7 +41,7 @@ int main(int, char* argv[]) {
printf("%d ", t);
if (t == 0) {
int p = gen.uniform(0, n - 1);
int x = gen.uniform(0, 1'000'000'000);
int x = gen.uniform<int>(0, A_AND_X_MAX);
printf("%d %d\n", p, x);
} else {
auto u = gen.uniform(0, n - 1);
Expand Down
7 changes: 4 additions & 3 deletions datastructure/vertex_add_path_sum/gen/small.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "random.h"
#include <iostream>
#include "../params.h"
#include "random.h"

using namespace std;

Expand All @@ -12,7 +13,7 @@ int main(int, char* argv[]) {
int q = gen.uniform(1, 1000);
printf("%d %d\n", n, q);
for (int i = 0; i < n; i++) {
printf("%d", gen.uniform(0, 1'000'000'000));
printf("%d", gen.uniform<int>(0, A_AND_X_MAX));
if (i != n - 1) printf(" ");
}
printf("\n");
Expand Down Expand Up @@ -40,7 +41,7 @@ int main(int, char* argv[]) {
printf("%d ", t);
if (t == 0) {
int p = gen.uniform(0, n - 1);
int x = gen.uniform(0, 1'000'000'000);
int x = gen.uniform<int>(0, A_AND_X_MAX);
printf("%d %d\n", p, x);
} else {
auto u = gen.uniform(0, n - 1);
Expand Down
6 changes: 5 additions & 1 deletion datastructure/vertex_add_path_sum/info.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@ forum = "https://github.com/yosupo06/library-checker-problems/issues/125"

[[solutions]]
name = "naive.cpp"
wrong = true
wrong = true

[params]
N_AND_Q_MAX = 500_000
A_AND_X_MAX = 1_000_000_000
4 changes: 2 additions & 2 deletions datastructure/vertex_add_path_sum/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ $Q$ 個のクエリが飛んでくるので処理。
制約
---------

- $1 \leq N, Q \leq 200,000$
- $0 \leq a_i, x \leq 10^9$
- $1 \leq N, Q \leq {{param N_AND_Q_MAX}}$
- $0 \leq a_i, x \leq {{param A_AND_X_MAX}}$
- $0 \leq p, u_i, v_i < N$
- $(u_i, v_i)$ は木

Expand Down
9 changes: 5 additions & 4 deletions datastructure/vertex_add_path_sum/verifier.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "testlib.h"
#include "params.h"
#include <vector>

struct UnionFind {
Expand Down Expand Up @@ -26,13 +27,13 @@ struct UnionFind {
int main() {
registerValidation();

int n = inf.readInt(1, 500'000, "N");
int n = inf.readInt(1, N_AND_Q_MAX, "N");
inf.readSpace();
int q = inf.readInt(1, 500'000, "Q");
int q = inf.readInt(1, N_AND_Q_MAX, "Q");
inf.readEoln();

for (int i = 0; i < n; i++) {
inf.readInt(0, 1'000'000'000, "a_i");
inf.readInt(0, A_AND_X_MAX, "a_i");
if (i != n - 1) inf.readSpace();
}
inf.readEoln();
Expand All @@ -53,7 +54,7 @@ int main() {
if (t == 0) {
inf.readInt(0, n - 1, "p");
inf.readSpace();
inf.readInt(0, 1'000'000'000, "x");
inf.readInt(0, A_AND_X_MAX, "x");
} else {
inf.readInt(0, n - 1, "u");
inf.readSpace();
Expand Down