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 ...
随机推荐
- django变量使用-在模板中使用视图函数中的变量
DTL语言,即django template language 第一次使用时,需要修改项目的setting.py文件,将其中TEMPLATES中的DIRS修改为os.path.join(BASE_DI ...
- JDK常用命令(三)jmap
jmap jmap,Java Memory Map.主要用于打印指定Java进程(或核心文件.远程调试服务器)的共享对象内存映射或堆内存细节. jmap命令可以获得运行中的jvm的堆的快照,从而可以离 ...
- 【题解】Luogu P1204 [USACO1.2]挤牛奶Milking Cows
原题传送门:P1204 [USACO1.2]挤牛奶Milking Cows 实际是道很弱智的题目qaq 但窝还是觉得用珂朵莉树写会++rp(窝都初二了,还要考pj) 前置芝士:珂朵莉树 窝博客里对珂朵 ...
- 【题解】Luogu P1648 看守
原题传送门:P1648 看守 这题目让求得的是d维( d <=4 )空间中n个点( 2 <= N <= 1000000 )之间最大的哈曼顿距离 模拟,emm,能拿30分,不错 因为d ...
- 08: MySQL慢查询
1.1 寻找慢查询 定义:我们将超过指定时间的SQL语句查询称为“慢查询”. 1.在mysql日志中开启慢查询日志 1. 修改配置文件 在 my.ini 增加几行: 主要是慢查询的定义时间(超 ...
- Codeforces 839C Journey - 树形动态规划 - 数学期望
There are n cities and n - 1 roads in the Seven Kingdoms, each road connects two cities and we can r ...
- [内核驱动] DOS路径转化为NT路径
转载:http://blog.csdn.net/qq_33504040/article/details/78468278 最近在做一个文件过滤驱动程序,禁止访问指定目录或文件.想要从R3给R0发命令和 ...
- 查看Windows系统信息
在终端输入"msinfo32". ms>Microsoft info>information
- 2015,3,10 1(南阳理工ACM)
描述输入三个字符(可以重复)后,按各字符的ASCII码从小到大的顺序输出这三个字符. 输入 第一行输入一个数N,表示有N组测试数据.后面的N行输入多组数据,每组输入数据都是占一行,有三个字符组成, ...
- javascript中的高阶函数, 和 类定义Function, 和apply的使用
参考: http://www.cnblogs.com/delin/archive/2010/06/17/1759695.html js中的类, 也是用function关键字来定义的: function ...