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 ...
随机推荐
- Linux Driver : i2c-gpio
# Linux Driver : i2c-gpio https://www.cnblogs.com/haoxing990/p/4718834.html https://blog.csdn.net/ji ...
- Xilinux PS与PL交互::Linux-App读写REG
Xilinux PS与PL交互::Linux-App读写REG 背景 PL配置好有关的硬件,PS端做验证. 设计方案:针对REG地址,不使用设备树配置. 遇到的问题:暂无. 验证目的 验证PL-PS的 ...
- Nuxt3 的生命周期和钩子函数(七)
title: Nuxt3 的生命周期和钩子函数(七) date: 2024/6/30 updated: 2024/6/30 author: cmdragon excerpt: 摘要:文章阐述了Nuxt ...
- 制作visual studio 离线安装包
应用场景:脱机.内网环境安装vs开发环境. 概述:在互联网环境下载安装工具,下载根据需求并缓存布局(类似功能模块),压缩缓存内容拷贝至离线环境进行安装. 1.官网下载指定版本的vs安装客户端 创建基于 ...
- pymsql往数据库插入表情报错
修改数据库 需要数据库支持utf8mb4 修改/etc/my.conf [client] default-character-set = utf8mb4 [mysql] default-charact ...
- yb课堂 视频详情页模块开发《三十八》
CourseDetail基础模块开发 CourseDetail模块开发,拆分组件 CourseDetail.vue Header.vue Course.vue Tab.vue Summary.vue ...
- WPF单行TextBox自动滚动至末尾
根据光标位置自动滚动 textBox.CaretIndex = textBox.SelectionStart; var rect = textBox.GetRectFromCharacterIndex ...
- nuxt3正确使用keepalive页面缓存组件缓存
最近使用nuxt@3.x版本做SEO优化项目比较多,之前也踩坑过,所以记录一下在 nuxt3 中路由缓存的正确使用方法,本人也之前在GitHub社区中提交过反馈问题,最后是在 3.8.2 版本解决了路 ...
- 使用@nuxtjs/sitemap给项目添加sitemap(网站地图)
安装使用步骤参照:此博客内容转载博客地址:https://huangliangbo.com/2097 如何使用?(详细图文) 在项目根目录下使用yarn/npm/cnpm 安装 @nuxtjs/sit ...
- ComfyUI进阶篇:ControlNet核心节点
前言: ControlNet_aux库包含大量的图片预处理节点,功能丰富,适用于图像分割.边缘检测.姿势检测.深度图处理等多种预处理方式.掌握这些节点的使用是利用ControlNet的关键,本篇文章将 ...