问题 H: Hunter’s Apprentice

时间限制: 1 Sec  内存限制: 128 MB

提交: 353  解决: 39

[提交] [状态] [命题人:admin]

题目描述

When you were five years old, you watched in horror as a spiked devil murdered your parents. You would have died too, except you were saved by Rose, a passing demon hunter. She ended up adopting you and training you as her apprentice.

Rose’s current quarry is a clock devil which has been wreaking havoc on the otherwise quiet and unassuming town of Innsmouth. It comes out each night to damage goods, deface signs, and kill anyone foolish enough to wander around too late. The clock devil has offed the last demon hunter after it; due to its time-warping powers, it is incredibly agile and fares well in straight-up fights.

The two of you have spent weeks searching through dusty tomes for a way to defeat this evil. Eventually, you stumbled upon a relevant passage. It detailed how a priest managed to ensnare a clock devil by constructing a trap from silver, lavender, pewter, and clockwork. The finished trap contained several pieces, which must be placed one-by-one in the shape of a particular polygon, in counter-clockwise order. The book stated that the counter-clockwise order was important to counter the clock devil’s ability to speed its own time up, and that a clockwise order would only serve to enhance its speed.

It was your responsibility to build and deploy the trap, while Rose prepared for the ensuing fight. You carefully reconstruct each piece as well as you can from the book. Unfortunately, things did not go as planned that night. Before you can finish preparing the trap, the clock devil finds the two of you. Rose tries to fight the devil, but is losing quickly. However, she is buying you the time to finish the trap. You quickly walk around them in the shape of the polygon, placing each piece in the correct position. You hurriedly activate the trap as Rose is knocked out. Just then, you remember the book’s warning. What should you do next?

输入

The first line of input contains a single integer T (1 ≤ T ≤ 100), the number of test cases. The first line of each test case contains a single integer n (3 ≤ n ≤ 20), the number of pieces in the trap. Each of the next n lines contains two integers xi and yi (|xi |, |yi | ≤ 100), denoting the x and y coordinates of where the ith piece was placed. It is guaranteed that the polygon is simple; edges only intersect at vertices, exactly two edges meet at each vertex, and all vertices are distinct.

输出

For each test case, output a single line containing either fight if the trap was made correctly or run if the trap was made incorrectly.

题意:

你要去帮罗斯去打怪兽balabala,然后你得绕着一个多边形跑,逆时针能帮上忙,顺时针会帮倒忙

给你一堆点坐标,然后按点坐标顺序跑,判断是顺时针还是逆时针

这有个公式,如果知道公式就是简单题了,

如果不知道又像我这种一辈子都不可能手推出来公式的就只能表示 模板+1

关于公式 https://blog.csdn.net/henuyh/article/details/80378818

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define rep(i,a,n) for(int i=a;i<n;++i)
#define readc(x) scanf("%c",&x)
#define read(x) scanf("%d",&x)
#define sca(x) scanf("%d",&x)
#define read2(x,y) scanf("%d%d",&x,&y)
#define read3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define print(x) printf("%d\n",x)
#define mst(a,b) memset(a,b,sizeof(a))
#define lowbit(x) x&-x
#define lson(x) x<<1
#define rson(x) x<<1|1
#define pb push_back
#define mp make_pair
typedef pair<int,int> P;
typedef long long ll;
const int INF =0x3f3f3f3f;
const int inf =0x3f3f3f3f;
const int mod = 1e9+7;
const int MAXN = 105;
const int maxn = 10010;
double x[1050],y[1050];
int main()
{
  int t;
  read(t);
  while(t--)
  {
    int n;
    read(n);
    double temp = 0;
    rep(i, 0, n)
    {
      scanf("%lf%lf", &x[i], &y[i]);
    }
    rep(i,0,n-1)
    {
      temp += -0.5 * (y[i + 1] + y[i]) * (x[i + 1] - x[i]); //Green 公式
    }
    if(temp > 0)
      cout<<"fight"<<endl;
    else
      cout<<"run"<<endl;
  }
  return 0;
}

