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. DHorse v1.5.1 发布,基于 k8s 的发布平台

    版本说明 新增特性 支持k8s的v1.30.x版本: 优化特性 优化回滚功能: 修复注册来源的回滚问题: 新增和修改应用时校验应用名: 升级kubernetes-client至v6.13.0: 调整部 ...

  2. centos8使用nmcli实现bond

    #添加bonding接口 nmcli con add type bond con-name bond0 ifname bond0 mode active-backup ipv4.method manu ...

  3. ENSP的VirtualBox虚拟网卡不能用

    VirtualBox 安装好后本地会新建一个名为 "VirtualBox Host-Only Network" 的虚拟网卡,虚拟机可以通过这个虚拟网卡网卡和物理机通信.但ENSP有 ...

  4. 含税仅498元起!复旦微ARM + FPGA SoC全国产工业核心板,性价比真高!

     

  5. Canavs在文字上绘制删除线/中划线

    效果图: 思路: 绘制文字 绘制高度为1px的长方形,并用黑色填充 长方形的宽度为文字的长度 具体代码: let canvas = document.getElementById('canvas'); ...

  6. JS--正则表达式--手稿

  7. FairMOT复现报错存档

    FairMOT复现 使用pip命令单独安装Cython包即可 修改下载的cython-bbox包里的setup.py里的代码 将#extra_compile_args=['-Wno-cpp'], 修改 ...

  8. 靶机: AdmX_new

    靶机: AdmX_new 准备阶段 靶机:https://download.vulnhub.com/admx/AdmX_new.7z 下载后进行 MD5:2948034da23a8acc1285fd4 ...

  9. [UE源码] 关于使用UE待改进的一些尝试

    UE从自己做了一款游戏后,发现了蓝图以及UE引擎本身的一些优缺点: 1.蓝图在一些简单的逻辑上书写方便,直观,而且编译速度快,但是也有一些其他问题: 结构体赋值后,无法二次修改 只有3种容器Array ...

  10. 游戏开发进行中UE5引擎打不开后续

    游戏每次启动都有个问题: 之前我实现了插件里的接口,但是已启动,关于接口这一块的就消失了,有些函数还在但是却是自定义事件,不是接口里的,Class Settings里面也提了 然后我把他改成了新的ch ...