19年东北四省省赛

做了J G C

补了E H

J签到题

G

题意:

给n个正方形的两个斜对角点坐标,问最小的移动可以重叠(移动上下左右一格)

思路:

一开始想的是中心pos移动,但是可能有小数,而且半径长度不知,可能有包含关系。

然后发现题目没说一定要某一个正方形移动的最小步数,那之间转换为点在面里面的移动最小,取中间的两个上下斜对角坐标就行了

 #include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<vector>
#include<queue>
#include<cmath>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
#define mod 998244353
const int maxn=1e5+;
struct node{
int x,y,xx,yy;
}a[maxn];
int t,n;
int x[maxn<<],y[maxn<<];
int main()
{
scanf("%d",&t);
while(t--){
scanf("%d",&n);
int xt=,yt=;
for(int i=;i<n;i++){
scanf("%d%d%d%d",&a[i].x,&a[i].y,&a[i].xx,&a[i].yy);
x[xt++]=a[i].x,x[xt++]=a[i].xx;
y[yt++]=a[i].y,y[yt++]=a[i].yy;
}
sort(x,x+xt);
sort(y,y+yt);
int zx=x[xt/],zy=y[yt/];
ll sum=;
for(int i=;i<n;i++){
if(zx<a[i].x || zx>a[i].xx){
sum+=(ll)min(abs(a[i].x-zx),abs(a[i].xx-zx));
}
if(zy<a[i].y || zy>a[i].yy){
sum+=(ll)min(abs(a[i].y-zy),abs(a[i].yy-zy));
}
}
printf("%lld\n",sum);
}
return ;
}

C

题意:

给n条直线,问有多少两两相交的线,重叠也算相交的线

思路:

总量n*(n-1)/2-平行的数量

一开始算斜率,但因为斜率的精确度,wa,然后想了用gcd或者用逆元

最后用了map存y/x的最小分数yy和xx,在特判一下重叠的

 #include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<vector>
#include<queue>
#include<cmath>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
#define mod 998244353
const int maxn=1e5+;
int n,t;
ll a,b,c,d;
ll gcd(ll a,ll b){
return b==?a:gcd(b,a%b);
}
struct node{
ll x,y;
node(){}
node(ll xx,ll yy):x(xx),y(yy){}
bool operator<(const node &b)const
{
if(x==b.x)
return y<b.y;
else
return x<b.x;
}
};
struct node1{
ll x,y,chong;
node1(){}
node1(ll xx,ll yy,ll cc):x(xx),y(yy),chong(cc){}
bool operator<(const node1 &b)const
{
if(x==b.x){
if(y==b.y){
return chong<b.chong;
}
return y<b.y;
}
else
return x<b.x;
}
};
map<node,ll>mp;
map<node1,ll>cd;
int main()
{
scanf("%d",&t);
while(t--){
scanf("%d",&n);
ll zong=(ll)n*(n-)/;
for(int i=;i<n;i++){
scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
ll xx=a-c,yy=b-d;
ll gd=gcd(xx,yy);
ll x=xx/gd,y=yy/gd;
ll f=x*b+y*a;
mp[node(x,y)]++;
zong-=mp[node(x,y)];
cd[node1(x,y,f)]++;
zong+=cd[node1(x,y,f)];
}
printf("%lld\n",zong);
mp.clear(),cd.clear();
}
return ;
}

E

题意:

给n个点,n-1条边,每条边都有权重,每个边形成一个最小生成树,形成线图

思路:

算每个点的贡献值,这个点的出度小于二,无贡献,大于二,就是相邻的边加一起,在最小的那个边*(相邻边数-2)

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<queue>
#include<stack>
#include<algorithm>
#include<stdio.h>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const int maxn=;
struct node
{
int v,w;
node(){}
node(int n,int m):v(n),w(m){}
bool operator < (const node &r)const{
return w<r.w;
}
};
vector<node>G[maxn];
int main()
{
int T;
scanf("%d",&T);
while(T--){
int n;
scanf("%d",&n);
for(int i=;i<=n;i++)G[i].clear();
for(int i=;i<=n-;i++){
int u,v,w;
scanf("%d%d%d",&u,&v,&w);
G[u].push_back(node(v,w));
G[v].push_back(node(u,w));
}
ll ans=;
for(int i=;i<=n;i++){
sort(G[i].begin(),G[i].end());
int minn=0x3f3f3f3f;
int degree=G[i].size();
for(int j=;j<degree;j++){
ans+=G[i][j].w;
minn=min(minn,G[i][j].w);
}
ans+=(ll)minn*(degree-);
}
printf("%lld\n",ans);
}
return ;
}

H:

https://www.cnblogs.com/luoyugongxi/p/12191649.html

