Skip to content

Commit

Permalink
Merge pull request yosupo06#1259 from maspypy/psrc
Browse files Browse the repository at this point in the history
問題追加 Point Set Range Composite (Large Array)
  • Loading branch information
maspypy authored Nov 11, 2024
2 parents c7b4bbd + 86d04f8 commit 1974433
Show file tree
Hide file tree
Showing 15 changed files with 804 additions and 0 deletions.
62 changes: 62 additions & 0 deletions data_structure/point_set_range_composite_large_array/checker.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// https://github.com/MikeMirzayanov/testlib/blob/master/checkers/wcmp.cpp

// The MIT License (MIT)

// Copyright (c) 2015 Mike Mirzayanov

// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:

// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

#include "testlib.h"

using namespace std;

int main(int argc, char * argv[])
{
setName("compare sequences of tokens");
registerTestlibCmd(argc, argv);

int n = 0;
string j, p;

while (!ans.seekEof() && !ouf.seekEof())
{
n++;

ans.readWordTo(j);
ouf.readWordTo(p);

if (j != p)
quitf(_wa, "%d%s words differ - expected: '%s', found: '%s'", n, englishEnding(n).c_str(), compress(j).c_str(), compress(p).c_str());
}

if (ans.seekEof() && ouf.seekEof())
{
if (n == 1)
quitf(_ok, "\"%s\"", compress(j).c_str());
else
quitf(_ok, "%d tokens", n);
}
else
{
if (ans.seekEof())
quitf(_wa, "Participant output contains extra tokens");
else
quitf(_wa, "Unexpected EOF in the participants output");
}
}
45 changes: 45 additions & 0 deletions data_structure/point_set_range_composite_large_array/gen/dense.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#include "random.h"
#include <iostream>
#include "../params.h"

using namespace std;

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

int n = N_MAX;
int q = Q_MAX;
printf("%d %d\n", n, q);

int ws[] = {1, 1000, 500000};
int w = ws[seed % 3];

int L = gen.uniform<int>(0, n - w);
int R = L + w;

auto idx = [&]() -> int { return gen.uniform<int>(L, R - 1); };

auto idx2 = [&]() -> pair<int, int> {
int a = idx(), b = idx();
if (a > b) swap(a, b);
++b;
return {a, b};
};

for (int i = 0; i < q; i++) {
int t = gen.uniform(0, 1);
printf("%d ", t);
if (t == 0) {
int p = idx();
int c = gen.uniform(1LL, MOD - 1);
int d = gen.uniform(0LL, MOD - 1);
printf("%d %d %d\n", p, c, d);
} else {
auto [a, b] = idx2();
int x = gen.uniform(0LL, MOD - 1);
printf("%d %d %d\n", a, b, x);
}
}
return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
1000000000 6
0 100 2 3
0 10000 4 5
1 99 100 10
1 1 1000000000 1
0 1000000 6 7
1 1 1000000000 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include "random.h"
#include <iostream>
#include "../params.h"

using namespace std;

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

int n = N_MAX;
int q = Q_MAX;
printf("%d %d\n", n, q);
for (int i = 0; i < q; i++) {
int t = gen.uniform(0, 100);
t = (t == 0 ? 1 : 0);
printf("%d ", t);
if (t == 0) {
int p = gen.uniform(0, n - 1);
int c = gen.uniform(1LL, MOD - 1);
int d = gen.uniform(0LL, MOD - 1);
printf("%d %d %d\n", p, c, d);
} else {
auto p = gen.uniform_pair(0, n);
int x = gen.uniform(0LL, MOD - 1);
printf("%d %d %d\n", p.first, p.second, x);
}
}
return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include "random.h"
#include <iostream>
#include "../params.h"

using namespace std;

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

int n = N_MAX;
int q = Q_MAX;
printf("%d %d\n", n, q);
for (int i = 0; i < q; i++) {
int t = gen.uniform(0, 100);
t = (t == 0 ? 0 : 1);
printf("%d ", t);
if (t == 0) {
int p = gen.uniform(0, n - 1);
int c = gen.uniform(1LL, MOD - 1);
int d = gen.uniform(0LL, MOD - 1);
printf("%d %d %d\n", p, c, d);
} else {
auto p = gen.uniform_pair(0, n);
int x = gen.uniform(0LL, MOD - 1);
printf("%d %d %d\n", p.first, p.second, x);
}
}
return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include "random.h"
#include <iostream>
#include "../params.h"

using namespace std;

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

int n = N_MAX;
int q = Q_MAX;
printf("%d %d\n", n, q);
for (int i = 0; i < q; i++) {
int t = gen.uniform(0, 1);
printf("%d ", t);
if (t == 0) {
int p = gen.uniform(0, n - 1);
int c = gen.uniform(1LL, MOD - 1);
int d = gen.uniform(0LL, MOD - 1);
printf("%d %d %d\n", p, c, d);
} else {
auto p = gen.uniform_pair(0, n);
int x = gen.uniform(0LL, MOD - 1);
printf("%d %d %d\n", p.first, p.second, x);
}
}
return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#include "random.h"
#include <iostream>
#include "../params.h"

