From 8f472939deb468881cee5077b96757b8073f4a7a Mon Sep 17 00:00:00 2001 From: ShazidMahsrafi Date: Tue, 30 Apr 2024 12:26:59 +0600 Subject: [PATCH] Added solutions for Codeforces problems 1969A and 1969B --- Codes/1969 A - Two Friends/1969A.cpp | 42 +++++++++++++++++++++ Codes/1969 B - Shifts and Sorting/1969B.cpp | 39 +++++++++++++++++++ Readme.md | 2 + 3 files changed, 83 insertions(+) create mode 100644 Codes/1969 A - Two Friends/1969A.cpp create mode 100644 Codes/1969 B - Shifts and Sorting/1969B.cpp diff --git a/Codes/1969 A - Two Friends/1969A.cpp b/Codes/1969 A - Two Friends/1969A.cpp new file mode 100644 index 0000000..4074232 --- /dev/null +++ b/Codes/1969 A - Two Friends/1969A.cpp @@ -0,0 +1,42 @@ +#include +using namespace std; +#ifdef ONLINE_JUDGE + #define dbg(...) +#else + #include "debug.h" +#endif +#define ll long long +#define endl '\n' +#define all(x) x.begin(), x.end() +#define sz(x) (int)(x).size() +#define yes cout<<"YES"<>=1;}return ans;} + +void solve() +{ + int n; + cin>>n; + vectorv(n); + for(auto &i:v) cin>>i; + for(int i=0; i> TC; + while (TC--) solve(); +} \ No newline at end of file diff --git a/Codes/1969 B - Shifts and Sorting/1969B.cpp b/Codes/1969 B - Shifts and Sorting/1969B.cpp new file mode 100644 index 0000000..1769b4f --- /dev/null +++ b/Codes/1969 B - Shifts and Sorting/1969B.cpp @@ -0,0 +1,39 @@ +#include +using namespace std; +#ifdef ONLINE_JUDGE + #define dbg(...) +#else + #include "debug.h" +#endif +#define ll long long +#define endl '\n' +#define all(x) x.begin(), x.end() +#define sz(x) (int)(x).size() +#define yes cout<<"YES"<>=1;}return ans;} + +void solve() +{ + string s; + cin>>s; + ll ans=0,ct=0; + for(auto c:s) + { + if(c=='1') + ct++; + else if(c=='0' && ct) + ans += ct+1; + } + cout<> TC; + while (TC--) solve(); +} \ No newline at end of file diff --git a/Readme.md b/Readme.md index 81e5f12..0b5100c 100644 --- a/Readme.md +++ b/Readme.md @@ -306,6 +306,8 @@ This repository contains my solutions of Codeforces problems. They are in C++ la | 294 | 1957 A | Stickogon | [Question](https://codeforces.com/problemset/problem/1957/A) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1957%20A%20-%20Stickogon) | 295 | 1957 B | A BIT of a Construction | [Question](https://codeforces.com/problemset/problem/1957/B) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1957%20B%20-%20A%20BIT%20of%20a%20Construction) | 296 | 1957 C | How Does the Rook Move | [Question](https://codeforces.com/problemset/problem/1957/C) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1957%20C%20-%20How%20Does%20the%20Rook%20Move) +| 297 | 1969 A | Two Friends | [Question](https://codeforces.com/problemset/problem/1969/A) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1969%20A%20-%20Two%20Friends) +| 298 | 1969 B | Shifts and Sorting | [Question](https://codeforces.com/problemset/problem/1969/B) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1969%20B%20-%20Shifts%20and%20Sorting)