当前位置:网站首页>Educational Codeforces Round 107 (Rated for Div. 2) E. Colorings and Dominoes
Educational Codeforces Round 107 (Rated for Div. 2) E. Colorings and Dominoes
2022-07-05 05:27:00 【solemntee】
Our idea on this question is , Look at the picture horizontally and vertically .
Obviously, only one color needs to be considered horizontally and vertically .
The problem became 1*n Of all the o square value and .
We can dp Find out , Regard red and blue as 01 strand .
The length is i Of value and
Equal to the length of i-1 Of value and *2 Plus the length is i-1 Of 01 The end of the string is continuous 1 Is the number of odd strings .
And then it's fun ac 了
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod=998244353;
ll dp[300005];
char s[300005];
ll poww[300005];
vector<int>pos1[300005],pos2[300005];
int main()
{
ll ji=1,ou=1;
dp[1]=0;
poww[0]=1;
poww[1]=2;
for(int i=2;i<=300000;i++)poww[i]=poww[i-1]*2%mod;
for(int i=2;i<=300000;i++)
{
ll tj=ji,to=ou;
ou=(tj+to+tj)%mod;
ji=to;
dp[i]=(2*dp[i-1]+tj)%mod;
}
int n,m;
scanf("%d%d",&n,&m);
int cnt=0;
ll ans=0;
for(int i=1;i<=n;i++)
{
scanf("%s",s+1);
for(int j=1;j<=m;j++)
if(s[j]=='o')pos1[i].push_back(j),pos2[j].push_back(i),cnt++;
}
for(int i=1;i<=n;i++)
{
int temp=0,last=-1;
for(auto x:pos1[i])
{
if(x==last+1)temp++,last=x;
else
{
ans=(ans+poww[cnt-temp]*dp[temp])%mod;
temp=1,last=x;
}
}
if(temp)
{
ans=(ans+poww[cnt-temp]*dp[temp])%mod;
}
}
for(int i=1;i<=m;i++)
{
int temp=0,last=-1;
for(auto x:pos2[i])
{
if(x==last+1)temp++,last=x;
else
{
ans=(ans+poww[cnt-temp]*dp[temp])%mod;
temp=1,last=x;
}
}
if(temp)
{
ans=(ans+poww[cnt-temp]*dp[temp])%mod;
}
}
printf("%lld",ans);
return 0;
}
边栏推荐
- [sum of two numbers] 169 sum of two numbers II - enter an ordered array
- Detailed explanation of expression (csp-j 2021 expr) topic
- Embedded database development programming (VI) -- C API
- Fragment addition failed error lookup
- 发现一个很好的 Solon 框架试手的教学视频(Solon,轻量级应用开发框架)
- [es practice] use the native realm security mode on es
- 剑指 Offer 58 - II. 左旋转字符串
- Download xftp7 and xshell7 (official website)
- [to be continued] [UE4 notes] L1 create and configure items
- 搭建完数据库和网站后.打开app测试时候显示服务器正在维护.
猜你喜欢
![[转]MySQL操作实战(一):关键字 & 函数](/img/b1/8b843014f365b786e310718f669043.png)
[转]MySQL操作实战(一):关键字 & 函数

Using HashMap to realize simple cache

The present is a gift from heaven -- a film review of the journey of the soul

剑指 Offer 58 - II. 左旋转字符串

Little known skills of Task Manager

利用HashMap实现简单缓存
![[turn to] MySQL operation practice (III): table connection](/img/70/20bf9b379ce58761bae9955982a158.png)
[turn to] MySQL operation practice (III): table connection

Talking about JVM (frequent interview)

读者写者模型

Improvement of pointnet++
随机推荐
Palindrome (csp-s-2021-palin) solution
软件测试 -- 0 序
剑指 Offer 06.从头到尾打印链表
YOLOv5添加注意力機制
Remote upgrade afraid of cutting beard? Explain FOTA safety upgrade in detail
Reader writer model
High precision subtraction
Animation scoring data analysis and visualization and it industry recruitment data analysis and visualization
Pointnet++的改进
Improvement of pointnet++
Acwing 4301. Truncated sequence
支持多模多态 GBase 8c数据库持续创新重磅升级
[to be continued] [UE4 notes] L3 import resources and project migration
Reverse one-way linked list of interview questions
Add level control and logger level control of Solon logging plug-in
Bubble sort summary
Haut OJ 1316: sister choice buys candy III
To be continued] [UE4 notes] L4 object editing
[allocation problem] 455 Distribute cookies
Haut OJ 1401: praise energy