【非常简单的】A. Computer Game

题目来源

Problem - 1598A - Codeforceshttps://codeforces.com/problemset/problem/1598/A

题干

 个人思路

要想让小伙子前进不了只要在任意一列都放上1,他就到不了终点啦

注意到在这里的输入形式为连续的数字,所以为在数组中放一个字符,数组使用char类型

代码段

void solve()//computer game
{
	int n;
	cin >> n;
	vector<vector<char>>grab(2, vector<char>(n));
	for (auto& x : grab[0])cin >> x;
	for (auto& x : grab[1])cin >> x;
	for (int i=0;i<grab[0].size();i++)
	{
		if (grab[0][i] == '1' && grab[1][i] == '1')
		{
			cout << "NO" << endl;
			return;
		}
	}
	cout << "YES" << endl;
}

猜你喜欢

转载自blog.csdn.net/nathanqian123/article/details/121225569
今日推荐