2025国庆Day2

模拟赛

T1

简单题

离散化+差分即可

或者直接贪心

对可能成为答案的点计算删的区间并取min

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<bits/stdc++.h>
#define int long long
#define jiaa(a,b) {a+=b;if(a>=MOD) a-=MOD;}
#define jian(a,b) {a-=b;if(a<0) a+=MOD;}
using namespace std;
int ksm(int a,int b,int p){if(b==0) return 1;if(b==1) return a%p;int c=ksm(a,b/2,p);c=c*c%p;if(b%2==1) c=c*a%p;return c%p;	
}
inline int read()
{int x=0,f=1;char ch=getchar();while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}while (ch>='0'&&ch<='9'){x=x*10+ch-48;ch=getchar();}return x*f;
}
int L[200005],R[200005],cnt,cn;
double p[800005],an[400005];
signed main()
{freopen("interval.in", "r", stdin);freopen("interval.out", "w", stdout);int T=read();while(T--){int n=read();cn=0;for(int i=1;i<=n;i++){L[i]=read();R[i]=read();an[++cn]=L[i];an[++cn]=R[i];}if(n<=1){cout<<-1<<'\n';continue;}sort(L+1,L+n+1);sort(R+1,R+n+1);sort(an+1,an+cn+1);cnt=0;for(int i=1;i<=cn;i++){p[++cnt]=1.0*an[i];if(i<cn) p[++cnt]=(an[i]+an[i+1])/2.0;}int minn=n;for(int i=1;i<=cnt;i++){int rsu=lower_bound(R+1,R+n+1,p[i])-R-1;int lsu=n-(upper_bound(L+1,L+n+1,p[i])-L-1);if(rsu&&lsu){minn=min(minn,n-rsu-lsu);}}if(minn>=n) cout<<-1<<'\n';else cout<<minn<<'\n';}return 0;
}

T2

猜结论

容易发现一开始答案为2^(n+m-1)

因为只要第一行第一列填满,剩余就全部确定了

具体的,a[i,j]=a[1,1]a[1,j]a[i,1]

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<bits/stdc++.h>
#define int long long
#define jiaa(a,b) {a+=b;if(a>=MOD) a-=MOD;}
#define jian(a,b) {a-=b;if(a<0) a+=MOD;}
using namespace std;
int ksm(int a,int b,int p){if(b==0) return 1;if(b==1) return a%p;int c=ksm(a,b/2,p);c=c*c%p;if(b%2==1) c=c*a%p;return c%p;	
}
inline int read()
{int x=0,f=1;char ch=getchar();while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}while (ch>='0'&&ch<='9'){x=x*10+ch-48;ch=getchar();}return x*f;
}
const int MOD=1e9+7;
int ans,n,m,q,sec[600005];
int fa[600005],val[600005];
int find(int x){if(fa[x]==x) return x;int ff=find(fa[x]);val[x]^=val[fa[x]];fa[x]=ff;return ff;
}
int merge(int x,int y,int c){int fx=find(x);int fy=find(y);if(fx==fy){if((val[x]^val[y])!=c) return 2;else return 1;} fa[fx]=fy;val[fx]=val[y]^val[x]^c;return 0;
}
signed main()
{freopen("color.in", "r", stdin);freopen("color.out", "w", stdout);n=read(),m=read(),q=read();sec[0]=1;for(int i=1;i<=n+m;i++) sec[i]=sec[i-1]*2%MOD;ans=n+m-1;cout<<sec[ans]<<'\n';for(int i=1;i<=n+m;i++) fa[i]=i;while(q--){int x=read(),y=read(),c=read();int zh=merge(x,y+n,c);if(zh==2) ans=-1;else if(!zh){if(ans!=-1) ans--;} if(ans==-1) cout<<0<<'\n';else cout<<sec[ans]<<'\n';}return 0;
}

T3

T4

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/926006.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

灵犀科技网站开发WordPress获取评论内容

5大安全产品全面升级&#xff0c;抢先了解&#xff1a;https://developer.aliyun.com/topic/securityapril 预约观看发布会&#xff1a;https://yq.aliyun.com/live/2670 新基建大势之下的物联网 近日&#xff0c;中央政治局常委会会议提出&#xff0c;加快发展5G、数据中心、…

新能源汽车整车电控环境详解!

新能源汽车整车电控环境详解!pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco"…

《吃透 C++ vector:从基础使用到核心接口实战指南》 - 指南

pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco", "Courier New", …

广州旅游网站建设设计学做投资网站好

DevExpress ASP. NET Scheduler组件能完全复制Microsoft Outlook Scheduler的样式和功能&#xff0c;具有日、周、月和时间轴视图&#xff0c;并包括内置的打印支持&#xff0c;因此用户可以在尽可能短的时间内交付全功能的个人信息管理系统。在上文中&#xff08;点击这里回顾…

