题解:P13103 [GCJ 2019 Qualification] You Can Go Your Own Way
题意
给定测试用例数量
思路
既然要不与其路径冲突,并且 Lydia 的路径一定是有效路径,那么我们就跟 Lydia 反着来,她往东走,我就往南走,她往南走,我就往东走,这样在满足路径有效不与 Lydia 的路径冲突的同时,也可以满足输出的 Case #x: y 就行了。
Code
#include<bits/stdc++.h>
#define N 200086
#define ll long long
#define iakioi cout<<"I AK IOI"<<endl
using namespace std;
int t,n;
char ch[N];
inline int read();
int main(){
t=read();
for(int p=1;p<=t;p++){
n=read();
for(int i=1;i<=2*n-2;i++){
cin>>ch[i]; //存储路径
}
cout<<"Case #"<<p<<": "; //提前输出Case #x: ,注意":"后还有一个空格
for(int i=1;i<=2*n-2;i++){
if(ch[i]=='S') cout<<'E'; //与Lydia走相反方向
else cout<<'S';
}
cout<<endl; //最后换行
}
return 0;
}
inline int read(){
int x=0,f=1;char ch=getchar();
while (ch<'0'||ch>'9') {if (ch=='-') f=-1;ch=getchar();}
while (ch>='0'&&ch<='9') {x=x*10+ch-48;ch=getchar();}
return x*f;
}