feat: Add solutions for Codeforces problems 1999 A, B, C, and D
This commit is contained in:
parent
3a67a13275
commit
5f2e72a8f3
41
Codes/1999 A - A+B Again/1999A.cpp
Normal file
41
Codes/1999 A - A+B Again/1999A.cpp
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
#include <bits/stdc++.h>
|
||||||
|
using namespace std;
|
||||||
|
#ifdef ONLINE_JUDGE
|
||||||
|
#define dbg(...)
|
||||||
|
#else
|
||||||
|
#include "Assets/debug.h"
|
||||||
|
#endif
|
||||||
|
#define int long long
|
||||||
|
#define ll long long
|
||||||
|
#define endl '\n'
|
||||||
|
#define ff first
|
||||||
|
#define ss second
|
||||||
|
#define ins insert
|
||||||
|
#define pb push_back
|
||||||
|
#define ppb pop_back
|
||||||
|
#define sz(x) (int)(x).size()
|
||||||
|
#define all(x) x.begin(), x.end()
|
||||||
|
#define rep(i,a,b) for(int i=a; i<b; ++i)
|
||||||
|
#define rrep(i,a,b) for(int i=a; i>=b; --i)
|
||||||
|
#define yn(f) f? cout<<"YES\n":cout<<"NO\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()
|
||||||
|
{
|
||||||
|
string s;
|
||||||
|
cin>>s;
|
||||||
|
cout<<s[1]+s[0]-'0'-'0'<<endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
signed main()
|
||||||
|
{
|
||||||
|
FAST;
|
||||||
|
int TCS = 1;
|
||||||
|
cin >> TCS;
|
||||||
|
for (int TC = 1; TC <= TCS; ++TC)
|
||||||
|
{
|
||||||
|
// cout<<"Case "<<TC<<": ";
|
||||||
|
solve();
|
||||||
|
}
|
||||||
|
}
|
74
Codes/1999 B - Card Game/1999B.cpp
Normal file
74
Codes/1999 B - Card Game/1999B.cpp
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
#include <bits/stdc++.h>
|
||||||
|
using namespace std;
|
||||||
|
#ifdef ONLINE_JUDGE
|
||||||
|
#define dbg(...)
|
||||||
|
#else
|
||||||
|
#include "Assets/debug.h"
|
||||||
|
#endif
|
||||||
|
#define int long long
|
||||||
|
#define ll long long
|
||||||
|
#define endl '\n'
|
||||||
|
#define ff first
|
||||||
|
#define ss second
|
||||||
|
#define ins insert
|
||||||
|
#define pb push_back
|
||||||
|
#define ppb pop_back
|
||||||
|
#define sz(x) (int)(x).size()
|
||||||
|
#define all(x) x.begin(), x.end()
|
||||||
|
#define rep(i,a,b) for(int i=a; i<b; ++i)
|
||||||
|
#define rrep(i,a,b) for(int i=a; i>=b; --i)
|
||||||
|
#define yn(f) f? cout<<"YES\n":cout<<"NO\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()
|
||||||
|
{
|
||||||
|
int a,b,c,d;
|
||||||
|
cin>>a>>b>>c>>d;
|
||||||
|
int ans=0;
|
||||||
|
if(a>c)
|
||||||
|
{
|
||||||
|
if(b>=d) ans++;
|
||||||
|
}
|
||||||
|
if(a==c)
|
||||||
|
{
|
||||||
|
if(b>d) ans++;
|
||||||
|
}
|
||||||
|
if(a>d)
|
||||||
|
{
|
||||||
|
if(b>=c) ans++;
|
||||||
|
}
|
||||||
|
if(a==d)
|
||||||
|
{
|
||||||
|
if(b>c) ans++;
|
||||||
|
}
|
||||||
|
if(b>c)
|
||||||
|
{
|
||||||
|
if(a>=d) ans++;
|
||||||
|
}
|
||||||
|
if(b==c)
|
||||||
|
{
|
||||||
|
if(a>d) ans++;
|
||||||
|
}
|
||||||
|
if(b>d)
|
||||||
|
{
|
||||||
|
if(a>=c) ans++;
|
||||||
|
}
|
||||||
|
if(b==d)
|
||||||
|
{
|
||||||
|
if(a>c) ans++;
|
||||||
|
}
|
||||||
|
cout<<ans<<endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
signed main()
|
||||||
|
{
|
||||||
|
FAST;
|
||||||
|
int TCS = 1;
|
||||||
|
cin >> TCS;
|
||||||
|
for (int TC = 1; TC <= TCS; ++TC)
|
||||||
|
{
|
||||||
|
// cout<<"Case "<<TC<<": ";
|
||||||
|
solve();
|
||||||
|
}
|
||||||
|
}
|
53
Codes/1999 C - Showering/1999C.cpp
Normal file
53
Codes/1999 C - Showering/1999C.cpp
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
#include <bits/stdc++.h>
|
||||||
|
using namespace std;
|
||||||
|
#ifdef ONLINE_JUDGE
|
||||||
|
#define dbg(...)
|
||||||
|
#else
|
||||||
|
#include "Assets/debug.h"
|
||||||
|
#endif
|
||||||
|
#define int long long
|
||||||
|
#define ll long long
|
||||||
|
#define endl '\n'
|
||||||
|
#define ff first
|
||||||
|
#define ss second
|
||||||
|
#define ins insert
|
||||||
|
#define pb push_back
|
||||||
|
#define ppb pop_back
|
||||||
|
#define sz(x) (int)(x).size()
|
||||||
|
#define all(x) x.begin(), x.end()
|
||||||
|
#define rep(i,a,b) for(int i=a; i<b; ++i)
|
||||||
|
#define rrep(i,a,b) for(int i=a; i>=b; --i)
|
||||||
|
#define yn(f) f? cout<<"YES\n":cout<<"NO\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()
|
||||||
|
{
|
||||||
|
int n,s,m;
|
||||||
|
cin>>n>>s>>m;
|
||||||
|
int last=0,f=0;
|
||||||
|
while(n--)
|
||||||
|
{
|
||||||
|
int l,r;
|
||||||
|
cin>>l>>r;
|
||||||
|
int t=l-last;
|
||||||
|
dbg(l,r,last,t,s);
|
||||||
|
last=r;
|
||||||
|
if(t>=s) f=1;
|
||||||
|
}
|
||||||
|
if(m-last>=s) f=1;
|
||||||
|
yn(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
signed main()
|
||||||
|
{
|
||||||
|
FAST;
|
||||||
|
int TCS = 1;
|
||||||
|
cin >> TCS;
|
||||||
|
for (int TC = 1; TC <= TCS; ++TC)
|
||||||
|
{
|
||||||
|
// cout<<"Case "<<TC<<": ";
|
||||||
|
dbg(TC);
|
||||||
|
solve();
|
||||||
|
}
|
||||||
|
}
|
59
Codes/1999 D - Slavic's Exam/1999D.cpp
Normal file
59
Codes/1999 D - Slavic's Exam/1999D.cpp
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
#include <bits/stdc++.h>
|
||||||
|
using namespace std;
|
||||||
|
#ifdef ONLINE_JUDGE
|
||||||
|
#define dbg(...)
|
||||||
|
#else
|
||||||
|
#include "Assets/debug.h"
|
||||||
|
#endif
|
||||||
|
#define int long long
|
||||||
|
#define ll long long
|
||||||
|
#define endl '\n'
|
||||||
|
#define ff first
|
||||||
|
#define ss second
|
||||||
|
#define ins insert
|
||||||
|
#define pb push_back
|
||||||
|
#define ppb pop_back
|
||||||
|
#define sz(x) (int)(x).size()
|
||||||
|
#define all(x) x.begin(), x.end()
|
||||||
|
#define rep(i,a,b) for(int i=a; i<b; ++i)
|
||||||
|
#define rrep(i,a,b) for(int i=a; i>=b; --i)
|
||||||
|
#define yn(f) f? cout<<"YES\n":cout<<"NO\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()
|
||||||
|
{
|
||||||
|
string s,t;
|
||||||
|
cin>>s>>t;
|
||||||
|
int i=0, j=0;
|
||||||
|
for(; i<sz(s) && j<sz(t); i++)
|
||||||
|
{
|
||||||
|
dbg(s[i], t[j]);
|
||||||
|
if(s[i]==t[j]) j++;
|
||||||
|
else if(s[i]=='?') s[i]=t[j++];
|
||||||
|
dbg(s,t);
|
||||||
|
}
|
||||||
|
while(i<sz(s))
|
||||||
|
{
|
||||||
|
if(s[i]=='?') s[i]='a';
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
if(j==sz(t))
|
||||||
|
{
|
||||||
|
yn(1);
|
||||||
|
cout<<s<<endl;
|
||||||
|
}
|
||||||
|
else yn(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
signed main()
|
||||||
|
{
|
||||||
|
FAST;
|
||||||
|
int TCS = 1;
|
||||||
|
cin >> TCS;
|
||||||
|
for (int TC = 1; TC <= TCS; ++TC)
|
||||||
|
{
|
||||||
|
// cout<<"Case "<<TC<<": ";
|
||||||
|
solve();
|
||||||
|
}
|
||||||
|
}
|
@ -383,6 +383,10 @@ This repository contains my solutions of Codeforces problems. They are in C++ la
|
|||||||
| 371 | 1997 B | Make Three Regions | [Question](https://codeforces.com/problemset/problem/1997/B) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1997%20B%20-%20Make%20Three%20Regions)
|
| 371 | 1997 B | Make Three Regions | [Question](https://codeforces.com/problemset/problem/1997/B) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1997%20B%20-%20Make%20Three%20Regions)
|
||||||
| 372 | 1997 C | Even Positions | [Question](https://codeforces.com/problemset/problem/1997/C) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1997%20C%20-%20Even%20Positions)
|
| 372 | 1997 C | Even Positions | [Question](https://codeforces.com/problemset/problem/1997/C) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1997%20C%20-%20Even%20Positions)
|
||||||
| 373 | 1997 D | Maximize the Root | [Question](https://codeforces.com/problemset/problem/1997/D) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1997%20D%20-%20Maximize%20the%20Root)
|
| 373 | 1997 D | Maximize the Root | [Question](https://codeforces.com/problemset/problem/1997/D) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1997%20D%20-%20Maximize%20the%20Root)
|
||||||
|
| 374 | 1999 A | A+B Again | [Question](https://codeforces.com/problemset/problem/1999/A) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1999%20A%20-%20A+B%20Again)
|
||||||
|
| 375 | 1999 B | Card Game | [Question](https://codeforces.com/problemset/problem/1999/B) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1999%20B%20-%20Card%20Game)
|
||||||
|
| 376 | 1999 C | Showering | [Question](https://codeforces.com/problemset/problem/1999/C) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1999%20C%20-%20Showering)
|
||||||
|
| 377 | 1999 D | Slavic's Exam | [Question](https://codeforces.com/problemset/problem/1999/D) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1999%20D%20-%20Slavic's%20Exam)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user