湖南大学第十四届ACM程序设计新生杯 Dandan's lunch

Dandan‘s lunch

Description:

As everyone knows, there are now n people participating in the competition. It was finally lunch time after 3 hours of the competition. Everyone brought a triangular bread. When they were going to eat bread, some people found that they solved more problems than others, but their bread was smaller than others. They thought it was very unfair. In this case, they will forcibly exchange bread with the other party (may be exchanged many times, someone can still exchange with others after being exchanged if the above conditions are satisfied, the other party can not refuse).
The description of the bread is given by the coordinates of the three vertices of the triangle. The size of the bread is twice the size of the triangle area, ensuring that there are no two breads of the same size, and the number of problems each person makes is different.
Dandan is also one of the contestants. Now he knows the number of problems solved by each person and the description of the bread they bring. Now he wants to know that after all the exchanges are over (That is, there can be no more exchanges between any two people), The size of the bread he can get.

Input:

The first line gives an integer n, which indicates the number of people who participated in the competition.
Lines 2~n+1, each line gives 7 integers separated by spaces such as:
num x1 y1 x2 y2 x3 y3
num represents the number of the ith personal problem solving. (x1, y1) (x2, y2) (x3, y3) represents the coordinates of the three points of the bread of the triangle with the i-th person. ensure that three points are not in the same line.
Notice that the second line (the first person) represents Dandan‘s information.
Data guarantee: 0<n<=1e5,0<=num<1e9, -1e8<x1, x2, x3, y1, y2, y3<1e8.

Output:

Outputs an integer representing the size of the bread that DanDan eventually gets.

Sample Input:

1
100000000 0 0 10000 0 0 1000

Sample Output:

10000000

题意:

给出n个三角形的三个顶点坐标,求第x大的三角形面积的2倍是多少。(详见Description)

题解:

就是叉乘求平行四边形面积,注意下绝对值。后面排个序找一下就好了。

代码如下:

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <queue>
#include <cmath>
using namespace std;
typedef long long ll;
const int N = 1e5+5;
int n;
int a[N];
int main(){
    cin>>n;
    vector <ll> vec;
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        int x1,x2,x3,y1,y2,y3;
        scanf("%d%d%d%d%d%d",&x1,&y1,&x2,&y2,&x3,&y3);
        ll vecx1 = x2-x1,vecx2 = x3-x1;
        ll vecy1 = y2-y1,vecy2 = y3-y1;
        vec.push_back(vecx1*vecy2-vecy1*vecx2);
    }
    sort(vec.begin(),vec.end());
    int tmp=a[1];
    sort(a+1,a+n+1);
    for(int i=1;i<=n;i++){
        if(a[i]==tmp){
            cout<<vec[i-1];
            return 0;
        }
    }
    return 0;
}

湖南大学第十四届ACM程序设计新生杯 Dandan's lunch

原文地址:https://www.cnblogs.com/heyuhhh/p/10229943.html

时间: 2024-09-30 18:33:00

湖南大学第十四届ACM程序设计新生杯 Dandan's lunch的相关文章

湖南大学第十四届ACM程序设计新生杯 E.Easy Problem

E.Easy Problem Description: Zghh likes number, but he doesn't like writing problem description. So he will just give you a problem instead of telling a long story for it. Now given a positive integer x and k digits a1,a2,...,ak, can you find a positi

浙江省第十四届大学生程序设计竞赛总结

恐怖故事,开场,我从后往前读题. 看到$M$,我感觉上好像会做,但不知道是不是最优策略.跳过. 看到$L$,我感觉上好像是找规律,算了几个样例,发现可能是那个规律,没仔细思考.跳过. 这时候,$xiang578$偷偷摸摸$AC$了一题. $Occult$看了$E$题.可以写,先跳过. 紧接着,有人过题,$xiang578$看题,$Occult$把前四题剩下的三题都$AC$了. 前四题貌似是简单题,都是$1A$,最终全场$160+$队伍过了四个及以上题目. 我在一旁划水,期间看了$I$题和$F$题

湖南大学ACM程序设计新生杯大赛(同步赛)L - Liao Han

题目描述 Small koala special love LiaoHan (of course is very handsome boys), one day she saw N (N<1e18) guys standing in a row, because the boys had some strange character,The first time to Liao them will not be successful, but the second time will be su

湖南大学ACM程序设计新生杯大赛(同步赛)B - Build

题目描述 In country  A, some roads are to be built to connect the cities.However, due to limited funds, only some roads can be built.That is to say,if the limit is 100$, only roads whose cost are no more than 100$ can be built. Now give you n cities, m r

湖南大学ACM程序设计新生杯大赛(同步赛)G - The heap of socks

题目描述 BSD is a lazy boy. He doesn't want to wash his socks, but he will have a data structure called 'socks heap'.By maintaining this structure, he can quickly pick out two of the most smelless socks from millions of socks everyday. As one of his good

湖南大学ACM程序设计新生杯大赛(同步赛)J - Piglet treasure hunt Series 2

题目描述 Once there was a pig, which was very fond of treasure hunting. One day, when it woke up, it found itself in a strange land of treasure. As for how to come in, or how to go out, no ways to know. Sad. The good news is, it was lucky that it got the

HDU 6467 简单数学题 【递推公式 &amp;&amp; O(1)优化乘法】(广东工业大学第十四届程序设计竞赛)

传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6467 简单数学题 Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 308    Accepted Submission(s): 150 Problem Description 已知 F(n)=∑i=1n(i×∑j=inCij) 求 F(n) m

第十四届华中科技大学程序设计竞赛决赛同步赛

第十四届华中科技大学程序设计竞赛决赛同步赛 A Beauty of Trees 思维,带权并查集 题意: 长度为 n 的序列,没告诉你具体数是多少.只给出 m 个查询,表示区间 [l,r] 的异或和为 k .但是第 i 个查询如果和前面的查询有矛盾,那就是错误的.输出所有的错误查询. tags: 对于一个查询,我们知道 sum[r] ^ sum[l-1] = k . 建成图就是 r -> (l-1) ,但要快速地求出异或值,就要用带权并查集处理.如有 sum[r]^sum[l-1]=k,即 r

没有什么不可能—记山东省第六届ACM程序设计竞赛(退役总结帖)

大一下学期,第一次听说了ACM这个词,当时每周六也开设了培训课,但我好像一次也没有去过,当时对这个词并没有什么太大的印象.后来学院里引进了自己的OJ,那时候我连基本的输入输出格式都不懂,当经历了一堆的WA,TLE之后突然换来的一个AC竟带来了莫名的喜悦.后来学院举办了第一届ACM程序设计竞赛,我报名参加了新秀赛和团队赛.三个小时的新秀赛,当时貌似做出了三道,意外的拿到了一等奖,这也成为了我大学生活的一个重要转折点.四个小时的团队赛,做得很艰难,各种不会,最后只做出了一道,排在三等奖的末尾.比赛之