题解 | 躲藏

躲藏

https://www.nowcoder.com/practice/b19eda9490d54505a1065a70c3005b47

#include<bits/stdc++.h>
#include <string>
using namespace std;
#define int long long
#define x first
#define y second
#define space ' '
#define endl '\n'
#define pb push_back
#define all(x) x.begin(),x.end()

#define debug(x) x<<' '
typedef pair<int,int> PII;

const int N=2e5+10;
const int INF=0x3f3f3f3f3f3f3f3fLL;
const int inf=0x3f3f3f3f3f3f3f3fLL;
const int mod=2000120420010122;
const int MOD=998244353;

int n,m,k,q;
string s;
void solve(){
 string s;
 while(cin>>s){
    int ans=0;
   int dp0=0,dp1=0,dp2=0;
   for(auto pr:s){
    if(pr=='w'||pr=='W') dp1+=dp0;
     if(pr=='b'||pr=='B') dp2+=dp1;
      if(pr=='c'||pr=='C') {
        ans+=dp2;
        dp0++;
      }
   }
   cout<<ans%mod<<endl;
 }
}

signed main(){
    // double start=(double)clock()/CLOCKS_PER_SEC;
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout<<fixed<<setprecision(3);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    // double end=(double)clock()/CLOCKS_PER_SEC;
    // cout<<endl<<"time="<<end-start<<endl;
    return 0;
}

全部评论

相关推荐

开发转测第二人:没实习的话,两个项目吧,八股也要准备一下,这个时间点有点小晚了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务