diff --git a/subset-sum/Makefile b/subset-sum/Makefile new file mode 100644 index 0000000..4227f1a --- /dev/null +++ b/subset-sum/Makefile @@ -0,0 +1,97 @@ +# Normal directories +SRC_DIR := src +BIN_DIR := bin +DBG_DIR := bin/debug + +# Grader directories +GRADER := $(wildcard $(SRC_DIR)/grader.cpp) +GRADER_DIR := $(SRC_DIR)/grader +HANDLER_DIR := $(SRC_DIR)/handler + +GRADER_SRC := $(wildcard $(GRADER_DIR)/*.cpp) +GRADER_BIN := $(patsubst $(GRADER_DIR)/%.cpp, $(BIN_DIR)/%, $(GRADER_SRC)) +GRADER_DBG := $(patsubst $(GRADER_DIR)/%.cpp, $(DBG_DIR)/%, $(GRADER_SRC)) + +# Change CPP source directories if grader is defined +ifdef GRADER + SRC := $(wildcard $(HANDLER_DIR)/*.cpp) + BIN := $(patsubst $(HANDLER_DIR)/%.cpp, $(BIN_DIR)/%, $(SRC)) + DBG := $(patsubst $(HANDLER_DIR)/%.cpp, $(DBG_DIR)/%, $(SRC)) +else + SRC := $(wildcard $(SRC_DIR)/*.cpp) + BIN := $(patsubst $(SRC_DIR)/%.cpp, $(BIN_DIR)/%, $(SRC)) + DBG := $(patsubst $(SRC_DIR)/%.cpp, $(DBG_DIR)/%, $(SRC)) +endif + +SRC_C := $(wildcard $(SRC_DIR)/*.c) +BIN_C := $(patsubst $(SRC_DIR)/%.c, $(BIN_DIR)/%, $(SRC_C)) +DBG_C := $(patsubst $(SRC_DIR)/%.c, $(DBG_DIR)/%, $(SRC_C)) + +SRC_JAVA := $(wildcard $(SRC_DIR)/*.java) +BIN_JAVA := $(patsubst $(SRC_DIR)/%.java, $(BIN_DIR)/%.class, $(SRC_JAVA)) +DBG_JAVA := $(patsubst $(SRC_DIR)/%.java, $(DBG_DIR)/%.class, $(SRC_JAVA)) + +CHECKER := $(wildcard $(SRC_DIR)/checker.cpp) + +C := gcc +CPP := g++ +CXX_FLAGS := -Wall -O2 +DEBUG_FLAGS := -Wall -g +BOCA_FLAGS := -static -DBOCA_SUPPORT + +JV = javac +JV_DEBUG = -g +JV_DIR = -d bin +JV_DBG_DIR = -d bin/debug + +.PHONY: all debug release checker clean + +all: debug release checker + +debug: $(DBG) $(DBG_C) $(DBG_JAVA) $(GRADER_DBG) + +release: $(BIN) $(BIN_C) $(BIN_JAVA) $(GRADER_BIN) + +ifdef CHECKER +checker: $(DBG_DIR)/checker-boca $(BIN_DIR)/checker-boca +endif + +$(BIN): $(BIN_DIR)/% : $(SRC_DIR)/%.cpp | $(BIN_DIR) + $(CPP) $(CXX_FLAGS) $^ -o $@ + +$(DBG): $(DBG_DIR)/% : $(SRC_DIR)/%.cpp | $(DBG_DIR) + $(CPP) $(DEBUG_FLAGS) $^ -o $@ + +$(BIN_C): $(BIN_DIR)/% : $(SRC_DIR)/%.c | $(BIN_DIR) + $(C) $(CXX_FLAGS) $^ -o $@ + +$(DBG_C): $(DBG_DIR)/% : $(SRC_DIR)/%.c | $(DBG_DIR) + $(C) $(DEBUG_FLAGS) $^ -o $@ + +$(BIN_JAVA): $(BIN_DIR)/%.class : $(SRC_DIR)/%.java | $(BIN_DIR) + $(JV) $(JV_DIR) $^ + +$(DBG_JAVA): $(DBG_DIR)/%.class : $(SRC_DIR)/%.java | $(DBG_DIR) + $(JV) $(JV_DEBUG) $(JV_DBG_DIR) $^ + +$(GRADER_BIN): $(BIN_DIR)/% : $(GRADER_DIR)/%.cpp $(GRADER) $(GRADER_DIR)/*.h + $(CPP) $(CXX_FLAGS) $^ -o $@ + +$(GRADER_DBG): $(DBG_DIR)/% : $(GRADER_DIR)/%.cpp $(GRADER) $(GRADER_DIR)/*.h + $(CPP) $(DEBUG_FLAGS) $^ -o $@ + +$(BIN_DIR): + mkdir -p $@ + +$(DBG_DIR): + mkdir -p $@ + +$(BIN_DIR)/checker-boca: $(SRC_DIR)/checker.cpp + $(CPP) $(CXX_FLAGS) $(BOCA_FLAGS) $^ -o $@ + +$(DBG_DIR)/checker-boca: $(SRC_DIR)/checker.cpp + $(CPP) $(DEBUG_FLAGS) $(BOCA_FLAGS) $^ -o $@ + +clean: + @echo Cleaning problem files + rm -rf bin diff --git a/subset-sum/input/1 b/subset-sum/input/1 new file mode 100644 index 0000000..4934da1 --- /dev/null +++ b/subset-sum/input/1 @@ -0,0 +1,2 @@ +5 10 +1 2 3 4 5 diff --git a/subset-sum/input/10 b/subset-sum/input/10 new file mode 100644 index 0000000..f67234f --- /dev/null +++ b/subset-sum/input/10 @@ -0,0 +1,2 @@ +298 9845 +54 73 6 65 24 52 31 29 53 31 92 27 13 81 38 63 58 58 66 1 95 74 7 51 68 78 9 4 7 8 92 99 50 6 99 22 98 15 81 67 82 37 19 11 26 44 88 26 44 2 88 44 55 21 89 46 31 16 45 54 34 22 50 83 42 26 41 86 1 61 32 61 68 3 76 58 72 66 59 24 36 41 54 18 25 95 49 25 56 50 78 11 83 84 90 59 45 45 68 22 1 55 72 85 75 12 65 21 20 96 16 57 49 48 7 35 91 84 82 68 98 74 41 39 93 17 3 34 68 71 65 21 83 3 66 49 32 76 88 38 64 36 73 70 22 74 32 60 55 48 80 61 89 54 20 34 33 45 90 40 12 17 35 11 37 83 44 68 78 56 45 27 98 8 28 58 66 91 71 76 5 64 79 70 9 41 29 25 29 61 41 66 70 94 14 13 1 87 48 14 65 22 22 48 34 11 97 93 38 72 6 3 11 47 36 42 43 31 20 23 43 39 14 3 1 22 35 77 75 21 77 4 61 72 93 47 62 37 98 71 36 4 20 1 43 33 97 77 10 45 87 24 46 89 24 43 58 61 89 81 89 19 88 77 99 25 13 34 20 79 65 97 27 51 6 63 100 71 68 52 66 50 52 100 19 11 56 26 15 64 80 17 57 64 79 1 26 90 diff --git a/subset-sum/input/100 b/subset-sum/input/100 new file mode 100644 index 0000000..4a925e2 --- /dev/null +++ b/subset-sum/input/100 @@ -0,0 +1,2 @@ +448 9865 +92 12 60 32 63 47 32 2 73 94 46 76 60 38 71 44 53 8 69 22 39 4 93 40 78 27 45 37 37 61 51 19 32 19 92 85 31 66 31 73 5 70 56 86 54 56 57 31 34 13 56 62 64 1 26 19 59 100 41 63 60 40 80 25 78 61 22 36 56 76 75 43 7 81 35 100 46 69 52 37 84 89 60 18 69 25 4 81 42 73 47 72 52 95 13 11 65 27 57 47 55 46 16 52 54 68 63 12 87 22 88 78 67 88 41 80 40 80 88 98 1 37 78 60 93 21 36 44 29 12 25 17 98 59 34 65 35 97 44 44 53 69 54 39 80 43 92 90 41 2 89 14 46 49 10 12 52 34 65 36 46 84 43 99 91 55 14 13 56 62 27 64 36 40 69 90 54 52 76 95 38 20 23 97 100 95 15 75 16 7 10 31 96 60 93 8 57 2 42 60 47 27 71 74 48 98 69 29 45 57 50 100 73 29 43 80 60 77 54 5 81 63 81 10 24 50 45 24 17 100 100 18 27 82 4 4 38 92 94 48 45 6 80 7 13 97 27 22 44 6 98 71 35 74 61 11 69 60 78 83 13 42 48 40 88 53 39 85 85 16 57 97 75 85 96 78 66 28 69 52 86 2 71 51 55 36 70 20 23 57 37 69 19 3 96 9 71 7 6 33 85 52 65 50 86 16 81 68 89 87 33 100 17 90 77 11 84 53 61 37 11 82 8 99 46 88 86 45 54 52 55 17 26 99 50 86 10 74 43 86 60 73 57 28 42 53 53 54 82 22 48 72 63 37 29 88 71 91 21 60 48 89 6 72 61 54 16 17 55 95 95 58 17 6 99 59 31 39 22 5 21 34 41 27 13 12 28 96 100 58 50 63 90 92 69 14 17 7 48 23 2 36 32 26 84 35 90 33 74 56 48 59 85 21 40 29 53 6 71 16 63 96 43 85 69 11 50 31 38 76 1 89 78 84 94 85 3 6 82 83 43 89 27 71 55 20 95 87 diff --git a/subset-sum/input/101 b/subset-sum/input/101 new file mode 100644 index 0000000..a3dc00a --- /dev/null +++ b/subset-sum/input/101 @@ -0,0 +1,2 @@ +701 5811 +64 83 27 13 50 78 54 69 28 32 77 48 39 62 63 39 1 8 48 1 83 71 60 13 16 96 14 46 84 63 19 36 18 21 13 54 54 6 76 15 79 51 12 48 18 82 73 49 97 49 18 40 66 71 7 16 14 99 99 87 98 87 38 60 17 6 67 78 43 38 27 48 52 99 25 38 35 98 57 75 27 14 45 13 66 11 51 30 53 66 88 87 41 62 86 36 57 30 55 21 22 41 92 4 17 13 39 32 41 72 38 67 22 46 6 94 47 65 28 8 65 60 63 62 66 36 7 38 59 50 80 19 62 11 42 7 68 26 31 73 8 30 100 87 15 50 59 30 82 23 6 25 95 49 31 1 20 82 38 56 14 89 79 65 35 13 89 17 77 83 76 70 68 16 63 87 80 28 54 9 93 88 6 53 98 73 76 91 43 71 6 17 70 27 30 6 85 17 97 39 94 67 22 13 86 76 88 53 23 42 11 3 50 92 11 64 66 69 39 24 47 47 59 29 59 61 15 38 97 73 55 40 89 59 33 4 93 100 25 35 63 27 12 5 60 76 53 55 99 12 71 89 56 30 46 68 18 38 29 17 62 68 1 44 85 13 81 2 97 31 100 32 52 84 7 82 24 35 60 65 30 86 12 17 19 45 13 35 22 86 37 44 52 75 25 56 26 71 15 68 78 33 49 76 91 99 51 62 21 25 41 50 42 68 58 28 43 67 42 13 87 77 13 29 35 72 7 94 100 80 50 8 25 30 90 80 83 98 8 94 19 14 11 18 23 68 86 74 80 4 81 90 97 99 27 82 48 69 85 64 52 68 58 44 85 43 25 59 4 28 95 16 62 86 18 66 53 44 18 31 47 100 60 30 85 1 78 67 33 17 81 26 41 96 87 27 70 91 25 45 30 34 6 94 6 54 34 84 1 99 73 84 71 72 49 94 30 98 11 38 36 53 78 26 99 3 58 38 53 42 11 18 30 6 75 75 100 65 16 43 65 38 52 40 36 39 7 17 40 38 68 45 97 59 8 34 51 73 94 63 100 77 73 10 46 22 30 16 63 87 63 100 88 43 60 55 82 9 30 91 16 6 7 91 62 1 100 93 24 82 71 32 53 30 93 2 76 17 53 11 71 81 7 76 19 36 62 10 29 94 54 12 28 40 99 1 61 98 73 27 22 99 14 32 63 35 34 93 20 100 66 86 33 2 16 28 16 25 29 56 2 51 84 77 46 10 41 53 81 23 67 36 69 18 53 64 55 60 5 52 80 29 96 53 51 70 99 43 45 64 58 93 84 70 15 29 53 84 47 85 95 78 62 65 25 13 50 14 43 39 12 97 86 46 83 58 67 65 55 58 41 51 51 41 52 29 87 48 14 100 27 84 1 49 18 5 7 48 32 8 65 46 37 18 41 74 76 19 8 76 80 35 17 13 2 24 8 52 85 87 16 68 96 94 97 47 80 64 70 9 80 69 24 60 79 50 53 45 5 71 23 57 39 4 26 46 22 67 2 37 92 12 46 51 11 88 34 9 59 19 30 62 41 18 29 17 54 61 3 16 56 82 23 98 66 4 13 2 63 9 65 diff --git a/subset-sum/input/102 b/subset-sum/input/102 new file mode 100644 index 0000000..abf3529 --- /dev/null +++ b/subset-sum/input/102 @@ -0,0 +1,2 @@ +530 9220 +61 47 69 10 81 100 50 55 85 84 18 58 73 82 25 7 36 90 58 57 52 76 71 99 60 77 62 26 82 85 90 97 53 48 47 47 65 72 53 49 50 58 61 10 100 25 41 73 26 6 67 10 78 70 22 65 86 55 85 94 75 11 90 71 97 63 51 65 100 85 25 56 2 50 56 10 86 5 44 80 7 23 11 37 83 25 49 9 16 61 67 3 19 45 56 63 47 3 15 37 19 11 75 92 25 72 46 100 8 91 66 24 71 66 35 57 39 10 71 57 41 29 76 61 38 57 94 8 57 84 31 33 64 86 81 97 8 82 63 79 36 45 32 6 86 13 18 70 87 16 72 7 14 54 5 13 100 71 7 70 98 98 65 19 26 67 82 100 62 2 15 79 48 29 28 17 85 90 48 9 49 79 93 18 93 49 9 25 65 41 55 62 67 98 67 50 30 21 86 27 71 71 43 92 91 26 68 85 91 81 5 72 31 99 32 83 56 32 32 52 50 93 11 34 2 3 28 91 49 56 49 28 20 21 33 63 30 29 44 78 25 76 6 77 64 33 83 20 50 21 67 11 82 62 18 4 1 13 76 20 100 76 20 99 39 61 71 11 71 80 26 85 81 61 46 100 93 36 74 15 55 15 36 95 77 84 28 3 8 96 56 95 58 62 62 66 34 17 45 100 72 37 72 21 77 63 77 67 49 8 3 27 32 19 9 41 76 56 61 76 89 57 50 47 64 20 27 99 21 87 77 3 100 55 69 2 8 18 3 24 44 22 80 85 72 31 45 68 18 4 78 30 34 3 8 49 100 76 59 89 6 3 1 18 76 7 9 20 50 83 93 78 86 92 20 52 39 77 13 1 91 74 82 25 90 58 5 59 40 22 19 20 59 43 16 87 26 75 64 88 12 25 58 65 47 8 59 43 49 60 43 58 63 66 33 85 65 43 38 79 3 68 30 73 19 53 14 73 36 85 91 36 37 8 10 86 60 58 74 9 67 65 77 9 67 86 43 78 51 100 30 44 17 40 36 39 50 68 68 5 65 16 13 42 1 4 41 95 32 68 44 71 32 14 23 53 9 92 1 49 81 79 85 71 35 45 1 22 96 64 73 17 74 45 38 26 52 50 4 10 67 72 45 63 24 17 31 82 55 15 14 97 46 95 3 66 68 76 58 34 74 61 17 63 37 98 87 62 38 4 diff --git a/subset-sum/input/103 b/subset-sum/input/103 new file mode 100644 index 0000000..1f04618 --- /dev/null +++ b/subset-sum/input/103 @@ -0,0 +1,2 @@ +490 2139 +85 37 49 56 11 89 63 17 73 71 10 66 86 41 24 11 24 91 10 91 75 12 92 75 68 73 74 44 36 64 75 92 39 91 68 26 86 10 66 65 29 5 13 1 1 7 5 69 99 36 49 90 19 64 39 31 79 45 93 95 33 58 47 19 12 54 91 5 68 17 28 46 81 100 96 88 84 87 93 1 78 78 11 46 19 53 57 65 20 67 8 44 41 80 95 67 88 63 93 42 45 25 77 20 100 96 5 9 34 84 24 73 76 73 13 28 50 12 62 36 13 38 33 17 89 20 22 76 76 97 34 80 81 42 70 100 2 1 74 68 71 63 55 79 45 50 18 30 96 100 10 4 48 97 82 24 100 73 24 51 42 84 83 55 93 76 86 64 20 63 87 11 71 95 89 18 57 48 74 74 21 17 89 85 52 75 46 68 62 47 93 78 100 21 95 59 92 60 65 86 76 3 54 76 83 79 82 71 57 51 49 19 41 51 40 24 42 49 5 78 7 19 62 31 78 38 78 57 10 29 99 58 84 68 89 90 18 42 6 8 43 19 88 9 97 86 58 12 44 37 19 8 44 80 6 2 50 37 32 100 19 95 49 46 8 78 71 13 40 29 45 67 13 37 54 77 52 23 84 65 96 93 9 80 43 58 73 53 54 82 22 32 76 86 22 28 94 62 97 37 66 78 16 31 3 76 95 65 2 37 32 96 21 36 30 25 66 17 35 2 17 95 18 9 3 39 74 51 92 23 37 91 54 12 2 1 59 76 27 27 20 32 72 7 60 43 30 3 29 30 45 64 55 70 98 48 95 9 74 52 33 77 29 38 18 71 75 35 99 97 15 23 60 85 83 52 11 92 26 19 58 3 54 75 88 66 30 68 33 36 76 13 85 96 60 82 89 99 60 55 14 80 10 11 12 14 69 54 24 6 24 28 95 98 62 92 93 63 52 9 47 44 94 96 97 48 46 48 68 93 80 44 28 19 44 29 36 61 87 10 66 65 62 30 43 47 85 1 65 29 42 35 87 10 23 20 99 14 72 6 5 20 3 75 98 56 22 20 58 6 100 86 98 73 92 57 78 20 16 80 100 17 27 75 19 1 84 13 5 65 diff --git a/subset-sum/input/104 b/subset-sum/input/104 new file mode 100644 index 0000000..5b996d6 --- /dev/null +++ b/subset-sum/input/104 @@ -0,0 +1,2 @@ +465 4554 +70 28 49 10 55 87 22 20 40 63 72 36 50 47 44 62 41 27 90 45 2 78 87 84 63 69 7 4 59 37 13 32 46 81 22 7 59 90 78 22 65 10 63 92 48 22 44 96 55 83 95 6 84 36 31 70 33 74 22 68 63 75 44 78 42 4 63 37 54 31 25 85 73 82 62 16 95 86 67 55 4 100 39 73 57 8 50 42 11 17 33 97 27 50 83 30 24 44 51 29 17 13 96 9 76 67 23 82 96 39 17 39 28 23 27 17 61 28 20 38 72 81 30 95 86 10 61 55 26 61 94 97 39 13 53 66 79 90 96 77 5 86 34 21 76 87 42 42 77 98 65 4 77 54 99 99 44 75 46 25 24 4 17 67 12 13 38 77 37 57 77 93 84 34 59 48 2 84 96 41 95 65 69 51 48 16 63 95 42 10 94 20 12 99 26 42 92 79 14 44 78 6 64 26 40 19 27 36 80 70 61 32 5 18 13 40 19 84 58 5 78 61 30 33 44 16 15 7 12 46 6 17 3 52 31 85 98 17 10 13 10 94 34 29 83 44 4 37 89 97 12 25 34 82 33 43 95 66 96 92 2 18 84 72 67 16 73 17 84 41 69 92 98 42 70 40 27 47 42 56 83 47 66 29 10 45 83 58 29 86 59 71 60 60 46 71 58 57 22 78 84 58 26 39 38 36 73 95 87 47 92 100 27 70 47 39 36 96 8 3 22 70 34 67 98 79 39 72 84 87 11 84 57 96 39 29 1 16 71 92 6 68 29 26 55 7 91 86 26 97 77 61 31 68 76 93 2 87 16 34 9 86 79 32 28 39 16 31 71 48 65 86 60 99 77 76 78 17 54 94 27 79 44 4 63 8 97 91 86 100 3 57 54 74 86 37 71 8 59 26 33 34 41 49 33 7 8 28 5 56 49 20 7 94 71 52 94 40 58 43 37 67 70 58 74 48 84 83 53 38 38 47 18 65 22 50 74 32 75 17 22 72 67 35 83 35 86 9 28 50 89 80 92 31 24 12 65 27 26 79 46 37 52 45 18 diff --git a/subset-sum/input/105 b/subset-sum/input/105 new file mode 100644 index 0000000..1f9d8d3 --- /dev/null +++ b/subset-sum/input/105 @@ -0,0 +1,2 @@ +661 9718 +55 90 98 76 28 27 50 44 95 1 56 35 16 30 29 20 23 37 48 46 87 64 43 10 11 58 37 93 73 45 11 64 6 77 30 41 28 91 96 93 28 83 87 16 44 87 49 19 2 74 54 95 51 89 1 51 37 46 23 37 97 48 34 61 50 100 19 94 56 26 93 40 35 29 40 84 65 27 66 60 95 98 78 66 24 78 68 42 25 49 46 49 67 21 90 39 52 97 97 1 27 65 38 71 59 73 13 24 96 18 73 29 17 65 38 14 79 27 60 4 5 27 58 32 6 10 91 3 19 46 21 56 90 39 68 5 20 21 68 2 43 21 9 17 61 32 60 64 63 70 61 18 83 16 3 86 11 35 38 47 99 86 37 46 31 48 16 71 30 84 20 8 8 39 86 96 45 30 16 86 24 25 99 51 46 61 54 12 44 70 97 29 64 6 99 39 33 44 13 56 41 74 1 13 54 64 96 67 19 59 28 63 19 39 87 96 66 1 66 100 99 69 90 16 54 89 71 68 96 28 8 71 10 32 32 25 42 37 100 12 62 59 46 59 59 32 56 67 19 60 67 100 35 55 37 41 10 86 15 51 40 55 71 67 36 52 87 57 87 28 17 81 19 11 53 54 80 44 34 14 46 78 85 72 72 68 32 61 39 8 41 54 38 25 4 53 4 24 97 16 29 7 19 2 64 37 66 93 66 4 82 12 38 44 25 70 39 9 9 81 53 56 28 81 17 94 82 55 44 52 59 78 48 9 86 49 99 48 75 91 6 15 62 97 35 77 18 68 75 33 51 32 33 28 24 42 97 79 98 64 58 42 90 71 100 99 15 36 55 81 18 60 2 93 16 34 65 29 4 97 16 36 78 71 26 11 61 79 30 59 74 80 57 28 19 28 14 63 69 6 17 25 82 68 20 27 56 42 65 4 27 17 46 22 15 4 92 53 40 75 77 42 68 15 21 73 49 8 33 23 80 19 99 13 79 80 76 84 36 25 10 3 40 80 82 23 49 77 31 38 44 50 25 44 3 34 35 13 92 15 65 18 77 7 15 40 50 79 36 3 2 95 96 97 22 95 43 16 28 61 79 23 61 97 74 82 32 72 90 85 37 61 75 9 10 39 32 91 62 81 54 63 9 17 64 38 57 1 45 76 72 49 61 15 32 31 24 87 49 5 38 63 99 23 49 51 73 10 47 8 55 74 93 77 29 37 52 62 41 2 100 4 62 11 72 86 31 16 44 3 36 33 71 22 14 76 57 31 17 100 2 57 5 7 77 91 51 85 86 34 99 15 17 62 4 73 88 37 68 100 33 94 100 49 50 99 70 76 83 96 3 30 15 37 33 51 87 92 77 77 1 61 58 82 35 56 61 90 34 94 39 15 99 21 54 12 54 43 79 75 9 39 14 75 57 16 98 62 98 24 1 23 30 39 58 29 98 9 42 43 45 15 42 18 78 86 36 66 7 31 90 30 29 78 5 87 21 87 44 8 62 diff --git a/subset-sum/input/106 b/subset-sum/input/106 new file mode 100644 index 0000000..bbbcadc --- /dev/null +++ b/subset-sum/input/106 @@ -0,0 +1,2 @@ +1000 10000 +76 70 13 88 12 15 36 54 69 48 62 89 67 91 44 31 52 12 16 37 2 34 71 50 100 95 6 53 81 83 46 23 58 93 2 35 9 78 9 36 89 80 65 10 35 73 53 73 92 33 44 28 84 43 56 64 77 93 36 51 14 56 91 77 32 45 58 15 89 6 90 34 48 65 71 48 82 48 58 44 83 88 40 29 10 74 9 11 41 61 46 70 58 85 95 1 37 42 74 48 4 3 30 63 50 23 53 56 100 24 54 81 54 71 31 39 71 94 8 16 97 74 79 91 22 68 18 50 30 20 69 95 50 98 21 100 95 15 73 17 1 2 33 14 96 28 70 83 99 87 91 54 44 4 23 28 33 1 89 73 22 7 79 43 72 5 95 67 95 80 69 87 33 13 91 49 94 74 48 63 66 49 49 53 90 83 27 47 15 6 7 84 65 84 80 8 89 50 49 22 99 42 76 99 61 25 53 49 82 57 100 45 12 68 31 42 43 20 62 75 60 1 44 21 87 78 85 82 33 96 86 67 70 61 47 16 72 19 37 7 90 62 73 24 98 69 91 99 4 66 8 41 57 17 24 95 64 17 48 54 56 12 58 78 16 10 28 6 82 25 9 53 97 84 16 64 43 31 75 2 96 53 77 15 52 71 56 34 1 66 8 11 63 40 82 73 82 11 93 29 7 89 41 5 100 27 99 90 39 99 90 59 79 85 45 27 91 33 87 23 73 68 90 53 5 34 36 6 79 95 41 77 28 38 15 86 5 7 77 85 35 31 36 20 53 71 89 28 42 77 33 68 4 23 75 89 66 57 22 92 35 15 1 27 20 73 93 57 86 81 42 57 82 73 66 7 47 58 12 7 15 6 51 15 11 23 100 17 14 66 88 28 6 16 31 78 91 25 86 4 86 28 86 50 92 60 15 71 4 66 46 42 92 28 63 4 16 80 16 19 82 7 76 64 53 95 97 98 46 98 74 45 46 20 2 53 33 12 23 88 72 36 76 3 72 12 95 57 5 35 92 26 37 2 96 90 82 67 26 12 3 16 38 43 84 57 29 52 21 26 82 82 64 98 100 65 67 41 78 20 70 15 50 79 67 70 79 57 23 33 15 83 48 75 45 31 90 84 87 62 73 24 9 78 6 26 32 32 2 43 89 56 41 12 44 73 12 36 29 26 76 75 34 39 69 64 59 72 35 48 44 84 56 40 47 91 52 3 100 1 12 58 62 25 80 87 73 31 41 70 58 83 47 67 45 16 20 62 28 45 7 9 57 43 82 58 20 17 13 10 2 51 69 23 11 100 34 66 89 28 37 26 15 6 54 32 63 66 19 9 92 49 23 51 73 4 12 56 52 57 18 49 24 58 69 85 23 32 15 35 33 81 20 51 43 2 28 6 73 90 57 17 8 45 62 99 32 90 85 68 68 98 57 42 13 22 21 52 75 13 36 82 48 76 58 70 42 15 53 26 49 63 26 63 95 83 92 96 47 6 93 97 59 16 52 4 69 32 8 56 1 39 7 97 18 72 84 41 85 30 78 47 17 49 42 10 93 46 77 82 56 22 56 39 73 95 26 60 9 59 90 38 91 2 34 30 31 37 25 10 78 2 82 13 96 89 46 18 19 78 74 33 85 52 46 99 18 19 60 33 19 67 51 80 20 51 12 4 39 79 57 96 59 47 73 72 34 66 29 92 20 3 26 46 5 95 88 87 51 57 97 78 5 12 44 28 77 25 2 15 83 35 52 76 60 21 55 48 24 96 59 74 52 22 41 76 73 51 85 49 78 12 44 86 3 91 55 46 68 41 3 12 18 68 83 76 23 17 49 86 13 3 45 26 11 14 91 43 64 21 21 5 1 40 76 46 79 7 18 56 87 77 7 41 65 50 77 70 90 30 61 17 57 3 73 100 37 19 53 23 18 28 37 69 44 82 2 20 39 92 73 4 33 51 74 76 86 50 30 97 60 4 73 58 40 93 53 42 99 61 86 1 3 52 44 3 53 88 64 95 78 86 58 17 87 94 64 36 3 6 90 66 53 15 73 87 39 60 16 14 52 77 54 28 95 53 78 98 82 32 97 27 96 10 51 96 48 14 78 14 23 8 54 91 1 28 79 30 69 52 55 51 81 94 17 28 51 24 75 94 38 73 81 96 54 27 39 51 31 60 83 77 90 83 9 42 25 74 69 62 70 26 8 25 80 20 32 61 70 39 23 76 2 16 36 99 30 17 35 72 47 22 63 57 89 36 23 55 56 65 diff --git a/subset-sum/input/11 b/subset-sum/input/11 new file mode 100644 index 0000000..7bfb96d --- /dev/null +++ b/subset-sum/input/11 @@ -0,0 +1,2 @@ +215 3604 +75 16 49 6 99 57 54 55 91 39 5 37 68 54 66 36 28 7 32 32 86 66 68 59 18 52 68 68 10 5 65 69 75 60 2 38 16 6 2 59 22 23 26 6 19 5 21 75 15 55 74 58 46 11 49 97 88 76 78 83 11 64 85 30 77 83 28 57 35 71 85 51 95 38 81 46 3 36 1 33 59 86 93 47 19 27 28 10 47 23 94 5 98 99 54 49 20 14 88 88 35 7 64 17 85 65 81 66 16 85 31 58 37 28 37 76 54 43 80 18 56 49 22 78 13 56 16 36 88 36 49 14 28 54 41 67 64 38 66 69 70 46 42 99 68 25 35 51 74 50 61 73 6 82 52 42 35 37 60 59 49 9 95 47 74 81 26 24 9 43 25 27 10 95 98 55 67 98 90 78 95 8 16 100 33 50 12 82 53 97 81 20 27 25 55 40 70 50 78 33 39 19 33 88 99 58 20 22 61 66 22 56 1 77 44 diff --git a/subset-sum/input/12 b/subset-sum/input/12 new file mode 100644 index 0000000..20c8992 --- /dev/null +++ b/subset-sum/input/12 @@ -0,0 +1,2 @@ +273 8966 +46 4 9 49 96 27 85 55 13 59 63 39 91 70 60 34 11 74 76 45 77 14 45 43 9 79 37 40 82 53 31 95 17 94 71 65 90 86 93 4 72 93 54 21 32 60 23 82 81 64 36 65 71 94 58 75 56 10 54 29 74 95 16 26 83 64 52 15 40 35 80 62 74 45 12 45 7 54 21 20 11 7 3 13 52 63 51 91 25 74 42 43 81 42 19 30 29 53 57 3 1 40 43 38 71 73 6 89 78 31 78 19 52 56 49 47 61 34 51 18 30 91 93 23 3 63 46 72 6 54 61 31 89 51 28 63 12 99 78 19 36 72 71 95 49 54 67 15 89 25 19 41 83 69 19 15 81 93 100 35 18 81 16 65 20 4 45 81 83 90 14 82 85 43 7 64 76 33 47 95 12 78 93 14 22 97 36 65 66 36 26 59 81 81 82 44 79 89 94 32 94 22 33 19 46 46 62 19 47 70 91 97 62 17 43 11 25 74 73 64 98 73 7 40 8 2 96 89 81 80 17 88 13 31 44 64 25 52 60 50 90 84 35 56 64 52 20 43 19 12 73 48 93 43 78 22 53 60 100 26 54 84 20 14 30 82 49 47 96 34 66 15 11 diff --git a/subset-sum/input/13 b/subset-sum/input/13 new file mode 100644 index 0000000..a96bcd7 --- /dev/null +++ b/subset-sum/input/13 @@ -0,0 +1,2 @@ +179 8645 +56 77 53 13 43 92 67 37 74 64 62 62 18 74 68 93 57 7 45 34 73 75 10 22 23 35 37 62 30 88 23 79 74 21 87 80 73 56 20 27 69 5 86 72 79 79 49 20 41 70 100 99 57 39 51 23 33 8 38 39 65 31 85 24 60 16 94 15 72 40 45 57 21 19 79 54 77 18 99 63 35 17 48 64 7 39 26 6 96 97 100 14 62 39 55 88 36 94 38 49 28 99 49 70 18 59 22 27 77 5 86 52 85 59 77 63 14 61 86 37 80 37 52 4 56 13 47 44 42 72 28 7 89 85 97 86 4 3 98 35 97 99 35 53 25 5 7 26 86 3 51 35 85 48 100 18 48 51 17 10 24 77 51 87 20 35 66 66 76 61 99 82 35 28 81 10 58 26 95 diff --git a/subset-sum/input/14 b/subset-sum/input/14 new file mode 100644 index 0000000..9eabee4 --- /dev/null +++ b/subset-sum/input/14 @@ -0,0 +1,2 @@ +280 2623 +4 49 72 55 71 86 31 28 44 31 96 96 54 19 95 24 7 57 76 49 12 50 69 98 45 20 49 61 37 44 98 2 32 36 96 79 28 13 36 38 80 59 5 85 97 36 18 61 63 89 27 100 13 38 67 23 4 64 44 24 37 10 47 89 56 21 64 92 5 66 59 45 87 96 2 47 72 47 49 43 23 59 56 71 6 31 88 1 79 26 98 13 11 77 47 2 71 15 11 18 86 99 14 17 58 2 30 58 34 15 38 59 61 73 24 12 37 81 21 23 30 53 4 59 61 78 94 97 73 14 93 13 61 94 12 71 72 82 89 63 31 12 55 64 91 97 96 82 13 100 84 84 39 57 56 95 50 23 5 32 90 51 26 50 76 74 85 46 57 75 23 93 96 83 99 38 68 78 23 41 19 49 51 61 100 78 52 31 30 94 99 17 51 56 91 36 94 64 58 78 33 77 96 60 64 58 23 93 80 89 17 54 56 23 77 44 80 73 7 97 97 31 48 23 23 87 75 19 7 22 94 47 89 96 5 53 87 71 53 46 91 16 51 100 53 90 23 8 39 85 10 48 52 8 64 26 2 15 94 75 64 70 37 74 64 4 53 55 5 29 31 4 34 61 84 7 81 63 44 69 diff --git a/subset-sum/input/15 b/subset-sum/input/15 new file mode 100644 index 0000000..ce20fce --- /dev/null +++ b/subset-sum/input/15 @@ -0,0 +1,2 @@ +283 3866 +95 64 98 51 83 19 88 29 72 61 47 35 99 30 70 34 20 10 27 89 16 43 72 83 64 31 33 84 28 7 36 73 76 2 47 43 54 100 54 36 38 60 54 42 73 91 63 21 31 94 95 62 81 43 17 34 47 56 35 67 35 63 49 100 76 25 79 28 32 71 51 80 39 60 20 69 38 85 52 42 96 91 87 28 40 53 82 83 62 83 45 32 33 40 65 65 64 61 87 43 49 56 35 89 71 50 18 10 46 17 92 59 85 62 7 15 15 64 29 65 75 31 50 9 35 30 80 7 54 98 18 75 18 53 10 99 99 88 67 4 49 21 15 50 30 34 21 51 17 52 92 28 40 37 43 88 72 82 59 47 60 77 16 92 74 88 45 63 81 12 87 60 83 79 29 98 97 71 7 21 27 29 31 56 97 11 6 80 72 46 1 11 97 97 62 42 53 64 94 84 63 81 42 40 13 23 75 95 76 46 24 32 63 64 64 38 16 11 57 57 99 8 75 41 25 26 26 90 31 97 43 74 48 88 28 2 50 75 96 10 82 1 60 96 35 8 33 41 23 20 51 24 58 92 47 96 81 28 82 71 92 56 32 18 29 7 98 69 91 13 28 1 23 86 16 41 86 65 53 61 81 74 45 diff --git a/subset-sum/input/16 b/subset-sum/input/16 new file mode 100644 index 0000000..92337b3 --- /dev/null +++ b/subset-sum/input/16 @@ -0,0 +1,2 @@ +310 1124 +60 23 77 56 76 33 93 17 67 51 74 52 40 79 10 34 84 59 47 44 5 83 48 21 95 36 22 6 14 57 96 53 14 30 82 10 41 88 20 77 32 50 12 39 99 55 47 17 53 86 33 95 72 45 56 90 43 66 73 71 39 89 75 62 89 88 29 91 31 38 12 96 79 20 72 25 2 51 2 87 50 20 28 98 89 2 57 15 16 52 41 35 25 24 18 41 17 30 74 84 82 58 22 67 50 30 4 83 39 26 50 20 13 9 45 28 27 31 4 23 50 49 98 6 100 83 79 44 82 74 67 84 15 83 21 93 43 18 22 15 73 20 12 81 9 89 11 10 62 30 19 71 49 13 40 16 44 28 85 31 53 34 98 3 53 86 22 50 37 46 77 67 84 41 26 49 26 37 66 15 23 34 12 41 46 93 8 18 26 25 36 48 21 66 66 1 84 49 67 66 76 5 53 35 36 1 78 40 13 92 47 51 88 32 38 91 92 75 9 58 69 69 41 33 82 68 15 15 92 39 14 9 97 79 30 37 2 73 59 2 77 30 17 94 63 21 86 80 99 89 43 78 58 77 42 81 41 94 17 68 62 16 62 84 59 25 81 95 49 20 22 40 10 4 32 84 88 78 63 57 47 91 90 54 63 95 21 36 36 67 13 36 89 20 71 42 22 66 73 88 5 30 29 9 100 100 12 94 29 50 diff --git a/subset-sum/input/17 b/subset-sum/input/17 new file mode 100644 index 0000000..2bced69 --- /dev/null +++ b/subset-sum/input/17 @@ -0,0 +1,2 @@ +273 3748 +69 35 11 36 38 73 34 26 13 39 94 7 13 92 54 55 86 14 90 76 78 36 70 93 76 16 38 43 36 62 20 71 56 27 48 66 94 14 39 4 47 19 20 14 94 95 42 84 3 49 33 51 41 1 60 80 33 47 96 39 32 4 96 17 72 18 11 63 15 3 34 89 43 30 39 92 81 25 47 56 10 44 60 82 81 89 36 51 3 42 40 47 57 78 50 87 49 88 24 27 38 90 30 57 44 44 48 25 29 59 33 63 54 54 21 80 70 76 100 28 78 67 26 61 7 87 1 95 36 73 1 51 50 73 39 5 18 85 94 25 74 87 69 25 63 31 8 69 52 90 2 25 35 28 32 43 3 91 65 27 52 2 28 82 83 75 10 55 89 73 45 29 12 83 57 22 70 95 63 77 52 92 69 26 28 48 64 25 12 15 26 30 61 6 80 16 25 21 13 9 93 45 61 31 88 38 72 3 26 11 12 93 1 33 10 81 47 64 77 21 58 30 25 49 80 61 54 33 61 73 30 70 59 4 43 26 36 69 11 67 7 66 54 8 75 77 3 40 80 34 55 73 70 92 1 70 55 60 20 61 53 77 33 51 86 26 2 71 31 38 55 30 65 diff --git a/subset-sum/input/18 b/subset-sum/input/18 new file mode 100644 index 0000000..5ea4e5b --- /dev/null +++ b/subset-sum/input/18 @@ -0,0 +1,2 @@ +259 8113 +38 67 37 2 94 85 20 83 84 67 5 70 71 60 57 64 69 23 52 60 2 46 36 58 27 86 91 33 73 40 93 73 31 91 71 66 8 44 17 64 50 37 94 77 59 26 86 41 56 91 51 93 5 24 25 19 59 11 12 8 23 41 34 79 32 17 85 100 56 64 74 74 39 100 9 84 75 22 35 44 67 79 60 7 24 18 21 98 66 96 63 45 52 79 37 62 8 88 39 30 76 58 13 5 56 32 60 73 29 34 50 59 28 33 45 82 73 26 64 10 21 16 46 26 56 19 32 14 99 17 31 54 47 48 80 29 72 26 67 99 75 64 9 80 21 88 33 27 2 75 63 71 78 64 76 13 63 7 91 40 6 87 75 3 29 72 86 91 63 45 64 75 56 43 95 62 61 60 100 32 18 94 20 54 3 9 45 5 62 65 92 75 15 57 70 22 15 13 40 46 54 81 77 84 57 64 80 57 20 58 19 27 29 86 73 9 47 60 29 34 68 64 41 87 24 26 40 61 8 91 53 74 52 63 33 65 96 81 60 58 75 97 89 88 19 91 10 90 55 52 73 69 5 64 49 72 92 95 54 diff --git a/subset-sum/input/19 b/subset-sum/input/19 new file mode 100644 index 0000000..0fe7300 --- /dev/null +++ b/subset-sum/input/19 @@ -0,0 +1,2 @@ +54 3100 +23 100 4 93 85 4 57 79 84 16 4 73 5 18 69 13 85 17 40 61 66 68 73 34 46 65 90 60 70 94 96 63 72 52 31 49 45 83 85 17 84 27 19 70 54 22 56 90 72 32 4 99 64 78 diff --git a/subset-sum/input/2 b/subset-sum/input/2 new file mode 100644 index 0000000..4e8e020 --- /dev/null +++ b/subset-sum/input/2 @@ -0,0 +1,2 @@ +4 4 +5 1 2 5 diff --git a/subset-sum/input/20 b/subset-sum/input/20 new file mode 100644 index 0000000..07dc4c3 --- /dev/null +++ b/subset-sum/input/20 @@ -0,0 +1,2 @@ +309 9850 +24 47 98 46 2 18 16 50 46 42 27 52 43 61 15 31 22 53 75 62 93 34 8 94 93 10 40 100 28 99 4 93 56 89 39 24 95 34 8 91 9 88 96 83 53 22 82 3 8 15 77 89 32 5 93 10 31 79 54 21 5 12 36 87 94 50 25 25 13 60 22 81 38 45 35 97 77 26 34 51 60 15 96 8 13 91 72 16 26 12 21 44 36 48 16 88 76 42 21 62 77 38 13 53 76 1 46 62 58 66 3 50 21 87 48 18 40 36 7 74 26 23 46 55 99 83 59 69 72 14 9 41 62 87 74 80 19 4 23 23 12 68 58 97 24 23 97 32 27 61 72 67 88 62 55 41 60 94 46 57 93 61 47 8 72 71 71 11 39 87 34 66 64 66 34 34 7 13 24 32 72 17 95 100 51 5 78 70 42 95 58 40 99 99 14 27 11 51 58 89 13 89 73 89 20 4 31 39 52 19 16 44 30 28 46 52 95 54 46 47 18 80 16 31 99 8 67 16 72 41 90 95 15 58 62 72 70 52 46 15 2 44 97 43 49 66 23 3 65 79 28 67 30 80 15 77 3 9 85 13 34 15 8 79 87 26 60 85 62 96 13 7 58 88 43 97 10 92 9 97 87 35 99 14 40 68 48 18 93 57 48 97 81 56 86 47 53 26 47 46 54 75 86 73 90 31 51 19 16 diff --git a/subset-sum/input/21 b/subset-sum/input/21 new file mode 100644 index 0000000..829ea82 --- /dev/null +++ b/subset-sum/input/21 @@ -0,0 +1,2 @@ +302 2352 +90 15 78 94 8 3 90 25 6 65 100 32 28 22 5 46 14 67 85 20 86 68 21 56 35 48 54 51 32 35 5 29 39 17 25 52 54 44 68 76 74 33 82 29 38 55 1 7 28 75 19 66 25 91 79 96 76 95 84 97 20 63 68 46 23 11 99 38 7 37 10 84 84 63 80 32 92 10 52 86 18 28 96 49 75 35 88 52 89 64 41 13 3 61 55 65 6 7 4 94 39 40 78 21 2 98 41 64 49 54 10 1 23 51 13 37 13 60 76 18 80 33 50 57 37 15 53 62 40 64 64 87 70 100 6 80 72 62 65 41 61 72 35 30 39 26 89 6 30 87 83 30 87 56 57 3 83 19 2 63 58 82 99 29 85 57 85 48 16 16 36 36 100 30 4 32 82 47 64 41 74 67 94 6 54 76 28 78 16 33 70 2 83 85 62 60 23 84 67 13 100 23 87 55 75 66 68 92 33 93 86 85 54 40 72 20 71 98 79 87 56 95 30 74 59 58 48 45 4 52 80 27 59 63 16 40 41 59 15 48 27 68 56 11 1 19 81 39 76 73 20 64 24 79 29 71 47 96 53 31 100 13 89 67 9 28 45 27 66 70 14 18 12 29 21 57 51 67 17 59 91 12 73 79 11 36 67 50 77 99 98 82 52 15 81 11 43 98 90 6 54 22 diff --git a/subset-sum/input/22 b/subset-sum/input/22 new file mode 100644 index 0000000..1d8dfec --- /dev/null +++ b/subset-sum/input/22 @@ -0,0 +1,2 @@ +323 893 +40 71 17 5 68 84 16 20 91 86 29 51 37 62 100 25 19 44 58 90 75 27 68 77 67 74 33 43 10 86 33 66 4 66 84 86 8 50 75 95 1 52 16 93 90 70 25 50 37 53 97 44 33 44 66 57 75 43 52 1 73 49 25 3 82 62 75 24 96 41 33 3 91 72 62 43 3 71 13 73 69 88 19 23 10 26 28 81 27 1 86 4 63 48 88 38 80 20 25 80 59 66 83 80 19 56 40 7 10 17 56 76 25 29 57 59 79 29 45 11 25 5 100 64 37 73 51 62 42 87 82 88 53 76 95 67 44 87 85 16 73 100 22 65 60 54 1 32 78 62 93 66 15 70 8 66 93 39 13 72 26 23 30 54 23 87 71 10 35 10 77 26 4 1 32 67 66 57 69 87 30 8 37 63 100 4 36 97 93 42 2 42 34 8 26 14 7 56 50 79 14 43 21 10 29 26 17 18 7 85 65 31 16 55 15 80 36 99 99 97 96 98 31 82 85 31 21 82 23 9 72 13 79 73 63 19 74 5 29 91 24 70 55 36 2 75 49 19 44 39 97 43 51 68 63 79 91 14 19 64 47 100 54 49 21 36 29 65 50 62 80 40 52 96 69 86 42 85 38 95 34 77 79 37 72 3 2 14 33 47 9 71 33 61 11 69 13 12 99 40 5 83 43 99 59 84 62 14 30 12 91 20 12 32 16 65 45 19 72 37 30 38 69 diff --git a/subset-sum/input/23 b/subset-sum/input/23 new file mode 100644 index 0000000..939ab33 --- /dev/null +++ b/subset-sum/input/23 @@ -0,0 +1,2 @@ +101 8631 +46 55 79 37 50 99 9 68 18 97 12 5 65 42 87 86 40 46 87 90 32 68 79 1 40 9 30 50 13 9 73 100 1 90 7 39 65 79 99 86 94 22 49 43 63 78 53 68 89 25 55 66 30 27 77 97 75 70 56 49 54 60 84 16 65 45 47 46 97 18 86 7 31 2 100 32 67 85 97 62 76 36 88 94 5 74 5 47 35 70 48 4 12 31 52 75 26 34 25 11 98 diff --git a/subset-sum/input/24 b/subset-sum/input/24 new file mode 100644 index 0000000..4bc31de --- /dev/null +++ b/subset-sum/input/24 @@ -0,0 +1,2 @@ +217 78 +63 6 10 56 4 91 67 85 51 56 61 82 41 21 96 42 17 56 45 4 18 88 68 9 70 1 59 36 92 25 73 40 15 86 5 81 64 29 96 91 28 61 90 14 47 94 41 36 27 51 12 70 75 8 13 76 80 84 60 92 15 53 2 3 1 59 75 32 54 4 76 22 23 7 50 86 41 9 9 91 23 18 41 61 47 66 1 79 49 21 99 29 87 94 42 55 87 21 60 67 36 89 40 71 6 63 65 88 17 12 89 32 79 99 34 30 63 33 53 56 10 11 66 80 73 52 93 36 69 49 37 48 42 63 27 16 60 16 63 80 37 69 24 86 38 73 15 43 65 49 35 39 98 91 24 20 35 12 40 31 37 21 29 39 18 98 77 71 50 94 5 28 61 56 62 1 4 49 10 66 47 87 1 62 65 92 65 25 91 85 97 10 77 3 20 30 66 6 87 63 26 89 82 22 15 31 75 38 69 5 69 10 53 10 10 43 3 diff --git a/subset-sum/input/25 b/subset-sum/input/25 new file mode 100644 index 0000000..5bb8aa6 --- /dev/null +++ b/subset-sum/input/25 @@ -0,0 +1,2 @@ +107 5950 +47 12 91 42 28 56 39 2 71 93 95 60 61 26 78 50 77 97 64 8 16 74 43 79 100 37 66 91 1 20 97 70 95 87 42 83 54 66 31 64 57 15 38 76 31 89 76 61 77 22 90 79 59 26 63 60 82 57 3 50 100 9 85 33 32 78 31 50 45 64 93 60 28 84 74 19 51 24 71 32 71 42 77 94 7 81 99 13 42 64 94 65 45 5 95 75 50 100 33 1 46 77 44 81 93 9 39 diff --git a/subset-sum/input/26 b/subset-sum/input/26 new file mode 100644 index 0000000..9b1f3e6 --- /dev/null +++ b/subset-sum/input/26 @@ -0,0 +1,2 @@ +88 5976 +45 71 38 14 46 30 65 20 55 93 76 15 27 18 11 47 80 38 41 14 65 36 75 64 1 16 64 62 33 37 51 7 78 1 39 22 84 91 78 79 77 20 7 98 36 47 73 38 11 46 9 98 97 24 60 72 24 14 71 41 24 77 24 23 2 15 12 99 34 14 3 79 74 8 22 57 77 93 62 62 88 32 54 8 5 34 40 12 diff --git a/subset-sum/input/27 b/subset-sum/input/27 new file mode 100644 index 0000000..12393de --- /dev/null +++ b/subset-sum/input/27 @@ -0,0 +1,2 @@ +45 4993 +24 41 99 38 97 79 45 40 15 38 92 15 51 40 6 5 95 62 73 89 93 11 37 35 93 48 32 69 4 14 20 33 78 51 32 24 48 14 56 21 2 42 60 96 87 diff --git a/subset-sum/input/28 b/subset-sum/input/28 new file mode 100644 index 0000000..0cae106 --- /dev/null +++ b/subset-sum/input/28 @@ -0,0 +1,2 @@ +163 2173 +44 24 20 80 81 1 18 14 95 7 48 86 65 51 9 5 54 22 58 93 72 31 65 86 27 20 23 24 43 5 78 12 68 60 24 55 55 83 74 1 60 37 62 15 2 5 70 86 93 98 34 45 24 69 66 55 55 74 77 87 55 83 27 46 37 55 12 33 91 1 23 4 78 74 97 8 25 63 63 9 16 60 27 41 18 42 84 35 76 59 8 33 92 40 89 19 23 90 18 30 51 42 62 42 34 75 61 32 33 43 54 40 93 35 13 20 90 47 55 39 79 2 61 95 83 60 53 4 55 3 33 74 17 38 78 83 83 94 34 43 34 99 94 78 24 48 89 1 2 22 11 42 86 26 7 23 94 100 82 27 24 28 98 diff --git a/subset-sum/input/29 b/subset-sum/input/29 new file mode 100644 index 0000000..3312a42 --- /dev/null +++ b/subset-sum/input/29 @@ -0,0 +1,2 @@ +123 1512 +53 67 43 33 45 13 1 80 99 3 79 71 20 26 35 20 69 45 52 39 48 23 3 80 43 60 90 66 77 7 32 77 24 85 31 45 39 97 35 64 17 2 12 56 16 72 71 27 48 64 61 61 94 11 19 34 17 7 76 53 76 46 71 42 58 65 94 65 64 70 88 49 39 2 36 10 55 64 75 51 73 32 86 89 51 49 45 97 22 87 74 10 47 42 48 77 51 9 36 43 41 52 52 63 100 39 43 37 66 5 82 8 54 13 42 13 19 20 23 86 27 9 46 diff --git a/subset-sum/input/3 b/subset-sum/input/3 new file mode 100644 index 0000000..d103238 --- /dev/null +++ b/subset-sum/input/3 @@ -0,0 +1,2 @@ +8 14 +1 2 3 4 4 9 9 15 diff --git a/subset-sum/input/30 b/subset-sum/input/30 new file mode 100644 index 0000000..0d504cd --- /dev/null +++ b/subset-sum/input/30 @@ -0,0 +1,2 @@ +75 6857 +92 56 9 47 11 98 91 21 40 55 98 60 93 33 14 39 7 8 79 86 76 41 99 22 72 64 28 79 32 34 63 86 6 12 78 7 63 27 51 76 33 22 47 15 65 98 32 72 22 73 27 45 32 15 38 5 70 96 43 26 16 21 28 6 26 27 45 2 23 26 49 54 47 64 81 diff --git a/subset-sum/input/31 b/subset-sum/input/31 new file mode 100644 index 0000000..ce09714 --- /dev/null +++ b/subset-sum/input/31 @@ -0,0 +1,2 @@ +195 2246 +51 75 32 26 6 36 32 97 97 23 15 13 48 12 60 58 20 53 90 87 90 29 32 57 34 72 72 39 57 12 40 68 31 67 68 16 66 11 46 63 58 88 8 1 58 74 2 88 18 4 65 6 59 82 65 40 52 56 36 87 65 8 97 19 43 9 38 23 69 22 39 23 34 91 12 10 85 77 99 4 62 88 59 13 84 40 34 32 66 2 12 49 85 34 26 4 29 47 32 71 80 63 23 8 21 51 92 65 54 5 67 46 19 54 77 38 4 40 10 90 59 4 60 76 68 17 9 46 23 44 77 65 73 18 58 26 80 29 15 37 98 78 14 32 34 33 38 64 55 73 29 57 11 52 50 25 18 5 76 81 92 41 30 60 74 49 33 29 53 19 37 30 50 53 57 76 85 64 18 64 34 35 51 49 7 85 20 51 27 2 15 41 16 67 5 diff --git a/subset-sum/input/32 b/subset-sum/input/32 new file mode 100644 index 0000000..8743820 --- /dev/null +++ b/subset-sum/input/32 @@ -0,0 +1,2 @@ +155 4498 +62 23 90 11 31 43 40 45 81 90 45 75 50 65 96 20 50 1 54 13 100 57 34 28 17 32 51 28 27 92 65 86 36 32 44 47 72 11 39 99 94 31 75 16 40 39 66 97 99 6 64 55 88 9 54 56 53 5 1 79 68 70 59 53 15 93 35 42 55 63 24 89 61 80 38 8 96 97 25 45 36 82 92 36 53 97 31 47 78 73 74 93 58 92 71 43 67 49 28 53 38 74 2 38 49 55 79 92 45 30 66 97 99 97 69 97 15 88 86 53 77 44 55 46 38 96 40 24 93 32 73 99 99 41 62 34 50 62 37 95 35 42 75 64 8 40 20 1 26 70 6 27 28 82 54 diff --git a/subset-sum/input/33 b/subset-sum/input/33 new file mode 100644 index 0000000..ff9032a --- /dev/null +++ b/subset-sum/input/33 @@ -0,0 +1,2 @@ +40 8603 +92 86 24 20 70 68 73 5 35 94 17 72 64 68 77 74 14 62 78 21 22 11 80 15 71 67 40 21 76 25 66 77 99 94 28 76 20 100 13 60 diff --git a/subset-sum/input/34 b/subset-sum/input/34 new file mode 100644 index 0000000..e66177b --- /dev/null +++ b/subset-sum/input/34 @@ -0,0 +1,2 @@ +73 4136 +19 27 58 61 82 39 17 22 63 100 75 40 18 57 60 49 52 63 41 30 17 40 42 71 87 38 28 82 93 69 52 35 85 16 62 98 67 49 79 8 68 92 31 98 67 44 19 1 31 83 45 53 15 13 11 21 81 20 20 52 96 7 63 75 6 62 90 29 83 8 28 74 83 diff --git a/subset-sum/input/35 b/subset-sum/input/35 new file mode 100644 index 0000000..931df74 --- /dev/null +++ b/subset-sum/input/35 @@ -0,0 +1,2 @@ +123 8683 +57 96 45 55 10 26 83 17 100 97 10 96 92 78 44 96 36 27 90 10 25 62 90 9 74 42 84 56 66 38 92 58 90 40 99 29 16 16 77 35 29 66 82 36 100 23 25 62 1 36 98 32 60 78 78 67 31 92 66 84 31 17 24 60 35 11 2 74 44 13 84 25 23 42 30 56 82 23 40 20 92 77 36 13 56 77 80 93 86 82 81 19 46 26 69 34 42 82 38 91 56 5 37 51 79 81 95 86 5 62 20 29 7 41 15 73 49 51 31 86 6 19 97 diff --git a/subset-sum/input/36 b/subset-sum/input/36 new file mode 100644 index 0000000..5c3be62 --- /dev/null +++ b/subset-sum/input/36 @@ -0,0 +1,2 @@ +188 8813 +55 63 82 87 31 19 47 10 65 14 55 31 32 94 56 61 89 25 97 8 81 75 69 84 72 75 38 7 91 31 11 6 23 23 18 68 44 82 99 9 92 1 59 69 1 78 65 43 74 87 53 46 23 40 64 35 12 17 5 49 47 9 91 92 22 56 65 91 37 46 89 86 2 89 98 28 98 60 98 62 79 82 68 82 89 3 58 5 72 59 52 17 65 33 15 67 97 34 92 95 32 3 31 80 59 39 16 45 19 42 97 94 28 67 74 91 46 63 39 47 15 75 14 38 15 90 31 44 83 21 97 80 63 6 76 30 68 5 5 14 58 14 76 35 43 25 51 64 30 36 40 90 17 41 55 72 84 25 49 6 60 86 94 15 33 69 16 55 48 81 50 93 49 43 50 85 70 60 59 8 46 34 20 51 11 51 59 44 diff --git a/subset-sum/input/37 b/subset-sum/input/37 new file mode 100644 index 0000000..96ff004 --- /dev/null +++ b/subset-sum/input/37 @@ -0,0 +1,2 @@ +6 1400 +3 25 28 28 70 87 diff --git a/subset-sum/input/38 b/subset-sum/input/38 new file mode 100644 index 0000000..095d860 --- /dev/null +++ b/subset-sum/input/38 @@ -0,0 +1,2 @@ +160 8298 +40 84 51 78 90 89 79 49 64 9 80 68 19 12 1 34 19 57 36 35 19 85 84 21 40 89 100 59 66 64 31 49 51 43 49 77 17 14 56 21 72 6 17 34 58 30 83 23 50 57 56 28 82 11 11 59 4 23 67 67 16 14 10 28 73 99 27 96 60 61 97 22 60 12 49 85 64 61 80 89 31 21 75 94 72 42 77 23 8 66 89 17 86 69 49 69 46 68 40 49 21 69 97 20 43 24 77 61 90 81 53 48 20 43 29 78 33 14 95 100 82 94 66 27 39 74 7 99 70 82 96 87 26 50 48 83 29 65 36 47 15 2 73 57 56 78 51 6 2 16 76 33 68 87 43 55 64 24 1 98 diff --git a/subset-sum/input/39 b/subset-sum/input/39 new file mode 100644 index 0000000..d39c04e --- /dev/null +++ b/subset-sum/input/39 @@ -0,0 +1,2 @@ +42 7700 +79 83 35 36 34 55 83 3 50 73 43 49 60 99 8 30 4 8 53 7 59 45 2 10 10 37 39 80 14 31 53 87 18 87 10 24 76 85 40 26 4 9 diff --git a/subset-sum/input/4 b/subset-sum/input/4 new file mode 100644 index 0000000..006748b --- /dev/null +++ b/subset-sum/input/4 @@ -0,0 +1,2 @@ +8 1 +2 2 2 2 2 2 2 2 diff --git a/subset-sum/input/40 b/subset-sum/input/40 new file mode 100644 index 0000000..2d2a28f --- /dev/null +++ b/subset-sum/input/40 @@ -0,0 +1,2 @@ +402 9044 +2 58 55 44 56 16 24 75 39 29 86 90 29 95 46 12 94 8 80 77 60 37 85 89 88 64 8 94 12 55 56 62 96 34 29 51 24 72 27 1 1 15 46 55 16 31 84 82 81 39 21 57 17 40 99 59 36 97 59 48 68 61 30 24 29 84 86 95 7 22 52 71 15 38 89 45 25 4 94 93 99 99 70 89 89 69 56 18 88 82 42 35 23 49 3 40 57 83 26 8 9 77 21 11 40 50 63 81 50 35 79 17 5 13 66 87 93 82 96 7 54 89 56 55 38 70 88 85 84 11 86 75 62 93 85 96 40 87 37 42 66 62 58 63 42 4 17 10 32 17 80 37 28 89 89 37 35 56 35 43 71 72 69 18 30 39 13 7 39 30 21 92 18 27 90 97 66 40 40 87 38 66 19 32 13 74 69 96 80 71 14 30 97 7 51 15 26 58 27 39 26 38 9 3 28 33 44 26 90 1 74 4 19 39 69 20 21 85 17 44 85 96 48 19 30 98 36 62 89 98 33 96 92 55 1 36 26 52 74 59 96 79 23 35 88 90 83 26 69 97 72 61 32 6 89 17 62 32 5 17 51 59 38 26 49 89 75 94 3 17 62 93 42 19 11 100 80 85 51 44 20 6 34 15 87 21 86 92 46 6 49 86 93 41 94 77 17 73 81 65 75 39 11 1 88 52 51 37 79 51 55 92 62 52 27 15 5 66 13 96 92 78 24 80 22 25 10 18 5 94 2 41 19 14 30 26 72 66 57 24 13 49 87 82 47 63 100 4 78 51 96 22 55 22 59 24 74 22 5 68 44 92 14 79 74 46 57 68 12 34 75 92 35 21 85 64 8 100 96 18 98 10 23 89 76 24 72 12 65 80 83 43 38 72 41 98 92 96 23 28 99 7 diff --git a/subset-sum/input/41 b/subset-sum/input/41 new file mode 100644 index 0000000..e12798c --- /dev/null +++ b/subset-sum/input/41 @@ -0,0 +1,2 @@ +325 319 +64 49 31 40 39 6 79 42 54 47 40 45 97 12 25 62 31 36 44 20 99 92 20 2 57 83 64 17 13 76 25 47 20 40 72 37 82 54 25 63 41 60 25 11 92 24 41 45 73 81 9 61 80 86 98 47 30 99 8 51 59 84 29 11 15 39 28 12 57 66 39 97 11 43 33 25 99 78 61 21 62 55 69 12 80 93 79 18 45 92 8 38 67 44 20 52 10 60 39 39 50 8 100 60 21 67 92 53 34 37 51 7 74 78 48 9 75 2 92 2 5 7 67 19 99 50 50 14 80 46 94 64 71 47 48 32 53 52 23 54 39 46 1 78 86 18 46 86 34 43 88 67 83 70 33 56 82 57 72 26 61 37 8 66 59 35 59 34 9 50 93 57 68 79 47 82 21 92 40 13 43 70 87 89 40 67 62 3 73 41 41 74 77 29 13 70 26 53 22 73 64 74 30 64 68 38 7 75 83 63 16 33 80 43 69 81 29 78 95 76 79 83 33 24 97 47 22 90 17 8 28 85 27 19 14 21 48 26 67 86 64 75 89 78 52 32 70 22 81 77 27 85 100 17 96 39 16 30 93 80 63 92 65 39 13 21 97 19 70 96 82 33 56 33 88 92 44 23 39 32 49 62 70 16 64 69 67 92 26 58 100 71 40 5 45 62 22 73 96 35 68 26 40 98 60 100 70 84 18 19 7 35 35 60 44 20 79 43 33 69 63 83 83 83 44 diff --git a/subset-sum/input/42 b/subset-sum/input/42 new file mode 100644 index 0000000..7bc81dc --- /dev/null +++ b/subset-sum/input/42 @@ -0,0 +1,2 @@ +455 6476 +50 98 73 26 67 41 50 61 21 7 64 92 5 72 96 6 20 5 44 10 13 42 9 98 80 52 26 32 25 95 19 16 35 69 59 79 53 78 91 58 32 42 53 77 63 25 2 41 70 54 64 31 76 36 33 98 17 80 94 29 56 94 72 62 29 96 70 80 73 97 10 98 45 51 8 34 87 22 18 67 93 98 34 87 32 65 26 33 2 59 7 57 20 44 63 39 85 78 91 12 41 32 25 53 95 96 43 57 99 14 75 72 13 50 89 26 13 46 12 28 37 29 69 76 45 62 90 28 14 47 41 55 23 38 78 23 66 52 56 84 49 12 69 32 59 49 41 77 87 61 75 82 93 11 33 46 76 50 67 20 68 99 64 21 69 16 28 25 63 43 7 14 57 83 52 71 62 51 95 79 10 88 92 32 6 52 34 60 92 94 93 43 96 67 64 83 70 40 64 62 89 70 18 64 97 48 61 98 10 52 2 52 43 55 70 28 28 76 92 89 85 25 16 65 1 90 53 15 7 80 20 58 4 55 31 96 91 65 95 20 83 65 2 28 93 68 93 4 44 47 7 65 23 27 33 35 47 12 60 7 42 59 70 94 16 80 69 20 74 81 58 41 86 73 71 12 88 29 6 91 77 86 40 1 15 97 63 36 46 58 60 43 58 89 5 84 86 93 8 7 38 8 26 18 70 52 10 71 13 41 44 85 87 64 78 19 100 2 66 16 54 46 5 61 91 47 25 54 89 12 13 37 91 82 88 94 31 78 6 37 23 36 7 75 22 77 21 69 18 62 82 43 52 74 67 3 53 20 27 71 81 51 70 11 54 64 23 85 29 88 3 7 66 62 19 40 31 97 13 91 49 93 79 6 99 74 23 68 89 36 2 92 70 89 33 88 58 73 43 35 69 4 25 51 2 48 24 84 77 85 55 47 62 19 38 56 51 84 72 92 74 47 66 15 69 58 22 8 71 81 33 96 78 60 53 19 12 29 7 71 32 12 78 75 79 29 78 77 57 58 30 4 96 34 75 diff --git a/subset-sum/input/43 b/subset-sum/input/43 new file mode 100644 index 0000000..0476680 --- /dev/null +++ b/subset-sum/input/43 @@ -0,0 +1,2 @@ +394 383 +55 79 31 78 44 79 41 40 96 13 38 66 61 67 38 93 14 86 78 79 22 92 41 56 23 22 42 19 32 42 25 77 58 26 38 82 63 95 13 79 62 51 69 58 65 64 71 90 35 51 52 3 67 74 25 76 75 10 97 24 73 6 34 32 13 82 16 23 17 48 64 96 52 83 58 40 96 47 64 69 64 54 17 60 70 50 88 5 42 64 58 98 89 23 99 47 12 75 61 73 82 23 55 50 57 79 95 14 46 62 33 10 28 10 78 91 9 79 34 75 45 32 14 21 53 77 83 16 73 86 13 28 46 6 68 1 17 21 35 94 39 3 56 59 63 7 54 87 95 53 91 31 35 28 34 37 88 37 18 94 30 6 29 97 62 43 61 21 77 64 59 43 39 94 15 62 61 73 17 53 100 85 68 80 48 78 29 91 42 74 72 73 58 91 71 91 73 78 78 59 68 97 17 49 59 77 89 66 3 33 4 7 61 34 88 2 36 65 99 98 27 84 10 42 41 13 66 54 11 89 13 30 90 46 79 37 90 58 42 15 20 70 41 67 8 16 63 98 88 29 25 74 60 15 91 96 52 44 35 71 69 58 16 26 83 69 80 14 4 40 75 93 48 68 50 80 8 27 1 2 39 18 62 75 32 48 59 27 89 37 83 84 97 8 82 51 40 17 49 56 46 99 63 41 67 95 86 7 78 12 23 68 1 89 82 10 55 30 58 71 30 3 83 59 33 15 27 74 84 82 12 75 26 96 66 94 18 76 6 42 63 37 95 84 51 93 33 94 21 1 93 17 75 18 22 3 44 79 40 54 23 9 19 91 90 89 84 36 40 78 5 91 72 24 60 48 91 94 23 83 7 45 23 20 30 43 57 89 79 69 95 79 29 93 diff --git a/subset-sum/input/44 b/subset-sum/input/44 new file mode 100644 index 0000000..7df0d91 --- /dev/null +++ b/subset-sum/input/44 @@ -0,0 +1,2 @@ +485 2715 +42 16 38 63 81 77 79 77 60 49 59 98 11 61 37 70 7 7 28 96 5 85 78 16 84 4 38 97 7 30 75 52 96 81 82 100 25 17 56 52 3 70 30 97 95 8 46 1 88 74 53 21 19 96 15 52 5 96 5 69 75 72 43 5 58 94 55 38 33 75 92 49 38 33 95 9 77 13 3 66 67 42 96 15 16 24 59 77 73 65 70 50 79 36 91 82 91 57 74 81 88 70 92 35 20 9 89 63 75 44 82 20 69 59 83 19 85 17 39 3 9 88 91 36 15 5 11 45 99 5 84 14 54 30 67 78 1 86 13 21 72 15 37 16 35 10 1 40 28 52 81 99 68 56 3 59 61 83 97 61 98 70 30 47 56 100 53 54 69 49 85 77 80 68 99 52 84 38 43 71 27 48 91 84 37 25 14 64 7 22 47 42 37 16 59 90 36 86 43 12 69 89 87 27 91 58 24 46 77 11 35 50 30 93 32 34 99 72 1 18 84 87 47 17 67 60 72 38 32 18 95 95 75 74 29 5 82 17 45 73 24 25 7 75 35 80 32 2 79 67 74 69 85 96 16 24 36 49 71 84 51 3 75 79 85 80 71 1 4 53 84 82 7 29 31 29 80 84 92 86 51 72 55 33 44 3 15 37 97 71 90 47 54 82 82 16 43 32 11 6 81 91 83 35 41 25 17 80 12 77 71 80 78 18 39 31 59 36 38 92 17 43 44 71 15 21 97 19 47 80 75 28 6 50 78 38 15 36 47 1 75 99 9 72 100 94 59 66 45 49 12 91 92 24 21 32 84 2 55 87 59 78 46 72 81 14 47 83 67 23 12 7 58 83 90 16 73 90 10 70 50 36 5 56 10 10 38 66 12 8 12 84 66 10 29 68 16 96 80 56 15 4 80 30 43 55 39 54 98 64 80 95 15 80 81 98 55 49 82 26 16 76 88 38 4 50 98 42 90 38 40 31 86 57 71 14 64 57 71 57 22 95 33 6 19 34 85 13 64 93 17 43 22 36 87 46 94 92 91 30 72 38 75 82 61 53 18 20 29 97 86 1 85 28 57 74 58 80 12 2 92 91 23 69 20 diff --git a/subset-sum/input/45 b/subset-sum/input/45 new file mode 100644 index 0000000..fe628fc --- /dev/null +++ b/subset-sum/input/45 @@ -0,0 +1,2 @@ +50 7624 +22 39 87 7 82 73 63 82 8 66 33 68 66 48 57 52 38 59 58 13 47 64 68 42 4 63 70 36 60 77 13 16 45 35 43 27 24 4 50 32 30 15 74 57 35 67 63 58 81 25 diff --git a/subset-sum/input/46 b/subset-sum/input/46 new file mode 100644 index 0000000..7b9eb12 --- /dev/null +++ b/subset-sum/input/46 @@ -0,0 +1,2 @@ +136 4587 +13 70 53 83 99 50 46 77 65 74 78 17 48 98 57 41 35 72 98 57 66 63 29 41 8 41 26 42 45 98 5 22 77 14 59 60 71 35 16 29 15 85 15 30 45 21 8 91 19 98 79 93 11 46 49 57 10 90 30 71 90 46 46 36 10 91 67 84 41 68 10 17 74 72 90 77 74 38 44 44 69 68 61 52 57 49 35 8 74 55 76 74 1 89 89 37 92 42 28 79 3 25 74 7 27 58 26 60 49 83 77 9 95 57 40 55 16 67 45 30 63 82 66 4 8 88 81 17 27 40 22 57 39 84 44 1 diff --git a/subset-sum/input/47 b/subset-sum/input/47 new file mode 100644 index 0000000..2d67233 --- /dev/null +++ b/subset-sum/input/47 @@ -0,0 +1,2 @@ +208 6358 +32 14 58 72 52 16 87 73 97 45 69 8 1 40 6 17 6 90 81 42 22 44 20 38 5 47 41 91 26 2 87 32 14 20 75 75 35 55 29 60 71 54 79 16 26 32 73 80 20 23 88 83 64 34 34 27 94 32 91 97 50 18 67 16 66 29 74 10 60 21 7 7 2 3 58 16 5 36 70 85 86 80 7 80 36 40 69 80 28 24 71 66 11 98 17 55 19 37 54 24 67 55 3 73 38 63 30 11 88 59 44 54 38 95 84 87 93 25 97 3 35 55 76 70 9 77 36 2 78 44 68 57 66 39 100 10 32 50 76 77 53 22 35 10 31 82 90 38 23 89 23 30 67 46 46 74 33 91 27 55 41 62 58 2 79 51 30 39 79 52 31 54 7 12 52 21 77 80 29 96 14 93 98 100 61 52 46 13 73 8 89 92 74 88 10 30 57 78 86 62 67 94 79 83 39 20 38 48 diff --git a/subset-sum/input/48 b/subset-sum/input/48 new file mode 100644 index 0000000..e6061a4 --- /dev/null +++ b/subset-sum/input/48 @@ -0,0 +1,2 @@ +105 1300 +5 30 47 36 78 9 39 41 87 87 83 57 67 20 80 1 3 69 56 21 54 33 1 86 84 55 47 89 21 54 1 18 91 2 61 6 27 62 83 9 89 65 63 8 7 40 12 77 94 87 57 46 32 67 91 34 59 30 25 36 25 99 39 2 98 74 40 47 6 18 97 73 92 30 31 91 8 22 24 1 49 84 55 15 60 5 51 2 47 100 64 67 67 71 99 49 22 93 17 55 26 57 47 48 80 diff --git a/subset-sum/input/49 b/subset-sum/input/49 new file mode 100644 index 0000000..29fd724 --- /dev/null +++ b/subset-sum/input/49 @@ -0,0 +1,2 @@ +446 169 +78 70 4 10 91 62 45 2 43 12 18 45 12 24 74 5 73 29 46 79 35 72 20 10 63 99 55 43 70 86 45 48 31 77 37 89 25 36 65 10 55 78 58 11 26 22 95 70 78 70 5 1 9 35 42 69 82 49 61 48 52 33 15 96 64 6 58 22 86 67 65 100 41 21 5 67 95 14 19 21 62 99 95 12 2 67 86 65 92 77 66 55 64 53 1 9 80 48 97 76 11 48 87 74 55 1 55 92 7 79 94 57 22 17 96 64 18 40 75 99 6 34 22 46 92 75 78 96 51 59 80 98 47 34 13 74 52 11 89 82 99 25 21 99 93 5 81 38 61 74 94 21 78 80 69 71 15 10 30 100 78 52 10 19 14 77 58 76 49 93 10 69 29 77 18 57 23 78 93 21 28 46 77 97 66 47 80 17 82 90 14 45 80 13 100 52 72 37 90 42 52 89 74 34 44 5 52 97 68 65 40 81 78 3 23 87 50 80 21 32 67 87 8 48 73 92 8 7 25 83 18 66 15 71 41 72 1 47 32 98 17 48 78 50 27 61 52 61 68 42 10 73 68 6 62 20 73 100 28 98 98 38 61 27 29 81 12 67 93 50 80 92 21 1 23 72 7 13 96 5 2 1 99 59 40 49 12 81 37 70 75 56 10 54 19 33 67 97 90 100 21 7 98 88 60 39 60 100 47 1 28 14 99 29 34 78 36 94 68 47 80 32 2 26 41 63 72 17 75 22 67 61 56 68 80 41 59 30 36 57 65 67 59 32 71 43 65 66 34 93 100 98 18 28 79 26 76 46 84 74 83 72 68 32 74 3 22 23 76 95 31 3 16 22 29 19 59 30 11 32 52 28 15 75 7 58 12 66 73 26 20 100 86 84 47 25 76 11 86 82 73 85 70 31 17 39 10 92 45 50 16 99 93 73 49 45 51 68 100 61 10 67 23 39 48 16 82 34 33 61 74 27 69 84 48 76 49 85 67 82 7 43 77 35 82 43 diff --git a/subset-sum/input/5 b/subset-sum/input/5 new file mode 100644 index 0000000..921b94d --- /dev/null +++ b/subset-sum/input/5 @@ -0,0 +1,2 @@ +10 2 +100 100 100 3 3 3 3 3 3 2 diff --git a/subset-sum/input/50 b/subset-sum/input/50 new file mode 100644 index 0000000..6e5f63e --- /dev/null +++ b/subset-sum/input/50 @@ -0,0 +1,2 @@ +498 6299 +59 40 28 40 86 33 74 28 30 70 85 13 1 55 21 1 33 88 33 18 61 12 11 29 57 30 81 12 77 78 91 17 26 49 98 65 54 37 15 33 27 98 86 73 96 71 24 96 4 46 61 57 60 28 22 61 13 86 8 27 80 31 51 30 69 95 48 15 53 25 84 92 39 38 71 26 62 49 9 60 37 48 80 5 15 69 36 59 93 23 74 90 66 13 2 1 74 86 97 26 15 19 76 9 10 72 83 16 12 15 82 94 71 56 43 55 88 8 14 74 44 77 8 59 36 40 45 6 91 63 18 66 36 27 71 74 93 83 82 32 85 71 46 77 15 46 85 54 1 72 11 54 90 21 57 54 64 88 11 55 63 85 49 16 76 15 42 97 51 51 92 69 46 48 22 1 91 68 22 34 53 77 39 3 48 70 77 69 8 61 36 22 46 68 80 47 64 13 96 17 100 85 90 79 77 18 8 6 34 44 23 80 21 72 35 74 28 28 96 78 40 76 52 10 65 37 70 7 75 92 69 98 24 79 63 31 72 41 38 21 100 5 11 71 79 27 57 34 52 47 35 92 58 68 75 15 27 78 20 40 13 69 25 33 76 63 79 71 58 18 99 25 37 64 38 87 53 100 11 59 48 72 96 100 24 82 66 30 44 25 76 91 7 82 32 17 87 53 23 53 83 64 44 34 26 83 52 60 26 59 96 22 34 46 69 76 76 92 96 41 8 57 64 3 15 53 95 42 61 75 57 32 96 31 67 12 78 88 57 79 46 46 25 37 72 97 54 10 29 48 17 50 56 23 99 80 67 77 41 40 26 35 11 41 95 27 38 80 61 14 66 70 14 19 12 26 97 25 29 9 48 49 82 65 74 21 26 74 78 63 86 76 43 8 100 67 86 85 60 57 51 41 42 35 65 53 7 60 1 87 24 93 79 19 85 64 24 53 27 90 5 69 27 68 71 66 93 42 17 40 25 51 73 98 45 14 87 100 1 12 80 50 18 83 17 67 48 65 22 31 56 59 51 53 3 46 10 6 100 86 10 32 50 58 26 100 24 77 20 56 35 72 91 54 80 6 46 79 79 47 6 25 60 1 28 42 26 2 32 78 15 63 95 65 70 43 70 71 diff --git a/subset-sum/input/51 b/subset-sum/input/51 new file mode 100644 index 0000000..e195137 --- /dev/null +++ b/subset-sum/input/51 @@ -0,0 +1,2 @@ +10 2017 +53 74 64 86 29 3 84 50 34 53 diff --git a/subset-sum/input/52 b/subset-sum/input/52 new file mode 100644 index 0000000..57b5a0d --- /dev/null +++ b/subset-sum/input/52 @@ -0,0 +1,2 @@ +456 9537 +34 97 72 68 48 64 88 14 98 72 6 38 43 36 77 5 98 51 27 28 9 85 15 54 70 62 76 15 78 17 77 54 13 14 18 29 35 60 46 8 63 40 35 2 14 16 67 12 92 85 67 83 36 49 91 50 75 2 67 6 53 45 81 100 91 84 92 99 94 29 62 59 51 76 8 79 33 93 65 60 10 51 74 32 42 35 53 12 71 63 57 66 47 95 44 63 69 87 73 46 92 31 70 43 42 90 56 13 47 59 86 34 95 3 5 89 20 33 51 59 26 21 35 3 96 78 42 7 82 48 50 70 9 22 66 9 77 89 51 13 84 19 74 88 72 45 15 96 4 53 76 7 80 25 76 61 81 94 28 5 86 38 29 88 18 67 48 24 55 41 49 70 84 28 89 1 36 67 40 21 25 99 68 24 49 34 20 81 93 64 25 56 17 1 56 27 17 77 62 20 56 27 95 76 23 14 12 90 19 95 37 58 44 49 47 23 30 52 71 81 72 91 93 92 80 65 90 75 56 20 59 41 96 17 4 24 90 22 46 85 49 36 73 13 38 45 30 87 62 31 54 27 54 7 89 69 65 83 28 28 10 4 27 40 76 69 76 92 36 78 95 64 42 86 12 1 32 6 52 44 21 92 79 59 60 88 52 99 43 54 48 95 76 50 87 3 35 87 64 50 5 40 31 25 31 58 86 94 65 40 57 74 100 38 85 27 25 86 13 63 67 82 96 79 53 57 26 37 1 25 66 18 66 39 83 48 99 79 43 5 10 23 65 90 30 29 21 81 13 26 23 84 6 60 87 40 41 25 48 51 10 53 48 38 90 80 82 83 58 13 16 37 69 96 73 87 19 61 44 96 84 23 55 58 9 58 90 34 40 98 85 6 39 94 77 84 97 33 84 32 100 36 56 10 96 34 36 65 79 11 51 69 7 70 39 10 55 54 27 10 6 13 46 47 19 52 86 23 75 8 85 42 10 13 56 36 94 25 90 9 66 2 41 10 65 37 34 50 9 32 20 11 4 24 9 1 diff --git a/subset-sum/input/53 b/subset-sum/input/53 new file mode 100644 index 0000000..6f1ca0b --- /dev/null +++ b/subset-sum/input/53 @@ -0,0 +1,2 @@ +454 4503 +90 39 61 36 2 34 83 19 10 23 56 30 11 89 57 38 87 21 34 38 4 24 97 86 72 5 1 86 48 80 88 8 65 40 9 54 89 82 99 18 100 12 88 4 40 95 79 51 43 85 66 96 34 52 5 90 28 76 89 100 31 73 42 14 19 83 53 84 1 52 75 30 25 82 80 79 60 50 20 22 67 86 42 15 86 96 40 15 2 61 1 79 100 39 59 77 48 15 1 24 75 19 65 96 97 61 51 7 83 43 53 14 74 57 89 68 50 98 38 45 60 91 23 40 29 86 87 94 25 48 35 29 100 40 35 66 41 98 81 8 98 56 4 15 24 13 71 41 21 9 96 8 77 30 33 18 73 10 82 8 21 3 93 84 89 41 8 22 59 8 95 95 75 35 43 89 38 98 44 9 28 29 25 61 30 10 34 14 56 4 9 87 56 78 70 24 9 40 73 100 33 11 80 23 64 35 86 97 3 28 89 45 82 3 53 99 94 12 31 30 71 99 95 11 38 43 90 32 41 40 8 98 3 79 16 80 72 77 31 18 27 12 65 6 99 45 76 46 32 39 19 88 9 47 60 4 76 14 62 51 91 62 91 26 51 68 87 31 4 28 44 36 18 57 4 17 43 13 47 14 75 63 58 39 30 48 12 43 9 37 36 14 53 84 14 35 83 47 98 50 74 11 16 79 49 87 23 21 90 67 24 88 100 45 8 96 34 26 92 3 5 38 90 19 90 44 27 93 50 79 72 35 32 29 95 12 63 34 64 82 1 73 1 39 89 83 41 85 62 34 15 96 89 80 32 53 67 33 16 1 44 80 77 61 78 23 14 74 48 35 69 77 75 93 66 47 88 67 78 76 52 19 9 43 67 91 28 84 34 4 68 30 38 63 65 33 66 63 47 33 48 20 9 13 36 22 21 9 68 64 30 44 74 82 98 35 81 47 96 16 37 87 23 88 46 59 61 66 82 44 8 93 4 71 1 10 49 72 24 71 18 99 13 61 20 69 23 56 75 41 27 30 3 84 diff --git a/subset-sum/input/54 b/subset-sum/input/54 new file mode 100644 index 0000000..ebbc3fd --- /dev/null +++ b/subset-sum/input/54 @@ -0,0 +1,2 @@ +201 801 +78 96 51 80 64 18 73 51 42 100 51 68 28 31 62 63 68 38 88 8 20 78 2 6 87 52 61 61 81 38 63 56 62 50 62 99 43 57 80 30 72 77 53 16 67 24 99 76 72 27 9 12 64 40 94 81 35 24 71 29 57 57 36 62 76 38 15 19 24 38 15 30 30 68 98 56 62 74 60 51 77 69 54 25 51 55 88 2 34 78 48 46 1 22 60 17 66 50 19 53 81 28 29 7 14 36 67 22 75 61 16 35 24 29 70 91 81 4 58 84 24 44 80 89 60 24 43 17 59 80 79 52 81 47 90 14 70 6 14 78 32 82 43 52 79 85 90 83 75 54 82 51 81 68 67 93 22 27 22 70 67 48 90 68 84 91 47 90 17 12 69 46 100 68 57 66 28 91 37 24 8 5 47 28 54 77 13 30 32 19 8 57 55 32 29 6 74 45 2 87 51 diff --git a/subset-sum/input/55 b/subset-sum/input/55 new file mode 100644 index 0000000..4f100ac --- /dev/null +++ b/subset-sum/input/55 @@ -0,0 +1,2 @@ +124 2636 +36 95 39 23 21 66 42 67 62 24 61 22 34 22 84 75 72 61 61 97 81 73 18 86 68 40 64 5 65 85 89 5 47 78 51 83 78 6 83 24 49 51 54 85 25 89 92 28 20 49 64 34 75 91 53 55 8 45 32 20 21 82 3 33 11 83 48 23 20 62 84 56 66 17 97 82 97 39 13 93 33 88 100 25 21 13 29 27 74 45 78 13 90 90 87 57 85 92 19 79 51 4 47 96 72 91 89 11 18 13 55 64 67 15 9 80 77 53 31 87 4 8 16 74 diff --git a/subset-sum/input/56 b/subset-sum/input/56 new file mode 100644 index 0000000..e1f8431 --- /dev/null +++ b/subset-sum/input/56 @@ -0,0 +1,2 @@ +432 3243 +4 5 16 68 23 49 11 15 19 23 27 72 55 100 57 14 26 55 82 29 8 38 54 17 29 61 88 27 64 62 35 84 22 71 96 48 96 75 49 92 85 21 31 65 53 47 97 6 43 25 47 82 84 52 8 8 45 27 49 37 73 21 72 2 57 21 69 47 7 100 100 45 51 87 25 96 57 50 86 98 21 30 37 86 89 16 68 70 19 72 35 62 44 19 98 83 74 29 43 49 38 4 64 64 11 95 95 51 82 12 5 28 28 99 64 74 15 24 49 40 97 80 58 78 71 41 69 63 100 94 39 46 75 96 94 44 40 19 80 9 48 14 73 90 92 74 69 21 59 20 43 32 69 72 23 18 96 26 17 19 55 53 64 46 46 7 64 2 23 10 37 38 68 46 58 48 26 1 38 51 100 98 22 80 6 95 53 77 35 18 31 85 59 84 6 82 45 45 56 100 22 45 84 23 93 66 80 40 93 32 9 60 22 8 23 4 36 9 28 79 18 62 26 67 53 34 42 5 50 10 61 57 27 23 83 55 19 77 67 44 77 69 49 1 37 41 12 58 40 86 57 25 75 37 22 29 75 43 7 59 88 23 100 9 61 100 68 26 6 84 88 11 83 14 39 1 98 25 56 32 56 79 6 93 53 55 55 97 91 87 61 5 71 91 88 64 57 68 99 84 6 1 82 85 73 74 77 4 64 92 88 25 98 95 5 89 32 36 30 5 29 83 60 45 32 66 92 23 17 11 90 77 56 14 89 94 5 1 17 6 7 35 69 37 86 74 6 24 96 16 37 100 91 62 81 1 49 96 3 77 59 94 23 26 39 6 6 23 43 40 6 76 95 21 84 73 30 84 55 59 10 36 43 99 91 100 14 73 84 73 70 86 18 32 41 58 60 38 8 51 13 78 5 24 81 70 24 83 68 54 98 32 17 75 21 12 56 21 65 15 40 94 31 6 23 45 41 9 9 96 95 54 diff --git a/subset-sum/input/57 b/subset-sum/input/57 new file mode 100644 index 0000000..8ef2bd4 --- /dev/null +++ b/subset-sum/input/57 @@ -0,0 +1,2 @@ +797 2240 +32 53 4 46 14 1 67 18 98 45 77 61 29 29 15 50 14 93 26 50 45 62 85 38 49 4 12 98 99 33 90 91 93 36 20 82 68 79 71 11 19 54 26 71 85 41 78 26 75 22 81 90 36 69 83 17 7 26 64 19 52 42 96 94 51 87 81 1 92 27 5 58 49 61 73 24 88 56 63 97 98 2 29 12 96 75 32 100 26 43 89 48 51 59 31 61 63 48 36 19 5 27 92 84 73 16 49 72 31 47 53 95 86 62 74 74 62 72 25 46 18 95 44 47 99 63 8 15 36 53 87 9 59 22 12 14 22 26 26 75 4 41 100 61 75 64 72 95 53 41 12 44 4 15 36 62 12 91 66 8 29 86 5 37 39 52 65 3 68 95 84 9 25 26 89 26 14 50 60 43 29 25 11 37 83 57 81 28 71 22 61 49 37 61 15 89 36 50 55 80 16 7 68 39 9 58 15 18 82 95 25 91 91 8 57 73 35 31 27 70 7 7 70 49 57 88 55 56 62 62 63 15 69 19 33 76 53 62 30 37 3 52 75 54 29 98 55 64 80 29 6 10 64 5 15 100 11 26 39 23 1 18 8 54 63 58 31 44 35 44 98 96 53 20 3 80 29 88 55 46 23 81 19 26 6 33 90 34 46 60 2 76 78 30 18 32 62 4 11 64 85 67 28 26 16 15 72 29 58 17 76 52 67 37 69 21 21 97 3 64 34 88 85 57 35 84 38 6 42 45 51 47 94 20 23 23 69 61 10 62 97 73 26 5 100 92 85 24 94 60 16 56 31 72 25 30 90 74 31 58 16 34 29 69 55 12 87 47 99 50 53 29 8 36 69 81 42 62 45 21 52 30 11 16 82 51 11 57 3 91 61 82 39 82 96 2 22 44 52 51 99 79 41 4 89 95 14 61 42 40 35 86 7 91 15 56 66 66 98 68 40 67 88 21 51 33 61 98 89 71 75 18 55 27 47 47 100 41 36 51 19 61 10 94 24 24 20 6 71 95 19 38 75 31 80 23 13 75 62 46 27 18 62 24 13 58 74 76 87 54 59 13 97 1 10 90 14 84 42 88 17 88 100 87 83 98 22 9 91 37 89 29 73 31 99 65 52 81 50 85 44 30 83 50 68 72 4 96 89 87 74 49 37 64 47 83 25 60 69 70 35 70 94 71 69 52 34 50 72 82 96 53 74 46 25 71 5 91 87 10 69 42 35 73 50 48 11 51 43 57 94 6 100 30 63 73 37 48 33 62 34 63 6 28 25 73 56 59 99 28 23 43 86 79 61 93 84 18 21 14 67 21 35 89 15 26 78 45 12 83 66 5 56 60 30 95 69 87 92 18 46 65 12 28 69 24 53 43 71 12 19 48 72 37 62 24 95 32 70 17 75 58 56 60 49 51 28 69 31 48 9 52 98 98 6 55 73 64 1 93 48 61 7 97 10 96 58 38 60 18 83 57 88 12 20 17 62 54 78 34 78 77 92 41 16 1 82 98 10 96 35 87 18 77 56 86 6 10 71 43 34 31 77 75 33 57 8 18 28 88 6 26 30 41 40 58 86 100 51 32 73 75 98 43 53 89 3 62 63 48 50 63 33 44 13 21 53 21 70 30 8 21 39 70 72 16 53 22 6 94 62 57 65 49 63 43 61 100 82 53 5 81 29 35 50 99 22 46 61 85 45 42 41 33 37 1 18 42 11 45 24 75 57 30 78 42 41 2 79 98 31 88 16 25 50 65 24 50 76 42 27 48 57 8 67 33 73 23 22 36 27 40 18 4 22 86 12 diff --git a/subset-sum/input/58 b/subset-sum/input/58 new file mode 100644 index 0000000..87bc898 --- /dev/null +++ b/subset-sum/input/58 @@ -0,0 +1,2 @@ +534 3264 +84 50 95 5 73 73 36 17 16 47 8 23 54 53 78 3 18 39 100 89 16 3 21 24 9 94 68 100 41 59 50 80 18 10 52 77 86 70 18 32 17 84 90 64 48 94 87 78 11 40 30 79 56 82 41 66 22 59 7 3 99 8 9 21 99 60 100 81 90 41 60 21 49 1 30 86 94 59 28 70 80 22 68 54 100 29 84 53 58 18 29 44 1 58 87 64 11 94 87 79 70 70 93 91 73 24 18 61 4 14 35 99 75 21 37 59 27 38 39 38 94 81 99 38 10 73 72 84 90 78 25 34 49 83 81 26 28 21 2 38 32 65 70 26 30 30 9 45 2 57 33 40 13 6 59 65 50 42 29 61 24 95 67 47 74 42 25 23 91 30 84 67 52 39 9 66 20 19 4 12 3 72 74 55 79 64 35 1 85 4 73 76 30 38 44 72 84 50 96 92 56 53 14 2 71 45 42 19 54 38 82 84 32 13 46 31 52 12 75 51 4 43 20 31 43 97 92 75 92 99 14 35 37 73 7 6 73 21 15 25 2 71 68 89 24 7 82 61 40 36 29 49 38 63 83 4 87 6 55 71 100 42 7 56 17 18 83 28 55 33 55 5 74 80 81 36 99 78 69 52 44 74 67 13 7 52 24 58 67 100 86 40 83 62 43 53 49 4 46 98 83 84 54 5 21 55 33 96 82 90 71 40 55 81 60 95 67 47 81 78 70 100 32 91 69 39 59 20 79 4 65 98 63 39 37 12 16 67 33 21 52 100 12 57 85 5 12 97 19 31 42 75 88 16 37 11 70 41 14 32 57 93 19 23 2 8 75 47 90 88 51 44 29 35 29 60 79 43 28 81 34 8 69 64 29 90 13 28 19 9 84 77 10 75 4 34 65 85 60 39 58 71 29 92 81 95 73 72 27 34 75 10 72 31 8 24 94 33 77 62 3 70 66 84 34 87 44 10 35 52 88 33 23 51 35 41 45 80 92 53 79 38 29 96 49 51 98 32 25 30 67 50 74 16 7 16 74 91 52 2 4 85 24 44 34 56 15 87 91 71 42 83 30 59 42 68 46 88 35 38 24 48 30 7 64 91 95 53 9 93 79 29 76 46 7 33 41 58 95 46 13 59 44 91 25 90 82 89 18 66 11 65 79 46 31 77 94 24 98 35 95 97 21 36 27 65 5 62 3 65 74 95 15 8 diff --git a/subset-sum/input/59 b/subset-sum/input/59 new file mode 100644 index 0000000..dab1250 --- /dev/null +++ b/subset-sum/input/59 @@ -0,0 +1,2 @@ +553 2628 +55 30 50 79 13 57 19 61 84 51 19 40 19 21 40 62 4 13 38 9 2 33 2 69 16 54 76 1 43 51 69 82 92 91 21 58 87 6 70 38 49 48 11 45 15 28 38 43 9 75 7 43 12 71 91 37 36 72 17 8 51 42 56 53 52 97 44 31 53 72 32 33 9 75 90 31 35 81 71 89 93 94 47 74 21 37 98 22 88 3 94 29 98 47 59 18 43 37 57 100 90 43 14 69 100 47 85 18 73 98 79 56 60 94 2 82 86 85 93 5 11 32 82 94 100 62 41 64 74 50 82 63 50 16 2 90 47 48 10 86 55 69 39 97 98 47 65 8 58 98 64 13 37 18 77 65 34 1 18 71 84 32 38 96 33 18 50 1 57 66 43 28 64 9 46 67 60 62 90 23 5 17 25 94 86 49 72 38 11 10 14 87 69 11 93 17 44 9 77 4 58 62 23 39 77 10 16 30 68 26 15 3 79 80 70 40 67 65 58 23 43 4 94 65 98 40 40 92 98 17 36 21 86 31 99 55 29 1 33 70 17 15 7 28 28 37 86 88 79 27 99 10 78 63 61 44 85 69 98 52 35 58 26 96 1 29 25 8 23 41 17 27 60 34 39 47 61 75 98 61 2 45 83 62 69 11 11 24 76 1 99 73 3 1 86 67 84 8 95 47 34 38 73 26 62 54 41 67 17 79 60 67 72 53 18 31 22 25 24 54 66 57 47 96 67 85 51 56 98 49 8 87 59 60 36 66 36 90 99 24 36 91 26 14 42 79 73 38 72 44 33 8 44 34 38 16 2 94 2 42 75 83 21 32 84 80 18 63 1 13 16 19 7 33 79 59 87 17 35 21 92 56 61 16 69 93 61 33 4 17 97 1 20 58 72 46 72 69 16 98 26 64 45 66 25 28 95 40 91 13 12 50 23 29 56 49 13 89 23 27 57 28 35 97 76 14 87 26 75 99 33 74 41 13 44 79 90 53 95 36 46 2 13 56 22 76 2 24 48 63 57 47 18 77 20 83 3 84 37 31 5 38 5 27 44 35 31 17 2 6 14 92 93 36 36 60 60 40 64 87 10 81 77 35 54 32 60 82 93 67 26 17 83 34 92 25 90 14 78 1 25 33 8 45 3 48 95 57 30 73 61 92 44 53 85 73 73 55 20 70 90 19 63 8 20 96 66 73 44 75 47 53 92 25 5 20 52 81 14 47 42 92 69 50 97 82 56 29 59 24 23 44 75 diff --git a/subset-sum/input/6 b/subset-sum/input/6 new file mode 100644 index 0000000..cfaf498 --- /dev/null +++ b/subset-sum/input/6 @@ -0,0 +1,2 @@ +8 4575 +26 45 72 81 47 29 97 2 diff --git a/subset-sum/input/60 b/subset-sum/input/60 new file mode 100644 index 0000000..4d7b8f8 --- /dev/null +++ b/subset-sum/input/60 @@ -0,0 +1,2 @@ +416 6012 +33 68 11 24 93 56 8 28 55 74 91 18 72 96 75 47 2 6 27 32 22 37 21 66 89 29 38 45 82 43 83 98 42 19 24 1 19 4 79 76 18 23 45 61 82 100 30 32 78 33 84 35 46 25 76 84 35 82 53 31 94 79 75 28 6 26 45 29 35 39 23 83 91 40 9 29 100 15 78 16 36 91 70 37 88 95 61 20 26 78 78 47 99 25 44 14 18 60 96 25 95 41 53 97 9 39 58 39 96 89 56 71 79 81 34 14 51 41 79 41 46 17 79 15 90 39 67 31 76 33 92 72 21 79 40 59 99 18 37 96 81 34 71 17 71 54 87 42 52 70 74 4 84 84 78 30 50 64 34 35 54 34 85 74 80 48 56 36 56 81 88 33 95 75 84 31 77 46 89 86 13 87 59 26 7 78 7 73 95 48 91 62 18 37 68 39 48 72 13 80 49 78 5 61 67 55 41 28 24 9 4 17 64 71 81 44 31 19 8 47 37 68 73 61 4 44 32 96 62 47 63 3 24 63 3 69 68 86 44 44 43 7 40 79 32 18 48 53 48 11 99 52 60 2 41 43 66 34 81 23 20 34 51 98 4 75 19 99 18 29 44 56 85 33 6 44 90 88 40 93 15 99 95 64 45 88 25 24 54 92 99 6 68 80 4 20 21 66 71 89 73 38 41 27 7 26 13 29 68 69 18 41 18 73 24 75 27 70 31 28 95 93 15 33 6 5 46 53 83 13 69 22 10 91 4 41 43 35 9 81 96 82 65 100 87 20 91 2 62 2 2 28 78 81 64 90 48 81 86 61 51 6 96 38 28 83 7 14 56 70 98 76 13 2 53 74 22 9 62 72 51 22 99 39 41 76 46 43 92 17 86 25 36 19 73 50 11 95 16 6 42 65 33 58 88 17 2 27 5 54 71 25 56 13 48 25 diff --git a/subset-sum/input/61 b/subset-sum/input/61 new file mode 100644 index 0000000..e2ef363 --- /dev/null +++ b/subset-sum/input/61 @@ -0,0 +1,2 @@ +890 2306 +33 11 25 27 60 88 50 32 86 13 3 21 67 82 26 55 37 56 7 68 69 28 86 37 50 13 51 55 95 14 100 80 65 38 39 90 56 90 21 71 25 23 65 59 90 1 10 52 66 61 80 93 93 31 8 65 81 33 11 21 52 51 76 33 23 37 59 83 80 56 42 34 25 16 3 88 79 3 76 37 69 57 2 26 30 2 63 31 90 28 13 54 25 46 84 85 66 98 63 3 38 64 96 20 75 21 28 69 29 45 12 53 36 20 66 34 12 17 92 61 40 42 40 22 24 54 34 76 31 63 14 83 69 96 79 49 25 89 97 100 28 65 80 40 81 43 6 26 72 58 18 29 91 80 79 89 19 88 57 71 72 92 61 94 57 47 64 42 81 32 7 79 45 73 70 70 31 57 40 21 64 63 61 74 96 76 65 67 89 86 26 49 75 15 97 81 46 22 61 29 54 86 51 81 63 9 93 64 91 2 76 63 51 47 53 65 69 52 87 61 95 6 87 42 35 2 3 38 21 23 52 60 53 88 88 43 66 39 41 92 36 46 16 12 90 50 67 71 28 36 51 74 7 54 26 51 56 80 26 75 57 64 8 19 64 8 71 19 46 45 94 52 85 46 58 88 34 65 13 33 29 22 72 74 16 14 70 10 51 93 66 15 34 16 46 68 41 36 6 75 88 58 45 16 93 17 20 56 76 23 17 18 50 84 18 90 98 100 44 25 23 38 84 87 41 100 8 53 99 48 71 94 46 34 53 14 93 7 53 95 35 44 15 83 97 81 53 5 17 10 98 55 76 41 19 29 80 30 80 13 59 78 81 57 94 1 90 20 43 84 6 9 4 100 53 86 21 77 26 99 10 67 70 53 38 4 23 91 81 100 6 56 43 88 4 79 52 80 85 33 26 97 41 83 97 36 13 61 46 48 68 4 32 8 91 45 6 11 52 64 52 78 60 54 85 1 13 67 66 30 29 49 22 21 80 55 68 6 14 91 81 59 19 85 95 43 69 25 22 72 38 8 71 82 4 44 28 81 67 32 82 63 22 45 71 28 14 59 8 20 44 1 80 53 88 64 95 62 29 77 13 77 58 72 76 94 41 77 89 69 34 63 95 76 36 80 98 70 80 30 2 34 88 53 97 38 5 19 53 76 6 7 24 33 19 59 86 77 95 61 62 48 94 86 89 20 63 30 6 20 48 21 36 42 29 53 16 15 84 2 4 6 100 5 68 32 77 77 69 7 6 57 97 54 28 51 89 42 64 51 11 65 13 7 68 34 83 88 55 2 81 67 64 10 19 74 74 7 17 62 5 56 71 12 1 31 99 81 74 13 18 12 10 9 55 28 85 37 78 19 100 17 90 92 29 22 76 94 5 40 86 27 7 53 1 58 71 60 31 81 100 90 89 80 89 56 58 56 83 99 63 64 94 55 29 24 4 21 14 29 42 5 8 47 18 73 88 99 77 24 52 45 19 19 18 87 70 99 43 7 67 97 4 37 53 17 93 63 12 3 97 20 79 2 7 6 98 100 68 99 33 43 99 16 87 11 71 21 44 17 41 70 28 62 27 57 66 45 34 78 73 65 33 58 98 21 51 76 56 78 58 71 14 1 18 66 33 42 90 74 76 66 60 96 70 66 20 25 47 93 96 68 71 50 39 35 26 4 21 22 3 8 93 46 69 83 24 59 92 29 47 3 80 95 12 5 29 49 81 43 22 21 96 93 43 94 38 39 99 98 20 90 42 85 69 20 28 59 42 92 40 22 24 67 78 18 14 2 74 96 76 93 3 91 21 13 96 93 6 79 30 35 85 54 40 41 62 30 41 83 25 64 78 43 31 3 26 81 93 85 20 5 52 78 40 41 51 88 58 4 39 26 98 64 22 42 86 72 53 83 35 55 66 99 21 40 39 13 26 19 33 100 63 82 29 39 43 30 35 67 18 98 62 60 67 35 9 64 10 7 1 67 87 17 100 89 9 67 32 91 96 41 18 94 83 23 96 74 87 30 diff --git a/subset-sum/input/62 b/subset-sum/input/62 new file mode 100644 index 0000000..b516609 --- /dev/null +++ b/subset-sum/input/62 @@ -0,0 +1,2 @@ +239 2496 +30 59 78 94 29 34 77 42 3 53 74 70 67 99 40 83 74 74 79 96 35 25 21 84 37 90 92 1 80 53 89 54 60 27 91 2 81 5 22 99 77 10 53 96 57 72 92 56 81 84 74 52 51 49 29 25 28 89 17 7 7 80 56 7 71 35 85 86 89 90 73 80 13 67 40 26 84 97 34 48 68 85 71 60 72 24 50 17 40 91 19 73 66 58 49 87 36 74 73 61 35 63 24 35 5 62 33 31 65 68 21 15 13 33 82 99 91 43 100 36 45 28 75 73 47 35 47 74 5 36 94 48 39 83 17 38 67 49 19 55 78 27 57 78 32 13 21 41 71 56 60 6 8 1 19 69 38 32 62 20 44 85 16 37 63 74 48 84 54 7 23 79 93 5 91 60 99 80 18 50 40 21 29 48 60 9 78 8 33 67 18 57 24 58 79 34 33 61 7 73 19 33 32 33 65 30 30 53 84 58 76 95 23 65 95 37 73 4 69 7 10 94 19 98 66 98 80 99 48 82 100 78 9 9 53 71 91 87 90 diff --git a/subset-sum/input/63 b/subset-sum/input/63 new file mode 100644 index 0000000..5e1b8bd --- /dev/null +++ b/subset-sum/input/63 @@ -0,0 +1,2 @@ +597 8633 +48 43 26 90 85 62 81 91 82 33 20 44 52 26 22 88 81 54 66 25 43 90 30 84 41 93 81 29 11 39 65 89 68 3 41 39 27 83 1 71 3 19 13 83 30 86 22 84 71 9 85 66 28 49 49 32 20 45 9 73 70 10 32 54 32 13 4 93 17 97 39 15 68 86 17 20 19 27 16 38 81 69 83 53 15 98 39 17 47 63 49 14 84 6 2 52 12 52 77 77 74 56 5 45 40 6 81 65 94 14 78 76 38 59 20 53 38 75 13 44 68 90 100 65 58 55 59 59 58 84 50 81 39 88 62 37 4 12 3 88 2 49 3 80 54 25 44 86 68 46 18 28 73 34 18 40 34 45 44 23 72 78 50 27 38 70 75 49 50 63 77 73 88 62 99 40 25 90 88 65 85 11 66 93 42 99 84 81 7 49 28 20 13 5 49 47 17 61 63 31 44 51 2 78 82 32 47 67 40 87 55 9 74 64 65 88 49 86 60 71 90 21 79 15 29 49 64 95 83 9 2 86 53 28 14 33 63 56 33 22 77 70 65 14 82 47 44 79 84 78 72 55 4 40 58 67 53 78 34 97 69 26 44 99 65 87 86 85 47 13 71 91 19 1 58 16 57 67 90 60 58 91 36 99 2 87 15 20 47 52 11 76 57 77 53 100 45 27 25 10 94 74 69 57 35 23 91 84 67 16 27 35 71 33 62 5 91 15 88 31 65 92 47 20 77 73 46 51 20 88 71 41 57 34 77 16 54 81 7 72 72 95 51 74 47 65 72 84 92 89 8 91 42 33 19 13 76 30 38 63 86 54 76 100 47 66 57 76 85 56 78 26 89 39 19 91 75 18 25 29 63 4 88 48 3 7 21 24 67 4 89 33 55 65 69 77 52 76 72 86 27 37 29 86 33 24 29 57 82 44 69 34 34 77 14 6 11 51 88 16 36 80 12 31 71 6 37 60 77 47 78 25 89 83 42 42 8 2 39 28 4 20 61 17 36 10 28 74 6 23 69 41 89 9 69 27 43 60 80 79 20 39 44 9 65 75 67 12 27 45 93 44 45 4 35 13 33 21 97 82 44 41 13 91 65 3 46 100 14 16 42 68 63 60 45 34 77 15 43 59 41 98 97 18 10 54 5 23 42 77 82 84 37 81 5 19 9 14 62 74 28 76 88 30 17 99 37 21 100 25 79 79 74 16 89 85 26 57 47 69 38 86 85 16 78 85 20 48 19 31 18 82 58 82 9 9 59 99 48 97 59 84 45 97 74 15 52 17 41 98 31 61 77 49 76 32 30 15 51 50 1 61 81 55 83 53 41 86 100 44 22 18 44 13 23 4 49 diff --git a/subset-sum/input/64 b/subset-sum/input/64 new file mode 100644 index 0000000..bee9a8f --- /dev/null +++ b/subset-sum/input/64 @@ -0,0 +1,2 @@ +720 4106 +35 19 3 39 42 3 97 10 54 41 30 92 26 78 88 7 33 23 57 16 15 32 3 96 92 89 46 1 60 56 34 60 93 81 86 86 9 57 30 28 57 92 18 81 74 95 37 60 20 70 7 27 34 59 42 45 36 85 21 41 61 10 29 73 13 34 66 72 56 62 96 100 25 69 28 57 80 10 6 44 37 13 74 65 31 45 3 41 85 1 73 21 80 47 77 17 15 78 36 13 97 26 52 60 3 74 78 96 92 25 57 64 99 58 22 74 60 51 38 17 27 7 39 24 68 36 78 56 37 2 95 70 47 45 89 67 34 27 94 31 4 75 77 39 58 11 7 86 47 92 65 20 51 21 97 98 41 28 77 23 85 76 34 10 75 80 99 42 46 6 56 1 58 25 3 61 26 12 53 26 91 40 46 86 79 10 29 59 99 91 93 33 22 50 88 37 51 37 22 19 3 85 74 46 41 13 41 31 12 11 69 29 12 39 96 67 53 22 2 52 19 9 6 14 36 31 58 60 45 66 23 60 65 91 38 90 25 17 25 99 83 34 82 3 54 30 79 56 88 42 93 100 75 94 65 66 87 44 42 90 44 75 28 85 29 4 83 94 10 80 26 95 3 84 29 28 46 56 31 11 13 57 16 51 65 35 85 18 12 91 91 67 57 22 64 84 2 73 17 12 85 91 33 90 8 1 56 49 51 9 53 26 42 63 5 85 49 31 10 65 90 42 73 3 18 25 8 47 57 20 80 58 37 92 16 1 87 82 89 77 9 66 76 21 45 76 55 39 73 74 96 39 41 96 16 38 29 83 5 76 12 63 17 4 78 85 41 3 22 94 47 36 21 49 76 94 49 25 11 16 59 13 56 56 94 30 9 57 17 72 48 6 33 41 55 44 76 89 11 40 48 77 58 58 98 56 6 3 11 73 15 96 6 7 64 69 96 11 51 15 35 93 56 62 23 79 82 20 16 1 27 40 74 59 71 12 68 87 92 75 21 68 45 8 42 68 26 93 98 18 78 28 45 1 30 86 26 88 23 19 45 11 63 59 49 13 69 73 39 24 44 6 21 26 60 46 96 80 18 36 91 82 26 21 57 48 12 1 19 60 93 53 43 25 85 46 46 85 36 57 51 9 57 25 14 20 36 20 59 59 2 10 80 36 80 77 30 70 40 75 72 39 40 47 67 86 88 100 80 29 88 76 1 5 96 94 69 21 78 21 59 46 44 88 71 54 19 48 25 88 81 12 52 41 4 8 91 71 37 41 72 97 9 75 32 44 72 60 4 33 21 2 36 100 83 28 39 7 19 38 8 33 87 61 48 71 37 4 25 2 54 14 56 83 32 5 36 22 9 12 57 88 61 42 91 69 47 28 24 95 37 67 9 13 79 9 61 32 4 75 60 45 81 65 10 69 8 78 54 52 95 51 20 19 22 12 87 10 21 12 63 26 75 96 83 68 92 80 88 64 88 54 69 39 29 24 93 94 62 42 41 13 66 6 27 33 85 31 20 14 7 42 42 81 75 64 63 11 82 18 68 96 77 35 79 17 95 26 22 38 4 54 49 73 23 76 40 10 21 76 74 57 31 84 91 67 68 51 19 12 17 24 97 54 52 36 30 85 29 48 diff --git a/subset-sum/input/65 b/subset-sum/input/65 new file mode 100644 index 0000000..fdfc626 --- /dev/null +++ b/subset-sum/input/65 @@ -0,0 +1,2 @@ +567 6369 +16 5 10 65 93 73 50 94 6 65 49 11 37 5 41 52 55 74 77 5 54 57 96 72 59 33 26 33 49 73 82 65 37 87 68 63 20 22 33 30 12 69 74 44 83 22 89 36 14 64 36 14 60 93 60 98 80 40 99 76 82 5 34 43 87 100 8 13 37 58 33 40 76 84 28 45 59 73 26 32 99 41 41 93 51 4 1 6 91 51 26 67 9 32 3 56 15 93 73 6 30 77 99 99 33 26 60 9 28 64 60 87 94 61 2 48 75 11 51 38 6 97 66 48 40 18 38 57 64 85 19 67 65 63 62 28 3 56 4 76 26 54 31 65 13 8 13 70 61 9 11 73 19 6 99 13 61 24 42 20 54 60 51 7 89 8 46 45 50 1 14 3 10 3 51 74 58 95 49 40 83 22 55 99 61 75 17 41 31 53 67 55 25 58 96 21 99 85 43 36 55 73 13 53 35 100 41 63 72 97 79 36 56 46 37 41 76 47 21 25 75 17 81 66 49 92 38 48 6 25 82 95 37 80 37 70 57 84 8 75 95 46 73 44 57 18 41 93 97 22 62 59 24 73 17 11 35 17 49 5 81 33 6 94 64 31 87 78 40 83 60 46 95 91 77 3 51 13 61 73 18 8 72 97 89 47 86 44 98 93 93 6 7 3 15 75 84 21 46 45 4 33 18 21 81 2 94 21 75 75 11 56 89 14 92 2 21 41 32 40 87 80 79 46 25 9 25 8 34 30 58 4 26 95 68 18 72 37 29 51 100 36 90 11 34 23 12 43 29 34 59 11 24 79 46 1 29 42 29 4 1 83 7 14 97 32 56 59 84 64 88 24 79 17 86 1 35 83 74 94 51 55 12 86 83 52 54 19 30 78 78 28 45 14 86 11 73 28 82 7 45 89 17 8 78 9 16 14 54 82 37 21 29 99 10 40 71 42 92 93 24 46 84 46 54 77 25 20 11 83 88 47 56 66 43 95 39 8 39 6 74 24 54 83 2 42 73 9 60 10 51 2 35 60 43 32 77 19 31 32 34 38 4 73 56 66 99 82 45 27 43 25 23 50 16 49 11 64 17 61 7 34 99 6 84 26 24 37 41 77 89 35 50 20 97 19 29 49 83 28 92 16 52 20 1 95 86 65 26 89 55 52 83 92 40 82 86 32 18 10 10 2 32 33 39 45 95 72 27 52 41 77 97 25 26 78 77 92 83 81 21 30 69 99 68 75 94 36 25 88 69 93 32 77 93 47 41 97 34 89 3 61 20 69 43 45 6 diff --git a/subset-sum/input/66 b/subset-sum/input/66 new file mode 100644 index 0000000..53981e0 --- /dev/null +++ b/subset-sum/input/66 @@ -0,0 +1,2 @@ +931 8832 +71 28 4 35 90 18 77 62 64 6 6 26 76 2 52 24 49 31 39 9 37 59 61 96 22 16 28 18 5 15 24 84 42 79 91 21 85 23 91 1 93 31 15 31 75 55 10 28 19 71 67 6 31 29 35 46 23 22 95 82 43 9 31 84 60 39 96 21 76 49 75 94 36 53 12 98 1 22 39 43 69 63 95 100 21 20 54 70 46 85 69 56 85 41 22 17 17 12 37 10 29 81 35 44 56 53 12 43 15 6 36 50 18 89 73 76 31 73 67 50 21 89 3 55 74 70 49 51 34 18 45 68 38 86 98 8 22 26 67 56 100 68 12 15 58 88 15 45 23 82 68 32 35 42 15 75 11 56 82 94 26 26 5 19 78 61 20 24 20 4 25 39 44 82 47 56 97 52 8 87 71 53 32 35 96 97 87 44 26 51 91 50 85 71 80 52 98 100 50 10 32 87 90 79 47 58 53 95 4 70 48 30 62 26 91 44 29 33 46 23 5 8 91 56 75 41 13 58 73 17 83 85 44 43 39 36 33 59 35 60 30 33 96 47 53 63 81 58 8 26 32 94 47 45 46 43 57 89 3 53 87 71 35 21 32 85 99 66 67 50 24 25 35 33 86 64 46 70 19 32 27 96 10 56 97 92 60 19 1 25 55 65 48 23 94 35 34 100 18 66 68 61 4 8 87 34 84 31 19 74 52 85 45 76 71 18 21 1 58 33 57 63 91 79 36 95 52 18 96 100 32 83 56 18 43 96 55 5 98 84 75 47 92 46 3 81 55 61 77 90 75 43 9 66 61 66 60 33 38 18 73 94 30 21 92 40 42 26 34 56 50 41 10 17 91 81 92 3 34 90 4 29 31 11 23 7 92 38 63 84 35 15 14 89 3 29 35 68 88 56 92 5 66 12 77 93 6 33 48 26 93 44 87 65 87 65 9 4 85 71 5 36 20 26 85 21 59 57 69 29 93 92 98 80 77 56 79 10 68 22 43 71 35 72 88 10 90 7 10 43 82 2 55 18 31 17 24 78 15 67 14 10 97 33 90 99 35 97 24 44 93 44 25 97 20 44 97 13 68 87 62 16 1 62 79 29 26 54 6 12 53 58 71 94 5 92 86 64 33 12 52 20 45 12 15 16 56 30 22 89 81 56 98 25 77 67 31 1 100 61 64 8 95 35 26 34 92 47 89 2 17 83 24 21 69 85 48 100 20 61 25 98 53 30 5 56 67 25 70 34 25 20 80 9 77 49 41 92 10 80 32 74 85 28 15 58 80 63 24 94 54 9 20 20 37 78 23 48 89 93 77 25 94 9 84 75 49 36 12 59 63 98 38 34 89 83 69 10 6 46 4 53 56 43 65 27 92 70 44 17 13 66 55 1 17 95 55 75 85 48 49 67 100 18 27 80 43 82 22 94 76 59 7 81 10 78 55 40 90 12 37 51 46 80 88 14 29 70 14 32 72 81 34 76 12 14 31 3 9 99 79 92 4 1 81 42 54 2 11 22 32 39 88 3 61 99 72 68 87 75 59 6 54 60 66 59 71 84 26 75 62 97 35 43 8 96 30 65 46 39 15 26 36 76 28 52 36 40 51 92 96 5 80 93 11 60 21 51 93 23 29 93 94 44 6 23 79 81 14 89 65 34 38 62 80 34 70 94 37 62 98 73 17 32 76 49 32 21 60 92 11 64 35 84 66 29 52 13 86 50 58 86 68 2 24 12 28 61 19 94 15 25 68 75 25 24 20 43 52 88 77 26 87 73 32 20 28 30 2 87 47 45 13 100 5 7 73 43 66 25 64 62 39 37 45 74 16 90 18 98 95 19 90 22 80 76 8 57 38 13 86 75 24 61 63 28 18 17 90 23 36 18 92 56 99 7 86 55 91 24 36 70 14 88 75 47 27 64 64 92 100 90 38 64 28 47 85 45 42 5 94 49 21 69 72 83 41 34 53 65 81 44 69 48 3 50 62 97 21 81 91 91 88 79 6 15 40 41 86 99 65 9 21 79 81 13 14 48 36 38 32 52 30 54 54 23 28 94 29 36 59 12 69 76 68 78 44 47 91 17 6 82 100 84 95 3 44 30 92 65 69 diff --git a/subset-sum/input/67 b/subset-sum/input/67 new file mode 100644 index 0000000..e58c816 --- /dev/null +++ b/subset-sum/input/67 @@ -0,0 +1,2 @@ +227 1247 +52 86 68 1 95 32 47 43 33 88 76 47 59 19 86 78 84 76 94 21 11 86 35 73 57 67 93 57 8 70 94 68 74 50 88 100 96 20 12 32 51 77 97 63 42 5 83 23 62 86 81 3 41 59 35 82 19 57 57 13 25 89 74 33 36 76 57 70 90 74 64 41 54 12 23 3 79 83 26 16 73 10 97 29 32 79 29 90 83 10 30 73 62 69 59 89 88 78 55 96 62 12 56 53 58 39 71 46 21 55 62 99 94 98 45 34 96 47 76 77 80 87 20 4 29 55 73 16 94 56 79 68 39 98 38 52 64 1 60 89 37 7 83 62 72 1 64 74 6 97 1 12 54 67 95 2 69 85 45 86 64 52 32 32 33 58 13 26 43 19 30 98 97 79 5 88 39 7 51 94 93 63 26 62 90 30 24 91 74 58 30 24 40 44 14 95 53 98 25 3 79 91 65 59 39 33 36 1 28 20 100 60 61 73 45 43 43 100 2 92 88 42 16 73 21 27 77 diff --git a/subset-sum/input/68 b/subset-sum/input/68 new file mode 100644 index 0000000..9b5ae92 --- /dev/null +++ b/subset-sum/input/68 @@ -0,0 +1,2 @@ +562 7324 +1 34 16 61 31 78 28 22 27 61 58 1 45 50 82 30 41 85 83 25 97 77 23 16 53 19 37 8 89 98 39 44 91 93 88 35 90 40 19 38 28 3 22 84 9 45 84 53 89 54 75 96 62 86 54 41 92 60 13 51 31 95 4 59 84 41 40 59 61 95 66 100 40 82 37 5 8 5 84 97 16 69 58 97 26 55 9 75 6 50 55 60 36 34 32 83 81 38 94 8 74 55 96 27 80 27 15 62 82 63 8 26 67 29 84 54 85 58 10 58 79 41 61 86 52 19 79 25 93 21 96 99 23 61 77 55 42 73 73 73 92 30 43 68 48 74 21 13 32 71 43 43 79 10 86 2 31 32 98 36 76 96 29 78 71 96 25 80 44 68 14 37 77 66 77 60 37 64 34 66 73 48 91 49 3 83 95 42 58 31 24 32 3 93 1 67 42 56 17 63 14 64 62 10 33 91 99 29 49 60 18 47 22 23 22 84 38 18 19 88 67 15 97 14 44 44 77 17 73 57 24 38 74 73 69 24 72 18 95 35 28 13 53 86 59 71 17 73 44 82 42 95 32 56 93 17 89 35 43 69 71 88 18 27 66 48 76 36 43 98 3 62 43 63 7 74 54 28 19 82 17 36 44 35 21 59 45 77 13 32 21 97 52 56 7 10 77 96 22 49 77 39 75 11 89 38 93 83 29 15 60 57 18 14 61 41 92 95 8 38 81 46 99 31 32 81 100 37 35 61 83 27 26 30 57 69 74 7 50 50 55 26 84 82 22 34 78 24 79 24 74 60 28 45 59 18 24 39 28 6 77 100 91 7 71 5 91 52 10 44 66 58 44 47 72 11 41 51 86 60 73 6 51 96 89 69 55 51 31 23 23 52 1 48 39 31 50 58 68 76 70 8 50 75 64 41 2 70 75 74 5 41 74 38 44 33 95 59 82 89 57 92 90 31 65 5 85 69 29 4 84 14 41 100 64 73 24 37 28 50 93 73 44 40 71 42 80 19 31 46 76 63 30 6 71 92 89 83 51 77 31 92 32 69 11 9 70 24 43 82 98 15 62 30 37 4 47 24 59 71 99 50 58 48 47 57 32 2 27 27 21 49 9 96 10 97 96 16 99 97 17 44 42 57 98 80 50 73 86 40 69 28 78 76 11 57 35 98 76 65 37 91 61 55 17 86 40 42 60 52 32 47 55 51 6 85 49 72 86 3 24 96 79 17 36 54 11 4 86 27 100 69 26 53 85 26 73 34 82 93 80 98 diff --git a/subset-sum/input/69 b/subset-sum/input/69 new file mode 100644 index 0000000..7bff07b --- /dev/null +++ b/subset-sum/input/69 @@ -0,0 +1,2 @@ +367 9802 +88 43 37 58 100 68 50 23 53 42 20 77 1 94 26 16 76 43 50 15 26 29 36 62 92 66 42 81 39 92 82 75 52 9 68 88 34 38 69 64 94 61 40 33 62 43 32 89 86 75 36 66 38 1 67 59 95 76 78 62 50 20 8 61 7 36 13 63 71 93 43 30 94 1 23 7 70 2 74 79 99 29 18 26 21 19 64 2 1 91 41 100 43 45 50 48 53 4 18 68 63 54 92 81 50 75 98 42 5 74 7 15 11 47 66 19 83 78 57 66 89 23 19 76 8 39 42 8 11 46 62 30 63 35 52 46 4 86 92 42 12 63 91 12 42 64 50 85 68 62 25 83 38 16 72 29 28 59 74 2 48 33 49 61 70 34 12 47 86 70 77 40 21 33 59 50 97 73 89 61 40 36 48 78 29 59 65 99 87 12 9 8 60 53 40 46 40 14 11 11 51 83 69 14 46 28 50 45 18 15 11 14 68 14 71 22 20 43 85 42 30 38 84 96 32 42 14 15 25 12 53 7 63 50 93 90 26 49 4 62 36 71 52 97 19 54 81 14 58 52 56 19 48 13 57 42 2 60 39 50 6 42 47 92 35 41 80 12 10 99 77 40 32 60 81 52 5 40 34 97 43 30 51 37 69 42 46 8 44 28 99 30 46 22 55 31 26 54 66 22 25 74 54 79 36 7 33 85 55 26 70 12 87 66 57 24 97 40 67 64 98 49 90 16 33 71 47 79 4 29 3 2 3 31 29 71 86 94 80 19 68 90 78 69 27 39 14 92 1 15 82 49 30 43 29 99 59 10 2 65 37 48 84 95 32 28 60 diff --git a/subset-sum/input/7 b/subset-sum/input/7 new file mode 100644 index 0000000..636746d --- /dev/null +++ b/subset-sum/input/7 @@ -0,0 +1,2 @@ +43 4325 +82 84 17 56 32 2 28 37 57 39 18 11 79 6 40 68 68 16 40 63 93 49 91 10 55 68 31 80 57 18 34 28 76 55 21 80 22 45 11 67 67 74 91 diff --git a/subset-sum/input/70 b/subset-sum/input/70 new file mode 100644 index 0000000..26c2bbe --- /dev/null +++ b/subset-sum/input/70 @@ -0,0 +1,2 @@ +961 3251 +91 30 82 68 39 85 23 2 61 14 66 4 95 93 87 66 75 47 23 9 41 77 83 13 9 20 37 96 15 43 48 74 37 28 39 83 25 99 30 36 32 81 17 90 65 62 87 37 35 17 80 90 94 59 95 49 87 47 29 20 75 56 56 66 37 45 93 81 9 68 23 9 41 12 1 27 23 40 12 83 49 49 74 78 72 44 96 28 58 21 85 27 13 89 1 54 29 61 48 75 6 21 40 34 31 34 6 68 8 40 26 64 1 77 98 85 4 84 7 63 3 51 87 85 40 89 36 49 39 65 64 92 20 29 39 66 90 95 81 35 37 20 93 85 73 28 3 60 1 91 2 92 77 24 83 38 75 88 28 40 50 83 10 60 35 76 7 85 27 4 41 26 39 87 29 89 43 14 29 18 18 22 35 33 72 92 31 19 53 35 89 69 43 69 89 32 71 30 13 27 56 56 82 85 75 41 11 12 62 88 96 75 42 68 13 13 24 83 21 7 3 40 72 82 32 50 21 7 45 52 52 9 3 15 96 50 8 66 58 31 90 69 1 43 90 61 44 72 86 14 68 70 7 73 63 70 79 59 26 85 4 48 96 34 7 93 64 83 59 63 23 49 28 61 67 99 52 18 53 71 68 48 16 25 28 82 48 42 55 98 24 74 100 32 33 26 29 22 9 15 26 91 28 29 42 36 58 46 34 29 67 88 40 49 38 14 98 77 18 20 1 13 8 78 78 72 51 30 95 7 51 31 67 38 3 34 98 63 19 8 83 88 62 58 62 1 92 43 33 80 34 94 87 68 1 50 29 58 55 72 11 87 86 53 69 28 63 57 39 48 12 57 56 82 74 38 20 37 16 24 38 94 22 35 51 21 40 21 81 4 60 98 85 82 87 3 80 34 56 40 6 81 7 74 59 80 64 13 92 64 22 11 72 27 20 99 48 30 99 31 22 89 70 35 27 13 85 60 41 7 67 70 46 54 91 2 35 5 31 92 41 66 68 50 35 28 43 7 75 62 36 33 64 10 46 8 67 78 80 80 55 83 98 51 51 49 89 37 32 41 87 78 39 71 72 20 64 16 56 10 70 73 46 62 16 25 14 83 20 99 52 72 94 42 75 8 57 80 16 87 70 40 48 83 31 28 77 41 41 19 77 64 51 55 81 86 65 12 80 6 50 8 70 75 66 81 2 39 52 70 75 1 74 62 43 68 60 72 23 1 92 5 24 97 53 37 26 37 75 58 80 48 25 83 21 49 32 87 25 86 45 59 49 14 35 40 55 36 82 91 59 77 21 26 68 54 28 54 92 47 7 15 80 2 90 22 89 42 95 76 70 97 87 32 15 6 65 65 92 91 1 69 47 8 46 47 2 22 21 62 43 53 12 88 50 75 68 28 10 63 35 56 92 46 98 72 43 61 52 1 66 53 2 27 85 2 9 43 69 13 15 5 99 6 82 32 9 86 95 5 17 66 20 48 67 23 99 67 40 52 41 53 2 19 7 68 21 32 17 26 100 27 6 28 61 94 49 87 85 34 83 18 57 77 47 59 80 15 1 65 42 18 55 83 6 43 75 60 5 76 66 53 34 25 50 74 51 10 38 13 46 52 25 37 58 52 86 5 54 42 8 67 1 23 14 53 1 51 43 7 87 16 92 83 44 6 60 79 84 41 23 83 69 18 12 32 100 17 100 46 49 80 4 20 86 35 22 74 12 63 40 38 14 83 32 4 28 10 11 4 41 75 74 76 9 35 92 91 56 82 54 23 33 66 85 52 88 23 92 23 20 45 67 79 62 14 73 76 33 25 83 47 11 52 99 48 82 63 26 44 25 98 29 31 6 75 48 31 3 62 51 63 58 11 7 85 88 68 15 16 35 72 8 98 19 64 68 83 37 70 24 25 27 22 38 86 89 39 28 41 12 16 87 17 97 20 4 89 58 12 91 50 82 46 87 96 92 56 39 82 40 25 100 85 10 56 60 56 21 7 49 95 73 69 36 52 38 8 75 1 50 97 95 72 63 39 91 10 67 7 83 4 45 67 81 56 43 22 8 70 31 21 12 60 48 62 99 17 99 52 91 59 20 80 17 78 97 63 68 79 86 45 64 21 72 88 92 43 29 79 44 35 69 63 47 9 76 82 11 22 94 27 32 2 38 67 53 66 72 3 74 diff --git a/subset-sum/input/71 b/subset-sum/input/71 new file mode 100644 index 0000000..9a0f4ce --- /dev/null +++ b/subset-sum/input/71 @@ -0,0 +1,2 @@ +246 6364 +95 67 21 67 28 71 48 32 39 18 55 57 61 36 12 22 41 76 30 94 65 10 87 50 77 69 62 4 70 82 30 17 48 46 61 56 80 60 65 60 39 29 35 66 69 91 39 29 19 70 41 44 10 78 92 47 50 63 21 74 36 39 100 16 64 63 15 62 7 74 86 10 2 81 1 76 61 86 73 92 93 70 79 90 51 15 71 29 30 98 95 81 41 13 30 37 63 86 17 5 61 82 81 81 48 35 71 44 24 55 6 82 42 15 5 38 74 13 26 5 30 10 61 17 46 32 3 67 21 33 23 25 98 83 80 5 29 98 68 24 14 33 63 44 74 89 78 51 65 20 41 29 5 55 34 22 9 77 27 2 75 78 55 15 15 36 54 14 66 90 13 35 28 44 71 76 57 32 74 9 28 60 38 11 23 2 90 33 97 91 50 14 56 76 59 46 31 40 39 45 46 67 44 62 32 16 38 5 52 77 26 77 97 6 99 91 5 26 1 69 91 46 73 96 1 71 86 18 74 44 39 73 41 78 11 90 92 86 36 79 74 95 5 86 30 73 diff --git a/subset-sum/input/72 b/subset-sum/input/72 new file mode 100644 index 0000000..fb0c492 --- /dev/null +++ b/subset-sum/input/72 @@ -0,0 +1,2 @@ +371 2378 +33 55 95 34 44 50 27 82 100 84 65 24 17 90 43 22 83 2 73 20 87 69 70 14 47 30 78 44 26 58 51 77 65 6 89 48 89 4 60 26 31 13 70 67 6 49 54 56 52 55 39 63 42 97 2 51 43 22 80 71 57 55 21 52 72 57 2 12 81 47 52 88 29 8 31 66 11 25 56 100 5 9 19 39 4 63 30 5 11 16 64 88 96 22 51 36 99 78 54 1 77 43 84 58 46 33 79 48 83 58 86 73 61 29 79 65 65 18 54 12 66 99 64 86 38 30 48 62 85 12 98 43 51 16 23 82 47 42 38 66 7 13 83 47 57 41 70 48 73 34 4 33 96 91 7 37 71 3 1 64 42 8 61 99 93 71 85 83 34 49 89 74 77 13 59 18 91 8 5 28 24 75 78 6 65 4 1 37 59 22 40 32 18 93 63 51 6 42 19 58 81 41 87 83 79 58 54 79 9 75 82 45 15 1 95 49 50 67 86 91 43 58 35 46 53 87 4 57 7 16 11 89 24 38 64 65 52 48 28 53 14 75 11 32 25 77 11 37 66 7 91 86 57 79 45 84 8 34 17 16 18 18 67 14 17 25 24 77 45 40 50 44 66 13 31 95 50 54 35 67 1 76 59 82 15 5 31 48 2 22 80 9 13 50 50 80 70 41 56 41 21 57 79 88 74 92 35 28 87 16 54 69 91 38 86 79 93 64 67 1 55 32 47 82 27 74 65 35 42 74 15 79 63 15 43 66 37 53 2 67 10 88 20 13 33 22 65 98 85 65 15 63 63 63 58 89 9 80 11 16 85 76 57 38 66 11 55 53 83 70 95 diff --git a/subset-sum/input/73 b/subset-sum/input/73 new file mode 100644 index 0000000..369eb22 --- /dev/null +++ b/subset-sum/input/73 @@ -0,0 +1,2 @@ +634 2758 +73 29 31 62 83 59 41 9 99 58 47 43 3 35 9 97 12 11 42 100 83 2 39 11 39 86 29 96 1 89 11 12 94 30 93 74 65 43 7 12 39 49 31 38 72 68 27 97 84 56 61 5 68 7 73 72 85 20 54 37 1 25 37 61 62 65 13 21 20 96 25 86 15 90 73 60 23 16 21 4 78 31 29 86 14 43 24 52 56 13 93 37 74 53 84 34 74 33 26 76 49 63 61 32 37 31 69 50 79 43 93 46 93 18 39 87 93 70 44 95 53 81 9 44 9 92 25 78 72 7 44 6 63 90 53 45 48 75 21 58 68 62 63 80 2 40 85 10 54 44 13 53 26 13 94 82 49 42 99 5 59 80 39 35 66 44 55 21 76 51 63 14 71 83 93 1 19 37 61 69 20 30 36 19 1 4 68 64 58 71 74 16 67 85 76 39 39 5 87 88 42 81 50 86 66 92 69 97 62 53 47 27 91 66 100 36 18 26 80 12 96 44 34 17 97 17 10 11 48 25 55 74 77 79 94 12 87 77 53 24 46 37 45 8 43 54 85 4 51 92 65 56 64 36 55 66 3 5 57 2 75 73 1 56 73 80 4 74 22 36 24 35 56 32 85 57 24 22 68 79 26 5 79 32 85 67 62 30 87 51 29 72 63 60 56 13 10 81 30 99 57 59 75 49 58 86 38 72 63 92 7 98 18 56 2 66 79 37 74 26 13 5 55 41 77 90 21 26 36 8 90 39 90 5 8 58 58 99 56 35 15 22 96 36 87 24 51 56 94 71 55 81 67 26 58 26 55 84 22 41 84 55 28 78 92 10 90 86 27 100 52 30 53 63 83 73 5 30 9 45 31 80 54 23 55 86 42 10 83 61 5 72 93 45 18 81 67 19 73 42 70 4 61 39 39 8 62 13 77 56 76 94 24 100 66 32 56 22 84 61 40 16 1 66 32 59 94 79 83 43 33 61 69 7 91 64 79 39 91 1 26 9 80 89 16 23 55 84 78 65 82 23 55 44 63 87 31 23 39 24 89 46 99 3 74 34 70 16 40 90 85 100 28 49 70 64 92 86 93 72 17 35 66 81 94 46 29 48 60 67 5 41 56 52 86 76 84 79 71 75 30 12 4 2 71 93 57 62 1 48 73 55 94 52 100 50 75 56 73 56 14 46 89 40 64 5 38 21 20 60 45 30 2 61 96 24 40 15 69 7 52 41 33 97 96 68 66 38 85 89 2 91 49 77 21 11 30 74 43 17 16 56 24 71 86 86 26 72 10 5 62 28 64 61 51 23 79 80 66 97 73 53 100 5 86 86 19 5 60 74 94 88 66 44 52 8 100 86 69 12 85 11 89 56 14 21 31 99 28 91 83 56 93 12 72 58 28 63 99 23 36 69 78 6 65 71 82 69 72 85 33 47 61 35 diff --git a/subset-sum/input/74 b/subset-sum/input/74 new file mode 100644 index 0000000..ccf6e20 --- /dev/null +++ b/subset-sum/input/74 @@ -0,0 +1,2 @@ +181 3644 +72 56 23 59 30 30 17 94 43 31 69 23 39 47 91 11 34 24 79 56 5 37 36 20 88 55 23 46 11 39 74 49 40 42 69 55 57 55 40 63 90 77 51 7 43 98 93 83 72 6 93 4 39 26 48 15 38 17 61 99 62 82 20 99 97 31 72 77 17 56 49 72 27 50 6 46 92 37 16 23 8 47 37 33 2 22 86 93 85 6 29 68 66 100 72 63 47 40 88 83 2 72 63 59 56 63 11 5 15 95 56 21 33 79 74 100 54 50 28 62 69 46 71 9 12 70 57 100 35 32 70 12 41 59 86 70 27 7 33 23 31 96 25 87 19 11 76 59 91 61 60 79 11 53 37 36 86 22 87 67 40 59 65 76 25 74 74 20 23 29 36 32 69 40 76 44 10 9 75 88 46 diff --git a/subset-sum/input/75 b/subset-sum/input/75 new file mode 100644 index 0000000..b005696 --- /dev/null +++ b/subset-sum/input/75 @@ -0,0 +1,2 @@ +939 5789 +46 25 88 93 39 58 94 98 61 14 65 49 95 18 68 68 62 57 32 96 4 79 32 12 88 3 83 40 17 62 88 15 21 25 54 62 16 31 94 31 23 89 19 78 34 9 25 15 26 27 81 42 100 39 43 49 47 25 33 38 34 59 77 11 4 3 19 64 62 26 60 53 16 2 68 12 20 88 21 3 42 79 70 41 38 48 53 100 78 4 69 45 65 89 1 96 81 77 7 95 78 85 98 68 65 72 68 64 1 57 93 69 17 72 2 5 16 10 10 36 68 85 21 98 8 17 60 54 10 81 31 40 86 82 7 64 4 3 12 85 90 32 63 67 100 95 37 66 50 98 91 33 97 2 4 3 82 38 59 25 58 38 5 58 5 45 51 26 87 63 62 48 70 15 33 59 29 98 3 77 2 51 79 15 90 53 78 94 100 20 88 14 93 12 7 93 95 24 35 1 25 81 64 75 13 76 7 96 66 75 65 80 2 25 62 66 33 21 84 58 92 75 13 64 64 28 81 14 80 57 25 17 14 51 33 72 83 10 87 47 6 14 14 41 21 20 68 39 24 11 13 64 88 12 1 67 5 49 37 40 85 87 67 2 67 72 78 90 28 5 55 95 90 33 10 72 27 48 66 89 14 94 93 10 7 90 73 55 14 3 89 14 9 14 4 97 15 37 57 73 89 82 42 60 60 6 78 3 37 94 51 28 84 18 72 6 34 5 23 80 11 46 88 35 88 86 73 49 10 87 96 98 57 71 40 66 14 7 97 52 78 73 67 65 1 39 10 7 71 53 85 3 86 66 11 60 86 64 93 26 40 59 2 91 36 94 38 81 71 27 6 2 14 22 58 67 77 61 48 2 40 75 3 43 97 40 88 67 48 59 68 72 10 4 12 66 63 7 43 6 72 55 84 38 97 55 61 86 64 17 97 37 64 2 71 37 55 15 49 35 53 23 74 40 75 91 44 27 92 52 35 8 63 41 12 14 92 14 71 26 94 14 53 18 95 98 15 35 92 23 9 28 61 44 11 5 3 26 44 76 85 27 78 23 54 3 36 72 65 14 84 15 72 80 1 5 62 95 6 47 5 77 56 35 40 83 28 23 42 55 59 83 46 75 17 59 4 84 51 7 94 75 76 70 85 95 100 36 64 14 36 100 29 84 39 30 27 47 72 42 44 33 82 31 21 32 27 53 90 9 29 40 7 62 4 78 65 32 78 37 53 46 9 38 80 96 9 31 73 32 67 11 62 44 71 36 72 50 60 20 74 28 26 65 38 82 91 83 52 62 3 34 77 7 58 66 62 69 98 1 78 67 38 85 39 33 88 39 46 30 84 24 62 100 3 72 17 11 69 14 59 89 47 2 9 9 86 35 27 83 74 13 51 30 80 12 64 91 64 83 87 27 11 18 53 53 71 96 43 5 2 30 13 6 43 18 32 33 29 45 100 51 2 46 18 7 73 32 95 50 36 60 75 53 22 20 68 95 2 41 56 65 3 7 6 67 42 44 54 17 79 76 28 60 21 88 37 65 65 34 54 38 75 18 31 13 92 56 5 63 9 60 89 49 79 37 27 82 57 99 19 84 69 1 59 74 31 67 43 73 4 77 40 24 68 82 94 54 66 65 10 72 95 4 13 43 22 96 90 67 78 11 68 83 14 42 2 66 96 11 21 17 35 53 21 91 50 82 28 84 86 96 82 6 91 9 92 7 68 13 21 100 43 72 96 76 30 50 88 35 53 73 85 87 53 70 46 75 10 68 98 99 74 56 66 9 88 55 82 87 82 95 28 47 91 79 83 85 54 70 89 49 89 48 37 10 26 77 78 60 50 28 43 31 89 88 52 74 39 11 28 5 39 50 41 43 6 43 85 89 20 79 73 12 88 100 49 11 35 61 13 39 36 12 11 21 39 11 2 96 30 20 76 52 67 47 26 64 49 52 23 9 70 14 44 89 62 10 11 93 19 82 95 50 15 82 66 16 37 94 71 3 24 42 68 12 94 69 70 90 86 78 20 2 39 74 27 74 76 88 41 31 18 68 21 24 44 21 12 84 74 63 32 27 69 69 92 70 1 20 77 14 99 58 28 49 36 44 93 5 76 84 89 44 100 8 46 2 69 diff --git a/subset-sum/input/76 b/subset-sum/input/76 new file mode 100644 index 0000000..715b061 --- /dev/null +++ b/subset-sum/input/76 @@ -0,0 +1,2 @@ +561 7854 +14 30 41 87 25 69 86 6 25 63 72 75 99 96 23 67 13 91 86 82 70 88 54 6 85 65 20 38 97 37 47 3 32 65 92 14 4 33 8 80 73 16 33 45 37 19 77 34 95 46 42 59 67 20 24 69 12 74 79 13 58 96 6 39 16 16 8 76 24 52 95 17 18 60 88 22 21 50 88 4 21 73 3 27 50 94 12 44 84 62 34 40 32 66 46 31 50 5 2 18 81 42 19 73 5 4 44 46 57 24 53 37 65 46 5 6 86 72 37 42 97 9 3 73 12 44 83 73 44 70 61 70 68 48 17 49 4 91 65 33 39 21 71 97 66 43 81 80 87 57 75 95 63 32 88 10 52 5 61 91 32 19 61 50 20 57 43 16 17 65 72 48 35 18 86 93 29 39 18 57 54 6 30 11 63 85 92 79 78 49 81 45 37 22 7 25 17 52 72 94 88 14 20 22 47 22 79 71 36 18 36 74 65 13 75 11 76 2 48 10 5 60 74 9 39 9 85 84 71 20 21 11 99 43 1 27 1 5 52 14 57 92 75 50 42 32 5 62 66 83 54 17 33 91 36 37 95 79 5 29 51 18 31 11 32 59 67 100 56 23 91 39 15 38 88 1 9 58 68 28 21 6 28 91 35 57 68 32 43 96 66 98 100 40 51 27 82 18 10 67 96 60 7 95 7 87 33 40 100 39 69 49 38 61 29 45 38 38 9 2 53 29 53 22 50 85 48 74 25 68 27 38 37 93 33 11 99 71 1 86 77 24 50 2 28 59 86 49 98 66 39 7 17 13 81 98 77 1 59 73 18 30 17 65 40 37 99 2 73 22 25 67 67 40 25 62 35 88 69 17 79 46 42 68 37 12 97 76 22 72 30 62 20 38 40 90 92 12 19 85 24 93 90 75 62 71 30 17 4 29 52 28 90 97 43 72 51 18 80 78 36 47 47 99 51 79 89 59 45 23 96 42 33 99 81 82 95 65 19 48 73 48 70 22 58 35 32 99 2 24 67 79 99 93 5 51 11 26 75 27 80 57 31 7 78 64 37 89 53 59 14 37 76 47 100 100 27 60 75 14 66 28 16 32 79 18 73 38 37 5 74 86 59 34 46 39 25 89 71 71 40 44 2 62 40 6 60 41 61 73 68 28 11 57 62 3 41 23 49 97 79 14 34 64 32 58 71 63 77 40 65 64 64 76 31 50 94 83 84 69 81 45 81 17 2 48 61 90 24 31 71 55 71 20 23 90 22 94 57 49 99 diff --git a/subset-sum/input/77 b/subset-sum/input/77 new file mode 100644 index 0000000..a1ff597 --- /dev/null +++ b/subset-sum/input/77 @@ -0,0 +1,2 @@ +943 2043 +89 89 7 9 66 8 20 51 12 57 64 4 73 18 70 81 32 88 21 98 12 57 36 46 27 78 8 97 7 81 9 98 61 8 66 5 80 32 12 50 71 60 38 88 40 71 20 79 62 89 20 58 52 63 76 18 87 35 46 17 92 85 55 84 96 56 23 78 10 97 87 63 60 23 32 93 79 70 65 78 94 20 53 52 83 23 86 7 39 81 48 23 49 2 3 28 34 93 25 16 39 8 10 36 10 51 89 80 41 2 54 78 54 92 86 75 38 84 17 94 69 20 100 11 16 20 39 25 15 92 81 40 36 92 83 60 54 81 5 8 70 23 69 68 73 97 50 75 92 70 14 82 99 48 48 31 51 20 95 63 40 4 16 65 55 5 64 60 89 12 65 17 23 33 48 98 52 7 41 8 58 46 78 7 48 50 31 17 97 61 85 50 20 21 27 66 98 3 73 22 56 61 3 31 70 44 18 34 93 43 23 47 70 71 82 93 81 73 61 84 30 51 71 83 83 43 41 6 5 46 16 84 90 66 1 86 13 33 31 11 90 4 81 23 70 29 49 60 1 61 75 24 87 90 12 44 30 90 15 42 42 19 79 65 32 21 18 43 24 31 68 18 2 70 18 96 13 72 68 49 95 42 68 45 75 51 4 19 44 15 91 56 47 21 69 70 12 49 31 69 1 78 36 69 14 10 22 46 71 77 1 31 10 57 16 44 46 21 79 28 81 53 35 3 27 96 78 69 44 66 2 85 62 39 63 62 36 2 98 90 49 70 38 62 99 1 11 52 32 4 38 1 17 68 90 15 50 4 62 24 91 85 81 9 50 24 25 57 26 8 37 3 73 5 90 67 56 22 13 93 78 16 96 72 96 9 29 17 4 82 74 74 25 81 31 31 97 35 79 92 47 63 70 81 18 78 54 21 60 9 87 79 83 42 13 100 43 71 34 11 54 57 77 60 43 10 57 54 47 28 71 37 16 44 48 84 41 47 64 76 3 20 84 59 87 77 33 90 33 82 71 19 31 9 95 96 12 92 25 18 89 69 83 27 35 81 16 77 83 70 26 44 61 53 68 72 18 61 85 12 58 34 75 12 87 50 69 96 92 84 73 4 38 76 75 78 78 28 36 98 33 2 99 1 87 16 12 50 49 98 12 16 75 55 38 99 50 9 74 95 51 5 12 14 86 40 69 14 84 12 15 62 70 39 8 52 44 11 19 49 59 13 62 13 99 26 45 39 77 37 26 58 22 75 43 74 54 45 63 16 66 38 81 78 54 6 43 12 4 80 45 42 28 5 68 3 6 38 11 44 71 18 5 51 88 98 16 92 9 28 40 15 86 72 90 32 6 94 6 9 64 82 54 36 84 34 64 19 60 76 96 58 28 97 91 64 81 19 45 46 51 59 68 91 10 60 7 50 61 91 44 72 2 5 6 63 44 40 48 44 2 70 56 97 36 28 1 44 1 64 25 70 52 92 20 16 97 81 63 50 51 65 38 100 96 45 66 19 75 64 19 30 18 78 12 6 28 29 94 4 28 80 85 43 36 67 39 59 64 72 14 76 24 29 54 73 1 87 45 33 37 17 6 1 26 83 95 20 35 11 82 50 95 88 19 89 52 98 17 47 57 43 41 26 9 5 2 83 74 70 48 16 54 95 36 98 70 9 89 83 93 91 82 64 89 85 53 5 19 87 90 96 34 60 63 66 24 31 49 2 98 74 53 28 11 58 56 75 16 73 90 64 75 11 33 49 31 52 3 66 93 89 19 83 27 10 79 55 31 31 4 39 57 12 46 42 2 71 1 94 78 49 99 97 99 41 43 14 63 12 43 60 19 76 38 82 6 30 20 74 30 35 61 57 23 66 26 44 46 89 84 35 11 67 70 96 39 5 56 72 71 78 7 31 59 56 57 71 17 6 47 73 55 77 18 36 4 14 77 32 100 16 47 76 75 51 6 13 2 21 4 32 66 44 29 32 35 70 96 90 10 92 66 94 8 52 78 73 33 80 56 69 30 56 37 51 39 43 52 2 41 39 56 73 36 12 100 29 55 69 33 9 24 39 80 60 28 60 54 15 73 42 85 64 70 94 50 15 29 93 29 33 10 42 63 4 78 17 21 32 57 57 54 diff --git a/subset-sum/input/78 b/subset-sum/input/78 new file mode 100644 index 0000000..0d19f22 --- /dev/null +++ b/subset-sum/input/78 @@ -0,0 +1,2 @@ +174 3000 +28 21 20 51 54 60 50 96 30 2 7 26 32 62 56 95 60 74 5 23 2 57 47 79 23 54 45 55 59 62 80 84 5 97 24 54 69 82 2 6 55 31 64 6 5 10 71 65 84 26 26 75 55 11 68 51 91 2 86 96 46 17 87 78 44 25 94 56 77 67 43 72 89 26 66 72 38 61 75 1 30 50 56 19 2 15 42 2 68 89 65 24 78 60 43 77 12 72 53 49 54 96 94 93 60 1 82 6 69 47 80 97 36 4 40 53 14 15 54 53 90 51 37 35 15 74 29 98 94 22 65 69 49 3 2 5 1 83 14 23 24 4 74 56 44 62 89 63 83 87 86 79 17 45 74 62 53 55 72 71 48 40 75 17 60 62 35 89 91 48 48 96 89 57 diff --git a/subset-sum/input/79 b/subset-sum/input/79 new file mode 100644 index 0000000..cc04fdc --- /dev/null +++ b/subset-sum/input/79 @@ -0,0 +1,2 @@ +462 2795 +6 55 91 29 53 97 76 36 6 98 37 36 41 35 12 10 24 32 42 31 98 52 42 99 18 5 15 7 20 65 83 20 8 68 51 45 21 51 59 44 44 82 57 33 38 71 37 94 57 36 14 29 40 94 37 53 31 17 52 6 99 20 17 64 92 87 95 69 22 4 64 12 99 21 86 26 48 62 64 76 12 52 83 23 43 86 58 7 96 32 30 36 96 83 16 12 5 54 5 44 92 28 29 54 67 8 8 14 88 64 8 78 87 30 54 71 40 38 65 95 7 18 76 50 30 76 84 92 67 4 69 98 71 16 44 28 97 26 15 76 44 69 73 50 56 12 22 59 18 45 80 27 55 83 53 42 14 53 70 94 43 25 41 47 52 58 68 70 27 55 44 75 90 57 100 15 31 69 3 22 29 15 1 94 21 72 74 78 62 21 73 76 44 42 3 20 46 20 78 2 36 47 34 60 98 25 99 74 42 21 45 72 66 33 11 52 96 92 37 29 12 97 10 37 54 2 2 92 25 66 36 74 25 59 25 21 70 4 52 81 19 92 33 46 96 94 70 41 40 75 17 31 3 68 55 97 25 21 58 91 62 86 44 21 39 94 86 1 92 31 18 82 24 75 50 87 83 90 15 94 97 66 30 73 24 77 46 41 73 3 51 21 43 70 93 20 87 56 48 68 15 92 46 40 40 5 76 79 75 73 44 58 15 8 52 78 29 51 2 51 79 73 78 75 42 65 72 17 64 89 99 75 87 81 31 24 4 90 75 42 85 48 51 45 99 21 72 2 92 43 59 41 90 22 26 60 78 43 51 50 47 50 55 88 33 89 21 28 74 55 24 8 31 50 64 68 4 41 85 1 36 7 54 55 98 74 79 56 56 61 40 86 46 94 77 73 87 84 80 38 84 74 29 10 48 79 37 49 74 65 67 96 66 70 86 19 48 9 34 27 71 21 10 21 67 9 51 93 39 67 56 49 45 17 76 75 1 43 28 78 37 39 94 78 20 48 75 87 59 76 82 10 54 49 70 96 9 43 31 13 88 13 diff --git a/subset-sum/input/8 b/subset-sum/input/8 new file mode 100644 index 0000000..0d40bd1 --- /dev/null +++ b/subset-sum/input/8 @@ -0,0 +1,2 @@ +208 9835 +34 65 80 21 95 1 52 25 31 2 53 96 22 89 99 7 66 32 2 68 33 75 92 84 10 94 28 54 12 9 80 43 21 51 92 20 97 7 25 67 17 38 100 86 4 83 20 6 81 58 59 53 2 54 62 25 35 79 64 27 49 32 95 100 20 58 39 92 30 67 89 58 81 100 66 73 29 75 81 70 55 18 28 7 35 98 52 30 11 69 48 84 54 13 14 15 86 34 82 92 26 8 53 62 57 50 31 61 85 88 5 80 64 90 52 47 43 40 93 69 70 16 43 7 25 99 12 63 99 71 76 55 17 90 43 27 20 42 84 39 96 75 1 58 49 77 40 28 38 55 17 53 33 68 57 7 56 78 77 68 99 82 41 26 64 69 1 98 98 63 15 13 95 23 71 6 57 4 10 10 44 11 84 10 59 62 94 49 7 46 37 87 79 6 85 91 42 42 34 94 51 89 98 29 12 64 97 23 diff --git a/subset-sum/input/80 b/subset-sum/input/80 new file mode 100644 index 0000000..74fb690 --- /dev/null +++ b/subset-sum/input/80 @@ -0,0 +1,2 @@ +618 5019 +14 8 69 60 7 27 24 58 74 13 79 43 20 49 69 66 43 61 34 16 4 81 58 78 48 33 29 24 79 58 37 51 69 1 94 15 59 34 17 74 72 39 45 95 41 58 29 40 36 51 9 9 30 91 68 67 33 6 39 6 23 10 93 47 57 34 97 66 48 32 48 4 95 71 4 39 64 98 10 38 26 23 16 50 38 21 71 47 7 82 27 67 24 62 90 94 62 6 45 4 62 77 99 90 84 19 100 94 63 85 4 26 46 6 89 69 55 82 12 91 26 78 40 67 46 72 57 28 44 37 59 41 62 54 72 72 5 54 50 72 24 36 39 10 43 29 3 76 13 14 33 85 38 96 6 43 89 6 73 66 40 31 13 74 67 90 55 8 80 88 37 13 98 89 99 54 25 55 86 86 88 29 76 32 88 14 22 26 14 8 98 35 49 21 17 14 89 45 74 36 77 50 97 22 17 30 73 72 1 37 71 84 61 64 68 33 7 31 99 40 56 60 5 35 23 22 94 61 12 11 31 43 6 94 18 66 30 70 84 98 58 5 100 56 71 98 10 5 51 48 57 14 63 72 20 62 34 34 73 91 9 49 85 1 61 11 5 93 84 42 61 7 32 69 75 64 14 23 76 5 8 19 72 34 56 87 29 61 63 6 24 44 3 6 36 82 57 54 41 75 91 24 50 7 59 28 67 19 74 24 80 84 43 94 28 78 70 13 63 39 29 84 33 69 74 30 69 99 10 36 62 65 55 62 69 91 40 35 21 54 88 16 65 79 46 56 82 30 85 51 11 68 52 22 51 69 14 37 74 47 64 6 65 98 89 51 69 93 37 72 64 11 59 7 76 68 56 94 89 88 25 48 20 20 24 92 10 5 63 56 49 58 96 35 24 34 24 28 10 35 60 73 20 20 43 85 11 77 22 6 25 6 42 92 41 24 2 76 99 83 90 58 90 29 53 35 33 49 32 8 37 53 25 9 49 49 9 78 88 65 1 82 11 11 57 79 41 99 53 20 45 85 74 67 11 34 95 59 15 16 85 75 33 49 50 92 43 40 63 39 86 52 6 53 46 3 81 6 29 25 81 35 16 58 28 99 78 59 19 6 87 77 84 21 82 61 73 95 43 23 35 63 74 59 76 68 62 23 46 68 31 54 2 93 16 62 42 71 14 31 43 52 67 15 24 70 68 20 93 85 100 49 56 62 34 61 8 97 95 29 1 53 50 87 17 86 58 70 62 54 83 43 33 1 1 19 53 51 80 42 86 6 22 2 15 29 100 62 100 38 78 51 100 97 90 51 17 71 37 56 47 36 2 22 93 17 52 22 39 11 68 4 25 94 74 90 82 59 35 58 26 50 25 36 65 24 35 46 18 87 97 83 57 45 5 96 61 49 diff --git a/subset-sum/input/81 b/subset-sum/input/81 new file mode 100644 index 0000000..153bb20 --- /dev/null +++ b/subset-sum/input/81 @@ -0,0 +1,2 @@ +245 7632 +35 2 11 37 80 2 10 54 55 100 12 2 97 94 82 81 32 87 82 28 44 30 98 32 9 46 10 49 51 48 90 95 24 32 6 21 5 5 92 53 45 4 93 5 2 12 17 97 95 93 66 6 60 61 41 92 46 34 29 73 98 75 25 21 42 62 66 32 72 83 67 15 9 91 92 75 55 98 72 48 88 63 83 71 49 70 21 100 40 25 68 73 2 96 69 45 21 63 100 98 99 16 88 60 22 18 60 96 26 52 57 98 90 75 2 39 95 71 58 91 51 75 5 100 3 93 87 21 18 43 39 4 8 45 2 5 19 60 22 8 62 24 71 35 21 35 61 2 78 36 32 77 75 73 35 66 62 21 22 96 4 23 88 33 94 72 69 65 79 13 20 100 95 20 70 4 42 42 98 73 3 11 56 71 25 30 98 3 14 12 21 11 71 29 53 25 45 80 9 48 3 26 36 71 94 6 91 80 75 8 96 83 85 82 16 92 72 6 67 4 51 27 3 32 67 87 88 85 74 38 34 46 21 86 73 2 6 57 17 67 46 58 80 96 40 diff --git a/subset-sum/input/82 b/subset-sum/input/82 new file mode 100644 index 0000000..cea0eeb --- /dev/null +++ b/subset-sum/input/82 @@ -0,0 +1,2 @@ +192 9640 +64 29 37 40 88 58 4 89 89 21 64 72 16 52 91 57 32 64 8 80 83 59 22 8 82 74 31 5 48 20 9 74 47 54 84 75 59 81 21 97 1 84 33 65 30 27 48 93 61 96 95 91 28 89 75 32 7 80 7 98 100 78 17 22 94 33 14 4 86 30 66 98 65 64 48 76 7 91 36 86 25 93 52 92 16 65 79 69 64 75 90 18 67 85 57 76 39 53 39 73 71 44 81 28 71 81 23 64 87 20 24 89 57 12 73 34 75 58 86 72 93 55 57 98 81 37 84 59 88 82 95 60 92 72 36 27 77 72 94 37 11 47 34 44 31 96 93 14 46 48 32 12 52 48 38 16 46 74 78 28 85 17 51 64 21 37 94 96 50 59 95 91 74 27 84 61 17 17 52 62 88 11 82 10 95 14 43 63 47 57 68 17 diff --git a/subset-sum/input/83 b/subset-sum/input/83 new file mode 100644 index 0000000..4aa8422 --- /dev/null +++ b/subset-sum/input/83 @@ -0,0 +1,2 @@ +832 8383 +70 17 100 71 87 78 30 65 72 35 20 52 17 88 98 99 47 96 53 87 15 4 89 78 100 27 75 45 72 44 83 74 92 84 47 82 56 53 26 3 52 79 26 55 42 3 39 51 12 99 5 33 51 60 46 99 47 64 66 26 60 16 65 16 41 19 45 94 68 93 5 95 7 57 83 27 85 72 74 32 85 56 29 20 34 81 87 13 22 43 68 80 92 74 26 39 98 44 94 28 39 23 27 71 33 17 11 8 60 30 69 10 30 9 88 33 41 39 30 37 28 83 70 76 18 60 91 28 1 51 98 87 21 78 44 58 55 73 98 86 14 89 19 86 45 92 26 30 31 15 25 26 37 12 91 69 92 100 19 14 29 22 26 47 38 14 5 45 28 39 16 61 59 53 41 14 84 60 91 89 40 71 59 88 18 87 47 23 17 5 30 38 51 59 61 100 63 79 45 81 20 14 90 6 76 67 61 72 78 2 48 45 20 2 41 59 22 90 98 87 89 59 68 62 81 1 95 51 63 42 100 11 99 63 23 100 96 2 37 27 87 36 47 43 64 81 78 47 13 27 1 15 24 3 82 64 25 76 44 43 54 50 6 18 62 36 99 91 27 66 25 68 44 88 46 17 15 89 6 17 35 85 71 81 31 20 62 7 90 45 41 28 5 91 84 43 56 79 79 84 33 96 83 89 75 77 49 33 69 95 5 48 61 9 64 16 5 70 86 79 65 62 73 67 95 97 77 20 81 79 62 14 83 82 53 12 22 68 18 26 58 58 99 92 45 29 36 97 26 69 42 33 24 17 28 98 36 97 77 95 42 72 24 33 56 42 22 1 53 51 3 64 87 90 93 38 10 43 64 74 11 42 48 44 5 98 99 39 20 30 52 79 9 15 89 9 100 24 74 14 74 88 27 4 59 48 34 48 57 39 19 45 74 12 90 4 7 19 12 82 12 92 75 13 20 99 5 35 27 34 65 17 23 74 3 65 54 71 10 76 59 99 93 29 17 27 7 61 15 46 93 25 50 56 45 47 82 52 85 13 70 10 72 53 27 18 89 35 40 55 66 34 69 81 74 83 76 91 23 47 66 46 54 58 8 48 22 23 36 58 60 57 83 55 90 2 38 58 3 54 58 76 36 48 70 60 35 37 93 97 99 59 77 87 37 44 18 90 18 88 24 90 82 99 73 89 3 12 53 92 60 55 31 75 78 20 83 92 3 37 34 96 90 8 31 46 28 3 62 61 98 95 52 30 96 65 1 21 71 16 94 43 84 73 63 14 40 1 2 89 14 62 82 8 44 27 61 89 58 71 14 74 92 82 40 36 45 5 44 53 75 81 71 56 84 88 86 55 72 3 53 16 4 9 13 57 17 22 5 10 19 93 9 99 75 39 74 44 49 18 19 27 94 11 27 97 91 80 53 50 56 47 83 4 2 16 71 72 14 3 25 61 95 20 91 66 8 25 8 88 68 96 41 42 88 34 27 68 21 21 11 61 99 67 16 57 15 65 17 87 29 37 88 56 87 16 89 66 60 97 61 38 34 4 99 55 33 47 82 24 54 96 40 14 93 81 73 99 67 23 42 9 72 8 75 25 74 58 49 92 28 33 41 69 60 32 15 57 82 81 72 18 19 64 89 52 50 52 37 59 42 91 26 67 95 21 100 95 48 72 45 66 19 39 32 37 33 2 99 56 66 36 1 92 34 66 40 43 91 73 92 44 13 83 38 51 48 99 57 74 42 52 33 78 34 82 71 19 89 14 82 56 69 56 29 92 86 80 47 12 7 23 6 62 51 41 80 55 73 66 5 83 82 94 59 36 99 54 9 62 97 42 81 85 4 94 13 25 52 92 81 46 42 14 63 14 92 12 90 25 81 78 diff --git a/subset-sum/input/84 b/subset-sum/input/84 new file mode 100644 index 0000000..853530b --- /dev/null +++ b/subset-sum/input/84 @@ -0,0 +1,2 @@ +465 1784 +70 36 69 46 76 72 62 2 24 56 66 80 57 29 20 60 69 85 51 9 65 26 20 10 88 25 100 97 16 16 19 87 17 56 2 30 92 55 34 39 6 79 79 24 94 89 10 15 18 36 39 29 3 63 12 76 92 38 52 97 11 58 89 40 16 45 94 58 60 99 78 50 75 51 35 61 6 19 16 8 94 87 91 94 96 34 100 16 23 25 32 43 37 58 14 13 82 59 58 93 46 16 25 46 55 25 86 40 54 49 53 34 70 64 62 21 68 38 58 24 93 33 43 58 66 56 19 4 54 82 45 80 100 55 59 19 23 95 37 23 32 97 37 6 56 46 37 17 7 11 8 10 58 91 49 55 38 42 86 24 99 79 43 77 1 79 97 45 82 47 63 40 90 42 100 26 22 77 38 74 10 34 89 33 59 57 82 16 69 6 49 41 6 9 96 35 78 4 13 33 8 93 24 94 63 13 22 56 83 18 83 5 8 82 85 77 15 81 51 31 8 75 7 36 17 60 96 26 41 90 93 97 86 55 72 58 100 25 80 63 71 8 7 53 49 38 45 62 62 70 79 67 62 41 9 47 59 85 88 66 68 14 96 87 67 83 28 11 76 61 33 88 91 63 47 14 94 81 36 53 84 21 86 61 8 41 89 20 24 98 23 52 18 63 47 51 55 80 15 97 74 20 81 93 54 71 93 80 53 8 18 73 14 45 57 31 60 70 1 59 32 85 90 87 7 5 24 71 62 26 29 44 97 59 37 72 88 45 47 8 88 21 67 62 55 97 54 15 72 24 4 70 100 93 15 51 56 28 77 57 37 6 70 80 70 56 20 16 65 12 29 20 55 23 16 88 71 32 83 24 91 91 55 87 83 39 84 60 52 49 14 20 70 15 43 90 99 82 54 2 98 40 17 94 32 42 43 100 74 47 40 70 57 96 40 97 13 38 44 3 39 3 41 24 23 17 26 9 7 45 59 16 10 57 25 82 65 63 58 85 17 48 7 22 3 93 21 76 67 26 79 39 9 94 80 34 28 96 34 85 70 25 91 64 17 diff --git a/subset-sum/input/85 b/subset-sum/input/85 new file mode 100644 index 0000000..1466669 --- /dev/null +++ b/subset-sum/input/85 @@ -0,0 +1,2 @@ +959 5615 +2 37 64 1 31 43 97 46 99 68 36 5 64 31 3 98 8 27 50 90 41 47 4 24 55 24 11 23 49 39 11 78 60 28 47 50 15 80 13 88 1 8 97 53 74 43 81 43 38 72 40 43 45 10 86 45 33 94 10 18 64 52 32 19 99 78 88 59 51 72 57 49 12 3 26 99 5 54 13 20 54 64 39 39 62 52 65 62 69 79 94 4 87 33 79 12 19 56 1 99 85 36 91 33 97 37 21 89 97 41 90 37 95 51 99 95 77 13 61 46 87 55 43 2 24 53 38 100 33 13 4 18 32 15 22 73 11 79 93 98 91 43 76 48 73 42 92 98 69 70 23 70 9 58 58 94 86 17 47 3 96 57 8 57 33 93 94 52 22 68 26 71 58 60 39 75 100 36 43 80 2 5 70 56 61 85 98 58 26 27 21 93 8 5 69 51 83 2 3 38 66 60 81 70 98 100 52 25 9 13 71 5 16 40 54 10 98 3 3 98 26 49 29 31 53 64 83 4 38 87 14 36 28 20 5 45 75 31 74 94 99 85 76 98 7 71 47 95 60 4 74 12 60 94 69 8 83 66 75 32 14 75 26 56 75 23 78 91 45 2 33 87 70 61 98 58 12 36 33 36 11 64 89 18 3 18 31 88 15 83 36 100 31 46 79 76 43 45 92 40 85 32 70 71 23 64 94 61 62 69 29 95 84 48 10 43 92 14 66 79 40 87 94 91 94 12 33 76 96 38 32 5 90 77 55 14 76 94 43 40 54 25 30 10 10 31 8 67 57 89 14 62 71 3 94 77 18 98 17 94 95 27 96 97 36 57 74 12 63 35 21 1 22 48 61 32 17 9 20 31 32 7 60 16 14 94 87 38 47 71 98 60 54 62 46 52 44 93 35 73 39 84 96 70 100 75 36 65 94 23 24 73 48 100 63 13 83 64 9 82 61 15 40 93 87 37 78 66 13 84 52 70 17 40 5 50 91 72 89 18 75 23 74 11 86 21 83 97 81 50 44 2 97 38 39 29 38 24 10 92 71 6 23 22 11 43 74 26 35 97 35 74 2 3 81 41 12 21 88 41 88 62 72 53 34 53 56 68 41 37 80 9 30 96 15 17 59 17 34 5 57 6 10 41 59 6 34 37 8 36 91 28 97 2 6 80 92 27 38 7 14 90 55 65 34 8 84 88 60 3 30 94 4 5 83 83 28 53 100 13 17 78 99 98 26 30 17 1 72 84 73 61 68 46 23 28 72 16 74 70 91 11 52 44 80 52 16 93 19 90 22 12 68 24 32 83 49 16 69 10 4 40 21 70 60 93 37 71 19 60 46 67 98 79 98 84 97 98 43 26 3 31 91 42 39 100 26 64 26 74 59 54 38 28 27 3 36 52 16 41 59 58 11 91 19 43 58 88 36 23 80 22 36 95 8 48 32 36 69 4 59 23 77 5 33 91 90 2 34 46 4 94 81 88 45 67 62 5 36 67 24 36 33 1 39 95 75 72 94 52 90 35 50 39 25 24 78 85 58 5 97 83 5 70 16 45 45 85 69 47 2 93 65 27 100 32 42 86 7 32 62 10 16 9 18 34 55 94 12 58 23 64 26 11 4 30 80 89 5 39 66 68 14 30 99 66 20 57 31 31 60 44 10 24 8 95 43 37 77 19 98 75 66 33 95 83 99 93 97 20 47 69 15 53 39 23 50 17 41 75 97 49 86 50 40 29 4 32 94 83 89 15 35 99 6 98 14 5 12 15 63 83 91 29 71 16 58 87 99 66 56 55 25 29 14 68 99 58 74 4 22 20 14 63 96 66 71 34 78 95 79 92 95 57 67 45 83 67 93 78 65 47 63 34 66 85 35 33 96 21 25 23 87 77 92 21 55 76 85 25 43 57 26 89 60 22 77 4 49 41 86 4 61 47 48 1 4 52 93 25 89 64 94 78 5 41 64 55 31 22 77 79 82 77 15 65 50 99 60 30 16 59 84 90 45 90 67 67 63 26 64 76 52 38 11 52 21 92 12 21 88 15 50 81 66 97 73 84 30 66 68 68 96 55 32 87 51 9 6 65 15 39 17 3 20 99 58 13 97 18 14 97 94 23 4 50 91 24 52 78 51 77 5 80 61 7 28 7 42 74 63 57 85 44 35 97 45 24 70 diff --git a/subset-sum/input/86 b/subset-sum/input/86 new file mode 100644 index 0000000..3158ad6 --- /dev/null +++ b/subset-sum/input/86 @@ -0,0 +1,2 @@ +78 9458 +31 78 17 42 31 95 46 5 46 33 16 57 67 12 16 52 66 14 63 26 75 25 33 52 72 42 34 64 40 19 89 15 72 2 16 63 97 92 42 89 32 55 85 64 69 48 24 16 49 93 17 64 4 80 48 16 15 75 19 96 47 94 24 99 92 68 58 93 67 34 44 18 53 50 49 100 54 29 diff --git a/subset-sum/input/87 b/subset-sum/input/87 new file mode 100644 index 0000000..bc58105 --- /dev/null +++ b/subset-sum/input/87 @@ -0,0 +1,2 @@ +866 4154 +30 98 11 3 31 1 39 2 69 100 55 9 57 26 54 89 55 79 24 49 64 29 34 20 29 78 80 22 97 100 20 71 43 15 48 59 10 11 48 80 51 35 94 35 23 35 84 44 22 39 13 33 21 33 44 59 52 12 19 37 97 83 5 83 3 50 57 100 52 46 93 100 84 59 96 27 47 89 28 80 39 8 13 63 72 3 92 52 55 30 13 49 27 8 41 76 10 10 53 75 93 14 13 53 8 77 41 48 48 77 80 70 28 47 88 42 51 74 8 18 80 98 74 51 53 14 65 42 77 4 35 30 26 15 4 16 51 95 74 94 51 46 3 85 53 11 23 95 29 18 43 29 85 100 18 62 34 34 88 41 79 6 90 4 33 34 11 84 38 27 42 17 53 56 86 97 68 16 92 33 91 31 29 17 74 54 70 46 62 39 66 18 44 10 75 14 20 38 45 77 20 45 49 98 7 15 79 42 7 59 90 31 39 54 22 47 89 54 89 79 53 77 39 32 8 3 12 53 35 83 54 15 61 3 36 100 24 75 60 68 9 95 14 32 99 18 67 21 20 43 79 61 16 64 19 7 56 93 92 62 68 58 54 54 90 59 34 51 73 69 80 48 30 60 97 57 6 35 39 78 86 69 80 13 70 84 27 55 63 45 59 88 81 2 42 55 17 28 23 79 8 12 80 73 34 50 8 8 37 33 38 47 47 13 61 86 79 10 90 13 53 42 93 60 57 23 9 13 28 82 75 85 67 45 86 63 74 21 50 92 34 21 77 85 24 38 21 36 60 61 88 44 78 56 23 16 28 81 31 32 70 21 86 24 21 26 88 39 9 50 24 73 99 38 54 1 36 16 24 60 15 85 14 52 3 11 92 78 31 52 12 77 60 62 29 100 82 5 81 4 11 92 44 55 91 72 47 22 43 43 18 13 2 63 75 86 55 52 36 37 64 13 73 62 24 40 43 53 99 53 90 34 81 99 8 91 47 16 24 9 65 48 40 67 52 33 35 32 34 58 4 53 1 23 68 57 8 3 48 32 63 67 74 13 10 56 51 16 97 36 3 32 58 9 97 86 98 33 78 72 60 5 74 79 70 10 68 14 27 47 89 76 94 49 64 2 70 57 65 82 15 26 90 37 31 16 21 74 59 18 61 21 78 9 16 66 53 23 78 63 14 1 88 69 88 65 55 75 97 44 43 66 24 89 92 99 71 97 48 8 55 97 78 12 75 15 17 90 76 9 43 26 56 56 19 91 62 82 100 62 19 41 8 50 97 50 17 99 27 78 95 35 42 37 43 91 83 14 42 83 10 100 24 26 44 32 46 71 51 64 93 3 77 26 96 76 48 83 9 83 17 9 49 35 88 53 96 8 46 82 57 90 91 24 56 39 13 21 43 4 59 92 97 4 18 93 11 75 39 86 41 41 79 21 98 77 46 40 3 2 45 19 80 97 100 10 56 65 4 96 72 98 70 37 28 3 6 53 89 60 69 50 76 24 100 98 86 52 11 19 86 22 54 10 54 14 52 72 50 85 71 60 56 5 100 27 98 95 62 62 83 29 91 72 94 92 20 25 66 40 3 16 44 26 4 22 16 29 95 96 52 74 89 65 83 74 2 98 24 48 56 53 48 4 71 94 28 74 16 73 20 41 86 14 97 24 44 51 45 88 29 90 89 76 10 52 74 36 59 91 85 43 30 48 49 81 39 66 40 41 67 98 79 51 33 69 2 24 91 17 85 65 18 68 46 16 30 75 83 39 52 85 85 63 24 29 80 82 18 15 100 37 77 36 84 67 63 81 30 16 86 77 28 87 11 12 73 92 58 48 100 31 35 8 48 28 24 60 7 9 37 86 12 42 10 60 17 92 36 11 17 14 8 46 78 87 99 89 60 34 97 46 13 5 2 12 35 90 4 71 9 57 38 41 38 73 10 48 60 2 1 94 11 8 26 20 diff --git a/subset-sum/input/88 b/subset-sum/input/88 new file mode 100644 index 0000000..764a7c4 --- /dev/null +++ b/subset-sum/input/88 @@ -0,0 +1,2 @@ +812 4630 +54 35 86 70 19 86 56 96 72 81 13 61 71 100 86 22 27 18 64 49 14 95 76 26 84 82 80 25 82 23 1 5 33 35 31 42 80 86 51 56 45 48 86 58 77 90 99 64 11 60 21 34 77 90 74 7 11 72 81 22 38 44 57 8 23 75 40 44 89 4 61 45 22 72 46 84 86 57 31 48 19 84 65 32 64 86 84 85 58 94 49 53 45 2 72 36 40 53 100 71 61 100 14 40 38 10 42 100 87 93 26 1 9 44 20 16 25 100 56 72 91 54 4 69 60 9 99 30 28 97 83 35 28 20 63 80 5 28 57 64 83 67 72 51 75 26 67 37 98 31 85 16 92 84 43 6 17 9 21 13 75 9 29 57 18 14 30 5 99 40 59 78 22 22 46 22 76 45 17 23 62 63 60 6 48 66 1 40 90 3 98 89 46 31 79 59 56 85 89 51 57 45 36 45 17 78 50 43 69 38 22 46 33 45 27 69 19 74 98 4 10 41 59 26 36 74 88 19 93 33 88 83 6 20 53 61 38 32 10 61 12 83 35 43 84 76 8 57 57 91 86 25 66 58 50 73 69 82 56 64 29 74 89 96 30 67 81 79 43 71 66 96 7 6 50 52 29 40 17 99 71 17 66 83 92 11 57 92 70 40 23 35 93 33 2 2 37 72 80 77 88 31 16 45 13 14 5 84 39 61 14 14 68 72 24 2 86 38 51 69 2 14 70 95 31 73 30 5 64 90 66 29 7 76 66 54 83 48 8 4 67 80 53 90 52 13 94 19 75 97 25 20 69 51 67 24 49 2 97 26 17 89 4 83 38 62 23 85 55 66 37 57 26 63 36 15 60 71 40 69 15 47 97 19 55 96 89 38 22 28 91 12 2 66 45 97 32 54 63 18 87 82 82 84 53 97 66 61 50 86 12 24 15 93 37 44 36 62 97 77 15 80 1 11 39 8 5 97 25 59 3 3 46 40 46 8 95 91 72 57 56 19 44 40 54 80 45 98 65 70 68 18 6 41 22 95 26 23 88 10 90 77 50 98 77 38 9 26 92 10 20 58 85 100 43 38 68 13 55 93 65 83 39 48 77 43 2 93 5 99 39 4 5 77 68 30 38 86 67 4 93 19 60 40 82 63 85 61 65 79 45 50 52 5 81 7 7 27 78 100 83 77 1 52 92 57 65 67 71 2 97 20 57 73 7 4 1 7 19 93 90 11 74 60 75 21 39 68 89 67 65 88 49 28 58 45 42 3 2 49 15 65 10 57 64 73 42 93 4 41 3 7 6 79 58 55 73 78 19 29 54 33 35 41 41 24 23 11 96 87 38 29 3 76 54 56 26 65 27 63 87 92 35 73 65 33 57 71 98 8 51 48 89 72 16 16 97 45 34 58 93 51 97 22 29 33 26 47 56 51 52 78 4 56 15 13 51 80 8 1 90 95 70 88 85 29 40 8 100 64 85 14 37 57 39 96 43 42 64 68 72 50 40 78 13 53 5 42 73 5 46 100 77 71 29 10 75 66 88 13 66 55 15 76 88 80 92 7 80 54 46 94 80 42 16 44 97 3 91 57 46 26 95 16 80 73 18 57 93 5 27 99 52 16 1 95 78 60 33 96 61 14 64 29 72 92 18 63 24 55 48 40 94 97 35 93 62 40 99 81 98 49 57 19 45 95 61 32 32 34 9 86 88 84 20 6 86 35 88 47 14 36 52 93 17 9 63 76 35 4 11 98 50 35 87 80 81 2 33 5 41 4 25 77 43 11 32 76 72 55 41 33 88 58 56 19 48 47 78 79 44 18 50 96 37 38 88 42 68 11 36 56 diff --git a/subset-sum/input/89 b/subset-sum/input/89 new file mode 100644 index 0000000..7c51c69 --- /dev/null +++ b/subset-sum/input/89 @@ -0,0 +1,2 @@ +69 3308 +87 14 65 39 91 79 77 16 18 55 33 66 71 47 42 89 100 8 40 17 41 60 72 17 72 73 27 93 39 64 25 6 37 63 3 80 81 51 49 94 65 95 41 30 17 11 75 49 34 19 15 21 19 9 70 27 27 82 100 97 8 5 59 72 86 94 39 51 46 diff --git a/subset-sum/input/9 b/subset-sum/input/9 new file mode 100644 index 0000000..31dfbff --- /dev/null +++ b/subset-sum/input/9 @@ -0,0 +1,2 @@ +75 5297 +80 17 38 76 83 65 40 41 55 3 16 56 13 11 74 31 24 9 76 4 51 99 76 25 93 39 37 74 23 46 19 54 57 14 43 86 97 100 56 9 79 79 61 14 23 44 100 94 47 20 52 63 74 29 84 30 22 65 46 85 91 53 5 10 53 56 43 94 54 97 75 31 74 20 37 diff --git a/subset-sum/input/90 b/subset-sum/input/90 new file mode 100644 index 0000000..1609fb4 --- /dev/null +++ b/subset-sum/input/90 @@ -0,0 +1,2 @@ +249 3791 +82 52 85 57 52 98 33 55 26 6 70 61 90 60 19 19 29 21 52 18 73 65 16 61 16 26 86 71 7 15 48 52 3 66 55 47 67 58 96 91 85 82 15 58 100 80 35 83 69 3 19 62 87 25 83 11 65 86 40 90 88 43 32 38 54 76 67 93 28 18 49 74 40 69 37 31 92 36 31 23 98 44 91 89 78 21 85 43 35 33 71 61 50 54 73 27 1 16 64 34 74 69 59 48 41 84 52 39 5 7 93 66 24 92 57 40 62 3 3 3 2 27 31 98 90 69 76 52 86 64 98 35 12 83 17 69 55 89 25 86 60 41 9 80 91 88 32 18 32 97 38 26 87 68 92 79 95 86 64 59 28 91 62 79 85 45 30 34 86 6 23 97 43 90 5 37 84 11 8 44 63 78 59 20 5 61 74 31 49 19 1 30 83 86 14 61 94 18 39 73 95 15 62 51 32 31 83 14 2 24 25 76 83 79 53 34 64 40 10 83 16 40 19 97 64 35 48 96 85 10 46 28 5 42 26 80 50 98 10 98 9 14 16 40 12 59 56 82 45 diff --git a/subset-sum/input/91 b/subset-sum/input/91 new file mode 100644 index 0000000..e10db00 --- /dev/null +++ b/subset-sum/input/91 @@ -0,0 +1,2 @@ +383 5354 +57 13 35 11 22 74 56 36 93 81 9 94 19 16 65 56 16 41 58 26 45 89 62 24 55 75 25 57 26 39 90 77 83 35 46 84 75 85 68 80 34 42 76 55 32 100 71 11 19 30 64 39 68 3 38 61 65 91 44 31 9 82 23 72 80 38 100 94 43 73 80 30 22 80 57 29 65 74 100 35 6 11 9 46 49 58 13 83 91 36 69 18 52 34 84 37 13 2 5 85 10 86 42 21 61 24 26 17 93 9 72 44 12 30 62 6 90 46 31 55 88 2 34 30 22 19 64 83 84 72 97 38 13 61 72 93 23 13 19 74 85 69 92 34 90 7 46 63 38 4 29 20 8 90 53 68 19 86 39 30 43 11 85 99 47 65 53 67 25 19 26 80 51 86 71 58 94 88 46 30 22 94 5 78 35 6 21 42 79 6 66 71 65 39 68 34 80 71 94 57 42 31 21 95 81 53 25 43 42 15 44 97 24 90 85 17 46 52 83 82 70 3 56 56 23 20 18 15 36 85 5 17 78 87 71 80 74 69 58 26 49 23 42 86 6 67 61 78 100 16 81 96 25 22 21 35 43 71 80 84 99 69 88 23 82 21 4 26 75 98 83 37 51 56 87 13 59 78 83 84 9 64 58 38 51 1 29 67 75 43 56 3 6 6 94 5 92 61 5 29 70 16 47 94 73 27 20 96 52 13 97 43 13 26 10 82 40 26 85 77 31 56 60 11 80 80 19 33 30 13 97 53 5 76 22 84 85 94 67 33 52 30 70 7 88 73 81 79 53 17 31 16 41 70 80 49 22 12 20 34 35 87 92 39 51 77 89 67 65 27 10 99 30 57 2 89 71 74 76 61 16 48 78 diff --git a/subset-sum/input/92 b/subset-sum/input/92 new file mode 100644 index 0000000..ff2cca9 --- /dev/null +++ b/subset-sum/input/92 @@ -0,0 +1,2 @@ +931 7706 +62 98 99 18 53 4 20 44 78 46 62 49 11 62 80 81 46 56 70 17 4 6 96 9 83 18 53 27 17 87 57 59 67 60 23 74 67 31 16 72 18 63 54 49 54 19 58 3 5 53 46 54 53 28 80 51 30 43 46 70 59 83 11 80 49 25 28 57 46 9 92 43 79 84 7 21 3 71 77 29 10 90 64 7 83 62 69 35 10 39 96 15 78 47 39 59 4 69 55 95 62 43 50 21 26 92 2 72 49 71 49 54 28 94 31 75 86 44 20 43 27 7 43 96 71 94 16 34 61 32 78 77 44 96 38 62 22 39 78 94 52 41 31 58 39 57 75 38 94 8 92 34 54 18 87 12 28 29 26 31 43 51 83 90 43 100 14 51 99 66 55 96 48 47 61 22 44 87 5 24 36 16 85 24 2 40 53 79 31 42 33 5 38 81 65 70 76 15 64 71 26 72 2 81 42 81 54 28 74 93 60 26 75 79 55 6 35 85 76 74 56 23 94 25 50 98 88 81 53 62 47 74 85 81 29 49 61 33 83 70 61 62 64 75 75 53 3 47 25 94 84 59 49 63 60 77 80 75 69 43 96 28 71 24 82 33 2 16 69 1 61 100 53 26 45 31 28 75 12 91 77 90 6 64 4 34 79 59 39 54 19 37 36 25 65 22 56 12 68 3 74 92 53 64 18 93 83 34 83 31 10 94 86 69 33 32 8 73 20 70 63 57 74 82 29 9 87 83 76 71 64 33 61 94 78 16 29 24 87 77 11 47 65 61 60 83 1 88 65 51 21 35 20 92 70 99 44 29 19 27 49 13 76 38 37 87 29 3 29 33 76 99 32 70 90 27 3 45 54 15 51 56 100 60 47 85 52 54 60 20 65 71 11 67 50 70 54 24 100 21 34 19 98 20 26 57 88 80 56 98 85 5 51 12 40 91 79 58 3 41 37 26 47 9 66 23 49 58 96 28 21 51 69 23 2 4 50 91 67 80 21 82 76 34 16 68 90 35 76 18 47 71 47 79 3 63 30 75 30 9 28 11 7 79 49 18 54 8 83 92 27 4 52 37 93 98 30 6 85 53 3 57 68 60 22 16 100 65 100 70 99 59 60 81 74 79 82 69 56 27 41 20 53 42 65 4 32 38 22 76 64 27 98 7 39 1 15 48 18 81 79 96 70 32 27 95 47 47 76 95 19 13 45 35 24 80 10 78 75 5 75 66 18 31 75 5 11 52 1 35 62 61 91 58 86 89 86 32 1 93 3 33 80 59 5 6 60 58 1 91 40 47 97 18 80 16 73 66 16 28 97 49 22 88 45 14 64 21 3 44 40 83 52 73 2 87 95 48 9 78 37 12 26 21 72 30 36 75 33 38 50 30 89 59 64 78 99 54 15 88 68 80 72 72 58 89 1 91 34 25 44 66 87 31 29 45 76 97 33 10 9 82 98 51 23 4 68 7 79 42 86 18 15 50 42 56 77 76 53 42 99 70 16 61 53 66 50 45 14 43 59 7 83 96 22 76 82 56 48 44 80 92 28 20 100 24 68 4 78 59 70 97 44 46 5 60 29 64 48 53 37 33 2 41 14 54 25 56 30 43 98 16 67 78 10 56 73 65 88 42 88 48 81 62 47 65 11 69 2 82 19 39 37 42 63 73 39 84 4 19 12 14 61 95 7 91 38 69 36 54 2 100 11 45 77 35 28 67 63 78 48 2 71 85 55 22 17 33 40 24 8 30 71 76 29 22 87 87 87 84 92 46 32 18 11 49 46 35 41 60 60 90 96 82 52 34 93 13 88 36 83 84 66 52 11 89 63 63 58 35 21 62 18 100 32 86 13 60 65 91 64 13 18 89 61 53 7 14 73 8 21 78 3 43 5 81 32 13 61 28 73 82 52 4 48 75 69 78 39 3 92 14 20 85 81 80 79 76 47 85 91 33 22 59 21 33 30 85 63 5 21 32 70 72 45 85 92 72 96 33 95 53 93 27 9 12 6 78 78 89 13 64 61 6 33 72 63 42 31 25 42 100 23 64 60 49 87 98 45 5 15 15 49 82 24 17 63 79 16 91 67 30 51 82 89 87 45 72 59 95 46 diff --git a/subset-sum/input/93 b/subset-sum/input/93 new file mode 100644 index 0000000..e4fa765 --- /dev/null +++ b/subset-sum/input/93 @@ -0,0 +1,2 @@ +551 5381 +34 73 19 83 33 70 57 96 97 60 25 99 74 35 93 3 21 63 3 49 62 95 7 66 38 15 27 72 35 82 41 70 15 41 4 51 65 54 8 87 4 34 29 19 26 52 85 100 74 91 47 48 70 16 20 4 77 21 9 47 66 48 87 69 88 54 6 21 40 44 14 12 42 9 69 16 61 50 72 30 30 77 53 24 8 22 52 88 59 73 7 34 21 38 91 30 4 56 14 100 18 91 92 98 52 50 61 38 15 61 10 5 53 52 12 98 26 70 71 40 57 87 48 43 14 2 3 16 87 92 62 52 60 11 64 30 37 68 15 82 44 69 19 18 32 64 37 20 55 50 85 18 25 9 4 37 87 71 82 35 69 72 93 14 21 16 20 42 37 51 41 90 33 87 64 48 82 57 73 68 76 84 94 65 25 13 59 57 40 77 84 64 63 38 47 12 73 67 39 52 56 87 42 28 76 46 88 7 47 4 29 66 76 96 3 18 56 18 90 9 23 57 50 46 60 86 8 80 32 55 90 95 3 89 94 16 59 46 47 68 44 20 56 12 66 84 19 52 86 56 100 59 82 90 63 77 32 38 61 14 95 8 15 64 1 95 34 52 98 56 69 73 35 21 59 68 77 94 6 75 64 51 61 30 76 68 63 13 51 88 81 88 96 30 64 17 78 87 12 46 59 98 87 52 78 43 68 17 46 61 9 63 1 16 93 79 41 87 14 27 82 15 28 52 65 74 40 84 59 61 54 37 48 66 32 32 77 19 41 96 23 45 6 44 1 98 57 36 13 32 89 85 40 83 11 57 86 95 95 8 34 7 48 97 88 20 48 58 98 32 21 63 34 11 59 91 56 9 76 91 81 70 18 5 57 81 96 35 73 53 78 89 21 43 48 87 84 86 35 64 51 70 12 92 38 6 100 19 62 30 90 67 100 77 79 23 17 95 29 94 12 9 52 20 87 60 100 14 54 62 70 84 39 13 87 58 76 94 67 24 88 7 35 89 66 5 92 81 37 19 41 67 22 97 45 44 57 50 15 66 60 27 88 69 26 58 13 65 98 7 6 15 61 82 12 95 40 79 51 77 39 93 65 41 11 71 1 17 54 98 93 95 65 97 69 68 9 28 10 62 91 2 60 99 46 14 48 27 88 34 18 62 34 75 92 56 52 90 33 71 9 23 15 97 29 44 62 76 22 39 10 48 11 53 49 84 13 56 11 49 8 62 4 44 83 59 94 9 96 47 80 diff --git a/subset-sum/input/94 b/subset-sum/input/94 new file mode 100644 index 0000000..70f2fbc --- /dev/null +++ b/subset-sum/input/94 @@ -0,0 +1,2 @@ +815 3718 +81 44 41 1 13 49 84 59 27 34 87 98 90 9 74 60 18 5 55 28 55 53 68 64 56 83 54 39 40 42 16 15 76 28 10 68 31 60 51 64 93 93 47 73 45 65 93 30 50 59 3 14 30 42 45 87 26 55 97 1 27 75 58 13 97 87 4 30 2 26 26 11 4 79 81 27 84 80 70 75 48 52 63 24 73 22 67 27 42 79 41 98 83 44 97 14 43 13 76 51 39 88 71 54 100 28 80 28 65 74 100 8 70 60 6 89 15 45 26 33 86 54 95 91 93 20 62 2 86 39 29 92 9 8 21 4 17 24 72 88 87 80 51 80 30 23 17 13 85 99 67 27 4 12 22 55 99 75 52 81 62 68 11 60 84 72 72 61 84 48 9 40 22 41 8 95 23 66 50 52 68 57 8 19 8 85 78 10 55 77 79 76 16 60 90 47 8 71 76 10 60 87 60 91 91 49 61 1 73 72 43 59 1 57 27 3 4 22 87 29 36 3 31 70 18 64 70 93 61 22 70 45 85 74 7 93 37 20 92 71 32 13 35 45 91 37 56 35 18 66 49 31 51 32 73 3 22 55 28 71 28 28 49 84 3 27 28 74 80 50 13 39 85 17 79 62 35 25 77 65 5 61 61 20 67 40 24 32 8 29 95 68 8 4 21 58 15 44 99 79 48 84 94 55 59 69 41 67 7 15 20 87 33 44 94 48 87 39 48 87 22 6 19 20 73 33 54 72 72 92 50 27 53 45 97 3 78 64 16 34 45 77 16 28 95 93 56 91 78 94 57 66 2 26 85 71 16 48 61 41 2 51 35 74 40 21 85 81 78 74 56 49 36 10 1 13 73 94 68 58 81 51 48 44 75 34 84 54 87 79 1 97 9 50 5 88 16 5 14 71 84 27 17 96 97 14 40 36 89 47 52 48 2 97 88 58 1 85 24 75 12 25 26 80 82 72 53 14 49 23 81 72 27 28 72 9 18 50 16 63 51 58 30 66 44 93 69 86 61 55 49 68 34 54 97 22 12 25 5 83 88 57 60 52 51 8 76 46 45 73 17 41 21 5 25 38 75 25 47 66 6 25 87 1 90 26 28 32 7 9 39 7 36 7 49 48 13 79 77 74 97 15 67 63 85 91 94 26 27 11 67 89 32 86 7 36 27 38 33 49 15 29 46 46 61 71 55 19 71 89 87 61 42 52 39 63 62 36 68 29 41 53 32 36 51 90 48 19 17 57 99 41 73 12 58 81 55 15 55 77 59 31 31 59 93 4 55 43 40 100 18 71 84 19 74 90 48 65 3 17 4 87 15 17 36 98 96 91 19 90 12 2 72 84 8 57 57 76 81 86 51 100 51 77 40 99 93 71 94 91 2 15 8 8 75 12 28 51 79 88 19 92 10 75 23 92 2 30 22 15 21 57 80 31 40 65 45 19 82 99 97 57 43 71 6 1 73 62 41 32 23 89 49 73 9 55 59 51 13 6 96 2 65 82 82 93 75 25 32 18 91 98 41 30 45 79 29 41 29 19 36 83 40 20 41 94 25 10 88 86 6 78 80 19 3 43 49 79 71 25 44 33 3 21 70 94 8 62 81 56 57 3 92 18 79 67 65 82 59 84 54 76 56 88 69 60 42 19 26 19 84 11 13 50 67 71 53 34 13 12 71 2 35 27 49 61 99 97 3 21 14 57 77 5 27 86 15 84 94 31 96 55 90 49 7 71 25 100 5 1 62 6 9 28 46 38 23 82 48 87 62 68 14 90 10 53 11 92 46 99 72 5 19 54 38 6 87 91 67 56 51 19 85 79 77 45 58 80 79 99 26 87 94 86 76 diff --git a/subset-sum/input/95 b/subset-sum/input/95 new file mode 100644 index 0000000..0dff871 --- /dev/null +++ b/subset-sum/input/95 @@ -0,0 +1,2 @@ +298 9087 +57 5 80 59 2 15 95 63 69 79 54 100 83 44 64 77 32 66 51 31 25 91 50 96 75 22 27 32 87 83 70 99 56 60 100 49 32 11 56 88 46 49 18 50 81 57 3 17 76 75 14 89 1 58 59 14 67 6 62 19 83 43 4 39 54 60 23 96 25 68 73 47 35 5 17 85 27 83 33 2 24 70 53 81 31 90 31 49 5 28 65 31 26 68 14 41 55 37 81 56 13 27 72 87 16 93 95 14 72 99 43 40 39 62 83 90 65 7 86 46 75 88 70 12 13 74 3 72 96 96 94 42 8 78 35 24 95 67 16 96 45 96 99 76 89 59 20 92 34 77 12 72 52 8 79 30 59 22 71 16 44 88 47 9 43 87 37 23 94 7 68 71 40 31 75 77 7 94 20 79 79 9 2 47 64 10 71 6 12 39 3 42 75 5 71 77 41 82 75 55 8 71 44 68 55 58 10 43 96 13 72 48 74 6 51 47 96 93 91 15 53 13 22 28 13 39 58 46 66 29 67 76 49 5 83 77 33 99 17 94 100 78 31 98 21 68 55 97 59 18 53 22 100 85 44 64 43 83 17 5 71 70 55 18 25 60 45 32 30 1 18 55 75 65 81 9 36 79 91 28 5 15 15 77 27 77 1 5 24 40 14 72 99 60 70 13 61 64 diff --git a/subset-sum/input/96 b/subset-sum/input/96 new file mode 100644 index 0000000..8ad87cb --- /dev/null +++ b/subset-sum/input/96 @@ -0,0 +1,2 @@ +763 1439 +71 97 47 53 37 32 46 58 77 76 1 12 6 82 100 70 98 63 78 96 76 50 83 41 54 39 69 58 40 5 84 50 87 97 44 28 63 77 43 3 66 30 47 69 87 34 69 32 55 95 49 12 91 41 24 4 80 8 34 72 18 80 68 60 58 91 31 60 52 47 78 22 53 1 21 92 6 63 68 79 64 51 80 41 98 30 47 39 78 82 35 83 68 40 19 68 84 2 70 77 28 54 89 75 89 38 29 40 86 14 15 52 60 33 11 11 12 36 62 68 10 89 83 88 32 45 42 21 14 15 56 12 48 31 100 28 23 59 5 29 20 74 74 89 67 32 20 90 49 99 52 74 94 89 63 86 96 28 99 24 63 28 9 36 19 73 61 43 69 58 80 23 97 99 31 56 77 88 21 67 61 31 53 86 70 47 41 5 31 59 24 11 11 79 61 90 89 88 38 3 54 46 62 11 66 57 12 57 31 17 33 93 57 41 49 94 76 9 83 5 86 44 57 36 78 87 13 60 94 68 14 60 34 16 56 100 30 13 63 78 32 4 80 52 92 12 21 32 58 21 88 2 64 46 80 35 33 93 88 68 14 61 66 42 29 94 32 14 82 18 95 89 84 72 23 4 50 32 100 59 27 59 48 41 4 86 63 18 67 63 2 9 54 56 52 90 4 94 76 29 52 88 65 77 64 57 45 38 3 77 62 12 23 29 96 17 5 55 69 67 36 27 99 31 69 32 70 71 14 88 72 42 14 7 47 42 99 4 58 53 92 72 80 45 7 49 15 30 8 73 46 4 40 56 68 95 67 37 63 33 39 10 38 64 59 80 36 29 64 92 6 49 4 32 40 44 34 82 77 5 47 84 55 80 96 2 8 80 17 96 55 89 59 34 12 15 19 37 12 9 82 89 6 95 51 57 8 56 4 16 66 65 25 20 54 32 15 78 87 62 10 12 67 22 43 39 21 59 75 48 3 54 10 3 84 21 77 8 80 57 57 88 71 94 94 74 42 46 5 23 38 25 46 25 94 68 58 1 89 89 38 17 22 52 66 38 71 77 63 27 90 12 38 37 99 40 78 21 36 13 94 69 75 38 21 79 32 35 52 100 93 91 84 18 68 15 69 55 12 66 56 80 68 92 9 91 54 11 18 33 5 41 63 36 28 35 20 34 61 35 74 29 91 56 57 25 73 16 11 85 64 1 60 50 61 9 4 74 28 84 13 15 42 18 62 57 20 71 93 51 46 13 6 91 65 29 6 13 13 98 85 12 4 85 79 46 29 83 23 3 78 14 51 17 38 53 62 15 88 3 70 17 66 24 58 30 67 64 34 31 17 18 49 9 55 65 2 50 96 63 20 64 83 61 29 37 97 41 24 58 38 12 59 92 85 60 41 90 99 7 97 33 28 2 5 27 54 24 72 76 95 44 57 32 3 38 5 90 76 10 33 90 24 79 82 41 71 66 4 80 75 17 43 37 54 72 97 21 11 39 5 91 89 82 33 32 42 8 9 65 2 96 58 12 42 87 81 59 21 72 61 43 86 75 76 26 95 51 43 26 16 24 5 72 46 97 8 61 61 7 8 89 31 76 98 19 74 81 87 70 78 92 90 79 24 91 93 28 16 99 29 19 16 26 5 49 23 98 75 84 55 91 95 13 91 77 42 27 54 23 8 66 78 21 58 9 13 47 69 24 52 85 14 74 95 81 80 36 90 32 5 76 28 diff --git a/subset-sum/input/97 b/subset-sum/input/97 new file mode 100644 index 0000000..5b94d83 --- /dev/null +++ b/subset-sum/input/97 @@ -0,0 +1,2 @@ +128 6921 +28 38 47 92 48 45 7 53 60 81 60 62 99 90 42 1 45 35 20 82 14 34 9 50 92 61 87 90 29 44 67 62 67 25 26 66 75 95 32 12 6 52 60 40 63 74 81 99 7 5 16 5 59 32 11 35 34 76 83 66 80 20 99 38 48 87 83 79 79 48 90 19 66 77 17 50 36 61 14 53 18 27 73 8 46 21 18 84 64 49 57 78 12 27 68 97 46 1 9 96 84 17 42 22 84 78 71 68 75 20 27 94 95 76 51 22 65 53 90 16 32 50 63 12 97 93 47 64 diff --git a/subset-sum/input/98 b/subset-sum/input/98 new file mode 100644 index 0000000..f028ca6 --- /dev/null +++ b/subset-sum/input/98 @@ -0,0 +1,2 @@ +513 6047 +8 27 98 5 31 71 74 67 10 28 94 86 35 14 65 20 47 79 94 48 80 99 17 78 64 2 71 70 99 14 49 97 56 94 10 80 93 24 22 18 31 12 43 95 71 46 44 23 20 28 57 15 66 73 72 69 73 48 43 99 92 19 87 32 34 12 99 54 44 16 79 85 53 87 37 71 69 29 24 74 46 63 64 81 14 87 83 71 31 64 95 15 62 91 66 94 29 54 73 12 81 43 1 15 60 49 13 70 35 95 62 8 66 90 9 47 27 12 28 57 83 100 22 78 1 47 90 36 21 66 48 65 18 70 37 25 85 66 26 57 72 40 12 17 31 33 31 59 30 72 54 70 32 95 5 12 98 18 60 20 59 46 9 25 5 71 81 33 94 15 51 59 97 45 44 81 57 6 78 27 69 27 70 6 79 81 37 66 40 84 66 68 57 81 43 41 42 72 7 21 49 59 3 12 32 69 10 89 20 87 22 70 42 86 66 42 34 43 79 59 19 94 94 56 49 31 58 83 51 57 51 4 22 50 7 81 59 28 40 72 5 91 76 20 45 32 32 48 55 4 74 55 92 66 36 58 14 5 74 61 10 92 63 22 99 12 53 13 77 78 76 78 10 30 43 62 84 17 75 22 85 36 47 34 98 2 50 60 97 14 92 94 14 7 81 16 66 18 60 60 47 28 89 56 65 25 91 3 49 97 32 56 93 99 80 69 5 58 46 5 96 14 7 95 72 17 68 89 46 67 36 34 71 8 60 32 54 58 73 3 23 13 89 28 29 85 27 23 21 44 99 57 73 69 27 94 14 62 72 1 43 47 81 99 87 16 43 68 43 47 8 70 22 88 60 12 39 3 63 76 70 94 57 85 83 72 84 89 46 47 26 52 17 82 72 16 34 12 32 15 14 19 92 81 74 26 60 27 22 88 84 56 21 23 80 32 67 70 95 12 95 58 53 23 1 65 24 4 49 82 34 62 10 11 93 26 84 99 78 97 38 25 31 56 97 15 77 6 35 87 50 9 45 37 61 29 10 23 77 63 70 28 5 63 11 46 51 55 59 64 1 46 28 32 91 83 90 46 39 7 53 39 96 82 13 60 86 70 4 20 19 78 71 69 6 4 34 44 19 80 31 84 80 95 15 31 80 93 5 13 26 31 21 diff --git a/subset-sum/input/99 b/subset-sum/input/99 new file mode 100644 index 0000000..cbca490 --- /dev/null +++ b/subset-sum/input/99 @@ -0,0 +1,2 @@ +707 5909 +98 26 45 52 82 60 77 75 43 11 46 8 40 10 77 60 99 97 7 78 31 31 13 30 6 89 11 75 27 49 66 94 9 20 98 68 22 80 36 4 96 83 13 47 44 39 17 74 90 35 70 52 38 24 46 85 59 98 32 100 18 71 64 86 83 39 58 21 25 98 63 62 21 33 100 95 70 69 13 82 36 35 47 80 29 63 83 62 31 24 61 19 68 85 53 12 65 60 85 79 15 78 21 34 60 51 74 53 44 56 56 66 89 68 24 40 18 95 35 76 82 91 40 31 42 82 30 24 14 89 4 47 88 14 63 90 7 28 91 44 1 73 34 76 34 39 4 15 99 80 22 76 32 20 11 13 59 47 46 64 74 88 81 36 5 8 55 56 57 37 84 80 2 11 92 44 42 2 4 26 72 18 76 72 38 86 41 56 71 94 45 82 29 25 30 86 8 75 59 99 94 56 84 13 61 34 40 76 17 99 22 51 71 22 89 90 99 49 87 20 62 50 55 45 72 18 87 45 51 71 46 80 3 63 43 12 80 55 4 94 47 22 24 48 50 95 34 25 63 38 100 29 13 35 9 50 34 33 10 57 34 84 85 73 58 49 89 47 11 29 72 13 1 49 9 28 52 45 22 61 82 32 63 23 34 77 25 55 23 33 21 95 75 31 26 28 37 67 87 20 72 48 30 33 2 34 46 80 21 64 90 39 93 7 35 51 55 49 82 30 76 82 75 98 68 3 19 44 56 74 3 39 53 44 72 35 18 8 45 22 69 29 96 82 18 51 77 76 52 58 17 82 99 25 24 54 20 16 60 74 85 43 24 30 80 90 9 77 25 83 100 13 25 30 58 46 76 96 71 86 31 16 80 40 78 89 53 92 88 59 71 81 74 17 63 95 68 64 5 89 87 99 2 93 16 82 39 99 60 43 92 54 54 43 5 82 32 90 4 19 6 99 82 65 34 37 49 41 22 12 29 83 85 37 24 58 2 54 59 69 68 55 16 22 72 80 14 2 58 76 35 11 16 64 52 34 57 9 59 41 68 30 79 49 6 64 52 97 96 35 83 29 38 56 15 16 69 14 51 67 35 100 78 68 73 2 33 72 68 79 80 41 93 12 45 97 39 52 72 73 44 54 97 66 73 19 18 35 42 49 22 94 78 21 27 47 9 65 13 4 61 34 81 59 13 72 98 30 18 97 23 82 100 22 100 49 54 75 36 56 41 93 85 41 70 11 92 26 17 14 13 89 2 67 20 30 72 25 23 40 61 88 82 60 64 52 41 92 63 44 41 66 80 7 15 26 40 62 96 3 44 96 32 83 43 24 63 70 63 79 99 99 3 96 51 80 6 66 13 17 42 42 66 4 91 50 97 28 58 19 51 26 2 99 62 62 50 79 53 88 77 71 66 52 4 41 88 89 36 30 57 79 62 97 45 49 12 30 1 32 95 56 94 49 71 96 95 39 53 75 90 79 78 76 68 38 89 48 52 39 89 19 60 2 4 50 40 10 13 39 17 16 99 63 88 62 28 89 56 45 87 9 7 47 82 30 45 73 97 15 64 86 29 94 10 55 9 24 26 93 13 54 28 42 78 76 97 diff --git a/subset-sum/maratona.cls b/subset-sum/maratona.cls new file mode 100644 index 0000000..e11d53d --- /dev/null +++ b/subset-sum/maratona.cls @@ -0,0 +1,188 @@ +\ProvidesPackage{maratona} +\LoadClass[11pt]{article} + +% remove page numbers +\pagenumbering{gobble} + +\RequirePackage{fancyhdr} + +\RequirePackage{tabularx,colortbl} + +%\RequirePackage{arial} +\RequirePackage{ifpdf} +\RequirePackage[T1]{fontenc} +\RequirePackage[utf8]{inputenc} +\RequirePackage[portuguese]{babel} +\RequirePackage{graphics} +\RequirePackage{graphicx} +\RequirePackage{amssymb,amsmath,wrapfig} +\RequirePackage{xcolor,colortbl} +\RequirePackage{xcolor} +\RequirePackage{ifthen} +\oddsidemargin 0cm +\evensidemargin -2cm +\topmargin -1cm +\textwidth 16cm +\textheight 23cm + +\ifpdf +\RequirePackage[pdftex]{hyperref} +\else +\RequirePackage[hypertex]{hyperref} +\fi + + +\newcommand{\var}[1]{\ensuremath{{#1}}} + + +\hypersetup{ + letterpaper, + colorlinks=true, + linkcolor=blue, + urlcolor=blue, + pdfpagemode=none, + pdftitle={IV Maratona de Programação do IFB \today}, + pdfauthor={}, + pdfsubject={Caderno de problemas da IV Maratona de Programação do IFB }, + pdfkeywords={maratona, programação, IFB} +} + + + +\DeclareGraphicsExtensions{png} + +\lhead{DS Contest Tools} +\pagestyle{fancy} + +% Capa +\newenvironment{Maratona}[3] +{ + \begin{titlepage} + \begin{center} + + \vspace{1cm} + \Large{\textbf{#1}} \\ + \vspace{1cm} + {\textbf{Caderno de Problemas}} \\ + \vspace{1cm} + \begin{small} + \textsl{#2} + \end{small} \\ + \begin{figure}[htp] + \begin{center} + \includegraphics[scale=1]{logos/logo-maratona.png} + \end{center} + \end{figure} + {(Este caderno contém {#3} problemas)} \\ + \vspace{1cm} + } + { + \vfill + \begin{small} + {QNM 40, Área Especial nº 01, + Taguatinga/DF, 72146-000 , + Brasil } \\ + {Telefone (61) 2103-2200 \\http://www.ifb.edu.br/taguatinga} \\ + \end{small} + \end{center} + \end{titlepage} +} + +\newcommand{\Organizacao}[2]{ + {\small \vfill + \begin{center} + + \textbf{Comissão Organizadora:} \\ + {#1} \\ + \bigskip + \textbf{Apoio:}\\ + {#2} + \end{center} + } + \vfill +} + + +% Problema +\newcounter{problem} +\newenvironment{Problema}[4]{ + \stepcounter{problem} + \newpage + \begin{center} + \Large{\ifthenelse{\equal{#1}{}}{\textbf{{#2}}}{\textbf{Problema {#1} -- {#2} }}}{\\\footnotesize \textbf{Limite de tempo: {#3}s}}{\\[-0.1cm]\footnotesize \textbf{Limite de memória: {#4}MB}} + \end{center} +} + +\newcounter{problemAutor} +\newenvironment{ProblemaAutor}[5]{ + \stepcounter{problemAutor} + \newpage + \begin{center} + \Large{\ifthenelse{\equal{#1}{}}{\textbf{{#2}}}{\textbf{Problema {#1} -- {#2} }}}{\\\footnotesize \textbf{Limite de tempo: {#3}s}}{\\[-0.1cm]\footnotesize \textbf{Limite de memória: {#4}MB\\}}{ + \footnotesize Autor: {#5} + } + \end{center} +} + + +% Código-fonte +\newcommand{\codigofonte}[1]{Nome do arquivo fonte: {#1}} + +% Entrada +\newcommand{\Entrada}{ + \bigskip + \begin{large} + \textbf{Entrada} \\ + \end{large} +} + +% Saida +\newcommand{\Saida}{ + \bigskip + \begin{large} + \textbf{Saída} \\ + \end{large} +} + +\newcommand{\Interacao}{ + \bigskip + \begin{large} + \textbf{Interação} \\ + \end{large} +} + +\newcommand{\Notas}{ + \bigskip + \begin{large} + \textbf{Notas} \\ + \end{large} +} + +% Exemplo +\newenvironment{Exemplo} +{ + + \tabularx{\textwidth}{XX} + % {@{\extracolsep{\fill}}|l|l|} + % {|l|l@{\extracolsep{\fill}|}} + \hline + Entrada & Saída \\\hline +} +{ + \hline + \endtabularx +} + +% Exemplo de Entrada +\newenvironment{ExemploEntrada} +{ + \bigskip + \begin{large} + \textbf{Exemplo} \\ + \end{large} +} +{ +} + +% Sample Output + diff --git a/subset-sum/output/1 b/subset-sum/output/1 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/1 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/10 b/subset-sum/output/10 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/10 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/100 b/subset-sum/output/100 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/100 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/101 b/subset-sum/output/101 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/101 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/102 b/subset-sum/output/102 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/102 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/103 b/subset-sum/output/103 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/103 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/104 b/subset-sum/output/104 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/104 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/105 b/subset-sum/output/105 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/105 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/106 b/subset-sum/output/106 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/106 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/11 b/subset-sum/output/11 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/11 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/12 b/subset-sum/output/12 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/12 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/13 b/subset-sum/output/13 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/13 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/14 b/subset-sum/output/14 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/14 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/15 b/subset-sum/output/15 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/15 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/16 b/subset-sum/output/16 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/16 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/17 b/subset-sum/output/17 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/17 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/18 b/subset-sum/output/18 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/18 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/19 b/subset-sum/output/19 new file mode 100644 index 0000000..9e17f21 --- /dev/null +++ b/subset-sum/output/19 @@ -0,0 +1 @@ +IMPOSSIVEL! diff --git a/subset-sum/output/2 b/subset-sum/output/2 new file mode 100644 index 0000000..9e17f21 --- /dev/null +++ b/subset-sum/output/2 @@ -0,0 +1 @@ +IMPOSSIVEL! diff --git a/subset-sum/output/20 b/subset-sum/output/20 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/20 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/21 b/subset-sum/output/21 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/21 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/22 b/subset-sum/output/22 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/22 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/23 b/subset-sum/output/23 new file mode 100644 index 0000000..9e17f21 --- /dev/null +++ b/subset-sum/output/23 @@ -0,0 +1 @@ +IMPOSSIVEL! diff --git a/subset-sum/output/24 b/subset-sum/output/24 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/24 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/25 b/subset-sum/output/25 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/25 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/26 b/subset-sum/output/26 new file mode 100644 index 0000000..9e17f21 --- /dev/null +++ b/subset-sum/output/26 @@ -0,0 +1 @@ +IMPOSSIVEL! diff --git a/subset-sum/output/27 b/subset-sum/output/27 new file mode 100644 index 0000000..9e17f21 --- /dev/null +++ b/subset-sum/output/27 @@ -0,0 +1 @@ +IMPOSSIVEL! diff --git a/subset-sum/output/28 b/subset-sum/output/28 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/28 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/29 b/subset-sum/output/29 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/29 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/3 b/subset-sum/output/3 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/3 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/30 b/subset-sum/output/30 new file mode 100644 index 0000000..9e17f21 --- /dev/null +++ b/subset-sum/output/30 @@ -0,0 +1 @@ +IMPOSSIVEL! diff --git a/subset-sum/output/31 b/subset-sum/output/31 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/31 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/32 b/subset-sum/output/32 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/32 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/33 b/subset-sum/output/33 new file mode 100644 index 0000000..9e17f21 --- /dev/null +++ b/subset-sum/output/33 @@ -0,0 +1 @@ +IMPOSSIVEL! diff --git a/subset-sum/output/34 b/subset-sum/output/34 new file mode 100644 index 0000000..9e17f21 --- /dev/null +++ b/subset-sum/output/34 @@ -0,0 +1 @@ +IMPOSSIVEL! diff --git a/subset-sum/output/35 b/subset-sum/output/35 new file mode 100644 index 0000000..9e17f21 --- /dev/null +++ b/subset-sum/output/35 @@ -0,0 +1 @@ +IMPOSSIVEL! diff --git a/subset-sum/output/36 b/subset-sum/output/36 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/36 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/37 b/subset-sum/output/37 new file mode 100644 index 0000000..9e17f21 --- /dev/null +++ b/subset-sum/output/37 @@ -0,0 +1 @@ +IMPOSSIVEL! diff --git a/subset-sum/output/38 b/subset-sum/output/38 new file mode 100644 index 0000000..9e17f21 --- /dev/null +++ b/subset-sum/output/38 @@ -0,0 +1 @@ +IMPOSSIVEL! diff --git a/subset-sum/output/39 b/subset-sum/output/39 new file mode 100644 index 0000000..9e17f21 --- /dev/null +++ b/subset-sum/output/39 @@ -0,0 +1 @@ +IMPOSSIVEL! diff --git a/subset-sum/output/4 b/subset-sum/output/4 new file mode 100644 index 0000000..9e17f21 --- /dev/null +++ b/subset-sum/output/4 @@ -0,0 +1 @@ +IMPOSSIVEL! diff --git a/subset-sum/output/40 b/subset-sum/output/40 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/40 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/41 b/subset-sum/output/41 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/41 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/42 b/subset-sum/output/42 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/42 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/43 b/subset-sum/output/43 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/43 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/44 b/subset-sum/output/44 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/44 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/45 b/subset-sum/output/45 new file mode 100644 index 0000000..9e17f21 --- /dev/null +++ b/subset-sum/output/45 @@ -0,0 +1 @@ +IMPOSSIVEL! diff --git a/subset-sum/output/46 b/subset-sum/output/46 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/46 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/47 b/subset-sum/output/47 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/47 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/48 b/subset-sum/output/48 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/48 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/49 b/subset-sum/output/49 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/49 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/5 b/subset-sum/output/5 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/5 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/50 b/subset-sum/output/50 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/50 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/51 b/subset-sum/output/51 new file mode 100644 index 0000000..9e17f21 --- /dev/null +++ b/subset-sum/output/51 @@ -0,0 +1 @@ +IMPOSSIVEL! diff --git a/subset-sum/output/52 b/subset-sum/output/52 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/52 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/53 b/subset-sum/output/53 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/53 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/54 b/subset-sum/output/54 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/54 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/55 b/subset-sum/output/55 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/55 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/56 b/subset-sum/output/56 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/56 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/57 b/subset-sum/output/57 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/57 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/58 b/subset-sum/output/58 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/58 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/59 b/subset-sum/output/59 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/59 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/6 b/subset-sum/output/6 new file mode 100644 index 0000000..9e17f21 --- /dev/null +++ b/subset-sum/output/6 @@ -0,0 +1 @@ +IMPOSSIVEL! diff --git a/subset-sum/output/60 b/subset-sum/output/60 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/60 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/61 b/subset-sum/output/61 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/61 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/62 b/subset-sum/output/62 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/62 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/63 b/subset-sum/output/63 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/63 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/64 b/subset-sum/output/64 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/64 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/65 b/subset-sum/output/65 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/65 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/66 b/subset-sum/output/66 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/66 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/67 b/subset-sum/output/67 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/67 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/68 b/subset-sum/output/68 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/68 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/69 b/subset-sum/output/69 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/69 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/7 b/subset-sum/output/7 new file mode 100644 index 0000000..9e17f21 --- /dev/null +++ b/subset-sum/output/7 @@ -0,0 +1 @@ +IMPOSSIVEL! diff --git a/subset-sum/output/70 b/subset-sum/output/70 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/70 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/71 b/subset-sum/output/71 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/71 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/72 b/subset-sum/output/72 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/72 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/73 b/subset-sum/output/73 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/73 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/74 b/subset-sum/output/74 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/74 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/75 b/subset-sum/output/75 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/75 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/76 b/subset-sum/output/76 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/76 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/77 b/subset-sum/output/77 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/77 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/78 b/subset-sum/output/78 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/78 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/79 b/subset-sum/output/79 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/79 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/8 b/subset-sum/output/8 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/8 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/80 b/subset-sum/output/80 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/80 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/81 b/subset-sum/output/81 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/81 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/82 b/subset-sum/output/82 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/82 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/83 b/subset-sum/output/83 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/83 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/84 b/subset-sum/output/84 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/84 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/85 b/subset-sum/output/85 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/85 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/86 b/subset-sum/output/86 new file mode 100644 index 0000000..9e17f21 --- /dev/null +++ b/subset-sum/output/86 @@ -0,0 +1 @@ +IMPOSSIVEL! diff --git a/subset-sum/output/87 b/subset-sum/output/87 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/87 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/88 b/subset-sum/output/88 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/88 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/89 b/subset-sum/output/89 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/89 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/9 b/subset-sum/output/9 new file mode 100644 index 0000000..9e17f21 --- /dev/null +++ b/subset-sum/output/9 @@ -0,0 +1 @@ +IMPOSSIVEL! diff --git a/subset-sum/output/90 b/subset-sum/output/90 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/90 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/91 b/subset-sum/output/91 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/91 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/92 b/subset-sum/output/92 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/92 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/93 b/subset-sum/output/93 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/93 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/94 b/subset-sum/output/94 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/94 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/95 b/subset-sum/output/95 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/95 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/96 b/subset-sum/output/96 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/96 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/97 b/subset-sum/output/97 new file mode 100644 index 0000000..9e17f21 --- /dev/null +++ b/subset-sum/output/97 @@ -0,0 +1 @@ +IMPOSSIVEL! diff --git a/subset-sum/output/98 b/subset-sum/output/98 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/98 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/output/99 b/subset-sum/output/99 new file mode 100644 index 0000000..abfd174 --- /dev/null +++ b/subset-sum/output/99 @@ -0,0 +1 @@ +PERFEITO! diff --git a/subset-sum/problem.json b/subset-sum/problem.json new file mode 100644 index 0000000..007e634 --- /dev/null +++ b/subset-sum/problem.json @@ -0,0 +1,64 @@ +{ + "version": "1.0", + "problem": { + "title": "", + "event": "", + "time_limit": 1.0, + "memory_limit_mb": 256, + "input_file": "stdin", + "output_file": "stdout", + "interactive": false, + "grader": false, + "subject": { + "en_us": [ + "dynamic-programming", "subset-sum", "knapsack-problem", "knapsack-0/1" + ], + "pt_br": [ + "programação-dinâmica", "problema-da-mochila", "problema-da-mochila-booleano" + ], + "es": [ + "" + ] + } + }, + "author": { + "name": "", + "affiliation": "", + "country": "", + "email": "" + }, + "build": { + "run_generator": true, + "run_validator": true, + "produce_outputs": true, + "run_checker": true, + "run_all_solutions": true, + "run_specific_solution": "", + "generate_io_only": false, + "generate_pdf_only": false, + "cpu_count": 1, + "build_pdf": true, + "pdf_format": "ds", + "io_samples": 3 + }, + "solutions": { + "main-ac": "ac.cpp", + "alternative-ac": [], + "wrong-answer": [], + "time-limit": ["TLE.cpp"], + "time-limit-or-ac": [], + "time-limit-or-memory-limit": [], + "memory-limit": [], + "presentation-error": [], + "runtime-error": [] + }, + "polygon_config": { + "id": "" + }, + "boca_config": { + "time_limit": 1, + "number_of_repetitions": 1, + "maximum_memory_mb": 512, + "maximum_output_size_kb": 24096 + } +} \ No newline at end of file diff --git a/subset-sum/src/TLE.cpp b/subset-sum/src/TLE.cpp new file mode 100644 index 0000000..0faaa12 --- /dev/null +++ b/subset-sum/src/TLE.cpp @@ -0,0 +1,33 @@ +#include + +using namespace std; + +int N, T; +vector nums; + +bool solve(int idx, int sum) +{ + if (sum == T) return true; + if (idx == N) return false; + if (sum > T) return false; + + return solve(idx + 1, sum + nums[idx]) || solve(idx + 1, sum); +} + +int main() +{ + cin >> N; + cin >> T; + nums.resize(N); + for (int i = 0; i < N; i++) + cin >> nums[i]; + + if (solve(0, 0)) { + cout << "PERFEITO!"; + } else { + cout << "IMPOSSIVEL!"; + } + cout << endl; + + return 0; +} \ No newline at end of file diff --git a/subset-sum/src/ac.cpp b/subset-sum/src/ac.cpp new file mode 100644 index 0000000..f0b8d4d --- /dev/null +++ b/subset-sum/src/ac.cpp @@ -0,0 +1,30 @@ +#include + +using namespace std; + +const int T = 10000; +int dp[T + 1] = {0}; + +int main(){ + int n; cin >> n; + int t; cin >> t; + vector nums(n); + for (int i = 0; i < n; i++) cin >> nums[i]; + + dp[0] = 1; + for (int i = 0; i < n; i++) { + for (int j = t - nums[i]; j >= 0; j--) { + if (dp[j]) { + dp[j + nums[i]] = 1; + } + } + if (dp[t]) { + cout << "PERFEITO!" << endl; + return 0; + } + } + + cout << "IMPOSSIVEL!" << endl; + + return 0; +} \ No newline at end of file diff --git a/subset-sum/src/checker.cpp b/subset-sum/src/checker.cpp new file mode 100644 index 0000000..8b5b76f --- /dev/null +++ b/subset-sum/src/checker.cpp @@ -0,0 +1,26 @@ +#include "testlib.h" +#include + +using namespace std; + +const string YES = "PERFEITO!"; +const string NO = "IMPOSSIVEL!"; + +int main(int argc, char *argv[]) { + setName("%s", (YES + " or " + NO + " (case insensitive)").c_str()); + registerTestlibCmd(argc, argv); + + std::string ja = upperCase(ans.readWord()); + std::string pa = upperCase(ouf.readWord()); + + if (ja != YES && ja != NO) + quitf(_fail, "%s or %s expected in answer, but %s found", YES.c_str(), NO.c_str(), compress(ja).c_str()); + + if (pa != YES && pa != NO) + quitf(_pe, "%s or %s expected, but %s found", YES.c_str(), NO.c_str(), compress(pa).c_str()); + + if (ja != pa) + quitf(_wa, "expected %s, found %s", compress(ja).c_str(), compress(pa).c_str()); + + quitf(_ok, "answer is %s", ja.c_str()); +} \ No newline at end of file diff --git a/subset-sum/src/generator.cpp b/subset-sum/src/generator.cpp new file mode 100644 index 0000000..085feb6 --- /dev/null +++ b/subset-sum/src/generator.cpp @@ -0,0 +1,107 @@ +#include "testlib.h" +#include + +using namespace std; + +const int MIN_N = 1; +const int MAX_N = 1000; +const int MIN_T = 1; +const int MAX_T = 10000; +const int MIN_NI = 1; +const int MAX_NI = 100; + +const int rnd_test_n = 100; + +template void append(vector &dest, const vector &orig) { + dest.insert(dest.end(), orig.begin(), orig.end()); +} + +vector genRandomArray(int size = 0, int minv = MIN_NI, int maxv = MAX_NI) { + if (size <= 0) size = rnd.next(MIN_N, MAX_N); + vector arr(size); + for (int i = 0; i < size; i++) { + arr[i] = rnd.next(minv, maxv); + } + return arr; +} + +string output_tc(int t, const vector& nums) { + ostringstream oss; + oss << nums.size() << " " << t << endl; + for (int i = 0; i < nums.size(); i++) { + if (i != 0) oss << " "; + oss << nums[i]; + } + oss << endl; + return oss.str(); +} + +vector generate_sample_tests() { + vector tests; + tests.push_back(output_tc(10, {1, 2, 3, 4, 5})); + tests.push_back(output_tc(4, {5, 1, 2, 5})); + tests.push_back(output_tc(14, {1, 2, 3, 4, 4, 9, 9, 15})); + return tests; +} + +vector generate_manual_tests() { + vector tests; + tests.push_back(output_tc(1, {2,2,2,2,2,2,2,2})); + tests.push_back(output_tc(2, {100, 100, 100, 3, 3, 3, 3, 3, 3, 2})); + return tests; +} + +string rnd_test(int i){ + int min_n = MIN_N; + int max_n = MAX_N; + int min_t = MIN_T; + int max_t = MAX_T; + + if(i generate_random_tests() { + vector tests; + for (int i = 0; i < rnd_test_n; i++){ + tests.push_back(rnd_test(i)); + } + return tests; +} + +string extreme_test_1(){ + return(output_tc(MAX_T, genRandomArray(MAX_N))); +} + +vector generate_extreme_tests(){ + vector tests; + tests.push_back(extreme_test_1()); + return tests; +} + +int main(int argc, char *argv[]) { + registerGen(argc, argv, 1); + vector tests; + size_t test = 0; + append(tests, generate_sample_tests()); + append(tests, generate_manual_tests()); + append(tests, generate_random_tests()); + append(tests, generate_extreme_tests()); + for (const auto &t : tests) { + startTest(++test); + cout << t; + } + return 0; +} \ No newline at end of file diff --git a/subset-sum/src/script.sh b/subset-sum/src/script.sh new file mode 100644 index 0000000..a8a6bda --- /dev/null +++ b/subset-sum/src/script.sh @@ -0,0 +1 @@ +generator \ No newline at end of file diff --git a/subset-sum/src/testlib.h b/subset-sum/src/testlib.h new file mode 100644 index 0000000..fac02ad --- /dev/null +++ b/subset-sum/src/testlib.h @@ -0,0 +1,5963 @@ +/* + * It is strictly recommended to include "testlib.h" before any other include + * in your code. In this case testlib overrides compiler specific "random()". + * + * If you can't compile your code and compiler outputs something about + * ambiguous call of "random_shuffle", "rand" or "srand" it means that + * you shouldn't use them. Use "shuffle", and "rnd.next()" instead of them + * because these calls produce stable result for any C++ compiler. Read + * sample generator sources for clarification. + * + * Please read the documentation for class "random_t" and use "rnd" instance in + * generators. Probably, these sample calls will be usefull for you: + * rnd.next(); rnd.next(100); rnd.next(1, 2); + * rnd.next(3.14); rnd.next("[a-z]{1,100}"). + * + * Also read about wnext() to generate off-center random distribution. + * + * See https://github.com/MikeMirzayanov/testlib/ to get latest version or bug tracker. + */ + +#ifndef _TESTLIB_H_ +#define _TESTLIB_H_ + +/* + * Copyright (c) 2005-2022 + */ + +#define VERSION "0.9.40-SNAPSHOT" + +/* + * Mike Mirzayanov + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +/* NOTE: This file contains testlib library for C++. + * + * Check, using testlib running format: + * check.exe [ [-appes]], + * If result file is specified it will contain results. + * + * Validator, using testlib running format: + * validator.exe < input.txt, + * It will return non-zero exit code and writes message to standard output. + * + * Generator, using testlib running format: + * gen.exe [parameter-1] [parameter-2] [... paramerter-n] + * You can write generated test(s) into standard output or into the file(s). + * + * Interactor, using testlib running format: + * interactor.exe [ [ [-appes]]], + * Reads test from inf (mapped to args[1]), writes result to tout (mapped to argv[2], + * can be judged by checker later), reads program output from ouf (mapped to stdin), + * writes output to program via stdout (use cout, printf, etc). + */ + +const char *latestFeatures[] = { + "Supported '--testMarkupFileName fn' and '--testCase tc/--testCaseFileName fn' for validators", + "Added opt defaults via opt(key/index, default_val); check unused opts when using has_opt or default opt (turn off this check with suppressEnsureNoUnusedOpt()).", + "For checker added --group and --testset command line params (like for validator), use checker.group() or checker.testset() to get values", + "Added quitpi(points_info, message) function to return with _points exit code 7 and given points_info", + "rnd.partition(size, sum[, min_part=1]) returns random (unsorted) partition which is a representation of the given `sum` as a sum of `size` positive integers (or >=min_part if specified)", + "rnd.distinct(size, n) and rnd.distinct(size, from, to)", + "opt(\"some_missing_key\") returns false now", + "has_opt(key)", + "Abort validator on validator.testset()/validator.group() if registered without using command line", + "Print integer range violations in a human readable way like `violates the range [1, 10^9]`", + "Opts supported: use them like n = opt(\"n\"), in a command line you can use an exponential notation", + "Reformatted", + "Use setTestCase(i) or unsetTestCase() to support test cases (you can use it in any type of program: generator, interactor, validator or checker)", + "Fixed issue #87: readStrictDouble accepts \"-0.00\"", + "Fixed issue #83: added InStream::quitif(condition, ...)", + "Fixed issue #79: fixed missed guard against repeated header include", + "Fixed issue #80: fixed UB in case of huge quitf message", + "Fixed issue #84: added readXs(size, indexBase = 1)", + "Fixed stringstream repeated usage issue", + "Fixed compilation in g++ (for std=c++03)", + "Batch of println functions (support collections, iterator ranges)", + "Introduced rnd.perm(size, first = 0) to generate a `first`-indexed permutation", + "Allow any whitespace in readInts-like functions for non-validators", + "Ignore 4+ command line arguments ifdef EJUDGE", + "Speed up of vtos", + "Show line number in validators in case of incorrect format", + "Truncate huge checker/validator/interactor message", + "Fixed issue with readTokenTo of very long tokens, now aborts with _pe/_fail depending of a stream type", + "Introduced InStream::ensure/ensuref checking a condition, returns wa/fail depending of a stream type", + "Fixed compilation in VS 2015+", + "Introduced space-separated read functions: readWords/readTokens, multilines read functions: readStrings/readLines", + "Introduced space-separated read functions: readInts/readIntegers/readLongs/readUnsignedLongs/readDoubles/readReals/readStrictDoubles/readStrictReals", + "Introduced split/tokenize functions to separate string by given char", + "Introduced InStream::readUnsignedLong and InStream::readLong with unsigned long long paramerters", + "Supported --testOverviewLogFileName for validator: bounds hits + features", + "Fixed UB (sequence points) in random_t", + "POINTS_EXIT_CODE returned back to 7 (instead of 0)", + "Removed disable buffers for interactive problems, because it works unexpectedly in wine", + "InStream over string: constructor of InStream from base InStream to inherit policies and std::string", + "Added expectedButFound quit function, examples: expectedButFound(_wa, 10, 20), expectedButFound(_fail, ja, pa, \"[n=%d,m=%d]\", n, m)", + "Fixed incorrect interval parsing in patterns", + "Use registerGen(argc, argv, 1) to develop new generator, use registerGen(argc, argv, 0) to compile old generators (originally created for testlib under 0.8.7)", + "Introduced disableFinalizeGuard() to switch off finalization checkings", + "Use join() functions to format a range of items as a single string (separated by spaces or other separators)", + "Use -DENABLE_UNEXPECTED_EOF to enable special exit code (by default, 8) in case of unexpected eof. It is good idea to use it in interactors", + "Use -DUSE_RND_AS_BEFORE_087 to compile in compatibility mode with random behavior of versions before 0.8.7", + "Fixed bug with nan in stringToDouble", + "Fixed issue around overloads for size_t on x64", + "Added attribute 'points' to the XML output in case of result=_points", + "Exit codes can be customized via macros, e.g. -DPE_EXIT_CODE=14", + "Introduced InStream function readWordTo/readTokenTo/readStringTo/readLineTo for faster reading", + "Introduced global functions: format(), englishEnding(), upperCase(), lowerCase(), compress()", + "Manual buffer in InStreams, some IO speed improvements", + "Introduced quitif(bool, const char* pattern, ...) which delegates to quitf() in case of first argument is true", + "Introduced guard against missed quitf() in checker or readEof() in validators", + "Supported readStrictReal/readStrictDouble - to use in validators to check strictly float numbers", + "Supported registerInteraction(argc, argv)", + "Print checker message to the stderr instead of stdout", + "Supported TResult _points to output calculated score, use quitp(...) functions", + "Fixed to be compilable on Mac", + "PC_BASE_EXIT_CODE=50 in case of defined TESTSYS", + "Fixed issues 19-21, added __attribute__ format printf", + "Some bug fixes", + "ouf.readInt(1, 100) and similar calls return WA", + "Modified random_t to avoid integer overflow", + "Truncated checker output [patch by Stepan Gatilov]", + "Renamed class random -> class random_t", + "Supported name parameter for read-and-validation methods, like readInt(1, 2, \"n\")", + "Fixed bug in readDouble()", + "Improved ensuref(), fixed nextLine to work in case of EOF, added startTest()", + "Supported \"partially correct\", example: quitf(_pc(13), \"result=%d\", result)", + "Added shuffle(begin, end), use it instead of random_shuffle(begin, end)", + "Added readLine(const string& ptrn), fixed the logic of readLine() in the validation mode", + "Package extended with samples of generators and validators", + "Written the documentation for classes and public methods in testlib.h", + "Implemented random routine to support generators, use registerGen() to switch it on", + "Implemented strict mode to validate tests, use registerValidation() to switch it on", + "Now ncmp.cpp and wcmp.cpp are return WA if answer is suffix or prefix of the output", + "Added InStream::readLong() and removed InStream::readLongint()", + "Now no footer added to each report by default (use directive FOOTER to switch on)", + "Now every checker has a name, use setName(const char* format, ...) to set it", + "Now it is compatible with TTS (by Kittens Computing)", + "Added \'ensure(condition, message = \"\")\' feature, it works like assert()", + "Fixed compatibility with MS C++ 7.1", + "Added footer with exit code information", + "Added compatibility with EJUDGE (compile with EJUDGE directive)", + "Added compatibility with Contester (compile with CONTESTER directive)" +}; + +#ifdef _MSC_VER +#define _CRT_SECURE_NO_DEPRECATE +#define _CRT_SECURE_NO_WARNINGS +#define _CRT_NO_VA_START_VALIDATION +#endif + +/* Overrides random() for Borland C++. */ +#define random __random_deprecated +#include +#include +#include +#include +#undef random + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef TESTLIB_THROW_EXIT_EXCEPTION_INSTEAD_OF_EXIT +# include +#endif + +#if (_WIN32 || __WIN32__ || __WIN32 || _WIN64 || __WIN64__ || __WIN64 || WINNT || __WINNT || __WINNT__ || __CYGWIN__) +# if !defined(_MSC_VER) || _MSC_VER > 1400 +# define NOMINMAX 1 +# include +# else +# define WORD unsigned short +# include +# endif +# include +# define ON_WINDOWS +# if defined(_MSC_VER) && _MSC_VER > 1400 +# pragma warning( disable : 4127 ) +# pragma warning( disable : 4146 ) +# pragma warning( disable : 4458 ) +# endif +#else +# define WORD unsigned short +# include +#endif + +#if defined(FOR_WINDOWS) && defined(FOR_LINUX) +#error Only one target system is allowed +#endif + +#ifndef LLONG_MIN +#define LLONG_MIN (-9223372036854775807LL - 1) +#endif + +#ifndef ULLONG_MAX +#define ULLONG_MAX (18446744073709551615) +#endif + +#define LF ((char)10) +#define CR ((char)13) +#define TAB ((char)9) +#define SPACE ((char)' ') +#define EOFC (255) + +#ifndef OK_EXIT_CODE +# ifdef CONTESTER +# define OK_EXIT_CODE 0xAC +# elif defined BOCA_SUPPORT +# define OK_EXIT_CODE 4 +# else +# define OK_EXIT_CODE 0 +# endif +#endif + +#ifndef WA_EXIT_CODE +# ifdef EJUDGE +# define WA_EXIT_CODE 5 +# elif defined(CONTESTER) +# define WA_EXIT_CODE 0xAB +# elif defined BOCA_SUPPORT +# define WA_EXIT_CODE 6 +# else +# define WA_EXIT_CODE 1 +# endif +#endif + +#ifndef PE_EXIT_CODE +# ifdef EJUDGE +# define PE_EXIT_CODE 4 +# elif defined(CONTESTER) +# define PE_EXIT_CODE 0xAA +# elif defined BOCA_SUPPORT +# define PE_EXIT_CODE 6 +# else +# define PE_EXIT_CODE 2 +# endif +#endif + +#ifndef FAIL_EXIT_CODE +# ifdef EJUDGE +# define FAIL_EXIT_CODE 6 +# elif defined(CONTESTER) +# define FAIL_EXIT_CODE 0xA3 +# elif defined BOCA_SUPPORT +# define FAIL_EXIT_CODE 7 +# else +# define FAIL_EXIT_CODE 3 +# endif +#endif + +#ifndef DIRT_EXIT_CODE +# ifdef EJUDGE +# define DIRT_EXIT_CODE 6 +# else +# define DIRT_EXIT_CODE 4 +# endif +#endif + +#ifndef POINTS_EXIT_CODE +# ifndef BOCA_SUPPORT +# define POINTS_EXIT_CODE 7 +# else +# define POINTS_EXIT_CODE 5 +# endif +#endif + +#ifndef UNEXPECTED_EOF_EXIT_CODE +# define UNEXPECTED_EOF_EXIT_CODE 8 +#endif + +#ifndef PC_BASE_EXIT_CODE +# ifdef TESTSYS +# define PC_BASE_EXIT_CODE 50 +# else +# define PC_BASE_EXIT_CODE 0 +# endif +#endif + +#ifdef __GNUC__ +# define __TESTLIB_STATIC_ASSERT(condition) typedef void* __testlib_static_assert_type[(condition) ? 1 : -1] __attribute__((unused)) +#else +# define __TESTLIB_STATIC_ASSERT(condition) typedef void* __testlib_static_assert_type[(condition) ? 1 : -1] +#endif + +#ifdef ON_WINDOWS +#define I64 "%I64d" +#define U64 "%I64u" +#else +#define I64 "%lld" +#define U64 "%llu" +#endif + +#ifdef _MSC_VER +# define NORETURN __declspec(noreturn) +#elif defined __GNUC__ +# define NORETURN __attribute__ ((noreturn)) +#else +# define NORETURN +#endif + +static char __testlib_format_buffer[16777216]; +static int __testlib_format_buffer_usage_count = 0; + +#define FMT_TO_RESULT(fmt, cstr, result) std::string result; \ + if (__testlib_format_buffer_usage_count != 0) \ + __testlib_fail("FMT_TO_RESULT::__testlib_format_buffer_usage_count != 0"); \ + __testlib_format_buffer_usage_count++; \ + va_list ap; \ + va_start(ap, fmt); \ + vsnprintf(__testlib_format_buffer, sizeof(__testlib_format_buffer), cstr, ap); \ + va_end(ap); \ + __testlib_format_buffer[sizeof(__testlib_format_buffer) - 1] = 0; \ + result = std::string(__testlib_format_buffer); \ + __testlib_format_buffer_usage_count--; \ + +const long long __TESTLIB_LONGLONG_MAX = 9223372036854775807LL; +const int __TESTLIB_MAX_TEST_CASE = 1073741823; + +int __testlib_exitCode; + +bool __testlib_hasTestCase; +int __testlib_testCase = -1; + +void setTestCase(int testCase); + +void unsetTestCase() { + __testlib_hasTestCase = false; + __testlib_testCase = -1; +} + +NORETURN static void __testlib_fail(const std::string &message); + +template +static inline T __testlib_abs(const T &x) { + return x > 0 ? x : -x; +} + +template +static inline T __testlib_min(const T &a, const T &b) { + return a < b ? a : b; +} + +template +static inline T __testlib_max(const T &a, const T &b) { + return a > b ? a : b; +} + +template +static inline T __testlib_crop(T value, T a, T b) { + return __testlib_min(__testlib_max(value, a), --b); +} + +static inline double __testlib_crop(double value, double a, double b) { + value = __testlib_min(__testlib_max(value, a), b); + if (value >= b) + value = std::nexttoward(b, a); + return value; +} + +static bool __testlib_prelimIsNaN(double r) { + volatile double ra = r; +#ifndef __BORLANDC__ + return ((ra != ra) == true) && ((ra == ra) == false) && ((1.0 > ra) == false) && ((1.0 < ra) == false); +#else + return std::_isnan(ra); +#endif +} + +static std::string removeDoubleTrailingZeroes(std::string value) { + while (!value.empty() && value[value.length() - 1] == '0' && value.find('.') != std::string::npos) + value = value.substr(0, value.length() - 1); + if (!value.empty() && value[value.length() - 1] == '.') + return value + '0'; + else + return value; +} + +#ifdef __GNUC__ +__attribute__ ((format (printf, 1, 2))) +#endif +std::string format(const char *fmt, ...) { + FMT_TO_RESULT(fmt, fmt, result); + return result; +} + +std::string format(const std::string fmt, ...) { + FMT_TO_RESULT(fmt, fmt.c_str(), result); + return result; +} + +static std::string __testlib_part(const std::string &s); + +static bool __testlib_isNaN(double r) { + __TESTLIB_STATIC_ASSERT(sizeof(double) == sizeof(long long)); + volatile double ra = r; + long long llr1, llr2; + std::memcpy((void *) &llr1, (void *) &ra, sizeof(double)); + ra = -ra; + std::memcpy((void *) &llr2, (void *) &ra, sizeof(double)); + long long llnan = 0xFFF8000000000000LL; + return __testlib_prelimIsNaN(r) || llnan == llr1 || llnan == llr2; +} + +static double __testlib_nan() { + __TESTLIB_STATIC_ASSERT(sizeof(double) == sizeof(long long)); +#ifndef NAN + long long llnan = 0xFFF8000000000000LL; + double nan; + std::memcpy(&nan, &llnan, sizeof(double)); + return nan; +#else + return NAN; +#endif +} + +static bool __testlib_isInfinite(double r) { + volatile double ra = r; + return (ra > 1E300 || ra < -1E300); +} + +#ifdef __GNUC__ +__attribute__((const)) +#endif +inline bool doubleCompare(double expected, double result, double MAX_DOUBLE_ERROR) { + MAX_DOUBLE_ERROR += 1E-15; + if (__testlib_isNaN(expected)) { + return __testlib_isNaN(result); + } else if (__testlib_isInfinite(expected)) { + if (expected > 0) { + return result > 0 && __testlib_isInfinite(result); + } else { + return result < 0 && __testlib_isInfinite(result); + } + } else if (__testlib_isNaN(result) || __testlib_isInfinite(result)) { + return false; + } else if (__testlib_abs(result - expected) <= MAX_DOUBLE_ERROR) { + return true; + } else { + double minv = __testlib_min(expected * (1.0 - MAX_DOUBLE_ERROR), + expected * (1.0 + MAX_DOUBLE_ERROR)); + double maxv = __testlib_max(expected * (1.0 - MAX_DOUBLE_ERROR), + expected * (1.0 + MAX_DOUBLE_ERROR)); + return result >= minv && result <= maxv; + } +} + +#ifdef __GNUC__ +__attribute__((const)) +#endif +inline double doubleDelta(double expected, double result) { + double absolute = __testlib_abs(result - expected); + + if (__testlib_abs(expected) > 1E-9) { + double relative = __testlib_abs(absolute / expected); + return __testlib_min(absolute, relative); + } else + return absolute; +} + +/** It does nothing on non-windows and files differ from stdin/stdout/stderr. */ +static void __testlib_set_binary(std::FILE *file) { + if (NULL != file) { +#ifdef ON_WINDOWS +# ifdef _O_BINARY + if (stdin == file) +# ifdef STDIN_FILENO + return void(_setmode(STDIN_FILENO, _O_BINARY)); +# else + return void(_setmode(_fileno(stdin), _O_BINARY)); +# endif + if (stdout == file) +# ifdef STDOUT_FILENO + return void(_setmode(STDOUT_FILENO, _O_BINARY)); +# else + return void(_setmode(_fileno(stdout), _O_BINARY)); +# endif + if (stderr == file) +# ifdef STDERR_FILENO + return void(_setmode(STDERR_FILENO, _O_BINARY)); +# else + return void(_setmode(_fileno(stderr), _O_BINARY)); +# endif +# elif O_BINARY + if (stdin == file) +# ifdef STDIN_FILENO + return void(setmode(STDIN_FILENO, O_BINARY)); +# else + return void(setmode(fileno(stdin), O_BINARY)); +# endif + if (stdout == file) +# ifdef STDOUT_FILENO + return void(setmode(STDOUT_FILENO, O_BINARY)); +# else + return void(setmode(fileno(stdout), O_BINARY)); +# endif + if (stderr == file) +# ifdef STDERR_FILENO + return void(setmode(STDERR_FILENO, O_BINARY)); +# else + return void(setmode(fileno(stderr), O_BINARY)); +# endif +# endif +#endif + } +} + +#if __cplusplus > 199711L || defined(_MSC_VER) +template +static std::string vtos(const T &t, std::true_type) { + if (t == 0) + return "0"; + else { + T n(t); + bool negative = n < 0; + std::string s; + while (n != 0) { + T digit = n % 10; + if (digit < 0) + digit = -digit; + s += char('0' + digit); + n /= 10; + } + std::reverse(s.begin(), s.end()); + return negative ? "-" + s : s; + } +} + +template +static std::string vtos(const T &t, std::false_type) { + std::string s; + static std::stringstream ss; + ss.str(std::string()); + ss.clear(); + ss << t; + ss >> s; + return s; +} + +template +static std::string vtos(const T &t) { + return vtos(t, std::is_integral()); +} + +/* signed case. */ +template +static std::string toHumanReadableString(const T &n, std::false_type) { + if (n == 0) + return vtos(n); + int trailingZeroCount = 0; + T n_ = n; + while (n_ % 10 == 0) + n_ /= 10, trailingZeroCount++; + if (trailingZeroCount >= 7) { + if (n_ == 1) + return "10^" + vtos(trailingZeroCount); + else if (n_ == -1) + return "-10^" + vtos(trailingZeroCount); + else + return vtos(n_) + "*10^" + vtos(trailingZeroCount); + } else + return vtos(n); +} + +/* unsigned case. */ +template +static std::string toHumanReadableString(const T &n, std::true_type) { + if (n == 0) + return vtos(n); + int trailingZeroCount = 0; + T n_ = n; + while (n_ % 10 == 0) + n_ /= 10, trailingZeroCount++; + if (trailingZeroCount >= 7) { + if (n_ == 1) + return "10^" + vtos(trailingZeroCount); + else + return vtos(n_) + "*10^" + vtos(trailingZeroCount); + } else + return vtos(n); +} + +template +static std::string toHumanReadableString(const T &n) { + return toHumanReadableString(n, std::is_unsigned()); +} +#else +template +static std::string vtos(const T& t) +{ + std::string s; + static std::stringstream ss; + ss.str(std::string()); + ss.clear(); + ss << t; + ss >> s; + return s; +} + +template +static std::string toHumanReadableString(const T &n) { + return vtos(n); +} +#endif + +template +static std::string toString(const T &t) { + return vtos(t); +} + +#if __cplusplus > 199711L || defined(_MSC_VER) +/* opts */ +void prepareOpts(int argc, char* argv[]); +#endif + +/* + * Very simple regex-like pattern. + * It used for two purposes: validation and generation. + * + * For example, pattern("[a-z]{1,5}").next(rnd) will return + * random string from lowercase latin letters with length + * from 1 to 5. It is easier to call rnd.next("[a-z]{1,5}") + * for the same effect. + * + * Another samples: + * "mike|john" will generate (match) "mike" or "john"; + * "-?[1-9][0-9]{0,3}" will generate (match) non-zero integers from -9999 to 9999; + * "id-([ac]|b{2})" will generate (match) "id-a", "id-bb", "id-c"; + * "[^0-9]*" will match sequences (empty or non-empty) without digits, you can't + * use it for generations. + * + * You can't use pattern for generation if it contains meta-symbol '*'. Also it + * is not recommended to use it for char-sets with meta-symbol '^' like [^a-z]. + * + * For matching very simple greedy algorithm is used. For example, pattern + * "[0-9]?1" will not match "1", because of greedy nature of matching. + * Alternations (meta-symbols "|") are processed with brute-force algorithm, so + * do not use many alternations in one expression. + * + * If you want to use one expression many times it is better to compile it into + * a single pattern like "pattern p("[a-z]+")". Later you can use + * "p.matches(std::string s)" or "p.next(random_t& rd)" to check matching or generate + * new string by pattern. + * + * Simpler way to read token and check it for pattern matching is "inf.readToken("[a-z]+")". + * + * All spaces are ignored in regex, unless escaped with \. For example, ouf.readLine("NO SOLUTION") + * will expect "NOSOLUTION", the correct call should be ouf.readLine("NO\\ SOLUTION") or + * ouf.readLine(R"(NO\ SOLUTION)") if you prefer raw string literals from C++11. + */ +class random_t; + +class pattern { +public: + /* Create pattern instance by string. */ + pattern(std::string s); + + /* Generate new string by pattern and given random_t. */ + std::string next(random_t &rnd) const; + + /* Checks if given string match the pattern. */ + bool matches(const std::string &s) const; + + /* Returns source string of the pattern. */ + std::string src() const; + +private: + bool matches(const std::string &s, size_t pos) const; + + std::string s; + std::vector children; + std::vector chars; + int from; + int to; +}; + +/* + * Use random_t instances to generate random values. It is preffered + * way to use randoms instead of rand() function or self-written + * randoms. + * + * Testlib defines global variable "rnd" of random_t class. + * Use registerGen(argc, argv, 1) to setup random_t seed be command + * line (to use latest random generator version). + * + * Random generates uniformly distributed values if another strategy is + * not specified explicitly. + */ +class random_t { +private: + unsigned long long seed; + static const unsigned long long multiplier; + static const unsigned long long addend; + static const unsigned long long mask; + static const int lim; + + long long nextBits(int bits) { + if (bits <= 48) { + seed = (seed * multiplier + addend) & mask; + return (long long) (seed >> (48 - bits)); + } else { + if (bits > 63) + __testlib_fail("random_t::nextBits(int bits): n must be less than 64"); + + int lowerBitCount = (random_t::version == 0 ? 31 : 32); + + long long left = (nextBits(31) << 32); + long long right = nextBits(lowerBitCount); + + return left ^ right; + } + } + +public: + static int version; + + /* New random_t with fixed seed. */ + random_t() + : seed(3905348978240129619LL) { + } + + /* Sets seed by command line. */ + void setSeed(int argc, char *argv[]) { + random_t p; + + seed = 3905348978240129619LL; + for (int i = 1; i < argc; i++) { + std::size_t le = std::strlen(argv[i]); + for (std::size_t j = 0; j < le; j++) + seed = seed * multiplier + (unsigned int) (argv[i][j]) + addend; + seed += multiplier / addend; + } + + seed = seed & mask; + } + + /* Sets seed by given value. */ + void setSeed(long long _seed) { + _seed = (_seed ^ multiplier) & mask; + seed = _seed; + } + +#ifndef __BORLANDC__ + + /* Random string value by given pattern (see pattern documentation). */ + std::string next(const std::string &ptrn) { + pattern p(ptrn); + return p.next(*this); + } + +#else + /* Random string value by given pattern (see pattern documentation). */ + std::string next(std::string ptrn) + { + pattern p(ptrn); + return p.next(*this); + } +#endif + + /* Random value in range [0, n-1]. */ + int next(int n) { + if (n <= 0) + __testlib_fail("random_t::next(int n): n must be positive"); + + if ((n & -n) == n) // n is a power of 2 + return (int) ((n * (long long) nextBits(31)) >> 31); + + const long long limit = INT_MAX / n * n; + + long long bits; + do { + bits = nextBits(31); + } while (bits >= limit); + + return int(bits % n); + } + + /* Random value in range [0, n-1]. */ + unsigned int next(unsigned int n) { + if (n >= INT_MAX) + __testlib_fail("random_t::next(unsigned int n): n must be less INT_MAX"); + return (unsigned int) next(int(n)); + } + + /* Random value in range [0, n-1]. */ + long long next(long long n) { + if (n <= 0) + __testlib_fail("random_t::next(long long n): n must be positive"); + + const long long limit = __TESTLIB_LONGLONG_MAX / n * n; + + long long bits; + do { + bits = nextBits(63); + } while (bits >= limit); + + return bits % n; + } + + /* Random value in range [0, n-1]. */ + unsigned long long next(unsigned long long n) { + if (n >= (unsigned long long) (__TESTLIB_LONGLONG_MAX)) + __testlib_fail("random_t::next(unsigned long long n): n must be less LONGLONG_MAX"); + return (unsigned long long) next((long long) (n)); + } + + /* Random value in range [0, n-1]. */ + long next(long n) { + return (long) next((long long) (n)); + } + + /* Random value in range [0, n-1]. */ + unsigned long next(unsigned long n) { + if (n >= (unsigned long) (LONG_MAX)) + __testlib_fail("random_t::next(unsigned long n): n must be less LONG_MAX"); + return (unsigned long) next((unsigned long long) (n)); + } + + /* Returns random value in range [from,to]. */ + int next(int from, int to) { + return int(next((long long) to - from + 1) + from); + } + + /* Returns random value in range [from,to]. */ + unsigned int next(unsigned int from, unsigned int to) { + return (unsigned int) (next((long long) to - from + 1) + from); + } + + /* Returns random value in range [from,to]. */ + long long next(long long from, long long to) { + return next(to - from + 1) + from; + } + + /* Returns random value in range [from,to]. */ + unsigned long long next(unsigned long long from, unsigned long long to) { + if (from > to) + __testlib_fail("random_t::next(unsigned long long from, unsigned long long to): from can't not exceed to"); + return next(to - from + 1) + from; + } + + /* Returns random value in range [from,to]. */ + long next(long from, long to) { + return next(to - from + 1) + from; + } + + /* Returns random value in range [from,to]. */ + unsigned long next(unsigned long from, unsigned long to) { + if (from > to) + __testlib_fail("random_t::next(unsigned long from, unsigned long to): from can't not exceed to"); + return next(to - from + 1) + from; + } + + /* Random double value in range [0, 1). */ + double next() { + long long left = ((long long) (nextBits(26)) << 27); + long long right = nextBits(27); + return __testlib_crop((double) (left + right) / (double) (1LL << 53), 0.0, 1.0); + } + + /* Random double value in range [0, n). */ + double next(double n) { + if (n <= 0.0) + __testlib_fail("random_t::next(double): n should be positive"); + return __testlib_crop(n * next(), 0.0, n); + } + + /* Random double value in range [from, to). */ + double next(double from, double to) { + if (from >= to) + __testlib_fail("random_t::next(double from, double to): from should be strictly less than to"); + return next(to - from) + from; + } + + /* Returns random element from container. */ + template + typename Container::value_type any(const Container &c) { + int size = int(c.size()); + if (size <= 0) + __testlib_fail("random_t::any(const Container& c): c.size() must be positive"); + return *(c.begin() + next(size)); + } + + /* Returns random element from iterator range. */ + template + typename Iter::value_type any(const Iter &begin, const Iter &end) { + int size = int(end - begin); + if (size <= 0) + __testlib_fail("random_t::any(const Iter& begin, const Iter& end): range must have positive length"); + return *(begin + next(size)); + } + + /* Random string value by given pattern (see pattern documentation). */ +#ifdef __GNUC__ + __attribute__ ((format (printf, 2, 3))) +#endif + std::string next(const char *format, ...) { + FMT_TO_RESULT(format, format, ptrn); + return next(ptrn); + } + + /* + * Weighted next. If type == 0 than it is usual "next()". + * + * If type = 1, than it returns "max(next(), next())" + * (the number of "max" functions equals to "type"). + * + * If type < 0, than "max" function replaces with "min". + */ + int wnext(int n, int type) { + if (n <= 0) + __testlib_fail("random_t::wnext(int n, int type): n must be positive"); + + if (abs(type) < random_t::lim) { + int result = next(n); + + for (int i = 0; i < +type; i++) + result = __testlib_max(result, next(n)); + + for (int i = 0; i < -type; i++) + result = __testlib_min(result, next(n)); + + return result; + } else { + double p; + + if (type > 0) + p = std::pow(next() + 0.0, 1.0 / (type + 1)); + else + p = 1 - std::pow(next() + 0.0, 1.0 / (-type + 1)); + + return __testlib_crop((int) (double(n) * p), 0, n); + } + } + + /* See wnext(int, int). It uses the same algorithms. */ + long long wnext(long long n, int type) { + if (n <= 0) + __testlib_fail("random_t::wnext(long long n, int type): n must be positive"); + + if (abs(type) < random_t::lim) { + long long result = next(n); + + for (int i = 0; i < +type; i++) + result = __testlib_max(result, next(n)); + + for (int i = 0; i < -type; i++) + result = __testlib_min(result, next(n)); + + return result; + } else { + double p; + + if (type > 0) + p = std::pow(next() + 0.0, 1.0 / (type + 1)); + else + p = 1 - std::pow(next() + 0.0, 1.0 / (-type + 1)); + + return __testlib_crop((long long) (double(n) * p), 0LL, n); + } + } + + /* Returns value in [0, n). See wnext(int, int). It uses the same algorithms. */ + double wnext(double n, int type) { + if (n <= 0) + __testlib_fail("random_t::wnext(double n, int type): n must be positive"); + + if (abs(type) < random_t::lim) { + double result = next(); + + for (int i = 0; i < +type; i++) + result = __testlib_max(result, next()); + + for (int i = 0; i < -type; i++) + result = __testlib_min(result, next()); + + return n * result; + } else { + double p; + + if (type > 0) + p = std::pow(next() + 0.0, 1.0 / (type + 1)); + else + p = 1 - std::pow(next() + 0.0, 1.0 / (-type + 1)); + + return __testlib_crop(n * p, 0.0, n); + } + } + + /* Returns value in [0, 1). See wnext(int, int). It uses the same algorithms. */ + double wnext(int type) { + return wnext(1.0, type); + } + + /* See wnext(int, int). It uses the same algorithms. */ + unsigned int wnext(unsigned int n, int type) { + if (n >= INT_MAX) + __testlib_fail("random_t::wnext(unsigned int n, int type): n must be less INT_MAX"); + return (unsigned int) wnext(int(n), type); + } + + /* See wnext(int, int). It uses the same algorithms. */ + unsigned long long wnext(unsigned long long n, int type) { + if (n >= (unsigned long long) (__TESTLIB_LONGLONG_MAX)) + __testlib_fail("random_t::wnext(unsigned long long n, int type): n must be less LONGLONG_MAX"); + + return (unsigned long long) wnext((long long) (n), type); + } + + /* See wnext(int, int). It uses the same algorithms. */ + long wnext(long n, int type) { + return (long) wnext((long long) (n), type); + } + + /* See wnext(int, int). It uses the same algorithms. */ + unsigned long wnext(unsigned long n, int type) { + if (n >= (unsigned long) (LONG_MAX)) + __testlib_fail("random_t::wnext(unsigned long n, int type): n must be less LONG_MAX"); + + return (unsigned long) wnext((unsigned long long) (n), type); + } + + /* Returns weighted random value in range [from, to]. */ + int wnext(int from, int to, int type) { + if (from > to) + __testlib_fail("random_t::wnext(int from, int to, int type): from can't not exceed to"); + return wnext(to - from + 1, type) + from; + } + + /* Returns weighted random value in range [from, to]. */ + int wnext(unsigned int from, unsigned int to, int type) { + if (from > to) + __testlib_fail("random_t::wnext(unsigned int from, unsigned int to, int type): from can't not exceed to"); + return int(wnext(to - from + 1, type) + from); + } + + /* Returns weighted random value in range [from, to]. */ + long long wnext(long long from, long long to, int type) { + if (from > to) + __testlib_fail("random_t::wnext(long long from, long long to, int type): from can't not exceed to"); + return wnext(to - from + 1, type) + from; + } + + /* Returns weighted random value in range [from, to]. */ + unsigned long long wnext(unsigned long long from, unsigned long long to, int type) { + if (from > to) + __testlib_fail( + "random_t::wnext(unsigned long long from, unsigned long long to, int type): from can't not exceed to"); + return wnext(to - from + 1, type) + from; + } + + /* Returns weighted random value in range [from, to]. */ + long wnext(long from, long to, int type) { + if (from > to) + __testlib_fail("random_t::wnext(long from, long to, int type): from can't not exceed to"); + return wnext(to - from + 1, type) + from; + } + + /* Returns weighted random value in range [from, to]. */ + unsigned long wnext(unsigned long from, unsigned long to, int type) { + if (from > to) + __testlib_fail("random_t::wnext(unsigned long from, unsigned long to, int type): from can't not exceed to"); + return wnext(to - from + 1, type) + from; + } + + /* Returns weighted random double value in range [from, to). */ + double wnext(double from, double to, int type) { + if (from >= to) + __testlib_fail("random_t::wnext(double from, double to, int type): from should be strictly less than to"); + return wnext(to - from, type) + from; + } + + /* Returns weighted random element from container. */ + template + typename Container::value_type wany(const Container &c, int type) { + size_t size = c.size(); + if (size <= 0) + __testlib_fail("random_t::wany(const Container& c, int type): c.size() must be positive"); + return *(c.begin() + wnext(size, type)); + } + + /* Returns weighted random element from iterator range. */ + template + typename Iter::value_type wany(const Iter &begin, const Iter &end, int type) { + int size = int(end - begin); + if (size <= 0) + __testlib_fail( + "random_t::any(const Iter& begin, const Iter& end, int type): range must have positive length"); + return *(begin + wnext(size, type)); + } + + /* Returns random permutation of the given size (values are between `first` and `first`+size-1)*/ + template + std::vector perm(T size, E first) { + if (size < 0) + __testlib_fail("random_t::perm(T size, E first = 0): size must non-negative"); + else if (size == 0) + return std::vector(); + std::vector p(size); + E current = first; + for (T i = 0; i < size; i++) + p[i] = current++; + if (size > 1) + for (T i = 1; i < size; i++) + std::swap(p[i], p[next(i + 1)]); + return p; + } + + /* Returns random permutation of the given size (values are between 0 and size-1)*/ + template + std::vector perm(T size) { + return perm(size, T(0)); + } + + /* Returns `size` unordered (unsorted) distinct numbers between `from` and `to`. */ + template + std::vector distinct(int size, T from, T to) { + std::vector result; + if (size == 0) + return result; + + if (from > to) + __testlib_fail("random_t::distinct expected from <= to"); + + if (size < 0) + __testlib_fail("random_t::distinct expected size >= 0"); + + uint64_t n = to - from + 1; + if (uint64_t(size) > n) + __testlib_fail("random_t::distinct expected size <= to - from + 1"); + + double expected = 0.0; + for (int i = 1; i <= size; i++) + expected += double(n) / double(n - i + 1); + + if (expected < double(n)) { + std::set vals; + while (int(vals.size()) < size) { + T x = T(next(from, to)); + if (vals.insert(x).second) + result.push_back(x); + } + } else { + if (n > 1000000000) + __testlib_fail("random_t::distinct here expected to - from + 1 <= 1000000000"); + std::vector p(perm(int(n), from)); + result.insert(result.end(), p.begin(), p.begin() + size); + } + + return result; + } + + /* Returns `size` unordered (unsorted) distinct numbers between `0` and `upper`-1. */ + template + std::vector distinct(int size, T upper) { + if (size < 0) + __testlib_fail("random_t::distinct expected size >= 0"); + if (size == 0) + return std::vector(); + + if (upper <= 0) + __testlib_fail("random_t::distinct expected upper > 0"); + if (size > upper) + __testlib_fail("random_t::distinct expected size <= upper"); + + return distinct(size, T(0), upper - 1); + } + + /* Returns random (unsorted) partition which is a representation of sum as a sum of integers not less than min_part. */ + template + std::vector partition(int size, T sum, T min_part) { + if (size < 0) + __testlib_fail("random_t::partition: size < 0"); + if (size == 0 && sum != 0) + __testlib_fail("random_t::partition: size == 0 && sum != 0"); + if (min_part * size > sum) + __testlib_fail("random_t::partition: min_part * size > sum"); + if (size == 0 && sum == 0) + return std::vector(); + + T sum_ = sum; + sum -= min_part * size; + + std::vector septums(size); + std::vector d = distinct(size - 1, T(1), T(sum + size - 1)); + for (int i = 0; i + 1 < size; i++) + septums[i + 1] = d[i]; + sort(septums.begin(), septums.end()); + + std::vector result(size); + for (int i = 0; i + 1 < size; i++) + result[i] = septums[i + 1] - septums[i] - 1; + result[size - 1] = sum + size - 1 - septums.back(); + + for (std::size_t i = 0; i < result.size(); i++) + result[i] += min_part; + + T result_sum = 0; + for (std::size_t i = 0; i < result.size(); i++) + result_sum += result[i]; + if (result_sum != sum_) + __testlib_fail("random_t::partition: partition sum is expected to be the given sum"); + + if (*std::min_element(result.begin(), result.end()) < min_part) + __testlib_fail("random_t::partition: partition min is expected to be no less than the given min_part"); + + if (int(result.size()) != size || result.size() != (size_t) size) + __testlib_fail("random_t::partition: partition size is expected to be equal to the given size"); + + return result; + } + + /* Returns random (unsorted) partition which is a representation of sum as a sum of positive integers. */ + template + std::vector partition(int size, T sum) { + return partition(size, sum, T(1)); + } +}; + +const int random_t::lim = 25; +const unsigned long long random_t::multiplier = 0x5DEECE66DLL; +const unsigned long long random_t::addend = 0xBLL; +const unsigned long long random_t::mask = (1LL << 48) - 1; +int random_t::version = -1; + +/* Pattern implementation */ +bool pattern::matches(const std::string &s) const { + return matches(s, 0); +} + +static bool __pattern_isSlash(const std::string &s, size_t pos) { + return s[pos] == '\\'; +} + +#ifdef __GNUC__ +__attribute__((pure)) +#endif +static bool __pattern_isCommandChar(const std::string &s, size_t pos, char value) { + if (pos >= s.length()) + return false; + + int slashes = 0; + + int before = int(pos) - 1; + while (before >= 0 && s[before] == '\\') + before--, slashes++; + + return slashes % 2 == 0 && s[pos] == value; +} + +static char __pattern_getChar(const std::string &s, size_t &pos) { + if (__pattern_isSlash(s, pos)) + pos += 2; + else + pos++; + + return s[pos - 1]; +} + +#ifdef __GNUC__ +__attribute__((pure)) +#endif +static int __pattern_greedyMatch(const std::string &s, size_t pos, const std::vector chars) { + int result = 0; + + while (pos < s.length()) { + char c = s[pos++]; + if (!std::binary_search(chars.begin(), chars.end(), c)) + break; + else + result++; + } + + return result; +} + +std::string pattern::src() const { + return s; +} + +bool pattern::matches(const std::string &s, size_t pos) const { + std::string result; + + if (to > 0) { + int size = __pattern_greedyMatch(s, pos, chars); + if (size < from) + return false; + if (size > to) + size = to; + pos += size; + } + + if (children.size() > 0) { + for (size_t child = 0; child < children.size(); child++) + if (children[child].matches(s, pos)) + return true; + return false; + } else + return pos == s.length(); +} + +std::string pattern::next(random_t &rnd) const { + std::string result; + result.reserve(20); + + if (to == INT_MAX) + __testlib_fail("pattern::next(random_t& rnd): can't process character '*' for generation"); + + if (to > 0) { + int count = rnd.next(to - from + 1) + from; + for (int i = 0; i < count; i++) + result += chars[rnd.next(int(chars.size()))]; + } + + if (children.size() > 0) { + int child = rnd.next(int(children.size())); + result += children[child].next(rnd); + } + + return result; +} + +static void __pattern_scanCounts(const std::string &s, size_t &pos, int &from, int &to) { + if (pos >= s.length()) { + from = to = 1; + return; + } + + if (__pattern_isCommandChar(s, pos, '{')) { + std::vector parts; + std::string part; + + pos++; + + while (pos < s.length() && !__pattern_isCommandChar(s, pos, '}')) { + if (__pattern_isCommandChar(s, pos, ',')) + parts.push_back(part), part = "", pos++; + else + part += __pattern_getChar(s, pos); + } + + if (part != "") + parts.push_back(part); + + if (!__pattern_isCommandChar(s, pos, '}')) + __testlib_fail("pattern: Illegal pattern (or part) \"" + s + "\""); + + pos++; + + if (parts.size() < 1 || parts.size() > 2) + __testlib_fail("pattern: Illegal pattern (or part) \"" + s + "\""); + + std::vector numbers; + + for (size_t i = 0; i < parts.size(); i++) { + if (parts[i].length() == 0) + __testlib_fail("pattern: Illegal pattern (or part) \"" + s + "\""); + int number; + if (std::sscanf(parts[i].c_str(), "%d", &number) != 1) + __testlib_fail("pattern: Illegal pattern (or part) \"" + s + "\""); + numbers.push_back(number); + } + + if (numbers.size() == 1) + from = to = numbers[0]; + else + from = numbers[0], to = numbers[1]; + + if (from > to) + __testlib_fail("pattern: Illegal pattern (or part) \"" + s + "\""); + } else { + if (__pattern_isCommandChar(s, pos, '?')) { + from = 0, to = 1, pos++; + return; + } + + if (__pattern_isCommandChar(s, pos, '*')) { + from = 0, to = INT_MAX, pos++; + return; + } + + if (__pattern_isCommandChar(s, pos, '+')) { + from = 1, to = INT_MAX, pos++; + return; + } + + from = to = 1; + } +} + +static std::vector __pattern_scanCharSet(const std::string &s, size_t &pos) { + if (pos >= s.length()) + __testlib_fail("pattern: Illegal pattern (or part) \"" + s + "\""); + + std::vector result; + + if (__pattern_isCommandChar(s, pos, '[')) { + pos++; + bool negative = __pattern_isCommandChar(s, pos, '^'); + if (negative) + pos++; + + char prev = 0; + + while (pos < s.length() && !__pattern_isCommandChar(s, pos, ']')) { + if (__pattern_isCommandChar(s, pos, '-') && prev != 0) { + pos++; + + if (pos + 1 == s.length() || __pattern_isCommandChar(s, pos, ']')) { + result.push_back(prev); + prev = '-'; + continue; + } + + char next = __pattern_getChar(s, pos); + if (prev > next) + __testlib_fail("pattern: Illegal pattern (or part) \"" + s + "\""); + + for (char c = prev; c != next; c++) + result.push_back(c); + result.push_back(next); + + prev = 0; + } else { + if (prev != 0) + result.push_back(prev); + prev = __pattern_getChar(s, pos); + } + } + + if (prev != 0) + result.push_back(prev); + + if (!__pattern_isCommandChar(s, pos, ']')) + __testlib_fail("pattern: Illegal pattern (or part) \"" + s + "\""); + + pos++; + + if (negative) { + std::sort(result.begin(), result.end()); + std::vector actuals; + for (int code = 0; code < 255; code++) { + char c = char(code); + if (!std::binary_search(result.begin(), result.end(), c)) + actuals.push_back(c); + } + result = actuals; + } + + std::sort(result.begin(), result.end()); + } else + result.push_back(__pattern_getChar(s, pos)); + + return result; +} + +pattern::pattern(std::string s) : s(s), from(0), to(0) { + std::string t; + for (size_t i = 0; i < s.length(); i++) + if (!__pattern_isCommandChar(s, i, ' ')) + t += s[i]; + s = t; + + int opened = 0; + int firstClose = -1; + std::vector seps; + + for (size_t i = 0; i < s.length(); i++) { + if (__pattern_isCommandChar(s, i, '(')) { + opened++; + continue; + } + + if (__pattern_isCommandChar(s, i, ')')) { + opened--; + if (opened == 0 && firstClose == -1) + firstClose = int(i); + continue; + } + + if (opened < 0) + __testlib_fail("pattern: Illegal pattern (or part) \"" + s + "\""); + + if (__pattern_isCommandChar(s, i, '|') && opened == 0) + seps.push_back(int(i)); + } + + if (opened != 0) + __testlib_fail("pattern: Illegal pattern (or part) \"" + s + "\""); + + if (seps.size() == 0 && firstClose + 1 == (int) s.length() + && __pattern_isCommandChar(s, 0, '(') && __pattern_isCommandChar(s, s.length() - 1, ')')) { + children.push_back(pattern(s.substr(1, s.length() - 2))); + } else { + if (seps.size() > 0) { + seps.push_back(int(s.length())); + int last = 0; + + for (size_t i = 0; i < seps.size(); i++) { + children.push_back(pattern(s.substr(last, seps[i] - last))); + last = seps[i] + 1; + } + } else { + size_t pos = 0; + chars = __pattern_scanCharSet(s, pos); + __pattern_scanCounts(s, pos, from, to); + if (pos < s.length()) + children.push_back(pattern(s.substr(pos))); + } + } +} + +/* End of pattern implementation */ + +template +inline bool isEof(C c) { + return c == EOFC; +} + +template +inline bool isEoln(C c) { + return (c == LF || c == CR); +} + +template +inline bool isBlanks(C c) { + return (c == LF || c == CR || c == SPACE || c == TAB); +} + +inline std::string trim(const std::string &s) { + if (s.empty()) + return s; + + int left = 0; + while (left < int(s.length()) && isBlanks(s[left])) + left++; + if (left >= int(s.length())) + return ""; + + int right = int(s.length()) - 1; + while (right >= 0 && isBlanks(s[right])) + right--; + if (right < 0) + return ""; + + return s.substr(left, right - left + 1); +} + +enum TMode { + _input, _output, _answer +}; + +/* Outcomes 6-15 are reserved for future use. */ +enum TResult { + _ok = 0, + _wa = 1, + _pe = 2, + _fail = 3, + _dirt = 4, + _points = 5, + _unexpected_eof = 8, + _partially = 16 +}; + +enum TTestlibMode { + _unknown, _checker, _validator, _generator, _interactor, _scorer +}; + +#define _pc(exitCode) (TResult(_partially + (exitCode))) + +/* Outcomes 6-15 are reserved for future use. */ +const std::string outcomes[] = { + "accepted", + "wrong-answer", + "presentation-error", + "fail", + "fail", +#ifndef PCMS2 + "points", +#else + "relative-scoring", +#endif + "reserved", + "reserved", + "unexpected-eof", + "reserved", + "reserved", + "reserved", + "reserved", + "reserved", + "reserved", + "reserved", + "partially-correct" +}; + +class InputStreamReader { +public: + virtual void setTestCase(int testCase) = 0; + + virtual std::vector getReadChars() = 0; + + virtual int curChar() = 0; + + virtual int nextChar() = 0; + + virtual void skipChar() = 0; + + virtual void unreadChar(int c) = 0; + + virtual std::string getName() = 0; + + virtual bool eof() = 0; + + virtual void close() = 0; + + virtual int getLine() = 0; + + virtual ~InputStreamReader() = 0; +}; + +InputStreamReader::~InputStreamReader() { + // No operations. +} + +class StringInputStreamReader : public InputStreamReader { +private: + std::string s; + size_t pos; + +public: + StringInputStreamReader(const std::string &content) : s(content), pos(0) { + // No operations. + } + + void setTestCase(int) { + __testlib_fail("setTestCase not implemented in StringInputStreamReader"); + } + + std::vector getReadChars() { + __testlib_fail("getReadChars not implemented in StringInputStreamReader"); + } + + int curChar() { + if (pos >= s.length()) + return EOFC; + else + return s[pos]; + } + + int nextChar() { + if (pos >= s.length()) { + pos++; + return EOFC; + } else + return s[pos++]; + } + + void skipChar() { + pos++; + } + + void unreadChar(int c) { + if (pos == 0) + __testlib_fail("StringInputStreamReader::unreadChar(int): pos == 0."); + pos--; + if (pos < s.length()) + s[pos] = char(c); + } + + std::string getName() { + return __testlib_part(s); + } + + int getLine() { + return -1; + } + + bool eof() { + return pos >= s.length(); + } + + void close() { + // No operations. + } +}; + +class FileInputStreamReader : public InputStreamReader { +private: + std::FILE *file; + std::string name; + int line; + std::vector undoChars; + std::vector readChars; + std::vector undoReadChars; + + inline int postprocessGetc(int getcResult) { + if (getcResult != EOF) + return getcResult; + else + return EOFC; + } + + int getc(FILE *file) { + int c; + int rc; + + if (undoChars.empty()) { + c = rc = ::getc(file); + } else { + c = undoChars.back(); + undoChars.pop_back(); + rc = undoReadChars.back(); + undoReadChars.pop_back(); + } + + if (c == LF) + line++; + + readChars.push_back(rc); + return c; + } + + int ungetc(int c/*, FILE* file*/) { + if (!readChars.empty()) { + undoReadChars.push_back(readChars.back()); + readChars.pop_back(); + } + if (c == LF) + line--; + undoChars.push_back(c); + return c; + } + +public: + FileInputStreamReader(std::FILE *file, const std::string &name) : file(file), name(name), line(1) { + // No operations. + } + + void setTestCase(int testCase) { + if (testCase < 0 || testCase > __TESTLIB_MAX_TEST_CASE) + __testlib_fail(format("testCase expected fit in [1,%d], but %d doesn't", __TESTLIB_MAX_TEST_CASE, testCase)); + readChars.push_back(testCase + 256); + } + + std::vector getReadChars() { + return readChars; + } + + int curChar() { + if (feof(file)) + return EOFC; + else { + int c = getc(file); + ungetc(c/*, file*/); + return postprocessGetc(c); + } + } + + int nextChar() { + if (feof(file)) + return EOFC; + else + return postprocessGetc(getc(file)); + } + + void skipChar() { + getc(file); + } + + void unreadChar(int c) { + ungetc(c/*, file*/); + } + + std::string getName() { + return name; + } + + int getLine() { + return line; + } + + bool eof() { + if (NULL == file || feof(file)) + return true; + else { + int c = nextChar(); + if (c == EOFC || (c == EOF && feof(file))) + return true; + unreadChar(c); + return false; + } + } + + void close() { + if (NULL != file) { + fclose(file); + file = NULL; + } + } +}; + +class BufferedFileInputStreamReader : public InputStreamReader { +private: + static const size_t BUFFER_SIZE; + static const size_t MAX_UNREAD_COUNT; + + std::FILE *file; + std::string name; + int line; + + char *buffer; + bool *isEof; + int bufferPos; + size_t bufferSize; + + bool refill() { + if (NULL == file) + __testlib_fail("BufferedFileInputStreamReader: file == NULL (" + getName() + ")"); + + if (bufferPos >= int(bufferSize)) { + size_t readSize = fread( + buffer + MAX_UNREAD_COUNT, + 1, + BUFFER_SIZE - MAX_UNREAD_COUNT, + file + ); + + if (readSize < BUFFER_SIZE - MAX_UNREAD_COUNT + && ferror(file)) + __testlib_fail("BufferedFileInputStreamReader: unable to read (" + getName() + ")"); + + bufferSize = MAX_UNREAD_COUNT + readSize; + bufferPos = int(MAX_UNREAD_COUNT); + std::memset(isEof + MAX_UNREAD_COUNT, 0, sizeof(isEof[0]) * readSize); + + return readSize > 0; + } else + return true; + } + + char increment() { + char c; + if ((c = buffer[bufferPos++]) == LF) + line++; + return c; + } + +public: + BufferedFileInputStreamReader(std::FILE *file, const std::string &name) : file(file), name(name), line(1) { + buffer = new char[BUFFER_SIZE]; + isEof = new bool[BUFFER_SIZE]; + bufferSize = MAX_UNREAD_COUNT; + bufferPos = int(MAX_UNREAD_COUNT); + } + + ~BufferedFileInputStreamReader() { + if (NULL != buffer) { + delete[] buffer; + buffer = NULL; + } + if (NULL != isEof) { + delete[] isEof; + isEof = NULL; + } + } + + void setTestCase(int) { + __testlib_fail("setTestCase not implemented in BufferedFileInputStreamReader"); + } + + std::vector getReadChars() { + __testlib_fail("getReadChars not implemented in BufferedFileInputStreamReader"); + } + + int curChar() { + if (!refill()) + return EOFC; + + return isEof[bufferPos] ? EOFC : buffer[bufferPos]; + } + + int nextChar() { + if (!refill()) + return EOFC; + + return isEof[bufferPos] ? EOFC : increment(); + } + + void skipChar() { + increment(); + } + + void unreadChar(int c) { + bufferPos--; + if (bufferPos < 0) + __testlib_fail("BufferedFileInputStreamReader::unreadChar(int): bufferPos < 0"); + isEof[bufferPos] = (c == EOFC); + buffer[bufferPos] = char(c); + if (c == LF) + line--; + } + + std::string getName() { + return name; + } + + int getLine() { + return line; + } + + bool eof() { + return !refill() || EOFC == curChar(); + } + + void close() { + if (NULL != file) { + fclose(file); + file = NULL; + } + } +}; + +const size_t BufferedFileInputStreamReader::BUFFER_SIZE = 2000000; +const size_t BufferedFileInputStreamReader::MAX_UNREAD_COUNT = BufferedFileInputStreamReader::BUFFER_SIZE / 2; + +/* + * Streams to be used for reading data in checkers or validators. + * Each read*() method moves pointer to the next character after the + * read value. + */ +struct InStream { + /* Do not use them. */ + InStream(); + + ~InStream(); + + /* Wrap std::string with InStream. */ + InStream(const InStream &baseStream, std::string content); + + InputStreamReader *reader; + int lastLine; + + std::string name; + TMode mode; + bool opened; + bool stdfile; + bool strict; + + int wordReserveSize; + std::string _tmpReadToken; + + int readManyIteration; + size_t maxFileSize; + size_t maxTokenLength; + size_t maxMessageLength; + + void init(std::string fileName, TMode mode); + + void init(std::FILE *f, TMode mode); + + void setTestCase(int testCase); + std::vector getReadChars(); + + /* Moves stream pointer to the first non-white-space character or EOF. */ + void skipBlanks(); + + /* Returns current character in the stream. Doesn't remove it from stream. */ + char curChar(); + + /* Moves stream pointer one character forward. */ + void skipChar(); + + /* Returns current character and moves pointer one character forward. */ + char nextChar(); + + /* Returns current character and moves pointer one character forward. */ + char readChar(); + + /* As "readChar()" but ensures that the result is equal to given parameter. */ + char readChar(char c); + + /* As "readChar()" but ensures that the result is equal to the space (code=32). */ + char readSpace(); + + /* Puts back the character into the stream. */ + void unreadChar(char c); + + /* Reopens stream, you should not use it. */ + void reset(std::FILE *file = NULL); + + /* Checks that current position is EOF. If not it doesn't move stream pointer. */ + bool eof(); + + /* Moves pointer to the first non-white-space character and calls "eof()". */ + bool seekEof(); + + /* + * Checks that current position contains EOLN. + * If not it doesn't move stream pointer. + * In strict mode expects "#13#10" for windows or "#10" for other platforms. + */ + bool eoln(); + + /* Moves pointer to the first non-space and non-tab character and calls "eoln()". */ + bool seekEoln(); + + /* Moves stream pointer to the first character of the next line (if exists). */ + void nextLine(); + + /* + * Reads new token. Ignores white-spaces into the non-strict mode + * (strict mode is used in validators usually). + */ + std::string readWord(); + + /* The same as "readWord()", it is preffered to use "readToken()". */ + std::string readToken(); + + /* The same as "readWord()", but ensures that token matches to given pattern. */ + std::string readWord(const std::string &ptrn, const std::string &variableName = ""); + + std::string readWord(const pattern &p, const std::string &variableName = ""); + + std::vector + readWords(int size, const std::string &ptrn, const std::string &variablesName = "", int indexBase = 1); + + std::vector + readWords(int size, const pattern &p, const std::string &variablesName = "", int indexBase = 1); + + std::vector readWords(int size, int indexBase = 1); + + /* The same as "readToken()", but ensures that token matches to given pattern. */ + std::string readToken(const std::string &ptrn, const std::string &variableName = ""); + + std::string readToken(const pattern &p, const std::string &variableName = ""); + + std::vector + readTokens(int size, const std::string &ptrn, const std::string &variablesName = "", int indexBase = 1); + + std::vector + readTokens(int size, const pattern &p, const std::string &variablesName = "", int indexBase = 1); + + std::vector readTokens(int size, int indexBase = 1); + + void readWordTo(std::string &result); + + void readWordTo(std::string &result, const pattern &p, const std::string &variableName = ""); + + void readWordTo(std::string &result, const std::string &ptrn, const std::string &variableName = ""); + + void readTokenTo(std::string &result); + + void readTokenTo(std::string &result, const pattern &p, const std::string &variableName = ""); + + void readTokenTo(std::string &result, const std::string &ptrn, const std::string &variableName = ""); + + /* + * Reads new long long value. Ignores white-spaces into the non-strict mode + * (strict mode is used in validators usually). + */ + long long readLong(); + + unsigned long long readUnsignedLong(); + + /* + * Reads new int. Ignores white-spaces into the non-strict mode + * (strict mode is used in validators usually). + */ + int readInteger(); + + /* + * Reads new int. Ignores white-spaces into the non-strict mode + * (strict mode is used in validators usually). + */ + int readInt(); + + /* As "readLong()" but ensures that value in the range [minv,maxv]. */ + long long readLong(long long minv, long long maxv, const std::string &variableName = ""); + + /* Reads space-separated sequence of long longs. */ + std::vector + readLongs(int size, long long minv, long long maxv, const std::string &variablesName = "", int indexBase = 1); + + /* Reads space-separated sequence of long longs. */ + std::vector readLongs(int size, int indexBase = 1); + + unsigned long long + readUnsignedLong(unsigned long long minv, unsigned long long maxv, const std::string &variableName = ""); + + std::vector + readUnsignedLongs(int size, unsigned long long minv, unsigned long long maxv, const std::string &variablesName = "", + int indexBase = 1); + + std::vector readUnsignedLongs(int size, int indexBase = 1); + + unsigned long long readLong(unsigned long long minv, unsigned long long maxv, const std::string &variableName = ""); + + std::vector + readLongs(int size, unsigned long long minv, unsigned long long maxv, const std::string &variablesName = "", + int indexBase = 1); + + /* As "readInteger()" but ensures that value in the range [minv,maxv]. */ + int readInteger(int minv, int maxv, const std::string &variableName = ""); + + /* As "readInt()" but ensures that value in the range [minv,maxv]. */ + int readInt(int minv, int maxv, const std::string &variableName = ""); + + /* Reads space-separated sequence of integers. */ + std::vector + readIntegers(int size, int minv, int maxv, const std::string &variablesName = "", int indexBase = 1); + + /* Reads space-separated sequence of integers. */ + std::vector readIntegers(int size, int indexBase = 1); + + /* Reads space-separated sequence of integers. */ + std::vector readInts(int size, int minv, int maxv, const std::string &variablesName = "", int indexBase = 1); + + /* Reads space-separated sequence of integers. */ + std::vector readInts(int size, int indexBase = 1); + + /* + * Reads new double. Ignores white-spaces into the non-strict mode + * (strict mode is used in validators usually). + */ + double readReal(); + + /* + * Reads new double. Ignores white-spaces into the non-strict mode + * (strict mode is used in validators usually). + */ + double readDouble(); + + /* As "readReal()" but ensures that value in the range [minv,maxv]. */ + double readReal(double minv, double maxv, const std::string &variableName = ""); + + std::vector + readReals(int size, double minv, double maxv, const std::string &variablesName = "", int indexBase = 1); + + std::vector readReals(int size, int indexBase = 1); + + /* As "readDouble()" but ensures that value in the range [minv,maxv]. */ + double readDouble(double minv, double maxv, const std::string &variableName = ""); + + std::vector + readDoubles(int size, double minv, double maxv, const std::string &variablesName = "", int indexBase = 1); + + std::vector readDoubles(int size, int indexBase = 1); + + /* + * As "readReal()" but ensures that value in the range [minv,maxv] and + * number of digit after the decimal point is in range [minAfterPointDigitCount,maxAfterPointDigitCount] + * and number is in the form "[-]digit(s)[.digit(s)]". + */ + double readStrictReal(double minv, double maxv, + int minAfterPointDigitCount, int maxAfterPointDigitCount, + const std::string &variableName = ""); + + std::vector readStrictReals(int size, double minv, double maxv, + int minAfterPointDigitCount, int maxAfterPointDigitCount, + const std::string &variablesName = "", int indexBase = 1); + + /* + * As "readDouble()" but ensures that value in the range [minv,maxv] and + * number of digit after the decimal point is in range [minAfterPointDigitCount,maxAfterPointDigitCount] + * and number is in the form "[-]digit(s)[.digit(s)]". + */ + double readStrictDouble(double minv, double maxv, + int minAfterPointDigitCount, int maxAfterPointDigitCount, + const std::string &variableName = ""); + + std::vector readStrictDoubles(int size, double minv, double maxv, + int minAfterPointDigitCount, int maxAfterPointDigitCount, + const std::string &variablesName = "", int indexBase = 1); + + /* As readLine(). */ + std::string readString(); + + /* Read many lines. */ + std::vector readStrings(int size, int indexBase = 1); + + /* See readLine(). */ + void readStringTo(std::string &result); + + /* The same as "readLine()/readString()", but ensures that line matches to the given pattern. */ + std::string readString(const pattern &p, const std::string &variableName = ""); + + /* The same as "readLine()/readString()", but ensures that line matches to the given pattern. */ + std::string readString(const std::string &ptrn, const std::string &variableName = ""); + + /* Read many lines. */ + std::vector + readStrings(int size, const pattern &p, const std::string &variableName = "", int indexBase = 1); + + /* Read many lines. */ + std::vector + readStrings(int size, const std::string &ptrn, const std::string &variableName = "", int indexBase = 1); + + /* The same as "readLine()/readString()", but ensures that line matches to the given pattern. */ + void readStringTo(std::string &result, const pattern &p, const std::string &variableName = ""); + + /* The same as "readLine()/readString()", but ensures that line matches to the given pattern. */ + void readStringTo(std::string &result, const std::string &ptrn, const std::string &variableName = ""); + + /* + * Reads line from the current position to EOLN or EOF. Moves stream pointer to + * the first character of the new line (if possible). + */ + std::string readLine(); + + /* Read many lines. */ + std::vector readLines(int size, int indexBase = 1); + + /* See readLine(). */ + void readLineTo(std::string &result); + + /* The same as "readLine()", but ensures that line matches to the given pattern. */ + std::string readLine(const pattern &p, const std::string &variableName = ""); + + /* The same as "readLine()", but ensures that line matches to the given pattern. */ + std::string readLine(const std::string &ptrn, const std::string &variableName = ""); + + /* Read many lines. */ + std::vector + readLines(int size, const pattern &p, const std::string &variableName = "", int indexBase = 1); + + /* Read many lines. */ + std::vector + readLines(int size, const std::string &ptrn, const std::string &variableName = "", int indexBase = 1); + + /* The same as "readLine()", but ensures that line matches to the given pattern. */ + void readLineTo(std::string &result, const pattern &p, const std::string &variableName = ""); + + /* The same as "readLine()", but ensures that line matches to the given pattern. */ + void readLineTo(std::string &result, const std::string &ptrn, const std::string &variableName = ""); + + /* Reads EOLN or fails. Use it in validators. Calls "eoln()" method internally. */ + void readEoln(); + + /* Reads EOF or fails. Use it in validators. Calls "eof()" method internally. */ + void readEof(); + + /* + * Quit-functions aborts program with and : + * input/answer streams replace any result to FAIL. + */ + NORETURN void quit(TResult result, const char *msg); + /* + * Quit-functions aborts program with and : + * input/answer streams replace any result to FAIL. + */ + NORETURN void quitf(TResult result, const char *msg, ...); + + /* + * Quit-functions aborts program with and : + * input/answer streams replace any result to FAIL. + */ + void quitif(bool condition, TResult result, const char *msg, ...); + /* + * Quit-functions aborts program with and : + * input/answer streams replace any result to FAIL. + */ + NORETURN void quits(TResult result, std::string msg); + + /* + * Checks condition and aborts a program if codition is false. + * Returns _wa for ouf and _fail on any other streams. + */ +#ifdef __GNUC__ + __attribute__ ((format (printf, 3, 4))) +#endif + void ensuref(bool cond, const char *format, ...); + + void __testlib_ensure(bool cond, std::string message); + + void close(); + + const static int NO_INDEX = INT_MAX; + const static char OPEN_BRACKET = char(11); + const static char CLOSE_BRACKET = char(17); + + const static WORD LightGray = 0x07; + const static WORD LightRed = 0x0c; + const static WORD LightCyan = 0x0b; + const static WORD LightGreen = 0x0a; + const static WORD LightYellow = 0x0e; + + static void textColor(WORD color); + + static void quitscr(WORD color, const char *msg); + + static void quitscrS(WORD color, std::string msg); + + void xmlSafeWrite(std::FILE *file, const char *msg); + + /* Skips UTF-8 Byte Order Mark. */ + void skipBom(); + +private: + InStream(const InStream &); + + InStream &operator=(const InStream &); +}; + +InStream inf; +InStream ouf; +InStream ans; +bool appesMode; +std::string resultName; +std::string checkerName = "untitled checker"; +random_t rnd; +TTestlibMode testlibMode = _unknown; +double __testlib_points = std::numeric_limits::infinity(); + +struct ValidatorBoundsHit { + static const double EPS; + bool minHit; + bool maxHit; + + ValidatorBoundsHit(bool minHit = false, bool maxHit = false) : minHit(minHit), maxHit(maxHit) { + }; + + ValidatorBoundsHit merge(const ValidatorBoundsHit &validatorBoundsHit) { + return ValidatorBoundsHit( + __testlib_max(minHit, validatorBoundsHit.minHit), + __testlib_max(maxHit, validatorBoundsHit.maxHit) + ); + } +}; + +const double ValidatorBoundsHit::EPS = 1E-12; + +class Validator { +private: + const static std::string TEST_MARKUP_HEADER; + const static std::string TEST_CASE_OPEN_TAG; + const static std::string TEST_CASE_CLOSE_TAG; + + bool _initialized; + std::string _testset; + std::string _group; + + std::string _testOverviewLogFileName; + std::string _testMarkupFileName; + int _testCase = -1; + std::string _testCaseFileName; + + std::map _boundsHitByVariableName; + std::set _features; + std::set _hitFeatures; + + bool isVariableNameBoundsAnalyzable(const std::string &variableName) { + for (size_t i = 0; i < variableName.length(); i++) + if ((variableName[i] >= '0' && variableName[i] <= '9') || variableName[i] < ' ') + return false; + return true; + } + + bool isFeatureNameAnalyzable(const std::string &featureName) { + for (size_t i = 0; i < featureName.length(); i++) + if (featureName[i] < ' ') + return false; + return true; + } + +public: + Validator() : _initialized(false), _testset("tests"), _group() { + } + + void initialize() { + _initialized = true; + } + + std::string testset() const { + if (!_initialized) + __testlib_fail("Validator should be initialized with registerValidation(argc, argv) instead of registerValidation() to support validator.testset()"); + return _testset; + } + + std::string group() const { + if (!_initialized) + __testlib_fail("Validator should be initialized with registerValidation(argc, argv) instead of registerValidation() to support validator.group()"); + return _group; + } + + std::string testOverviewLogFileName() const { + return _testOverviewLogFileName; + } + + std::string testMarkupFileName() const { + return _testMarkupFileName; + } + + int testCase() const { + return _testCase; + } + + std::string testCaseFileName() const { + return _testCaseFileName; + } + + void setTestset(const char *const testset) { + _testset = testset; + } + + void setGroup(const char *const group) { + _group = group; + } + + void setTestOverviewLogFileName(const char *const testOverviewLogFileName) { + _testOverviewLogFileName = testOverviewLogFileName; + } + + void setTestMarkupFileName(const char *const testMarkupFileName) { + _testMarkupFileName = testMarkupFileName; + } + + void setTestCase(int testCase) { + _testCase = testCase; + } + + void setTestCaseFileName(const char *const testCaseFileName) { + _testCaseFileName = testCaseFileName; + } + + void addBoundsHit(const std::string &variableName, ValidatorBoundsHit boundsHit) { + if (isVariableNameBoundsAnalyzable(variableName)) { + _boundsHitByVariableName[variableName] + = boundsHit.merge(_boundsHitByVariableName[variableName]); + } + } + + std::string getBoundsHitLog() { + std::string result; + for (std::map::iterator i = _boundsHitByVariableName.begin(); + i != _boundsHitByVariableName.end(); + i++) { + result += "\"" + i->first + "\":"; + if (i->second.minHit) + result += " min-value-hit"; + if (i->second.maxHit) + result += " max-value-hit"; + result += "\n"; + } + return result; + } + + std::string getFeaturesLog() { + std::string result; + for (std::set::iterator i = _features.begin(); + i != _features.end(); + i++) { + result += "feature \"" + *i + "\":"; + if (_hitFeatures.count(*i)) + result += " hit"; + result += "\n"; + } + return result; + } + + void writeTestOverviewLog() { + if (!_testOverviewLogFileName.empty()) { + std::string fileName(_testOverviewLogFileName); + _testOverviewLogFileName = ""; + FILE *testOverviewLogFile = fopen(fileName.c_str(), "w"); + if (NULL == testOverviewLogFile) + __testlib_fail("Validator::writeTestOverviewLog: can't write test overview log to (" + fileName + ")"); + fprintf(testOverviewLogFile, "%s%s", getBoundsHitLog().c_str(), getFeaturesLog().c_str()); + if (fclose(testOverviewLogFile)) + __testlib_fail( + "Validator::writeTestOverviewLog: can't close test overview log file (" + fileName + ")"); + } + } + + void writeTestMarkup() { + if (!_testMarkupFileName.empty()) { + std::vector readChars = inf.getReadChars(); + if (!readChars.empty()) { + std::string markup(TEST_MARKUP_HEADER); + for (size_t i = 0; i < readChars.size(); i++) { + int c = readChars[i]; + if (i + 1 == readChars.size() && c == -1) + continue; + if (c <= 256) { + char cc = char(c); + if (cc == '\\' || cc == '!') + markup += '\\'; + markup += cc; + } else { + markup += TEST_CASE_OPEN_TAG; + markup += toString(c - 256); + markup += TEST_CASE_CLOSE_TAG; + } + } + FILE* f; + bool standard_file = false; + if (_testMarkupFileName == "stdout") + f = stdout, standard_file = true; + else if (_testMarkupFileName == "stderr") + f = stderr, standard_file = true; + else { + f = fopen(_testMarkupFileName.c_str(), "wb"); + if (NULL == f) + __testlib_fail("Validator::writeTestMarkup: can't write test markup to (" + _testMarkupFileName + ")"); + } + std::fprintf(f, "%s", markup.c_str()); + std::fflush(f); + if (!standard_file) + if (std::fclose(f)) + __testlib_fail("Validator::writeTestMarkup: can't close test markup file (" + _testCaseFileName + ")"); + } + } + } + + void writeTestCase() { + if (_testCase > 0) { + std::vector readChars = inf.getReadChars(); + if (!readChars.empty()) { + std::string content, testCaseContent; + bool matchedTestCase = false; + for (size_t i = 0; i < readChars.size(); i++) { + int c = readChars[i]; + if (i + 1 == readChars.size() && c == -1) + continue; + if (c <= 256) + content += char(c); + else { + if (matchedTestCase) { + testCaseContent = content; + matchedTestCase = false; + } + content = ""; + int testCase = c - 256; + if (testCase == _testCase) + matchedTestCase = true; + } + } + if (matchedTestCase) + testCaseContent = content; + + if (!testCaseContent.empty()) { + FILE* f; + bool standard_file = false; + if (_testCaseFileName.empty() || _testCaseFileName == "stdout") + f = stdout, standard_file = true; + else if (_testCaseFileName == "stderr") + f = stderr, standard_file = true; + else { + f = fopen(_testCaseFileName.c_str(), "wb"); + if (NULL == f) + __testlib_fail("Validator::writeTestCase: can't write test case to (" + _testCaseFileName + ")"); + } + std::fprintf(f, "%s", testCaseContent.c_str()); + std::fflush(f); + if (!standard_file) + if (std::fclose(f)) + __testlib_fail("Validator::writeTestCase: can't close test case file (" + _testCaseFileName + ")"); + } + } + } + } + + void addFeature(const std::string &feature) { + if (_features.count(feature)) + __testlib_fail("Feature " + feature + " registered twice."); + if (!isFeatureNameAnalyzable(feature)) + __testlib_fail("Feature name '" + feature + "' contains restricted characters."); + + _features.insert(feature); + } + + void feature(const std::string &feature) { + if (!isFeatureNameAnalyzable(feature)) + __testlib_fail("Feature name '" + feature + "' contains restricted characters."); + + if (!_features.count(feature)) + __testlib_fail("Feature " + feature + " didn't registered via addFeature(feature)."); + + _hitFeatures.insert(feature); + } +} validator; + +const std::string Validator::TEST_MARKUP_HEADER = "MU\xF3\x01"; +const std::string Validator::TEST_CASE_OPEN_TAG = "!c"; +const std::string Validator::TEST_CASE_CLOSE_TAG = ";"; + +struct TestlibFinalizeGuard { + static bool alive; + static bool registered; + + int quitCount, readEofCount; + + TestlibFinalizeGuard() : quitCount(0), readEofCount(0) { + // No operations. + } + + ~TestlibFinalizeGuard() { + bool _alive = alive; + alive = false; + + if (_alive) { + if (testlibMode == _checker && quitCount == 0) + __testlib_fail("Checker must end with quit or quitf call."); + + if (testlibMode == _validator && readEofCount == 0 && quitCount == 0) + __testlib_fail("Validator must end with readEof call."); + + /* opts */ + autoEnsureNoUnusedOpts(); + + if (!registered) + __testlib_fail("Call register-function in the first line of the main (registerTestlibCmd or other similar)"); + } + + if (__testlib_exitCode == 0) { + validator.writeTestOverviewLog(); + validator.writeTestMarkup(); + validator.writeTestCase(); + } + } + +private: + /* opts */ + void autoEnsureNoUnusedOpts(); +}; + +bool TestlibFinalizeGuard::alive = true; +bool TestlibFinalizeGuard::registered = false; +extern TestlibFinalizeGuard testlibFinalizeGuard; + +/* + * Call it to disable checks on finalization. + */ +void disableFinalizeGuard() { + TestlibFinalizeGuard::alive = false; +} + +/* Interactor streams. + */ +std::fstream tout; + +/* implementation + */ + +InStream::InStream() { + reader = NULL; + lastLine = -1; + opened = false; + name = ""; + mode = _input; + strict = false; + stdfile = false; + wordReserveSize = 4; + readManyIteration = NO_INDEX; + maxFileSize = 128 * 1024 * 1024; // 128MB. + maxTokenLength = 32 * 1024 * 1024; // 32MB. + maxMessageLength = 32000; +} + +InStream::InStream(const InStream &baseStream, std::string content) { + reader = new StringInputStreamReader(content); + lastLine = -1; + opened = true; + strict = baseStream.strict; + stdfile = false; + mode = baseStream.mode; + name = "based on " + baseStream.name; + readManyIteration = NO_INDEX; + maxFileSize = 128 * 1024 * 1024; // 128MB. + maxTokenLength = 32 * 1024 * 1024; // 32MB. + maxMessageLength = 32000; +} + +InStream::~InStream() { + if (NULL != reader) { + reader->close(); + delete reader; + reader = NULL; + } +} + +void InStream::setTestCase(int testCase) { + if (testlibMode != _validator || mode != _input || !stdfile || this != &inf) + __testlib_fail("InStream::setTestCase can be used only for inf in validator-mode." + " Actually, prefer setTestCase function instead of InStream member"); + reader->setTestCase(testCase); +} + +std::vector InStream::getReadChars() { + if (testlibMode != _validator || mode != _input || !stdfile || this != &inf) + __testlib_fail("InStream::getReadChars can be used only for inf in validator-mode."); + return reader == NULL ? std::vector() : reader->getReadChars(); +} + +void setTestCase(int testCase) { + static bool first_run = true; + static bool zero_based = false; + + if (first_run && testCase == 0) + zero_based = true; + + if (zero_based) + testCase++; + + __testlib_hasTestCase = true; + __testlib_testCase = testCase; + + if (testlibMode == _validator) + inf.setTestCase(testCase); + + first_run = false; +} + +#ifdef __GNUC__ +__attribute__((const)) +#endif +int resultExitCode(TResult r) { + if (r == _ok) + return OK_EXIT_CODE; + if (r == _wa) + return WA_EXIT_CODE; + if (r == _pe) + return PE_EXIT_CODE; + if (r == _fail) + return FAIL_EXIT_CODE; + if (r == _dirt) + return DIRT_EXIT_CODE; + if (r == _points) + return POINTS_EXIT_CODE; + if (r == _unexpected_eof) +#ifdef ENABLE_UNEXPECTED_EOF + return UNEXPECTED_EOF_EXIT_CODE; +#else + return PE_EXIT_CODE; +#endif + if (r >= _partially) + return PC_BASE_EXIT_CODE + (r - _partially); + return FAIL_EXIT_CODE; +} + +void InStream::textColor( +#if !(defined(ON_WINDOWS) && (!defined(_MSC_VER) || _MSC_VER > 1400)) && defined(__GNUC__) + __attribute__((unused)) +#endif + WORD color +) { +#if defined(ON_WINDOWS) && (!defined(_MSC_VER) || _MSC_VER > 1400) + HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE); + SetConsoleTextAttribute(handle, color); +#endif +#if !defined(ON_WINDOWS) && defined(__GNUC__) + if (isatty(2)) + { + switch (color) + { + case LightRed: + fprintf(stderr, "\033[1;31m"); + break; + case LightCyan: + fprintf(stderr, "\033[1;36m"); + break; + case LightGreen: + fprintf(stderr, "\033[1;32m"); + break; + case LightYellow: + fprintf(stderr, "\033[1;33m"); + break; + case LightGray: + default: + fprintf(stderr, "\033[0m"); + } + } +#endif +} + +#ifdef TESTLIB_THROW_EXIT_EXCEPTION_INSTEAD_OF_EXIT +class exit_exception: public std::exception { +private: + int exitCode; +public: + exit_exception(int exitCode): exitCode(exitCode) {} + int getExitCode() { return exitCode; } +}; +#endif + +NORETURN void halt(int exitCode) { +#ifdef FOOTER + InStream::textColor(InStream::LightGray); + std::fprintf(stderr, "Checker: \"%s\"\n", checkerName.c_str()); + std::fprintf(stderr, "Exit code: %d\n", exitCode); + InStream::textColor(InStream::LightGray); +#endif + __testlib_exitCode = exitCode; +#ifdef TESTLIB_THROW_EXIT_EXCEPTION_INSTEAD_OF_EXIT + throw exit_exception(exitCode); +#endif + std::exit(exitCode); +} + +static bool __testlib_shouldCheckDirt(TResult result) { + return result == _ok || result == _points || result >= _partially; +} + +static std::string __testlib_appendMessage(const std::string &message, const std::string &extra) { + int openPos = -1, closePos = -1; + for (size_t i = 0; i < message.length(); i++) { + if (message[i] == InStream::OPEN_BRACKET) { + if (openPos == -1) + openPos = int(i); + else + openPos = INT_MAX; + } + if (message[i] == InStream::CLOSE_BRACKET) { + if (closePos == -1) + closePos = int(i); + else + closePos = INT_MAX; + } + } + if (openPos != -1 && openPos != INT_MAX + && closePos != -1 && closePos != INT_MAX + && openPos < closePos) { + size_t index = message.find(extra, openPos); + if (index == std::string::npos || int(index) >= closePos) { + std::string result(message); + result.insert(closePos, ", " + extra); + return result; + } + return message; + } + + return message + " " + InStream::OPEN_BRACKET + extra + InStream::CLOSE_BRACKET; +} + +static std::string __testlib_toPrintableMessage(const std::string &message) { + int openPos = -1, closePos = -1; + for (size_t i = 0; i < message.length(); i++) { + if (message[i] == InStream::OPEN_BRACKET) { + if (openPos == -1) + openPos = int(i); + else + openPos = INT_MAX; + } + if (message[i] == InStream::CLOSE_BRACKET) { + if (closePos == -1) + closePos = int(i); + else + closePos = INT_MAX; + } + } + if (openPos != -1 && openPos != INT_MAX + && closePos != -1 && closePos != INT_MAX + && openPos < closePos) { + std::string result(message); + result[openPos] = '('; + result[closePos] = ')'; + return result; + } + + return message; +} + +NORETURN void InStream::quit(TResult result, const char *msg) { + if (TestlibFinalizeGuard::alive) + testlibFinalizeGuard.quitCount++; + + std::string message(msg); + message = trim(message); + + if (__testlib_hasTestCase) { + if (result != _ok) + message = __testlib_appendMessage(message, "test case " + vtos(__testlib_testCase)); + else { + if (__testlib_testCase == 1) + message = __testlib_appendMessage(message, vtos(__testlib_testCase) + " test case"); + else + message = __testlib_appendMessage(message, vtos(__testlib_testCase) + " test cases"); + } + } + + // You can change maxMessageLength. + // Example: 'inf.maxMessageLength = 1024 * 1024;'. + if (message.length() > maxMessageLength) { + std::string warn = "message length exceeds " + vtos(maxMessageLength) + + ", the message is truncated: "; + message = warn + message.substr(0, maxMessageLength - warn.length()); + } + +#ifndef ENABLE_UNEXPECTED_EOF + if (result == _unexpected_eof) + result = _pe; +#endif + + if (testlibMode == _scorer && result != _fail) + quits(_fail, "Scorer should return points only. Don't use a quit function."); + + if (mode != _output && result != _fail) { + if (mode == _input && testlibMode == _validator && lastLine != -1) + quits(_fail, __testlib_appendMessage(__testlib_appendMessage(message, name), "line " + vtos(lastLine))); + else + quits(_fail, __testlib_appendMessage(message, name)); + } + + std::FILE *resultFile; + std::string errorName; + + if (__testlib_shouldCheckDirt(result)) { + if (testlibMode != _interactor && !ouf.seekEof()) + quit(_dirt, "Extra information in the output file"); + } + + int pctype = result - _partially; + bool isPartial = false; + + switch (result) { + case _ok: + errorName = "ok "; + quitscrS(LightGreen, errorName); + break; + case _wa: + errorName = "wrong answer "; + quitscrS(LightRed, errorName); + break; + case _pe: + errorName = "wrong output format "; + quitscrS(LightRed, errorName); + break; + case _fail: + errorName = "FAIL "; + quitscrS(LightRed, errorName); + break; + case _dirt: + errorName = "wrong output format "; + quitscrS(LightCyan, errorName); + result = _pe; + break; + case _points: + errorName = "points "; + quitscrS(LightYellow, errorName); + break; + case _unexpected_eof: + errorName = "unexpected eof "; + quitscrS(LightCyan, errorName); + break; + default: + if (result >= _partially) { + errorName = format("partially correct (%d) ", pctype); + isPartial = true; + quitscrS(LightYellow, errorName); + } else + quit(_fail, "What is the code ??? "); + } + + if (resultName != "") { + resultFile = std::fopen(resultName.c_str(), "w"); + if (resultFile == NULL) { + resultName = ""; + quit(_fail, "Can not write to the result file"); + } + if (appesMode) { + std::fprintf(resultFile, ""); + if (isPartial) + std::fprintf(resultFile, "", + outcomes[(int) _partially].c_str(), pctype); + else { + if (result != _points) + std::fprintf(resultFile, "", outcomes[(int) result].c_str()); + else { + if (__testlib_points == std::numeric_limits::infinity()) + quit(_fail, "Expected points, but infinity found"); + std::string stringPoints = removeDoubleTrailingZeroes(format("%.10f", __testlib_points)); + std::fprintf(resultFile, "", + outcomes[(int) result].c_str(), stringPoints.c_str()); + } + } + xmlSafeWrite(resultFile, __testlib_toPrintableMessage(message).c_str()); + std::fprintf(resultFile, "\n"); + } else + std::fprintf(resultFile, "%s", __testlib_toPrintableMessage(message).c_str()); + if (NULL == resultFile || fclose(resultFile) != 0) { + resultName = ""; + quit(_fail, "Can not write to the result file"); + } + } + + quitscr(LightGray, __testlib_toPrintableMessage(message).c_str()); + std::fprintf(stderr, "\n"); + + inf.close(); + ouf.close(); + ans.close(); + if (tout.is_open()) + tout.close(); + + textColor(LightGray); + + if (resultName != "") + std::fprintf(stderr, "See file to check exit message\n"); + + halt(resultExitCode(result)); +} + +#ifdef __GNUC__ +__attribute__ ((format (printf, 3, 4))) +#endif +NORETURN void InStream::quitf(TResult result, const char *msg, ...) { + FMT_TO_RESULT(msg, msg, message); + InStream::quit(result, message.c_str()); +} + +#ifdef __GNUC__ +__attribute__ ((format (printf, 4, 5))) +#endif +void InStream::quitif(bool condition, TResult result, const char *msg, ...) { + if (condition) { + FMT_TO_RESULT(msg, msg, message); + InStream::quit(result, message.c_str()); + } +} + +NORETURN void InStream::quits(TResult result, std::string msg) { + InStream::quit(result, msg.c_str()); +} + +void InStream::xmlSafeWrite(std::FILE *file, const char *msg) { + size_t lmsg = strlen(msg); + for (size_t i = 0; i < lmsg; i++) { + if (msg[i] == '&') { + std::fprintf(file, "%s", "&"); + continue; + } + if (msg[i] == '<') { + std::fprintf(file, "%s", "<"); + continue; + } + if (msg[i] == '>') { + std::fprintf(file, "%s", ">"); + continue; + } + if (msg[i] == '"') { + std::fprintf(file, "%s", """); + continue; + } + if (0 <= msg[i] && msg[i] <= 31) { + std::fprintf(file, "%c", '.'); + continue; + } + std::fprintf(file, "%c", msg[i]); + } +} + +void InStream::quitscrS(WORD color, std::string msg) { + quitscr(color, msg.c_str()); +} + +void InStream::quitscr(WORD color, const char *msg) { + if (resultName == "") { + textColor(color); + std::fprintf(stderr, "%s", msg); + textColor(LightGray); + } +} + +void InStream::reset(std::FILE *file) { + if (opened && stdfile) + quit(_fail, "Can't reset standard handle"); + + if (opened) + close(); + + if (!stdfile && NULL == file) + if (NULL == (file = std::fopen(name.c_str(), "rb"))) { + if (mode == _output) + quits(_pe, std::string("Output file not found: \"") + name + "\""); + + if (mode == _answer) + quits(_fail, std::string("Answer file not found: \"") + name + "\""); + } + + if (NULL != file) { + opened = true; + __testlib_set_binary(file); + + if (stdfile) + reader = new FileInputStreamReader(file, name); + else + reader = new BufferedFileInputStreamReader(file, name); + } else { + opened = false; + reader = NULL; + } +} + +void InStream::init(std::string fileName, TMode mode) { + opened = false; + name = fileName; + stdfile = false; + this->mode = mode; + + std::ifstream stream; + stream.open(fileName.c_str(), std::ios::in); + if (stream.is_open()) { + std::streampos start = stream.tellg(); + stream.seekg(0, std::ios::end); + std::streampos end = stream.tellg(); + size_t fileSize = size_t(end - start); + stream.close(); + + // You can change maxFileSize. + // Example: 'inf.maxFileSize = 256 * 1024 * 1024;'. + if (fileSize > maxFileSize) + quitf(_pe, "File size exceeds %d bytes, size is %d", int(maxFileSize), int(fileSize)); + } + + reset(); + skipBom(); +} + +void InStream::init(std::FILE *f, TMode mode) { + opened = false; + name = "untitled"; + this->mode = mode; + + if (f == stdin) + name = "stdin", stdfile = true; + if (f == stdout) + name = "stdout", stdfile = true; + if (f == stderr) + name = "stderr", stdfile = true; + + reset(f); + skipBom(); +} + +void InStream::skipBom() { + const std::string utf8Bom = "\xEF\xBB\xBF"; + size_t index = 0; + while (index < utf8Bom.size() && curChar() == utf8Bom[index]) { + index++; + skipChar(); + } + if (index < utf8Bom.size()) { + while (index != 0) { + unreadChar(utf8Bom[index - 1]); + index--; + } + } +} + +char InStream::curChar() { + return char(reader->curChar()); +} + +char InStream::nextChar() { + return char(reader->nextChar()); +} + +char InStream::readChar() { + return nextChar(); +} + +char InStream::readChar(char c) { + lastLine = reader->getLine(); + char found = readChar(); + if (c != found) { + if (!isEoln(found)) + quit(_pe, ("Unexpected character '" + std::string(1, found) + "', but '" + std::string(1, c) + + "' expected").c_str()); + else + quit(_pe, ("Unexpected character " + ("#" + vtos(int(found))) + ", but '" + std::string(1, c) + + "' expected").c_str()); + } + return found; +} + +char InStream::readSpace() { + return readChar(' '); +} + +void InStream::unreadChar(char c) { + reader->unreadChar(c); +} + +void InStream::skipChar() { + reader->skipChar(); +} + +void InStream::skipBlanks() { + while (isBlanks(reader->curChar())) + reader->skipChar(); +} + +std::string InStream::readWord() { + readWordTo(_tmpReadToken); + return _tmpReadToken; +} + +void InStream::readWordTo(std::string &result) { + if (!strict) + skipBlanks(); + + lastLine = reader->getLine(); + int cur = reader->nextChar(); + + if (cur == EOFC) + quit(_unexpected_eof, "Unexpected end of file - token expected"); + + if (isBlanks(cur)) + quit(_pe, "Unexpected white-space - token expected"); + + result.clear(); + + while (!(isBlanks(cur) || cur == EOFC)) { + result += char(cur); + + // You can change maxTokenLength. + // Example: 'inf.maxTokenLength = 128 * 1024 * 1024;'. + if (result.length() > maxTokenLength) + quitf(_pe, "Length of token exceeds %d, token is '%s...'", int(maxTokenLength), + __testlib_part(result).c_str()); + + cur = reader->nextChar(); + } + + reader->unreadChar(cur); + + if (result.length() == 0) + quit(_unexpected_eof, "Unexpected end of file or white-space - token expected"); +} + +std::string InStream::readToken() { + return readWord(); +} + +void InStream::readTokenTo(std::string &result) { + readWordTo(result); +} + +static std::string __testlib_part(const std::string &s) { + std::string t; + for (size_t i = 0; i < s.length(); i++) + if (s[i] != '\0') + t += s[i]; + else + t += '~'; + if (t.length() <= 64) + return t; + else + return t.substr(0, 30) + "..." + t.substr(s.length() - 31, 31); +} + +#define __testlib_readMany(readMany, readOne, typeName, space) \ + if (size < 0) \ + quit(_fail, #readMany ": size should be non-negative."); \ + if (size > 100000000) \ + quit(_fail, #readMany ": size should be at most 100000000."); \ + \ + std::vector result(size); \ + readManyIteration = indexBase; \ + \ + for (int i = 0; i < size; i++) \ + { \ + result[i] = readOne; \ + readManyIteration++; \ + if (strict && space && i + 1 < size) \ + readSpace(); \ + } \ + \ + readManyIteration = NO_INDEX; \ + return result; \ + + +std::string InStream::readWord(const pattern &p, const std::string &variableName) { + readWordTo(_tmpReadToken); + if (!p.matches(_tmpReadToken)) { + if (readManyIteration == NO_INDEX) { + if (variableName.empty()) + quit(_wa, + ("Token \"" + __testlib_part(_tmpReadToken) + "\" doesn't correspond to pattern \"" + p.src() + + "\"").c_str()); + else + quit(_wa, ("Token parameter [name=" + variableName + "] equals to \"" + __testlib_part(_tmpReadToken) + + "\", doesn't correspond to pattern \"" + p.src() + "\"").c_str()); + } else { + if (variableName.empty()) + quit(_wa, ("Token element [index=" + vtos(readManyIteration) + "] equals to \"" + + __testlib_part(_tmpReadToken) + "\" doesn't correspond to pattern \"" + p.src() + + "\"").c_str()); + else + quit(_wa, ("Token element " + variableName + "[" + vtos(readManyIteration) + "] equals to \"" + + __testlib_part(_tmpReadToken) + "\", doesn't correspond to pattern \"" + p.src() + + "\"").c_str()); + } + } + return _tmpReadToken; +} + +std::vector +InStream::readWords(int size, const pattern &p, const std::string &variablesName, int indexBase) { + __testlib_readMany(readWords, readWord(p, variablesName), std::string, true); +} + +std::vector InStream::readWords(int size, int indexBase) { + __testlib_readMany(readWords, readWord(), std::string, true); +} + +std::string InStream::readWord(const std::string &ptrn, const std::string &variableName) { + return readWord(pattern(ptrn), variableName); +} + +std::vector +InStream::readWords(int size, const std::string &ptrn, const std::string &variablesName, int indexBase) { + pattern p(ptrn); + __testlib_readMany(readWords, readWord(p, variablesName), std::string, true); +} + +std::string InStream::readToken(const pattern &p, const std::string &variableName) { + return readWord(p, variableName); +} + +std::vector +InStream::readTokens(int size, const pattern &p, const std::string &variablesName, int indexBase) { + __testlib_readMany(readTokens, readToken(p, variablesName), std::string, true); +} + +std::vector InStream::readTokens(int size, int indexBase) { + __testlib_readMany(readTokens, readToken(), std::string, true); +} + +std::string InStream::readToken(const std::string &ptrn, const std::string &variableName) { + return readWord(ptrn, variableName); +} + +std::vector +InStream::readTokens(int size, const std::string &ptrn, const std::string &variablesName, int indexBase) { + pattern p(ptrn); + __testlib_readMany(readTokens, readWord(p, variablesName), std::string, true); +} + +void InStream::readWordTo(std::string &result, const pattern &p, const std::string &variableName) { + readWordTo(result); + if (!p.matches(result)) { + if (variableName.empty()) + quit(_wa, ("Token \"" + __testlib_part(result) + "\" doesn't correspond to pattern \"" + p.src() + + "\"").c_str()); + else + quit(_wa, ("Token parameter [name=" + variableName + "] equals to \"" + __testlib_part(result) + + "\", doesn't correspond to pattern \"" + p.src() + "\"").c_str()); + } +} + +void InStream::readWordTo(std::string &result, const std::string &ptrn, const std::string &variableName) { + return readWordTo(result, pattern(ptrn), variableName); +} + +void InStream::readTokenTo(std::string &result, const pattern &p, const std::string &variableName) { + return readWordTo(result, p, variableName); +} + +void InStream::readTokenTo(std::string &result, const std::string &ptrn, const std::string &variableName) { + return readWordTo(result, ptrn, variableName); +} + +#ifdef __GNUC__ +__attribute__((pure)) +#endif +static inline bool equals(long long integer, const char *s) { + if (integer == LLONG_MIN) + return strcmp(s, "-9223372036854775808") == 0; + + if (integer == 0LL) + return strcmp(s, "0") == 0; + + size_t length = strlen(s); + + if (length == 0) + return false; + + if (integer < 0 && s[0] != '-') + return false; + + if (integer < 0) + s++, length--, integer = -integer; + + if (length == 0) + return false; + + while (integer > 0) { + int digit = int(integer % 10); + + if (s[length - 1] != '0' + digit) + return false; + + length--; + integer /= 10; + } + + return length == 0; +} + +#ifdef __GNUC__ +__attribute__((pure)) +#endif +static inline bool equals(unsigned long long integer, const char *s) { + if (integer == ULLONG_MAX) + return strcmp(s, "18446744073709551615") == 0; + + if (integer == 0ULL) + return strcmp(s, "0") == 0; + + size_t length = strlen(s); + + if (length == 0) + return false; + + while (integer > 0) { + int digit = int(integer % 10); + + if (s[length - 1] != '0' + digit) + return false; + + length--; + integer /= 10; + } + + return length == 0; +} + +static inline double stringToDouble(InStream &in, const char *buffer) { + double retval; + + size_t length = strlen(buffer); + + int minusCount = 0; + int plusCount = 0; + int decimalPointCount = 0; + int digitCount = 0; + int eCount = 0; + + for (size_t i = 0; i < length; i++) { + if (('0' <= buffer[i] && buffer[i] <= '9') || buffer[i] == '.' + || buffer[i] == 'e' || buffer[i] == 'E' + || buffer[i] == '-' || buffer[i] == '+') { + if ('0' <= buffer[i] && buffer[i] <= '9') + digitCount++; + if (buffer[i] == 'e' || buffer[i] == 'E') + eCount++; + if (buffer[i] == '-') + minusCount++; + if (buffer[i] == '+') + plusCount++; + if (buffer[i] == '.') + decimalPointCount++; + } else + in.quit(_pe, ("Expected double, but \"" + __testlib_part(buffer) + "\" found").c_str()); + } + + // If for sure is not a number in standard notation or in e-notation. + if (digitCount == 0 || minusCount > 2 || plusCount > 2 || decimalPointCount > 1 || eCount > 1) + in.quit(_pe, ("Expected double, but \"" + __testlib_part(buffer) + "\" found").c_str()); + + char *suffix = new char[length + 1]; + std::memset(suffix, 0, length + 1); + int scanned = std::sscanf(buffer, "%lf%s", &retval, suffix); + bool empty = strlen(suffix) == 0; + delete[] suffix; + + if (scanned == 1 || (scanned == 2 && empty)) { + if (__testlib_isNaN(retval)) + in.quit(_pe, ("Expected double, but \"" + __testlib_part(buffer) + "\" found").c_str()); + return retval; + } else + in.quit(_pe, ("Expected double, but \"" + __testlib_part(buffer) + "\" found").c_str()); +} + +static inline double stringToDouble(InStream &in, const std::string& buffer) { + for (size_t i = 0; i < buffer.length(); i++) + if (buffer[i] == '\0') + in.quit(_pe, ("Expected double, but \"" + __testlib_part(buffer) + "\" found (it contains \\0)").c_str()); + return stringToDouble(in, buffer.c_str()); +} + +static inline double stringToStrictDouble(InStream &in, const char *buffer, + int minAfterPointDigitCount, int maxAfterPointDigitCount) { + if (minAfterPointDigitCount < 0) + in.quit(_fail, "stringToStrictDouble: minAfterPointDigitCount should be non-negative."); + + if (minAfterPointDigitCount > maxAfterPointDigitCount) + in.quit(_fail, + "stringToStrictDouble: minAfterPointDigitCount should be less or equal to maxAfterPointDigitCount."); + + double retval; + + size_t length = strlen(buffer); + + if (length == 0 || length > 1000) + in.quit(_pe, ("Expected strict double, but \"" + __testlib_part(buffer) + "\" found").c_str()); + + if (buffer[0] != '-' && (buffer[0] < '0' || buffer[0] > '9')) + in.quit(_pe, ("Expected strict double, but \"" + __testlib_part(buffer) + "\" found").c_str()); + + int pointPos = -1; + for (size_t i = 1; i + 1 < length; i++) { + if (buffer[i] == '.') { + if (pointPos > -1) + in.quit(_pe, ("Expected strict double, but \"" + __testlib_part(buffer) + "\" found").c_str()); + pointPos = int(i); + } + if (buffer[i] != '.' && (buffer[i] < '0' || buffer[i] > '9')) + in.quit(_pe, ("Expected strict double, but \"" + __testlib_part(buffer) + "\" found").c_str()); + } + + if (buffer[length - 1] < '0' || buffer[length - 1] > '9') + in.quit(_pe, ("Expected strict double, but \"" + __testlib_part(buffer) + "\" found").c_str()); + + int afterDigitsCount = (pointPos == -1 ? 0 : int(length) - pointPos - 1); + if (afterDigitsCount < minAfterPointDigitCount || afterDigitsCount > maxAfterPointDigitCount) + in.quit(_pe, ("Expected strict double with number of digits after point in range [" + + vtos(minAfterPointDigitCount) + + "," + + vtos(maxAfterPointDigitCount) + + "], but \"" + __testlib_part(buffer) + "\" found").c_str() + ); + + int firstDigitPos = -1; + for (size_t i = 0; i < length; i++) + if (buffer[i] >= '0' && buffer[i] <= '9') { + firstDigitPos = int(i); + break; + } + + if (firstDigitPos > 1 || firstDigitPos == -1) + in.quit(_pe, ("Expected strict double, but \"" + __testlib_part(buffer) + "\" found").c_str()); + + if (buffer[firstDigitPos] == '0' && firstDigitPos + 1 < int(length) + && buffer[firstDigitPos + 1] >= '0' && buffer[firstDigitPos + 1] <= '9') + in.quit(_pe, ("Expected strict double, but \"" + __testlib_part(buffer) + "\" found").c_str()); + + char *suffix = new char[length + 1]; + std::memset(suffix, 0, length + 1); + int scanned = std::sscanf(buffer, "%lf%s", &retval, suffix); + bool empty = strlen(suffix) == 0; + delete[] suffix; + + if (scanned == 1 || (scanned == 2 && empty)) { + if (__testlib_isNaN(retval) || __testlib_isInfinite(retval)) + in.quit(_pe, ("Expected double, but \"" + __testlib_part(buffer) + "\" found").c_str()); + if (buffer[0] == '-' && retval >= 0) + in.quit(_pe, ("Redundant minus in \"" + __testlib_part(buffer) + "\" found").c_str()); + return retval; + } else + in.quit(_pe, ("Expected double, but \"" + __testlib_part(buffer) + "\" found").c_str()); +} + +static inline double stringToStrictDouble(InStream &in, const std::string& buffer, + int minAfterPointDigitCount, int maxAfterPointDigitCount) { + for (size_t i = 0; i < buffer.length(); i++) + if (buffer[i] == '\0') + in.quit(_pe, ("Expected double, but \"" + __testlib_part(buffer) + "\" found (it contains \\0)").c_str()); + return stringToStrictDouble(in, buffer.c_str(), minAfterPointDigitCount, maxAfterPointDigitCount); +} + +static inline long long stringToLongLong(InStream &in, const char *buffer) { + if (strcmp(buffer, "-9223372036854775808") == 0) + return LLONG_MIN; + + bool minus = false; + size_t length = strlen(buffer); + + if (length > 1 && buffer[0] == '-') + minus = true; + + if (length > 20) + in.quit(_pe, ("Expected integer, but \"" + __testlib_part(buffer) + "\" found").c_str()); + + long long retval = 0LL; + + int zeroes = 0; + bool processingZeroes = true; + + for (int i = (minus ? 1 : 0); i < int(length); i++) { + if (buffer[i] == '0' && processingZeroes) + zeroes++; + else + processingZeroes = false; + + if (buffer[i] < '0' || buffer[i] > '9') + in.quit(_pe, ("Expected integer, but \"" + __testlib_part(buffer) + "\" found").c_str()); + retval = retval * 10 + (buffer[i] - '0'); + } + + if (retval < 0) + in.quit(_pe, ("Expected integer, but \"" + __testlib_part(buffer) + "\" found").c_str()); + + if ((zeroes > 0 && (retval != 0 || minus)) || zeroes > 1) + in.quit(_pe, ("Expected integer, but \"" + __testlib_part(buffer) + "\" found").c_str()); + + retval = (minus ? -retval : +retval); + + if (length < 19) + return retval; + + if (equals(retval, buffer)) + return retval; + else + in.quit(_pe, ("Expected int64, but \"" + __testlib_part(buffer) + "\" found").c_str()); +} + +static inline long long stringToLongLong(InStream &in, const std::string& buffer) { + for (size_t i = 0; i < buffer.length(); i++) + if (buffer[i] == '\0') + in.quit(_pe, ("Expected integer, but \"" + __testlib_part(buffer) + "\" found (it contains \\0)").c_str()); + return stringToLongLong(in, buffer.c_str()); +} + +static inline unsigned long long stringToUnsignedLongLong(InStream &in, const char *buffer) { + size_t length = strlen(buffer); + + if (length > 20) + in.quit(_pe, ("Expected unsigned integer, but \"" + __testlib_part(buffer) + "\" found").c_str()); + if (length > 1 && buffer[0] == '0') + in.quit(_pe, ("Expected unsigned integer, but \"" + __testlib_part(buffer) + "\" found").c_str()); + + unsigned long long retval = 0LL; + for (int i = 0; i < int(length); i++) { + if (buffer[i] < '0' || buffer[i] > '9') + in.quit(_pe, ("Expected unsigned integer, but \"" + __testlib_part(buffer) + "\" found").c_str()); + retval = retval * 10 + (buffer[i] - '0'); + } + + if (length < 19) + return retval; + + if (length == 20 && strcmp(buffer, "18446744073709551615") > 0) + in.quit(_pe, ("Expected unsigned int64, but \"" + __testlib_part(buffer) + "\" found").c_str()); + + if (equals(retval, buffer)) + return retval; + else + in.quit(_pe, ("Expected unsigned int64, but \"" + __testlib_part(buffer) + "\" found").c_str()); +} + +static inline long long stringToUnsignedLongLong(InStream &in, const std::string& buffer) { + for (size_t i = 0; i < buffer.length(); i++) + if (buffer[i] == '\0') + in.quit(_pe, ("Expected unsigned integer, but \"" + __testlib_part(buffer) + "\" found (it contains \\0)").c_str()); + return stringToUnsignedLongLong(in, buffer.c_str()); +} + +int InStream::readInteger() { + if (!strict && seekEof()) + quit(_unexpected_eof, "Unexpected end of file - int32 expected"); + + readWordTo(_tmpReadToken); + + long long value = stringToLongLong(*this, _tmpReadToken); + if (value < INT_MIN || value > INT_MAX) + quit(_pe, ("Expected int32, but \"" + __testlib_part(_tmpReadToken) + "\" found").c_str()); + + return int(value); +} + +long long InStream::readLong() { + if (!strict && seekEof()) + quit(_unexpected_eof, "Unexpected end of file - int64 expected"); + + readWordTo(_tmpReadToken); + + return stringToLongLong(*this, _tmpReadToken); +} + +unsigned long long InStream::readUnsignedLong() { + if (!strict && seekEof()) + quit(_unexpected_eof, "Unexpected end of file - int64 expected"); + + readWordTo(_tmpReadToken); + + return stringToUnsignedLongLong(*this, _tmpReadToken); +} + +long long InStream::readLong(long long minv, long long maxv, const std::string &variableName) { + long long result = readLong(); + + if (result < minv || result > maxv) { + if (readManyIteration == NO_INDEX) { + if (variableName.empty()) + quit(_wa, ("Integer " + vtos(result) + " violates the range [" + toHumanReadableString(minv) + ", " + toHumanReadableString(maxv) + + "]").c_str()); + else + quit(_wa, ("Integer parameter [name=" + std::string(variableName) + "] equals to " + vtos(result) + + ", violates the range [" + toHumanReadableString(minv) + ", " + toHumanReadableString(maxv) + "]").c_str()); + } else { + if (variableName.empty()) + quit(_wa, ("Integer element [index=" + vtos(readManyIteration) + "] equals to " + vtos(result) + + ", violates the range [" + toHumanReadableString(minv) + ", " + toHumanReadableString(maxv) + "]").c_str()); + else + quit(_wa, + ("Integer element " + std::string(variableName) + "[" + vtos(readManyIteration) + "] equals to " + + vtos(result) + ", violates the range [" + toHumanReadableString(minv) + ", " + toHumanReadableString(maxv) + "]").c_str()); + } + } + + if (strict && !variableName.empty()) + validator.addBoundsHit(variableName, ValidatorBoundsHit(minv == result, maxv == result)); + + return result; +} + +std::vector +InStream::readLongs(int size, long long minv, long long maxv, const std::string &variablesName, int indexBase) { + __testlib_readMany(readLongs, readLong(minv, maxv, variablesName), long long, true) +} + +std::vector InStream::readLongs(int size, int indexBase) { + __testlib_readMany(readLongs, readLong(), long long, true) +} + +unsigned long long +InStream::readUnsignedLong(unsigned long long minv, unsigned long long maxv, const std::string &variableName) { + unsigned long long result = readUnsignedLong(); + + if (result < minv || result > maxv) { + if (readManyIteration == NO_INDEX) { + if (variableName.empty()) + quit(_wa, + ("Unsigned integer " + vtos(result) + " violates the range [" + toHumanReadableString(minv) + ", " + toHumanReadableString(maxv) + + "]").c_str()); + else + quit(_wa, + ("Unsigned integer parameter [name=" + std::string(variableName) + "] equals to " + vtos(result) + + ", violates the range [" + toHumanReadableString(minv) + ", " + toHumanReadableString(maxv) + "]").c_str()); + } else { + if (variableName.empty()) + quit(_wa, + ("Unsigned integer element [index=" + vtos(readManyIteration) + "] equals to " + vtos(result) + + ", violates the range [" + toHumanReadableString(minv) + ", " + toHumanReadableString(maxv) + "]").c_str()); + else + quit(_wa, ("Unsigned integer element " + std::string(variableName) + "[" + vtos(readManyIteration) + + "] equals to " + vtos(result) + ", violates the range [" + toHumanReadableString(minv) + ", " + toHumanReadableString(maxv) + + "]").c_str()); + } + } + + if (strict && !variableName.empty()) + validator.addBoundsHit(variableName, ValidatorBoundsHit(minv == result, maxv == result)); + + return result; +} + +std::vector InStream::readUnsignedLongs(int size, unsigned long long minv, unsigned long long maxv, + const std::string &variablesName, int indexBase) { + __testlib_readMany(readUnsignedLongs, readUnsignedLong(minv, maxv, variablesName), unsigned long long, true) +} + +std::vector InStream::readUnsignedLongs(int size, int indexBase) { + __testlib_readMany(readUnsignedLongs, readUnsignedLong(), unsigned long long, true) +} + +unsigned long long +InStream::readLong(unsigned long long minv, unsigned long long maxv, const std::string &variableName) { + return readUnsignedLong(minv, maxv, variableName); +} + +int InStream::readInt() { + return readInteger(); +} + +int InStream::readInt(int minv, int maxv, const std::string &variableName) { + int result = readInt(); + + if (result < minv || result > maxv) { + if (readManyIteration == NO_INDEX) { + if (variableName.empty()) + quit(_wa, ("Integer " + vtos(result) + " violates the range [" + toHumanReadableString(minv) + ", " + toHumanReadableString(maxv) + + "]").c_str()); + else + quit(_wa, ("Integer parameter [name=" + std::string(variableName) + "] equals to " + vtos(result) + + ", violates the range [" + toHumanReadableString(minv) + ", " + toHumanReadableString(maxv) + "]").c_str()); + } else { + if (variableName.empty()) + quit(_wa, ("Integer element [index=" + vtos(readManyIteration) + "] equals to " + vtos(result) + + ", violates the range [" + toHumanReadableString(minv) + ", " + toHumanReadableString(maxv) + "]").c_str()); + else + quit(_wa, + ("Integer element " + std::string(variableName) + "[" + vtos(readManyIteration) + "] equals to " + + vtos(result) + ", violates the range [" + toHumanReadableString(minv) + ", " + toHumanReadableString(maxv) + "]").c_str()); + } + } + + if (strict && !variableName.empty()) + validator.addBoundsHit(variableName, ValidatorBoundsHit(minv == result, maxv == result)); + + return result; +} + +int InStream::readInteger(int minv, int maxv, const std::string &variableName) { + return readInt(minv, maxv, variableName); +} + +std::vector InStream::readInts(int size, int minv, int maxv, const std::string &variablesName, int indexBase) { + __testlib_readMany(readInts, readInt(minv, maxv, variablesName), int, true) +} + +std::vector InStream::readInts(int size, int indexBase) { + __testlib_readMany(readInts, readInt(), int, true) +} + +std::vector InStream::readIntegers(int size, int minv, int maxv, const std::string &variablesName, int indexBase) { + __testlib_readMany(readIntegers, readInt(minv, maxv, variablesName), int, true) +} + +std::vector InStream::readIntegers(int size, int indexBase) { + __testlib_readMany(readIntegers, readInt(), int, true) +} + +double InStream::readReal() { + if (!strict && seekEof()) + quit(_unexpected_eof, "Unexpected end of file - double expected"); + + return stringToDouble(*this, readWord()); +} + +double InStream::readDouble() { + return readReal(); +} + +double InStream::readReal(double minv, double maxv, const std::string &variableName) { + double result = readReal(); + + if (result < minv || result > maxv) { + if (readManyIteration == NO_INDEX) { + if (variableName.empty()) + quit(_wa, ("Double " + vtos(result) + " violates the range [" + vtos(minv) + ", " + vtos(maxv) + + "]").c_str()); + else + quit(_wa, ("Double parameter [name=" + std::string(variableName) + "] equals to " + vtos(result) + + ", violates the range [" + vtos(minv) + ", " + vtos(maxv) + "]").c_str()); + } else { + if (variableName.empty()) + quit(_wa, ("Double element [index=" + vtos(readManyIteration) + "] equals to " + vtos(result) + + ", violates the range [" + vtos(minv) + ", " + vtos(maxv) + "]").c_str()); + else + quit(_wa, + ("Double element " + std::string(variableName) + "[" + vtos(readManyIteration) + "] equals to " + + vtos(result) + ", violates the range [" + vtos(minv) + ", " + vtos(maxv) + "]").c_str()); + } + } + + if (strict && !variableName.empty()) + validator.addBoundsHit(variableName, ValidatorBoundsHit( + doubleDelta(minv, result) < ValidatorBoundsHit::EPS, + doubleDelta(maxv, result) < ValidatorBoundsHit::EPS + )); + + return result; +} + +std::vector +InStream::readReals(int size, double minv, double maxv, const std::string &variablesName, int indexBase) { + __testlib_readMany(readReals, readReal(minv, maxv, variablesName), double, true) +} + +std::vector InStream::readReals(int size, int indexBase) { + __testlib_readMany(readReals, readReal(), double, true) +} + +double InStream::readDouble(double minv, double maxv, const std::string &variableName) { + return readReal(minv, maxv, variableName); +} + +std::vector +InStream::readDoubles(int size, double minv, double maxv, const std::string &variablesName, int indexBase) { + __testlib_readMany(readDoubles, readDouble(minv, maxv, variablesName), double, true) +} + +std::vector InStream::readDoubles(int size, int indexBase) { + __testlib_readMany(readDoubles, readDouble(), double, true) +} + +double InStream::readStrictReal(double minv, double maxv, + int minAfterPointDigitCount, int maxAfterPointDigitCount, + const std::string &variableName) { + if (!strict && seekEof()) + quit(_unexpected_eof, "Unexpected end of file - strict double expected"); + + double result = stringToStrictDouble(*this, readWord(), minAfterPointDigitCount, maxAfterPointDigitCount); + + if (result < minv || result > maxv) { + if (readManyIteration == NO_INDEX) { + if (variableName.empty()) + quit(_wa, ("Strict double " + vtos(result) + " violates the range [" + vtos(minv) + ", " + vtos(maxv) + + "]").c_str()); + else + quit(_wa, + ("Strict double parameter [name=" + std::string(variableName) + "] equals to " + vtos(result) + + ", violates the range [" + vtos(minv) + ", " + vtos(maxv) + "]").c_str()); + } else { + if (variableName.empty()) + quit(_wa, ("Strict double element [index=" + vtos(readManyIteration) + "] equals to " + vtos(result) + + ", violates the range [" + vtos(minv) + ", " + vtos(maxv) + "]").c_str()); + else + quit(_wa, ("Strict double element " + std::string(variableName) + "[" + vtos(readManyIteration) + + "] equals to " + vtos(result) + ", violates the range [" + vtos(minv) + ", " + vtos(maxv) + + "]").c_str()); + } + } + + if (strict && !variableName.empty()) + validator.addBoundsHit(variableName, ValidatorBoundsHit( + doubleDelta(minv, result) < ValidatorBoundsHit::EPS, + doubleDelta(maxv, result) < ValidatorBoundsHit::EPS + )); + + return result; +} + +std::vector InStream::readStrictReals(int size, double minv, double maxv, + int minAfterPointDigitCount, int maxAfterPointDigitCount, + const std::string &variablesName, int indexBase) { + __testlib_readMany(readStrictReals, + readStrictReal(minv, maxv, minAfterPointDigitCount, maxAfterPointDigitCount, variablesName), + double, true) +} + +double InStream::readStrictDouble(double minv, double maxv, + int minAfterPointDigitCount, int maxAfterPointDigitCount, + const std::string &variableName) { + return readStrictReal(minv, maxv, + minAfterPointDigitCount, maxAfterPointDigitCount, + variableName); +} + +std::vector InStream::readStrictDoubles(int size, double minv, double maxv, + int minAfterPointDigitCount, int maxAfterPointDigitCount, + const std::string &variablesName, int indexBase) { + __testlib_readMany(readStrictDoubles, + readStrictDouble(minv, maxv, minAfterPointDigitCount, maxAfterPointDigitCount, variablesName), + double, true) +} + +bool InStream::eof() { + if (!strict && NULL == reader) + return true; + + return reader->eof(); +} + +bool InStream::seekEof() { + if (!strict && NULL == reader) + return true; + skipBlanks(); + return eof(); +} + +bool InStream::eoln() { + if (!strict && NULL == reader) + return true; + + int c = reader->nextChar(); + + if (!strict) { + if (c == EOFC) + return true; + + if (c == CR) { + c = reader->nextChar(); + + if (c != LF) { + reader->unreadChar(c); + reader->unreadChar(CR); + return false; + } else + return true; + } + + if (c == LF) + return true; + + reader->unreadChar(c); + return false; + } else { + bool returnCr = false; + +#if (defined(ON_WINDOWS) && !defined(FOR_LINUX)) || defined(FOR_WINDOWS) + if (c != CR) { + reader->unreadChar(c); + return false; + } else { + if (!returnCr) + returnCr = true; + c = reader->nextChar(); + } +#endif + if (c != LF) { + reader->unreadChar(c); + if (returnCr) + reader->unreadChar(CR); + return false; + } + + return true; + } +} + +void InStream::readEoln() { + lastLine = reader->getLine(); + if (!eoln()) + quit(_pe, "Expected EOLN"); +} + +void InStream::readEof() { + lastLine = reader->getLine(); + if (!eof()) + quit(_pe, "Expected EOF"); + + if (TestlibFinalizeGuard::alive && this == &inf) + testlibFinalizeGuard.readEofCount++; +} + +bool InStream::seekEoln() { + if (!strict && NULL == reader) + return true; + + int cur; + do { + cur = reader->nextChar(); + } while (cur == SPACE || cur == TAB); + + reader->unreadChar(cur); + return eoln(); +} + +void InStream::nextLine() { + readLine(); +} + +void InStream::readStringTo(std::string &result) { + if (NULL == reader) + quit(_pe, "Expected line"); + + result.clear(); + + for (;;) { + int cur = reader->curChar(); + + if (cur == LF || cur == EOFC) + break; + + if (cur == CR) { + cur = reader->nextChar(); + if (reader->curChar() == LF) { + reader->unreadChar(cur); + break; + } + } + + lastLine = reader->getLine(); + result += char(reader->nextChar()); + } + + if (strict) + readEoln(); + else + eoln(); +} + +std::string InStream::readString() { + readStringTo(_tmpReadToken); + return _tmpReadToken; +} + +std::vector InStream::readStrings(int size, int indexBase) { + __testlib_readMany(readStrings, readString(), std::string, false) +} + +void InStream::readStringTo(std::string &result, const pattern &p, const std::string &variableName) { + readStringTo(result); + if (!p.matches(result)) { + if (readManyIteration == NO_INDEX) { + if (variableName.empty()) + quit(_wa, ("Line \"" + __testlib_part(result) + "\" doesn't correspond to pattern \"" + p.src() + + "\"").c_str()); + else + quit(_wa, ("Line [name=" + variableName + "] equals to \"" + __testlib_part(result) + + "\", doesn't correspond to pattern \"" + p.src() + "\"").c_str()); + } else { + if (variableName.empty()) + quit(_wa, + ("Line element [index=" + vtos(readManyIteration) + "] equals to \"" + __testlib_part(result) + + "\" doesn't correspond to pattern \"" + p.src() + "\"").c_str()); + else + quit(_wa, + ("Line element " + std::string(variableName) + "[" + vtos(readManyIteration) + "] equals to \"" + + __testlib_part(result) + "\", doesn't correspond to pattern \"" + p.src() + "\"").c_str()); + } + } +} + +void InStream::readStringTo(std::string &result, const std::string &ptrn, const std::string &variableName) { + readStringTo(result, pattern(ptrn), variableName); +} + +std::string InStream::readString(const pattern &p, const std::string &variableName) { + readStringTo(_tmpReadToken, p, variableName); + return _tmpReadToken; +} + +std::vector +InStream::readStrings(int size, const pattern &p, const std::string &variablesName, int indexBase) { + __testlib_readMany(readStrings, readString(p, variablesName), std::string, false) +} + +std::string InStream::readString(const std::string &ptrn, const std::string &variableName) { + readStringTo(_tmpReadToken, ptrn, variableName); + return _tmpReadToken; +} + +std::vector +InStream::readStrings(int size, const std::string &ptrn, const std::string &variablesName, int indexBase) { + pattern p(ptrn); + __testlib_readMany(readStrings, readString(p, variablesName), std::string, false) +} + +void InStream::readLineTo(std::string &result) { + readStringTo(result); +} + +std::string InStream::readLine() { + return readString(); +} + +std::vector InStream::readLines(int size, int indexBase) { + __testlib_readMany(readLines, readString(), std::string, false) +} + +void InStream::readLineTo(std::string &result, const pattern &p, const std::string &variableName) { + readStringTo(result, p, variableName); +} + +void InStream::readLineTo(std::string &result, const std::string &ptrn, const std::string &variableName) { + readStringTo(result, ptrn, variableName); +} + +std::string InStream::readLine(const pattern &p, const std::string &variableName) { + return readString(p, variableName); +} + +std::vector +InStream::readLines(int size, const pattern &p, const std::string &variablesName, int indexBase) { + __testlib_readMany(readLines, readString(p, variablesName), std::string, false) +} + +std::string InStream::readLine(const std::string &ptrn, const std::string &variableName) { + return readString(ptrn, variableName); +} + +std::vector +InStream::readLines(int size, const std::string &ptrn, const std::string &variablesName, int indexBase) { + pattern p(ptrn); + __testlib_readMany(readLines, readString(p, variablesName), std::string, false) +} + +#ifdef __GNUC__ +__attribute__ ((format (printf, 3, 4))) +#endif +void InStream::ensuref(bool cond, const char *format, ...) { + if (!cond) { + FMT_TO_RESULT(format, format, message); + this->__testlib_ensure(cond, message); + } +} + +void InStream::__testlib_ensure(bool cond, std::string message) { + if (!cond) + this->quit(_wa, message.c_str()); +} + +void InStream::close() { + if (NULL != reader) { + reader->close(); + delete reader; + reader = NULL; + } + + opened = false; +} + +NORETURN void quit(TResult result, const std::string &msg) { + ouf.quit(result, msg.c_str()); +} + +NORETURN void quit(TResult result, const char *msg) { + ouf.quit(result, msg); +} + +NORETURN void __testlib_quitp(double points, const char *message) { + __testlib_points = points; + std::string stringPoints = removeDoubleTrailingZeroes(format("%.10f", points)); + + std::string quitMessage; + if (NULL == message || 0 == strlen(message)) + quitMessage = stringPoints; + else + quitMessage = stringPoints + " " + message; + + quit(_points, quitMessage.c_str()); +} + +NORETURN void __testlib_quitp(int points, const char *message) { + __testlib_points = points; + std::string stringPoints = format("%d", points); + + std::string quitMessage; + if (NULL == message || 0 == strlen(message)) + quitMessage = stringPoints; + else + quitMessage = stringPoints + " " + message; + + quit(_points, quitMessage.c_str()); +} + +NORETURN void quitp(float points, const std::string &message = "") { + __testlib_quitp(double(points), message.c_str()); +} + +NORETURN void quitp(double points, const std::string &message = "") { + __testlib_quitp(points, message.c_str()); +} + +NORETURN void quitp(long double points, const std::string &message = "") { + __testlib_quitp(double(points), message.c_str()); +} + +NORETURN void quitp(int points, const std::string &message = "") { + __testlib_quitp(points, message.c_str()); +} + +NORETURN void quitpi(const std::string &points_info, const std::string &message = "") { + if (points_info.find(' ') != std::string::npos) + quit(_fail, "Parameter 'points_info' can't contain spaces"); + if (message.empty()) + quit(_points, ("points_info=" + points_info).c_str()); + else + quit(_points, ("points_info=" + points_info + " " + message).c_str()); +} + +template +#ifdef __GNUC__ +__attribute__ ((format (printf, 2, 3))) +#endif +NORETURN void quitp(F points, const char *format, ...) { + FMT_TO_RESULT(format, format, message); + quitp(points, message); +} + +#ifdef __GNUC__ +__attribute__ ((format (printf, 2, 3))) +#endif +NORETURN void quitf(TResult result, const char *format, ...) { + FMT_TO_RESULT(format, format, message); + quit(result, message); +} + +#ifdef __GNUC__ +__attribute__ ((format (printf, 3, 4))) +#endif +void quitif(bool condition, TResult result, const char *format, ...) { + if (condition) { + FMT_TO_RESULT(format, format, message); + quit(result, message); + } +} + +NORETURN void __testlib_help() { + InStream::textColor(InStream::LightCyan); + std::fprintf(stderr, "TESTLIB %s, https://github.com/MikeMirzayanov/testlib/ ", VERSION); + std::fprintf(stderr, "by Mike Mirzayanov, copyright(c) 2005-2020\n"); + std::fprintf(stderr, "Checker name: \"%s\"\n", checkerName.c_str()); + InStream::textColor(InStream::LightGray); + + std::fprintf(stderr, "\n"); + std::fprintf(stderr, "Latest features: \n"); + for (size_t i = 0; i < sizeof(latestFeatures) / sizeof(char *); i++) { + std::fprintf(stderr, "*) %s\n", latestFeatures[i]); + } + std::fprintf(stderr, "\n"); + + std::fprintf(stderr, "Program must be run with the following arguments: \n"); + std::fprintf(stderr, " [--testset testset] [--group group] [ [<-appes>]]\n\n"); + + __testlib_exitCode = FAIL_EXIT_CODE; + std::exit(FAIL_EXIT_CODE); +} + +static void __testlib_ensuresPreconditions() { + // testlib assumes: sizeof(int) = 4. + __TESTLIB_STATIC_ASSERT(sizeof(int) == 4); + + // testlib assumes: INT_MAX == 2147483647. + __TESTLIB_STATIC_ASSERT(INT_MAX == 2147483647); + + // testlib assumes: sizeof(long long) = 8. + __TESTLIB_STATIC_ASSERT(sizeof(long long) == 8); + + // testlib assumes: sizeof(double) = 8. + __TESTLIB_STATIC_ASSERT(sizeof(double) == 8); + + // testlib assumes: no -ffast-math. + if (!__testlib_isNaN(+__testlib_nan())) + quit(_fail, "Function __testlib_isNaN is not working correctly: possible reason is '-ffast-math'"); + if (!__testlib_isNaN(-__testlib_nan())) + quit(_fail, "Function __testlib_isNaN is not working correctly: possible reason is '-ffast-math'"); +} + +std::string __testlib_testset; + +std::string getTestset() { + return __testlib_testset; +} + +std::string __testlib_group; + +std::string getGroup() { + return __testlib_group; +} + +static void __testlib_set_testset_and_group(int argc, char* argv[]) { + for (int i = 1; i < argc; i++) { + if (!strcmp("--testset", argv[i])) { + if (i + 1 < argc && strlen(argv[i + 1]) > 0) + __testlib_testset = argv[++i]; + else + quit(_fail, std::string("Expected non-empty testset after --testset command line parameter")); + } else if (!strcmp("--group", argv[i])) { + if (i + 1 < argc) + __testlib_group = argv[++i]; + else + quit(_fail, std::string("Expected group after --group command line parameter")); + } + } +} + +void registerGen(int argc, char *argv[], int randomGeneratorVersion) { + if (randomGeneratorVersion < 0 || randomGeneratorVersion > 1) + quitf(_fail, "Random generator version is expected to be 0 or 1."); + random_t::version = randomGeneratorVersion; + + __testlib_ensuresPreconditions(); + TestlibFinalizeGuard::registered = true; + + testlibMode = _generator; + __testlib_set_binary(stdin); + rnd.setSeed(argc, argv); + +#if __cplusplus > 199711L || defined(_MSC_VER) + prepareOpts(argc, argv); +#endif +} + +#ifdef USE_RND_AS_BEFORE_087 +void registerGen(int argc, char* argv[]) +{ + registerGen(argc, argv, 0); +} +#else +#ifdef __GNUC__ +#if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 4)) +__attribute__ ((deprecated("Use registerGen(argc, argv, 0) or registerGen(argc, argv, 1)." +" The third parameter stands for the random generator version." +" If you are trying to compile old generator use macro -DUSE_RND_AS_BEFORE_087 or registerGen(argc, argv, 0)." +" Version 1 has been released on Spring, 2013. Use it to write new generators."))) +#else +__attribute__ ((deprecated)) +#endif +#endif +#ifdef _MSC_VER +__declspec(deprecated("Use registerGen(argc, argv, 0) or registerGen(argc, argv, 1)." + " The third parameter stands for the random generator version." + " If you are trying to compile old generator use macro -DUSE_RND_AS_BEFORE_087 or registerGen(argc, argv, 0)." + " Version 1 has been released on Spring, 2013. Use it to write new generators.")) +#endif +void registerGen(int argc, char *argv[]) { + std::fprintf(stderr, "Use registerGen(argc, argv, 0) or registerGen(argc, argv, 1)." + " The third parameter stands for the random generator version." + " If you are trying to compile old generator use macro -DUSE_RND_AS_BEFORE_087 or registerGen(argc, argv, 0)." + " Version 1 has been released on Spring, 2013. Use it to write new generators.\n\n"); + registerGen(argc, argv, 0); +} +#endif + +void registerInteraction(int argc, char *argv[]) { + __testlib_ensuresPreconditions(); + __testlib_set_testset_and_group(argc, argv); + TestlibFinalizeGuard::registered = true; + + testlibMode = _interactor; + __testlib_set_binary(stdin); + + if (argc > 1 && !strcmp("--help", argv[1])) + __testlib_help(); + + if (argc < 3 || argc > 6) { + quit(_fail, std::string("Program must be run with the following arguments: ") + + std::string(" [ [ [<-appes>]]]") + + "\nUse \"--help\" to get help information"); + } + + if (argc <= 4) { + resultName = ""; + appesMode = false; + } + +#ifndef EJUDGE + if (argc == 5) { + resultName = argv[4]; + appesMode = false; + } + + if (argc == 6) { + if (strcmp("-APPES", argv[5]) && strcmp("-appes", argv[5])) { + quit(_fail, std::string("Program must be run with the following arguments: ") + + " [ [<-appes>]]"); + } else { + resultName = argv[4]; + appesMode = true; + } + } +#endif + + inf.init(argv[1], _input); + + tout.open(argv[2], std::ios_base::out); + if (tout.fail() || !tout.is_open()) + quit(_fail, std::string("Can not write to the test-output-file '") + argv[2] + std::string("'")); + + ouf.init(stdin, _output); + + if (argc >= 4) + ans.init(argv[3], _answer); + else + ans.name = "unopened answer stream"; +} + +void registerValidation() { + __testlib_ensuresPreconditions(); + TestlibFinalizeGuard::registered = true; + + testlibMode = _validator; + + __testlib_set_binary(stdin); + __testlib_set_binary(stdout); + __testlib_set_binary(stderr); + + inf.init(stdin, _input); + inf.strict = true; +} + +void registerValidation(int argc, char *argv[]) { + registerValidation(); + __testlib_set_testset_and_group(argc, argv); + + validator.initialize(); + TestlibFinalizeGuard::registered = true; + + std::string comment = "Validator must be run with the following arguments:" + " [--testset testset]" + " [--group group]" + " [--testOverviewLogFileName fileName]" + " [--testMarkupFileName fileName]" + " [--testCase testCase]" + " [--testCaseFileName fileName]" + ; + + for (int i = 1; i < argc; i++) { + if (!strcmp("--testset", argv[i])) { + if (i + 1 < argc && strlen(argv[i + 1]) > 0) + validator.setTestset(argv[++i]); + else + quit(_fail, comment); + } + if (!strcmp("--group", argv[i])) { + if (i + 1 < argc) + validator.setGroup(argv[++i]); + else + quit(_fail, comment); + } + if (!strcmp("--testOverviewLogFileName", argv[i])) { + if (i + 1 < argc) + validator.setTestOverviewLogFileName(argv[++i]); + else + quit(_fail, comment); + } + if (!strcmp("--testMarkupFileName", argv[i])) { + if (i + 1 < argc) + validator.setTestMarkupFileName(argv[++i]); + else + quit(_fail, comment); + } + if (!strcmp("--testCase", argv[i])) { + if (i + 1 < argc) { + long long testCase = stringToLongLong(inf, argv[++i]); + if (testCase < 1 || testCase >= __TESTLIB_MAX_TEST_CASE) + quit(_fail, format("Argument testCase should be between 1 and %d, but ", __TESTLIB_MAX_TEST_CASE) + + toString(testCase) + " found"); + validator.setTestCase(int(testCase)); + } else + quit(_fail, comment); + } + if (!strcmp("--testCaseFileName", argv[i])) { + if (i + 1 < argc) { + validator.setTestCaseFileName(argv[++i]); + } else + quit(_fail, comment); + } + } +} + +void addFeature(const std::string &feature) { + if (testlibMode != _validator) + quit(_fail, "Features are supported in validators only."); + validator.addFeature(feature); +} + +void feature(const std::string &feature) { + if (testlibMode != _validator) + quit(_fail, "Features are supported in validators only."); + validator.feature(feature); +} + +class Checker { +private: + bool _initialized; + std::string _testset; + std::string _group; + +public: + Checker() : _initialized(false), _testset("tests"), _group() { + } + + void initialize() { + _initialized = true; + } + + std::string testset() const { + if (!_initialized) + __testlib_fail("Checker should be initialized with registerTestlibCmd(argc, argv) instead of registerTestlibCmd() to support checker.testset()"); + return _testset; + } + + std::string group() const { + if (!_initialized) + __testlib_fail("Checker should be initialized with registerTestlibCmd(argc, argv) instead of registerTestlibCmd() to support checker.group()"); + return _group; + } + + void setTestset(const char *const testset) { + _testset = testset; + } + + void setGroup(const char *const group) { + _group = group; + } +} checker; + +void registerTestlibCmd(int argc, char *argv[]) { + __testlib_ensuresPreconditions(); + __testlib_set_testset_and_group(argc, argv); + TestlibFinalizeGuard::registered = true; + + testlibMode = _checker; + __testlib_set_binary(stdin); + + std::vector args(1, argv[0]); + checker.initialize(); + + for (int i = 1; i < argc; i++) { + if (!strcmp("--testset", argv[i])) { + if (i + 1 < argc && strlen(argv[i + 1]) > 0) + checker.setTestset(argv[++i]); + else + quit(_fail, std::string("Expected testset after --testset command line parameter")); + } else if (!strcmp("--group", argv[i])) { + if (i + 1 < argc) + checker.setGroup(argv[++i]); + else + quit(_fail, std::string("Expected group after --group command line parameter")); + } else + args.push_back(argv[i]); + } + + argc = int(args.size()); + if (argc > 1 && "--help" == args[1]) + __testlib_help(); + + if (argc < 4 || argc > 6) { + quit(_fail, std::string("Program must be run with the following arguments: ") + + std::string("[--testset testset] [--group group] [ [<-appes>]]") + + "\nUse \"--help\" to get help information"); + } + + if (argc == 4) { + resultName = ""; + appesMode = false; + } + + if (argc == 5) { + resultName = args[4]; + appesMode = false; + } + + if (argc == 6) { + if ("-APPES" != args[5] && "-appes" != args[5]) { + quit(_fail, std::string("Program must be run with the following arguments: ") + + " [ [<-appes>]]"); + } else { + resultName = args[4]; + appesMode = true; + } + } + + #ifdef BOCA_SUPPORT + inf.init(argv[3], _input); + ouf.init(argv[1], _output); + ans.init(argv[2], _answer); + #else + inf.init(argv[1], _input); + ouf.init(argv[2], _output); + ans.init(argv[3], _answer); + #endif +} + +void registerTestlib(int argc, ...) { + if (argc < 3 || argc > 5) + quit(_fail, std::string("Program must be run with the following arguments: ") + + " [ [<-appes>]]"); + + char **argv = new char *[argc + 1]; + + va_list ap; + va_start(ap, argc); + argv[0] = NULL; + for (int i = 0; i < argc; i++) { + argv[i + 1] = va_arg(ap, char*); + } + va_end(ap); + + registerTestlibCmd(argc + 1, argv); + delete[] argv; +} + +static inline void __testlib_ensure(bool cond, const std::string &msg) { + if (!cond) + quit(_fail, msg.c_str()); +} + +#ifdef __GNUC__ +__attribute__((unused)) +#endif +static inline void __testlib_ensure(bool cond, const char *msg) { + if (!cond) + quit(_fail, msg); +} + +#define ensure(cond) __testlib_ensure(cond, "Condition failed: \"" #cond "\"") +#define STRINGIZE_DETAIL(x) #x +#define STRINGIZE(x) STRINGIZE_DETAIL(x) +#define ensure_ext(cond) __testlib_ensure(cond, "Line " STRINGIZE(__LINE__) ": Condition failed: \"" #cond "\"") + +#ifdef __GNUC__ +__attribute__ ((format (printf, 2, 3))) +#endif +inline void ensuref(bool cond, const char *format, ...) { + if (!cond) { + FMT_TO_RESULT(format, format, message); + __testlib_ensure(cond, message); + } +} + +NORETURN static void __testlib_fail(const std::string &message) { + quitf(_fail, "%s", message.c_str()); +} + +#ifdef __GNUC__ +__attribute__ ((format (printf, 1, 2))) +#endif +void setName(const char *format, ...) { + FMT_TO_RESULT(format, format, name); + checkerName = name; +} + +/* + * Do not use random_shuffle, because it will produce different result + * for different C++ compilers. + * + * This implementation uses testlib random_t to produce random numbers, so + * it is stable. + */ +template +void shuffle(_RandomAccessIter __first, _RandomAccessIter __last) { + if (__first == __last) return; + for (_RandomAccessIter __i = __first + 1; __i != __last; ++__i) + std::iter_swap(__i, __first + rnd.next(int(__i - __first) + 1)); +} + + +template +#if defined(__GNUC__) && !defined(__clang__) +__attribute__ ((error("Don't use random_shuffle(), use shuffle() instead"))) +#endif +void random_shuffle(_RandomAccessIter, _RandomAccessIter) { + quitf(_fail, "Don't use random_shuffle(), use shuffle() instead"); +} + +#ifdef __GLIBC__ +# define RAND_THROW_STATEMENT throw() +#else +# define RAND_THROW_STATEMENT +#endif + +#if defined(__GNUC__) && !defined(__clang__) + +__attribute__ ((error("Don't use rand(), use rnd.next() instead"))) +#endif +#ifdef _MSC_VER +# pragma warning( disable : 4273 ) +#endif +int rand() RAND_THROW_STATEMENT +{ + quitf(_fail, "Don't use rand(), use rnd.next() instead"); + + /* This line never runs. */ + //throw "Don't use rand(), use rnd.next() instead"; +} + +#if defined(__GNUC__) && !defined(__clang__) + +__attribute__ ((error("Don't use srand(), you should use " +"'registerGen(argc, argv, 1);' to initialize generator seed " +"by hash code of the command line params. The third parameter " +"is randomGeneratorVersion (currently the latest is 1)."))) +#endif +#ifdef _MSC_VER +# pragma warning( disable : 4273 ) +#endif +void srand(unsigned int seed) RAND_THROW_STATEMENT +{ + quitf(_fail, "Don't use srand(), you should use " + "'registerGen(argc, argv, 1);' to initialize generator seed " + "by hash code of the command line params. The third parameter " + "is randomGeneratorVersion (currently the latest is 1) [ignored seed=%u].", seed); +} + +void startTest(int test) { + const std::string testFileName = vtos(test); + if (NULL == freopen(testFileName.c_str(), "wt", stdout)) + __testlib_fail("Unable to write file '" + testFileName + "'"); +} + +inline std::string upperCase(std::string s) { + for (size_t i = 0; i < s.length(); i++) + if ('a' <= s[i] && s[i] <= 'z') + s[i] = char(s[i] - 'a' + 'A'); + return s; +} + +inline std::string lowerCase(std::string s) { + for (size_t i = 0; i < s.length(); i++) + if ('A' <= s[i] && s[i] <= 'Z') + s[i] = char(s[i] - 'A' + 'a'); + return s; +} + +inline std::string compress(const std::string &s) { + return __testlib_part(s); +} + +inline std::string englishEnding(int x) { + x %= 100; + if (x / 10 == 1) + return "th"; + if (x % 10 == 1) + return "st"; + if (x % 10 == 2) + return "nd"; + if (x % 10 == 3) + return "rd"; + return "th"; +} + +template +std::string join(_ForwardIterator first, _ForwardIterator last, _Separator separator) { + std::stringstream ss; + bool repeated = false; + for (_ForwardIterator i = first; i != last; i++) { + if (repeated) + ss << separator; + else + repeated = true; + ss << *i; + } + return ss.str(); +} + +template +std::string join(_ForwardIterator first, _ForwardIterator last) { + return join(first, last, ' '); +} + +template +std::string join(const _Collection &collection, _Separator separator) { + return join(collection.begin(), collection.end(), separator); +} + +template +std::string join(const _Collection &collection) { + return join(collection, ' '); +} + +/** + * Splits string s by character separator returning exactly k+1 items, + * where k is the number of separator occurences. + */ +std::vector split(const std::string &s, char separator) { + std::vector result; + std::string item; + for (size_t i = 0; i < s.length(); i++) + if (s[i] == separator) { + result.push_back(item); + item = ""; + } else + item += s[i]; + result.push_back(item); + return result; +} + +/** + * Splits string s by character separators returning exactly k+1 items, + * where k is the number of separator occurences. + */ +std::vector split(const std::string &s, const std::string &separators) { + if (separators.empty()) + return std::vector(1, s); + + std::vector isSeparator(256); + for (size_t i = 0; i < separators.size(); i++) + isSeparator[(unsigned char) (separators[i])] = true; + + std::vector result; + std::string item; + for (size_t i = 0; i < s.length(); i++) + if (isSeparator[(unsigned char) (s[i])]) { + result.push_back(item); + item = ""; + } else + item += s[i]; + result.push_back(item); + return result; +} + +/** + * Splits string s by character separator returning non-empty items. + */ +std::vector tokenize(const std::string &s, char separator) { + std::vector result; + std::string item; + for (size_t i = 0; i < s.length(); i++) + if (s[i] == separator) { + if (!item.empty()) + result.push_back(item); + item = ""; + } else + item += s[i]; + if (!item.empty()) + result.push_back(item); + return result; +} + +/** + * Splits string s by character separators returning non-empty items. + */ +std::vector tokenize(const std::string &s, const std::string &separators) { + if (separators.empty()) + return std::vector(1, s); + + std::vector isSeparator(256); + for (size_t i = 0; i < separators.size(); i++) + isSeparator[(unsigned char) (separators[i])] = true; + + std::vector result; + std::string item; + for (size_t i = 0; i < s.length(); i++) + if (isSeparator[(unsigned char) (s[i])]) { + if (!item.empty()) + result.push_back(item); + item = ""; + } else + item += s[i]; + + if (!item.empty()) + result.push_back(item); + + return result; +} + +NORETURN void __testlib_expectedButFound(TResult result, std::string expected, std::string found, const char *prepend) { + std::string message; + if (strlen(prepend) != 0) + message = format("%s: expected '%s', but found '%s'", + compress(prepend).c_str(), compress(expected).c_str(), compress(found).c_str()); + else + message = format("expected '%s', but found '%s'", + compress(expected).c_str(), compress(found).c_str()); + quit(result, message); +} + +NORETURN void __testlib_expectedButFound(TResult result, double expected, double found, const char *prepend) { + std::string expectedString = removeDoubleTrailingZeroes(format("%.12f", expected)); + std::string foundString = removeDoubleTrailingZeroes(format("%.12f", found)); + __testlib_expectedButFound(result, expectedString, foundString, prepend); +} + +template +#ifdef __GNUC__ +__attribute__ ((format (printf, 4, 5))) +#endif +NORETURN void expectedButFound(TResult result, T expected, T found, const char *prependFormat = "", ...) { + FMT_TO_RESULT(prependFormat, prependFormat, prepend); + std::string expectedString = vtos(expected); + std::string foundString = vtos(found); + __testlib_expectedButFound(result, expectedString, foundString, prepend.c_str()); +} + +template<> +#ifdef __GNUC__ +__attribute__ ((format (printf, 4, 5))) +#endif +NORETURN void +expectedButFound(TResult result, std::string expected, std::string found, const char *prependFormat, ...) { + FMT_TO_RESULT(prependFormat, prependFormat, prepend); + __testlib_expectedButFound(result, expected, found, prepend.c_str()); +} + +template<> +#ifdef __GNUC__ +__attribute__ ((format (printf, 4, 5))) +#endif +NORETURN void expectedButFound(TResult result, double expected, double found, const char *prependFormat, ...) { + FMT_TO_RESULT(prependFormat, prependFormat, prepend); + std::string expectedString = removeDoubleTrailingZeroes(format("%.12f", expected)); + std::string foundString = removeDoubleTrailingZeroes(format("%.12f", found)); + __testlib_expectedButFound(result, expectedString, foundString, prepend.c_str()); +} + +template<> +#ifdef __GNUC__ +__attribute__ ((format (printf, 4, 5))) +#endif +NORETURN void +expectedButFound(TResult result, const char *expected, const char *found, const char *prependFormat, + ...) { + FMT_TO_RESULT(prependFormat, prependFormat, prepend); + __testlib_expectedButFound(result, std::string(expected), std::string(found), prepend.c_str()); +} + +template<> +#ifdef __GNUC__ +__attribute__ ((format (printf, 4, 5))) +#endif +NORETURN void expectedButFound(TResult result, float expected, float found, const char *prependFormat, ...) { + FMT_TO_RESULT(prependFormat, prependFormat, prepend); + __testlib_expectedButFound(result, double(expected), double(found), prepend.c_str()); +} + +template<> +#ifdef __GNUC__ +__attribute__ ((format (printf, 4, 5))) +#endif +NORETURN void +expectedButFound(TResult result, long double expected, long double found, const char *prependFormat, ...) { + FMT_TO_RESULT(prependFormat, prependFormat, prepend); + __testlib_expectedButFound(result, double(expected), double(found), prepend.c_str()); +} + +#if __cplusplus > 199711L || defined(_MSC_VER) +template +struct is_iterable { + template + static char test(typename U::iterator *x); + + template + static long test(U *x); + + static const bool value = sizeof(test(0)) == 1; +}; + +template +struct __testlib_enable_if { +}; + +template +struct __testlib_enable_if { + typedef T type; +}; + +template +typename __testlib_enable_if::value, void>::type __testlib_print_one(const T &t) { + std::cout << t; +} + +template +typename __testlib_enable_if::value, void>::type __testlib_print_one(const T &t) { + bool first = true; + for (typename T::const_iterator i = t.begin(); i != t.end(); i++) { + if (first) + first = false; + else + std::cout << " "; + std::cout << *i; + } +} + +template<> +typename __testlib_enable_if::value, void>::type +__testlib_print_one(const std::string &t) { + std::cout << t; +} + +template +void __println_range(A begin, B end) { + bool first = true; + for (B i = B(begin); i != end; i++) { + if (first) + first = false; + else + std::cout << " "; + __testlib_print_one(*i); + } + std::cout << std::endl; +} + +template +struct is_iterator { + static T makeT(); + + typedef void *twoptrs[2]; + + static twoptrs &test(...); + + template + static typename R::iterator_category *test(R); + + template + static void *test(R *); + + static const bool value = sizeof(test(makeT())) == sizeof(void *); +}; + +template +struct is_iterator::value>::type> { + static const bool value = false; +}; + +template +typename __testlib_enable_if::value, void>::type println(const A &a, const B &b) { + __testlib_print_one(a); + std::cout << " "; + __testlib_print_one(b); + std::cout << std::endl; +} + +template +typename __testlib_enable_if::value, void>::type println(const A &a, const B &b) { + __println_range(a, b); +} + +template +void println(const A *a, const A *b) { + __println_range(a, b); +} + +template<> +void println(const char *a, const char *b) { + __testlib_print_one(a); + std::cout << " "; + __testlib_print_one(b); + std::cout << std::endl; +} + +template +void println(const T &x) { + __testlib_print_one(x); + std::cout << std::endl; +} + +template +void println(const A &a, const B &b, const C &c) { + __testlib_print_one(a); + std::cout << " "; + __testlib_print_one(b); + std::cout << " "; + __testlib_print_one(c); + std::cout << std::endl; +} + +template +void println(const A &a, const B &b, const C &c, const D &d) { + __testlib_print_one(a); + std::cout << " "; + __testlib_print_one(b); + std::cout << " "; + __testlib_print_one(c); + std::cout << " "; + __testlib_print_one(d); + std::cout << std::endl; +} + +template +void println(const A &a, const B &b, const C &c, const D &d, const E &e) { + __testlib_print_one(a); + std::cout << " "; + __testlib_print_one(b); + std::cout << " "; + __testlib_print_one(c); + std::cout << " "; + __testlib_print_one(d); + std::cout << " "; + __testlib_print_one(e); + std::cout << std::endl; +} + +template +void println(const A &a, const B &b, const C &c, const D &d, const E &e, const F &f) { + __testlib_print_one(a); + std::cout << " "; + __testlib_print_one(b); + std::cout << " "; + __testlib_print_one(c); + std::cout << " "; + __testlib_print_one(d); + std::cout << " "; + __testlib_print_one(e); + std::cout << " "; + __testlib_print_one(f); + std::cout << std::endl; +} + +template +void println(const A &a, const B &b, const C &c, const D &d, const E &e, const F &f, const G &g) { + __testlib_print_one(a); + std::cout << " "; + __testlib_print_one(b); + std::cout << " "; + __testlib_print_one(c); + std::cout << " "; + __testlib_print_one(d); + std::cout << " "; + __testlib_print_one(e); + std::cout << " "; + __testlib_print_one(f); + std::cout << " "; + __testlib_print_one(g); + std::cout << std::endl; +} + +/* opts */ + +/** + * A struct for a singular testlib opt, containing the raw string value, + * and a boolean value for marking whether the opt is used. + */ +struct TestlibOpt { + std::string value; + bool used; + + TestlibOpt() : value(), used(false) {} +}; + +/** + * Get the type of opt based on the number of `-` at the beginning and the + * _validity_ of the key name. + * + * A valid key name must start with an alphabetical character. + * + * Returns: 1 if s has one `-` at the beginning, that is, "-keyName". + * 2 if s has two `-` at the beginning, that is, "--keyName". + * 0 otherwise. That is, if s has no `-` at the beginning, or has more + * than 2 at the beginning ("---keyName", "----keyName", ...), or the + * keyName is invalid (the first character is not an alphabetical + * character). + */ +size_t getOptType(char *s) { + if (!s || strlen(s) <= 1) + return 0; + + if (s[0] == '-') { + if (isalpha(s[1])) + return 1; + else if (s[1] == '-') + return isalpha(s[2]) ? 2 : 0; + } + + return 0; +} + +/** + * Parse the opt at a given index, and put it into the opts maps. + * + * An opt can has the following form: + * 1) -keyName=value or --keyName=value (ex. -n=10 --test-count=20) + * 2) -keyName value or --keyName value (ex. -n 10 --test-count 20) + * 3) -kNumval or --kNumval (ex. -n10 --t20) + * 4) -boolProperty or --boolProperty (ex. -sorted --tree-only) + * + * Only the second form consumes 2 arguments. The other consumes only 1 + * argument. + * + * In the third form, the key is a single character, and after the key is the + * value. The value _should_ be a number. + * + * In the forth form, the value is true. + * + * Params: + * - argc and argv: the number of command line arguments and the command line + * arguments themselves. + * - index: the starting index of the opts. + * - opts: the map containing the resulting opt. + * + * Returns: the number of consumed arguments to parse the opt. + * 0 if there is no arguments to parse. + * + * Algorithm details: + * TODO. Please refer to the implementation to see how the code handles the 3rd and 4th forms separately. + */ +size_t parseOpt(size_t argc, char *argv[], size_t index, std::map &opts) { + if (index >= argc) + return 0; + + size_t type = getOptType(argv[index]), inc = 1; + if (type > 0) { + std::string key(argv[index] + type), val; + size_t sep = key.find('='); + if (sep != std::string::npos) { + val = key.substr(sep + 1); + key = key.substr(0, sep); + } else { + if (index + 1 < argc && getOptType(argv[index + 1]) == 0) { + val = argv[index + 1]; + inc = 2; + } else { + if (key.length() > 1 && isdigit(key[1])) { + val = key.substr(1); + key = key.substr(0, 1); + } else { + val = "true"; + } + } + } + opts[key].value = val; + } else { + return inc; + } + + return inc; +} + +/** + * Global list containing all the arguments in the order given in the command line. + */ +std::vector __testlib_argv; + +/** + * Global dictionary containing all the parsed opts. + */ +std::map __testlib_opts; + +/** + * Whether automatic no unused opts ensurement should be done. This flag will + * be turned on when `has_opt` or `opt(key, default_value)` is called. + * + * The automatic ensurement can be suppressed when + * __testlib_ensureNoUnusedOptsSuppressed is true. + */ +bool __testlib_ensureNoUnusedOptsFlag = false; + +/** + * Suppress no unused opts automatic ensurement. Can be set to true with + * `suppressEnsureNoUnusedOpts()`. + */ +bool __testlib_ensureNoUnusedOptsSuppressed = false; + +/** + * Parse command line arguments into opts. + * The results are stored into __testlib_argv and __testlib_opts. + */ +void prepareOpts(int argc, char *argv[]) { + if (argc <= 0) + __testlib_fail("Opts: expected argc>=0 but found " + toString(argc)); + size_t n = static_cast(argc); // NOLINT(hicpp-use-auto,modernize-use-auto) + __testlib_opts = std::map(); + for (size_t index = 1; index < n; index += parseOpt(n, argv, index, __testlib_opts)); + __testlib_argv = std::vector(n); + for (size_t index = 0; index < n; index++) + __testlib_argv[index] = argv[index]; +} + +/** + * An utility function to get the argument with a given index. This function + * also print a readable message when no arguments are found. + */ +std::string __testlib_indexToArgv(int index) { + if (index < 0 || index >= int(__testlib_argv.size())) + __testlib_fail("Opts: index '" + toString(index) + "' is out of range [0," + + toString(__testlib_argv.size()) + ")"); + return __testlib_argv[size_t(index)]; +} + +/** + * An utility function to get the opt with a given key . This function + * also print a readable message when no opts are found. + */ +std::string __testlib_keyToOpts(const std::string &key) { + auto it = __testlib_opts.find(key); + if (it == __testlib_opts.end()) + __testlib_fail("Opts: unknown key '" + compress(key) + "'"); + it->second.used = true; + return it->second.value; +} + +template +T optValueToIntegral(const std::string &s, bool nonnegative); + +long double optValueToLongDouble(const std::string &s); + +std::string parseExponentialOptValue(const std::string &s) { + size_t pos = std::string::npos; + for (size_t i = 0; i < s.length(); i++) + if (s[i] == 'e' || s[i] == 'E') { + if (pos != std::string::npos) + __testlib_fail("Opts: expected typical exponential notation but '" + compress(s) + "' found"); + pos = i; + } + if (pos == std::string::npos) + return s; + std::string e = s.substr(pos + 1); + if (!e.empty() && e[0] == '+') + e = e.substr(1); + if (e.empty()) + __testlib_fail("Opts: expected typical exponential notation but '" + compress(s) + "' found"); + if (e.length() > 20) + __testlib_fail("Opts: expected typical exponential notation but '" + compress(s) + "' found"); + int ne = optValueToIntegral(e, false); + std::string num = s.substr(0, pos); + if (num.length() > 20) + __testlib_fail("Opts: expected typical exponential notation but '" + compress(s) + "' found"); + if (!num.empty() && num[0] == '+') + num = num.substr(1); + optValueToLongDouble(num); + bool minus = false; + if (num[0] == '-') { + minus = true; + num = num.substr(1); + } + for (int i = 0; i < +ne; i++) { + size_t sep = num.find('.'); + if (sep == std::string::npos) + num += '0'; + else { + if (sep + 1 == num.length()) + num[sep] = '0'; + else + std::swap(num[sep], num[sep + 1]); + } + } + for (int i = 0; i < -ne; i++) { + size_t sep = num.find('.'); + if (sep == std::string::npos) + num.insert(num.begin() + int(num.length()) - 1, '.'); + else { + if (sep == 0) + num.insert(num.begin() + 1, '0'); + else + std::swap(num[sep - 1], num[sep]); + } + } + while (!num.empty() && num[0] == '0') + num = num.substr(1); + while (num.find('.') != std::string::npos && num.back() == '0') + num = num.substr(0, num.length() - 1); + if (!num.empty() && num.back() == '.') + num = num.substr(0, num.length() - 1); + if ((!num.empty() && num[0] == '.') || num.empty()) + num.insert(num.begin(), '0'); + return (minus ? "-" : "") + num; +} + +template +T optValueToIntegral(const std::string &s_, bool nonnegative) { + std::string s(parseExponentialOptValue(s_)); + if (s.empty()) + __testlib_fail("Opts: expected integer but '" + compress(s_) + "' found"); + T value = 0; + long double about = 0.0; + signed char sign = +1; + size_t pos = 0; + if (s[pos] == '-') { + if (nonnegative) + __testlib_fail("Opts: expected non-negative integer but '" + compress(s_) + "' found"); + sign = -1; + pos++; + } + for (size_t i = pos; i < s.length(); i++) { + if (s[i] < '0' || s[i] > '9') + __testlib_fail("Opts: expected integer but '" + compress(s_) + "' found"); + value = value * 10 + s[i] - '0'; + about = about * 10 + s[i] - '0'; + } + value *= sign; + about *= sign; + if (fabsl(value - about) > 0.1) + __testlib_fail("Opts: integer overflow: expected integer but '" + compress(s_) + "' found"); + return value; +} + +long double optValueToLongDouble(const std::string &s_) { + std::string s(parseExponentialOptValue(s_)); + if (s.empty()) + __testlib_fail("Opts: expected float number but '" + compress(s_) + "' found"); + long double value = 0.0; + signed char sign = +1; + size_t pos = 0; + if (s[pos] == '-') { + sign = -1; + pos++; + } + bool period = false; + long double mul = 1.0; + for (size_t i = pos; i < s.length(); i++) { + if (s[i] == '.') { + if (period) + __testlib_fail("Opts: expected float number but '" + compress(s_) + "' found"); + else { + period = true; + continue; + } + } + if (period) + mul *= 10.0; + if (s[i] < '0' || s[i] > '9') + __testlib_fail("Opts: expected float number but '" + compress(s_) + "' found"); + if (period) + value += (s[i] - '0') / mul; + else + value = value * 10 + s[i] - '0'; + } + value *= sign; + return value; +} + +/** + * Return true if there is an opt with a given key. + * + * By calling this function, automatic ensurement for no unused opts will be + * done when the program is finalized. Call suppressEnsureNoUnusedOpts() to + * turn it off. + */ +bool has_opt(const std::string &key) { + __testlib_ensureNoUnusedOptsFlag = true; + return __testlib_opts.count(key) != 0; +} + +/* About the followings part for opt with 2 and 3 arguments. + * + * To parse the argv/opts correctly for a give type (integer, floating point or + * string), some meta programming must be done to determine the type of + * the type, and use the correct parsing function accordingly. + * + * The pseudo algorithm for determining the type of T and parse it accordingly + * is as follows: + * + * if (T is integral type) { + * if (T is unsigned) { + * parse the argv/opt as an **unsigned integer** of type T. + * } else { + * parse the argv/opt as an **signed integer** of type T. + * } else { + * if (T is floating point type) { + * parse the argv/opt as an **floating point** of type T. + * } else { + * // T should be std::string + * just the raw content of the argv/opts. + * } + * } + * + * To help with meta programming, some `opt` function with 2 or 3 arguments are + * defined. + * + * Opt with 3 arguments: T opt(true/false is_integral, true/false is_unsigned, index/key) + * + * + The first argument is for determining whether the type T is an integral + * type. That is, the result of std::is_integral() should be passed to + * this argument. When false, the type _should_ be either floating point or a + * std::string. + * + * + The second argument is for determining whether the signedness of the type + * T (if it is unsigned or signed). That is, the result of + * std::is_unsigned() should be passed to this argument. This argument can + * be ignored if the first one is false, because it only applies to integer. + * + * Opt with 2 arguments: T opt(true/false is_floating_point, index/key) + * + The first argument is for determining whether the type T is a floating + * point type. That is, the result of std::is_floating_point() should be + * passed to this argument. When false, the type _should_ be a std::string. + */ + +template +T opt(std::false_type is_floating_point, int index); + +template<> +std::string opt(std::false_type /*is_floating_point*/, int index) { + return __testlib_indexToArgv(index); +} + +template +T opt(std::true_type /*is_floating_point*/, int index) { + return T(optValueToLongDouble(__testlib_indexToArgv(index))); +} + +template +T opt(std::false_type /*is_integral*/, U /*is_unsigned*/, int index) { + return opt(std::is_floating_point(), index); +} + +template +T opt(std::true_type /*is_integral*/, std::false_type /*is_unsigned*/, int index) { + return optValueToIntegral(__testlib_indexToArgv(index), false); +} + +template +T opt(std::true_type /*is_integral*/, std::true_type /*is_unsigned*/, int index) { + return optValueToIntegral(__testlib_indexToArgv(index), true); +} + +template<> +bool opt(std::true_type /*is_integral*/, std::true_type /*is_unsigned*/, int index) { + std::string value = __testlib_indexToArgv(index); + if (value == "true" || value == "1") + return true; + if (value == "false" || value == "0") + return false; + __testlib_fail("Opts: opt by index '" + toString(index) + "': expected bool true/false or 0/1 but '" + + compress(value) + "' found"); +} + +/** + * Return the parsed argv by a given index. + */ +template +T opt(int index) { + return opt(std::is_integral(), std::is_unsigned(), index); +} + +/** + * Return the raw string value of an argv by a given index. + */ +std::string opt(int index) { + return opt(index); +} + +/** + * Return the parsed argv by a given index. If the index is bigger than + * the number of argv, return the given default_value. + */ +template +T opt(int index, const T &default_value) { + if (index >= int(__testlib_argv.size())) { + return default_value; + } + return opt(index); +} + +/** + * Return the raw string value of an argv by a given index. If the index is + * bigger than the number of argv, return the given default_value. + */ +std::string opt(int index, const std::string &default_value) { + return opt(index, default_value); +} + +template +T opt(std::false_type is_floating_point, const std::string &key); + +template<> +std::string opt(std::false_type /*is_floating_point*/, const std::string &key) { + return __testlib_keyToOpts(key); +} + +template +T opt(std::true_type /*is_integral*/, const std::string &key) { + return T(optValueToLongDouble(__testlib_keyToOpts(key))); +} + +template +T opt(std::false_type /*is_integral*/, U, const std::string &key) { + return opt(std::is_floating_point(), key); +} + +template +T opt(std::true_type /*is_integral*/, std::false_type /*is_unsigned*/, const std::string &key) { + return optValueToIntegral(__testlib_keyToOpts(key), false); +} + +template +T opt(std::true_type /*is_integral*/, std::true_type /*is_unsigned*/, const std::string &key) { + return optValueToIntegral(__testlib_keyToOpts(key), true); +} + +template<> +bool opt(std::true_type /*is_integral*/, std::true_type /*is_unsigned*/, const std::string &key) { + if (!has_opt(key)) + return false; + std::string value = __testlib_keyToOpts(key); + if (value == "true" || value == "1") + return true; + if (value == "false" || value == "0") + return false; + __testlib_fail("Opts: key '" + compress(key) + "': expected bool true/false or 0/1 but '" + + compress(value) + "' found"); +} + +/** + * Return the parsed opt by a given key. + */ +template +T opt(const std::string &key) { + return opt(std::is_integral(), std::is_unsigned(), key); +} + +/** + * Return the raw string value of an opt by a given key + */ +std::string opt(const std::string &key) { + return opt(key); +} + +/* Scorer started. */ + +enum TestResultVerdict { + SKIPPED, + OK, + WRONG_ANSWER, + RUNTIME_ERROR, + TIME_LIMIT_EXCEEDED, + IDLENESS_LIMIT_EXCEEDED, + MEMORY_LIMIT_EXCEEDED, + COMPILATION_ERROR, + CRASHED, + FAILED +}; + +std::string serializeVerdict(TestResultVerdict verdict) { + switch (verdict) { + case SKIPPED: return "SKIPPED"; + case OK: return "OK"; + case WRONG_ANSWER: return "WRONG_ANSWER"; + case RUNTIME_ERROR: return "RUNTIME_ERROR"; + case TIME_LIMIT_EXCEEDED: return "TIME_LIMIT_EXCEEDED"; + case IDLENESS_LIMIT_EXCEEDED: return "IDLENESS_LIMIT_EXCEEDED"; + case MEMORY_LIMIT_EXCEEDED: return "MEMORY_LIMIT_EXCEEDED"; + case COMPILATION_ERROR: return "COMPILATION_ERROR"; + case CRASHED: return "CRASHED"; + case FAILED: return "FAILED"; + } + throw "Unexpected verdict"; +} + +TestResultVerdict deserializeTestResultVerdict(std::string s) { + if (s == "SKIPPED") + return SKIPPED; + else if (s == "OK") + return OK; + else if (s == "WRONG_ANSWER") + return WRONG_ANSWER; + else if (s == "RUNTIME_ERROR") + return RUNTIME_ERROR; + else if (s == "TIME_LIMIT_EXCEEDED") + return TIME_LIMIT_EXCEEDED; + else if (s == "IDLENESS_LIMIT_EXCEEDED") + return IDLENESS_LIMIT_EXCEEDED; + else if (s == "MEMORY_LIMIT_EXCEEDED") + return MEMORY_LIMIT_EXCEEDED; + else if (s == "COMPILATION_ERROR") + return COMPILATION_ERROR; + else if (s == "CRASHED") + return CRASHED; + else if (s == "FAILED") + return FAILED; + ensuref(false, "Unexpected serialized TestResultVerdict"); + // No return actually. + return FAILED; +} + +struct TestResult { + int testIndex; + std::string testset; + std::string group; + TestResultVerdict verdict; + double points; + long long timeConsumed; + long long memoryConsumed; + std::string input; + std::string output; + std::string answer; + int exitCode; + std::string checkerComment; +}; + +std::string serializePoints(double points) { + if (std::isnan(points)) + return ""; + else { + char c[64]; + sprintf(c, "%.03lf", points); + return c; + } +} + +double deserializePoints(std::string s) { + if (s.empty()) + return std::numeric_limits::quiet_NaN(); + else { + double result; + ensuref(sscanf(s.c_str(), "%lf", &result) == 1, "Invalid serialized points"); + return result; + } +} + +std::string escapeTestResultString(std::string s) { + std::string result; + for (size_t i = 0; i < s.length(); i++) { + if (s[i] == '\r') + continue; + if (s[i] == '\n') { + result += "\\n"; + continue; + } + if (s[i] == '\\' || s[i] == ';') + result += '\\'; + result += s[i]; + } + return result; +} + +std::string unescapeTestResultString(std::string s) { + std::string result; + for (size_t i = 0; i < s.length(); i++) { + if (s[i] == '\\' && i + 1 < s.length()) { + if (s[i + 1] == 'n') { + result += '\n'; + i++; + continue; + } else if (s[i + 1] == ';' || s[i + 1] == '\\') { + result += s[i + 1]; + i++; + continue; + } + } + result += s[i]; + } + return result; +} + +std::string serializeTestResult(TestResult tr) { + std::string result; + result += std::to_string(tr.testIndex); + result += ";"; + result += escapeTestResultString(tr.testset); + result += ";"; + result += escapeTestResultString(tr.group); + result += ";"; + result += serializeVerdict(tr.verdict); + result += ";"; + result += serializePoints(tr.points); + result += ";"; + result += std::to_string(tr.timeConsumed); + result += ";"; + result += std::to_string(tr.memoryConsumed); + result += ";"; + result += escapeTestResultString(tr.input); + result += ";"; + result += escapeTestResultString(tr.output); + result += ";"; + result += escapeTestResultString(tr.answer); + result += ";"; + result += std::to_string(tr.exitCode); + result += ";"; + result += escapeTestResultString(tr.checkerComment); + return result; +} + +TestResult deserializeTestResult(std::string s) { + std::vector items; + std::string t; + for (size_t i = 0; i < s.length(); i++) { + if (s[i] == '\\') { + t += s[i]; + if (i + 1 < s.length()) + t += s[i + 1]; + i++; + continue; + } else { + if (s[i] == ';') { + items.push_back(t); + t = ""; + } else + t += s[i]; + } + } + items.push_back(t); + + ensuref(items.size() == 12, "Invalid TestResult serialization: expected exactly 12 items"); + + TestResult tr; + size_t pos = 0; + tr.testIndex = stoi(items[pos++]); + tr.testset = unescapeTestResultString(items[pos++]); + tr.group = unescapeTestResultString(items[pos++]); + tr.verdict = deserializeTestResultVerdict(items[pos++]); + tr.points = deserializePoints(items[pos++]); + tr.timeConsumed = stoll(items[pos++]); + tr.memoryConsumed = stoll(items[pos++]); + tr.input = unescapeTestResultString(items[pos++]); + tr.output = unescapeTestResultString(items[pos++]); + tr.answer = unescapeTestResultString(items[pos++]); + tr.exitCode = stoi(items[pos++]); + tr.checkerComment = unescapeTestResultString(items[pos++]); + + return tr; +} + +std::vector readTestResults(std::string fileName) { + std::ifstream stream; + stream.open(fileName.c_str(), std::ios::in); + ensuref(stream.is_open(), "Can't read test results file '%s'", fileName.c_str()); + std::vector result; + std::string line; + while (getline(stream, line)) + if (!line.empty()) + result.push_back(deserializeTestResult(line)); + stream.close(); + return result; +} + +std::function)> __testlib_scorer; + +struct TestlibScorerGuard { + ~TestlibScorerGuard() { + if (testlibMode == _scorer) { + std::vector testResults; + while (!inf.eof()) { + std::string line = inf.readLine(); + if (!line.empty()) + testResults.push_back(deserializeTestResult(line)); + } + inf.readEof(); + printf("%.3f\n", __testlib_scorer(testResults)); + } + } +} __testlib_scorer_guard; + +void registerScorer(int argc, char *argv[], std::function)> scorer) { + /* Supress unused. */ + (void)(argc), (void)(argv); + + __testlib_ensuresPreconditions(); + + testlibMode = _scorer; + __testlib_set_binary(stdin); + + inf.init(stdin, _input); + inf.strict = false; + + __testlib_scorer = scorer; +} + +/* Scorer ended. */ + +/** + * Return the parsed opt by a given key. If no opts with the given key are + * found, return the given default_value. + * + * By calling this function, automatic ensurement for no unused opts will be + * done when the program is finalized. Call suppressEnsureNoUnusedOpts() to + * turn it off. + */ +template +T opt(const std::string &key, const T &default_value) { + if (!has_opt(key)) { + return default_value; + } + return opt(key); +} + +/** + * Return the raw string value of an opt by a given key. If no opts with the + * given key are found, return the given default_value. + * + * By calling this function, automatic ensurement for no unused opts will be + * done when the program is finalized. Call suppressEnsureNoUnusedOpts() to + * turn it off. + */ +std::string opt(const std::string &key, const std::string &default_value) { + return opt(key, default_value); +} + +/** + * Check if all opts are used. If not, __testlib_fail is called. + * Should be used after calling all opt() function calls. + * + * This function is useful when opt() with default_value for checking typos + * in the opt's key. + */ +void ensureNoUnusedOpts() { + for (const auto &opt: __testlib_opts) { + if (!opt.second.used) { + __testlib_fail(format("Opts: unused key '%s'", compress(opt.first).c_str())); + } + } +} + +void suppressEnsureNoUnusedOpts() { + __testlib_ensureNoUnusedOptsSuppressed = true; +} + +void TestlibFinalizeGuard::autoEnsureNoUnusedOpts() { + if (__testlib_ensureNoUnusedOptsFlag && !__testlib_ensureNoUnusedOptsSuppressed) { + ensureNoUnusedOpts(); + } +} + +TestlibFinalizeGuard testlibFinalizeGuard; + +#endif +#endif diff --git a/subset-sum/src/validator.cpp b/subset-sum/src/validator.cpp new file mode 100644 index 0000000..d6ec622 --- /dev/null +++ b/subset-sum/src/validator.cpp @@ -0,0 +1,22 @@ +#include "testlib.h" +#include + +using namespace std; + + +int main(int argc, char* argv[]) { + registerValidation(argc, argv); + + int n = inf.readInt(1, 1000, "N"); + inf.readSpace(); + inf.readInt(1, 10000, "T"); + inf.readEoln(); + for (int i = 0; i < n; i++) { + if (i != 0) inf.readSpace(); + inf.readInt(1, 100, "ni"); + } + inf.readEoln(); + inf.readEof(); + + return 0; +} \ No newline at end of file diff --git a/subset-sum/statement/description.tex b/subset-sum/statement/description.tex new file mode 100644 index 0000000..504ba3c --- /dev/null +++ b/subset-sum/statement/description.tex @@ -0,0 +1,7 @@ +Você foi recentemente contratado como arquivista júnior na Biblioteca Central, lar de manuscritos inestimáveis. Sua primeira grande tarefa é organizar a famosa \textbf{Prateleira Dourada}, um espaço de exposição reservado apenas para as obras mais raras. + +Esta prateleira possui um comprimento físico exato de $T$ centímetros. O bibliotecário-chefe, Sr. Justino, é famoso por sua exigência extrema com a estética e a preservação: ele abomina espaços vazios onde a poeira possa se acumular, mas também proíbe terminantemente que os livros sejam espremidos, o que danificaria suas capas de couro. + +Para o Sr. Justino, a organização só é aceitável se a prateleira for preenchida \textbf{de ponta a ponta}, sem que sobre ou falte qualquer espaço. + +Você recebeu uma pilha contendo $n$ livros raros. Cada livro possui uma espessura específica. Sua missão é verificar se existe uma seleção de livros cuja soma das espessuras seja \textbf{exatamente} igual ao comprimento $T$ da prateleira. diff --git a/subset-sum/statement/input.tex b/subset-sum/statement/input.tex new file mode 100644 index 0000000..6ac53c8 --- /dev/null +++ b/subset-sum/statement/input.tex @@ -0,0 +1,2 @@ +A primeira linha possui dois inteiros: $n$ ($1 \le n \le 1\,000$), representando a quantidade de livros, e $T$ ($1 \le T \le 10\,000$), o comprimento total da prateleira, em centímetros. +A segunda linha contém $n$ inteiros positivos $a_1, a_2, \dots, a_n$, as larguras dos livros em centímetros, com $1 \le a_i \le 100$. \ No newline at end of file diff --git a/subset-sum/statement/notes.tex b/subset-sum/statement/notes.tex new file mode 100644 index 0000000..ea880c2 --- /dev/null +++ b/subset-sum/statement/notes.tex @@ -0,0 +1,5 @@ +No primeiro caso de teste é possível escolher os livros de comprimentos 2, 3 e 5. + +No segundo caso de teste nenhuma combinação de livros resultará no comprimento da prateleira. + +No Terceiro caso de teste é possível escolher os livros de comprimentos 9, 4, e 1. Outra opção seriam os livros de comprimentos 1, 2, 3, 4, 4. \ No newline at end of file diff --git a/subset-sum/statement/output.tex b/subset-sum/statement/output.tex new file mode 100644 index 0000000..237fb1f --- /dev/null +++ b/subset-sum/statement/output.tex @@ -0,0 +1 @@ +Imprima exatamente uma linha: \texttt{PERFEITO!} caso exista um subconjunto de livros cuja soma das larguras seja exatamente $T$, ou \texttt{IMPOSSIVEL!} caso contrário. \ No newline at end of file diff --git a/subset-sum/statement/preamble.tex b/subset-sum/statement/preamble.tex new file mode 100644 index 0000000..e69de29 diff --git a/subset-sum/statement/tutorial.tex b/subset-sum/statement/tutorial.tex new file mode 100644 index 0000000..e69de29 diff --git a/subset-sum/subset-sum.pdf b/subset-sum/subset-sum.pdf new file mode 100644 index 0000000..fbcaa8a Binary files /dev/null and b/subset-sum/subset-sum.pdf differ diff --git a/subset-sum/subset-sum.tex b/subset-sum/subset-sum.tex new file mode 100644 index 0000000..ed7a7b5 --- /dev/null +++ b/subset-sum/subset-sum.tex @@ -0,0 +1,42 @@ +\documentclass{maratona} + +\begin{document} +\begin{ProblemaAutor}{}{}{1}{256}{} + +Você foi recentemente contratado como arquivista júnior na Biblioteca Central, lar de manuscritos inestimáveis. Sua primeira grande tarefa é organizar a famosa \textbf{Prateleira Dourada}, um espaço de exposição reservado apenas para as obras mais raras. + +Esta prateleira possui um comprimento físico exato de $T$ centímetros. O bibliotecário-chefe, Sr. Justino, é famoso por sua exigência extrema com a estética e a preservação: ele abomina espaços vazios onde a poeira possa se acumular, mas também proíbe terminantemente que os livros sejam espremidos, o que danificaria suas capas de couro. + +Para o Sr. Justino, a organização só é aceitável se a prateleira for preenchida \textbf{de ponta a ponta}, sem que sobre ou falte qualquer espaço. + +Você recebeu uma pilha contendo $n$ livros raros. Cada livro possui uma espessura específica. Sua missão é verificar se existe uma seleção de livros cuja soma das espessuras seja \textbf{exatamente} igual ao comprimento $T$ da prateleira. + +\Entrada + +A primeira linha possui dois inteiros: $n$ ($1 \le n \le 1\,000$), representando a quantidade de livros, e $T$ ($1 \le T \le 10\,000$), o comprimento total da prateleira, em centímetros. +A segunda linha contém $n$ inteiros positivos $a_1, a_2, \dots, a_n$, as larguras dos livros em centímetros, com $1 \le a_i \le 100$. + +\Saida + +Imprima exatamente uma linha: \texttt{PERFEITO!} caso exista um subconjunto de livros cuja soma das larguras seja exatamente $T$, ou \texttt{IMPOSSIVEL!} caso contrário. + +\ExemploEntrada +\begin{Exemplo} +\texttt{5~10} & \texttt{PERFEITO!}\\ +\texttt{1~2~3~4~5} & \\ +\rowcolor{gray!20}\texttt{4~4} & \texttt{IMPOSSIVEL!}\\ +\rowcolor{gray!20}\texttt{5~1~2~5} & \\ +\texttt{8~14} & \texttt{PERFEITO!}\\ +\texttt{1~2~3~4~4~9~9~15} & \\ +\end{Exemplo} + + + +\Notas + +No primeiro caso de teste é possível escolher os livros de comprimentos 2, 3 e 5. + +No segundo caso de teste nenhuma combinação de livros resultará no comprimento da prateleira. + +No Terceiro caso de teste é possível escolher os livros de comprimentos 9, 4, e 1. Outra opção seriam os livros de comprimentos 1, 2, 3, 4, 4.\end{ProblemaAutor} +\end{document}