跳到正文

题解

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

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

文章信息

收录
2025年12月12日
更新
2026年2月15日
篇幅
约 1 分钟
题目
P13103

版本

  1. v1当前

题意

给出一个 n∗nn*n 大小的正整数矩阵,要求出:从1,11,1到n,nn,n的路线,只有两种可用的移动方式:向东移动一格,以及向南移动一格。你可以进入任何单元格,但不能做出会导致你离开网格的移动。并且不能与给出的路线重和。

思路

既然不和给出的路线重合,那么我们只需要与给出的路线反过来不就行了?

代码

C++
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int t;
	cin>>t;
	int cnt=0;
	while(t--)
	{
		cnt++;
		int n;
		cin>>n;
		string s;
		cin>>s;
		int len=s.size();
		cout<<"Case #"<<cnt<<": ";
		for(int i=0;i<len;++i)
		{
			if(s[i]=='E')
			{
				cout<<'S';
			}
			else
			{
				cout<<'E';
			}
		}
		cout<<endl;
	}
	return 0;
}
原文