UVa 11586 - Train Tracks】的更多相关文章

题目:给你一些积木碎片,每一个碎片的两端仅仅能是凸或凹(M或F).凸凹可拼起来.是否能拼成一个环. 分析:图论.欧拉回路.推断入度等于出度就可以,即M和F同样且大于1组. 说明:╮(╯▽╰)╭. #include <cstring> #include <cstdio> char buf[202]; int main() { int n; while (~scanf("%d",&n)) { getchar(); while (n --) { gets(bu…
Problem J: Train Tracks Andy loves his set of wooden trains and railroad tracks. Each day, Daddy has to build a new track for him. The tracks he likes best form a simple loop with no branches or dead ends, so he can run his trains around and around f…
题意:给定平面上$n(3\leq n \leq 1200)$个无三点共线的点,问这些点组成了多少个锐角三角形. 分析:显然任意三点可构成三角形,而锐角三角形不如直角或钝角三角形容易计数,因为后者有且仅有一个角度大于等于$90^{\circ}$的特征角. 于是考虑固定平面上每一个顶点,也就是固定了钝角或直角三角形的一个特征顶点,将其余所有点按照极角排序,然后固定一条侧边,统计有多少条 边和该侧边夹角不小于$90^{\circ}$.这些边必然是连续的,可以使用区间统计的办法,用二分查找在$O(log…
题目大意:给n个数的一个序列,通过交换相邻的两个数使得这n个数按照从小到大的顺序排列. Inversion index problem: count how many swaps are needed to make the list sorted. 使用冒泡排序解决. #include <cstdio> int main() { #ifdef LOCAL freopen("in", "r", stdin); #endif int T; scanf(&q…
题意:给定 n 个不三点共线的点,然后问你能组成多少锐角或者直角三角形. 析:可以反过来求,求有多少个钝角三角形,然后再用总的减去,直接求肯定会超时,但是可以枚举每个点,以该点为钝角的那个顶点,然后再枚举另一条边,维护与该边大于90度并小于等于180度的点的数量,这里要用极角排序,这样就可以减小时间复杂度,但是会WA,要控制精度,但是精度是个迷,表示不会. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #in…
这个题和UVa11529很相似. 枚举一个中心点,然后按极角排序,统计以这个点为钝角的三角形的个数,然后用C(n, 3)减去就是答案. 另外遇到直角三角形的情况很是蛋疼,可以用一个eps,不嫌麻烦的话就用整数的向量做点积. #include <cstdio> #include <cmath> #include <algorithm> using namespace std; typedef long long LL; + ; const double PI = acos…
题号:a001: 哈囉 背景知识:输出语句,while not eof 题号:a002: 簡易加法 背景知识:输出语句,while not eof,加法运算 题号:a003: 兩光法師占卜術 背景知识:while not eof,分支语句,求余 PS:%表示求余 题号:a004: 文文的求婚 背景知识:while not eof,分支语句,判断闰年 题号:a005: Eva 的回家作業 背景知识:循环,if语句,等比数列,等差数列,输出语句 题号:a006: 一元二次方程式 背景知识:if语句的…
//第一期 计算几何题的特点与做题要领: 1.大部分不会很难,少部分题目思路很巧妙 2.做计算几何题目,模板很重要,模板必须高度可靠. 3.要注意代码的组织,因为计算几何的题目很容易上两百行代码,里面大部分是模板.如果代码一片混乱,那么会严重影响做题正确率. 4.注意精度控制. 5.能用整数的地方尽量用整数,要想到扩大数据的方法(扩大一倍,或扩大sqrt2).因为整数不用考虑浮点误差,而且运算比浮点快. 一.点,线,面,形基本关系,点积叉积的理解 POJ 2318 TOYS(推荐) http:/…
Supersized特性: 自动等比例调整图片并填充整浏览器个屏幕. 循环展示图片,支持滑动和淡入淡出等多种图片切换效果. 导航按钮,支持键盘方向键导航. XHTML <div id="loading"> </div>  <div id="supersized"></div>    <div id="prevthumb"></div>  <div id="ne…
UVA - 1025 A Spy in the Metro Secret agent Maria was sent to Algorithms City to carry out an especially dangerous mission. After several thrilling events we find her in the first station of Algorithms City Metro, examining the time table. The Algorit…
列车调度(Train) Description Figure 1 shows the structure of a station for train dispatching. Figure 1 In this station, A is the entrance for each train and B is the exit. S is the transfer end. All single tracks are one-way, which means that the train ca…
Problem    UVA - 11374 - Airport Express Time Limit: 1000 mSec Problem Description In a small city called Iokh, a train service, Airport-Express, takes residents to the airport more quickly than other transports. There are two types of trains in Airp…
A Spy in the Metro Time Limit: 3000MS     64bit IO Format: %lld & %llu Submit Status uDebug Secret agent Maria was sent to Algorithms City to carry out an especially dangerous mission. After several thrilling events we find her in the first station o…
from my CSDN: https://blog.csdn.net/su_cicada/article/details/86939523 例题6-2 铁轨(Rails, ACM/ICPC CERC 1997, UVa 514) 某城市有一个火车站,铁轨铺设如图6-1所示. 有n节车厢从A方向驶入车站,按进站顺 序编号为1-n. 你的任务是判断是否能让它们按照某种特定的顺序进入B方向的铁轨并驶出 车站. 例如,出栈顺序(5 4 1 2 3)是不可能的,但(5 4 3 2 1)是可能的. 为了重…
UVA - 11374 Airport Express Time Limit:1000MS   Memory Limit:Unknown   64bit IO Format:%lld & %llu [Submit]  [Go Back]  [id=22966" style="color:rgb(106,57,6); text-decoration:none">Status] Description ProblemD: Airport Express In a s…
Contents [hide] 1 Audio Classification (Test/Train) tasks 1.1 Description 1.1.1 Task specific mailing list 1.2 Data 1.2.1 Audio Classical Composer Identification 1.2.2 Audio US Pop Music Genre Classification 1.2.3 Audio Latin Music Genre Classificati…
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2369 Description Problem D: Airport Express In a small city called Iokh, a train service, Airport-Express, takes residents to the airport more quick…
题意: 给你一个数n,表示有n辆火车,编号从1到n,入站,问你有多少种出站的可能.    (题于文末) 知识点: ps:百度百科的卡特兰数讲的不错,注意看其参考的博客. 卡特兰数(Catalan):前几项为 : 1, 1, 2, 5, 14, 42, 132, 429, 1430, 4862, 16796, 58786, 208012, 742900, 2674440, 9694845, 35357670- 令h(0)=1,h(1)=1,catalan数满足递推式:      h(n)= h(0…
You have a long drive by car ahead. You have a tape recorder, but unfortunately your best music is onCDs. You need to have it on tapes so the problem to solve is: you have a tape N minutes long. Howto choose tracks from CD to get most out of tape spa…
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABGcAAANuCAYAAAC7f2QuAAAgAElEQVR4nOy9XUhjWbo3vu72RRgkF5…
UVA - 10564 Paths through the Hourglass 题意: 要求从第一层走到最下面一层,只能往左下或右下走 问有多少条路径之和刚好等于S? 如果有的话,输出字典序最小的路径. f[i][j][k]从下往上到第i层第j个和为k的方案数 上下转移不一样,分开处理 没必要判断走出沙漏 打印方案倒着找下去行了,尽量往左走   沙茶的忘注释掉文件WA好多次   #include <iostream> #include <cstdio> #include <a…
UVA - 11404 Palindromic Subsequence 题意:一个字符串,删去0个或多个字符,输出字典序最小且最长的回文字符串 不要求路径区间DP都可以做 然而要字典序最小 倒过来求LCS,转移同时维护f[i][j].s为当前状态字典序最小最优解 f[n][n].s的前半部分一定是回文串的前半部分(想想就行了) 当s的长度为奇时要多输出一个(因为这样长度+1,并且字典序保证最小(如axyzb  bzyxa,就是axb|||不全是回文串的原因是后半部分的字典序回文串可能不是最小,多…
POJ3869 Headshot 题意:给出左轮手枪的子弹序列,打了一枪没子弹,要使下一枪也没子弹概率最大应该rotate还是shoot 条件概率,|00|/(|00|+|01|)和|0|/n谁大的问题 |00|+|01|=|0| 注意序列是环形 // // main.cpp // poj3869 // // Created by Candy on 25/10/2016. // Copyright © 2016 Candy. All rights reserved. // #include <i…
UVA - 11538 Chess Queen 题意:n*m放置两个互相攻击的后的方案数 分开讨论行 列 两条对角线 一个求和式 可以化简后计算 // // main.cpp // uva11538 // // Created by Candy on 24/10/2016. // Copyright © 2016 Candy. All rights reserved. // #include <iostream> #include <cstdio> #include <cst…
UVA - 11388 GCD LCM 题意:输入g和l,找到a和b,gcd(a,b)=g,lacm(a,b)=l,a<b且a最小 g不能整除l时无解,否则一定g,l最小 #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> using namespace std; typedef long long ll…
UVA - 1625 Color Length   白书 很明显f[i][j]表示第一个取到i第二个取到j的代价 问题在于代价的计算,并不知道每种颜色的开始和结束   和模拟赛那道环形DP很想,计算这次转移会给其他的元素带来的代价,也就是转移前已经出现但还没结束的元素都会代价+1   预处理每种颜色在两个序列中出现的位置bg[i][0/1]和ed[i][0/1], 计算f[i][j]时同时计算w[i][j]为(i,j)这个状态已经出现还没结束的个数 注意bg要先初始化为INF,计算w: if(b…
UVA - 10375 Choose and divide Choose and divide Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 4053   Accepted: 1318 Description The binomial coefficient C(m,n) is defined as m! C(m,n) = -------- n!(m-n)! Given four natural numbers p, q…
UVA - 11584 Partitioning by Palindromes We say a sequence of char- acters is a palindrome if it is the same written forwards and backwards. For example, ‘racecar’ is a palindrome, but ‘fastcar’ is not. A partition of a sequence of characters is a lis…
UVA - 11134 Fabled Rooks We would like to place n rooks, 1 ≤ n ≤ 5000, on a n × n board subject to the following restrictions The i-th rook can only be placed within the rectan- gle given by its left-upper corner (xli,yli) and its right- lower corner…
UVA - 11987 Almost Union-Find I hope you know the beautiful Union-Find structure. In this problem, you’re to implement something similar, but not identical. The data structure you need to write is also a collection of disjoint sets, supporting 3 oper…