其实这个几何写起来还是比较方便,只用到了叉积。首先我们贪心的考虑一种情况,对于任意给定的LR串,我们起点的选择肯定是在这些点围成的凸包端点上,对于这样的起点来说,他对于L或者R都是有选择的机会,而且一定可以从剩下n-1个点选出两个点满足要求(可以画图观察),接下来我们对于这个起点出发开始去寻找满足LR的点,对于第二个点来说,我们需要去找到剩下n-1个点中最外侧的点,并且满足剩下n-2个点都在向量point[1]-point[0]的左侧或者右侧,这个可以直接由叉积得到,那么我们便得到了第二个点,显然第二个点也一定是在剩下n-1个点围成的凸包端点上,无论取剩下n-2个点中的任何一个都是满足两个向量满足 point[2]-point[1],point[1]-point[0]的向量转向满足s[0],那么问题就可以看成是一个 n'=n-2 的新问题,那么此时起点是point[1],那么依然通过上述方法找到point[2],反复如此,直到找到 n-1 个点,最后剩下一个点必然满足最后一个s的转向,那么此题也是没有-1的情况。

  1. // ——By DD_BOND
  2.  
  3. //#include<bits/stdc++.h>
  4. #include<functional>
  5. #include<algorithm>
  6. #include<iostream>
  7. #include<sstream>
  8. #include<iomanip>
  9. #include<climits>
  10. #include<cstring>
  11. #include<cstdlib>
  12. #include<cstddef>
  13. #include<cstdio>
  14. #include<memory>
  15. #include<vector>
  16. #include<cctype>
  17. #include<string>
  18. #include<cmath>
  19. #include<queue>
  20. #include<deque>
  21. #include<ctime>
  22. #include<stack>
  23. #include<map>
  24. #include<set>
  25.  
  26. #define fi first
  27. #define se second
  28. #define MP make_pair
  29. #define pb push_back
  30. #define INF 0x3f3f3f3f
  31. #define pi 3.1415926535898
  32. #define lowbit(a) (a&(-a))
  33. #define lson l,(l+r)/2,rt<<1
  34. #define rson (l+r)/2+1,r,rt<<1|1
  35. #define Min(a,b,c) min(a,min(b,c))
  36. #define Max(a,b,c) max(a,max(b,c))
  37. #define debug(x) cerr<<#x<<"="<<x<<"\n";
  38.  
  39. using namespace std;
  40.  
  41. typedef long long ll;
  42. typedef pair<int,int> P;
  43. typedef pair<ll,ll> Pll;
  44. typedef unsigned long long ull;
  45.  
  46. const ll LLMAX=2e18;
  47. const int MOD=1e9+;
  48. const double eps=1e-;
  49. const int MAXN=1e6+;
  50. const int hmod1=0x48E2DCE7;
  51. const int hmod2=0x60000005;
  52.  
  53. inline ll sqr(ll x){ return x*x; }
  54. inline int sqr(int x){ return x*x; }
  55. inline double sqr(double x){ return x*x; }
  56. ll __gcd(ll a,ll b){ return b==? a: __gcd(b,a%b); }
  57. ll qpow(ll a,ll n){ll sum=;while(n){if(n&)sum=sum*a%MOD;a=a*a%MOD;n>>=;}return sum;}
  58. inline int dcmp(double x){ if(fabs(x)<eps) return ; return (x>? : -); }
  59.  
  60. int use[MAXN];
  61. vector<int>ans;
  62.  
  63. struct Point{
  64. ll x,y,id;
  65. Point(){ x=y=; }
  66. Point(ll a,ll b){ x=a,y=b; }
  67. Point operator -(const Point &n)const{
  68. return Point(x-n.x,y-n.y);
  69. }
  70. bool operator <(const Point &n)const{
  71. if(x==n.x) return y<n.y;
  72. return x<n.x;
  73. }
  74. }point[MAXN];
  75.  
  76. int dcmp(ll x){
  77. if(x==) return ;
  78. return x>? : -;
  79. }
  80.  
  81. bool cmp(Point a,Point b){
  82. return a.id<b.id;
  83. }
  84.  
  85. ll cross(Point a,Point b){
  86. return a.x*b.y-a.y*b.x;
  87. }
  88.  
  89. int main(void)
  90. {
  91. ios::sync_with_stdio(false); cin.tie(); cout.tie();
  92. int n; cin>>n;
  93. for(int i=;i<=n;i++) cin>>point[i].x>>point[i].y,point[i].id=i;
  94. string s; cin>>s;
  95. sort(point+,point+n+);
  96. ans.pb(point[].id),use[point[].id]=;
  97. sort(point+,point+n+,cmp);
  98. for(int i=;i<s.size();i++){
  99. int k=,flag=(s[i]=='L'? : -);
  100. for(int j=;j<=n;j++){
  101. if(use[j]) continue;
  102. if(!k||dcmp(cross(point[k]-point[ans[i]],point[j]-point[k]))!=flag) k=j;
  103. }
  104. ans.pb(k),use[k]=;
  105. }
  106. for(int i=;i<=n;i++)
  107. if(!use[i])
  108. ans.pb(i);
  109. for(auto i:ans) cout<<i<<' ';
  110. return ;
  111. }

