wordpress 短码按钮/搜索引擎优化的完整过程
新年坐大牢
A - Wallet Exchange
题意:共有俩钱包,每回合从其中一个钱包中拿走一块钱,谁拿走最后一块钱谁赢。
思路:奇偶讨论即可。
// Problem: A. Wallet Exchange
// Contest: Codeforces - Hello 2024
// URL: https://codeforces.com/contest/1919/problem/0
// Memory Limit: 256 MB
// Time Limit: 1000 ms
//
// Powered by CP Editor (https://cpeditor.org)#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define pb push_back
#define x first
#define y second
#define endl '\n'
const LL maxn = 4e05+7;
const LL N = 5e05+10;
const LL mod = 1e09+7;
const int inf = 0x3f3f3f3f;
const LL llinf = 5e18;
typedef pair<int,int>pl;
priority_queue<LL , vector<LL>, greater<LL> >mi;//小根堆
priority_queue<LL> ma;//大根堆
LL gcd(LL a, LL b){return b > 0 ? gcd(b , a % b) : a;
}LL lcm(LL a , LL b){return a / gcd(a , b) * b;
}
int n , m;
vector<int>a(N , 0);
void init(int n){for(int i = 0 ; i <= n ; i ++){a[i] = 0;}
}
void solve()
{LL a , b;cin >> a >> b;LL t = a + b;if(t & 1){cout <<"Alice\n";} else{cout<<"Bob\n";}
}
int main()
{ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout.precision(10);int t=1;cin>>t;while(t--){solve();}return 0;
}
B - Plus-Minus Split
题意:给定一个"+-"串,其中"+"代表了‘’+1“,"-”代表了“-1”.你需要将整个串分成若干份,每一份的价值为子串所代表的数的绝对值,求整个串的最小价值.
思路:贪心,其实整个串的价值就是最小价值.
// Problem: B. Plus-Minus Split
// Contest: Codeforces - Hello 2024
// URL: https://codeforces.com/contest/1919/problem/B
// Memory Limit: 256 MB
// Time Limit: 1000 ms
//
// Powered by CP Editor (https://cpeditor.org)#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define pb push_back
#define x first
#define y second
#define endl '\n'
const LL maxn = 4e05+7;
const LL N = 5e05+10;
const LL mod = 1e09+7;
const int inf = 0x3f3f3f3f;
const LL llinf = 5e18;
typedef pair<int,int>pl;
priority_queue<LL , vector<LL>, greater<LL> >mi;//小根堆
priority_queue<LL> ma;//大根堆
LL gcd(LL a, LL b){return b > 0 ? gcd(b , a % b) : a;
}LL lcm(LL a , LL b){return a / gcd(a , b) * b;
}
int n , m;
vector<int>a(N , 0);
void init(int n){for(int i = 0 ; i <= n ; i ++){a[i] = 0;}
}
void solve()
{cin >> n;int ans = 0;string s;cin >> s;for(int i = 0 ; i < n ; i ++){if(s[i] == '+'){ans++;}else{ans--;}} cout << abs(ans) << endl;
}
int main()
{ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout.precision(10);int t=1;cin>>t;while(t--){solve();}return 0;
}
C - Grouping Increases
题意:给定一个数组,要求将其分成两部分,要求每部分中元素在原数组中的相对位置不能改变,每一部分的价值为:这一部分中,前一个数小于后一个数的个数.求两部分价值之和的最小值。
思路:可以想到,由于无法改变相对顺序,我们需要从前往后的插入元素.而每一部分的最后一个元素值应当越大越好。因此我们每次插入元素只需要插入到两个部分中尾数小的那部分即可,然后再算出总共价值就是最小价值.
// Problem: C. Grouping Increases// Contest: Codeforces - Hello 2024// URL: https://codeforces.com/contest/1919/problem/C// Memory Limit: 256 MB// Time Limit: 1000 ms// // Powered by CP Editor (https://cpeditor.org)#include <bits/stdc++.h>using namespace std;#define LL long long#define pb push_back#define x first#define y second #define endl '\n'const LL maxn = 4e05+7;const LL N = 5e05+10;const LL mod = 1e09+7;const int inf = 0x3f3f3f3f;const LL llinf = 5e18;typedef pair<int,int>pl;priority_queue<LL , vector<LL>, greater<LL> >mi;//小根堆priority_queue<LL> ma;//大根堆LL gcd(LL a, LL b){return b > 0 ? gcd(b , a % b) : a;}LL lcm(LL a , LL b){return a / gcd(a , b) * b;}int n , m;vector<int>a(N , 0);void init(int n){for(int i = 0 ; i <= n ; i ++){a[i] = 0;}}void solve() {int rear[2] = {inf , inf};int n;cin >> n;for(int i = 0 ; i < n ; i ++){cin >> a[i];} int ans = 0;for(int i = 0 ; i < n ; i ++){int cnt = 0;for(int j = 0 ; j < 2 ; j ++){cnt += (rear[j] < a[i]);}if(cnt == 0){if(rear[0] < rear[1]){rear[0] = a[i];}else{rear[1] = a[i];}}else if(cnt == 1){if(rear[0] < a[i]){rear[1] = a[i];}else{rear[0] = a[i];}}else{if(rear[0] < rear[1]){rear[0] = a[i];}else{rear[1] = a[i];}ans++;}}cout << ans << endl;} int main() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout.precision(10);int t=1;cin>>t;while(t--){solve();}return 0;}
F1 - Wine Factory (Easy Version)
题意:
思路:由于固定了,也就是前一个水塔的水必定能全部流入后一个水塔.
这是一开始的想法,然后发现整个过程其实是一个区间从前往后合并的过程,因此考虑用线段树去解决区间合并问题。
接下来考虑如何合并:若前面区间还有剩余的水,那么可以由后面的魔法师去变为葡萄酒,因此我们需要知道的是,区间中还剩多少水和区间中的魔法师还剩多少能量。同时我们还可以统计转换了多少葡萄酒。
每次只需要单点修改和整个区间查询就行了。
// Problem: F1. Wine Factory (Easy Version)
// Contest: Codeforces - Hello 2024
// URL: https://codeforces.com/contest/1919/problem/F1
// Memory Limit: 512 MB
// Time Limit: 5000 ms
//
// Powered by CP Editor (https://cpeditor.org)#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define pb push_back
#define x first
#define y second
#define endl '\n'
#define int long long
const LL maxn = 4e05+7;
const LL N = 5e05+10;
const LL mod = 1e09+7;
const int inf = 0x3f3f3f3f;
const LL llinf = 5e18;
typedef pair<int,int>pl;
priority_queue<LL , vector<LL>, greater<LL> >mi;//小根堆
priority_queue<LL> ma;//大根堆
LL gcd(LL a, LL b){return b > 0 ? gcd(b , a % b) : a;
}
vector<int>a(N , 0);
vector<int>b(N, 0);
vector<int>c(N, 0);
struct info{LL Res;//剩余多少水LL Res_ma;//魔法师还剩余多少能量LL Value;//价值friend info operator + (info a ,info b){info c;c.Value = a.Value + b.Value;c.Res_ma = b.Res_ma + a.Res_ma;if(a.Res > 0){int d = min(a.Res , b.Res_ma);c.Res_ma -= d;c.Value += d;a.Res -= d;}c.Res = a.Res + b.Res;return c;}
};
struct node{info val;
} seg[N * 4];
struct SegTree{void update(int id){seg[id].val = seg[id * 2].val + seg[id * 2 + 1].val;}void build(int id, int l, int r){if (l == r) {seg[id].val = {max(0 * 1LL ,a[l] - b[l]) , max(0 * 1LL , b[l] - a[l]) , min(a[l] , b[l])};}else{int mid = (l + r) / 2;build(id * 2, l, mid);build(id * 2 + 1, mid + 1, r);update(id);}}void modify(int id, int l, int r, int ql, int qr){if (l == ql && r == qr){seg[id].val = {max(0 * 1LL ,a[l] - b[l]) , max(0 * 1LL , b[l] - a[l]) , min(a[l] , b[l])};return;}if (ql > r || qr < l) // 区间无交集return; // 剪枝int mid = (l + r) / 2;if (qr <= mid) modify(id * 2, l, mid, ql, qr);else if (ql > mid) modify(id * 2 + 1, mid + 1, r, ql, qr);else{modify(id * 2, l, mid, ql, mid);modify(id * 2 + 1, mid + 1, r, mid + 1, qr);}update(id);}info query(int id, int l, int r, int ql, int qr){if (ql == l && qr == r) return seg[id].val;int mid = (l + r) / 2;if (qr <= mid) return query(id * 2, l, mid, ql, qr);else if (ql > mid) return query(id * 2 + 1, mid + 1, r, ql, qr);else{return query(id * 2, l, mid, ql, mid) + query(id * 2 + 1, mid + 1, r, mid + 1, qr);}}
};
LL lcm(LL a , LL b){return a / gcd(a , b) * b;
}
int n , m;
void solve()
{cin >> n >> m;for(int i = 1 ; i <= n ; i ++){cin >> a[i];}for(int i = 1 ; i <= n ; i ++){cin >> b[i];}for(int i = 1 ; i < n ; i ++){cin >> c[i];}SegTree segTree;segTree.build(1 , 1 , n);for(int i = 0 ; i < m ; i ++){int q , x , y , z;cin >> q >> x >> y >> z;a[q] = x;b[q] = y;segTree.modify(1 , 1 , n , q , q);cout << segTree.query(1 , 1 , n , 1 , n).Value << endl;}
}
signed main()
{ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout.precision(10);int t=1;
// cin>>t;while(t--){solve();}return 0;
}
D - 01 Tree
题意:先有一颗未知的完整二叉树,非叶子结点的两条与子节点相连的边权一个为0,另一个为1.如今给出了根据dfs序的叶子结点的权值序列,求能否还原出一颗完整二叉树.定义结点的权值为该节点到根节点的边权之和.
思路:可以发现:同一个父亲的两个叶子结点的权值只差了1,且两个叶子结点中小的那个就是父节点的权值.也就是说,dfs序中若相邻两个数差了1,那么这两个数就是同一个父亲结点的。由此我们可以将同一个父亲的两个叶子结点中大的删除,小的保留,这样就相当于将两个叶子结点给删除了.最后若只剩下一个点没有被删除,且这个点为0,那么就代表了能够通过删除操作只保留一个顶点,反过来也就是说通过这个序列能够形成一个完整二叉树.
// Problem: D. 01 Tree
// Contest: Codeforces - Hello 2024
// URL: https://codeforces.com/contest/1919/problem/D
// Memory Limit: 256 MB
// Time Limit: 1000 ms
//
// Powered by CP Editor (https://cpeditor.org)#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define pb push_back
#define x first
#define y second
#define endl '\n'
const LL maxn = 4e05+7;
const LL N = 5e05+10;
const LL mod = 1e09+7;
const int inf = 0x3f3f3f3f;
const LL llinf = 5e18;
typedef pair<int,int>pl;
priority_queue<LL , vector<LL>, greater<LL> >mi;//小根堆
priority_queue<LL> ma;//大根堆
LL gcd(LL a, LL b){return b > 0 ? gcd(b , a % b) : a;
}LL lcm(LL a , LL b){return a / gcd(a , b) * b;
}
int n , m;
vector<int>a(N , 0);
void init(int n){for(int i = 0 ; i <= n ; i ++){a[i] = 0;}
}
void solve()
{cin >> n;for(int i = 1; i <= n ; i ++){cin >> a[i];}a[0] = a[n + 1] = -inf;vector<int>nex(n + 5 , 0) , pre(n + 5 , 0);for(int i = 1; i <= n ; i ++){nex[i] = i + 1;pre[i] = i - 1;}auto check = [&](int x){return (a[pre[x]] == a[x] - 1) || (a[nex[x]] == a[x] - 1);};vector<int>in(n + 5 , 0);priority_queue<pair<int,int>>ma;for(int i = 1 ; i <= n ; i ++){if(check(i)){in[i] = 1;ma.push({a[i] , i});}}while(!ma.empty()){auto tmp = ma.top();ma.pop();int pos = tmp.y;nex[pre[pos]] = nex[pos];pre[nex[pos]] = pre[pos];if(!in[nex[pos]] && check(nex[pos])){in[nex[pos]] = 1;ma.push({a[nex[pos]] , nex[pos]});}if(!in[pre[pos]] && check(pre[pos])){in[pre[pos]] = 1;ma.push({a[pre[pos]] , pre[pos]});}}int mi = n , bad = 0;for(int i = 1 ; i <= n ; i ++){bad += (!in[i]);mi = min(mi , a[i]);}if(bad == 1 && mi == 0){cout <<"YES\n";}else{cout <<"NO\n";}
}
int main()
{ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout.precision(10);int t=1;cin>>t;while(t--){solve();}return 0;
}
相关文章:
Hello 2024(A~D,F1)
新年坐大牢 A - Wallet Exchange 题意:共有俩钱包,每回合从其中一个钱包中拿走一块钱,谁拿走最后一块钱谁赢。 思路:奇偶讨论即可。 // Problem: A. Wallet Exchange // Contest: Codeforces - Hello 2024 // URL: https://cod…...

Python+Torch+FasterCNN网络目标检测识别
程序示例精选 PythonTorchFasterCNN网络目标检测识别 如需安装运行环境或远程调试,见文章底部个人QQ名片,由专业技术人员远程协助! 前言 这篇博客针对《PythonTorchFasterCNN网络目标检测识别》编写代码,代码整洁,规…...

v8 pwn利用合集
文章目录 前置知识JS Object 相关Ignition 相关JIT - turboFan 相关starCTF2019 OOB【越界读写map字段】googleCTF2018 jit【浮点数精度丢失导致越界读写】数字经济线下 Browser【Object::toNumber中callback导致的越界写】前置知识 JS Object 相关 V8 中的对象表示 ==> 基…...

JVM:字节码
JVM:字节码 前言1. JVM概述1.1 JVM vs JDK vs JRE1.1.1 JVM1.1.2 JDK1.1.2.1 常用的JDK8是Oracle JDK 还是 OpenJDK 1.1.3 JRE1.1.4 三者之间的关系与区别 1.2 什么是字节码?采用字节码的好处是什么?1.3 Java 程序从源代码到运行的过程1.4 JVM的生命周期1.5 JVM架…...

常见网络设备及功能详解
网络设备 - 交换机 交换机:距离终端用户最近的设备,用于终端用户接入网络、对数据帧进行交换等。 交换机的功能: 终端设备(PC、服务器等)的网络接入二层交换(Layer 2 Switching) 网络设备 - …...

Python教程(20)——python面向对象编程基本概念
面向对象 类和对象初始化方法属性和方法self关键字继承多态 面向对象(Object-oriented)是一种常用的程序设计思想,它以对象作为程序的基本单元,将数据和操作封装在一起,通过对象之间的交互来实现程序的功能。 在面向对…...

C# Winform教程(一):MD5加密
1、介绍 在C#中,MD5(Message Digest Algorithm 5)是一种常用的哈希函数,用于将任意长度的数据转换为固定长度的哈希值(通常是128位)。MD5广泛用于校验数据完整性、密码存储等领域。 2、示例 创建MD5加密…...

Mongodb使用指定索引删除数据
回顾Mongodb删除语法 db.collection.deleteMany(<filter>,{writeConcern: <document>,collation: <document>,hint: <document|string>} ) 删除语法中,除了指定过滤器外,还可以指定写入策略,字符序和使用的索引。 …...

虾皮怎么选品:虾皮(Shopee)跨境电商业务成功的关键步骤
在虾皮(Shopee)平台上进行跨境电商业务,选品是至关重要的一环。有效的选品策略可以帮助卖家更好地了解市场需求,提高销售业绩和客户满意度。以下是一些成功的选品策略,可以帮助卖家在虾皮平台上取得更好的业务成绩。 先…...

QML —— 使用Qt虚拟键盘示例(附完整源码)
示例效果 使用"虚拟键盘"注意 (例子的Qt版本:5.12.4) 注意一: /* 必须在main.cpp开始处加入如下代码,否则无法使用"虚拟键盘" */ qputenv(“QT_IM_MODULE”,QByteArray(“qtvirtualkeybo…...

Nacos 持久化及集群的搭建【微服务】
文章目录 一、统一配置管理二、微服务配置拉取三、配置热更新四、多环境共享配置五、Nacos 集群搭建1. 集群结构2. 初始化数据库3. 搭建集群 六、Nginx 反向代理七、启动项目测试 一、统一配置管理 案例练习的时候我们只有两个微服务,管理起来非常简单,但…...

win10下vscode+cmake编译C代码操作详解
0 工具准备 1.Visual Studio Code 1.85.1 2.cmake 3.24.01 前言 当我们只有一个.c文件时直接使用vscodeCode Runner插件即可完成编译,如果我们的工程很复杂包含多个.c文件时建议使用cmake来生成对应的make,指导编译器完成编译,否则会提示各…...

网络安全红队常用的攻击方法及路径
一、信息收集 收集的内容包括目标系统的组织架构、IT资产、敏感信息泄露、供应商信息等各个方面,通过对收集的信息进行梳理,定位到安全薄弱点,从而实施下一步的攻击行为。 域名收集 1.备案查询 天眼查爱企查官方ICP备案查询 通过以上三个…...

【基于openGauss2.1.0企业版安装X-Tuner参数调优工具】
【基于openGauss2.1.0企业版安装X-Tuner参数调优工具】 一、前提条件二、安装X-Tuner 2.1.0: 一、前提条件 已安装了openGauss2.1.0企业版 二、安装X-Tuner 2.1.0: 以root用户登录到服务器 安装以下依赖: yum -y groupinstall "Development tools" yum…...

SpringBoot+Vue轻松实现考试管理系统
简介 本系统基于 Spring Boot 搭建的方便易用、高颜值的教学管理平台,提供多租户、权限管理、考试、练习、在线学习等功能。主要功能为在线考试、练习、刷题,在线学习。课程内容支持图文、视频,考试类型支持考试、练习、问卷。 源码下载 网…...

详解Keras:keras.preprocessing.image
keras.preprocessing.image Keras 库中的一个模块,用于处理和增强图像数据,它提供了一些实用的函数,如图像的加载、预处理、增强等。 常用函数 1、load_img 用于加载图像文件,并返回一个 NumPy 数组表示该图像 示例 from ker…...

来瞅瞅Java 11都有啥新特性
第1章:引言 大家好,我是小黑!今天小黑要和咱们聊聊Java 11,这个在Java发展史上占有一席之地的版本。说起Java,咱们都知道,它是一门历史悠久又持续发展的编程语言。Java不仅因其“一次编写,到处…...

Copilot在IDEA中的应用:提升编码效率的得力助手
Copilot在IDEA中的应用:提升编码效率的得力助手 前言: 欢迎来到本篇博客,今天我们将深入探讨 GitHub Copilot 在 IntelliJ IDEA 中的应用。GitHub Copilot 是一款由 GitHub 与 OpenAI 共同开发的人工智能代码生成工具,它能够根据上下文提示…...

【Python】Excel不同sheet另存为不同CSV
我有一个excel,内有不同sheet,现在批量生成不通csv文件,并以sheet名命名,或根据sheet名调整命名。 # 读取新的Excel文件 df pd.read_excel(rD:\itm\data.xlsx, sheet_nameNone)# 遍历每个sheet,将其另存为不同的CSV文…...

软件测试|深入学习 Docker Logs
简介 Docker 是一种流行的容器化技术,它能够帮助用户将应用程序及其依赖项打包成一个可移植的容器。Docker logs 是 Docker 提供的用于管理容器日志的命令,本文将深入学习 Docker logs 的使用和管理,帮助用户更好地监测和解决容器问题。 Do…...
试除法求约数算法总结
知识概览 试除法求一个数的约数的时间复杂度是。 例题展示 题目链接 活动 - AcWing 系统讲解常用算法与数据结构,给出相应代码模板,并会布置、讲解相应的基础算法题目。https://www.acwing.com/problem/content/871/ 题解 用试除法求约数,…...

[JavaWeb玩耍日记] 数据库
mysql版本:5.7.24 使用Navicat for MySQL辅助学习(2015年版),这个在粘贴本博客的块引用内容时会有额外的不可见内容导致sql运行出问题,不过有影响的地方笔者已排除 目录 一.数据库创建 二.使用数据库与创建表 三.表内列的数据类型 四.修…...

rime中州韵小狼毫 inputShow lua Translator 输入字符透传翻译器
在 rime中州韵小狼毫 help lua Translator 中我们分享了如何使用 lua 脚本定义一个 translator,并以 五笔・拼音 为例引用了该 translator,并且达到了预期的效果。 今天,我们继续通过 lua 脚本为 rime中州韵/小狼毫 输入法打造一个 translat…...

【RockChip | RV1126】学习与开发
【RockChip | RV1126】学习与开发 文章目录 【RockChip | RV1126】学习与开发1. 资料1. 资料 您好,这是关于A191型RV1126的资料包,请您及时接收哦~链接: https://pan.baidu.com/s/1FXWVxa27Q78nI78d2QKlBQ?pwd=j7mk 提取码: j7mk 若您在开发过程中遇到技术问题,需要帮助时:…...

copilot在pycharm的应用
Copilot在PyCharm中的应用 一、引言 随着人工智能技术的飞速发展,AI在编程领域的应用也越来越广泛。Copilot,作为一款由微软开发的AI编程助手,已经引起了广大开发者的关注。它利用深度学习技术,通过分析大量开源代码,…...

HDU 2841:Visible Trees ← 容斥原理
【题目来源】http://acm.hdu.edu.cn/showproblem.php?pid2841【题目描述】 There are many trees forming a m * n grid, the grid starts from (1,1). Farmer Sherlock is standing at (0,0) point. He wonders how many trees he can see. If two trees and Sherlock are in…...

分布式数据之复制(Replication)
1.简介 1.1简介——使用复制的目的 在分布式系统中,数据通常需要被分散在多台机器上,主要为了达到以下目的: 扩展性,数据量因读写负载巨大,一台机器无法承载,数据分散在多台机器 上可以有效地进行负载均衡…...

【多线程】
文章目录 一、线程与进程的概念:二、多线程实现三、线程锁四、线程数量的设置 一、线程与进程的概念: 简单理解 假设总共有3个孩子需要喂饭,孩子每吃一口饭需要咀嚼消化一下。 多线程方案: 雇佣1个保姆,在喂A孩子吃饭…...

基于Vue开发的一个仿京东电商购物平台系统(附源码下载)
电商购物平台项目 项目完整源码下载 基于Vue开发的一个仿京东电商购物平台系统 Build Setup # csdn下载该项目源码压缩包 解压重命名为sangpinghui_project# 进入项目目录 cd sangpinghui_project# 安装依赖 npm install# 建议不要直接使用 cnpm 安装以来,会有各…...

Nginx多ip部署多站点
目录 1.修改网卡配置信息 2.修改主要配置文件nginx.conf 1.修改网卡配置信息 1)来到网卡配置文件存放目录下 cd /etc/sysconfig/network-scripts/ 2)对 ifcfg-ens33 文件进行配置修改前先进行备份 cp ifcfg-ens33 ifcfg-ens33.default 3)先修改成最小配置,使用 d…...