跳到正文

题解

CF1994B 题解

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

文章信息

发布
2024年7月20日
收录
2025年12月12日
更新
2026年11月21日
篇幅
约 1 分钟
题目
CF1994B

版本

  1. v1当前

思路

我们设 xx 为第 11 个 11 的位置,则可以使用 a1∼axa_1\sim a_x 异或 ar−x+1∼ara_{r-x+1}\sim a_r 把 ara_r 取反,所以 ax∼ana_x\sim a_n 都是可以随意改变的,但 a1∼ax−1a_1\sim a_{x-1} 不行。所以我们只要判断 b1∼bx−1b_1\sim b_{x-1} 是否全 00 就行。

代码

C++
# include <bits/stdc++.h>
# define I return
# define AK 0
# define IOI ;
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
int t, n;
string a, b;
int main () {
	ios::sync_with_stdio (0);
	cin.tie (0);
	cout.tie (0);
	cin >> t;
	while (t --) {
		cin >> n >> a >> b;
		for (int i = 0; i < n; ++ i) {
			if (a[i] == '1')
				break ;
			if (a[i] != b[i])
				goto no;
		}
		cout << "Yes\n";
		continue ;
no:
		cout << "No\n";
	}
	I AK IOI
}
原文