初始有N堆积木,第i堆积木只有一个编号为i的积木,然后进行p次操作,每次操作可能为以下两种:
M x y:将编号x所在的那堆积木放到编号y所在的那堆积木的上面。
输入描述:
第一行一个整数q,表示操作次数。
接下来有q行输入,M, x, y或者C, x(保证)。
积木的总个数N,不会出现在输入中。初始时每个积木单独为一列。你可以认为,操作过程中,不会出现编号大于30000的积木。
输出描述:
对于每个询问,输出相应的值。
Talk is Cheap, Show Me the Code!
初始有N堆积木,第i堆积木只有一个编号为i的积木,然后进行p次操作,每次操作可能为以下两种:
M x y:将编号x所在的那堆积木放到编号y所在的那堆积木的上面。
输入描述:
第一行一个整数q,表示操作次数。
接下来有q行输入,M, x, y或者C, x(保证)。
积木的总个数N,不会出现在输入中。初始时每个积木单独为一列。你可以认为,操作过程中,不会出现编号大于30000的积木。
输出描述:
对于每个询问,输出相应的值。
有n个城市,被m条无向边连接,每条边有一个开车经过所需要的时间。
Jack开车的时间不能连续超过x分钟,也就是需要开车时间超过x的边,他不会走。
求有多少对城市(a,b),满足他可以开车从a城市到达b城市。
输入描述:
第一行3个整数n,m和q。
接下来m行,每行3个整数a,b,c.表示一条连接a和b的边,长度为c。
接下来q行,每行一个整数x,表示一次询问。
输出描述:
对于每个询问,输出相应的结果。
逛逛集市,兑兑奖品,看看节目对农夫约翰来说不算什么,可是他的奶牛们非常缺乏锻炼——如果要逛完一整天的集市,他们一定会筋疲力尽的。所以为了让奶牛们也能愉快地逛集市,约翰准备让奶牛们在集市上以车代步。但是,约翰木有钱,他租来的班车只能在集市上沿直线跑一次,而且只能停靠N个地点(所有地点都以1到N之间的一个数字来表示)。
现在奶牛们分成K个小组,第i组有M_i头奶牛,他们希望从S_i跑到T_i。由于班车容量有限,可能载不下所有想乘车的奶牛们,此时也允许小组里的一部分奶牛分开乘坐班车。约翰经过调查得知班车的容量是C ,请你帮助约翰计划一个尽可能满足更多奶牛愿望的方案。
输入描述:
第一行包括三个整数K N C,彼此用空格隔开。
第二行到K+1行:在第i+1行,将会告诉你第i组奶牛的信息:S_i,E_i和M_i,彼此用空格隔开。
输出描述:
可以坐班车的奶牛的最大头数。
给定一个长度为n的序列A,有m个询问,每次询问下标在[L,R]范围内的数字,从小到大排序之后,第K小的元素值,同时需要支持修改某个元素。
输入描述:
第一行两个整数n和m。
第二行n个整数,表示Ai。
接下来m行,属于下面两种情况之一:
1 L R K:表示下标在[L,R]范围内的第K小的数。
2 x y:把A[x]赋值成y。
输出描述:
对于每个询问,输出相应的结果。
给定一个长度为n的序列A,有m次操作,每次操作为以下两种之一:
(1)0 x a,把A[x]改成a。
(2)1 x y,求区间[x,y]的最大连续和,即 max{A[i] + … + A[j]} (x<=i<=j<=y)
输入描述:
第一行一个整数n。
第二行n个元素,表示序列中的元素。
第三行一个整数m,表示操作的个数。
接下来m行,每行为两种操作中的一种。
输出描述:
对于每个询问输出相应的结果。
给定一个长度为n的序列A,有m个询问,每次询问下标在[L,R]范围内的数字,从小到大排序之后,第K小的元素值。
输入描述:
第一行两个整数n和m。
第二行n个整数,表示Ai。
接下来m行,每行3个整数L,R,K。
输出描述:
对于每个询问,输出相应的结果。
求逆序对数
输入描述:
The first line contains the number of scenarios.
For every scenario, you are given a line containing first the length N (1 <= N <= 1000) of the sequence,followed by the N elements of the sequence (each element is an integer in [-1000000, 1000000]). All numbers in this line are separated by single blanks.
输出描述:
Start the output for every scenario with a line containing “Scenario #i:”, where i is the number of the scenario starting at 1. Then print a single line containing the minimal number of swaps of adjacent numbers that are necessary to sort the given sequence. Terminate the output for the scenario with a blank line.
Japan plans to welcome the ACM ICPC World Finals and a lot of roads must be built for the venue. Japan is tall island with N cities on the East coast and M cities on the West coast (M <= 1000, N <= 1000). K superhighways will be build. Cities on each coast are numbered 1, 2, … from North to South. Each superhighway is straight line and connects city on the East coast with city of the West coast. The funding for the construction is guaranteed by ACM. A major portion of the sum is determined by the number of crossings between superhighways. At most two superhighways cross at one location. Write a program that calculates the number of the crossings between superhighways.
输入描述:
The input file starts with T - the number of test cases. Each test case starts with three numbers – N, M, K. Each of the next K lines contains two numbers – the numbers of cities connected by the superhighway. The first one is the number of the city on the East coast and second one is the number of the city of the West coast.
输出描述:
For each test case write one line on the standard output:
Test case (case number): (number of crossings)
For the k-th number, we all should be very familiar with it. Of course,to kiki it is also simple. Now Kiki meets a very similar problem, kiki wants to design a container, the container is to support the three operations.
Push: Push a given element e to container
Pop: Pop element of a given e from container
Query: Given two elements a and k, query the kth larger number which greater than a in container;
Although Kiki is very intelligent, she can not think of how to do it, can you help her to solve this problem?
输入描述:
Input some groups of test data ,each test data the first number is an integer m (1 <= m <100000), means that the number of operation to do. The next m lines, each line will be an integer p at the beginning, p which has three values:
If p is 0, then there will be an integer e (0 <e <100000), means press element e into Container.If p is 1, then there will be an integer e (0 <e <100000), indicated that delete the element e from the container
If p is 2, then there will be two integers a and k (0 <a <100000, 0 <k <10000),means the inquiries, the element is greater than a, and the k-th larger number.
输出描述:
For each deletion, if you want to delete the element which does not exist, the output “No Elment!”. For each query, output the suitable answers in line .if the number does not exist, the output “Not Find!”.
Astronomers often examine star maps where stars are represented by points on a plane and each star has Cartesian coordinates. Let the level of a star be an amount of the stars that are not higher and not to the right of the given star. Astronomers want to know the distribution of the levels of the stars.
For example, look at the map shown on the figure above. Level of the star number 5 is equal to 3 (it’s formed by three stars with a numbers 1, 2 and 4). And the levels of the stars numbered by 2 and 4 are 1. At this map there are only one star of the level 0, two stars of the level 1, one star of the level 2, and one star of the level 3.
You are to write a program that will count the amounts of the stars of each level on a given map.
输入描述:
The first line of the input file contains a number of stars N (1<=N<=15000). The following N lines describe coordinates of stars (two integers X and Y per line separated by a space, 0<=X,Y<=32000). There can be only one star at one point of the plane. Stars are listed in ascending order of Y coordinate. Stars with equal Y coordinates are listed in ascending order of X coordinate.
输出描述:
The output should contain N lines, one number per line. The first line contains amount of stars of the level 0, the second does amount of stars of the level 1 and so on, the last line contains amount of stars of the level N-1.