Skip to content

Commit

Permalink
a
Browse files Browse the repository at this point in the history
  • Loading branch information
maspypy committed Nov 5, 2024
1 parent 6d26f5f commit 341d312
Show file tree
Hide file tree
Showing 11 changed files with 751 additions and 0 deletions.
62 changes: 62 additions & 0 deletions data_structure/ordered_set/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");
}
}
19 changes: 19 additions & 0 deletions data_structure/ordered_set/gen/example_00.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
3 17
10 20 30
2 1
2 2
2 3
3 19
3 20
3 21
4 19
4 20
4 21
0 0
2 1
0 0
2 1
1 0
2 1
1 0
2 1
6 changes: 6 additions & 0 deletions data_structure/ordered_set/gen/example_01.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
0 4

2 1
3 1
4 1
5 1
113 changes: 113 additions & 0 deletions data_structure/ordered_set/gen/max_random.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
#include <iostream>
#include <string>

#include "../params.h"
#include "random.h"

using namespace std;

/*
要素の種類 K
0:1000, dense
1:1000, random
2:10^6, dense
3:10^6, random
クエリ
0:[1/6,1/6,1/6,1/6,1/6,1/6]
1:[1/5,eps,1/5,1/5,1/5,1/5]
2:[1,eps,eps,eps,eps,eps]
3:[eps,1,eps,eps,eps,eps]
4:[eps,eps,1,eps,eps,eps]
5:[eps,eps,eps,1,eps,eps]
6:[eps,eps,eps,eps,1,eps]
7:[eps,eps,eps,eps,eps,1]
seed/8, seed%8
*/

vector<int> gen_val(Random& gen, int seed) {
seed /= 8;
int K = ((seed == 0 || seed == 1) ? 1000 : 1000000);
if (seed == 0 || seed == 2) {
int s = gen.uniform<int>(0, A_MAX - K + 1);
vector<int> A(K);
for (int i = 0; i < K; ++i) A[i] = i + s;
return A;
}
return gen.choice<int>(K, A_MIN, A_MAX);
}

vector<int> gen_prob(int seed) {
seed %= 8;
vector<int> S = {0, 1, 2, 3, 4, 5};
for (int t = 0; t < 6; ++t) {
bool add = 0;
if (seed == 0) add = 1;
if (seed == 1 && t != 1) add = 1;
if (seed == 2 && t == 0) add = 1;
if (seed == 3 && t == 1) add = 1;
if (seed == 4 && t == 1) add = 1;
if (seed == 5 && t == 1) add = 1;
if (seed == 6 && t == 1) add = 1;
if (seed == 7 && t == 1) add = 1;
if (add) {
for (int i = 0; i < 100; ++i) S.emplace_back(t);
}
}
return S;
}

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

vector<int> kind = gen_val(gen, seed);
vector<int> S = gen_prob(seed);

vector<int> A;
for (auto& x: kind) {
if (gen.uniform<int>(0, 1)) { A.emplace_back(x); }
}
if (int(A.size()) > N_MAX) A.resize(N_MAX);

int N = A.size();
int Q = Q_MAX;

printf("%d %d\n", N, Q);
for (int i = 0; i < N; ++i) {
if (i) printf(" ");
printf("%d", A[i]);
}
printf("\n");

int sz = S.size();
int K = kind.size();

set<int> ANS(A.begin(), A.end());

for (int i = 0; i < Q; i++) {
int t = S[gen.uniform<int>(0, sz - 1)];
int x;
if (t == 0) {
x = kind[gen.uniform<int>(0, K - 1)];
ANS.insert(x);
}
if (t == 1) {
x = kind[gen.uniform<int>(0, K - 1)];
ANS.erase(x);
}
if (t == 2) {
int n = ANS.size();
x = gen.uniform<int>(1, n + 1);
if (gen.uniform<int>(0, 100) == 0) { x = gen.uniform<int>(1, A_MAX); }
}
if (t == 3 || t == 4 || t == 5) {
x = gen.uniform<int>(A_MIN, A_MAX);
if (gen.uniform<int>(0, 1)) { x = kind[gen.uniform<int>(0, K - 1)]; }
}

printf("%d %d\n", t, x);
}
return 0;
}
36 changes: 36 additions & 0 deletions data_structure/ordered_set/gen/small.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include <iostream>
#include <string>

