summaryrefslogtreecommitdiffstats
path: root/01-algorithmic_toolbox/04-dynamic_programming/05-lcs3
diff options
context:
space:
mode:
Diffstat (limited to '01-algorithmic_toolbox/04-dynamic_programming/05-lcs3')
-rw-r--r--01-algorithmic_toolbox/04-dynamic_programming/05-lcs3/lcs3.cpp31
-rw-r--r--01-algorithmic_toolbox/04-dynamic_programming/05-lcs3/tests/016
-rw-r--r--01-algorithmic_toolbox/04-dynamic_programming/05-lcs3/tests/01.a1
-rw-r--r--01-algorithmic_toolbox/04-dynamic_programming/05-lcs3/tests/026
-rw-r--r--01-algorithmic_toolbox/04-dynamic_programming/05-lcs3/tests/02.a1
5 files changed, 45 insertions, 0 deletions
diff --git a/01-algorithmic_toolbox/04-dynamic_programming/05-lcs3/lcs3.cpp b/01-algorithmic_toolbox/04-dynamic_programming/05-lcs3/lcs3.cpp
new file mode 100644
index 0000000..2ca0339
--- /dev/null
+++ b/01-algorithmic_toolbox/04-dynamic_programming/05-lcs3/lcs3.cpp
@@ -0,0 +1,31 @@
+#include <iostream>
+#include <vector>
+
+using std::vector;
+
+int lcs3(vector<int> &a, vector<int> &b, vector<int> &c) {
+ //write your code here
+ return std::min(std::min(a.size(), b.size()), c.size());
+}
+
+int main() {
+ size_t an;
+ std::cin >> an;
+ vector<int> a(an);
+ for (size_t i = 0; i < an; i++) {
+ std::cin >> a[i];
+ }
+ size_t bn;
+ std::cin >> bn;
+ vector<int> b(bn);
+ for (size_t i = 0; i < bn; i++) {
+ std::cin >> b[i];
+ }
+ size_t cn;
+ std::cin >> cn;
+ vector<int> c(cn);
+ for (size_t i = 0; i < cn; i++) {
+ std::cin >> c[i];
+ }
+ std::cout << lcs3(a, b, c) << std::endl;
+}
diff --git a/01-algorithmic_toolbox/04-dynamic_programming/05-lcs3/tests/01 b/01-algorithmic_toolbox/04-dynamic_programming/05-lcs3/tests/01
new file mode 100644
index 0000000..354d6f0
--- /dev/null
+++ b/01-algorithmic_toolbox/04-dynamic_programming/05-lcs3/tests/01
@@ -0,0 +1,6 @@
+3
+1 2 3
+3
+2 1 3
+3
+1 3 5
diff --git a/01-algorithmic_toolbox/04-dynamic_programming/05-lcs3/tests/01.a b/01-algorithmic_toolbox/04-dynamic_programming/05-lcs3/tests/01.a
new file mode 100644
index 0000000..0cfbf08
--- /dev/null
+++ b/01-algorithmic_toolbox/04-dynamic_programming/05-lcs3/tests/01.a
@@ -0,0 +1 @@
+2
diff --git a/01-algorithmic_toolbox/04-dynamic_programming/05-lcs3/tests/02 b/01-algorithmic_toolbox/04-dynamic_programming/05-lcs3/tests/02
new file mode 100644
index 0000000..3969ebb
--- /dev/null
+++ b/01-algorithmic_toolbox/04-dynamic_programming/05-lcs3/tests/02
@@ -0,0 +1,6 @@
+5
+8 3 2 1 7
+7
+8 2 1 3 8 10 7
+6
+6 8 3 1 4 7
diff --git a/01-algorithmic_toolbox/04-dynamic_programming/05-lcs3/tests/02.a b/01-algorithmic_toolbox/04-dynamic_programming/05-lcs3/tests/02.a
new file mode 100644
index 0000000..00750ed
--- /dev/null
+++ b/01-algorithmic_toolbox/04-dynamic_programming/05-lcs3/tests/02.a
@@ -0,0 +1 @@
+3