5
3 2 3
100 100 100
50 49 49
10 30 20
1 1000000000 1000000000
YES
3 2 1
YES
100 100 100
NO
NO
YES
1 1 1000000000
#include
#include
using namespace std;
int main()
{
int t,a[3];
scanf("%d",&t);
while(t--)
{
scanf("%d%d%d",&a[0],&a[1],&a[2]);
sort(a,a+3);
if(a[1]==a[2])
{
printf("YES\n");
printf("%d %d %d\n",a[0],a[0],a[2]);
}
else printf("NO\n");
}
return 0;
}
5
2
1 1 2 2
4
1 3 1 4 3 4 2 2
5
1 2 1 2 3 4 3 5 4 5
3
1 2 3 1 2 3
4
2 3 2 4 1 3 4 1
1 2
1 3 4 2
1 2 3 4 5
1 2 3
2 3 4 1
#include
#include
#include
using namespace std;
int t,n,x,a[110],b[55],cnt;
int main()
{
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
cnt=0;
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
for(int i=1;i<=2*n;i++)
{
scanf("%d",&x);
if(!b[x])
{
b[x]++;a[++cnt]=x;
}
}
for(int i=1;i<=cnt;i++)printf("%d ",a[i]);
printf("\n");
}
return 0;
}
5
4
1 2 3 4
7
4 3 3 8 4 5 2
3
1 1 1
7
1 3 1 4 5 3 2
5
5 4 3 2 3
0
4
0
2
3
#include
#include
#include
using namespace std;
int const N=2e5+5;
int t,n,a[N];
int main()
{
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
for(int i=1;i<=n;i++)scanf("%d",&a[i]);
int i=0,j=0;
for(i=n-1;i>=1;i--)
if(a[i]<a[i+1])break;
for(j=i;j>=1;j--)
if(a[j]>a[j+1])break;
printf("%d\n",j);
}
return 0;
}
6
8
bbdcaaaa
8
asdfghjk
8
ceaaaabb
8
bbaaddcc
1
z
2
ac
0
7
4
5
1
1
#include
#include
#include
using namespace std;
int const N=2e5;
char s[N];
int t,n;
int dfs(int l,int r,char ch)
{
if(l==r)//n=1的情况
{
if(ch==s[l])return 0;//不需要修改
return 1; //需要修改
}
int cnt1=0,cnt2=0,x=(l+r)/2;
for(int i=l;i<=x;i++)
if(ch!=s[i])cnt1++;
for(int i=x+1;i<=r;i++)
if(ch!=s[i])cnt2++;
return min(dfs(l,x,ch+1)+cnt2,cnt1+dfs(x+1,r,ch+1));
//分别表示 改前半段为(ch+1)-good后半段为ch 与 改前半段为ch后半段为(ch+1)-good 的情况取最优
}
int main()
{
scanf("%d\n",&t);
while(t--)
{
scanf("%d\n",&n);
scanf("%s",s+1);
printf("%d\n",dfs(1,n,'a'));
}
return 0;
}