跳到正文

题解

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

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

文章信息

发布
2025年7月8日
收录
2025年12月12日
更新
2026年11月19日
篇幅
约 1 分钟
获赞
2
题目
P13103

版本

  1. v1当前

题目要求路径不能重合,为了保证路径不重合,我们尽量不要一致,所以我们把所有东西反过来输出即可。

注意 nn 其实是 2×n−22\times n-2。

参考代码:

C++
#include <iostream>
#define int long long
using namespace std;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    int t;
    cin>>t;
    int cnt = 0;
    while(t--){
        cnt++;
        cout<<"Case #"<<cnt<<": ";
        int n;
        string s;
        cin>>n>>s;
        n = 2*n-2;//注意
        for(int i = 0;i<n;i++){
            if(s[i]=='E') cout<<'S';//反过来输出即可
            else cout<<'E';
        }
        cout<<endl;
    }
    return 0;
}
原文