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 +++ 4 files changed, 34 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 (limited to 'codechef/DifferentConsecutiveCharacter') 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 -- cgit v1.2.3