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的更多相关文章

  1. 2015 Astar Contest - Round 3 题解

    1001 数长方形 题目大意 平面内有N条平行于坐标轴的线段,且不会在端点处相交 问共形成多少个矩形 算法思路 枚举4条线段的全部组合.分别作为矩形四条边.推断是否合法 时间复杂度: O(N4) 代码 ...

  2. Contest Round #451 (Div. 2)F/Problemset 898F Restoring the Expression

    题意: 有一个a+b=c的等式,去掉两个符号,把三个数连在一起得到一个数 给出这个数,要求还原等式,length <= 1e6 三个数不能含有前导0,保证有解 解法: 铁头过题法,分类然后各种判 ...

  3. 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 ...

  4. Sending messages to non-windowed applications -- AllocateHWnd, DeallocateHWnd

    http://delphi.about.com/od/windowsshellapi/l/aa093003a.htm Page 1: How Delphi dispatches messages in ...

  5. Codeforces 240 F. TorCoder

    F. TorCoder time limit per test 3 seconds memory limit per test 256 megabytes input input.txt output ...

  6. cf499B-Lecture 【map】

    http://codeforces.com/problemset/problem/499/B B. Lecture     You have a new professor of graph theo ...

  7. Why to Not Not Start a Startup

    我花了周六,周日两天的时间,把这篇长文给阅读完了.很受益,改变了我的很多认知,也给我开拓了视野. 转载: Want to start a startup? Get funded by Y Combin ...

  8. Codeforces 240F. TorCoder 线段树

    线段树统计和维护某一区间内的字母个数.. . . F. TorCoder time limit per test 3 seconds memory limit per test 256 megabyt ...

  9. 物联网学生科协第三届H-star现场编程比赛

    问题 A: 剪纸片 时间限制: 1 Sec 内存限制: 128 MB 题目描写叙述 这是一道简单的题目,假如你身边有一张纸.一把剪刀.在H-star的比赛现场,你会这么做: 1. 将这张纸剪成两片(平 ...

  10. [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 ...

随机推荐

  1. python + pytestTestreport生成测试报告_报告没有生成图标和报告样式错乱

    pytestreport 生成测试报告的问题 1.生成报告html页面的样式错乱 2.生成报告html页面的图标没有展示 3. 生成报告html页面的查询详情按钮点击没有相应 问题排除: 浏览器开发者 ...

  2. 基于 Cloudflare Workers 和 cloudflare-docker-proxy 搭建镜像加速服务

    本文主要介绍了如何基于 Cloudflare Workers 和 cloudflare-docker-proxy 搭建 dockerhub.gcr.quay 等镜像加速服务. 最近,受限于各种情况,部 ...

  3. FFmpeg新旧接口对照使用一览

    背景 根据例程学习调用ffmpeg 库方法的时候,发现了一堆警告. main.cpp:81:37: warning: 'AVStream::codec' is deprecated [-Wdeprec ...

  4. 你真的了解Java内存模型JMM吗?

    哈喽,大家好,我是世杰. 本文我为大家介绍面试官经常考察的「Java内存模型JMM相关内容」 面试连环call 什么是Java内存模型(JMM)? 为什么需要JMM? Java线程的工作内存和主内存各 ...

  5. Serverless无服务应用架构纵横谈2:边缘计算激战正酣

    Serverless无服务应用架构纵横谈2 前言 6年前,我写了一篇<Serverless无服务应用架构纵横谈>. 文中说到无论是公有云FaaS还是私有云FaaS,都不是云计算的未来. 因 ...

  6. vue中 lang="ts"与js的区别

    `lang="ts"` 与 `js` 的区别在于指定了脚本语言的类型,其中: - `lang="ts"` 指定了 TypeScript,一种由微软开发的 Jav ...

  7. elementplus django drf 如何做到确认单据禁止删除

    elementplus django drf 如何做到确认单据禁止删除     要在Django和Django Rest Framework(DRF)中实现禁止删除确认单据的功能,你可以通过以下步骤来 ...

  8. Profinet转Modbus模块减轻通讯编程工作量实现Modbus通讯

    巴图自动化PN转Modbus模块(BT-MDPN10)能够实现Profinet协议与Modbus协议之间的转换,使得Profinet协议设备与Modbus协议设备进行连接并能够相互通信. 通过使用巴图 ...

  9. [oeasy]python0015_十六进制_hexadecimal_字节形态_hex函数

    ​ 十六进制(hexadecimal) 回忆上次内容 上次数制可以转化 bin(n)可以把数字转化为 ​​2进制​ binary 接收一个整数(int) 得到一个二进制数形式的字符串 ​ 编辑 数字在 ...

  10. 题解:P10722 [GESP202406 六级] 二叉树

    题意 一颗 \(n\) 节点的二叉树,每个节点非黑即白,给你 \(Q\) 次操作,每次给你一个 \(u\),把 \(u\) 的子树内所有节点颜色反转,问最终每个节点的颜色. 分析 看到数据范围,首先把 ...