Educational Codeforces Round 123 (Rated for Div. 2) E. Expand the Path
2022/3/18 23:57:37
本文主要是介绍Educational Codeforces Round 123 (Rated for Div. 2) E. Expand the Path,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
自己没想出来 参考了大佬们的博客 添加链接描述
#include<bits/stdc++.h> #define int long long using namespace std; const int N=200005; int t,n;string s; int32_t main(){ cin>>t; while(t--){ cin>>n>>s; int m=s.size(); int pos=1,x=0,y=0; while(pos<m&&s[pos]==s[pos-1]) pos++; if(pos==m) { cout<<n<<endl; continue; } for(int i=pos;i<m;i++){ if(s[i]=='R') x++; else y++; } // cout<<x<<" "<<y<<endl; int ans=n*n; ans=ans-x*y-pos*(n-1); cout<<ans<<endl; } }
这篇关于Educational Codeforces Round 123 (Rated for Div. 2) E. Expand the Path的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-06-26小白家庭 nas 搭建方案-icode9专业技术文章分享
- 2024-06-23AI大模型企业应用实战(14)-langchain的Embedding
- 2024-06-23AI大模型企业应用实战(15)-langchain核心组件
- 2024-06-23AI大模型企业应用实战(16)-langchain核心组件
- 2024-06-23AI 大模型企业应用实战(06)-初识LangChain
- 2024-06-19EntBot.ai: AI Website Chatbot for Product Guides and Development Doc
- 2024-06-17zero-shot-learning-definition-examples-comparison
- 2024-06-06Package Easy(基于 NSIS 的打包exe安装包工具)使用方法-icode9专业技术文章分享
- 2024-06-06基于 casdoor 的 ELK 开源登录认证解决方案: elk-auth-casdoor-icode9专业技术文章分享
- 2024-05-29Elasticsearch慢查询日志配置