using namespace std;

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

int n = N_MAX;
int q = Q_MAX;
printf("%d %d\n", n, q);

auto idx = [&]() -> int {
int t = gen.uniform<int>(0, 2);
if (t == 0) return gen.uniform<int>(0, n - 1);
if (t == 1) return gen.uniform<int>(0, 1000);
if (t == 2) return gen.uniform<int>(n - 1000, n - 1);
return 0;
};

auto idx2 = [&]() -> pair<int, int> {
int a = idx(), b = idx();
if (a > b) swap(a, b);
++b;
return {a, b};
};

for (int i = 0; i < q; i++) {
int t = gen.uniform(0, 1);
printf("%d ", t);
if (t == 0) {
int p = idx();
int c = gen.uniform(1LL, MOD - 1);
int d = gen.uniform(0LL, MOD - 1);
printf("%d %d %d\n", p, c, d);
} else {
auto [a, b] = idx2();
int x = gen.uniform(0LL, MOD - 1);
printf("%d %d %d\n", a, b, x);
}
}
return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include "random.h"
#include <iostream>
#include "../params.h"

using namespace std;

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

int n = N_MAX;
int q = Q_MAX;
printf("%d %d\n", n, q);
for (int i = 0; i < q; i++) {
int t = (i < q / 2 ? 0 : 1);
if (gen.uniform<int>(0, 100) == 0) t = 1 - t;
printf("%d ", t);
if (t == 0) {
int p = gen.uniform(0, n - 1);
int c = gen.uniform(1LL, MOD - 1);
int d = gen.uniform(0LL, MOD - 1);
printf("%d %d %d\n", p, c, d);
} else {
auto p = gen.uniform_pair(0, n);
int x = gen.uniform(0LL, MOD - 1);
printf("%d %d %d\n", p.first, p.second, x);
}
}
return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include "random.h"
#include <iostream>
#include "../params.h"

using namespace std;

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

int n = gen.uniform(1LL, N_MAX);
int q = gen.uniform(1LL, Q_MAX);
printf("%d %d\n", n, q);
for (int i = 0; i < q; i++) {
int t = gen.uniform(0, 1);
printf("%d ", t);
if (t == 0) {
int p = gen.uniform(0, n - 1);
int c = gen.uniform(1LL, MOD - 1);
int d = gen.uniform(0LL, MOD - 1);
printf("%d %d %d\n", p, c, d);
} else {
auto p = gen.uniform_pair(0, n);
int x = gen.uniform(0LL, MOD - 1);
printf("%d %d %d\n", p.first, p.second, x);
}
}
return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include "random.h"
#include <iostream>
#include "../params.h"

using namespace std;

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

