Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated directory with some new solutions #640

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions CODECHEF EASY/August Long One 2022 (AUG221B)/HLEQN.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//Author: Akash Gautam (@geekblower)
//Date: 13-08-2022
#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define TEST_CASES create(t);while(t--)
#define SOLUTION solve(); return 0;
#define display(n) cout<<n<<endl;
#define VI vector<int>
#define PB push_back
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define loop(i,a,b,c) for(int i=a;i<b;i+=c)
#define revloop(i,a,b,c) for(int i=a;i>=b;i-=c)
#define start_loop loop(i,0,n,1)
#define start_revloop revloop(i,n,0,1)
#define create(n) int n;cin>>n;
#define def(a,n) int a[n];start_loop cin>>a[i];
#define print(a) for(auto i:a){cout<<i<<" ";}cout<<endl;
#define vector(a,n) VI a;loop(i,0,n,1){int x;cin>>x;a.PB(x);}
inline int GCD(int a,int b){return !b?a:GCD(b,a%b);}
const int MOD = 1000000007;

void solve() {
create(x)

for(int i=1; i*i<=x; i++) {
if(((x - 2*i) % (i+2) == 0) && (x != 2*i)) {
display("YES")
return;
}
}

display("NO")
}

int32_t main() {
GEEKBLOWER
TEST_CASES
SOLUTION
}
80 changes: 80 additions & 0 deletions CODECHEF EASY/August Long One 2022 (AUG221B)/SMALLXOR.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
//Author: Akash Gautam (@geekblower)
//Date: 14-08-2022
#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define TEST_CASES create(t);while(t--)
#define SOLUTION solve(); return 0;
#define display(n) cout<<n<<endl;
#define VI vector<int>
#define PB push_back
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define loop(i,a,b,c) for(int i=a;i<b;i+=c)
#define revloop(i,a,b,c) for(int i=a;i>=b;i-=c)
#define start_loop loop(i,0,n,1)
#define start_revloop revloop(i,n,0,1)
#define create(n) int n;cin>>n;
#define def(a,n) int a[n];start_loop cin>>a[i];
#define print(a) for(auto i : a){cout<<i<<" ";}cout<<endl;
#define vector(a,n) VI a;loop(i,0,n,1){int x;cin>>x;a.PB(x);}
inline int GCD(int a,int b){return !b?a:GCD(b,a%b);}
const int MOD = 1000000007;

priority_queue<pair<int,int>> p,nul;
map<int,vector<int>> k;

void otto() {
while(!p.empty()) {
cout<<-p.top().first<<' ';
p.pop();
}
cout << endl;
}

void solve() {
p = nul;
k.clear();

create(n)
create(x)
create(y)

loop(i, 1, n+1, 1) {
create(t)
p.push({-t,i});
}

loop(i, 1, y+1, 1) {
pair<int,int> _= {-((-p.top().first) ^ x), p.top().second};
k[p.top().second].push_back (i);

if(k[p.top().second].size() == 4) {
int s = k[p.top().second][3] - k[p.top().second][1];
i += (y-i) / s*s;

for(; i<=y; i++) {
pair<int,int> t = {-((-p.top().first) ^ x), p.top().second};
p.pop();
p.push (t);
}

otto();
return;
}

p.pop();
p.push (_);
}

otto();
}

int32_t main() {
GEEKBLOWER
TEST_CASES
SOLUTION
}
62 changes: 62 additions & 0 deletions CODECHEF EASY/August Long One 2022 (AUG221B)/TWOTRAINS.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
//Author: Akash Gautam (@geekblower)
//Date: 13-08-2022
#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define TEST_CASES create(t);while(t--)
#define SOLUTION solve(); return 0;
#define display(n) cout<<n<<endl;
#define VI vector<int>
#define PB push_back
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define loop(i,a,b,c) for(int i=a;i<b;i+=c)
#define revloop(i,a,b,c) for(int i=a;i>=b;i-=c)
#define start_loop loop(i,0,n,1)
#define start_revloop revloop(i,n,0,1)
#define create(n) int n;cin>>n;
#define def(a,n) int a[n];start_loop cin>>a[i];
#define print(a) for(auto i:a){cout<<i<<" ";}cout<<endl;
#define vector(a,n) VI a;loop(i,0,n,1){int x;cin>>x;a.PB(x);}
inline int GCD(int a,int b){return !b?a:GCD(b,a%b);}
const int MOD = 1000000007;

void solve() {
create(n)

int *arr1 = new int[n];
int *arr2 = new int[n];

arr1[0] = 0;
arr2[0] = 0;

loop(i, 1, n, 1) {
cin>>arr1[i];
}

int sum = 0;
loop(i, 1, n, 1) {
sum += arr1[i];
arr2[i] = arr1[i];
arr1[i] = sum;
}

loop(i, 0, n-1, 1) {
if(arr1[i+1] - arr2[i] > 0) {
arr2[i+1] = arr1[i+1] + arr2[i+1];
} else {
arr2[i+1] = arr2[i] + arr2[i+1];
}
}

display(arr2[n-1])
}

