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 ...
随机推荐
- Python3 Pandas的DataFrame格式数据写入excle文件、json、html、剪贴板、数据库
Python3 Pandas的DataFrame格式数据写入excle文件.json.html.剪贴板.数据库 一.DataFrame格式数据 Pandas是Python下一个开源数据分析的库,它提供 ...
- oracle 12cR1&12cR2核心高实用性新特性
今天把本地环境升到了12.2.12c应该来说无论从性能和功能性方面都得到了很大的加强,就是不知道实际license怎么卖...原来有些功能在exadata中可用的,现在在12c中可用了,估计很大程度上 ...
- log4j升级到logback
虽然现在log4j已经基本上不更新很久了,但实际上升级log4j到logback最大的难度并不在于本身的替换,而是现有大量的三方jar依然使用log4j,以至于无法100%的exclude掉,所以很有 ...
- 动态规划之97 Interleaving String
题目链接:https://leetcode-cn.com/problems/interleaving-string/description/ 参考链接:https://blog.csdn.net/u0 ...
- Python3基础 dict get 在查询不存在的键时,返回指定的内容
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- (转)开源项目miaosha(上)
石墨文档:https://shimo.im/docs/iTDoZs4CVfICgSfV/ (二期)19.开源秒杀项目miaosha解读(上) [课程19]几张图.xmind0.6MB [课程19]开源 ...
- CF600E Lomsat gelral(dsu on tree)
dsu on tree跟冰茶祭有什么关系啊喂 dsu on tree的模板题 思想与解题过程 类似树链剖分的思路 先统计轻儿子的贡献,再统计重儿子的贡献,得出当前节点的答案后再减去轻儿子对答案的贡献 ...
- (zhuan) How to Train Neural Networks With Backpropagation
this blog from: http://blog.demofox.org/2017/03/09/how-to-train-neural-networks-with-backpropagation ...
- Docker save & load
docker save Estimated reading time: 1 minute Description Save one or more images to a tar archive (s ...
- docker 命令2
docker build -t dvm.adsplatformproxy:v1.0.0 . #build images docker run -e WWNamespace=dev -e ZKServe ...