A
# include <bits/stdc++.h>
using namespace std;
int main()
{
int n,flag=1,minn=27,maxx=0;
string a;
int f[30];
cin>>n;
memset(f,0,sizeof(f));
for(int i=0;i<n;i++){
cin>>a;
if(a.length()==1){
cout<<"Yes"<<endl;
continue;
}
for(int j=0;j<a.length();j++){
f[a[j]-'a']++;
if(int(a[j]-'a')<minn){
minn=int(a[j]-'a');
}
if(int(a[j]-'a')>maxx){
maxx=int(a[j]-'a');
}
}
for(int j=minn;j<=maxx;j++){
if(f[j]!=1){
cout<<"No"<<endl;
flag=0;
break;
}
}
if(flag){
cout<<"Yes"<<endl;
}
flag=1,minn=27,maxx=0;
memset(f,0,sizeof(f));
}
return 0;
}
B
# include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main()
{
LL n,j=0,e=0,d,sy,sum=0;
LL a[2010],b[2010];
cin>>n;
for(int i=0;i<n;i++){
cin>>d;
if(d%2==0){
b[e++]=d;
}else{
a[j++]=d;
}
}
if(abs(j-e)==1||j-e==0){
cout<<0;
}else{
if(j>e){
sy=j-e-1;
sort(a,a+j);
for(int i=0;i<sy;i++){
sum+=a[i];
}
cout<<sum;
}else if(j<e){
sy=e-j-1;
sort(b,b+e);
for(int i=0;i<sy;i++){
sum+=b[i];
}
cout<<sum;
}
}
return 0;
}
C
# include <bits/stdc++.h>
using namespace std;
int a[200010];
int f[200010];
int aa[200010],bb[200010];
int a1=0,b1=0,flag=1;
int main()
{
int n;
memset(f,0,sizeof(f));
cin>>n;
for(int i=0;i<n;i++){
cin>>a[i];
f[a[i]]++;
if(f[a[i]]==1){
bb[b1++]=a[i];
}else if(f[a[i]]==2){
aa[a1++]=a[i];
}else if(f[a[i]]==3){
cout<<"NO";
flag=0;
break;
}
}
if(flag){
cout<<"YES"<<endl;;
cout<<a1<<endl;
sort(aa,aa+a1);
for(int i=0;i<a1;i++){
cout<<aa[i]<<" ";
}
cout<<endl;
cout<<b1<<endl;
sort(bb,bb+b1,greater<int>());
for(int i=0;i<b1;i++){
cout<<bb[i]<<" ";
}
}
return 0;
}
D
# include <bits/stdc++.h>
using namespace std;
int a[200010];
int f[200010];
int main()
{
int n,maxx=0,d,sum=0,b,bb=0;
cin>>n;
memset(f,0,sizeof(f));
for(int i=0;i<n;i++){
cin>>a[i];
f[a[i]]++;
if(f[a[i]]>maxx){
maxx=f[a[i]];
d=a[i];
b=i;
}
}
sum=n-maxx;
cout<<sum<<endl;
if(sum){
for(int i=0;i<n;i++){
if(a[i]==d){
for(int j=i-1;j>=bb;j--){
if(a[j]>d){
cout<<2<<" ";
cout<<j+1<<" "<<j+2<<endl;
}if(a[j]<d){
cout<<1<<" ";
cout<<j+1<<" "<<j+2<<endl;
}
}
bb=i;
}
}
if(bb<(n-1)){
for(int j=bb;j<n;j++){
if(a[j]>d){
cout<<2<<" ";
cout<<j+1<<" "<<j<<endl;
}if(a[j]<d){
cout<<1<<" ";
cout<<j+1<<" "<<j<<endl;
}
}
}
}
return 0;
}