yp寒假训练一的更多相关文章

  1. FZU ICPC 2020 寒假训练 4 —— 模拟(一)

    P1042 乒乓球 题目背景 国际乒联现在主席沙拉拉自从上任以来就立志于推行一系列改革,以推动乒乓球运动在全球的普及.其中11分制改革引起了很大的争议,有一部分球员因为无法适应新规则只能选择退役.华华 ...

  2. 寒假训练第九场 Brocard Point of a Triangle

    题意:求布洛卡点坐标 思路:直接利用布洛卡点的性质.http://pan.baidu.com/s/1eQiP76E #include<cstdio> #include<cstring ...

  3. FJUT2017寒假训练二题解

    A题 题意:让你找出唯一的一个四位数,满足对话时的要求. 思路:因为是4位数,可以直接从1000-9999遍历一遍,判断是否有唯一的数能满足所有条件,如果不是唯一的或者没有满足条件的数就输出Not s ...

  4. J - Abbott's Revenge 搜索 寒假训练

    题目 题目大意:这个题目就是大小不超过9*9的迷宫,给你起点终点和起点的方向,让你进行移动移动特别之处是不一定上下左右都可以,只有根据方向确定可以走的方向.思路:需要写一个读入函数,这个需要读入起点, ...

  5. 寒假训练——搜索——C - Robot

    The Robot Moving Institute is using a robot in their local store to transport different items. Of co ...

  6. 寒假训练——搜索 K - Cycle

    A tournament is a directed graph without self-loops in which every pair of vertexes is connected by ...

  7. HRBUST - 2347 - 递归画图 - vj大一上寒假训练2.11

    其他题可由本题变形得到. 思路:利用坐标dfs搜索. 注意:1,初始化.2,坐标实时更新(x,y) 代码: #include<iostream> #include<cstdio> ...

  8. 寒假训练——搜索 G - Xor-Paths

    There is a rectangular grid of size n×mn×m . Each cell has a number written on it; the number on the ...

  9. 寒假训练——搜索 E - Bloxorz I

    Little Tom loves playing games. One day he downloads a little computer game called 'Bloxorz' which m ...

随机推荐

  1. Java正则表达式提取String字符串中的IP地址

    /** * 正则提前字符串中的IP地址 * @param ipString * @return */ public static List<String> getIps(String ip ...

  2. Web 安全工具篇:Burp Suite 使用指南

    真的是一点都不过分,了解详情请继续往下读. Burp Suite 介绍 Burp Suite 是用于攻击 web 应用程序的集成平台.它包含了许多工具,并为这些工具设计了许多接口,以促进加快攻击应用程 ...

  3. Cheapest Palindrome

    这个区间dp解的话是先知道小区间再推大区间,具体需要分类讨论当小区间已经是回文串了,下一层判断,所以一层一个呢还是一层两个呢, 下面讨论一层一个的话是什么情况,那么如果一层两个,可以在评论区写下代码供 ...

  4. Qt5 error LNK2019 无法解析的外部符号的解决办法

    今天在使用Qt Create 4.5.2时遇到一个莫名其妙的问题: 在原有工程里添加一个新类(有界面的),在调用的mainwindow.cpp中添加#include "a.h",然 ...

  5. Java“被迫”退出争霸,Python继续霸占首位!老牌程序员:我不服

    2019年转眼已经接近尾声,如果盘点下2019年最火的语言,除了Python还能有谁?你心中的王者语言又是谁? 这一年Python风光无限 这一年JAVA走向右边 这一年,我们都很感慨,你呢? 关于P ...

  6. 使用webpack搭建vue环境

    1.安装node.js,在官网下载,直接下一步,完成.nodejs里默认包含npm环境.国内安装包的速度太慢,建议使用cnpm淘宝镜像. npm install -g cnpm --registry= ...

  7. [消灭虫子] Qt 套接字发不出去东西

    最近状态不是太好,导致出现bug之后心烦意乱的 遇到这样的事情,就是在 这样的函数执行之后服务端收不到任何消息,但是在调试台显示已经发送了正常的字节数. 表示大概已经发出去了,但是我确定服务端没有问题 ...

  8. Abaqus 载荷分类(部分)

    目录 1. 集中载荷 1.1 集中载荷施加方法 1.2 定义集中跟随力 1.3 指定文件定义集中节点力 2. 分布载荷 2.1 分布载荷分类 3. 热载荷 3.1 模拟热辐射 3.2 直接定义热流量 ...

  9. Codeforces Round #624 (Div. 3) F

    题意: 给出n的质点,带着初位置和速度: 如果中途两点可以相遇dis(i,j)=0: 如果不可以相遇,mindis(i,j): 求n个点的两两质点最小dis(i,j)之和 思路: 因为当初位置x和速度 ...

  10. 【PAT甲级】1112 Stucked Keyboard (20分)(字符串)

    题意: 输入一个正整数K(1<K<=100),接着输入一行字符串由小写字母,数字和下划线组成.如果一个字符它每次出现必定连续出现K个,它可能是坏键,找到坏键按照它们出现的顺序输出(相同坏键 ...