From adb97626f5553013e2758aeb136c8ffd28436627 Mon Sep 17 00:00:00 2001 From: omagdy7 Date: Mon, 18 Jul 2022 22:11:40 +0200 Subject: Solved a couple of problems --- AlmostTernaryMatrix/main | Bin 0 -> 22624 bytes AlmostTernaryMatrix/main.cpp | 20 ++++ AlmostTernaryMatrix/main_input0.txt | 4 + AlmostTernaryMatrix/main_input1.txt | 2 + AlmostTernaryMatrix/main_output0.txt | 8 ++ DifferenceOperations/main | Bin 0 -> 27368 bytes DifferenceOperations/main.cpp | 23 +++++ DifferenceOperations/main_input0.txt | 9 ++ DifferenceOperations/main_input1.txt | 3 + DifferenceOperations/main_input2.txt | 105 +++++++++++++++++++ DifferenceOperations/main_input3.txt | 153 +++++++++++++++++++++++++++ DifferenceOperations/main_output0.txt | 4 + DifferenceOperations/main_output1.txt | 1 + DifferenceOperations/main_output2.txt | 52 ++++++++++ DifferenceOperations/randomInput.txt | 154 ++++++++++++++++++++++++++++ FunkyNumbers/main | Bin 0 -> 40528 bytes FunkyNumbers/main.cpp | 24 +++++ FunkyNumbers/main_input0.txt | 1 + FunkyNumbers/main_input1.txt | 1 + FunkyNumbers/main_input2.txt | 1 + FunkyNumbers/main_output0.txt | 1 + FunkyNumbers/main_output1.txt | 1 + FunkyNumbers/main_output2.txt | 1 + TheThirdThreeNumberProblem/main | Bin 0 -> 22680 bytes TheThirdThreeNumberProblem/main.cpp | 20 ++++ TheThirdThreeNumberProblem/main_input0.txt | 6 ++ TheThirdThreeNumberProblem/main_output0.txt | 5 + codechef/sticks/main | Bin 0 -> 85968 bytes codechef/sticks/main.cpp | 42 ++++++++ codechef/sticks/main_input0.txt | 5 + codechef/sticks/main_input1.txt | 7 ++ codechef/sticks/main_output0.txt | 2 + codechef/sticks/main_output1.txt | 3 + contests/Round#809/A/B/C/D/E/F/main.cpp | 13 +++ contests/Round#809/A/B/C/D/E/main.cpp | 13 +++ contests/Round#809/A/B/C/D/main.cpp | 13 +++ contests/Round#809/A/B/C/main.cpp | 13 +++ contests/Round#809/A/B/main | Bin 0 -> 31808 bytes contests/Round#809/A/B/main.cpp | 58 +++++++++++ contests/Round#809/A/B/main_input0.txt | 13 +++ contests/Round#809/A/B/main_input1.txt | 3 + contests/Round#809/A/B/main_input2.txt | 3 + contests/Round#809/A/B/main_input3.txt | 3 + contests/Round#809/A/B/main_output0.txt | 6 ++ contests/Round#809/A/B/main_output1.txt | 1 + contests/Round#809/A/B/main_output2.txt | 1 + contests/Round#809/A/B/main_output3.txt | 1 + contests/Round#809/A/main | Bin 0 -> 42488 bytes contests/Round#809/A/main.cpp | 35 +++++++ contests/Round#809/A/main_input0.txt | 13 +++ contests/Round#809/A/main_output0.txt | 6 ++ strangeAddition/main | Bin 0 -> 46808 bytes strangeAddition/main.cpp | 51 +++++++++ strangeAddition/main_input0.txt | 2 + strangeAddition/main_input1.txt | 2 + strangeAddition/main_output0.txt | 2 + strangeAddition/main_output1.txt | 2 + testGenerator.py | 13 +++ 58 files changed, 925 insertions(+) create mode 100755 AlmostTernaryMatrix/main create mode 100644 AlmostTernaryMatrix/main.cpp create mode 100644 AlmostTernaryMatrix/main_input0.txt create mode 100644 AlmostTernaryMatrix/main_input1.txt create mode 100644 AlmostTernaryMatrix/main_output0.txt create mode 100755 DifferenceOperations/main create mode 100644 DifferenceOperations/main.cpp create mode 100644 DifferenceOperations/main_input0.txt create mode 100644 DifferenceOperations/main_input1.txt create mode 100644 DifferenceOperations/main_input2.txt create mode 100644 DifferenceOperations/main_input3.txt create mode 100644 DifferenceOperations/main_output0.txt create mode 100644 DifferenceOperations/main_output1.txt create mode 100644 DifferenceOperations/main_output2.txt create mode 100644 DifferenceOperations/randomInput.txt create mode 100755 FunkyNumbers/main create mode 100644 FunkyNumbers/main.cpp create mode 100644 FunkyNumbers/main_input0.txt create mode 100644 FunkyNumbers/main_input1.txt create mode 100644 FunkyNumbers/main_input2.txt create mode 100644 FunkyNumbers/main_output0.txt create mode 100644 FunkyNumbers/main_output1.txt create mode 100644 FunkyNumbers/main_output2.txt create mode 100755 TheThirdThreeNumberProblem/main create mode 100644 TheThirdThreeNumberProblem/main.cpp create mode 100644 TheThirdThreeNumberProblem/main_input0.txt create mode 100644 TheThirdThreeNumberProblem/main_output0.txt create mode 100755 codechef/sticks/main create mode 100644 codechef/sticks/main.cpp create mode 100644 codechef/sticks/main_input0.txt create mode 100644 codechef/sticks/main_input1.txt create mode 100644 codechef/sticks/main_output0.txt create mode 100644 codechef/sticks/main_output1.txt create mode 100644 contests/Round#809/A/B/C/D/E/F/main.cpp create mode 100644 contests/Round#809/A/B/C/D/E/main.cpp create mode 100644 contests/Round#809/A/B/C/D/main.cpp create mode 100644 contests/Round#809/A/B/C/main.cpp create mode 100755 contests/Round#809/A/B/main create mode 100644 contests/Round#809/A/B/main.cpp create mode 100644 contests/Round#809/A/B/main_input0.txt create mode 100644 contests/Round#809/A/B/main_input1.txt create mode 100644 contests/Round#809/A/B/main_input2.txt create mode 100644 contests/Round#809/A/B/main_input3.txt create mode 100644 contests/Round#809/A/B/main_output0.txt create mode 100644 contests/Round#809/A/B/main_output1.txt create mode 100644 contests/Round#809/A/B/main_output2.txt create mode 100644 contests/Round#809/A/B/main_output3.txt create mode 100755 contests/Round#809/A/main create mode 100644 contests/Round#809/A/main.cpp create mode 100644 contests/Round#809/A/main_input0.txt create mode 100644 contests/Round#809/A/main_output0.txt create mode 100755 strangeAddition/main create mode 100644 strangeAddition/main.cpp create mode 100644 strangeAddition/main_input0.txt create mode 100644 strangeAddition/main_input1.txt create mode 100644 strangeAddition/main_output0.txt create mode 100644 strangeAddition/main_output1.txt create mode 100755 testGenerator.py diff --git a/AlmostTernaryMatrix/main b/AlmostTernaryMatrix/main new file mode 100755 index 0000000..e0e1fa7 Binary files /dev/null and b/AlmostTernaryMatrix/main differ diff --git a/AlmostTernaryMatrix/main.cpp b/AlmostTernaryMatrix/main.cpp new file mode 100644 index 0000000..b12f974 --- /dev/null +++ b/AlmostTernaryMatrix/main.cpp @@ -0,0 +1,20 @@ +#include + +using namespace std; + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--){ + int n, m; + cin >> n >> m; + for(int i = 0; i < n; i++) { + for(int j = 0; j < m; j++) { + cout << ((((i + 1) / 2 + (j + 1) / 2)) % 2) << " "; + } + cout << '\n'; + } + } +} diff --git a/AlmostTernaryMatrix/main_input0.txt b/AlmostTernaryMatrix/main_input0.txt new file mode 100644 index 0000000..1cb1a53 --- /dev/null +++ b/AlmostTernaryMatrix/main_input0.txt @@ -0,0 +1,4 @@ +3 +2 4 +2 2 +4 4 diff --git a/AlmostTernaryMatrix/main_input1.txt b/AlmostTernaryMatrix/main_input1.txt new file mode 100644 index 0000000..1c253ac --- /dev/null +++ b/AlmostTernaryMatrix/main_input1.txt @@ -0,0 +1,2 @@ +1 +8 8 \ No newline at end of file diff --git a/AlmostTernaryMatrix/main_output0.txt b/AlmostTernaryMatrix/main_output0.txt new file mode 100644 index 0000000..8231c12 --- /dev/null +++ b/AlmostTernaryMatrix/main_output0.txt @@ -0,0 +1,8 @@ +1 0 0 1 +0 1 1 0 +1 0 +0 1 +1 0 1 0 +0 0 1 1 +1 1 0 0 +0 1 0 1 diff --git a/DifferenceOperations/main b/DifferenceOperations/main new file mode 100755 index 0000000..808f4b1 Binary files /dev/null and b/DifferenceOperations/main differ diff --git a/DifferenceOperations/main.cpp b/DifferenceOperations/main.cpp new file mode 100644 index 0000000..7594a5c --- /dev/null +++ b/DifferenceOperations/main.cpp @@ -0,0 +1,23 @@ +#include + +using namespace std; + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while (tt--) { + int n; + cin >> n; + vector v(n); + for (int &x : v) + cin >> x; + bool ok = true; + for (int i = 1; i < n; ++i) { + if (v[i] % v[0]) + ok = false; + } + cout << (ok ? "YES" : "NO") << endl; + } +} diff --git a/DifferenceOperations/main_input0.txt b/DifferenceOperations/main_input0.txt new file mode 100644 index 0000000..a34da86 --- /dev/null +++ b/DifferenceOperations/main_input0.txt @@ -0,0 +1,9 @@ +4 +2 +5 10 +3 +1 2 3 +4 +1 1 1 1 +9 +9 9 8 2 4 4 3 5 3 diff --git a/DifferenceOperations/main_input1.txt b/DifferenceOperations/main_input1.txt new file mode 100644 index 0000000..984e61f --- /dev/null +++ b/DifferenceOperations/main_input1.txt @@ -0,0 +1,3 @@ +1 +3 +1 1 2 \ No newline at end of file diff --git a/DifferenceOperations/main_input2.txt b/DifferenceOperations/main_input2.txt new file mode 100644 index 0000000..55ea267 --- /dev/null +++ b/DifferenceOperations/main_input2.txt @@ -0,0 +1,105 @@ +52 +2 +1 1 +3 +1 1 1 +3 +1 1 2 +3 +1 1 3 +3 +1 1 4 +3 +1 1 5 +2 +1 2 +3 +1 2 1 +3 +1 2 2 +3 +1 2 3 +3 +1 2 4 +3 +1 2 5 +2 +1 3 +3 +1 3 1 +3 +1 3 2 +3 +1 3 3 +3 +1 3 4 +3 +1 3 5 +2 +1 4 +3 +1 4 1 +3 +1 4 2 +3 +1 4 3 +3 +1 4 4 +3 +1 4 5 +2 +1 5 +3 +1 5 1 +3 +1 5 2 +3 +1 5 3 +3 +1 5 4 +3 +1 5 5 +2 +2 1 +3 +2 1 1 +3 +2 1 2 +3 +2 1 3 +3 +2 1 4 +3 +2 1 5 +2 +2 2 +3 +2 2 1 +3 +2 2 2 +3 +2 2 3 +3 +2 2 4 +3 +2 2 5 +2 +2 3 +3 +2 3 1 +3 +2 3 2 +3 +2 3 3 +3 +2 3 4 +3 +2 3 5 +2 +2 4 +3 +2 4 1 +3 +2 4 2 +3 +2 4 3 \ No newline at end of file diff --git a/DifferenceOperations/main_input3.txt b/DifferenceOperations/main_input3.txt new file mode 100644 index 0000000..fe89f7c --- /dev/null +++ b/DifferenceOperations/main_input3.txt @@ -0,0 +1,153 @@ +76 +9 +52 65 14 59 16 52 62 71 90 +8 +66 88 27 98 28 49 48 50 +3 +24 57 99 +7 +51 43 76 90 36 61 97 +9 +86 23 91 42 57 79 38 30 31 +4 +77 10 84 76 +9 +48 89 76 43 47 57 51 71 23 +5 +63 56 17 89 16 +2 +33 45 +4 +34 64 63 48 +10 +92 88 59 78 84 34 64 64 55 61 +4 +52 43 84 43 +9 +13 39 57 62 35 59 10 60 1 +9 +84 89 30 55 33 56 4 18 64 +4 +24 17 78 2 +4 +85 40 7 67 +2 +84 92 +7 +100 3 36 17 46 28 82 +9 +38 2 45 28 32 50 18 92 18 +2 +1 41 +10 +62 85 34 100 40 54 88 31 77 4 +2 +95 86 +2 +72 36 +9 +24 5 98 3 7 22 15 45 67 +3 +22 71 85 +8 +81 51 59 59 89 99 87 18 +10 +5 89 7 19 62 8 31 24 9 86 +10 +1 46 77 90 71 38 34 23 58 10 +3 +60 71 84 +4 +11 16 30 33 +6 +87 91 35 39 4 22 +8 +70 30 39 53 19 23 54 17 +8 +10 95 25 95 20 34 52 11 +9 +74 49 64 24 21 76 63 81 35 +10 +4 64 83 21 85 77 60 65 94 74 +7 +88 53 39 2 29 93 80 +5 +73 3 99 31 10 +8 +54 90 58 48 2 12 16 81 +2 +5 29 +5 +15 97 35 49 7 +10 +9 13 35 59 85 12 26 35 28 81 +10 +15 77 48 56 43 49 68 37 7 37 +2 +76 87 +7 +72 62 21 12 69 42 76 +6 +55 40 45 91 33 25 +10 +71 67 50 78 13 85 90 45 33 51 +7 +81 64 62 88 48 100 82 +10 +45 16 64 85 7 79 18 81 52 95 +6 +84 49 36 20 32 69 +4 +16 47 28 48 +7 +24 93 53 31 78 64 90 +7 +84 68 92 53 8 94 53 +8 +38 54 83 10 80 69 32 25 +8 +17 64 28 81 52 94 85 39 +2 +29 97 +6 +85 26 1 7 75 67 +10 +17 7 11 74 28 44 89 13 69 87 +8 +32 98 15 73 26 32 90 43 +6 +36 88 84 10 60 22 +6 +40 6 26 61 87 85 +9 +95 44 35 39 1 43 16 44 49 +2 +43 98 +3 +6 38 12 +2 +29 96 +4 +52 66 58 66 +2 +61 92 +2 +16 74 +6 +78 53 79 80 99 63 +9 +64 66 71 28 73 4 72 1 61 +9 +27 22 52 20 95 70 69 66 25 +7 +27 86 37 20 48 53 77 +8 +40 92 63 33 91 23 94 37 +3 +17 21 9 +10 +1 30 17 6 12 75 63 71 3 70 +6 +65 74 6 41 10 6 +7 +51 70 8 94 100 64 8 diff --git a/DifferenceOperations/main_output0.txt b/DifferenceOperations/main_output0.txt new file mode 100644 index 0000000..4d34574 --- /dev/null +++ b/DifferenceOperations/main_output0.txt @@ -0,0 +1,4 @@ +YES +YES +YES +NO diff --git a/DifferenceOperations/main_output1.txt b/DifferenceOperations/main_output1.txt new file mode 100644 index 0000000..d2bb323 --- /dev/null +++ b/DifferenceOperations/main_output1.txt @@ -0,0 +1 @@ +YES \ No newline at end of file diff --git a/DifferenceOperations/main_output2.txt b/DifferenceOperations/main_output2.txt new file mode 100644 index 0000000..a31ba10 --- /dev/null +++ b/DifferenceOperations/main_output2.txt @@ -0,0 +1,52 @@ +YES +YES +YES +YES +YES +YES +YES +YES +YES +YES +YES +YES +YES +YES +YES +YES +YES +YES +YES +YES +YES +YES +YES +YES +YES +YES +YES +YES +YES +YES +YES +YES +YES +YES +YES +YES +YES +NO +YES +NO +YES +NO +YES +YES +YES +YES +YES +YES +YES +NO +YES +NO \ No newline at end of file diff --git a/DifferenceOperations/randomInput.txt b/DifferenceOperations/randomInput.txt new file mode 100644 index 0000000..44573bc --- /dev/null +++ b/DifferenceOperations/randomInput.txt @@ -0,0 +1,154 @@ +76 +9 +52 65 14 59 16 52 62 71 90 +8 +66 88 27 98 28 49 48 50 +3 +24 57 99 +7 +51 43 76 90 36 61 97 +9 +86 23 91 42 57 79 38 30 31 +4 +77 10 84 76 +9 +48 89 76 43 47 57 51 71 23 +5 +63 56 17 89 16 +2 +33 45 +4 +34 64 63 48 +10 +92 88 59 78 84 34 64 64 55 61 +4 +52 43 84 43 +9 +13 39 57 62 35 59 10 60 1 +9 +84 89 30 55 33 56 4 18 64 +4 +24 17 78 2 +4 +85 40 7 67 +2 +84 92 +7 +100 3 36 17 46 28 82 +9 +38 2 45 28 32 50 18 92 18 +2 +1 41 +10 +62 85 34 100 40 54 88 31 77 4 +2 +95 86 +2 +72 36 +9 +24 5 98 3 7 22 15 45 67 +3 +22 71 85 +8 +81 51 59 59 89 99 87 18 +10 +5 89 7 19 62 8 31 24 9 86 +10 +1 46 77 90 71 38 34 23 58 10 +3 +60 71 84 +4 +11 16 30 33 +6 +87 91 35 39 4 22 +8 +70 30 39 53 19 23 54 17 +8 +10 95 25 95 20 34 52 11 +9 +74 49 64 24 21 76 63 81 35 +10 +4 64 83 21 85 77 60 65 94 74 +7 +88 53 39 2 29 93 80 +5 +73 3 99 31 10 +8 +54 90 58 48 2 12 16 81 +2 +5 29 +5 +15 97 35 49 7 +10 +9 13 35 59 85 12 26 35 28 81 +10 +15 77 48 56 43 49 68 37 7 37 +2 +76 87 +7 +72 62 21 12 69 42 76 +6 +55 40 45 91 33 25 +10 +71 67 50 78 13 85 90 45 33 51 +7 +81 64 62 88 48 100 82 +10 +45 16 64 85 7 79 18 81 52 95 +6 +84 49 36 20 32 69 +4 +16 47 28 48 +7 +24 93 53 31 78 64 90 +7 +84 68 92 53 8 94 53 +8 +38 54 83 10 80 69 32 25 +8 +17 64 28 81 52 94 85 39 +2 +29 97 +6 +85 26 1 7 75 67 +10 +17 7 11 74 28 44 89 13 69 87 +8 +32 98 15 73 26 32 90 43 +6 +36 88 84 10 60 22 +6 +40 6 26 61 87 85 +9 +95 44 35 39 1 43 16 44 49 +2 +43 98 +3 +6 38 12 +2 +29 96 +4 +52 66 58 66 +2 +61 92 +2 +16 74 +6 +78 53 79 80 99 63 +9 +64 66 71 28 73 4 72 1 61 +9 +27 22 52 20 95 70 69 66 25 +7 +27 86 37 20 48 53 77 +8 +40 92 63 33 91 23 94 37 +3 +17 21 9 +10 +1 30 17 6 12 75 63 71 3 70 +6 +65 74 6 41 10 6 +7 +51 70 8 94 100 64 8 + diff --git a/FunkyNumbers/main b/FunkyNumbers/main new file mode 100755 index 0000000..8b7a093 Binary files /dev/null and b/FunkyNumbers/main differ diff --git a/FunkyNumbers/main.cpp b/FunkyNumbers/main.cpp new file mode 100644 index 0000000..9c5234d --- /dev/null +++ b/FunkyNumbers/main.cpp @@ -0,0 +1,24 @@ +#include + +using namespace std; + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int n; + cin >> n; + n = n * 2; + set st; + for (int i = 1; i * i <= n; i++) { + st.insert(i * (i + 1)); + } + bool ok = false; + for (auto x : st) { + cerr << x << endl; + if(st.count(n - x)) { + ok = true; + break; + } + } + cout << (ok ? "YES" : "NO") << endl; +} diff --git a/FunkyNumbers/main_input0.txt b/FunkyNumbers/main_input0.txt new file mode 100644 index 0000000..9183bf0 --- /dev/null +++ b/FunkyNumbers/main_input0.txt @@ -0,0 +1 @@ +256 diff --git a/FunkyNumbers/main_input1.txt b/FunkyNumbers/main_input1.txt new file mode 100644 index 0000000..4d0e90c --- /dev/null +++ b/FunkyNumbers/main_input1.txt @@ -0,0 +1 @@ +512 diff --git a/FunkyNumbers/main_input2.txt b/FunkyNumbers/main_input2.txt new file mode 100644 index 0000000..7bed022 --- /dev/null +++ b/FunkyNumbers/main_input2.txt @@ -0,0 +1 @@ +828 \ No newline at end of file diff --git a/FunkyNumbers/main_output0.txt b/FunkyNumbers/main_output0.txt new file mode 100644 index 0000000..f033a50 --- /dev/null +++ b/FunkyNumbers/main_output0.txt @@ -0,0 +1 @@ +YES diff --git a/FunkyNumbers/main_output1.txt b/FunkyNumbers/main_output1.txt new file mode 100644 index 0000000..5e35d1b --- /dev/null +++ b/FunkyNumbers/main_output1.txt @@ -0,0 +1 @@ +NO diff --git a/FunkyNumbers/main_output2.txt b/FunkyNumbers/main_output2.txt new file mode 100644 index 0000000..d2bb323 --- /dev/null +++ b/FunkyNumbers/main_output2.txt @@ -0,0 +1 @@ +YES \ No newline at end of file diff --git a/TheThirdThreeNumberProblem/main b/TheThirdThreeNumberProblem/main new file mode 100755 index 0000000..4d2eb59 Binary files /dev/null and b/TheThirdThreeNumberProblem/main differ diff --git a/TheThirdThreeNumberProblem/main.cpp b/TheThirdThreeNumberProblem/main.cpp new file mode 100644 index 0000000..656b3df --- /dev/null +++ b/TheThirdThreeNumberProblem/main.cpp @@ -0,0 +1,20 @@ +#include + +using namespace std; + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--){ + int n; + cin >> n; + if(n % 2) { + cout << -1 << endl; + } else { + cout << "0" << " " << n / 2 << " " << n / 2 << endl; + } + + } +} diff --git a/TheThirdThreeNumberProblem/main_input0.txt b/TheThirdThreeNumberProblem/main_input0.txt new file mode 100644 index 0000000..8cc752e --- /dev/null +++ b/TheThirdThreeNumberProblem/main_input0.txt @@ -0,0 +1,6 @@ +5 +4 +1 +12 +2046 +194723326 diff --git a/TheThirdThreeNumberProblem/main_output0.txt b/TheThirdThreeNumberProblem/main_output0.txt new file mode 100644 index 0000000..35b1415 --- /dev/null +++ b/TheThirdThreeNumberProblem/main_output0.txt @@ -0,0 +1,5 @@ +3 3 1 +-1 +2 4 6 +69 420 666 +12345678 87654321 100000000 diff --git a/codechef/sticks/main b/codechef/sticks/main new file mode 100755 index 0000000..ebd7c57 Binary files /dev/null and b/codechef/sticks/main differ diff --git a/codechef/sticks/main.cpp b/codechef/sticks/main.cpp new file mode 100644 index 0000000..b5fae0e --- /dev/null +++ b/codechef/sticks/main.cpp @@ -0,0 +1,42 @@ +#include + +using namespace std; + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while (tt--) { + int n; + cin >> n; + vector v(n); + map mp; + for (int &x : v) { + cin >> x; + mp[x]++; + } + vector pair; + set vis; + int sq = 0; + sort(v.begin(), v.end()); + for(int i = v.size() - 1; i > 0; i--) { + int elem = v[i]; + if(mp[elem] >= 4) { + sq = elem; + } + if(mp[elem] >= 2 && !vis.count(elem)) { + if(pair.size() == 2) { + break; + } + pair.push_back(elem); + vis.insert(elem); + } + } + if(pair.size() == 2) { + cout << max(pair[0] * pair[1], sq * sq) << endl; + } else { + cout << -1 << endl; + } + } +} diff --git a/codechef/sticks/main_input0.txt b/codechef/sticks/main_input0.txt new file mode 100644 index 0000000..c12bf91 --- /dev/null +++ b/codechef/sticks/main_input0.txt @@ -0,0 +1,5 @@ +2 +5 +1 2 3 1 2 +4 +1 2 2 3 diff --git a/codechef/sticks/main_input1.txt b/codechef/sticks/main_input1.txt new file mode 100644 index 0000000..636b9ba --- /dev/null +++ b/codechef/sticks/main_input1.txt @@ -0,0 +1,7 @@ +3 +6 +1 1 2 2 3 3 +10 +1 1 3 3 4 4 5 5 5 5 +1 +1 \ No newline at end of file diff --git a/codechef/sticks/main_output0.txt b/codechef/sticks/main_output0.txt new file mode 100644 index 0000000..4bbcfcf --- /dev/null +++ b/codechef/sticks/main_output0.txt @@ -0,0 +1,2 @@ +2 +-1 diff --git a/codechef/sticks/main_output1.txt b/codechef/sticks/main_output1.txt new file mode 100644 index 0000000..89488f4 --- /dev/null +++ b/codechef/sticks/main_output1.txt @@ -0,0 +1,3 @@ +6 +25 +-1 \ No newline at end of file diff --git a/contests/Round#809/A/B/C/D/E/F/main.cpp b/contests/Round#809/A/B/C/D/E/F/main.cpp new file mode 100644 index 0000000..9549f1d --- /dev/null +++ b/contests/Round#809/A/B/C/D/E/F/main.cpp @@ -0,0 +1,13 @@ +#include + +using namespace std; + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--){ + + } +} diff --git a/contests/Round#809/A/B/C/D/E/main.cpp b/contests/Round#809/A/B/C/D/E/main.cpp new file mode 100644 index 0000000..9549f1d --- /dev/null +++ b/contests/Round#809/A/B/C/D/E/main.cpp @@ -0,0 +1,13 @@ +#include + +using namespace std; + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--){ + + } +} diff --git a/contests/Round#809/A/B/C/D/main.cpp b/contests/Round#809/A/B/C/D/main.cpp new file mode 100644 index 0000000..9549f1d --- /dev/null +++ b/contests/Round#809/A/B/C/D/main.cpp @@ -0,0 +1,13 @@ +#include + +using namespace std; + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--){ + + } +} diff --git a/contests/Round#809/A/B/C/main.cpp b/contests/Round#809/A/B/C/main.cpp new file mode 100644 index 0000000..9549f1d --- /dev/null +++ b/contests/Round#809/A/B/C/main.cpp @@ -0,0 +1,13 @@ +#include + +using namespace std; + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--){ + + } +} diff --git a/contests/Round#809/A/B/main b/contests/Round#809/A/B/main new file mode 100755 index 0000000..12f7c31 Binary files /dev/null and b/contests/Round#809/A/B/main differ diff --git a/contests/Round#809/A/B/main.cpp b/contests/Round#809/A/B/main.cpp new file mode 100644 index 0000000..90c55c2 --- /dev/null +++ b/contests/Round#809/A/B/main.cpp @@ -0,0 +1,58 @@ +#include + +using namespace std; + +bool isCool(vector &a, int i) { + if (i == 0) { + return false; + } + if (a[i - 1] < a[i] && a[i + 1] < a[i]) { + return true; + } + return false; +} + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while (tt--) { + int n; + cin >> n; + vector a(n); + for (int &x : a) + cin >> x; + long long ans = 0; + long long mx = 0; + int max_cool = (n - 1) / 2; + int cnt = 0; + if(n > 3) { + for (int i = 1; i < n - 1; i++) { + if(isCool(a,i)) { + cnt++; + } + if (!isCool(a, i) && i % 2 == 0) { + ans += abs(a[i] - max(a[i - 1], a[i + 1])) + 1; + } else if(!isCool(a, i) && i % 2 != 0) { + mx += abs(a[i] - max(a[i - 1], a[i + 1])) + 1; + } + } + long long mx2 = 0; + for (int i = 1; i < n - 1; i += 3) { + if (!isCool(a, i)) { + mx2 += abs(a[i] - max(a[i - 1], a[i + 1])) + 1; + } + } + cerr << mx << " " << ans << " " << mx2 << endl; + if(cnt < max_cool) { + // cout << max(mx2, max(ans, mx)) << endl; + } else { + cout << min(mx2, min(ans, mx)) << endl; + } + + } else { + cout << abs(a[1] - max(a[0], a[2])) + 1 << endl; + } + } +} diff --git a/contests/Round#809/A/B/main_input0.txt b/contests/Round#809/A/B/main_input0.txt new file mode 100644 index 0000000..3781f01 --- /dev/null +++ b/contests/Round#809/A/B/main_input0.txt @@ -0,0 +1,13 @@ +6 +3 +2 1 2 +5 +1 2 1 4 3 +6 +3 1 4 5 5 2 +8 +4 2 1 3 5 3 6 1 +6 +1 10 1 1 10 1 +8 +1 10 11 1 10 11 10 1 diff --git a/contests/Round#809/A/B/main_input1.txt b/contests/Round#809/A/B/main_input1.txt new file mode 100644 index 0000000..07c8f0a --- /dev/null +++ b/contests/Round#809/A/B/main_input1.txt @@ -0,0 +1,3 @@ +1 +4 +1 2 2 1 \ No newline at end of file diff --git a/contests/Round#809/A/B/main_input2.txt b/contests/Round#809/A/B/main_input2.txt new file mode 100644 index 0000000..b5a46e0 --- /dev/null +++ b/contests/Round#809/A/B/main_input2.txt @@ -0,0 +1,3 @@ +1 +5 +1 1 1 4 3 \ No newline at end of file diff --git a/contests/Round#809/A/B/main_input3.txt b/contests/Round#809/A/B/main_input3.txt new file mode 100644 index 0000000..fb1fbc0 --- /dev/null +++ b/contests/Round#809/A/B/main_input3.txt @@ -0,0 +1,3 @@ +1 +7 +1000000000 1 1000000000 1 1000000000 1 1000000000 \ No newline at end of file diff --git a/contests/Round#809/A/B/main_output0.txt b/contests/Round#809/A/B/main_output0.txt new file mode 100644 index 0000000..6a9dd24 --- /dev/null +++ b/contests/Round#809/A/B/main_output0.txt @@ -0,0 +1,6 @@ +2 +0 +3 +3 +0 +4 diff --git a/contests/Round#809/A/B/main_output1.txt b/contests/Round#809/A/B/main_output1.txt new file mode 100644 index 0000000..56a6051 --- /dev/null +++ b/contests/Round#809/A/B/main_output1.txt @@ -0,0 +1 @@ +1 \ No newline at end of file diff --git a/contests/Round#809/A/B/main_output2.txt b/contests/Round#809/A/B/main_output2.txt new file mode 100644 index 0000000..56a6051 --- /dev/null +++ b/contests/Round#809/A/B/main_output2.txt @@ -0,0 +1 @@ +1 \ No newline at end of file diff --git a/contests/Round#809/A/B/main_output3.txt b/contests/Round#809/A/B/main_output3.txt new file mode 100644 index 0000000..c227083 --- /dev/null +++ b/contests/Round#809/A/B/main_output3.txt @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/contests/Round#809/A/main b/contests/Round#809/A/main new file mode 100755 index 0000000..8ee5ead Binary files /dev/null and b/contests/Round#809/A/main differ diff --git a/contests/Round#809/A/main.cpp b/contests/Round#809/A/main.cpp new file mode 100644 index 0000000..9f5e962 --- /dev/null +++ b/contests/Round#809/A/main.cpp @@ -0,0 +1,35 @@ +#include + +using namespace std; + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--){ + int n, m; + cin >> n >> m; + vector v(m, 'B'); + vector a(n); + set vis; + for(int &x : a) cin >> x; + for(int i = 0; i < n; i++) { + int f = a[i] - 1; + int l = m - a[i]; + if(f <= l && v[f] != 'A') { + v[f] = 'A'; + } else if(f <= l && v[f] == 'A') { + v[l] = 'A'; + } else if(l <= f && v[l] != 'A') { + v[l] = 'A'; + } else if(l <= f && v[l] == 'A') { + v[f] = 'A'; + } + } + for(auto ch : v) { + cout << ch; + } + cout << endl; + } +} diff --git a/contests/Round#809/A/main_input0.txt b/contests/Round#809/A/main_input0.txt new file mode 100644 index 0000000..b09d594 --- /dev/null +++ b/contests/Round#809/A/main_input0.txt @@ -0,0 +1,13 @@ +6 +4 5 +1 1 3 1 +1 5 +2 +4 1 +1 1 1 1 +2 4 +1 3 +2 7 +7 5 +4 5 +5 5 3 5 diff --git a/contests/Round#809/A/main_output0.txt b/contests/Round#809/A/main_output0.txt new file mode 100644 index 0000000..ac6b315 --- /dev/null +++ b/contests/Round#809/A/main_output0.txt @@ -0,0 +1,6 @@ +ABABA +BABBB +A +AABB +ABABBBB +ABABA diff --git a/strangeAddition/main b/strangeAddition/main new file mode 100755 index 0000000..32d1277 Binary files /dev/null and b/strangeAddition/main differ diff --git a/strangeAddition/main.cpp b/strangeAddition/main.cpp new file mode 100644 index 0000000..4e1e203 --- /dev/null +++ b/strangeAddition/main.cpp @@ -0,0 +1,51 @@ +#include +#include + +using namespace std; + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int n; + cin >> n; + int zeros = 0; + vector ind; + vector v(n); + for(int i = 0; i < n; i++) { + cin >> v[i]; + int y = v[i]; + if(v[i] == 0) { + zeros++; + ind.push_back(i); + } + while(y >= 1) { + int d = y % 10; + y /= 10; + if(d == 0) { + zeros++; + ind.push_back(i); + break; + } + } + } + int diff = 1; + zeros = zeros * 2; + cout << min(zeros, n) << endl; + vector ans; + for(int i = 0; i < n; i++) { + if(count(ind.begin(), ind.end(), i)) { + ans.push_back(v[i]); + } + } + for(int i = 0; i < n; i++){ + if(!count(ind.begin(), ind.end(), i) && diff) { + ans.push_back(v[i]); + diff--; + } + } + sort(ans.begin(), ans.end()); + for(auto x : ans) { + cout << x << " "; + } + cout << endl; +} diff --git a/strangeAddition/main_input0.txt b/strangeAddition/main_input0.txt new file mode 100644 index 0000000..27669ab --- /dev/null +++ b/strangeAddition/main_input0.txt @@ -0,0 +1,2 @@ +4 +100 10 1 0 diff --git a/strangeAddition/main_input1.txt b/strangeAddition/main_input1.txt new file mode 100644 index 0000000..bd4305b --- /dev/null +++ b/strangeAddition/main_input1.txt @@ -0,0 +1,2 @@ +3 +2 70 3 diff --git a/strangeAddition/main_output0.txt b/strangeAddition/main_output0.txt new file mode 100644 index 0000000..e9a3643 --- /dev/null +++ b/strangeAddition/main_output0.txt @@ -0,0 +1,2 @@ +4 +0 1 10 100 diff --git a/strangeAddition/main_output1.txt b/strangeAddition/main_output1.txt new file mode 100644 index 0000000..0cd8cd5 --- /dev/null +++ b/strangeAddition/main_output1.txt @@ -0,0 +1,2 @@ +2 +2 70 diff --git a/testGenerator.py b/testGenerator.py new file mode 100755 index 0000000..4b5fa74 --- /dev/null +++ b/testGenerator.py @@ -0,0 +1,13 @@ +#!/bin/env python3 +from random import randint + + +testcases = randint(1, 100) +print(testcases) +for i in range(testcases): + arr_n = randint(2, 10) + print(arr_n) + for j in range(arr_n): + print(randint(1, 100), end=" ") + print() +print() -- cgit v1.2.3