正解
注意到只需要将路径沿对角线翻折即可。
具体地,记 为路径,若 为 ,则输出 ;反之则输出 ,正确性显然。
#include <bits/stdc++.h>
using namespace std;
int T, n;
string s;
int main(void) {
cin.tie(0), cout.tie(0);
cin >> T;
for (int t = 1; t <= T; ++t) {
cin >> n >> s;
cout << "Case #" << t << ": ";
for (char c : s) {
if (c == 'E') cout << 'S';
else cout << 'E';
}
cout << '\n';
}
return 0;
}