Dashboard - Codeforces Round 913 (Div. 3) - Codeforces
#include<bits/stdc++.h>
using namespace std;
void solve()
{
string s;
cin>>s;
for(char a='a';a<='h';a++)
{
if(s[0]!=a) printf("%c%c\n",a,s[1]);
}
for(char a='1';a<='8';a++)
{
if(s[1]!=a) printf("%c%c\n",s[0],a);
}
}
int main()
{
int t;
cin>>t;
while(t--)
{
solve();
}
}
#include<bits/stdc++.h>
using namespace std;
void solve()
{
string s;
cin>>s;
string ans="";
int B=0,b=0;
for(int i=s.size()-1;i>=0;i--)
{
if(s[i]=='B') B++;
else if(s[i]=='b') b++;
else if(s[i]>='a' && s[i]<='z')
{
if(b)
{
b--;
continue;
}else{
ans+=s[i];
}
}else{
if(B){
B--;
continue;
}else{
ans+=s[i];
}
}
}
reverse(ans.begin(),ans.end());
cout<<ans<<endl;
}
int main()
{
int t;
cin>>t;
while(t--)
{
solve();
}
}
#include<bits/stdc++.h>
using namespace std;
void solve()
{
int n,maxx=0;
string s;
map<char,int>mp;
cin>>n>>s;
for(char x:s)
{
mp[x]++;
maxx=max(maxx,mp[x]);
}
if(maxx<=n/2) cout<<n%2<<endl;
else cout<<maxx-(n-maxx)<<endl;
}
int main()
{
int t;
cin>>t;
while(t--)
{
solve();
}
}
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define PII pair<int, int>
#define x first
#define y second
const int N=3e5+10;
PII q[N];
int n;
bool check(int x)
{
int l0=0,r0=0;
for(int i=1;i<=n;i++)
{
l0=max(q[i].x,l0-x);
r0=min(q[i].y,r0+x);
if(l0>r0) return false;
}
return true;
}
void solve()
{
cin>>n;
for(int i=1;i<=n;i++) cin>>q[i].x>>q[i].y;
int l=0,r=3e9;
while(l<r)
{
int mid=l+r>>1;
if(check(mid)) r=mid;
else l=mid+1;
}
cout<<l<<endl;
}
signed main()
{
int t;
cin>>t;
while(t--)
{
solve();
}
}
#include<bits/stdc++.h>
using namespace std;
#define int long long
map<int,int> mp;
int n;
void init()
{
for(int i=0;i<=9;i++)
{
for(int j=0;j<=9;j++)
{
for(int k=0;k<=9;k++)
{
mp[i+j+k]++;
}
}
}
}
void solve()
{
cin>>n;
int ans=1,u=n;
while(u)
{
ans*=mp[u%10];
u/=10;
}
cout<<ans<<endl;
}
signed main()
{
init();
int t;
cin>>t;
while(t--)
{
solve();
}
}