UVA12653 Buses】的更多相关文章

Problem HBusesFile: buses.[c|cpp|java]Programming competitions usually require infrastructure and organization on the part of thoseresponsible. A problem that frequently must be solved is regarding transportation. While participatingin a recent compe…
C - Pashmak and Buses Codeforces Round #261 (Div. 2) C. Pashmak and Buses time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Recently Pashmak has been employed in a transportation company. The…
题目链接:http://codeforces.com/problemset/problem/459/C 题目意思:有 n 个 students,k 辆 buses.问是否能对 n 个students安排每一天搭乘的buses,使得没有两个student 在 d 天搭乘相同的buses,buses 的 容量没有限制,也就是它可以搭无限多的人. 做这条题的时候,我是得不出无解的条件的,看了 tutorial 之后一下子明白了,就是 k^d > n.很容易理解,因为每一天某个student可以选择的…
1434. Buses in Vasyuki Time limit: 3.0 secondMemory limit: 64 MB The Vasyuki University is holding an ACM contest. In order to help the participants make their stay in the town more comfortable, the organizers composed a scheme of Vasyuki's bus route…
C. Pashmak and Buses time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Recently Pashmak has been employed in a transportation company. The company has k buses and has a contract with a school…
题目地址:http://codeforces.com/contest/459/problem/C C. Pashmak and Buses time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Recently Pashmak has been employed in a transportation company. The com…
主要题意是:大海之间有岛,有的岛之间有桥,问你岛的个数,桥的个数,以及没有桥联通岛的个数,其中最后一次输入的没有回车,不注意的话最后一次会被吞,第二,桥的两端的标记是“X”(X也代表陆地),“X”的四周都可以有“B”形成的桥,一开始没写好,后来根据“X”标记所有的桥只能走一次然后标记……总之,虽然是水题,写出来还是蛮开心的…… #include <iostream> #include <cstdio> #include <cstdlib> #include <al…
A. Buses Between Cities time limit per test: 1 second memory  limit per test: 256 megabytes input: standard input output: standard output Buses run between the cities A and B, the first one is at 05:00 AM and the last one departs not later than at 11…
A. Buses Between Cities 题目连接: http://www.codeforces.com/contest/665/problem/A Description Buses run between the cities A and B, the first one is at 05:00 AM and the last one departs not later than at 11:59 PM. A bus from the city A departs every a mi…
E - Pashmak and Buses Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 459C Description Recently Pashmak has been employed in a transportation company. The company has k buses and has a c…
 Buses                                                                                                                                                                                      time limit per test 2 seconds                                 …
Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 6234   Accepted: 1698 Description A man arrives at a bus stop at 12:00. He remains there during 12:00-12:59. The bus stop is used by a number of bus routes. The man notes the times of arriv…
题目链接: A. Buses Between Cities time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output   Buses run between the cities A and B, the first one is at 05:00 AM and the last one departs not later than at…
先上题目+: C. Pashmak and Buses time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Recently Pashmak has been employed in a transportation company. The company has k buses and has a contract with a…
Buses and People CodeForces 160E 三维偏序+线段树 题意 给定 N 个三元组 (a,b,c),现有 M 个询问,每个询问给定一个三元组 (a',b',c'),求满足 a<a', b'<b, c'<c 的最小 c 对应的元组编号. 解题思路 三维偏序问题,是我第一次做,查的题解. 一位大佬是这么说的,原博客首先,离线处理所有询问,将这 N+M 个元组按照 a 从小到达进行排序,若有相同的 a,则给定元组应该排在询问元组之前.排序后即可保证对于任意一个询问元组…
/* 题意:n个同学,k个车, 取旅游d天! 要求所有的学生没有两个或者两个以上的在同一辆车上共同带d天! 输出可行的方案! 对于d行n列的矩阵,第i行第j列表示的是第i天第j个同学所在的车号! 也就是保证所有行不全相同,即每一列都是不相同的! 如果每一列都不相同就是表示第j个同学(第j列)在这d天中不会和其他同学(列)在这d天中 都在同一辆车中! 思路:对于每一列我们枚举d天该学生所在的车号!它的下一列只保证有一个元素和它不同就行了!依次下去! 还有一共有 d 个位置来填充车号(1....k)…
题目 跑个案例看看结果就知道了:8 2 3 题目给的数据是 n,k,d 相当于高中数学题:k个人中选择d个人排成一列,有多少种不同的方案数,列出其中n中就可以了. #include<iostream> #include<algorithm> #include<string> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <math.h>…
题目链接 题意: n个人,k个车,d天.每一个人每天能够坐随意一个车.输出一种情况保证:不存在两个人,每天都在同一辆车上 (1 ≤ n, d ≤ 1000; 1 ≤ k ≤ 109). 分析: 比赛中用的方法麻烦至极...基本想法是均分,这样答案肯定比較优.第一天分到同一辆车上的人在第二天再均分,一直到结束就可以 学习了别人的方法:一个人在所有d天中每天坐哪辆车,能够表示为d位k进制数x. 那么2个人每天都在同一辆车上,就是两个人的x相等.所以我们仅仅要构造出n个不同的d位k进制数即可 这种方法…
简单题 #include<cstdio> #include<cstring> #include<cmath> #include<vector> #include<map> #include<stack> #include<queue> #include<string> #include<algorithm> using namespace std; int a,ta,b,tb; int hh,mm;…
题意:n个人,k辆车,要求d天内任意两人都不能一直在同一辆车,能做到给出构造,不能输出-1 思路:我们把某一个人这d天的车号看成一个d位的数字,比如 1 1 2 3代表第一天1号车.第二天1号车.第三天2号车.第四天3号车,那么就是求构造n个不相同的d位数,所以只要kd >= n,然后模拟加一 代码: #include<set> #include<map> #include<stack> #include<cmath> #include<queu…
http://codeforces.com/contest/101/problem/B 给定一个数n,起点是0  终点是n,有m两车,每辆车是从s开去t的,我们只能从[s,s+1,s+2....t-1]处上车,从t处下车., 问能否去到点n,求方案数 设L[x]表示有多少辆车能够到达x处. 只能从t处下车:说明只能单点更新,对于没辆车x,在区间[s,s+1,s+2....t-1]内上车是可以得,那么有多少辆车呢?明显就是∑区间里能到达的点.然后单点更新t即可 数据大,明显不能到达的点是没用的,离…
这题假设将终于的结果竖着看,每一列构成的数能够看成是k进制的数.一共同拥有d列,随意两列都不同样,所以这就是一个d位k进制数全排列的问题,一共同拥有k ^ d个排列.假设k ^ d < n,则打印-1. 打印终于结果时设第一列就为1 1 1 1 ... 1,然后依次每列添加1后(公交车编号从1開始,不是从0開始) .注意,这里是k进制. #include <stdlib.h> #include <stdio.h> #include <algorithm> #inc…
题意: 从A到B的汽车每隔 a 分钟发车一次,从A到B要ta分钟. 从B到A汽车每隔b分钟发车一次,从B到A要ta分钟. Simion从A出发,问他在A->B的途中共遇到了多少辆车. 汽车都是从上午5.00出发,最晚到晚上11.59. 思路: 这种CF题模拟模拟!!!讲道理模拟题的能力好弱啊!!! 直接就是从5:00到11:59模拟一发,然后中间只会有两种可能,一个是那个人还没出去之前,一个是那个人出去了以后,车子在路上. 然后就是纯模拟就可以了,但是模拟的条件,还是靠感觉写的好啊 #inclu…
[题目链接] http://poj.org/problem?id=1167 [算法] 深度优先搜索 + 迭代加深 [代码] #include <algorithm> #include <bitset> #include <cctype> #include <cerrno> #include <clocale> #include <cmath> #include <complex> #include <cstdio&g…
思路: 先把能选的路线都预处理出来 按照能停的车的多少排个序 (剪枝1) 搜搜搜 如果当前剩的车÷当前能停车的多少+deep>=ans剪掉 (剪枝2) //By SiriusRen #include <cstdio> #include <cstring> #include <algorithm> using namespace std; int n,vis[60],xx,cnt,ans=17; struct Route{int start,gap,all;}rou…
题目链接:http://codeforces.com/problemset/problem/459/C 题意:有n个人,k辆车,d天要求没有两个人在d天都坐在一起.输出坐的方法. 题解:这题很有意思,首先在这d天里每个人都有一个序列那就是每天坐哪辆车.然后为了满足题意只要他们 的序列都是独一无二的就行.也就是说k辆车,d天总共有k^d次方的坐法,所以最多能提供k^d个人.然后 就是怎么输出了,这有一个技巧,只要构成d位的k进制数就行.然后遍历1-n依次加1即可. #include <iostre…
题目链接:http://codeforces.com/problemset/problem/459/C 题意:n个人, k辆车, d天,每天将所有 任意人安排到k辆车, 问怎样安排, 可时不存在 2人或2人以上 d天都在一起. 题解:可以构造一个数组A, n行d列,0<a[i][j] <= k. 不存在两行完全相等,由此可得 k^d < n 可以构造以个k进制数, 从0 加到n 不得不说智商是硬伤T T,看了赛后题解才恍然大悟. /***Good Luck***/ #define _CR…
题目大意:给定 N 个三元组 (a,b,c),现有 M 个询问,每个询问给定一个三元组 (a',b',c'),求满足 a<a', b'<b, c'<c 的最小 c 对应的元组编号. 题解:这可以算是一道经典的三维偏序问题. 首先,离线处理所有询问,将这 N+M 个元组按照 a 从小到达进行排序,若有相同的 a,则给定元组应该排在询问元组之前.排序后即可保证对于任意一个询问元组,答案一定出现在该元组以前的给定元组中.因为要求的是最小的满足条件的 C,应该在 C 上建立线段树.对 C 进行离…
传送门 POJ Vjudge 解题思路 可以首先预处理一下可能成为一条线路的所有方案,然后把这些可能的方案按照长度降序排序,即按照路线上的时间节点从多到少排序. 因为这样我们就可以先确定更多的时刻的状态,减少搜索深度. 然后加一个最优化剪枝: 如果当前花费加上未来的最少的花费不会优,就直接return掉. 然后因为我们把所有的路线都按照路上节点数降序排序,所以我们只要碰到第一个不会更优的就直接return. 细节注意事项 ans的初始化最好只要开到17,不然会跑得慢一些 然后在 vjudge 或…
这个题目说的是有n个人,有k辆巴士,有m天,每天都要安排n个人坐巴士(可以有巴士为空),为了使得这n个人不会成为朋友,只要每两个人在这m天里坐的巴士至少一天不相同即可. 要你求是否有这样的安排方法,如果有,输出具体的安排方案,每个人每天坐那辆车. 挺不错的题目,我压根没想到..真的,虽然知道之后惊呼原来如此简单,但一开始确实想岔了.现在一看这题目,很清晰,每个学生在这m天中坐的车辆,就会形成一个由m个数字组成的序列(数字为1-k代表巴士编号),按照题目要求,只需要学生的那个序列是独一无二的即可.…