From 91ca20b8f78eeeb74fc4eea6eeecdca9fefa5656 Mon Sep 17 00:00:00 2001 From: omagdy7 Date: Tue, 1 Nov 2022 11:51:53 +0200 Subject: Added new problems --- codechef/DifferentConsecutiveCharacter/main | Bin 0 -> 23448 bytes codechef/DifferentConsecutiveCharacter/main.cpp | 24 ++++++++++++++++++++ .../DifferentConsecutiveCharacter/main_input0.txt | 7 ++++++ .../DifferentConsecutiveCharacter/main_output0.txt | 3 +++ codechef/FinalSum/main | Bin 0 -> 27328 bytes codechef/FinalSum/main.cpp | 25 +++++++++++++++++++++ codechef/FinalSum/main_input0.txt | 10 +++++++++ codechef/FinalSum/main_output0.txt | 2 ++ codechef/MakeMultiple/main | Bin 0 -> 22648 bytes codechef/MakeMultiple/main.cpp | 15 +++++++++++++ codechef/MakeMultiple/main_input0.txt | 4 ++++ codechef/MakeMultiple/main_output0.txt | 3 +++ codechef/MinimiseLcs/main.cpp | 13 +++++++++++ codechef/OddSumPair/main | Bin 0 -> 22648 bytes codechef/OddSumPair/main.cpp | 16 +++++++++++++ codechef/OddSumPair/main_input0.txt | 5 +++++ codechef/OddSumPair/main_output0.txt | 4 ++++ codechef/ReachOnTime/main.cpp | 15 +++++++++++++ codechef/Rectangle/main | Bin 0 -> 22648 bytes codechef/Rectangle/main.cpp | 15 +++++++++++++ codechef/Rectangle/main_input0.txt | 4 ++++ codechef/Rectangle/main_output0.txt | 3 +++ codechef/ShortestPathInBinaryTrees/main | Bin 0 -> 22544 bytes codechef/ShortestPathInBinaryTrees/main.cpp | 24 ++++++++++++++++++++ codechef/ShortestPathInBinaryTrees/main_input0.txt | 4 ++++ .../ShortestPathInBinaryTrees/main_output0.txt | 3 +++ codechef/chopSticks/main.cpp | 14 ++++++++++++ 27 files changed, 213 insertions(+) create mode 100755 codechef/DifferentConsecutiveCharacter/main create mode 100644 codechef/DifferentConsecutiveCharacter/main.cpp create mode 100644 codechef/DifferentConsecutiveCharacter/main_input0.txt create mode 100644 codechef/DifferentConsecutiveCharacter/main_output0.txt create mode 100755 codechef/FinalSum/main create mode 100644 codechef/FinalSum/main.cpp create mode 100644 codechef/FinalSum/main_input0.txt create mode 100644 codechef/FinalSum/main_output0.txt create mode 100755 codechef/MakeMultiple/main create mode 100644 codechef/MakeMultiple/main.cpp create mode 100644 codechef/MakeMultiple/main_input0.txt create mode 100644 codechef/MakeMultiple/main_output0.txt create mode 100644 codechef/MinimiseLcs/main.cpp create mode 100755 codechef/OddSumPair/main create mode 100644 codechef/OddSumPair/main.cpp create mode 100644 codechef/OddSumPair/main_input0.txt create mode 100644 codechef/OddSumPair/main_output0.txt create mode 100644 codechef/ReachOnTime/main.cpp create mode 100755 codechef/Rectangle/main create mode 100644 codechef/Rectangle/main.cpp create mode 100644 codechef/Rectangle/main_input0.txt create mode 100644 codechef/Rectangle/main_output0.txt create mode 100755 codechef/ShortestPathInBinaryTrees/main create mode 100644 codechef/ShortestPathInBinaryTrees/main.cpp create mode 100644 codechef/ShortestPathInBinaryTrees/main_input0.txt create mode 100644 codechef/ShortestPathInBinaryTrees/main_output0.txt create mode 100644 codechef/chopSticks/main.cpp (limited to 'codechef') diff --git a/codechef/DifferentConsecutiveCharacter/main b/codechef/DifferentConsecutiveCharacter/main new file mode 100755 index 0000000..1469d82 Binary files /dev/null and b/codechef/DifferentConsecutiveCharacter/main differ diff --git a/codechef/DifferentConsecutiveCharacter/main.cpp b/codechef/DifferentConsecutiveCharacter/main.cpp new file mode 100644 index 0000000..18cc70e --- /dev/null +++ b/codechef/DifferentConsecutiveCharacter/main.cpp @@ -0,0 +1,24 @@ +#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; + string s; + cin >> s; + int ans = 0; + for(int i = 0; i < n - 1; i++) { + if(s[i + 1] == s[i]) { + s[i] = s[i + 1] - '0'; + ans++; + } + } + cout << ans << endl; + } +} diff --git a/codechef/DifferentConsecutiveCharacter/main_input0.txt b/codechef/DifferentConsecutiveCharacter/main_input0.txt new file mode 100644 index 0000000..1956197 --- /dev/null +++ b/codechef/DifferentConsecutiveCharacter/main_input0.txt @@ -0,0 +1,7 @@ +3 +2 +11 +4 +0101 +5 +00100 diff --git a/codechef/DifferentConsecutiveCharacter/main_output0.txt b/codechef/DifferentConsecutiveCharacter/main_output0.txt new file mode 100644 index 0000000..56f24a1 --- /dev/null +++ b/codechef/DifferentConsecutiveCharacter/main_output0.txt @@ -0,0 +1,3 @@ +1 +0 +2 diff --git a/codechef/FinalSum/main b/codechef/FinalSum/main new file mode 100755 index 0000000..c385446 Binary files /dev/null and b/codechef/FinalSum/main differ diff --git a/codechef/FinalSum/main.cpp b/codechef/FinalSum/main.cpp new file mode 100644 index 0000000..4fc98d8 --- /dev/null +++ b/codechef/FinalSum/main.cpp @@ -0,0 +1,25 @@ +#include + +using namespace std; + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--){ + int n, q; + cin >> n >> q; + vector v(n); + for(auto &x : v) { + cin >> x; + } + int k = 0; + while(q--) { + int x, y; + cin >> x >> y; + k += (y - x + 1) % 2; + } + cout << accumulate(v.begin(), v.end(), 0) + k << '\n'; + } +} diff --git a/codechef/FinalSum/main_input0.txt b/codechef/FinalSum/main_input0.txt new file mode 100644 index 0000000..1c11117 --- /dev/null +++ b/codechef/FinalSum/main_input0.txt @@ -0,0 +1,10 @@ +2 +5 3 +1 3 4 4 2 +1 5 +3 4 +2 2 +1 2 +4 +1 1 +1 1 diff --git a/codechef/FinalSum/main_output0.txt b/codechef/FinalSum/main_output0.txt new file mode 100644 index 0000000..ef273a4 --- /dev/null +++ b/codechef/FinalSum/main_output0.txt @@ -0,0 +1,2 @@ +16 +6 diff --git a/codechef/MakeMultiple/main b/codechef/MakeMultiple/main new file mode 100755 index 0000000..06c7ecf Binary files /dev/null and b/codechef/MakeMultiple/main differ diff --git a/codechef/MakeMultiple/main.cpp b/codechef/MakeMultiple/main.cpp new file mode 100644 index 0000000..653970c --- /dev/null +++ b/codechef/MakeMultiple/main.cpp @@ -0,0 +1,15 @@ +#include + +using namespace std; + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--){ + int a, b; + cin >> a >> b; + cout << ((a <= b / 2 || a == b) ? "YES" : "NO") << endl; + } +} diff --git a/codechef/MakeMultiple/main_input0.txt b/codechef/MakeMultiple/main_input0.txt new file mode 100644 index 0000000..11784f3 --- /dev/null +++ b/codechef/MakeMultiple/main_input0.txt @@ -0,0 +1,4 @@ +3 +3 6 +4 14 +9 10 diff --git a/codechef/MakeMultiple/main_output0.txt b/codechef/MakeMultiple/main_output0.txt new file mode 100644 index 0000000..5ae1e3d --- /dev/null +++ b/codechef/MakeMultiple/main_output0.txt @@ -0,0 +1,3 @@ +YES +YES +NO diff --git a/codechef/MinimiseLcs/main.cpp b/codechef/MinimiseLcs/main.cpp new file mode 100644 index 0000000..9549f1d --- /dev/null +++ b/codechef/MinimiseLcs/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/codechef/OddSumPair/main b/codechef/OddSumPair/main new file mode 100755 index 0000000..2579f03 Binary files /dev/null and b/codechef/OddSumPair/main differ diff --git a/codechef/OddSumPair/main.cpp b/codechef/OddSumPair/main.cpp new file mode 100644 index 0000000..174d714 --- /dev/null +++ b/codechef/OddSumPair/main.cpp @@ -0,0 +1,16 @@ +#include + +using namespace std; + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--){ + int a, b, c; + cin >> a >> b >> c; + int sum = (a & 1) + (b & 1) + (c & 1); + cout << (sum == 1 || sum == 2 ? "YES" : "NO") << endl; + } +} diff --git a/codechef/OddSumPair/main_input0.txt b/codechef/OddSumPair/main_input0.txt new file mode 100644 index 0000000..b45ce37 --- /dev/null +++ b/codechef/OddSumPair/main_input0.txt @@ -0,0 +1,5 @@ +4 +1 2 3 +8 4 6 +3 3 9 +7 8 6 diff --git a/codechef/OddSumPair/main_output0.txt b/codechef/OddSumPair/main_output0.txt new file mode 100644 index 0000000..c8cd351 --- /dev/null +++ b/codechef/OddSumPair/main_output0.txt @@ -0,0 +1,4 @@ +YES +NO +NO +YES diff --git a/codechef/ReachOnTime/main.cpp b/codechef/ReachOnTime/main.cpp new file mode 100644 index 0000000..caf16c8 --- /dev/null +++ b/codechef/ReachOnTime/main.cpp @@ -0,0 +1,15 @@ +#include + +using namespace std; + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--){ + int x; + cin >> x; + cout << (x >= 30 ? "YES" : "NO") << endl; + } +} diff --git a/codechef/Rectangle/main b/codechef/Rectangle/main new file mode 100755 index 0000000..e52d0f8 Binary files /dev/null and b/codechef/Rectangle/main differ diff --git a/codechef/Rectangle/main.cpp b/codechef/Rectangle/main.cpp new file mode 100644 index 0000000..a032542 --- /dev/null +++ b/codechef/Rectangle/main.cpp @@ -0,0 +1,15 @@ +#include + +using namespace std; + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--){ + int a, b, c, d; + cin >> a >> b >> c >> d; + cout << ((a ^ b ^ c ^ d) == 0 ? "YES" : "NO") << endl; + } +} diff --git a/codechef/Rectangle/main_input0.txt b/codechef/Rectangle/main_input0.txt new file mode 100644 index 0000000..3a34a60 --- /dev/null +++ b/codechef/Rectangle/main_input0.txt @@ -0,0 +1,4 @@ +3 +1 1 2 2 +3 2 2 3 +1 2 2 2 diff --git a/codechef/Rectangle/main_output0.txt b/codechef/Rectangle/main_output0.txt new file mode 100644 index 0000000..5ae1e3d --- /dev/null +++ b/codechef/Rectangle/main_output0.txt @@ -0,0 +1,3 @@ +YES +YES +NO diff --git a/codechef/ShortestPathInBinaryTrees/main b/codechef/ShortestPathInBinaryTrees/main new file mode 100755 index 0000000..1b29c37 Binary files /dev/null and b/codechef/ShortestPathInBinaryTrees/main differ diff --git a/codechef/ShortestPathInBinaryTrees/main.cpp b/codechef/ShortestPathInBinaryTrees/main.cpp new file mode 100644 index 0000000..eb5f641 --- /dev/null +++ b/codechef/ShortestPathInBinaryTrees/main.cpp @@ -0,0 +1,24 @@ +#include + +using namespace std; + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--){ + int i, j; + cin >> i >> j; + int ans = 0; + while(i != j) { + if (j > i) { + j /= 2; + } else { + i /= 2; + } + ans++; + } + cout << ans << '\n'; + } +} diff --git a/codechef/ShortestPathInBinaryTrees/main_input0.txt b/codechef/ShortestPathInBinaryTrees/main_input0.txt new file mode 100644 index 0000000..94da79c --- /dev/null +++ b/codechef/ShortestPathInBinaryTrees/main_input0.txt @@ -0,0 +1,4 @@ +3 +1 2 +2 3 +4 3 diff --git a/codechef/ShortestPathInBinaryTrees/main_output0.txt b/codechef/ShortestPathInBinaryTrees/main_output0.txt new file mode 100644 index 0000000..01e79c3 --- /dev/null +++ b/codechef/ShortestPathInBinaryTrees/main_output0.txt @@ -0,0 +1,3 @@ +1 +2 +3 diff --git a/codechef/chopSticks/main.cpp b/codechef/chopSticks/main.cpp new file mode 100644 index 0000000..5f6862e --- /dev/null +++ b/codechef/chopSticks/main.cpp @@ -0,0 +1,14 @@ +#include + +using namespace std; + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--){ + + + } +} -- cgit v1.2.3