SMU Spring 2023 Contest Round 6
E. Expenditure Reduction
从左右往右找到包含B字符的最近位置,然后从这个位置有从右到左找回去找到包含完所有B字符的位置,这个区间就是答案

#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define endl '\n'
#define int long long using namespace std; const int N = 1e6+10, M = 998244353; //typedef long long ll;
typedef pair<int,int> PII;
int n,m,t,k;
map<int,int> mp;
priority_queue<int> QQ;
deque<int> Q;
int ksm(int a,int b,int mod){
int res = 1;
a %= mod;
while(b){
if(b & 1)
res = res * a % mod;
a = a * a % mod;
b >>= 1;
}
return res;
}
void solve() {
string a,b;
cin >> a >> b;
int l = 0, r = a.size() - 1, pos = 0;
for(int i = 0;i < a.size();i++){
if(a[i] == b[pos])
pos++;
if(pos == b.size()){
r = i;
break;
}
}
pos --;
//cout << pos << endl;
for(int i = r;i >= 0;i--){
if(a[i] == b[pos])
pos--;
if(pos == -1){
l = i;
break;
}
}
//cout << l << ' ' << r << endl;
cout << a.substr(l, r - l + 1) << endl;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
int Ke_scholar = 1;
cin >> Ke_scholar;
while(Ke_scholar--)
solve();
return 0;
}
/* */
G. Gua!
签到题,注意细节.

#include<bits/stdc++.h> //#define int long long
#define endl '\n'
#define PII pair<int,int> using namespace std; const int N = 2010,mod = 1e9 + 7;
int n,s,v,m; void solve() {
int b, r, d, s;
cin >> b >> r >> d >> s;
if (b == 0||r==0) {
if (d)cout << "gua!" << endl;
else cout << "ok" << endl;
return;
}
int x = (d + b - 1) / b;
int y = r * s / 60 + 1;
//cout << x << ' ' << y << endl;
if (x <= y)cout << "ok" << endl;
else cout << "gua!" << endl;
} int32_t main() {
ios::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
int Ke_scholar = 1;
cin >> Ke_scholar;
while(Ke_scholar--)solve();
return 0;
}
H. Heirloom Painting
考虑最后一次涂色,必然会形成一个长度不小于 的相同颜色的连续区间。因此如果不存在 长度不小于 的相同颜色的连续区间,则必然无解。不难发现,每一段相同颜色的连续区间都是独 立的,假设其长度为 ,则至少需要 ⌈ / ⌉ 次涂色才能得到这段区间。
下面我们证明这一下界可以 达到:随便选择一个长度不小于 的相同颜色的连续区间,作为最后涂色的区间。倒过来考虑,如 果已知下一次涂色最终留下颜色的区间,那么本次涂色最终留下颜色的区间可以与下一次涂色的区 间相邻,且长度不超过 ,因此每一个长度为 的相同颜色连续区间,都可以恰好经过 ⌈ / ⌉ 次涂 色得到。
因此将每个区间的贡献简单相加即可得到答案,总时间复杂度 ()。

