Educational Codeforces Round 63 (Rated for Div. 2) A

 扫一遍,发现当前上一个小,直接交换 输出就行了

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn =3e5+10;
const int INF=0x3f3f3f3f;
char s[maxn];
int main(int argc, char const *argv[])
{
	int n;cin>>n;
	scanf("%s",s+1);
	int len=strlen(s+1);
	for(int i=2;i<=len;i++)
	{
		if(s[i]<s[i-1])
		{
			swap(s[i],s[i-1]);
			cout<<"YES"<<endl;
			cout<<i-1<<" "<<i;
			return 0;
		} 
	}
	cout<<"NO"<<endl;
	return 0;
}

猜你喜欢

转载自blog.csdn.net/wzazzy/article/details/89679865