当前位置:网站首页>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;
}
边栏推荐
- 动漫评分数据分析与可视化 与 IT行业招聘数据分析与可视化
- Improvement of pointnet++
- FVP和Juno平台的Memory Layout介绍
- A new micro ORM open source framework
- Under the national teacher qualification certificate in the first half of 2022
- Introduction to memory layout of FVP and Juno platforms
- 剑指 Offer 53 - I. 在排序数组中查找数字 I
- Yolov5 ajouter un mécanisme d'attention
- SAP method of modifying system table data
- Haut OJ 1401: praise energy
猜你喜欢

object serialization
![[转]MySQL操作实战(一):关键字 & 函数](/img/b1/8b843014f365b786e310718f669043.png)
[转]MySQL操作实战(一):关键字 & 函数

剑指 Offer 53 - II. 0~n-1中缺失的数字

Corridor and bridge distribution (csp-s-2021-t1) popular problem solution

Research on the value of background repeat of background tiling

Embedded database development programming (V) -- DQL

Yolov5 ajouter un mécanisme d'attention

Quick sort summary

剑指 Offer 09. 用两个栈实现队列

Hang wait lock vs spin lock (where both are used)
随机推荐
SAP method of modifying system table data
Embedded database development programming (zero)
Count sort
A new micro ORM open source framework
Add level control and logger level control of Solon logging plug-in
Reflection summary of Haut OJ freshmen on Wednesday
2022上半年全国教师资格证下
软件测试 -- 0 序
Merge sort
【ES实战】ES上的native realm安全方式使用
[转]MySQL操作实战(一):关键字 & 函数
Web APIs DOM node
Haut OJ 1241: League activities of class XXX
Haut OJ 1221: a tired day
[turn to] MySQL operation practice (I): Keywords & functions
[sum of two numbers] 169 sum of two numbers II - enter an ordered array
A preliminary study of sdei - see the essence through transactions
Research on the value of background repeat of background tiling
A problem and solution of recording QT memory leakage
对象的序列化