Hunter’s Apprentice 【判断多边形边界曲线顺逆时针】的更多相关文章

  1. upc组队赛5 Hunter’s Apprentice 【判断多边形边界曲线顺逆时针】

    Hunter's Apprentice 题目描述 When you were five years old, you watched in horror as a spiked devil murde ...

  2. 【ECNU3386】Hunter's Apprentice(多边形有向面积)

    点此看题面 大致题意: 按顺序给你一个多边形的全部顶点,让你判断是按顺时针还是逆时针给出的. 多边形有向面积 显然我们知道,叉积可以求出两个向量之间有向面积的两倍. 所以,我们三角剖分,就可以求出四边 ...

  3. Hunter’s Apprentice(判断所走路线为顺时针或逆时针)【Green公式】

    Hunter's Apprentice 题目链接(点击) 题目描述 When you were five years old, you watched in horror as a spiked de ...

  4. POJ1584 判断多边形是否为凸多边形,并判断点到直线的距离

    求点到直线的距离: double dis(point p1,point p2){   if(fabs(p1.x-p2.x)<exp)//相等的  {    return fabs(p2.x-pe ...

  5. hdu 2108:Shape of HDU(计算几何,判断多边形是否是凸多边形,水题)

    Shape of HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tota ...

  6. hdu 2108 Shape of HDU【判断多边形是否是凸多边形模板】

    链接: http://acm.hdu.edu.cn/showproblem.php?pid=2108 http://acm.hust.edu.cn/vjudge/contest/view.action ...

  7. poj1584 A Round Peg in a Ground Hole 判断多边形凹凸,点到线的距离【基础计算几何】

    大致思路:首先对于所给的洞的点,判断是否是凸多边形,图形的输入和输出可以是顺时针或者逆时针,而且允许多点共线 Debug 了好几个小时,发现如下问题 判断三点是否共线,可用斜率公式判断 POINT p ...

  8. hdu2108 Shape of HDU 极角排序判断多边形

    Problem Description 话说上回讲到海东集团推选老总的事情,最终的结果是XHD以微弱优势当选,从此以后,"徐队"的称呼逐渐被"徐总"所取代,海东 ...

  9. TZOJ 2560 Geometric Shapes(判断多边形是否相交)

    描述 While creating a customer logo, ACM uses graphical utilities to draw a picture that can later be ...

随机推荐

  1. Unity3d之表情动画--眨眼

    可通过BlendShape来实现眨眼动画,效果如下: 转载请注明出处:http://www.cnblogs.com/jietian331/p/7054673.html 代码如下: using Unit ...

  2. man查看帮助命令

    man -h/-help 1.在man命令帮助信息的界面中,所包含的常用操作按键及其用途 按键 用处 空格键 向下翻一页 PaGe down 向下翻一页 PaGe up 向上翻一页 home 直接前往 ...

  3. C# & ASP.NET Core 入门官方资料汇总

    借助给公司实习生培训事宜,整理了一些微软官方的适合新同学入门的资料,这里分享一下: 工具: Visual Studio 2017 Community 版本下载地址:https://www.visual ...

  4. Mini-Batch 、Momentum、Adam算法的实现

    Mini-Batch 1. 把训练集打乱,但是X和Y依旧是一一对应的 import numpy as np a = np.random.randn(3,3) print(a) b = list(np. ...

  5. Impala 学习

    Impala 基础知识介绍与学习,参考文章: Impala-大数据时代快速SQL引擎 https://blog.csdn.net/kangkangwanwan/article/details/7865 ...

  6. Kylin, Mondrian, Saiku系统的整合

    本文主要介绍有赞数据团队为了满足在不同维度查看.分析重点指标的需求而搭建的OLAP分析工具.这个工具对Kylin.Mondrian以及Saiku做了一个整合,主要工作包括一些定制化的修改以及环境的配置 ...

  7. POJ 1018 Communication System (动态规划)

    We have received an order from Pizoor Communications Inc. for a special communication system. The sy ...

  8. CentOS7 zabbix服务 简单安装文档

    1. 简介 zabbix是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案. zabbix能监视各种网络参数,保证服务器系统的安全运营:并提供灵活的通知机制以让系统管理员快 ...

  9. Java学习路线教程之JDBC基本操作

    为了帮助大家熟练应用JDBC编程,接下来,在本节将通过一个综合案例来讲解JDBC的基本操作,确保大家能够深刻理解JDBC的增.删.改.查,灵活利用JDBC完成对数据库的各项操作. 1. 创建一个Jav ...

  10. 在vim编辑器python实现tab补全功能

    在vim编辑器中实现python tab补全插件有Pydiction,Pydiction可以实现下面python代码的自动补全: 1. 简单python关键词补全 2. python函数补全带括号 3 ...