新疆大学ACM新生赛(公开赛)

A~D签到题,E稍微用点脑子?F经典分治题(lyd蓝书的袭击)反正分治算就行了复杂度2个log(用个归并能到1个log)

A - hello world

#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#pragma GCC optimize(2)
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<string>
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int main()
{IO;int T=1;//cin>>T;while(T--){cout<<"ifmmp!xpsme\n";}return 0;
}

B - 挂科

#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#pragma GCC optimize(2)
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<string>
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int main()
{IO;int T=1;//cin>>T;while(T--){int n,x,y;cin>>n>>x>>y;cout<<min(x,y)<<' '<<max(x+y-n,0)<<'\n';}return 0;
}

C - a+b

#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#pragma GCC optimize(2)
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<string>
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int main()
{IO;int T=1;//cin>>T;while(T--){int a,b;cin>>a>>b;cout<<hex<<a+b;}return 0;
}

D - 数组的和

#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#pragma GCC optimize(2)
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<string>
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N=200010;
ll a[N];
ll s[N];
int n,k;
int main()
{IO;int T=1;//cin>>T;while(T--){cin>>n>>k;ll res=1e18;for(int i=1;i<=n;i++) {cin>>a[i];s[i]=s[i-1]+a[i];}for(int i=1;i<=n;i++){int j=i+k-1;if(j<=n)res=min(res,s[i-1]+s[n]-s[i+k-1]);}cout<<res<<'\n';}return 0;
}

E - 异或

#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#pragma GCC optimize(2)
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<string>
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N=200010;
ll a[N];
int p[N];
int main()
{IO;int T=1;//cin>>T;while(T--){int n,q;ll now=0;cin>>n>>q;while(q--){int k,v;cin>>k>>v;if(k<=n) p[k]^=v;int cnt=n/k;if(cnt&1) now^=v;cout<<now<<'\n';}for(int i=1;i<=n;i++)if(p[i])for(int j=i;j<=n;j+=i)a[j]^=p[i];for(int i=1;i<=n;i++)cout<<a[i]<<' ';}return 0;
}

F - 最近的两个点

#include<bits/stdc++.h>using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N=100010;
int n;
struct node
{double x,y,z;
}p[N],tmp[N];
bool cmpx(node a,node b)
{return a.x<b.x;
}
bool cmpy(node a,node b)
{return a.y<b.y;
}
double dis(node a,node b)
{double dx=a.x-b.x;double dy=a.y-b.y;double dz=a.z-b.z;return sqrt(dx*dx+dy*dy+dz*dz);
}
double solve(int l,int r)
{if(l==r) return 1e10;int mid=l+r>>1;double flag=p[mid].x;double res=min(solve(l,mid),solve(mid+1,r));//sort(p+l,p+r+1,cmpy);// 归并这一步能够少一个loginplace_merge(p+l,p+mid+1,p+r+1,cmpy); // 归并排序int k=0;for(int i=l;i<=r;i++)if(p[i].x>=flag-res&&p[i].x<=flag+res)tmp[++k]=p[i];// 经证明下面操作复杂度线性?for(int i=1;i<=k;i++)for(int j=i-1;j&&tmp[i].y-tmp[j].y<res&&abs(tmp[i].z-tmp[j].z)<res;j--)res=min(res,dis(tmp[i],tmp[j]));return res;
}
int main()
{cin>>n;for(int i=1;i<=n;i++) cin>>p[i].x>>p[i].y>>p[i].z;sort(p+1,p+1+n,cmpx);printf("%.3lf\n",solve(1,n));return 0;
}

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

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

相关文章

P3214-[HNOI2011]卡农【dp】

正题 题目链接:https://www.luogu.com.cn/problem/P3214 题目大意 一个由1∼n1\sim n1∼n的所有整数构成的集合SSS&#xff0c;求出它的mmm个不同非空子集满足每个元素都出现了偶数次。 解题思路 集合的话不用考虑顺序&#xff0c;可以输出有序的答案除以m!m!m!就好了。 选…

