当前位置: 首页 > news >正文

Codeforces Round 888 (Div. 3)(视频讲解全部题目)

@[TOC](Codeforces Round 888 (Div. 3)(视频讲解全部题目))

Codeforces Round 888 (Div. 3)(A–G)全部题目详解
在这里插入图片描述

A Escalator Conversations

#include<bits/stdc++.h>
#define endl '\n'
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N = 1e5 + 10;void solve()
{int n, m, k, H;cin >> n >> m >> k >> H;int ans = 0;for(int i = 0; i < n; i ++){int h;cin >> h;int dis = abs(h - H);if(h != H && dis % k == 0 && dis / k < m)ans ++;}cout << ans << endl;
}signed main()
{ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);int t;cin >> t;while(t--)solve();
}

B Parity Sort

#include<bits/stdc++.h>
#define endl '\n'
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N = 1e5 + 10;void solve()
{int n;cin >> n;vector<int>a(n);for(int i = 0; i < n; i ++)cin >> a[i];vector<int>b;b = a;sort(b.begin(), b.end());for(int i = 0; i < n; i ++){if(a[i] % 2 != b[i] % 2){cout << "NO" << endl;return;}}cout << "YES" << endl;
}signed main()
{ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);int t;cin >> t;while(t--)solve();
}

C Tiles Comeback

#include<bits/stdc++.h>
#define endl '\n'
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N = 1e5 + 10;void solve()
{int n, k;cin >> n >> k;vector<int>a(n);for(int i = 0; i < n; i ++)cin >> a[i];if(a[0] == a.back()){if(count(a.begin(), a.end(), a[0]) >= k)cout << "YES" << endl;elsecout << "NO" << endl;}else{int c1 = count(a.begin(), a.end(), a[0]);int c2 = count(a.begin(), a.end(), a.back());int cnt = 0;for(int i = 0; i < n; i ++){if(a[i] == a[0])cnt ++;if(a[i] == a.back())c2 --;if(cnt == k)break;}if(c1 >= k && c2 >= k){cout << "YES" << endl;}else{cout << "NO" << endl;}}
}signed main()
{ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);int t;cin >> t;while(t--)solve();
}

D Prefix Permutation Sums

#include<bits/stdc++.h>
#define endl '\n'
#define INF 0x3f3f3f3f
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N = 1e5 + 10;void solve()
{int n;cin >> n;vector<int>a(n - 1);for(int i = 0; i < n - 1; i ++)cin >> a[i];int sum = n * (n + 1) / 2;if(sum != a.back()){a.push_back(sum);map<int,bool>st;for(int i = 0; i < n; i ++){int b;if(!i)b = a[i];elseb = a[i] - a[i - 1];if(b <= 0 || b > n || st[b]){cout << "NO" << endl;return;}st[b] = true;}cout << "YES" << endl;}else{map<int,bool>st;int x, cnt = 0;for(int i = 0; i < n - 1; i ++){int b;if(!i)b = a[i];elseb = a[i] - a[i - 1];if(b <= 0 || b > 2 * n){cout << "NO" << endl;return;}if(b > n || st[b]){x = b;cnt ++;}st[b] = true;}if(cnt > 1){cout << "NO" << endl;return;}else{int sum = 0;int c = 0;for(int i = 1; i <= n; i ++){if(!st[i]){sum += i;c ++;}}if(c == 2 && sum == x){cout << "YES" << endl;}else{cout << "NO" << endl;}}}
}signed main()
{ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);int t;cin >> t;while(t--)solve();
}

E Nastya and Potions

