103. Traffic Lights Time limit per test: 0.25 second(s)Memory limit: 4096 kilobytes input: standardoutput: standard In the city of Dingilville the traffic is arranged in an unusual way. There are junctions and roads connecting the junctions. There is…
Hangover Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 103896   Accepted: 50542 Description How far can you make a stack of cards overhang a table? If you have one card, you can create a maximum overhang of half a card length. (We're a…
POJ1158 城市交通Traffic lights IOI 1999 (最短路) (1) 问题描述(probolem) 在d城里交通的安排不同寻常,城中有路口和路口之间的道路,再任意两个不同的路口之间之多有一条道路.从任何一个路口出发,不可能不经过其他路口直接回到该路口.在同一条路道上反正两个方向所需要的通过时间是相同的.在每个路口上只有一盏信号灯,信号灯的颜色在蓝色和紫色之间有规律的交替变化:蓝色有特定的持续时间,紫色也有特定的持续时间,再任意一条道路的两个路口之间,当且仅当这两个路口的信号…
103. Traffic Lights Time limit per test: 0.25 second(s) Memory limit: 4096 kilobytes 题解: 1.其实就是求两点间的最短路,不过加了交通灯的限制,使得两点间的所需时间并不只是由路程决定. 2.只有一条路两个端点的交通灯颜色相同时,该路才可以通过.但是这有一种情况,当两个交通灯处于不同颜色时,经过t时间,交通灯又恰好处于不同颜色,由于最初有一个颜色预变时间riC以及蓝色tiB.紫色周期tiP ,那么就需要计算交通灯…
Traffic Lights time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A car moves from point A to point B at speed v meters per second. The action takes place on the X-axis. At the distance d met…
时间: 0.50 second(s) 空间: 4096 kilobytes 输入: 标准输入 输出: 标准输出 Dingiville 城市的交通规则非常奇怪,城市公路通过路口相连,两个不同路口之间最多只有一条直达公路.公路的起止点不会是同一路口.在任意一条公路上顺不同方向走所需 时间相同.每一个路口都有交通灯,这些交通灯在某一时刻要么是蓝色,要么是紫色.同一个灯上2个颜色的维持时间受到定期调控,总是蓝色持续一段时间,紫色 持续一段时间.交通规则规定两个路口可以通车仅当公路两边交通灯的颜色相同(也…
Highways Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 23033   Accepted: 10612 Description The island nation of Flatopia is perfectly flat. Unfortunately, Flatopia has no public highways. So the traffic is difficult in Flatopia. The Fl…
题目大意:有一个城市的路线图,有N个交叉点,每两个交叉点之间只有一条路,现在想从交点u去交点v,不过这个路的交通比较特别,每个路都有一个交通灯,灯有两种颜色,蓝色和紫色,例如一条路线在交点s,t之间,如果想从s走到t,那么只有等s和t的交通灯的颜色一致的时候才可以从s走,求出来从u到v的最短时间. 分析:比较明显能看出来是一个最短路问题,不过里面夹杂的这个交通灯比较恶心,要随时能求出来两点点下一个相同颜色的时间,如果使用时间去枚举无疑是个比较笨的方法,注意到有个剩余时间,并且交通灯的每种颜色存在…
115. Calendar time limit per test: 0.25 sec. memory limit per test: 4096 KB First year of new millenium is gone away. In commemoration of it write a program that finds the name of the day of the week for any date in 2001. Input Input is a line with t…
113. Nearly prime numbers time limit per test: 0.25 sec. memory limit per test: 4096 KB Nearly prime number is an integer positive number for which it is possible to find such primes P1 and P2 that given number is equal to P1*P2. There is given a seq…
111.Very simple problem time limit per test: 0.5 sec. memory limit per test: 4096 KB You are given natural number X. Find such maximum integer number that it square is not greater than X. Input Input file contains number X (1≤X≤101000). Output Write…
105. Div 3 time limit per test: 0.25 sec. memory limit per test: 4096 KB There is sequence 1, 12, 123, 1234, ..., 12345678910, ... . Given first N elements of that sequence. You must determine amount of numbers in it that are divisible by 3. Input In…
104. Little shop of flowers time limit per test: 0.25 sec. memory limit per test: 4096 KB PROBLEM You want to arrange the window of your flower shop in a most pleasant way. You have F bunches of flowers, each being of a different kind, and at least a…
102. Coprimes time limit per test: 0.25 sec. memory limit per test: 4096 KB For given integer N (1<=N<=104) find amount of positive numbers not greater than N that coprime with N. Let us call two positive integers (say, A and B, for example) coprime…
Help Me with the Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3510   Accepted: 2251 Description Your task is to read a picture of a chessboard position and print it in the chess notation. Input The input consists of an ASCII-art…
Emag eht htiw Em Pleh Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2806   Accepted: 1865 Description This problem is a reverse case of the problem 2996. You are given the output of the problem H and your task is to find the correspond…
实在太冷了今天 taxi :错误原因1 忽略了 1 1 1 1 和 1 2 1 这种情况,直接认为最多两组一车了 2 语句顺序错 double cola: 忘了减去n的序号1,即n-- B. Taxi time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output After the lessons n groups of schoolchi…
112. a^b-b^a time limit per test: 0.25 sec. memory limit per test: 4096 KB You are given natural numbers a and b. Find a^b-b^a. Input Input contains numbers a and b (1≤a,b≤100). Output Write answer to output. Sample Input 2 3Sample Output -1 import j…
487-3279 Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 247781   Accepted: 44015 Description Businesses like to have memorable telephone numbers. One way to make a telephone number memorable is to have it spell a memorable word or phras…
Borg Maze Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8905   Accepted: 2969 Description The Borg is an immensely powerful race of enhanced humanoids from the delta quadrant of the galaxy. The Borg collective is the term used to descr…
题目链接: http://acm.hust.edu.cn/vjudge/problem/visitOriginUrl.action?id=16530 题意: 给定每个点最初的颜色,最初颜色持续时间,以及每个颜色的持续时间.每个点的颜色蓝紫交替,只有等待到一条路的两个端点颜色相同才能通行.到达某点时颜色恰好变色,则按照变色之后的颜色考虑. 给定道路的花费,问最少需要多少时间. 分析: 最短路问题. dijk可做,麻烦之处在于要加上等待时间.对于每个点,判断相邻点颜色是否一致,不一致则选取当前颜色持…
Extended Traffic 题目链接: http://acm.hust.edu.cn/vjudge/contest/122685#problem/O Description Dhaka city is getting crowded and noisy day by day. Certain roads always remain blocked in congestion. In order to convince people avoid shortest routes, and he…
题目链接:Fight Against Traffic 题意:有n个点个m条双向边,现在给出两个点S和T并要增加一条边,问增加一条边且S和T之间距离不变短的情况有几种? 题解:首先dfs求一下S到其他点和T到其他点的最短路(好久不写有点手生@.@),然后遍历所有的建边的情况,假设在i和j两个点之间建边则要满足 ds[i] + 1 + dt[j] > ds[T] && ds[j] + 1 + dt[i] > ds[T]. #include<bits/stdc++.h>…
这道题难得不是算法,而是处理. 题意就是让你求最短路,只有当两个点在某一秒颜色相同时,这条边才可以通行,输入首先给你 起点和终点, 然后给你 点数和边数, 接下来 n 行 初始颜色,初始颜色持续时间,蓝色持续时间,紫色持续时间. 再接下来m行,无向边的起点和终点以及通过所需的时间. 题意他说的有些模糊,样例我看了很多遍也不对,后来才发现如果你在某一秒到达一个点,这一秒颜色和下一个点相同,但是下一秒这个点就要变色,那么是不能在这一秒走的,这个具体处理起来很麻烦 这篇博客说的很详细,戳链接:http…
题目大意: 在Dingilville 城市安排是一种不同寻常的方式,每个交叉路口有一条道路连接,一条道路最多连接两个不同的交叉路口.每个交叉路口不能连接他自己.道路旅行一端到另一端的时间是相同的,任何一个交叉路口都有一个红绿灯,它在任意时刻只能有红色或者绿色.当且仅当两个交叉路口的灯的颜色一样的时候才允许从一个交叉路口到达另一个交叉路口.如果一辆车到达一个交叉路口的时候这个灯刚好转换,那么它必须考虑这个灯的颜色.允许车辆在交叉路口等待. 给你这个城市的地图如下: 所有道路的通过时间是整数,每个交…
Description On the evening of 3 August 1492, Christopher Columbus departed from Palos de la Frontera with a few ships, starting a serious of voyages of finding a new route to India. As you know, just in those voyages, Columbus discovered the America…
Description 题目链接 Solution 从起点和终点分别做一次最短路并记录结果 枚举每一条可能的边判断 Code #include <cstdio> #include <algorithm> #include <queue> #include <cstring> #define N 1010 using namespace std; struct info{int to,nex;}e[N*2]; int n,m,s,t,tot,head[N],d…
题意:一个无向图,求起点到终点最少时间,限制:每个路口有灯,要灯颜色一样才能过去,灯之有俩种颜色,周期 变化,给定每个灯初态,时间. 思路:开始就想到直接DP,方程dp[k]=dp[i]+distance[i][k]+waittime(i,k),于是天真得BFS敲了这个, SB啊!有些点松弛了,之后它又被松弛,它便还可以松弛别人啊!否则世界上最短路O(n)的算法就诞生了! 所以,一旦某个点被松弛了,它便可以再入队,啊哈?这不就是SPFA吗!!我去,这次是对SPFA更加理解了, 自己想法竟然遇上经…
http://poj.org/problem?id=1125 #include <iostream> #include <cstring> using namespace std; int d[101][101];// dag ATTENTION int num[101];//the number of contracts int edge[101][101];// adjecent edge table int n;//always represent the maxnum of…
http://poj.org/problem?id=2253 #include <iostream> #include <queue> #include <cmath> #include <iomanip> using namespace std; queue <int > que; int co[202][2]; double d[202][202],u[202][202]; int n; int main(){ ios::sync_with_…