-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c22e06a
commit 5704f9b
Showing
51 changed files
with
2,206 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
...oblem_Solving/L_Problems/L. Controllers/.cph/.1.cpp_306695f268e1dd92edcdf260b06ed238.prob
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"name":"Local: 1","url":"c:\\Users\\varsh\\.vscode\\nayan work c c++\\Codeforces_Problem_Solving\\L_Problems\\L. Controllers\\1.cpp","tests":[{"id":1679763541529,"input":"8\n+-+---+-\n5\n2 1\n10 3\n7 9\n10 10\n5 3","output":"YES\nNO\nNO\nNO\nYES"},{"id":1679763556958,"input":"6\n+-++--\n2\n9 7\n1 1","output":"YES\nYES"},{"id":1679764171400,"input":"20\n+-----+--+--------+-\n2\n1000000000 99999997\n250000000 1000000000","output":"NO\nYES"}],"interactive":false,"memoryLimit":1024,"timeLimit":3000,"srcPath":"c:\\Users\\varsh\\.vscode\\nayan work c c++\\Codeforces_Problem_Solving\\L_Problems\\L. Controllers\\1.cpp","group":"local","local":true} |
Binary file not shown.
202 changes: 202 additions & 0 deletions
202
Codeforces_Problem_Solving/L_Problems/L. Controllers/1.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,202 @@ | ||
#include<bits/stdc++.h> | ||
|
||
#include <ext/pb_ds/assoc_container.hpp> | ||
#include <ext/pb_ds/tree_policy.hpp> | ||
using namespace __gnu_pbds; | ||
|
||
using namespace std; | ||
|
||
#ifndef ONLINE_JUDGE | ||
#define debug(x) cerr << #x <<" "; _print(x); cerr << endl; | ||
#else | ||
#define debug(x) | ||
#endif | ||
|
||
void _print(long long t) {cerr << t;} | ||
void _print(string t) {cerr << t;} | ||
void _print(char t) {cerr << t;} | ||
void _print(long double t) {cerr << t;} | ||
|
||
template <class T, class V> void _print(pair <T, V> p) {cerr << "{"; _print(p.first); cerr << ","; _print(p.second); cerr << "}";} | ||
template <class T> void _print(vector <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} | ||
template <class T> void _print(set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} | ||
template <class T> void _print(multiset <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} | ||
template <class T, class V> void _print(map <T, V> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";} | ||
|
||
#define ll long long | ||
#define int ll | ||
#define ld long double | ||
#define iv(a , n) vector<int>a(n); for(int i=0;i<n;++i){cin>>a[i];} | ||
#define yes cout << "YES" << endl; | ||
#define no cout << "NO" << endl; | ||
#define all(v) v.begin(),v.end() | ||
#define F first | ||
#define S second | ||
#define check1(v) for(auto &i : v){ cout<<i<<" "; } cout<<endl; | ||
#define check2(v) for(auto &i : v){ cout<<i.F<<" "<<i.S<<endl; } | ||
#define check3(v) for(auto &i : v){ cout<<i.F.F<<" "<<i.F.S<<" "<<i.S<<endl; } | ||
#define check4(v) for(auto &i : v){ cout<<i.F.F<<" "<<i.F.S<<" "<<i.S.F<<" "<<i.S.S<<endl; } | ||
#define pb push_back | ||
#define popb pop_back | ||
#define pf push_front | ||
#define popf pop_front | ||
#define lb lower_bound | ||
#define ub upper_bound | ||
#define bpp __builtin_popcountll | ||
#define Pi 3.1415926535897932384626 | ||
#define EPS 1e-9 | ||
#define nl "\n" | ||
|
||
const int mod97 = 1000000007 ; | ||
const int modg = 998244353 ; | ||
const int N = 2e1 + 10 ; | ||
int fac[N] , invfact[N] ; | ||
vector<bool> isPrime(N , 1) ; | ||
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()) ; | ||
|
||
int gcd(int a, int b) {if(b == 0){return a;} return gcd(b, a % b);} | ||
int lcm(int a, int b){return (a/gcd(a,b)*b);} | ||
int power(int a, int b) {int res=1; while(b > 0) {if(b & 1) res= (res*a); a=(a*a); b=b >> 1;} return res;} | ||
int inv_mult(int i) {if (i == 1) return 1; return (mod97 - ((mod97 / i) * inv_mult(mod97 % i)) % mod97) % mod97;} | ||
string decToBinary(int n){string s=""; int i=0; while(n > 0) {s=to_string(n % 2) + s; n=n/2; i++;}return s;} | ||
bool isPowerOfTwo(int n){if(n==0) {return false;} return (ceil(log2(n)) == floor(log2(n)));} | ||
bool isPerfectSquare(int x) {if (x>=0) {int sr = sqrt(x);return (sr * sr == x);}return false;} | ||
int modpower(int x, int y){int res=1; x=x % mod97; while(y>0){if(y&1) res = (res*x) % mod97; y=y>>1; x=(x*x) % mod97;}return res;} | ||
int modInverse(int n){return power(n, modg - 2);} | ||
int ncr(int n,int r, int p){if(r > n){return 0;}if(n < 0 || r < 0){return 0;}if (r==0) return 1;int fac[n+1]; fac[0] = 1; for (int i=1 ; i<=n; i++) fac[i] = fac[i-1]*i%p;return (fac[n]* power(fac[r], p-2)%p*power(fac[n-r], p-2) % p) % p;} | ||
void prime(){isPrime[0]=isPrime[1]=false;for(int i = 2; i <= N; ++i){if(isPrime[i] == true){for(int j = 2*i; j <= N; j += i){isPrime[j] = false;}}}} | ||
int isqrt(int n){long long x = sqrtl(n);while (x*x>n){--x;} while((x+1) * (x+1)<=n){++x;}return x;} | ||
int sqrtprecision(int l,int r,int target){while(r-l>EPS){int mid=(l+(r-l)/2);if(mid*mid<target)l=mid;else r=mid;}return l+(r-l)/2;} | ||
int errichtokabinary(int l,int r,vector<int>&a,int target){int ans=-1; while(l <= r){int mid=(l+(r-l)/2); if(a[mid]==target){ans=mid;return ans;}if(a[mid]<target)l=mid+1;else r=mid-1;}return ans;} | ||
void nCr(int n, int r){long long p = 1, k = 1;if (n - r < r)r = n - r;if (r != 0) {while (r) {p *= n;k *= r;long long m = __gcd(p, k);p /= m;k /= m;n--;r--;}}else cout << p << endl;} | ||
int getRandomNumber(int l, int r) {return uniform_int_distribution<int>(l, r)(rng);} | ||
|
||
vector<vector<int > > adj ; | ||
vector<int > visited ; | ||
vector<int > value ; | ||
|
||
bool solve(){ | ||
//adj.assign(n + 1 , vector<int >()); | ||
//visited.assign(n + 1 , false) ; | ||
//value.assign(n + 1 , 0) ; | ||
int n ; | ||
cin >> n ; | ||
string s ; | ||
cin >> s ; | ||
int positive = 0 ; | ||
int negative = 0 ; | ||
for(int i = 0 ; i < n ; ++i){ | ||
if(s[i] == '+') positive ++ ; | ||
else negative ++ ; | ||
} | ||
int q ; | ||
cin >> q ; | ||
for(int i = 0 ; i < q ; ++i){ | ||
int x , y ; | ||
cin >> x >> y ; | ||
if(positive == negative) yes | ||
else if(positive > negative) { | ||
if(x > y) { | ||
int has_to_be_greater = negative * x ; | ||
int lesser = positive * y ; | ||
if(has_to_be_greater == lesser) { | ||
yes | ||
} | ||
else if(has_to_be_greater < lesser){ | ||
no | ||
} | ||
else{ | ||
int t = has_to_be_greater - lesser ; | ||
if((x + y) % t == 0){ | ||
yes | ||
}else{ | ||
no | ||
} | ||
} | ||
}else{ | ||
int has_to_be_greater = negative * y ; | ||
int lesser = positive * x ; | ||
if(has_to_be_greater == lesser) { | ||
yes | ||
} | ||
else if(has_to_be_greater < lesser){ | ||
no | ||
} | ||
else{ | ||
int t = has_to_be_greater - lesser ; | ||
if((x + y) % t == 0){ | ||
yes | ||
}else{ | ||
no | ||
} | ||
} | ||
} | ||
}else{ | ||
if(x > y) { | ||
int has_to_be_greater = positive * x ; | ||
int lesser = negative * y ; | ||
if(has_to_be_greater == lesser) { | ||
yes | ||
} | ||
else if(has_to_be_greater < lesser){ | ||
no | ||
} | ||
else{ | ||
int t = has_to_be_greater - lesser ; | ||
if((x + y) % t == 0){ | ||
yes | ||
}else{ | ||
no | ||
} | ||
} | ||
}else{ | ||
int has_to_be_greater = positive * y ; | ||
int lesser = negative * x ; | ||
if(has_to_be_greater == lesser) { | ||
yes | ||
} | ||
else if(has_to_be_greater < lesser){ | ||
no | ||
} | ||
else{ | ||
int t = has_to_be_greater - lesser ; | ||
if((x + y) % t == 0){ | ||
yes | ||
}else{ | ||
no | ||
} | ||
} | ||
} | ||
} | ||
} | ||
return true; | ||
} | ||
|
||
|
||
int32_t main() | ||
{ | ||
ios_base::sync_with_stdio(false); cin.tie(NULL); | ||
//#ifndef ONLINE_JUDGE | ||
// freopen("input.txt","r",stdin); | ||
// freopen("output.txt","w",stdout); | ||
// freopen("error.txt", "w", stder); | ||
//#endif | ||
int t = 1; | ||
//cin >> t; | ||
//int count = 1; | ||
|
||
while (t--){ | ||
//cout << "Case #" << count << ": "; | ||
if(solve()){ | ||
//count++; | ||
}else{ | ||
// cout << "NO" << endl; | ||
} | ||
} | ||
return 0; | ||
} | ||
|
||
|
||
|
||
|
||
|
1 change: 1 addition & 0 deletions
1
...Problem_Solving/L_Problems/L. Summation/.cph/.1.cpp_48f3b75b5686e739bc3e72c38b41f676.prob
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"name":"Local: 1","url":"c:\\Users\\varsh\\.vscode\\nayan work c c++\\Codeforces_Problem_Solving\\L_Problems\\L. Summation\\1.cpp","tests":[{"id":1686514812427,"input":"4\n1 4 2 7\n","output":""},{"id":1686514833132,"input":"4\n5 5 5 5","output":""}],"interactive":false,"memoryLimit":1024,"timeLimit":3000,"srcPath":"c:\\Users\\varsh\\.vscode\\nayan work c c++\\Codeforces_Problem_Solving\\L_Problems\\L. Summation\\1.cpp","group":"local","local":true} |
Binary file not shown.
116 changes: 116 additions & 0 deletions
116
Codeforces_Problem_Solving/L_Problems/L. Summation/1.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
#include<bits/stdc++.h> | ||
using namespace std; | ||
|
||
// Policy based data structures(PBDS) C++ STL | ||
// order_of_key(k): returns count of elements strictly smaller than k | ||
// find_by_order(k): returns the iterator of the k-th element in a set (0-index) | ||
// Time complexity: O(logn) for both | ||
#include <ext/pb_ds/assoc_container.hpp> | ||
#include <ext/pb_ds/tree_policy.hpp> | ||
using namespace __gnu_pbds; | ||
template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; | ||
template <class K, class V> using ordered_map = tree<K, V, less<K>, rb_tree_tag, tree_order_statistics_node_update>; | ||
|
||
#ifndef ONLINE_JUDGE | ||
#define debug(x) cerr << #x <<" "; _print(x); cerr << endl; | ||
#else | ||
#define debug(x) | ||
#endif | ||
|
||
void _print(long long t) {cerr << t;} | ||
void _print(string t) {cerr << t;} | ||
void _print(char t) {cerr << t;} | ||
void _print(long double t) {cerr << t;} | ||
|
||
template <class T, class V> void _print(pair <T, V> p) {cerr << "{"; _print(p.first); cerr << ","; _print(p.second); cerr << "}";} | ||
template <class T> void _print(vector <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} | ||
template <class T> void _print(set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} | ||
template <class T> void _print(multiset <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} | ||
template <class T, class V> void _print(map <T, V> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";} | ||
|
||
#define ll long long | ||
#define int ll | ||
#define ld long double | ||
#define iv(a , n) vector<int>a(n); for(int i=0;i<n;++i){cin>>a[i];} | ||
#define yes cout << "YES" << endl; | ||
#define no cout << "NO" << endl; | ||
#define all(v) v.begin(),v.end() | ||
#define F first | ||
#define S second | ||
#define check1(v) for(auto &i : v){ cout<<i<<" "; } cout<<endl; | ||
#define check2(v) for(auto &i : v){ cout<<i.F<<" "<<i.S<<endl; } | ||
#define check3(v) for(auto &i : v){ cout<<i.F.F<<" "<<i.F.S<<" "<<i.S<<endl; } | ||
#define check4(v) for(auto &i : v){ cout<<i.F.F<<" "<<i.F.S<<" "<<i.S.F<<" "<<i.S.S<<endl; } | ||
#define pb push_back | ||
#define lb lower_bound | ||
#define ub upper_bound | ||
#define bpp __builtin_popcountll | ||
#define INF 1000000000000000000 | ||
#define Pi 3.1415926535897932384626 | ||
#define EPS 1e-9 | ||
#define nl "\n" | ||
|
||
const int mod97 = 1000000007 ; | ||
const int modg = 998244353 ; | ||
const int N = 2e1 + 10 ; | ||
int SPF[N] ; | ||
vector<bool> isPrime(N , 1) ; | ||
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()) ; // a random number generator (RNG) using the Mersenne Twister algorithm, specifically the mt19937 engine. The purpose of an RNG is to generate a sequence of random numbers. | ||
|
||
int gcd(int a, int b){if(b == 0){return a;} return gcd(b, a % b);} | ||
int lcm(int a, int b){return (a / gcd(a, b) * b) ;} | ||
bool comparatorfunction(pair<int,int> &a, pair<int,int> &b){if(a.S != b.S){return a.S < b.S ;}return a.F > b.F ;} | ||
int power(int x, int y){int res = 1 ; while(y > 0) {if(y & 1) res = (res * x) ; x = (x * x) ; y = y >> 1 ;} return res ;} | ||
int powermod(int x, int y){int res = 1; x = x % mod97; while(y > 0){if(y&1) res = (res * x) % mod97; y = y >> 1; x = (x * x) % mod97 ;}return res ;} | ||
bool isPowerOfTwo(int n){if(n==0) {return false;} return (ceil(log2(n)) == floor(log2(n)));} | ||
void prime(){isPrime[0]=isPrime[1]=false;for(int i = 2; i <= N; ++i){if(isPrime[i] == true){for(int j = 2*i; j <= N; j += i){isPrime[j] = false;}}}} | ||
void spf(){for(int i = 0; i <= N; ++i) SPF[i] = i; for(int i = 2; i <= N; ++i) if(SPF[i] == i) for(int j = i; j <= N; j += i) if(SPF[j] == j) SPF[j] = i;} // SPF is the smallest prime number that divides a given number without leaving a remainder | ||
int isqrt(int n){long long x = sqrtl(n);while (x*x>n){--x;} while((x+1) * (x+1)<=n){++x;}return x;} | ||
int sqrtprecision(int l,int r,int target){while(r-l>EPS){int mid=(l+(r-l)/2);if(mid*mid<target)l=mid;else r=mid;}return l+(r-l)/2;} | ||
int errichtokabinary(int l,int r,vector<int>&a,int target){int ans=-1; while(l <= r){int mid=(l+(r-l)/2); if(a[mid]==target){ans=mid;return ans;}if(a[mid]<target)l=mid+1;else r=mid-1;}return ans;} | ||
void ncrwithoutmod(int n, int r){long long p = 1, k = 1; if (n-r < r) r = n-r; if (r != 0) {while (r) {p *= n; k *= r; long long m = __gcd(p, k);p /= m; k /= m; n--; r--; }} else cout << p << endl; } | ||
int getRandomNumber(int l, int r) {return uniform_int_distribution<int>(l, r)(rng);} | ||
|
||
bool solve(){ | ||
int n ; | ||
cin >> n ; | ||
iv(v , n) | ||
int sum = 0 ; | ||
function<void(int) > f = [&](int i) -> void { | ||
if(i == n) return ; | ||
f(i + 1) ; | ||
sum += v[i] ; | ||
}; | ||
f(0) ; | ||
cout << sum << nl ; | ||
return true; | ||
} | ||
|
||
|
||
int32_t main() | ||
{ | ||
ios_base::sync_with_stdio(false); cin.tie(NULL); | ||
//#ifndef ONLINE_JUDGE | ||
// freopen("input.txt","r",stdin); | ||
// freopen("output.txt","w",stdout); | ||
// freopen("error.txt", "w", stderr); | ||
//#endif | ||
int t = 1; | ||
//cin >> t; | ||
//int count = 1; | ||
|
||
while (t--){ | ||
//cout << "Case #" << count << ": "; | ||
if(solve()){ | ||
//count++; | ||
}else{ | ||
// cout << "NO" << endl; | ||
} | ||
} | ||
return 0; | ||
} | ||
|
||
|
||
|
||
|
||
|
1 change: 1 addition & 0 deletions
1
...roblem_Solving/M_Problems/M. Suffix Sum/.cph/.1.cpp_024aeebff1cc7492bde85f24155ada66.prob
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"name":"Local: 1","url":"c:\\Users\\varsh\\.vscode\\nayan work c c++\\Codeforces_Problem_Solving\\M_Problems\\M. Suffix Sum\\1.cpp","tests":[{"id":1686664797328,"input":"5 3\n1 8 2 10 3\n","output":"15\n"}],"interactive":false,"memoryLimit":1024,"timeLimit":3000,"srcPath":"c:\\Users\\varsh\\.vscode\\nayan work c c++\\Codeforces_Problem_Solving\\M_Problems\\M. Suffix Sum\\1.cpp","group":"local","local":true} |
Binary file not shown.
Oops, something went wrong.