#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define endl '\n'
#define int long long using namespace std; const int N = 1e6+10, M = 998244353; typedef unsigned long long ll;
typedef pair<int,int> PII; int n,m,t,k;
map<int,int> mp;
priority_queue<int> QQ;
deque<int> Q;
void solve() {
cin >> n >> m >> k;
vector<int> a(n + 1), b(n + 1);
int pos = 0;
for(int i = 1;i <= n;i ++){
cin >> a[i];
if(a[i] != a[i - 1]){
b[++pos] = 1;
}else{
b[pos]++;
}
}
if(a[1] == a[n] && pos != 1){
b[1] += b[pos--];
}
bool f = false;
int ans = 0;
for(int i = 1;i <= pos;i ++){
if(b[i] >= k)
f = true;
ans += (b[i] + k - 1) / k;
}
cout << (f ? ans : (-1)) << endl;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
int Ke_scholar = 1;
cin >> Ke_scholar;
while(Ke_scholar--)
solve();
return 0;
}
/* */
N. Nine Is Greater Than Ten
签到题.
void solve() {
string s1,s2;
cin >> s1 >> s2;
if(s1 > s2){
cout << s1 << '>' << s2 << endl;
}
else if(s1 < s2){
cout << s1 << '<' << s2 << endl;
}
else
cout << s1 << '=' << s2 << endl;
}
SMU Spring 2023 Contest Round 6的更多相关文章
- 2015 Astar Contest - Round 3 题解
1001 数长方形 题目大意 平面内有N条平行于坐标轴的线段,且不会在端点处相交 问共形成多少个矩形 算法思路 枚举4条线段的全部组合.分别作为矩形四条边.推断是否合法 时间复杂度: O(N4) 代码 ...
- Contest Round #451 (Div. 2)F/Problemset 898F Restoring the Expression
题意: 有一个a+b=c的等式,去掉两个符号,把三个数连在一起得到一个数 给出这个数,要求还原等式,length <= 1e6 三个数不能含有前导0,保证有解 解法: 铁头过题法,分类然后各种判 ...
- Codeforces Round #284 (Div. 2)A B C 模拟 数学
A. Watching a movie time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Sending messages to non-windowed applications -- AllocateHWnd, DeallocateHWnd
http://delphi.about.com/od/windowsshellapi/l/aa093003a.htm Page 1: How Delphi dispatches messages in ...
- Codeforces 240 F. TorCoder
F. TorCoder time limit per test 3 seconds memory limit per test 256 megabytes input input.txt output ...
- cf499B-Lecture 【map】
http://codeforces.com/problemset/problem/499/B B. Lecture You have a new professor of graph theo ...
- Why to Not Not Start a Startup
我花了周六,周日两天的时间,把这篇长文给阅读完了.很受益,改变了我的很多认知,也给我开拓了视野. 转载: Want to start a startup? Get funded by Y Combin ...
- Codeforces 240F. TorCoder 线段树
线段树统计和维护某一区间内的字母个数.. . . F. TorCoder time limit per test 3 seconds memory limit per test 256 megabyt ...
- 物联网学生科协第三届H-star现场编程比赛
问题 A: 剪纸片 时间限制: 1 Sec 内存限制: 128 MB 题目描写叙述 这是一道简单的题目,假如你身边有一张纸.一把剪刀.在H-star的比赛现场,你会这么做: 1. 将这张纸剪成两片(平 ...
- [cf contest 893(edu round 33)] F - Subtree Minimum Query
[cf contest 893(edu round 33)] F - Subtree Minimum Query time limit per test 6 seconds memory limit ...
随机推荐
- spring-事务案例
spring的案例场景 同一个事务中使用并发操作导致更新获取锁失败 @Autowired Service service1; @Transactional public void methodA(){ ...
- 格式化显示JSON数据
测试JSON {"took":1,"timed_out":false,"_shards":{"total":1,&quo ...
- 嵌入式测试手册——基于NXP iMX6ULL开发板(2)
基于测试板卡:创龙科技TLIMX6U-EVM是一款基于NXP i.MX 6ULL的ARM Cortex-A7高性能低功耗处理器设计的评估板,由核心板和评估底板组成.核心板经过专业的PCB Layout ...
- 全志T113-i+玄铁HiFi4开发板(双核ARM Cortex-A7 )规格书
评估板简介 创龙科技TLT113-EVM是一款基于全志科技T113-i双核ARM Cortex-A7 + 玄铁C906 RISC-V + HiFi4 DSP异构多核处理器设计的国产工业评估板,ARM ...
- Linux系统用户组管理
用户管理 和Windows一样在Linux中也存在许多用户,可以登陆Linux,和Windows不同的是,在Windows中同一时刻只可以存在一个用户登录系统,而在Linux中是允许多个用户同时登 ...
- AI Agent技术的最新进展与改变世界的典型项目巡礼
AI Agent技术的最新进展与改变世界的典型项目巡礼 1. AI Agent 技术发展以及典型项目 1.0 前 AI Agent 时代 在学术探索的浩瀚星空中,机器人技术领域的璀璨明珠莫过于Agen ...
- yb课堂 开发前端项目路由 《三十五》
Vue-Router开发前端项目路由 vue-router 是Vue.js官方的路由管理器,它和Vue.js的核心深度集成,让构建单页面应用变得易如反掌 官方文档:https://router.vue ...
- react为什么不用数组的下标来绑定key
最近在看一本名叫<深入浅出React和Redux>这一书,里面谈到了react的dom更新比对,记录一下. 假设有这么一个组件 <ul> <ListItem text=& ...
- 把nodejs程序打包成可执行文件
在写好之后的nodejs程序,想发给同事的电脑上运行程序,就不得不下载node环境,还要安装第三方依赖包,非常的麻烦. 因此,可以借助一些插件来完成nodejs程序的打包,变成可以执行的文件. 将No ...
- 循环冗余检验CRC
先约定一个除数,除数根据生成多项式来决定,余数的位数就是除数位数减一,在被除数后面添加余数个0,然后进行运算. 注意虽然叫做除数被除数,但是是按位进行异或操作,相同为1,不同为0,最后的余数就叫帧检验 ...