Graph Coloring I

来源&#xff1a;牛客网&#xff1a; 题目描述 修修在黑板上画了一些无向连通图&#xff0c;他发现他可以将这些图的结点用两种颜色染色&#xff0c;满足相邻点不同色。 澜澜不服气&#xff0c;在黑板上画了一个三个点的完全图。修修跟澜澜说&#xff0c;这个图我能找到一个简…

Visual Studio 2017 15.9预览版3支持ARM64 for UWP

微软针对Visual Studio 2017 15.9的更新工作还在继续。在15.9的第三个预览版中&#xff0c;微软宣布支持ARM64平台上的UWP应用程序&#xff0c;并扩展了TypeScript开发人员可以使用的功能。和通常的情况一样&#xff0c;该版本还包含了大量的修复程序。UWP应用现在可以把ARM64平…

【树形DP】路径计数机(nowcoder 1103-B)

正题 nowcoder 1103-B 题目大意 给你一棵树&#xff0c;让你找两条不交的链&#xff0c;长度分别为a,b&#xff0c;问有多少中方案 解题思路 设fx,0∼3,yf_{x,0\sim 3,y}fx,0∼3,y​为在x的子树中&#xff0c;第1/2条链连了y条边&#xff0c;另一条链连完了/没连 然后对于每…

[ZJOI2007]矩阵游戏

来源&#xff1a;牛客网&#xff1a; 题目描述 小Q是一个非常聪明的孩子&#xff0c;除了国际象棋&#xff0c;他还很喜欢玩一个电脑益智游戏——矩阵游戏。矩阵游戏在一个N *N黑白方阵进行&#xff08;如同国际象棋一般&#xff0c;只是颜色是随意的&#xff09;。 每次可以对…

HHKB Programming Contest 2020 总结

A - Keyboard 签到题1 #define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0) #pragma GCC optimize(2) #include<set> #include<map> #include<cmath> #include<queue> #include<string> #include<vector> #include<cstdio…

AT4996-[AGC034F]RNG and XOR【FWT,生成函数】

正题 题目链接:https://www.luogu.com.cn/problem/AT4996 题目大意 给出一个0∼2n−10\sim 2^n-10∼2n−1下标的数组ppp&#xff0c;pip_ipi​表示有pip_ipi​的权重概率选择iii。 开始有一个x0x0x0&#xff0c;每次选择一个数字yyy让xxxoryxx\ xor\ yxx xor y 对于每个iii…

如何通过本地化事件正确实现微服务内部强一致性,事件总线跨微服务间最终一致性...

目录设计重点流程图伪代码2.1. PublishEvent2.2. SubscribeEvent2.3. Publisher2.4. Subscriber微服务 强一致性3.1 Publisher3.2 Subscriber事件总线 - 跨服务 最终一致性4.1 Publisher & Subscriber 都开启了本地事务&#xff0c;保证了强一致性4.2 问题场景一&#xff1…

【状压DP】十二桥问题(nowcoder 1104-B)

正题 nowcoder 1104-B 题目大意 给你一个无向图&#xff0c;问你从1开始经过若干必要边&#xff0c;然后回到1的最短路径 解题思路 因为关键边较少&#xff0c;先从每个关键点跑一遍dij&#xff0c;得出最短距离 设fs,if_{s,i}fs,i​表示必要边的状态为s&#xff0c;当前在…

干货!请码住——点此领取免费开源框架

何谓框架框架&#xff08;Framework&#xff09;是整个或部分系统的可重用设计&#xff0c;表现为一组抽象构件及构件实例间交互的方法; 框架是可被应用开发者定制的应用骨架。拥有一套企业级开发框架有哪些好处&#xff1f;对于一个软件公司或者互联网公司来说&#xff0c;开发…

YbtOJ#493-最大分数【斜率优化dp,分治】

