A:差点开场懵逼。只要有相邻两位不同就可以作为答案。

#include<iostream> 
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int read()
{
    int x=0,f=1;char c=getchar();
    while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
    while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
    return x*f;
}
#define N 1010
int n,cnt[N][26];
char s[N];
int main()
{
    n=read();
    scanf("%s",s+1);
    for (int i=1;i<n;i++) if (s[i]!=s[i+1]) {cout<<"YES\n"<<s[i]<<s[i+1];return 0;}
    cout<<"NO";
    return 0;
}
View Code

相关文章: