From a31571cb3cf4e83bc20d20bbe6d80f9462377101 Mon Sep 17 00:00:00 2001 From: hanyixuanten <105723997+hanyixuanten@users.noreply.github.com> Date: Tue, 15 Sep 2026 17:38:39 +0800 Subject: [PATCH] new file: P15254.cpp --- P15254.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 P15254.cpp diff --git a/P15254.cpp b/P15254.cpp new file mode 100644 index 0000000..9c3a021 --- /dev/null +++ b/P15254.cpp @@ -0,0 +1,33 @@ +#include +using namespace std; +int t,k; +int n; +char s[200005]; +int main(){ + scanf("%d%d",&t,&k); + while(t--){ + scanf("%d%s",&n,s); + bool flag=0; + vector ans; + for(int i=n-1;i>=0;--i){ + if((s[i]=='O'&&!flag) || (s[i]=='M' &&flag)){ + ans.push_back('O'); + flag=!flag; + }else{ + ans.push_back('M'); + } + } + puts("YES"); + if(k==1){ + for(int i=n-1;i>=0;--i){ + putchar(ans[i]); + } + puts(""); + } + } + return 0; +} +/* +MOO +MOO +*/ \ No newline at end of file