#include<bits/stdc++.h>
#define endl '\n'
#define INF 0x3f3f3f3f
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N = 2e5 + 10;
int c[N], idx[N], ans[N];
map<int,bool>p;
int n, k;
vector<int>edge[N];void bfs()
{queue<int>q;for(int i = 0; i < n; i ++){if(idx[i] == 0){q.push(i);if(p[i])ans[i] = 0;elseans[i] = c[i];}}while(q.size()){int t = q.front();q.pop();for(int i = 0; i < edge[t].size(); i ++){int son = edge[t][i];ans[son] += ans[t];idx[son] --;if(idx[son] == 0){if(p[son])ans[son] = 0;elseans[son] = min(ans[son], c[son]);q.push(son);}}}
}void solve()
{cin >> n >> k;for(int i = 0; i < n; i ++){c[i] = idx[i] = ans[i] = 0;edge[i].clear();}p.clear();for(int i = 0; i < n; i ++)cin >> c[i];for(int i = 0; i < k; i ++){int x;cin >> x;x --;p[x] = true;}for(int i = 0; i < n; i ++){int m;cin >> m;for(int j = 0; j < m; j ++){int x;cin >> x;x --;idx[i] ++;edge[x].push_back(i);}}bfs();for(int i = 0; i < n; i ++)cout << ans[i] << " ";cout << endl;
}signed main()
{ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);int t;cin >> t;while(t--)solve();
}

F Lisa and the Martians

#include<bits/stdc++.h>
#define endl '\n'
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N = 1e5 + 10;void solve()
{int n, k;cin >> n >> k;vector<pii>a(n);for(int i = 0; i < n; i ++){cin >> a[i].first;a[i].second = i + 1;}sort(a.begin(), a.end());int minv = INT_MAX, a1, a2, p1, p2;for(int i = 0; i < n - 1; i ++){if(minv > (a[i].first ^ a[i + 1].first)){a1 = a[i].first, a2 = a[i + 1].first;p1 = a[i].second, p2 = a[i + 1].second;minv = a1 ^ a2;}}int x = 0;for(int i = 0; i < k; i ++){int x1 = (a1 >> i) & 1, x2 = (a2 >> i) & 1;if(x1 + x2 == 0)x += 1 << i;}cout << p1 << " " << p2 << " " << x << endl;
}signed main()
{ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);int t;cin >> t;while(t--)solve();
}

G Vlad and the Mountains

#include<bits/stdc++.h>
#define endl '\n'
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N = 2e5 + 10;
int h[N], p[N];
struct NODE
{int a, b, w;
};
struct QRY
{int a, b, h_max, ii;
};
vector<NODE>edge;
vector<QRY>Q;
bool cmp1(NODE x, NODE y)
{return x.w < y.w;
}
bool cmp2(QRY x, QRY y)
{return x.h_max < y.h_max;
}int find(int x)
{if(x != p[x])p[x] = find(p[x]);return p[x];
}
void solve()
{edge.clear();Q.clear();int n, m;cin >> n >> m;for(int i = 1; i <= n; i ++)cin >> h[i];for(int i = 0; i < m; i ++){int a, b;cin >> a >> b;edge.push_back({a,b, max(h[a], h[b])});}sort(edge.begin(), edge.end(), cmp1);int q;cin >> q;vector<bool>ans(q);for(int i = 0; i <= n; i ++)p[i] = i;for(int i = 0; i < q; i ++){int a, b, e;cin >> a >> b >> e;Q.push_back({a, b, h[a] + e, i});}sort(Q.begin(), Q.end(), cmp2);int cnt = 0;for(int i = 0; i < q; i ++){while(cnt < m && Q[i].h_max >= edge[cnt].w){int pa = find(edge[cnt].a), pb = find(edge[cnt].b);if(pa != pb)p[pa] = pb;cnt ++;}if(find(Q[i].a) == find(Q[i].b))ans[Q[i].ii] = true;elseans[Q[i].ii] = false;}for(int i = 0; i < q; i ++){if(ans[i])cout << "YES" << endl;elsecout << "NO" << endl;}cout << endl;
}signed main()
{ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);int t;cin >> t;while(t--)solve();
}

相关文章:

Codeforces Round 888 (Div. 3)(视频讲解全部题目)

