Codeforces 101173 C - Convex Contour
思路:
如果所有的图形都是三角形,那么答案是2*n+1
否则轮廓肯定触到了最上面,要使轮廓线最短,那么轮廓肯定是中间一段平的
我们考虑先将轮廓线赋为2*n+2,然后删去左右两边多余的部分
如果最左边或最由边是正方形,那么不需要删
如果最左边或最由边是圆形,那么删取2 - pi/2
如果如果最左边或最由边是三角形,那么我们需要找到一段连续的三角形,然后考虑怎么删去
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pi acos(-1.0)
#define LL long long
//#define mp make_pair
#define pb push_back
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pii pair<int, int>
#define piii pair<pii, int>
#define mem(a, b) memset(a, b, sizeof(a))
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stout);
//head int main() {
fio;
int n;
string s;
cin >> n;
cin >> s;
bool f = true;
for (int i = ; i < n; i++) if(s[i] != 'T') f = false;
if(f) {
cout << *n + << endl;
}
else {
double ans = *n + ;
if(s[] == 'T') {
int x = ;
for (int i = ; i < n; i++) {
if(s[i] == 'T') {
x++;
}
else if(s[i] == 'C'){
double tot = x + 0.5;
double t = sqrt((sqrt()/ - 0.5)*(sqrt()/ - 0.5) + x*x - 0.25);
tot -= t;
double a = atan((sqrt()/ - 0.5) / x);
double b = atan(t*);
double c = pi/ -a - b;
tot -= c*0.5;
ans -= tot;
break;
}
else if(s[i] == 'S') {
double tot = x;
double t = sqrt((-sqrt()/)*(-sqrt()/) + (x-0.5) * (x-0.5));
tot -= t;
ans -= tot;
break;
}
}
}
else if(s[] == 'C') {
ans -= - pi/;
} reverse(s.begin(), s.end());
if(s[] == 'T') {
int x = ;
for (int i = ; i < n; i++) {
if(s[i] == 'T') {
x++;
}
else if(s[i] == 'C'){
double tot = x + 0.5;
double t = sqrt((sqrt()/ - 0.5)*(sqrt()/ - 0.5) + x*x - 0.25);
tot -= t;
double a = atan((sqrt()/ - 0.5) / x);
double b = atan(t*);
double c = pi/ -a - b;
tot -= c*0.5;
ans -= tot;
break;
}
else if(s[i] == 'S') {
double tot = x;
double t = sqrt((-sqrt()/)*(-sqrt()/) + (x-0.5) * (x-0.5));
tot -= t;
ans -= tot;
break;
}
}
}
else if(s[] == 'C') {
ans -= - pi/;
}
cout << fixed << setprecision() << ans << endl;
}
return ;
}
Codeforces 101173 C - Convex Contour的更多相关文章
- [CERC2016]:凸轮廓线Convex Contour(模拟+数学)
题目描述 一些几何图形整齐地在一个网格图上从左往右排成一列.它们占据了连续的一段横行,每个位置恰好一个几何图形.每个图形是以下的三种之一:$1.$一个恰好充满单个格子的正方形.$2.$一个内切于单个格 ...
- UVALive 7749 Convex Contour (计算几何)
题意:给定上正方形,圆,三角形,让你求出包围它的最短的路径. 析:首先,如果是这种情况 三角形 三角形 三角形 正方形(圆) 三角形 三角形 三角形 ..这一种就是直接从左边直接连到正方形(圆),也 ...
- 【计算几何】【分类讨论】Gym - 101173C - Convex Contour
注意等边三角形的上顶点是卡不到边界上的. 于是整个凸包分成三部分:左边的连续的三角形.中间的.右边的连续的三角形. 套个计算几何板子求个三角形顶点到圆的切线.三角形顶点到正方形左上角距离啥的就行了,分 ...
- codeforces B. Convex Shape 解题报告
题目链接:http://codeforces.com/problemset/problem/275/B 题目内容:给出一个n * m 大小的grid,上面只有 black 和 white 两种颜色填充 ...
- Codeforces 838E Convex Countour
题 OvO http://codeforces.com/contest/838/problem/E (IndiaHacks 2nd Elimination 2017 (unofficial, unra ...
- Codeforces.838E.Convex Countour(区间DP)
题目链接 \(Description\) 给定一个n边凸多边形(保证没有三点共线),求一条经过每个点最多一次的不会相交的路径,使得其长度最大.输出这个长度. \(Solution\) 最长路径应该是尽 ...
- Codeforces Round #270 1003
Codeforces Round #270 1003 C. Design Tutorial: Make It Nondeterministic time limit per test 2 second ...
- codeforces 70D Professor's task(动态二维凸包)
题目链接:http://codeforces.com/contest/70/problem/D Once a walrus professor Plato asked his programming ...
- Codeforces Round #328 (Div. 2) B. The Monster and the Squirrel 打表数学
B. The Monster and the Squirrel Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/c ...
随机推荐
- P1357 花园
洛咕原题 题解 状压dp+矩乘 首先看到题目说M<=5,这么小的数据明显可以用状压保存相邻状态,于是可以得到一个80分的dp: 先筛出所有可用的状态,然后建立一个矩阵保存可转移的状态,再然后把每 ...
- oracle 11g AUTO_SAMPLE_SIZE动态采用工作机制
Note that if you're interested in learning about Oracle Database 12c, there's an updated version of ...
- Java Web-----JSP与Servlet(一)
JSP (java服务器页面) JSP全名为Java Server Pages,中文名叫java服务器页面,其根本是一个简化的Servlet设计,它[1] 是由Sun Microsystems公司倡 ...
- Summarization of Tech Interviews
Summarization of Tech Interviews(技术面试总结) 手心网(2015) Q1. 解释一下 TCP/IP 协议之滑动窗口? 滑动窗口协议的维基:https://en.wik ...
- 理解 neutron
之前大师发个结构图. understanding_neutron.pdf 自己走读了代码: 1. get_extensions_path() # 在/opt/stack/neutron/neutro ...
- 20145308 《网络对抗》 MAL_免杀原理及实践 学习总结
20145308 <网络对抗> MAL_免杀原理及实践 学习总结 实践内容 (1)理解免杀技术原理 (2)正确使用msf编码器,veil-evasion,自己利用shellcode编程等免 ...
- Office 2016 永久激活
启示:office突然过期,QWQ,卖电脑的真坑爹,找了好多办法,总结2个不花钱的办法啦. 1>只有30天试用期 Office 2016预览版序列号:NKGG6-WBPCC-HXWMY-6DQG ...
- Codeforces 834D The Bakery - 动态规划 - 线段树
Some time ago Slastyona the Sweetmaid decided to open her own bakery! She bought required ingredient ...
- 写了个脚本将json换成md
用python 脚本将protocol.json中的json按照templete.md模版生成,结果在protocol.md中 Python: #!/usr/bin/python # -*- codi ...
- Provinces of China
https://en.wikipedia.org/wiki/Provinces_of_China#Province