#include "../params.h"
#include "random.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 Q = Q_MAX;

vector<int> A;
for (int x = 0; x < K; ++x) {
if (gen.uniform<int>(0, 1)) A.emplace_back(x);
}
int N = A.size();

printf("%d %d\n", N, Q);
for (int i = 0; i < N; ++i) {
if (i) printf(" ");
printf("%d", A[i]);
}
printf("\n");

for (int i = 0; i < Q; i++) {
int t = gen.uniform(0, 5);
int x = gen.uniform(0, K - 1);
if (t == 2) ++x;
printf("%d %d\n", t, x);
}
return 0;
}
76 changes: 76 additions & 0 deletions data_structure/ordered_set/hash.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
"example_00.in": "226c519151f1cdbd49fc9904c6d1e143a34b29b69b38cb129cf7bcd8ff2b171f",
"example_00.out": "7447f71ee379e98b22a881d3630c5efac561290939b0c7204a2002c339d6ff8d",
"example_01.in": "8e4ab9cc1f3b21c6fe5e854a9e8149d833ed7dd7893a8ddfaaa28788988abf16",
"example_01.out": "c072f97b1f6faeb9a98a6e63d5962d56aff52be48a1eef570c9722906d51c621",
"max_random_00.in": "7a1ac2dbb0b7c6df32ae690777b1623223254b80871be6e80e86af6bd326d44f",
"max_random_00.out": "56674f50d7f4e725aac2108f7d94097639273ace40371b5619c165914bcde89e",
"max_random_01.in": "2e303efdaac48ca9e6269f0d72ce29f95f2f4d88e7d5aea088abfa2c8e2a11c6",
"max_random_01.out": "73a09ca72730187407976ee27946d9daff35840ab6b8c9671e91177d2b85e454",
"max_random_02.in": "0a71a46735f430adbdb80bd8653ed3de2e30885e70ee88833aecc25d986ef3dd",
"max_random_02.out": "202fbf58a0965fe5753e55cef0d060f6187c9e084e8000643ee59349efb221b6",
"max_random_03.in": "516397deefa093842049fcc8fd0ab4ef068219dddf3b7d41b285c85ba9e8c406",
"max_random_03.out": "87ccadb2d01b25a87c87c9d95968b1739a1876b78ebf46cdf8a702c24d5ec2f4",
"max_random_04.in": "7b4ed7399c8eb16b73239b14ebb9bc28b3b49810372c404f2bebe9c74d242b7e",
"max_random_04.out": "bd3ff4ecc67b4d0f54fd9d5c38c80b75d2f29b162c83a2511212459ac1b1e800",
"max_random_05.in": "6915915ddb86e93b9873d8d8bc50a213eb251fa6b9e2622f852963ba1eab9b05",
"max_random_05.out": "9e4ccb3cbc4dd40211bb1ac44dd567ea6c38369de4c66a4e4a7240e4630beacf",
"max_random_06.in": "0394aba70b89a60148c6fcad42a33f6436000fae3e07a2ab0d3cfa8c6264a3e1",
"max_random_06.out": "bf9bf0c987ecc5481ab4ff66e5ce46e5c12727f4be017805acd047fd090058a4",
"max_random_07.in": "f0080b1947af51d0ed249759b0e47fbd92cd64c8b3f1e336150bf5016a292345",
"max_random_07.out": "4c8ceb7fbd0b73c1c263eabc3d7142095ae7e9fd03e4e56af9d543d8a7b4d825",
"max_random_08.in": "e70fd62194f2a6fffabbf0d258767a88a2f436a799a6194345d6f0dc6ae46bfc",
"max_random_08.out": "f770f12ccfc1f9e09791ab6d41d07faa0a2141c591049e32b1dd1873fd089f1a",
"max_random_09.in": "161d51d239c31f1b70b9d526394d2a9eff0115147751a1741354bdb768b1817c",
"max_random_09.out": "973f568cac6830e4136010b50fbd6f0a2f65cfe25be70660e7975018a2f2a543",
"max_random_10.in": "246854b84ee227121dbba4112890c0c5c09e2b4f5ee6c0ba8ed1e2a1c90fe0c7",
"max_random_10.out": "18779899a7a81ed6b6ea66e9691b4f069ded760d91aa5c4895f2e30c2585cff9",
"max_random_11.in": "d891016bb5baa31f4c88fdc5f8f2338f025b8990644d25b0ca8752a262ecc905",
"max_random_11.out": "23a12beae04ec057be350f3590b0b9f44ca375a808f662a9208370ad1fc24280",
"max_random_12.in": "05b4134774a944035c3d0fc3c8bb0af855bf5d2478f2726c7e9f4c1bdda76986",
"max_random_12.out": "ad0860ff41552d18af384c6c273e22e80cfde9292b93151d0eb9cca70ab9f490",
"max_random_13.in": "aa5d541659ef0965d8c8614365c556e8f61c02a5ef4be3a87340e454d6517aab",
"max_random_13.out": "96041da219dbe0e91d83a8fb63fdcef94891e55c463437d659f08751a61ca271",
"max_random_14.in": "bb70f7bb17dfa6083f579bcc8ed46fd294da02432eb9a1dd913bf7a63efde31f",
"max_random_14.out": "d8e557420a24f56954f98e816a1e4b61433d22bd07ddb250e5b55d524bad068d",
"max_random_15.in": "c83f69f83d2d55edd728c71c428ccf88ec2f2ab2e2779680e784ef00c4023378",
"max_random_15.out": "cdf41142ecbebbebd3a20769e8b495e8f0c596c7242130162074091a6e4327dc",
"max_random_16.in": "438db97646a3f6055d6bfc7b7ffca2c590b07aac2c0ad01bdc28dd1939470aa0",
"max_random_16.out": "31fe327f27e16cea0753008891619f3c08612c40e109e3a0ddc96de567553535",
"max_random_17.in": "d3888c77ca8863b6984687f518624fcd6276405b18a52b942e505509531b82b1",
"max_random_17.out": "8c3d1fda530e3162c900ba9145d1753bfc819477ae617f054110963e40584773",
"max_random_18.in": "8c270fdba93ec531c764a0ccaabc56baa8648fa1c3a2776d87fa5daabaf16a9c",
"max_random_18.out": "dbb88b8e9593a2bb4b8a888bf0377afcc433d5169c740073397fe3b51f76402d",
"max_random_19.in": "2869883ac314cd9a5b8a6cfdec834ea295980014242e97b0bef7019142229f88",
"max_random_19.out": "6fba96c92e2151cc95a542eedd13a59e65f20e7968b279dd1666d268f7ad7969",
"max_random_20.in": "f027283041446fc69f83c2bb9f99b17733a70d1c1ed86bb2f8c15f26a4b09d92",
"max_random_20.out": "287770e8cae033db815fdb15862e9233a7817e9b12822d4cfa46b9fcf1078dd8",
"max_random_21.in": "21ce35481ed7d44051bad5f504193085250af121bd1b4e3e5b09e04d3ade9d5a",
"max_random_21.out": "75c96c6755432d0421210448b35100e400e6108b4d9f54f822574c32477170c3",
"max_random_22.in": "86b481b2cf70a815c0c714fd3981c2922760c7a55c78880433fa742f03c0e3d0",
"max_random_22.out": "c6c72a7b603bcd22e9c5a2f8662a46d794cdaab48c090c1df1c884d75f6b004a",
"max_random_23.in": "63ff141a61c9428acd855486ec155f4a798be8dd38febfcaa72890ddf54ec0ac",
"max_random_23.out": "e4e45bc683f061814fbe2d06ae857ea4e2b9cfad5f4033b458190563b6554d73",
"max_random_24.in": "04aac5c4fda27cd5d7aadbeca7a4cd15d814467398f20244343f52f7270a7d47",
"max_random_24.out": "036c79ba4e691d3758e3a2a7cb3caebee08c20eea16ec0d5663ccc56ac0d52c7",
"max_random_25.in": "128c8493416e5c7a1334cd92fd5d1861009afe065b918f1ffb8b174afeafaf1b",
"max_random_25.out": "d1295b4b7f5d7af683197356d835b9245ec8b0098595b924c7105bc8dae9a73f",
"max_random_26.in": "46e5ddda3af75e67c6a0c15c75fa102ac9469108a21c510cf57ae7b4d4a9b23c",
"max_random_26.out": "4e7d4109df372366f9d4febdd3896abd5986b95397a18fa4a212c23db98c5e2b",
"max_random_27.in": "3ffff875b827372a9c11b1844eb08bc5ec696ba7c3d22f9ebae4d604a130035c",
"max_random_27.out": "3b3a40970957ea67fdd218e1bf2e56ec65789b40c60ead430e302c586c1f446b",
"max_random_28.in": "c77e0ede0c24497316897c1d130ba6b1ece762294f19f8a0106de50f4b6c64e1",
"max_random_28.out": "3d43faca5a09e76a40971fd0ba39274869efbcae184bb6926d9c0e3abebb39d6",
"max_random_29.in": "6b3ac9bb8461e605e1370eb61591b6205c375366be5b556c361121f09cc80e8a",
"max_random_29.out": "357472d6a820575427daa00a1cf67ddfa9008b88f7cf3502ea0cf70b75674a4b",
"max_random_30.in": "3647aab9dac88dd2bdabd32caf7c52cada2a81e0ad9ab85c0e5771816f9ab121",
"max_random_30.out": "f23518e43baa11880024f153b1101a02d8fc8eb5be59483e479bb750b9b76d38",
"max_random_31.in": "311a10680ccb45a20e469f2ac99f7d274e52389101632a9bc6543c46a738d5ce",
"max_random_31.out": "f91b5613770c8dab78828a68983b8dc64f063192a68283389f4429eef3330a15",
"small_00.in": "ddc8dd62d510c2622d8aa2f4852b7e4e3e851edcd25a97149c8e539ffcc49860",
"small_00.out": "1530577c46406620cb03fd10fd9efe4fd77b7dca73293dade58cf8e86c6d3f08",
"small_01.in": "27b74d22f8235a213c93555d3fd2a22648ff03f22c0ee926589a41f8a24d0192",
"small_01.out": "65578eb9a7fc4903e03aa4a7ac1ecf3a781e08c9880761a538177c00a042ff2f",
"small_02.in": "94334f2e39d09a6f16070dcf5be669f983df859238f171e672808823b85031a7",
"small_02.out": "5aed019a0274322279ef71cd06bc6fff1ffdaf331a18343c112d019717951f17"
}
28 changes: 28 additions & 0 deletions data_structure/ordered_set/info.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
title = 'Ordered Set'
timelimit = 10.0
forum = "https://github.com/yosupo06/library-checker-problems/issues/1243"


[[tests]]
name = "example.in"
number = 2

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

[[tests]]
name = "max_random.cpp"
number = 32

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

[params]
N_MIN = 0
N_MAX = 500_000
Q_MIN = 1
Q_MAX = 500_000
A_MIN = 0
A_MAX = 1_000_000_000
Loading

0 comments on commit 341d312

Please sign in to comment.