Coloring Dominoes

题目描述

We have a board with a 2×N grid. Snuke covered the board with N dominoes without overlaps. Here, a domino can cover a 1×2 or 2×1 square.
Then, Snuke decided to paint these dominoes using three colors: red, cyan and green. Two dominoes that are adjacent by side should be painted by different colors. Here, it is not always necessary to use all three colors.
Find the number of such ways to paint the dominoes, modulo 1000000007.
The arrangement of the dominoes is given to you as two strings S1 and S2 in the following manner:
Each domino is represented by a different English letter (lowercase or uppercase).
The j-th character in Si represents the domino that occupies the square at the i-th row from the top and j-th column from the left.

Constraints
1≤N≤52
|S1|=|S2|=N
S1 and S2 consist of lowercase and uppercase English letters.
S1 and S2 represent a valid arrangement of dominoes.

 

输入

Input is given from Standard Input in the following format:
N
S1
S2

 

输出

Print the number of such ways to paint the dominoes, modulo 1000000007.

 

 

样例输入

3
aab
ccb

 

样例输出

6

 

提示

There are six ways as shown below:

 

 初始情况为:

一个竖着的方块共有3中可能

两个横着的木块共有6种可能

剩下的排列题主要讨论2种情况

1:前边方块为竖着的时候看将要放的木块是一个竖着的(前边的结果*2)还是两个横着的(前边的结果*1)

2:前边的方块为两个横着的时候看要放的木块是一个竖着的(前边的结果*1)还是两个横着的(前边的结果*3)

ac代码:

#include<iostream>
#include<string>
using namespace std;
const int mod=1e9+7;
int main(){
	string str1,str2;
	int n;
	cin>>n;
	cin>>str1;
	cin>>str2;
	int i=0;
	int p;
	long long int  sum=1;
	while(i<n){
		if(i==0){
			if(str1[i]==str2[i]){
			sum=sum*3%mod;
			p=1;
			i++;
			}
			else{
			sum=sum*6%mod;
			p=2;
			i+=2;
			}
		}
		else{
			if(str1[i]==str2[i]){
				if(p==1){
				sum=sum*2%mod;
				i++;
				}
				else{
				sum=sum*1%mod;
				i++;
				p=1;
				}
			}
			else{
				if(p==1){
				sum=sum*2%mod;
				i+=2;
				p=2;
				}
				else{
				sum=sum*3%mod;
				i+=2;
				}
			}
		}
	}


	cout<<sum<<endl;
	return 0;
}

 

### BSS Coloring 字段的定义与作用 BSS Coloring 是一种用于识别重叠基本服务集(OBSS,Overlapping Basic Service Set)的方法[^1]。它最初在 IEEE 802.11ah-2016 修正案中定义,并被延续到 IEEE 802.11ax(即 Wi-Fi 6)标准中[^1]。 在 IEEE 802.11ax 标准中,BSS Coloring 是 PHY(物理层)头部中的一个字段,用于标识特定的基本服务集(BSS)[^2]。通过为每个 BSS 分配唯一的颜色(实际上是一个数值),无线电设备可以区分属于不同 BSS 的信号。这种机制允许 STA(Station,终端设备)快速判断接收到的信号是否来自其所属的 BSS,从而优化干扰管理[^2]。 具体而言,BSS Coloring 的功能包括: - 当 STA 检测到来自其他 BSS 的干扰时,可以通过 BSS Coloring 字段决定是否停止传输。 - 如果干扰信号不属于当前 BSS,STA 可以忽略该干扰并继续进行并发传输[^2]。 此外,BSS Coloring 机制不仅提高了网络效率,还增强了高密度环境下的性能表现,这是 IEEE 802.11ax 标准的核心目标之一[^3]。 ```python # 示例代码:模拟 BSS Coloring 的简单实现 class BSS: def __init__(self, bss_id, color): self.bss_id = bss_id self.color = color # BSS Coloring 字段 def identify(self, signal_color): if self.color == signal_color: return "Signal belongs to this BSS" else: return "Signal from another BSS" # 创建两个不同的 BSS bss1 = BSS(bss_id="BSS1", color=5) bss2 = BSS(bss_id="BSS2", color=10) # 测试信号识别 print(bss1.identify(signal_color=5)) # 输出: Signal belongs to this BSS print(bss1.identify(signal_color=10)) # 输出: Signal from another BSS ``` ###
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值