[TOC](Codeforces Round 888 (Div. 3)&#xff08;视频讲解全部题目&#xff09;) Codeforces Round 888 (Div. 3)&#xff08;A–G&#xff09;全部题目详解 A Escalator Conversations #include<bits/stdc.h> #define endl \n #define INF 0x3f3f3f3f using namesp…...

MySQL之深入InnoDB存储引擎——物理文件

文章目录 一、参数文件二、日志文件三、表结构定义文件四、InnoDB 存储引擎文件1、表空间文件2、重做日志文件 一、参数文件 当 MySQL 实例启动时&#xff0c;数据库会先去读一个配置参数文件&#xff0c;用来寻找数据库的各种文件所在位置以及指定某些初始化参数。在默认情况…...

Jquery操作html常用函数

1. text() 获取元素的文本内容&#xff1a;$("#element").text(); 设置元素的文本内容&#xff1a;$("#element").text("New Text"); 2. html() 获取元素的 HTML 内容&#xff1a;$("#element").html(); 设置元素的 HTML 内容&am…...

【Lua学习笔记】Lua进阶——Table,迭代器

文章目录 官方唯一指定数据结构--tabletable的一万种用法字典和数组 迭代器ipairs()pairs() 回到Table 在【Lua学习笔记】Lua入门中我们讲到了Lua的一些入门知识点&#xff0c;本文将补充Lua的一些进阶知识 官方唯一指定数据结构–table 在上篇文章的最后&#xff0c;我们指出…...

重庆市北斗新型智慧城市政府项目

技术栈&#xff1a;使用vue2JavaScriptElementUIvuexaxiosmapboxcesium 项目描述&#xff1a;重庆市北斗新型智慧城市政府项目是基于千寻孪界开发的一款智慧城市项目&#xff0c;包含车辆实时位置定位&#xff0c;智能设备的报警&#xff0c;基础设施的部设等等功能 工作内容&a…...

FANUC机器人SRVO-217故障报警原因分析及参考解决办法

FANUC机器人SRVO-217故障报警原因分析及参考解决办法 如下图所示,示教器提示:SRVO-217紧急停止电路板未找到, 查阅手册可以看到以下的报警说明: 故障原因: 通电时未能识别紧急停止电路板或者增设的安全I/O装置。连接有多个安全I/O装置的系统中,在报警信息的最后,会显示发…...

统信UOS安装mysql数据库(mariadb)-统信UOS安装JDK-统信UOS安装nginx(附安装包)

统信UOS离线全套安装教程&#xff08;手把手教程&#xff09; 银河麒麟的各种离线全套安装教程&#xff1a; https://blog.csdn.net/ACCPluzhiqi/article/details/131988147 1.统信UOS桌面系统安装mysql&#xff08;mariadb&#xff09; 2.统信UOS桌面系统安装JDK 3.统信UOS桌…...

上门小程序开发|上门服务小程序|上门家政小程序开发

随着移动互联网的普及和发展&#xff0c;上门服务成为了许多人生活中的一部分。上门小程序是一种基于小程序平台的应用程序&#xff0c;它提供了上门服务的在线平台&#xff0c;为用户提供了便捷的上门服务体验。下面将介绍一些适合开发上门小程序的商家。   家政服务商家&am…...

1000道网络安全必备面试题合集,秋招金九银十必看!!!

以下为网络安全各个方向涉及的面试题&#xff0c;星数越多代表问题出现的几率越大&#xff0c;祝各位都能找到满意的工作。 注&#xff1a;本套面试题&#xff0c;已整理成pdf文档&#xff0c;但内容还在持续更新中&#xff0c;因为无论如何都不可能覆盖所有的面试问题&#x…...

从0-1实现简易Raft分布式共识算法

一、Raft前置简介 Raft目前是最著名的分布式共识性算法&#xff0c;被广泛的应用在各种分布式框架、组件中&#xff0c;如Redis、RocketMq、Kafka、Nacos&#xff08;CP&#xff09;等 根据Raft论文&#xff0c;可将Raft拆分为如下4个功能模块&#xff1a; 领导者选举日志同…...

Spring 创建和使用

Spring 是⼀个包含了众多⼯具⽅法的 IoC 容器。既然是容器那么它就具备两个最基本的功能&#xff1a; 将对象存储到容器&#xff08;Spring&#xff09;中&#xff1b; 从容器中将对象取出来。 在 Java 语⾔中对象也叫做 Bean 1.创建 Spring 项目 接下来使⽤ Maven ⽅式来创…...

Javadoc comment自动生成

光标放在第二行 按下Alt Shift j 下面是Java doc的生成 Next Next-> Finish...

vue3 +ts 报错 index.vue 不是模块

那是因为index.vue中创建了一个空的script标签&#xff0c;而且语法使用的是ts语法。vue-cli会用ts语法解析和校验 如果是无状态组件&#xff0c;删掉 如果是有状态组件&#xff0c;导出该组件的实例 去掉null的script后&#xff1a;...

win10 hadoop报错 unable to load native-hadoop library

win10 安装hadoop执行hdfs -namenode format 和运行hadoop的start-all报错 unable to load native-hadoop library 验证&#xff1a; hadoop checknative -a 这个命令返回都是false是错的 返回下图是正确的 winutils: true D:\soft\hadoop-3.0.0\bin\winutils.exe Native li…...

前端(九)——探索微信小程序、Vue、React和Uniapp生命周期

&#x1f642;博主&#xff1a;小猫娃来啦 &#x1f642;文章核心&#xff1a;探索微信小程序、Vue、React和Uniapp生命周期 文章目录 微信小程序、Vue、React和Uniapp的基本定义和应用领域微信小程序生命周期生命周期概述页面生命周期应用生命周期组件和API的生命周期钩子 Vu…...

MyBatis查询数据库(2)

目录 前言&#x1f36d; 一、增删查改操作 1、查 Ⅰ、mapper接口&#xff1a; Ⅱ、UserMapper.xml 查询所有用户的具体实现 SQL&#xff1a; Ⅲ、进行单元测试 2、增、删、改操作 Ⅰ、增 添加用户 添加用户并且返回自增 id Ⅱ、改 根据id修改用户名 开启 MyBatis …...

Jenkins构建完成后发送消息至钉钉

钉钉群的最终效果&#xff1a; 1、jenkins安装DingTalk插件&#xff0c;安装完成后重启 2、配置钉钉插件 参考官网文档&#xff1a;快速开始 | 钉钉机器人插件 系统管理 拉到最下面&#xff0c;可以看到钉钉配置 按照如下配置钉钉机器人 配置完成可以点击测试按钮&#xff0…...

从浏览器输入url到页面加载(六)前端必须了解的路由器和光纤小知识

前言 上一章我们说到了数据包在网线中的故事&#xff0c;说到了双绞线&#xff0c;还说到了麻花。这一章继续沿着这条线路往下走&#xff0c;说一些和cdn以及路由器相关&#xff0c;运营商以及光纤相关的小知识&#xff0c;前端同学应该了解一下的 目录 前言 1. CDN和路由器…...

C语言假期作业 DAY 06

题目 一、选择题 1、以下叙述中正确的是&#xff08; &#xff09; A: 只能在循环体内和 switch 语句体内使用 break 语句 B: 当 break 出现在循环体中的 switch 语句体内时&#xff0c;其作用是跳出该 switch 语句体&#xff0c;并中止循环体的执行 C: continue 语句的作用是&…...

[nlp] tokenizer加速:fast_tokenizer=True

fast_tokenizer 是一个布尔值参数,用于指定是否使用快速的 tokenizer。在某些情况下,使用快速的 tokenizer 可以加快模型训练和推理速度。如果 fast_tokenizer 参数为 True,则会使用快速的 tokenizer;否则,将使用默认的 tokenizer。 快速的 tokenizer 通常使用一些技巧来减…...

UE5 学习系列(三)创建和移动物体

这篇博客是该系列的第三篇&#xff0c;是在之前两篇博客的基础上展开&#xff0c;主要介绍如何在操作界面中创建和拖动物体&#xff0c;这篇博客跟随的视频链接如下&#xff1a; B 站视频&#xff1a;s03-创建和移动物体 如果你不打算开之前的博客并且对UE5 比较熟的话按照以…...

【大模型RAG】Docker 一键部署 Milvus 完整攻略

本文概要 Milvus 2.5 Stand-alone 版可通过 Docker 在几分钟内完成安装&#xff1b;只需暴露 19530&#xff08;gRPC&#xff09;与 9091&#xff08;HTTP/WebUI&#xff09;两个端口&#xff0c;即可让本地电脑通过 PyMilvus 或浏览器访问远程 Linux 服务器上的 Milvus。下面…...

HTML 列表、表格、表单

1 列表标签 作用&#xff1a;布局内容排列整齐的区域 列表分类&#xff1a;无序列表、有序列表、定义列表。 例如&#xff1a; 1.1 无序列表 标签&#xff1a;ul 嵌套 li&#xff0c;ul是无序列表&#xff0c;li是列表条目。 注意事项&#xff1a; ul 标签里面只能包裹 li…...

vue3 定时器-定义全局方法 vue+ts

1.创建ts文件 路径&#xff1a;src/utils/timer.ts 完整代码&#xff1a; import { onUnmounted } from vuetype TimerCallback (...args: any[]) > voidexport function useGlobalTimer() {const timers: Map<number, NodeJS.Timeout> new Map()// 创建定时器con…...

第 86 场周赛:矩阵中的幻方、钥匙和房间、将数组拆分成斐波那契序列、猜猜这个单词

Q1、[中等] 矩阵中的幻方 1、题目描述 3 x 3 的幻方是一个填充有 从 1 到 9 的不同数字的 3 x 3 矩阵&#xff0c;其中每行&#xff0c;每列以及两条对角线上的各数之和都相等。 给定一个由整数组成的row x col 的 grid&#xff0c;其中有多少个 3 3 的 “幻方” 子矩阵&am…...

基于 TAPD 进行项目管理

起因 自己写了个小工具&#xff0c;仓库用的Github。之前在用markdown进行需求管理&#xff0c;现在随着功能的增加&#xff0c;感觉有点难以管理了&#xff0c;所以用TAPD这个工具进行需求、Bug管理。 操作流程 注册 TAPD&#xff0c;需要提供一个企业名新建一个项目&#…...

在Mathematica中实现Newton-Raphson迭代的收敛时间算法(一般三次多项式)

考察一般的三次多项式&#xff0c;以r为参数&#xff1a; p[z_, r_] : z^3 (r - 1) z - r; roots[r_] : z /. Solve[p[z, r] 0, z]&#xff1b; 此多项式的根为&#xff1a; 尽管看起来这个多项式是特殊的&#xff0c;其实一般的三次多项式都是可以通过线性变换化为这个形式…...

MySQL 8.0 事务全面讲解

以下是一个结合两次回答的 MySQL 8.0 事务全面讲解&#xff0c;涵盖了事务的核心概念、操作示例、失败回滚、隔离级别、事务性 DDL 和 XA 事务等内容&#xff0c;并修正了查看隔离级别的命令。 MySQL 8.0 事务全面讲解 一、事务的核心概念&#xff08;ACID&#xff09; 事务是…...

解决:Android studio 编译后报错\app\src\main\cpp\CMakeLists.txt‘ to exist

现象&#xff1a; android studio报错&#xff1a; [CXX1409] D:\GitLab\xxxxx\app.cxx\Debug\3f3w4y1i\arm64-v8a\android_gradle_build.json : expected buildFiles file ‘D:\GitLab\xxxxx\app\src\main\cpp\CMakeLists.txt’ to exist 解决&#xff1a; 不要动CMakeLists.…...

wpf在image控件上快速显示内存图像

wpf在image控件上快速显示内存图像https://www.cnblogs.com/haodafeng/p/10431387.html 如果你在寻找能够快速在image控件刷新大图像&#xff08;比如分辨率3000*3000的图像&#xff09;的办法&#xff0c;尤其是想把内存中的裸数据&#xff08;只有图像的数据&#xff0c;不包…...