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 ...
随机推荐
- 获取ImageView的触摸点所对应的UIImage的坐标
获取ImageView的触摸点所对应的UIImage的坐标 功能描述 实现前分析 注意事项 代码 求打赏 功能描述 在imageview上触摸图片,求对应UIImage的触摸点. 实现前分析 从ima ...
- opc da 服务器数据 转 profinet IO项目案例
1 案例说明 1. 在OPC DA服务器上运行OPC DA client软件查看OPC DA服务器的相关参数. 2. 配置VFBOX网关参数,使用网关采集OPC DA服务器数据 ...
- 【译】了解17.10 GA 中最新的 Git 工具特性
我们相信提高开发和团队协作的生产力可以帮助您产生更好的软件解决方案.这就是为什么 Visual Studio 版本控制团队发布了新特性,简化了内部循环和代码审查体验.您将获得 AI 支持编写提交消息. ...
- FFmpeg变速处理视频文件
使用工具:小丸工具箱,HandBrake,FFmpeg 首先确定视频是否为VFR(可变帧率),如果是VFR需要在二次处理前转换成CFR(固定帧率) VFR转换CFR可以使用FFmpeg命令行或Hand ...
- 【ClickHouse】0:clickhouse学习2之数据类型
一 :如何查看clickhouse具体支持哪些数据类型? 1:查看官方文档:https://clickhouse.tech/docs/en/sql-reference/data-types/ 2:查看 ...
- HSCSEC CTF 2023
HSCSEC CTF 2023_misc的部分writeup 有趣的比赛,学到了新姿势orz Ancient-MISC Deduced gossip ☲☵ ☷☵☳ ☶空 ☷☵☳ ☶☱ ☶空 ☷空☱ ☶ ...
- yb课堂实战之轮播图接口引入本地缓存 《二十一》
轮播图接口引入缓存 CacheKeyManager.java package net.ybclass.online_ybclass.config; /** * 缓存key管理类 */ public c ...
- 如何优雅地使用Mybatis逆向工程生成类
文/朱季谦 1.环境:SpringBoot 2.在pom.xml文件里引入相关依赖: 1 <plugin> 2 <groupId>org.mybatis.generator&l ...
- 咬文嚼图式的介绍二叉树、B树/B-树
前言 因为本人天资愚钝,所以总喜欢将抽象化的事务具象化表达.对于各类眼花缭乱的树,只需要认知到它们只是一种数据结构,类似数组,切片,列表,映射等这些耳熟能详的词汇.对于一个数据结构而言,无非就是增删改 ...
- leetcode简单(数组,字符串,链表):[168, 171, 190, 205, 228, 448, 461, 876, 836, 844]
目录 168. Excel表列名称 171. Excel 表列序号 190. 颠倒二进制位 205. 同构字符串 228. 汇总区间 448. 找到所有数组中消失的数字 461. 汉明距离 876. ...