From a2f9c81865a84d4be96e6bfa22d26dcdbdd23380 Mon Sep 17 00:00:00 2001 From: ShazidMahsrafi Date: Sat, 4 May 2024 18:51:19 +0600 Subject: [PATCH] feat: Add solutions for Codeforces problems 1968F, 1968G1 --- Codes/1968 F - Equal XOR Segments/1968F.cpp | 49 ++++++++++++++ .../1968G1.cpp | 66 +++++++++++++++++++ Readme.md | 6 +- 3 files changed, 119 insertions(+), 2 deletions(-) create mode 100644 Codes/1968 F - Equal XOR Segments/1968F.cpp create mode 100644 Codes/1968 G1 - Division + LCP (easy version)/1968G1.cpp diff --git a/Codes/1968 F - Equal XOR Segments/1968F.cpp b/Codes/1968 F - Equal XOR Segments/1968F.cpp new file mode 100644 index 0000000..1f5d5b3 --- /dev/null +++ b/Codes/1968 F - Equal XOR Segments/1968F.cpp @@ -0,0 +1,49 @@ +#include +using namespace std; +#define ll long long +#define endl '\n' +#define FAST (ios_base::sync_with_stdio(false), cin.tie(nullptr)); +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, q; + cin >> n >> q; + vectorv(n+1,0); + map> m; + m[0].push_back(0); + for(int i = 1; i <= n; ++i) + { + cin>>v[i]; + v[i] ^= v[i-1]; + m[v[i]].push_back(i); + } + while(q--) + { + ll l, r; + cin>>l>>r; + if(v[l-1]==v[r]) + { + cout<<"YES\n"; + continue; + } + auto &v1=m[v[r]], &v2=m[v[l-1]]; + int it1=*lower_bound(v1.begin(), v1.end(), l); + int it2=*--lower_bound(v2.begin(), v2.end(), r); + if(it1> TCS; + for (int TC = 1; TC <= TCS; ++TC) + { + // cout<<"Case "< +using namespace std; +#define ll long long +#define endl '\n' +#define FAST (ios_base::sync_with_stdio(false), cin.tie(nullptr)); +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;} + +vectorZfunc(string &str) +{ + int n=str.size(); + vectorz(n); + int l=0,r=0; + for(int i=1;ir) + { + l=i; + r=i+z[i]-1; + } + } + return z; +} + +void solve() +{ + int n, k; + string s; + cin>> n >> k >> k >> s; + vectorz = Zfunc(s); + ll low = 1, high = n, ans = 0; + while(low <= high) + { + ll mid = low + (high - low) / 2; + ll cnt = 1; + for(int i = mid;i < n;) + { + if(z[i] >= mid) + { + cnt++; + i += mid; + } + else i++; + } + if(cnt >= k) + { + ans = mid; + low = mid+1; + } + else high = mid-1; + } + cout<> TCS; + for (int TC = 1; TC <= TCS; ++TC) + { + // cout<<"Case "<