A.
A little water problem
B.
Containing only a given ’a’,'b’,’c’
adjacent character strings of different \ (S \) , seeking a length \ (≥ \ lfloor \ frac { | s |} {2} \ rfloor \) a palindromic sequence \ (T \) .
Code
#include<bits/stdc++.h>
using namespace std;
typedef long long D;
const int maxn=1000003;
int n;
D pre[maxn],suf[maxn];
char s[maxn];
int main(){
scanf("%s",s+1);
n=strlen(s+1);
for(int i=1,last=0;i<=n;i++){
pre[i]=pre[i-1];
if(s[i]=='v')pre[i]+=bool(last),last++;
else last=0;
}
for(int i=n,last=0;i>=1;i--){
suf[i]=suf[i+1];
if(s[i]=='v')suf[i]+=bool(last),last++;
else last=0;
}
D ans=0;
for(int i=1;i<=n;i++){
if(s[i]=='o')ans+=pre[i]*suf[i];
}
printf("%lld\n",ans);
return 0;
}
C.
solution
You will find that when elements of the first row and first column to determine the elements of the whole matrix also determined.
And the first elements of the first row and column are \ (2 ^ {n + m } \) possible.
Therefore, the answer is \ (2 ^ {n-m} + \) .