int32_t main() {
GEEKBLOWER
TEST_CASES
SOLUTION
}
44 changes: 44 additions & 0 deletions CODECHEF EASY/July Long One 2022 (JULY221D)/AUCTION.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//Author: Akash Gautam (@geekblower)
//Date: 09-07-2022
#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define TEST_CASES create(t);while(t--)
#define SOLUTION solve(); return 0;
#define display(n) cout<<n<<endl;
#define VI vector<int>
#define PB push_back
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define loop(i,a,b,c) for(int i=a;i<b;i+=c)
#define revloop(i,a,b,c) for(int i=a;i>=b;i-=c)
#define start_loop loop(i,0,n,1)
#define start_revloop revloop(i,n,0,1)
#define create(n) int n;cin>>n;
#define def(a,n) int a[n];start_loop cin>>a[i];
#define print(a) for(auto i : a){cout<<i<<" ";}cout<<endl;
#define vector(a,n) VI a;loop(i,0,m,1){int x;cin>>x;a.PB(x);}
inline int GCD(int a,int b){return !b?a:GCD(b,a%b);}
const int MOD = 1000000007;

void solve() {
create(a)
create(b)
create(c)

if(a>b && a>c)
display("Alice")
else if(b>c)
display("Bob")
else
display("Charlie")
}

int32_t main() {
GEEKBLOWER
TEST_CASES
SOLUTION
}
46 changes: 46 additions & 0 deletions CODECHEF EASY/July Long One 2022 (JULY221D)/CHEFCAND.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//Author: Akash Gautam (@geekblower)
//Date: 09-07-2022
#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define TEST_CASES create(t);while(t--)
#define SOLUTION solve(); return 0;
#define display(n) cout<<n<<endl;
#define VI vector<int>
#define PB push_back
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define loop(i,a,b,c) for(int i=a;i<b;i+=c)
#define revloop(i,a,b,c) for(int i=a;i>=b;i-=c)
#define start_loop loop(i,0,n,1)
#define start_revloop revloop(i,n,0,1)
#define create(n) int n;cin>>n;
#define def(a,n) int a[n];start_loop cin>>a[i];
#define print(a) for(auto i : a){cout<<i<<" ";}cout<<endl;
#define vector(a,n) VI a;loop(i,0,m,1){int x;cin>>x;a.PB(x);}
inline int GCD(int a,int b){return !b?a:GCD(b,a%b);}
const int MOD = 1000000007;

void solve() {
create(n)
create(x)

if(x>=n)
display("0")
else {
int tot = (n-x);
if(tot%4==0)
display(tot/4)
else
display(tot/4+1)
}
}

int32_t main() {
GEEKBLOWER
TEST_CASES
SOLUTION
}
46 changes: 46 additions & 0 deletions CODECHEF EASY/July Long One 2022 (JULY221D)/GAMEOFPILES1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//Author: Akash Gautam (@geekblower)
//Date: 10-07-2022
#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define TEST_CASES create(t);while(t--)
#define SOLUTION solve(); return 0;
#define display(n) cout<<n<<endl;
#define VI vector<int>
#define PB push_back
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define loop(i,a,b,c) for(int i=a;i<b;i+=c)
#define revloop(i,a,b,c) for(int i=a;i>=b;i-=c)
#define start_loop loop(i,0,n,1)
#define start_revloop revloop(i,n,0,1)
#define create(n) int n;cin>>n;
#define def(a,n) int a[n];start_loop cin>>a[i];
#define print(a) for(auto i : a){cout<<i<<" ";}cout<<endl;
#define vector(a,n) VI a;loop(i,0,m,1){int x;cin>>x;a.PB(x);}
inline int GCD(int a,int b){return !b?a:GCD(b,a%b);}
const int MOD = 1000000007;

void solve() {
create(n)
def(arr, n)

sort(arr, arr+n);
int odd = 0;
start_loop
odd = (arr[i]&1) ? odd+1 : odd;

if(odd&1 || arr[0]==1)
display("CHEF")
else
display("CHEFINA")
}

int32_t main() {
GEEKBLOWER
TEST_CASES
SOLUTION
}
48 changes: 48 additions & 0 deletions CODECHEF EASY/July Long One 2022 (JULY221D)/KNIGHT2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//Author: Akash Gautam (@geekblower)
//Date: 10-07-2022
#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define GEEKBLOWER ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define TEST_CASES create(t);while(t--)
#define SOLUTION solve(); return 0;
#define display(n) cout<<n<<endl;
#define VI vector<int>
#define PB push_back
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define loop(i,a,b,c) for(int i=a;i<b;i+=c)
#define revloop(i,a,b,c) for(int i=a;i>=b;i-=c)
#define start_loop loop(i,0,n,1)
#define start_revloop revloop(i,n,0,1)
#define create(n) int n;cin>>n;
#define def(a,n) int a[n];start_loop cin>>a[i];
#define print(a) for(auto i : a){cout<<i<<" ";}cout<<endl;
#define vector(a,n) VI a;loop(i,0,m,1){int x;cin>>x;a.PB(x);}
inline int GCD(int a,int b){return !b?a:GCD(b,a%b);}
const int MOD = 1000000007;

void solve() {
create(x1)
create(y1)
create(x2)
create(y2)

int diff1 = abs(x1-x2);
int diff2 = abs(y1-y2);

if(diff1&1 && diff2&1)
display("YES")
else if(diff1%2==0 && diff2%2==0)
display("YES")
else
display("NO")
}

int32_t main() {
GEEKBLOWER
TEST_CASES
SOLUTION
}
Loading