int n = seed + 1;
int q = Q_MAX;
printf("%d %d\n", n, q);
for (int i = 0; i < q; i++) {
int t = gen.uniform(0, 1);
printf("%d ", t);
if (t == 0) {
int p = gen.uniform(0, n - 1);
int c = gen.uniform(1LL, MOD - 1);
int d = gen.uniform(0LL, MOD - 1);
printf("%d %d %d\n", p, c, d);
} else {
auto p = gen.uniform_pair(0, n);
int x = gen.uniform(0LL, MOD - 1);
printf("%d %d %d\n", p.first, p.second, x);
}
}
return 0;
}
52 changes: 52 additions & 0 deletions data_structure/point_set_range_composite_large_array/hash.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"dense_00.in": "aac0bc3bbb873579fc2894cbe32a5f45359d1e967bc89fa59456f75a97e33c2c",
"dense_00.out": "a3e7bd103cc9601ab276f7227165c5d607c6f2ce27dde0aa36fe4eba5ce36a88",
"dense_01.in": "18b0eb5884155b47b102aace2a4be82dbe3aebc89dde018c0f29c24febd82537",
"dense_01.out": "180eea4034b9c90a5125366d21a7e03b2edec05a7372d82111215e1c63be84a8",
"dense_02.in": "05434bcaf19613ab1103544cc6c11e6bc84df8cb36a6fe46cdfa277318b80d03",
"dense_02.out": "9f7ab8d838c5ebffe0c1693847e520d8e68d964ba5520a86e16998f0376edf69",
"example_00.in": "3512449209bf077afb69df94260a1135d3d71458c6a742170c4bbfc41fbfcb1e",
"example_00.out": "432f365abd0d9d7b9b67b6b0be5fa0bd2940ee4f9df0d2cbc318658f7aeea7af",
"many_query_0_00.in": "ab4b634bbee0f03054909e740d7a39aba0de6573ba11f7cd58487024f4088f96",
"many_query_0_00.out": "538e614084fd09ea95df9ffe0b89bf0d7cbe911fbf672d3c257a2eb30c63f0d7",
"many_query_0_01.in": "d597cb8ca0be4a15dffe8f3aa197f54447633995c973ff24ed09fd38e16d1dfc",
"many_query_0_01.out": "386d40ce39f92413a092e60a4243dd325d6b7cfe820497ef2d5f5967c8371f84",
"many_query_1_00.in": "d4e3cc6f8691bf612afb4d7613d6302c095706e510d2b6c7546d3f0295f6b456",
"many_query_1_00.out": "4097c275626452fd3c77f983fa1ba0a2197c321aeda5ba28030261efd1a4a025",
"many_query_1_01.in": "fc7e3328fb021e37a05653a78a25834c09c013cd04e2757976d9a145bcd68dae",
"many_query_1_01.out": "4700856c439519117706340cfb1b0e4c2c8712036d6a8df4f9cc2de1de164c5b",
"max_random_00.in": "829619b6ab6cf8c2ce59ab19fa8bae31305a0719788c0ee49b5bb4b5a24faf92",
"max_random_00.out": "40e12623bc9b2f3d3717c0cf70cac2e1462732d6411eb71f4bd335b72efb273d",
"max_random_01.in": "d50bb497ddcafa950f172d10b5a3f5000ae741f59cf851281c5dd598e69e000c",
"max_random_01.out": "e8b5a3a94efa4a28cbc3d663f206a7eec410d29ad305f0af658e7d4fcefd8146",
"max_random_02.in": "2801f71e2fa577682e301523b42de75040ef7b90d818a635ea4108ac7f98b026",
"max_random_02.out": "4ead287c82a575cbbadf881449b495959af81dda125f90e99c17f590d46a92a0",
"near_0_and_N_00.in": "2d36aefba480ec9eeeb0c80faf54b55e89db99627937aae9c83ce3dc73fb999c",
"near_0_and_N_00.out": "ab402cc84a296d3d158659a42d50b2b5c0c8008bd4e04778949e9e8d90eda595",
"near_0_and_N_01.in": "83ba7d1d5f7b3949bafafa429c51e47b7bc030bb8ad2263de1bf65a1c9d88c3a",
"near_0_and_N_01.out": "e9bc968856e780f536963fb4cf26f7dcd5bb05e70ef80e8847f540c116610935",
"query_0_then_1_00.in": "bfb2ab64c42a518c99e1a51a9dd6b4dbbaf5951b2171eaf176019b38fd26a393",
"query_0_then_1_00.out": "6c0b9bbf74d47dcab6cf98aa64b9fbc7054d8d38e55f305de447ba8df88a6def",
"query_0_then_1_01.in": "57c32fb9eba0bdb0e82d0ed706f75cb98f878b2562db41e047eca17923217e0b",
"query_0_then_1_01.out": "386a289329af425faee18e74c8335eb2a7ffcb41d41d5bf6f02b6a0ff3e61e6a",
"random_00.in": "3bf06d96dcd52541fee71fee92ec2f90f260dc3336f047c33c8ffd7b650061ee",
"random_00.out": "b44acfd213f368ab5076c8331bd3600ad0b4a51cfd2a1dc64120d27cf3f3ae67",
"random_01.in": "9a1d7f7bd483b61408bd166049dba2b9b3feb14db82be3d8650712697538c6d4",
"random_01.out": "613b95068e00f605fb824b2ee6146c7d41b20655f6526de39c6d58f3a9f01283",
"random_02.in": "d24aba145518593da122ec294f6d275f57381da35016f4676920eeb95c92e13d",
"random_02.out": "e7d04219b3950ab6e9762d46fe1f4d2364a6cb35d54a2f80d3a43ae0e7f665f0",
"random_03.in": "2594af7af2cc85800b611c7a3a457698828bf24b171d14c20d75a88b21ef63e5",
"random_03.out": "5c9a138d0766ee386499e0b50d62d0d194a36e38c40070d29efcfb59c126b162",
"random_04.in": "70c753a91c0bec8a07f1fe75be82775310ba36369f730cf954734b4fe3f61723",
"random_04.out": "e38e6f3c743f669247e5caa8e75467ce86646efb87074b16febface9927c9caf",
"small_N_00.in": "894d52db171eaf2d15f05827093edad677b8c8999b5838d7723d18d174f339a2",
"small_N_00.out": "7c0343509b33e615bd862f81d4b68858dc7ab78865745194fd35b628acf0da7e",
"small_N_01.in": "c6922ce16091800c0c6051daa466217095059fd9a193f40a38a7e8e19eeeba32",
"small_N_01.out": "fa78f1d87fc011e7dbaf1e573dbd7dfff735bed3b8e62be35b0113cc0e330964",
"small_N_02.in": "5f8237d1e8301fb607099a808729bb8bf70e9df1a955edfb87d319ddae4fb334",
"small_N_02.out": "ae1e29c91eddabafa19fc22c13606173119be2014b600882a21feb4ea2a84913",
"small_N_03.in": "1d495649f1cc7bcde7623f4f0c77d8eeaefa84f9b88fdd52dd46729dd04b3c71",
"small_N_03.out": "229a6440c0616a8ff07513f52f23d6ccd8b3ad420e59c3ac4fdc3980b264479b",
"small_N_04.in": "98c4f2597aa77cc486a19ea477997f33303d9ad82ff205534c7589dd60ed7507",
"small_N_04.out": "a4d32241a272c121eea168ee8a433a1662c7ae3a41e994b807eae73a6193e3be"
}
Loading

0 comments on commit 1974433

Please sign in to comment.