完整教程:GitOps:一种实现云原生的持续交付模型

完整教程:GitOps:一种实现云原生的持续交付模型pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas",…

黑马程序员苍穹外卖学习指南(本文消除我跟视频做该项目时遇到的问题和解决方法)

黑马程序员苍穹外卖学习指南(本文消除我跟视频做该项目时遇到的问题和解决方法)pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font…

做网站的个人心得学校网站模版

基于蚁群算法的TSP问题建模求解 一、蚁群优化算法&#xff08;Ant Colony Optimization&#xff0c;ACO&#xff09;1.1 蚁群算法的起源——“双桥实验”1.2 蚁群优化算法思想1.3 蚁群算法应用于求解组合优化问题 二、基于蚁群算法的TSP问题建模求解2.1 旅行商问题&#xff08;…

佛山网站建设百家号网站统计平台

使用Selenium处理动态生成的网页内容和语法代码可以通过以下步骤进行&#xff1a; 安装Selenium库&#xff1a;使用pip命令安装Selenium库&#xff0c;可以在命令行中运行如下命令&#xff1a; pip install selenium 下载WebDriver&#xff1a;Selenium需要与特定的浏览器进行交…

P11983 [JOIST 2025] 展览会 3 题解

Description JOI 美术馆计划近期举办一场绘画展览。馆方拥有编号为 \(1\) 至 \(N\) 的 \(N\) 幅画作,其中画作 \(i\)(\(1 \leq i \leq N\))的美观值为 \(A_i\)。在展览中这些画作将排成一行展示,但具体排列顺序尚未…

黑客马拉松(Hackathon)

黑客马拉松(Hackathon)黑客马拉松是一种 短时间内高强度的软件/硬件开发活动。一般持续 24~72 小时,有的甚至一周。参与者通常是开发者、设计师、产品经理等,组成小团队。目标是在有限时间里,从零开始,开发出一个…

详细介绍:Quarkus深度解析:响应式编程与Native镜像,如何重构Java云原生应用?

详细介绍:Quarkus深度解析:响应式编程与Native镜像,如何重构Java云原生应用?2025-10-03 14:29 tlnshuju 阅读(0) 评论(0) 收藏 举报pre { white-space: pre !important; word-wrap: normal !important; overfl…

节能网站源码深圳外贸业务员工资

void SaveBitmapToFile(HBITMAP hBitmap, char* szfilename) {HDC hdc; //设备描述表int ibits;WORD wbitcount; //当前显示分辨率下每个像素所占字节数//位图中每个像素所占字节数&#xff0c;定义调色板大小&#xff0c;位图中像素字节大小&#xff0c;位图文件大小 &a…

网络流 费用流 EK算法

模板题:洛谷p3381 #include<bits/stdc++.h> using namespace std; const int N=5e3+10,M=5e4+10,INF=0x3f3f3f3f; typedef long long LL; int n,m,s,t,id=1; int e[M<<1],h[N],cap[M<<1],d[M<&l…

“AI元人文”构想说明:构建智能时代的人文学科新范式

“AI元人文”构想说明:构建智能时代的人文学科新范式 一、 构想缘起与问题意识 我们正处在一个由人工智能技术驱动的历史性转折点。AI不仅重塑着我们的物质世界,更深刻地介入并挑战着人类对语言、文化、历史、伦理和…

双向LSTM-Attention模型

为了让你彻底理解双向LSTM-Attention模型的每一步,我们会在原有运转流程的基础上,对每个核心概念做“定义+通俗解释+模型中作用+项目实例”的四层拆解,从最基础的“时序窗口”到复杂的“注意力权重计算”,每个概念…

tomcat的功能和作用 - 详解

pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco", "Courier New", …

实用指南:【论文阅读 | ECCV 2024 | DAMSDet:具有竞争性查询选择与自适应特征融合的动态自适应多光谱检测变换器】

pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco", "Courier New", …

手机网站开发 pdf网页特效源码网站

来源&#xff1a;软件定义世界&#xff08;SDX&#xff09;作者&#xff1a;吴甘沙、张玉新摘要&#xff1a;当卡尔 本茨发明汽车&#xff0c;人类进入汽车时代时&#xff0c;科学技术就对人类的 “ 出行 ” 进行了新的定义&#xff0c;而随着技术的不断发展与进步&#xff0c…

Xilinx高性能NVMe Host控制器IP+PCIe 3.0软核控制器IP,4通道DMA,1通道IO,纯逻辑实现,AXI4和AXI4-Stream DMA接口,支持PCIe 3.0和4.0

NVMe AXI4 Host Controller IP可以连接高速存储PCIe SSD,无需CPU,自动加速处理所有的NVMe协议命令,具备独立的数据写入和读取AXI4接口,不但适用高性能、顺序访问的应用,也适用于随机访问的应用,同时结合外部存储…