From c40b1c8007546c74649117c864513f4616a08b0a Mon Sep 17 00:00:00 2001 From: ShazidMahsrafi Date: Mon, 24 Jun 2024 22:38:02 +0600 Subject: [PATCH] Add solutions for Codeforces problems 1986A, 1986B, and 1986C --- Codes/1986 A - X Axis/1986A.cpp | 30 ++++++++++++ Codes/1986 B - Matrix Stabilization/1986B.cpp | 48 +++++++++++++++++++ Codes/1986 C - Update Queries/1986C.cpp | 41 ++++++++++++++++ Readme.md | 3 ++ 4 files changed, 122 insertions(+) create mode 100644 Codes/1986 A - X Axis/1986A.cpp create mode 100644 Codes/1986 B - Matrix Stabilization/1986B.cpp create mode 100644 Codes/1986 C - Update Queries/1986C.cpp diff --git a/Codes/1986 A - X Axis/1986A.cpp b/Codes/1986 A - X Axis/1986A.cpp new file mode 100644 index 0000000..423a974 --- /dev/null +++ b/Codes/1986 A - X Axis/1986A.cpp @@ -0,0 +1,30 @@ +#include +using namespace std; +#define ll long long +#define endl '\n' +ll pow(ll x,ll y,ll m=1e9+7){ll ans=1;x%=m;while(y){if(y&1)ans=(ans*x)%m;x=(x*x)%m;y>>=1;}return ans;} + +void solve() +{ + int a,b,c; + cin>>a>>b>>c; + int mn = INT_MAX; + for(int i=1; i<=10; ++i) + { + int diff = abs(a-i)+abs(b-i)+abs(c-i); + mn = min(diff, mn); + } + cout<> TCS; + for (int TC = 1; TC <= TCS; ++TC) + { + // cout<<"Case "< +using namespace std; +#define ll long long +#define endl '\n' +ll pow(ll x,ll y,ll m=1e9+7){ll ans=1;x%=m;while(y){if(y&1)ans=(ans*x)%m;x=(x*x)%m;y>>=1;}return ans;} + + +void solve() +{ + ll n,m; + cin>>n>>m; + vector> v(n, vector(m)); + for(ll i=0; i>v[i][j]; + } + for(int i=0; i=0) + mx=max(mx, v[i-1][j]); + if(j+1=0) + mx=max(mx, v[i][j-1]); + if(v[i][j]>mx) v[i][j] = mx; + cout<> TCS; + for (int TC = 1; TC <= TCS; ++TC) + { + // cout<<"Case "< +using namespace std; +#define ll long long +#define endl '\n' +ll pow(ll x,ll y,ll m=1e9+7){ll ans=1;x%=m;while(y){if(y&1)ans=(ans*x)%m;x=(x*x)%m;y>>=1;}return ans;} + +void solve() +{ + int n,m; + cin>>n>>m; + string s,c; + cin>>s; + setst; + for(int i=0; i>x; + st.insert(x); + } + cin>>c; + sort(c.begin(),c.end()); + vectorv; + for(auto x:st) v.push_back(x); + for(int i=0; i> TCS; + for (int TC = 1; TC <= TCS; ++TC) + { + // cout<<"Case "<