Codeforces 1159F Winding polygonal line(叉积)的更多相关文章

  1. [codeforces 549]G. Happy Line

    [codeforces 549]G. Happy Line 试题描述 Do you like summer? Residents of Berland do. They especially love ...

  2. codeforces 251A Points on Line(二分or单调队列)

    Description Little Petya likes points a lot. Recently his mom has presented him n points lying on th ...

  3. [ An Ac a Day ^_^ ] CodeForces 659D Bicycle Race 计算几何 叉积

    问有多少个点在多边形内 求一遍叉积 小于零计数就好了~ #include<stdio.h> #include<iostream> #include<algorithm&g ...

  4. codeforces 431 B Shower Line【暴力】

    题意:给出五个人的编号,分别为 1 2 3 4 5,他们在排队, 最开始的时候,1和2可以交谈,3和4可以交谈 然后1走了之后,2和3交谈,4和5可以交谈 2走了之后,3和4可以交谈, 3走了之后,4 ...

  5. @codeforces - 594E@ Cutting the Line

    目录 @description@ @solution@ @accepted code@ @details@ @description@ 给定一个字符串 s 与正整数 k.现在你需要进行恰好一次操作: ...

  6. Codeforces VP/补题小记 (持续填坑)

    Codeforces VP/补题小记 1149 C. Tree Generator 给你一棵树的括号序列,每次交换两个括号,维护每次交换之后的直径. ​ 考虑括号序列维护树的路径信息和,是将左括号看做 ...

  7. Codeforces GYM 100114 B. Island 水题

    B. Island Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100114 Description O ...

  8. CodeForces 164 B. Ancient Berland Hieroglyphs 单调队列

    B. Ancient Berland Hieroglyphs 题目连接: http://codeforces.com/problemset/problem/164/B Descriptionww.co ...

  9. Codeforces Round #328 (Div. 2) D. Super M 虚树直径

    D. Super M Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/592/problem/D ...

随机推荐

  1. DevExpress 2019 .NET产品现已完全支持Visual Studio 2019

    [DevExpress v18.2.8最新版免费下载] 我们非常高兴地跟宣布DevExpress .NET产品现已完全支持Visual Studio 2019.如果您是DevExpress忠实用户,可 ...

  2. Java:字符编码

    常用的字符编码 UFT-8 ISO-8859-1 GBK/GBK2312

  3. Python---进阶---常用模块os、jso

    一.写一个6位随机验证码程序(使用 random模块),要求验证码中至少包含一个数字.一个小写字母.一个大写字母 import randomimport string #help(string) co ...

  4. ionic icon(图标)

    https://www.runoob.com/ionic/ionic-icon.html ionic 也默认提供了许多的图标,大概有 700 多个,针对 Android 和 iOS 有不同的样式.

  5. 【NOIP2013模拟】导弹防御塔

    题目 Freda的城堡-- "Freda,城堡外发现了一些入侵者!" "喵...刚刚探究完了城堡建设的方案数,我要歇一会儿嘛lala~" "可是入侵者 ...

  6. 对postcss以及less和sass的研究

    1.postcss PostCSS 的主要功能只有两个:第一个就是前面提到的把 CSS 解析成 JavaScript 可以操作的 抽象语法树结构(Abstract Syntax Tree,AST),第 ...

  7. (容量超大)or(容量及价值)超大背包问题 ( 折半枚举 || 改变 dp 意义 )

    题意 : 以下两个问题的物品都只能取有且只有一次 ① 给你 N 个物品,所有物品的价值总和不会超过 5000, 单个物品的价格就可达 10^10 ,背包容量为 B ② 给你 N (N ≤ 40 ) 个 ...

  8. linux php扩展模块安装

    安装Freetds Freetds 官方网站是 http://www.freetds.org,可以去官方网站下载程序,文中下载的是0.92.79版本. wget ftp://ftp.freetds.o ...

  9. CG-CTF | 上传绕过

    最近一直在做算法题,头都要大了,今天悄咪咪来一个web换换脑子,一发flag敲开♥[虽然知道这是个水题ε=ε=ε=┏(゜ロ゜;)┛]

  10. IIS发布mvc网站需操作的内容

    VS2010 WEB部署,先在IIS中创建站点,站点创建需注意以下的内容,创建完成后点击[发布]---[WEB部署]--[发布]. 在IIS7下部署MVC已经简化了许多,基本按照一般的项目部署即可,下 ...