added many
This commit is contained in:
parent
ba04e7f6da
commit
9171403d0c
106
1296A Array with Odd Sum/1296A.cpp
Normal file
106
1296A Array with Odd Sum/1296A.cpp
Normal file
@ -0,0 +1,106 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
|
||||
// Short forms
|
||||
#define int long long
|
||||
#define ll long long
|
||||
#define lld long double
|
||||
#define ull unsigned long long
|
||||
#define endl '\n'
|
||||
#define ff first
|
||||
#define ss second
|
||||
#define all(x) x.begin(), x.end()
|
||||
#define sz(x) (int)(x).size()
|
||||
#define pb push_back
|
||||
#define ppb pop_back
|
||||
#define mp make_pair
|
||||
#define ins insert
|
||||
#define fr(i, a, b) for(int i=a; i<b; ++i)
|
||||
#define fn(i, n) for(int i=0; i<n; ++i)
|
||||
#define rf(i, a, b) for(int i=a; i>b; --i)
|
||||
#define nf(i, n) for(int i=n-1; i>=0; --i)
|
||||
|
||||
// STLs
|
||||
#define PII pair<int, int>
|
||||
#define VI vector<int>
|
||||
#define VVI vector<vector<int>>
|
||||
#define SI set<int>
|
||||
#define SC set<char>
|
||||
#define MII map<int,int>
|
||||
#define VLL vector<ll>
|
||||
#define VVL vector<vector<ll>>
|
||||
#define SL set<ll>
|
||||
|
||||
// Outputs
|
||||
#define yes cout<<"YES"<<endl
|
||||
#define no cout<<"NO"<<endl
|
||||
|
||||
// Constants
|
||||
#define PI 3.141592653589793238
|
||||
#define INF LONG_LONG_MAX
|
||||
#define MOD 1e9+7
|
||||
|
||||
// Faster Input Output
|
||||
#define FAST_IO (ios_base:: sync_with_stdio(false),cin.tie(NULL));
|
||||
|
||||
// Maths
|
||||
ll fact(ll n) { if(n==0) return 1; ll res = 1; for (ll i = 2; i <= n; i++) res = res * i; return res; }
|
||||
ll nPr(ll n, ll r) { return fact(n) / fact(n - r); }
|
||||
ll nCr(ll n, ll r) { return fact(n) / (fact(r) * fact(n - r)); }
|
||||
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
|
||||
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b);}
|
||||
ll mypow(ll a, ll b) { ll ans = 1; while(b){ if (b&1) ans = (ans*a) ; b /= 2; a = (a*a); } return ans; }
|
||||
bool isPrime(ll n) { if(n <= 1) return false; for(ll i = 2; i <= sqrt(n); i++) if(n % i == 0) return false; return true; }
|
||||
|
||||
//Debugging
|
||||
#ifndef ONLINE_JUDGE
|
||||
#define dbg(x) cerr << #x <<" "; _print(x); cerr << endl;
|
||||
#define dbgin(x) cerr << #x <<" "; _print(x); cerr << ";"<<endl;
|
||||
#else
|
||||
#define dbg(x)
|
||||
#define dbgin(x)
|
||||
#endif
|
||||
|
||||
void _print(int t) {cerr << t;}void _print(string t) {cerr << t;}void _print(char t) {cerr << t;}
|
||||
void _print(lld t) {cerr << t;}void _print(double t) {cerr << t;}void _print(ull t) {cerr << t;}
|
||||
template <class T, class V> void _print(pair <T, V> p);
|
||||
template <class T> void _print(vector <T> v);template <class T> void _print(set <T> v);
|
||||
template <class T, class V> void _print(map <T, V> v);template <class T> void _print(multiset <T> v);
|
||||
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 << "]";}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void solve()
|
||||
{
|
||||
int n;
|
||||
cin>>n;
|
||||
int odd=0, even=0;
|
||||
fn(i,n)
|
||||
{
|
||||
int x;
|
||||
cin>>x;
|
||||
if(x&1)
|
||||
odd++;
|
||||
else
|
||||
even++;
|
||||
}
|
||||
if(odd==0)
|
||||
no;
|
||||
else if(even==0 && n%2==0)
|
||||
no;
|
||||
else
|
||||
yes;
|
||||
}
|
||||
|
||||
int32_t main()
|
||||
{
|
||||
FAST_IO;
|
||||
int TC = 1;
|
||||
cin >> TC;
|
||||
while (TC--) solve();
|
||||
}
|
79
1833A Musical Puzzle/1833A.cpp
Normal file
79
1833A Musical Puzzle/1833A.cpp
Normal file
@ -0,0 +1,79 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
|
||||
// Short forms
|
||||
#define int long long
|
||||
#define ll long long
|
||||
#define endl '\n'
|
||||
#define ff first
|
||||
#define ss second
|
||||
#define pb push_back
|
||||
#define all(x) x.begin(), x.end()
|
||||
#define sz(x) (int)(x).size()
|
||||
|
||||
// Outputs
|
||||
#define yes cout<<"YES"<<endl
|
||||
#define no cout<<"NO"<<endl
|
||||
|
||||
// Constants
|
||||
#define PI 3.141592653589793238
|
||||
#define INF LONG_LONG_MAX
|
||||
#define MOD 1e9+7
|
||||
|
||||
// Faster Input Output
|
||||
#define FAST_IO (ios_base:: sync_with_stdio(false),cin.tie(NULL));
|
||||
|
||||
// Maths
|
||||
ll fact(ll n) { if(n==0) return 1; ll res = 1; for (ll i = 2; i <= n; i++) res = res * i; return res; }
|
||||
ll nPr(ll n, ll r) { return fact(n) / fact(n - r); }
|
||||
ll nCr(ll n, ll r) { return fact(n) / (fact(r) * fact(n - r)); }
|
||||
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
|
||||
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b);}
|
||||
ll mypow(ll a, ll b) { ll ans = 1; while(b){ if (b&1) ans = (ans*a) ; b /= 2; a = (a*a); } return ans; }
|
||||
bool isPrime(ll n) { if(n <= 1) return false; for(ll i = 2; i <= sqrt(n); i++) if(n % i == 0) return false; return true; }
|
||||
|
||||
//Debugging
|
||||
#ifndef ONLINE_JUDGE
|
||||
#define dbg(x) cerr << #x <<" "; _print(x); cerr << endl;
|
||||
#define dbgin(x) cerr << #x <<" "; _print(x); cerr << ";"<<endl;
|
||||
#else
|
||||
#define dbg(x)
|
||||
#define dbgin(x)
|
||||
#endif
|
||||
|
||||
void _print(int t) {cerr << t;}void _print(string t) {cerr << t;}void _print(char t) {cerr << t;}
|
||||
void _print(long double t) {cerr << t;}void _print(double t) {cerr << t;}void _print(unsigned ll t) {cerr << t;}
|
||||
template <class T, class V> void _print(pair <T, V> p);
|
||||
template <class T> void _print(vector <T> v);template <class T> void _print(set <T> v);
|
||||
template <class T, class V> void _print(map <T, V> v);template <class T> void _print(multiset <T> v);
|
||||
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 << "]";}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void solve()
|
||||
{
|
||||
int n;
|
||||
string s;
|
||||
cin>>n>>s;
|
||||
set<string>st;
|
||||
for(int i=0; i<n-1; ++i)
|
||||
{
|
||||
string str=s.substr(i,2);
|
||||
st.insert(str);
|
||||
}
|
||||
cout<<st.size()<<endl;
|
||||
}
|
||||
|
||||
int32_t main()
|
||||
{
|
||||
FAST_IO;
|
||||
int TC = 1;
|
||||
cin >> TC;
|
||||
while (TC--)
|
||||
solve();
|
||||
}
|
90
1833B Restore the Weather/1833B.cpp
Normal file
90
1833B Restore the Weather/1833B.cpp
Normal file
@ -0,0 +1,90 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
|
||||
// Short forms
|
||||
#define int long long
|
||||
#define ll long long
|
||||
#define endl '\n'
|
||||
#define ff first
|
||||
#define ss second
|
||||
#define pb push_back
|
||||
#define all(x) x.begin(), x.end()
|
||||
#define sz(x) (int)(x).size()
|
||||
|
||||
// Outputs
|
||||
#define yes cout<<"YES"<<endl
|
||||
#define no cout<<"NO"<<endl
|
||||
|
||||
// Constants
|
||||
#define PI 3.141592653589793238
|
||||
#define INF LONG_LONG_MAX
|
||||
#define MOD 1e9+7
|
||||
|
||||
// Faster Input Output
|
||||
#define FAST_IO (ios_base:: sync_with_stdio(false),cin.tie(NULL));
|
||||
|
||||
// Maths
|
||||
ll fact(ll n) { if(n==0) return 1; ll res = 1; for (ll i = 2; i <= n; i++) res = res * i; return res; }
|
||||
ll nPr(ll n, ll r) { return fact(n) / fact(n - r); }
|
||||
ll nCr(ll n, ll r) { return fact(n) / (fact(r) * fact(n - r)); }
|
||||
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
|
||||
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b);}
|
||||
ll mypow(ll a, ll b) { ll ans = 1; while(b){ if (b&1) ans = (ans*a) ; b /= 2; a = (a*a); } return ans; }
|
||||
bool isPrime(ll n) { if(n <= 1) return false; for(ll i = 2; i <= sqrt(n); i++) if(n % i == 0) return false; return true; }
|
||||
|
||||
//Debugging
|
||||
#ifndef ONLINE_JUDGE
|
||||
#define dbg(x) cerr << #x <<" "; _print(x); cerr << endl;
|
||||
#define dbgin(x) cerr << #x <<" "; _print(x); cerr << ";"<<endl;
|
||||
#else
|
||||
#define dbg(x)
|
||||
#define dbgin(x)
|
||||
#endif
|
||||
|
||||
void _print(int t) {cerr << t;}void _print(string t) {cerr << t;}void _print(char t) {cerr << t;}
|
||||
void _print(long double t) {cerr << t;}void _print(double t) {cerr << t;}void _print(unsigned ll t) {cerr << t;}
|
||||
template <class T, class V> void _print(pair <T, V> p);
|
||||
template <class T> void _print(vector <T> v);template <class T> void _print(set <T> v);
|
||||
template <class T, class V> void _print(map <T, V> v);template <class T> void _print(multiset <T> v);
|
||||
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 << "]";}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void solve()
|
||||
{
|
||||
int n,k;
|
||||
cin>>n>>k;
|
||||
vector<pair<int,int>>a;
|
||||
vector<int>b(n),c(n);
|
||||
for(int i=0; i<n; ++i)
|
||||
{
|
||||
int x;
|
||||
cin>>x;
|
||||
a.pb({x,i});
|
||||
}
|
||||
for(int i=0; i<n; ++i)
|
||||
cin>>b[i];
|
||||
sort(all(a));
|
||||
sort(all(b));
|
||||
for(int i=0; i<n; ++i)
|
||||
{
|
||||
c[a[i].second]=b[i];
|
||||
}
|
||||
for(auto x:c)
|
||||
cout<<x<<" ";
|
||||
cout<<endl;
|
||||
}
|
||||
|
||||
int32_t main()
|
||||
{
|
||||
FAST_IO;
|
||||
int TC = 1;
|
||||
cin >> TC;
|
||||
while (TC--)
|
||||
solve();
|
||||
}
|
93
1843B Long Long/1843B.cpp
Normal file
93
1843B Long Long/1843B.cpp
Normal file
@ -0,0 +1,93 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
|
||||
// Short forms
|
||||
#define int long long
|
||||
#define ll long long
|
||||
#define endl '\n'
|
||||
#define ff first
|
||||
#define ss second
|
||||
#define pb push_back
|
||||
#define all(x) x.begin(), x.end()
|
||||
#define sz(x) (int)(x).size()
|
||||
|
||||
// Outputs
|
||||
#define yes cout<<"YES"<<endl
|
||||
#define no cout<<"NO"<<endl
|
||||
|
||||
// Constants
|
||||
#define PI 3.141592653589793238
|
||||
#define INF LONG_LONG_MAX
|
||||
#define MOD 1e9+7
|
||||
|
||||
// Faster Input Output
|
||||
#define FAST_IO (ios_base:: sync_with_stdio(false),cin.tie(NULL));
|
||||
|
||||
// Maths
|
||||
ll fact(ll n) { if(n==0) return 1; ll res = 1; for (ll i = 2; i <= n; i++) res = res * i; return res; }
|
||||
ll nPr(ll n, ll r) { return fact(n) / fact(n - r); }
|
||||
ll nCr(ll n, ll r) { return fact(n) / (fact(r) * fact(n - r)); }
|
||||
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
|
||||
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b);}
|
||||
ll mypow(ll a, ll b) { ll ans = 1; while(b){ if (b&1) ans = (ans*a) ; b /= 2; a = (a*a); } return ans; }
|
||||
bool isPrime(ll n) { if(n <= 1) return false; for(ll i = 2; i <= sqrt(n); i++) if(n % i == 0) return false; return true; }
|
||||
|
||||
//Debugging
|
||||
#ifndef ONLINE_JUDGE
|
||||
#define dbg(x) cerr << #x <<" "; _print(x); cerr << endl;
|
||||
#define dbgin(x) cerr << #x <<" "; _print(x); cerr << ";"<<endl;
|
||||
#else
|
||||
#define dbg(x)
|
||||
#define dbgin(x)
|
||||
#endif
|
||||
|
||||
void _print(int t) {cerr << t;}void _print(string t) {cerr << t;}void _print(char t) {cerr << t;}
|
||||
void _print(long double t) {cerr << t;}void _print(double t) {cerr << t;}void _print(unsigned ll t) {cerr << t;}
|
||||
template <class T, class V> void _print(pair <T, V> p);
|
||||
template <class T> void _print(vector <T> v);template <class T> void _print(set <T> v);
|
||||
template <class T, class V> void _print(map <T, V> v);template <class T> void _print(multiset <T> v);
|
||||
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 << "]";}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void solve()
|
||||
{
|
||||
int n;
|
||||
cin>>n;
|
||||
vector<int>v;
|
||||
for(int i=0; i<n; ++i)
|
||||
{
|
||||
int x;
|
||||
cin>>x;
|
||||
if(x!=0)
|
||||
v.pb(x);
|
||||
}
|
||||
ll sum=0,ct=0;
|
||||
bool flag = 1;
|
||||
for(auto x: v)
|
||||
{
|
||||
if(x<0 && flag)
|
||||
{
|
||||
ct++;
|
||||
flag = 0;
|
||||
}
|
||||
else if(x>0)
|
||||
flag = 1;
|
||||
sum += abs(x);
|
||||
}
|
||||
cout<<sum<<" "<<ct<<endl;
|
||||
}
|
||||
|
||||
int32_t main()
|
||||
{
|
||||
FAST_IO;
|
||||
int TC = 1;
|
||||
cin >> TC;
|
||||
while (TC--)
|
||||
solve();
|
||||
}
|
98
1875A Jellyfish and Undertale/1875A.cpp
Normal file
98
1875A Jellyfish and Undertale/1875A.cpp
Normal file
@ -0,0 +1,98 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
|
||||
// Short forms
|
||||
#define int long long
|
||||
#define ll long long
|
||||
#define lld long double
|
||||
#define ull unsigned long long
|
||||
#define endl '\n'
|
||||
#define ff first
|
||||
#define ss second
|
||||
#define all(x) x.begin(), x.end()
|
||||
#define sz(x) (int)(x).size()
|
||||
#define pb push_back
|
||||
#define ppb pop_back
|
||||
#define mp make_pair
|
||||
#define ins insert
|
||||
#define fr(i, a, b) for(int i=a; i<b; ++i)
|
||||
#define fr(i, n) for(int i=0; i<n; ++i)
|
||||
#define rf(i, a, b) for(int i=a; i>b; --i)
|
||||
#define rf(i, n) for(int i=n; i>0; --i)
|
||||
|
||||
// STLs
|
||||
#define PII pair<int, int>
|
||||
#define VI vector<int>
|
||||
#define VVI vector<vector<int>>
|
||||
#define SI set<int>
|
||||
#define SC set<char>
|
||||
#define MII map<int,int>
|
||||
#define VLL vector<ll>
|
||||
#define VVL vector<vector<ll>>
|
||||
#define SL set<ll>
|
||||
|
||||
// Outputs
|
||||
#define yes cout<<"YES"<<endl
|
||||
#define no cout<<"NO"<<endl
|
||||
|
||||
// Constants
|
||||
#define PI 3.141592653589793238
|
||||
#define INF LONG_LONG_MAX
|
||||
#define MOD 1e9+7
|
||||
|
||||
// Faster Input Output
|
||||
#define FAST_IO (ios_base:: sync_with_stdio(false),cin.tie(NULL));
|
||||
|
||||
// Maths
|
||||
ll fact(ll n) { if(n==0) return 1; ll res = 1; for (ll i = 2; i <= n; i++) res = res * i; return res; }
|
||||
ll nPr(ll n, ll r) { return fact(n) / fact(n - r); }
|
||||
ll nCr(ll n, ll r) { return fact(n) / (fact(r) * fact(n - r)); }
|
||||
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
|
||||
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b);}
|
||||
ll mypow(ll a, ll b) { ll ans = 1; while(b){ if (b&1) ans = (ans*a) ; b /= 2; a = (a*a); } return ans; }
|
||||
bool isPrime(ll n) { if(n <= 1) return false; for(ll i = 2; i <= sqrt(n); i++) if(n % i == 0) return false; return true; }
|
||||
|
||||
//Debugging
|
||||
#ifndef ONLINE_JUDGE
|
||||
#define dbg(x) cerr << #x <<" "; _print(x); cerr << endl;
|
||||
#define dbgin(x) cerr << #x <<" "; _print(x); cerr << ";"<<endl;
|
||||
#else
|
||||
#define dbg(x)
|
||||
#define dbgin(x)
|
||||
#endif
|
||||
|
||||
void _print(int t) {cerr << t;}void _print(string t) {cerr << t;}void _print(char t) {cerr << t;}
|
||||
void _print(lld t) {cerr << t;}void _print(double t) {cerr << t;}void _print(ull t) {cerr << t;}
|
||||
template <class T, class V> void _print(pair <T, V> p);
|
||||
template <class T> void _print(vector <T> v);template <class T> void _print(set <T> v);
|
||||
template <class T, class V> void _print(map <T, V> v);template <class T> void _print(multiset <T> v);
|
||||
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 << "]";}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void solve()
|
||||
{
|
||||
int a,b,n;
|
||||
cin>>a>>b>>n;
|
||||
int ans=b;
|
||||
for(int i=0; i<n; ++i)
|
||||
{
|
||||
int x;
|
||||
cin>>x;
|
||||
ans+=min(x,a-1);
|
||||
}
|
||||
cout<<ans<<endl;
|
||||
}
|
||||
|
||||
int32_t main()
|
||||
{
|
||||
FAST_IO;
|
||||
int TC = 1;
|
||||
cin >> TC;
|
||||
while (TC--) solve();
|
||||
}
|
99
1879B Chips on the Board/1879B.cpp
Normal file
99
1879B Chips on the Board/1879B.cpp
Normal file
@ -0,0 +1,99 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
|
||||
// Short forms
|
||||
#define int long long
|
||||
#define ll long long
|
||||
#define lld long double
|
||||
#define ull unsigned long long
|
||||
#define endl '\n'
|
||||
#define ff first
|
||||
#define ss second
|
||||
#define all(x) x.begin(), x.end()
|
||||
#define sz(x) (int)(x).size()
|
||||
#define pb push_back
|
||||
#define ppb pop_back
|
||||
#define mp make_pair
|
||||
#define ins insert
|
||||
#define fr(i, a, b) for(int i=a; i<b; ++i)
|
||||
#define fr(i, n) for(int i=0; i<n; ++i)
|
||||
|
||||
// STLs
|
||||
#define PII pair<int, int>
|
||||
#define VI vector<int>
|
||||
#define VVI vector<vector<int>>
|
||||
#define SI set<int>
|
||||
#define SC set<char>
|
||||
#define MII map<int,int>
|
||||
#define VLL vector<ll>
|
||||
#define VVL vector<vector<ll>>
|
||||
#define SL set<ll>
|
||||
|
||||
// Outputs
|
||||
#define yes cout<<"YES"<<endl
|
||||
#define no cout<<"NO"<<endl
|
||||
|
||||
// Constants
|
||||
#define PI 3.141592653589793238
|
||||
#define INF LONG_LONG_MAX
|
||||
#define MOD 1e9+7
|
||||
|
||||
// Faster Input Output
|
||||
#define FAST_IO (ios_base:: sync_with_stdio(false),cin.tie(NULL));
|
||||
|
||||
// Maths
|
||||
ll fact(ll n) { if(n==0) return 1; ll res = 1; for (ll i = 2; i <= n; i++) res = res * i; return res; }
|
||||
ll nPr(ll n, ll r) { return fact(n) / fact(n - r); }
|
||||
ll nCr(ll n, ll r) { return fact(n) / (fact(r) * fact(n - r)); }
|
||||
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
|
||||
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b);}
|
||||
ll mypow(ll a, ll b) { ll ans = 1; while(b){ if (b&1) ans = (ans*a) ; b /= 2; a = (a*a); } return ans; }
|
||||
bool isPrime(ll n) { if(n <= 1) return false; for(ll i = 2; i <= sqrt(n); i++) if(n % i == 0) return false; return true; }
|
||||
|
||||
//Debugging
|
||||
#ifndef ONLINE_JUDGE
|
||||
#define dbg(x) cerr << #x <<" "; _print(x); cerr << endl;
|
||||
#define dbgin(x) cerr << #x <<" "; _print(x); cerr << "; ";
|
||||
#else
|
||||
#define dbg(x)
|
||||
#define dbgin(x)
|
||||
#endif
|
||||
|
||||
void _print(int t) {cerr << t;}void _print(string t) {cerr << t;}void _print(char t) {cerr << t;}
|
||||
void _print(lld t) {cerr << t;}void _print(double t) {cerr << t;}void _print(ull t) {cerr << t;}
|
||||
template <class T, class V> void _print(pair <T, V> p);
|
||||
template <class T> void _print(vector <T> v);template <class T> void _print(set <T> v);
|
||||
template <class T, class V> void _print(map <T, V> v);template <class T> void _print(multiset <T> v);
|
||||
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 << "]";}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void solve()
|
||||
{
|
||||
int n;
|
||||
cin>>n;
|
||||
VI a(n), b(n);
|
||||
fr(i, n) cin>>a[i];
|
||||
fr(i, n) cin>>b[i];
|
||||
sort(all(a));
|
||||
sort(all(b));
|
||||
int row=0, col=0;
|
||||
fr(i,n)
|
||||
row+=a[i]+b[0];
|
||||
fr(i,n)
|
||||
col+=b[i]+a[0];
|
||||
cout<<min(row,col)<<endl;
|
||||
}
|
||||
|
||||
int32_t main()
|
||||
{
|
||||
FAST_IO;
|
||||
int TC = 1;
|
||||
cin >> TC;
|
||||
while (TC--) solve();
|
||||
}
|
108
1900A Cover in Water/1900A.cpp
Normal file
108
1900A Cover in Water/1900A.cpp
Normal file
@ -0,0 +1,108 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
|
||||
// Short forms
|
||||
#define int long long
|
||||
#define ll long long
|
||||
#define lld long double
|
||||
#define ull unsigned long long
|
||||
#define endl '\n'
|
||||
#define ff first
|
||||
#define ss second
|
||||
#define all(x) x.begin(), x.end()
|
||||
#define sz(x) (int)(x).size()
|
||||
#define pb push_back
|
||||
#define ppb pop_back
|
||||
#define mp make_pair
|
||||
#define ins insert
|
||||
|
||||
// STLs
|
||||
#define PII pair<int, int>
|
||||
#define VI vector<int>
|
||||
#define VVI vector<vector<int>>
|
||||
#define SI set<int>
|
||||
#define SC set<char>
|
||||
#define MII map<int,int>
|
||||
#define VLL vector<ll>
|
||||
#define VVL vector<vector<ll>>
|
||||
#define SL set<ll>
|
||||
|
||||
// Outputs
|
||||
#define yes cout<<"YES"<<endl
|
||||
#define no cout<<"NO"<<endl
|
||||
|
||||
// Constants
|
||||
#define PI 3.141592653589793238
|
||||
#define INF LONG_LONG_MAX
|
||||
#define MOD 1e9+7
|
||||
|
||||
// Faster Input Output
|
||||
#define FAST_IO (ios_base:: sync_with_stdio(false),cin.tie(NULL));
|
||||
|
||||
// Maths
|
||||
ll fact(ll n) { if(n==0) return 1; ll res = 1; for (ll i = 2; i <= n; i++) res = res * i; return res; }
|
||||
ll nPr(ll n, ll r) { return fact(n) / fact(n - r); }
|
||||
ll nCr(ll n, ll r) { return fact(n) / (fact(r) * fact(n - r)); }
|
||||
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
|
||||
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b);}
|
||||
ll mypow(ll a, ll b) { ll ans = 1; while(b){ if (b&1) ans = (ans*a) ; b /= 2; a = (a*a); } return ans; }
|
||||
bool isPrime(ll n) { if(n <= 1) return false; for(ll i = 2; i <= sqrt(n); i++) if(n % i == 0) return false; return true; }
|
||||
|
||||
//Debugging
|
||||
#ifndef ONLINE_JUDGE
|
||||
#define dbg(x) cerr << #x <<" "; _print(x); cerr << endl;
|
||||
#define dbgin(x) cerr << #x <<" "; _print(x); cerr << "; ";
|
||||
#else
|
||||
#define dbg(x)
|
||||
#define dbgin(x)
|
||||
#endif
|
||||
|
||||
void _print(int t) {cerr << t;}void _print(string t) {cerr << t;}void _print(char t) {cerr << t;}
|
||||
void _print(lld t) {cerr << t;}void _print(double t) {cerr << t;}void _print(ull t) {cerr << t;}
|
||||
template <class T, class V> void _print(pair <T, V> p);
|
||||
template <class T> void _print(vector <T> v);template <class T> void _print(set <T> v);
|
||||
template <class T, class V> void _print(map <T, V> v);template <class T> void _print(multiset <T> v);
|
||||
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 << "]";}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void solve()
|
||||
{
|
||||
int n;
|
||||
string s;
|
||||
cin>>n>>s;
|
||||
int cnt=0, ct=0, mx=0;
|
||||
for(char c : s)
|
||||
{
|
||||
if(c == '.')
|
||||
{
|
||||
cnt++;
|
||||
ct++;
|
||||
}
|
||||
if(c == '#')
|
||||
{
|
||||
mx=max(mx,ct);
|
||||
ct=0;
|
||||
}
|
||||
}
|
||||
mx=max(ct,mx);
|
||||
if(cnt==0)
|
||||
cout<<0<<endl;
|
||||
else if(mx>2)
|
||||
cout<<2<<endl;
|
||||
else
|
||||
cout<<cnt<<endl;
|
||||
}
|
||||
|
||||
int32_t main()
|
||||
{
|
||||
FAST_IO;
|
||||
int TC = 1;
|
||||
cin >> TC;
|
||||
while (TC--) solve();
|
||||
}
|
115
1900B Laura and Operations/1900B.cpp
Normal file
115
1900B Laura and Operations/1900B.cpp
Normal file
@ -0,0 +1,115 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
|
||||
// Short forms
|
||||
#define int long long
|
||||
#define ll long long
|
||||
#define lld long double
|
||||
#define ull unsigned long long
|
||||
#define endl '\n'
|
||||
#define ff first
|
||||
#define ss second
|
||||
#define all(x) x.begin(), x.end()
|
||||
#define sz(x) (int)(x).size()
|
||||
#define pb push_back
|
||||
#define ppb pop_back
|
||||
#define mp make_pair
|
||||
#define ins insert
|
||||
|
||||
// STLs
|
||||
#define PII pair<int, int>
|
||||
#define VI vector<int>
|
||||
#define VVI vector<vector<int>>
|
||||
#define SI set<int>
|
||||
#define SC set<char>
|
||||
#define MII map<int,int>
|
||||
#define VLL vector<ll>
|
||||
#define VVL vector<vector<ll>>
|
||||
#define SL set<ll>
|
||||
|
||||
// Outputs
|
||||
#define yes cout<<"YES"<<endl
|
||||
#define no cout<<"NO"<<endl
|
||||
|
||||
// Constants
|
||||
#define PI 3.141592653589793238
|
||||
#define INF LONG_LONG_MAX
|
||||
#define MOD 1e9+7
|
||||
|
||||
// Faster Input Output
|
||||
#define FAST_IO (ios_base:: sync_with_stdio(false),cin.tie(NULL));
|
||||
|
||||
// Maths
|
||||
ll fact(ll n) { if(n==0) return 1; ll res = 1; for (ll i = 2; i <= n; i++) res = res * i; return res; }
|
||||
ll nPr(ll n, ll r) { return fact(n) / fact(n - r); }
|
||||
ll nCr(ll n, ll r) { return fact(n) / (fact(r) * fact(n - r)); }
|
||||
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
|
||||
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b);}
|
||||
ll mypow(ll a, ll b) { ll ans = 1; while(b){ if (b&1) ans = (ans*a) ; b /= 2; a = (a*a); } return ans; }
|
||||
bool isPrime(ll n) { if(n <= 1) return false; for(ll i = 2; i <= sqrt(n); i++) if(n % i == 0) return false; return true; }
|
||||
|
||||
//Debugging
|
||||
#ifndef ONLINE_JUDGE
|
||||
#define dbg(x) cerr << #x <<" "; _print(x); cerr << endl;
|
||||
#define dbgin(x) cerr << #x <<" "; _print(x); cerr << "; ";
|
||||
#else
|
||||
#define dbg(x)
|
||||
#define dbgin(x)
|
||||
#endif
|
||||
|
||||
void _print(int t) {cerr << t;}void _print(string t) {cerr << t;}void _print(char t) {cerr << t;}
|
||||
void _print(lld t) {cerr << t;}void _print(double t) {cerr << t;}void _print(ull t) {cerr << t;}
|
||||
template <class T, class V> void _print(pair <T, V> p);
|
||||
template <class T> void _print(vector <T> v);template <class T> void _print(set <T> v);
|
||||
template <class T, class V> void _print(map <T, V> v);template <class T> void _print(multiset <T> v);
|
||||
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 << "]";}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void solve()
|
||||
{
|
||||
int a,b,c,x,y,z,tmp;
|
||||
cin>>a>>b>>c;
|
||||
VI v(3,0);
|
||||
|
||||
x=a, y=b, z=c;
|
||||
tmp=min(y,z);
|
||||
y-=tmp;
|
||||
z-=tmp;
|
||||
x+=tmp;
|
||||
if(x>0 && max(y,z)%2==0)
|
||||
v[0]=1;
|
||||
|
||||
x=a, y=b, z=c;
|
||||
tmp=min(x,z);
|
||||
x-=tmp;
|
||||
z-=tmp;
|
||||
y+=tmp;
|
||||
if(y>0 && max(x,z)%2==0)
|
||||
v[1]=1;
|
||||
|
||||
x=a, y=b, z=c;
|
||||
tmp=min(x,y);
|
||||
x-=tmp;
|
||||
y-=tmp;
|
||||
z+=tmp;
|
||||
if(z>0 && max(x,y)%2==0)
|
||||
v[2]=1;
|
||||
|
||||
for(auto ele:v)
|
||||
cout<<ele<<" ";
|
||||
cout<<endl;
|
||||
}
|
||||
|
||||
int32_t main()
|
||||
{
|
||||
FAST_IO;
|
||||
int TC = 1;
|
||||
cin >> TC;
|
||||
while (TC--) solve();
|
||||
}
|
102
1907A Rook/1907A.cpp
Normal file
102
1907A Rook/1907A.cpp
Normal file
@ -0,0 +1,102 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
|
||||
// Short forms
|
||||
#define int long long
|
||||
#define ll long long
|
||||
#define lld long double
|
||||
#define ull unsigned long long
|
||||
#define endl '\n'
|
||||
#define ff first
|
||||
#define ss second
|
||||
#define all(x) x.begin(), x.end()
|
||||
#define sz(x) (int)(x).size()
|
||||
#define pb push_back
|
||||
#define ppb pop_back
|
||||
#define mp make_pair
|
||||
#define ins insert
|
||||
|
||||
// STLs
|
||||
#define PII pair<int, int>
|
||||
#define VI vector<int>
|
||||
#define VVI vector<vector<int>>
|
||||
#define SI set<int>
|
||||
#define SC set<char>
|
||||
#define MII map<int,int>
|
||||
#define VLL vector<ll>
|
||||
#define VVL vector<vector<ll>>
|
||||
#define SL set<ll>
|
||||
|
||||
// Outputs
|
||||
#define yes cout<<"YES"<<endl
|
||||
#define no cout<<"NO"<<endl
|
||||
|
||||
// Constants
|
||||
#define PI 3.141592653589793238
|
||||
#define INF LONG_LONG_MAX
|
||||
#define MOD 1e9+7
|
||||
|
||||
// Faster Input Output
|
||||
#define FAST_IO (ios_base:: sync_with_stdio(false),cin.tie(NULL));
|
||||
|
||||
// Maths
|
||||
ll fact(ll n) { if(n==0) return 1; ll res = 1; for (ll i = 2; i <= n; i++) res = res * i; return res; }
|
||||
ll nPr(ll n, ll r) { return fact(n) / fact(n - r); }
|
||||
ll nCr(ll n, ll r) { return fact(n) / (fact(r) * fact(n - r)); }
|
||||
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
|
||||
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b);}
|
||||
ll mypow(ll a, ll b) { ll ans = 1; while(b){ if (b&1) ans = (ans*a) ; b /= 2; a = (a*a); } return ans; }
|
||||
bool isPrime(ll n) { if(n <= 1) return false; for(ll i = 2; i <= sqrt(n); i++) if(n % i == 0) return false; return true; }
|
||||
|
||||
//Debugging
|
||||
#ifndef ONLINE_JUDGE
|
||||
#define dbg(x) cerr << #x <<" "; _print(x); cerr << endl;
|
||||
#define dbgin(x) cerr << #x <<" "; _print(x); cerr << "; ";
|
||||
#else
|
||||
#define dbg(x)
|
||||
#define dbgin(x)
|
||||
#endif
|
||||
|
||||
void _print(int t) {cerr << t;}void _print(string t) {cerr << t;}void _print(char t) {cerr << t;}
|
||||
void _print(lld t) {cerr << t;}void _print(double t) {cerr << t;}void _print(ull t) {cerr << t;}
|
||||
template <class T, class V> void _print(pair <T, V> p);
|
||||
template <class T> void _print(vector <T> v);template <class T> void _print(set <T> v);
|
||||
template <class T, class V> void _print(map <T, V> v);template <class T> void _print(multiset <T> v);
|
||||
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 << "]";}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void solve()
|
||||
{
|
||||
string s;
|
||||
cin>>s;
|
||||
string ch ="abcdefgh";
|
||||
int it = ch.find(s[0]);
|
||||
for(int i=0; i<sz(ch); ++i)
|
||||
{
|
||||
if(i==it)
|
||||
continue;
|
||||
else
|
||||
cout<<ch[i]<<s[1]<<endl;
|
||||
}
|
||||
for(int i=1; i<=8; ++i)
|
||||
{
|
||||
if(i==s[1]-'0')
|
||||
continue;
|
||||
else
|
||||
cout<<s[0]<<i<<endl;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t main()
|
||||
{
|
||||
FAST_IO;
|
||||
int TC = 1;
|
||||
cin >> TC;
|
||||
while (TC--) solve();
|
||||
}
|
112
1907B YetnotherrokenKeoard/1907B.cpp
Normal file
112
1907B YetnotherrokenKeoard/1907B.cpp
Normal file
@ -0,0 +1,112 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
|
||||
// Short forms
|
||||
#define int long long
|
||||
#define ll long long
|
||||
#define lld long double
|
||||
#define ull unsigned long long
|
||||
#define endl '\n'
|
||||
#define ff first
|
||||
#define ss second
|
||||
#define all(x) x.begin(), x.end()
|
||||
#define sz(x) (int)(x).size()
|
||||
#define pb push_back
|
||||
#define ppb pop_back
|
||||
#define mp make_pair
|
||||
#define ins insert
|
||||
|
||||
// STLs
|
||||
#define PII pair<int, int>
|
||||
#define VI vector<int>
|
||||
#define VVI vector<vector<int>>
|
||||
#define SI set<int>
|
||||
#define SC set<char>
|
||||
#define MII map<int,int>
|
||||
#define VLL vector<ll>
|
||||
#define VVL vector<vector<ll>>
|
||||
#define SL set<ll>
|
||||
|
||||
// Outputs
|
||||
#define yes cout<<"YES"<<endl
|
||||
#define no cout<<"NO"<<endl
|
||||
|
||||
// Constants
|
||||
#define PI 3.141592653589793238
|
||||
#define INF LONG_LONG_MAX
|
||||
#define MOD 1e9+7
|
||||
|
||||
// Faster Input Output
|
||||
#define FAST_IO (ios_base:: sync_with_stdio(false),cin.tie(NULL));
|
||||
|
||||
// Maths
|
||||
ll fact(ll n) { if(n==0) return 1; ll res = 1; for (ll i = 2; i <= n; i++) res = res * i; return res; }
|
||||
ll nPr(ll n, ll r) { return fact(n) / fact(n - r); }
|
||||
ll nCr(ll n, ll r) { return fact(n) / (fact(r) * fact(n - r)); }
|
||||
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
|
||||
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b);}
|
||||
ll mypow(ll a, ll b) { ll ans = 1; while(b){ if (b&1) ans = (ans*a) ; b /= 2; a = (a*a); } return ans; }
|
||||
bool isPrime(ll n) { if(n <= 1) return false; for(ll i = 2; i <= sqrt(n); i++) if(n % i == 0) return false; return true; }
|
||||
|
||||
//Debugging
|
||||
#ifndef ONLINE_JUDGE
|
||||
#define dbg(x) cerr << #x <<" "; _print(x); cerr << endl;
|
||||
#define dbgin(x) cerr << #x <<" "; _print(x); cerr << "; ";
|
||||
#else
|
||||
#define dbg(x)
|
||||
#define dbgin(x)
|
||||
#endif
|
||||
|
||||
void _print(int t) {cerr << t;}void _print(string t) {cerr << t;}void _print(char t) {cerr << t;}
|
||||
void _print(lld t) {cerr << t;}void _print(double t) {cerr << t;}void _print(ull t) {cerr << t;}
|
||||
template <class T, class V> void _print(pair <T, V> p);
|
||||
template <class T> void _print(vector <T> v);template <class T> void _print(set <T> v);
|
||||
template <class T, class V> void _print(map <T, V> v);template <class T> void _print(multiset <T> v);
|
||||
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 << "]";}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void solve()
|
||||
{
|
||||
string s,ans="";
|
||||
cin>>s;
|
||||
int small=0, capital=0;
|
||||
for(int i=sz(s)-1; i>=0; --i)
|
||||
{
|
||||
char c=s[i];
|
||||
if(islower(c))
|
||||
{
|
||||
if(c=='b')
|
||||
small++;
|
||||
else if(small)
|
||||
small--;
|
||||
else
|
||||
ans+=c;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(c=='B')
|
||||
capital++;
|
||||
else if(capital)
|
||||
capital--;
|
||||
else
|
||||
ans+=c;
|
||||
}
|
||||
}
|
||||
reverse(all(ans));
|
||||
cout<<ans<<endl;
|
||||
|
||||
}
|
||||
|
||||
int32_t main()
|
||||
{
|
||||
FAST_IO;
|
||||
int TC = 1;
|
||||
cin >> TC;
|
||||
while (TC--) solve();
|
||||
}
|
105
456B Fedya and Maths/456B.cpp
Normal file
105
456B Fedya and Maths/456B.cpp
Normal file
@ -0,0 +1,105 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
|
||||
// Short forms
|
||||
#define int long long
|
||||
#define ll long long
|
||||
#define lld long double
|
||||
#define ull unsigned long long
|
||||
#define endl '\n'
|
||||
#define ff first
|
||||
#define ss second
|
||||
#define all(x) x.begin(), x.end()
|
||||
#define sz(x) (int)(x).size()
|
||||
#define pb push_back
|
||||
#define ppb pop_back
|
||||
#define mp make_pair
|
||||
#define ins insert
|
||||
#define fr(i, a, b) for(int i=a; i<b; ++i)
|
||||
#define fn(i, n) for(int i=0; i<n; ++i)
|
||||
#define rf(i, a, b) for(int i=a; i>b; --i)
|
||||
#define nf(i, n) for(int i=n; i>0; --i)
|
||||
|
||||
// STLs
|
||||
#define PII pair<int, int>
|
||||
#define VI vector<int>
|
||||
#define VVI vector<vector<int>>
|
||||
#define SI set<int>
|
||||
#define SC set<char>
|
||||
#define MII map<int,int>
|
||||
#define VLL vector<ll>
|
||||
#define VVL vector<vector<ll>>
|
||||
#define SL set<ll>
|
||||
|
||||
// Outputs
|
||||
#define yes cout<<"YES"<<endl
|
||||
#define no cout<<"NO"<<endl
|
||||
|
||||
// Constants
|
||||
#define PI 3.141592653589793238
|
||||
#define INF LONG_LONG_MAX
|
||||
#define MOD 1e9+7
|
||||
|
||||
// Faster Input Output
|
||||
#define FAST_IO (ios_base:: sync_with_stdio(false),cin.tie(NULL));
|
||||
|
||||
// Maths
|
||||
ll fact(ll n) { if(n==0) return 1; ll res = 1; for (ll i = 2; i <= n; i++) res = res * i; return res; }
|
||||
ll nPr(ll n, ll r) { return fact(n) / fact(n - r); }
|
||||
ll nCr(ll n, ll r) { return fact(n) / (fact(r) * fact(n - r)); }
|
||||
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
|
||||
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b);}
|
||||
ll mypow(ll a, ll b) { ll ans = 1; while(b){ if (b&1) ans = (ans*a) ; b /= 2; a = (a*a); } return ans; }
|
||||
bool isPrime(ll n) { if(n <= 1) return false; for(ll i = 2; i <= sqrt(n); i++) if(n % i == 0) return false; return true; }
|
||||
|
||||
//Debugging
|
||||
#ifndef ONLINE_JUDGE
|
||||
#define dbg(x) cerr << #x <<" "; _print(x); cerr << endl;
|
||||
#define dbgin(x) cerr << #x <<" "; _print(x); cerr << ";"<<endl;
|
||||
#else
|
||||
#define dbg(x)
|
||||
#define dbgin(x)
|
||||
#endif
|
||||
|
||||
void _print(int t) {cerr << t;}void _print(string t) {cerr << t;}void _print(char t) {cerr << t;}
|
||||
void _print(lld t) {cerr << t;}void _print(double t) {cerr << t;}void _print(ull t) {cerr << t;}
|
||||
template <class T, class V> void _print(pair <T, V> p);
|
||||
template <class T> void _print(vector <T> v);template <class T> void _print(set <T> v);
|
||||
template <class T, class V> void _print(map <T, V> v);template <class T> void _print(multiset <T> v);
|
||||
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 << "]";}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void solve()
|
||||
{
|
||||
string s;
|
||||
cin>>s;
|
||||
if(sz(s)<2)
|
||||
{
|
||||
int n=s[0]-'0';
|
||||
if(n%4)
|
||||
cout<<0<<endl;
|
||||
else
|
||||
cout<<4<<endl;
|
||||
return;
|
||||
}
|
||||
string str=s.substr(sz(s)-2,2);
|
||||
int n=stoi(str);
|
||||
if(n%4)
|
||||
cout<<0<<endl;
|
||||
else
|
||||
cout<<4<<endl;
|
||||
}
|
||||
|
||||
int32_t main()
|
||||
{
|
||||
FAST_IO;
|
||||
int TC = 1;
|
||||
// cin >> TC;
|
||||
while (TC--) solve();
|
||||
}
|
Loading…
Reference in New Issue
Block a user