正题 题目链接:http://172.17.55.160/contest/117/problem/1 题目大意 nnn个数的一个序列&#xff0c;给其中的一些数打上标记。 一个标记方案的贡献为s1s_1s1​表示有多少对L,RL,RL,R满足区间[L,R][L,R][L,R]都被打上了标记&#xff0c;s2s_2s2​表示标记的数字和。贡献为s1−…

大鱼吃小鱼

题目大意 给你若干数&#xff0c;让你分成若干组&#xff0c;每组两个&#xff0c;如果一组数中大的数大于等于小的数的两倍&#xff0c;那么有一点贡献&#xff0c;问贡献最大是多少 解题思路 先排序&#xff0c;然后分为大小两组&#xff0c;双指针看可以合多少组 code #i…

2018CCPC吉林赛区(重现赛)补题部分——F线段树待补

A - The Fool 数论分块暴力求和 #define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0) #pragma GCC optimize(2) #include<set> #include<map> #include<cmath> #include<queue> #include<string> #include<vector> #include&…

【dfs】年会小游戏

题目大意 给出n&#xff0c;问小于n的数中&#xff0c;因数最多的数 解题思路 要满足因数最多&#xff0c;则小的质因数个数要大于等于打的质因数个数 那么直接按这个需求dfs枚举每个质因数的指数 code #include<cstdio> #include<cstring> #include<iostre…

在 ASP.NET Core 中集成 Skywalking APM

前言大家好&#xff0c;今天给大家介绍一下如何在 ASP.NET Core 项目中集成 Skywalking&#xff0c;Skywalking 是 Apache 基金会下面的一个开源 APM 项目&#xff0c;有些同学可能会 APM 是干什么用的还不是太了解&#xff0c;那么下面我就简单的来说一下。APM 全称是 &#x…

YbtOJ-大收藏家【分层图,最大流】

正题 题目链接:https://www.ybtoj.com.cn/contest/117/problem/2 题目大意 nnn个人&#xff0c;每人有aia_iai​个属于自己的物品。mmm次交换依次进行&#xff0c;每次xi,yix_i,y_ixi​,yi​两个人可以决定拿不拿自己的一个物品进行交换。 求111号人最后能拿到最多多少种物品…

2019中国大学生程序设计竞赛(CCPC) - 网络选拔赛 Fishing Master

文章目录题意&#xff1a;题解&#xff1a;代码&#xff1a;题意&#xff1a; 你在钓鱼&#xff0c;每次钓鱼固定时间为k&#xff08;必定钓上一条鱼&#xff09;&#xff0c;池塘一共n条鱼&#xff0c;钓上鱼后要煮&#xff0c;每条鱼煮的时间不相同&#xff0c;可以在煮鱼的…

NWERC 2018——B.Brexit Negotiations

Brexit Negotiations 有向无环图&#xff0c;很容易想到拓扑排序&#xff0c;很明显我们需要把权值大的点放在最前面&#xff0c;然后就想到搞个优先队列&#xff0c;每次拓扑排序的时候出权值大的点&#xff0c;但是发现答案是不对的。 正向建图拓扑排序能够保证小的点一定最后…

.NET运行时中的监测和可观测性

今年5月份的时候研究分布式追踪的问题知道了的拦截方式比较零散&#xff0c; 刚好8月份的时候看到这篇文章&#xff0c;这个文章总结的比较完整。存档了很久&#xff0c;趁今天有空翻译给大家。原文地址&#xff0c;校验&#xff1a;张蘅水.NET是一个托管运行时&#xff0c;这意…

YbtOJ#532-往事之树【广义SAM,线段树合并】

正题 题目链接:https://www.ybtoj.com.cn/problem/532 题目大意 给出nnn个点的一个TrieTrieTrie树&#xff0c;定义SxS_xSx​表示节点xxx代表的字符串 求max{∣LCP(Sx,Sy)∣∣LCS(Sx,Sy)∣}(x≠y)max\{|LCP(S_x,S_y)||LCS(S_x,S_y)|\}(x\neq y)max{∣LCP(Sx​,Sy​)∣∣LCS(S…