跳到正文

题解

题解:P13103 [GCJ 2019 Qualification] You Can Go Your Own Way

BlackHoles约 1 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2025年12月12日
篇幅
约 1 分钟
获赞
1
题目
P13103

版本

  1. v1当前

正解

注意到只需要将路径沿对角线翻折即可。

具体地,记 ss 为路径,若 sis_i 为 EE,则输出 SS;反之则输出 EE,正确性显然。

C++
#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;
}
原文