BUAA-SCSE Training day3 5 6 7

NYIST_2013寒假ACM集训队练习赛(2) 集训第二周周四,做出来了7道题目,题目非常水,还有几道没有A出来的也不难,完了花点时间水一下,a过的题目贴在这里。没有a的后面补上。 比赛链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=39441#overview 密码:nyist I - I Time Limit:1000MS     Memory Limit:32 阅读详情
Highways
Time Limit: 1000MS Memory Limit: 65536K
Total Submissions: 18400 Accepted: 8543

Description

The island nation of Flatopia is perfectly flat. Unfortunately, Flatopia has no public highways. So the traffic is difficult in Flatopia. The Flatopian government is aware of this problem. They're planning to build some highways so that it will be possible to drive between any pair of towns without leaving the highway system. 

Flatopian towns are numbered from 1 to N. Each highway connects exactly two towns. All highways follow straight lines. All highways can be used in both directions. Highways can freely cross each other, but a driver can only switch between highways at a town that is located at the end of both highways. 

The Flatopian government wants to minimize the length of the longest highway to be built. However, they want to guarantee that every town is highway-reachable from every other town.

Input

The first line of input is an integer T, which tells how many test cases followed. 
The first line of each case is an integer N (3 <= N <= 500), which is the number of villages. Then come N lines, the i-th of which contains N integers, and the j-th of these N integers is the distance (the distance should be an integer within [1, 65536]) between village i and village j. There is an empty line after each test case.

Output

For each test case, you should output a line contains an integer, which is the length of the longest road to be built such that all the villages are connected, and this value is minimum.

Sample Input

1

3
0 990 692
990 0 179
692 179 0

Sample Output

692

Hint

Huge input,scanf is recommended.

Source

POJ Contest,Author:Mathematica@ZSU

唯一一道会做的mst...
#include<iostream>
#define INF 0x3f3f3f3f
using namespace std;
int n;
int map[505][505];
int visit[505];
int dis[505];
void getmap()
{
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			cin>>map[i][j];
		}
	}
}
void prim()
{
	int k=1;
	int ans=0;
	memset(visit,0,sizeof(visit));
	memset(dis,INF,sizeof(dis));
	for(int i=1;i<=n;i++)
	{
		dis[i]=map[1][i];
	}
	visit[1]=1;
	for(int i=1;i<n;i++)
	{
		int MIN=INF;
		for(int j=1;j<=n;j++)
		{
			if(!visit[j]&&dis[j]<MIN)
			{
				MIN=dis[j];
				k=j;
			}
		}
		if(MIN==INF)
			break;
		visit[k]=1;
		ans+=MIN;
		for(int j=1;j<=n;j++)
		{
			if(!visit[j])
			{
				dis[j]=min(dis[j],map[k][j]);
			}
		}
	}
	cout<<ans<<endl;
}
	
int main()
{
	int T;
	cin>>T;
	while(T--)
	{
		cin>>n;
		getmap();
		prim();
	}
	system("pause");
	return 0;
}

最短路

Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 20977    Accepted Submission(s): 8965


Problem Description
在每年的校赛里,所有进入决赛的同学都会获得一件很漂亮的t-shirt。但是每当我们的工作人员把上百件的衣服从商店运回到赛场的时候,却是非常累的!所以现在他们想要寻找最短的从商店到赛场的路线,你可以帮助他们吗?

 

Input
输入包括多组数据。每组数据第一行是两个整数N、M(N<=100,M<=10000),N表示成都的大街上有几个路口,标号为1的路口是商店所在地,标号为N的路口是赛场所在地,M则表示在成都有几条路。N=M=0表示输入结束。接下来M行,每行包括3个整数A,B,C(1<=A,B<=N,1<=C<=1000),表示在路口A与路口B之间有一条路,我们的工作人员需要C分钟的时间走过这条路。
输入保证至少存在1条商店到赛场的路线。
 

Output
对于每组输入,输出一行,表示工作人员从商店走到赛场的最短时间
 

Sample Input
   
2 1 1 2 3 3 3 1 2 5 2 3 5 3 1 2 0 0
 

Sample Output
   
3 2
 

Source
 

Recommend
lcy
 
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#define INF 0x3f3f3f3f
using namespace std;
int n;
int map[105][105];
int visit[105];
int dis[105];
int m;
void getmap()
{
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			map[i][j]=i==j?0:INF;
		}
	}
	for(int i=0;i<m;i++)
	{
		int a,b,c;
		cin>>a>>b>>c;
		map[a][b]=map[b][a]=min(c,map[a][b]);
	}
}
void dijsktra()
{
	int k=1;
	memset(visit,0,sizeof(visit));
	memset(dis,0,sizeof(dis));
	for(int i=1;i<=n;i++)
	{
		dis[i]=map[1][i];
	}
	for(int i=0;i<n;i++)
	{
		int MIN=INF;
		for(int j=1;j<=n;j++)
		{
			if(!visit[j]&&dis[j]<MIN)
			{
				MIN=dis[j];
				k=j;
			}
		}
		if(MIN==INF)
			break;
		visit[k]=1;
		for(int j=1;j<=n;j++)
		{
			if(!visit[j])
			{
				dis[j]=min(dis[j],dis[k]+map[k][j]);
			}
		}
	}
	cout<<dis[n]<<endl;
}
int main()
{
	while(cin>>n>>m,n!=0&&m!=0)
	{
		getmap();
		dijsktra();
	}
	return 0;
}

B - Dijkstra?
Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u

Description

You are given a weighted undirected graph. The vertices are enumerated from 1 to n. Your task is to find the shortest path between the vertex 1 and the vertex n.

Input

The first line contains two integers n and m (2 ≤ n ≤ 105, 0 ≤ m ≤ 105), where n is the number of vertices and m is the number of edges. Following m lines contain one edge each in form ai, bi and wi (1 ≤ ai, bi ≤ n, 1 ≤ wi ≤ 106), where ai, bi are edge endpoints and wi is the length of the edge.

It is possible that the graph has loops and multiple edges between pair of vertices.

Output

Write the only integer -1 in case of no path. Write the shortest path in opposite case. If there are many solutions, print any of them.

Sample Input

Input
5 6
1 2 2
2 5 5
2 3 4
1 4 1
4 3 3
3 5 1
Output
1 4 3 5 
Input
5 6
1 2 2
2 5 5
2 3 4
1 4 1
4 3 3
3 5 1
Output
1 4 3 5 

TT..不会。。。
C - Tram
Time Limit:1000MS     Memory Limit:30000KB     64bit IO Format:%I64d & %I64u

Description

Tram network in Zagreb consists of a number of intersections and rails connecting some of them. In every intersection there is a switch pointing to the one of the rails going out of the intersection. When the tram enters the intersection it can leave only in the direction the switch is pointing. If the driver wants to go some other way, he/she has to manually change the switch. 

When a driver has do drive from intersection A to the intersection B he/she tries to choose the route that will minimize the number of times he/she will have to change the switches manually. 

Write a program that will calculate the minimal number of switch changes necessary to travel from intersection A to intersection B. 

Input

The first line of the input contains integers N, A and B, separated by a single blank character, 2 <= N <= 100, 1 <= A, B <= N, N is the number of intersections in the network, and intersections are numbered from 1 to N. 

Each of the following N lines contain a sequence of integers separated by a single blank character. First number in the i-th line, Ki (0 <= Ki <= N-1), represents the number of rails going out of the i-th intersection. Next Ki numbers represents the intersections directly connected to the i-th intersection.Switch in the i-th intersection is initially pointing in the direction of the first intersection listed. 

Output

The first and only line of the output should contain the target minimal number. If there is no route from A to B the line should contain the integer "-1".

Sample Input

3 2 1
2 2 3
2 3 1
2 1 2

Sample Output

0

关键是构图
#include<iostream>
#include<cstring>
#define INF 0x3f3f3f3f
using namespace std;
int map[105][105];
int visit[105];
int dis[105];
int n,s,e;
void getmap()
{
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			map[i][j]=i==j?0:INF;
		}
	}
	for(int i=1;i<=n;i++)
	{
		int sum;
		cin>>sum;
		for(int j=0;j<sum;j++)
		{
			int x;
			cin>>x;
			if(j)
			{
				map[i][x]=1;
			}
			else
			{
				map[i][x]=0;
			}
		}
	}
}
void dijsktra()
{
	int k=1;
	memset(visit,0,sizeof(visit));
	memset(dis,0,sizeof(dis));
	for(int i=1;i<=n;i++)
	{
		dis[i]=map[s][i];
	}
	visit[s]=1;
	for(int i=0;i<n;i++)
	{
		int MIN=INF;
		for(int j=1;j<=n;j++)
		{
			if(!visit[j]&&dis[j]<MIN)
			{
				MIN=dis[j];
				k=j;
			}
		}
		if(MIN==INF)
			break;
		visit[k]=1;
		for(int j=1;j<=n;j++)
		{
			if(!visit[j])
			{
				dis[j]=min(dis[j],dis[k]+map[k][j]);
			}
		}
	}
	if(dis[e]==INF)
	{
		cout<<"-1"<<endl;
	}
	else
	{
		cout<<dis[e]<<endl;
	}
}
int main()
{
	cin>>n>>s>>e;
	getmap();
	dijsktra();
	return 0;
}

D - Greg and Graph
Time Limit:3000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

Description

Greg has a weighed directed graph, consisting of n vertices. In this graph any pair of distinct vertices has an edge between them in both directions. Greg loves playing with the graph and now he has invented a new game:

  • The game consists of n steps.
  • On the i-th step Greg removes vertex number xi from the graph. As Greg removes a vertex, he also removes all the edges that go in and out of this vertex.
  • Before executing each step, Greg wants to know the sum of lengths of the shortest paths between all pairs of the remaining vertices. The shortest path can go through any remaining vertex. In other words, if we assume that d(i, v, u) is the shortest path between vertices v and u in the graph that formed before deleting vertex xi, then Greg wants to know the value of the following sum: .

Help Greg, print the value of the required sum before each step.

Input

The first line contains integer n (1 ≤ n ≤ 500) — the number of vertices in the graph.

Next n lines contain n integers each — the graph adjacency matrix: the j-th number in the i-th line aij (1 ≤ aij ≤ 105, aii = 0)represents the weight of the edge that goes from vertex i to vertex j.

The next line contains n distinct integers: x1, x2, ..., xn (1 ≤ xi ≤ n) — the vertices that Greg deletes.

Output

Print n integers — the i-th number equals the required sum before the i-th step.

Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams of the %I64dspecifier.

Sample Input

Input
1
0
1
Output
0 
Input
2
0 5
4 0
1 2
Output
9 0 
Input
4
0 3 1 1
6 0 400 1
2 4 0 1
1 1 1 0
4 1 2 3
Output
17 23 404 0 

反向floyd。。
其实不太懂。。
#include <iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#define MAXN 505
int n;
long long int sum[MAXN];
int map[MAXN][MAXN];
int del[MAXN];
using namespace std;
void floyd()
{
	for(int k=n-1;k>=0;--k)
    {
        for(int i=1;i<=n;++i)
        {
            for(int j=1;j<=n;++j)
            {
                map[i][j]=min(map[i][del[k]]+map[del[k]][j],map[i][j]);
            }
        }
        for(int i=n-1;i>=k;i--)
        {
            for(int j=n-1;j>=k;j--)
            {
                sum[k]+=map[del[i]][del[j]];
			}
		}
	}
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            cin>>map[i][j];
        }
    }
    for(int i=0;i<n;i++)
    {
        cin>>del[i];
        sum[i]=0;
    }
    floyd();
    for(int i=0;i<n;i++)
    {
        if(i!=0)
			cout<<" ";
        cout<<sum[i];
    }
    cout<<endl;
    return 0;
}

A - 签到
Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u

Description

Calculate  A + B.
 

Input

Each line will contain two integers  A and  B. Process to end of file.
 

Output

For each case, output  A + B in one line.
 

Sample Input

        
1 1
 

Sample Output

        
2
 

#include<iostream>
using namespace std;
int main()
{
	int a,b;
	while(cin>>a>>b)
	{
		cout<<a+b<<endl;
	}
	return 0;
}

B - Sudoku Checker
Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u

Description

The puzzle game of Sudoku is played on a board of N2 × N2 cells. The cells are grouped in N × N squares of N × N cells each. Each cell is either empty or contains a number between 1 and N2.

The sudoku position is correct when numbers in each row, each column and each square are different. The goal of the game is, starting from some correct position, fill all empty cells so that the final position is still correct.

This game is fairly popular in the Internet, and there are many sites which allow visitors to solve puzzles online. Such sites always have a subroutine to determine a correctness of a given position.

You are to write such a routin.

Input

Input file contains integer N, followed by N4 integers — sudoku position. Empty cells are denoted by zeroes.

Constraints

1 ≤ N ≤ 10.

Output

Output file must contain a single string 'CORRECT' or 'INCORRECT'.
 

Sample Input

Sample input 1
2
0 0 0 0
0 0 0 0
0 0 2 0
0 0 0 1
Sample input 2
2
2 1 3 0
3 2 4 0
1 3 2 4
0 0 0 1

Sample Output

Sample output 1
CORRECT
Sample output 2
INCORRECT

Hint

Bold texts appearing in the sample sections are informative and do not form part of the actual data.

微软小学者面试的时候还问我数独算法来着。。。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib> 
using namespace std;
int map[105][105];
int visit[105];
int n;
int N;
int column(int index)
{
    memset(visit,0,sizeof(visit));
    for(int i=0;i<N;i++)
    {
        if(visit[map[i][index]])
		{
			return 0;
		}
        if(map[i][index]!=0)
        {
            visit[map[i][index]]=1;
        }
    }
    return 1;
}
   
int row(int index)
{
    memset(visit,0,sizeof(visit));
    for(int i=0;i<N;i++)
    {
        if(visit[map[index][i]])
		{
			return 0;
		}
        if(map[index][i]!=0)
        {
            visit[map[index][i]]=1;
        }
    }
    return 1;
}
int oksquare(int x,int y)
{
    memset(visit,0,sizeof(visit));
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(map[i+x][y+j]==0)
			{
				continue;
			}
            if(visit[map[i+x][y+j]])
			{
				return 0;
			}
            visit[map[i+x][y+j]]=1;
        }
    }
    return 1;
}
int judge()
{
    for(int i=0;i<N;i++)
    {
        if(!column(i))
		{
			return 0;
		}
		if(!row(i))
		{
			return 0;
		}
    }
    for(int i=0;i<N;i+=n)
    {
        for(int j=0;j<N;j+=n)
        {
            if(!oksquare(i,j))
			{
				return 0;
			}
        }
    }
    return 1;
}
int main()
{
    while(scanf("%d",&n)!=EOF)
    {
    	N=n*n;
        for(int i=0;i<N;i++)
        {
            for(int j=0;j<N;j++)
            {
                scanf("%d",&map[i][j]);
            }
        }   
        if(judge())
        {
            printf("CORRECT\n");
        }
        else
        {
            printf("INCORRECT\n");
        }
    }
    return 0;
}

C - Unordered Subsequence
Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

Description

The sequence is called ordered if it is non-decreasing or non-increasing. For example, sequnces [3, 1, 1, 0] and [1, 2, 3, 100] are ordered, but the sequence [1, 3, 3, 1] is not. You are given a sequence of numbers. You are to find it's shortest subsequence which is not ordered.

A subsequence is a sequence that can be derived from the given sequence by deleting zero or more elements without changing the order of the remaining elements.

Input

The first line of the input contains one integer n (1 ≤ n ≤ 105). The second line contains n space-separated integers — the given sequence. All numbers in this sequence do not exceed 106 by absolute value.

Output

If the given sequence does not contain any unordered subsequences, output 0. Otherwise, output the length k of the shortest such subsequence. Then output k integers from the range [1..n] — indexes of the elements of this subsequence. If there are several solutions, output any of them.

Sample Input

Input
5
67 499 600 42 23
Output
3
1 3 5
Input
3
1 2 3
Output
0
Input
3
2 3 1
Output
3
1 2 3

就像找波峰/波谷一样
#include<iostream>
using namespace std;
int main()
{
	int n;
	int a[100005];
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	int j;
	for(j=2;a[j]==a[1];j++)
	{
		;
	}
	int flag=0;
	if(a[j]>a[1])
	{
		for(int i=j+1;i<=n;i++)
		{
			if(a[i]<a[i-1])
			{
				cout<<"3"<<endl;
				cout<<"1 "<<i-1<<" "<<i<<endl;
				return 0;
			}
		}
	}
	if(a[j]<a[1])
	{
		for(int i=j+1;i<=n;i++)
		{
			if(a[i]>a[i-1])
			{
				cout<<"3"<<endl;
				cout<<"1 "<<i-1<<" "<<i<<endl;
				return 0;
			}
		}
	}
	cout<<"0"<<endl;
	return 0;
}

D - Greenhouse Effect
Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

Description

Emuskald is an avid horticulturist and owns the world's longest greenhouse — it is effectively infinite in length.

Over the years Emuskald has cultivated n plants in his greenhouse, of m different plant species numbered from 1 to m. His greenhouse is very narrow and can be viewed as an infinite line, with each plant occupying a single point on that line.

Emuskald has discovered that each species thrives at a different temperature, so he wants to arrange m - 1 borders that would divide the greenhouse into m sections numbered from 1 to m from left to right with each section housing a single species. He is free to place the borders, but in the end all of the i-th species plants must reside in i-th section from the left.

Of course, it is not always possible to place the borders in such way, so Emuskald needs to replant some of his plants. He can remove each plant from its position and place it anywhere in the greenhouse (at any real coordinate) with no plant already in it. Since replanting is a lot of stress for the plants, help Emuskald find the minimum number of plants he has to replant to be able to place the borders.

Input

The first line of input contains two space-separated integers n and m (1 ≤ n, m ≤ 5000, n ≥ m), the number of plants and the number of different species. Each of the following n lines contain two space-separated numbers: one integer number si (1 ≤ si ≤ m), and one real number xi (0 ≤ xi ≤ 109), the species and position of the i-th plant. Each xi will contain no more than 6 digits after the decimal point.

It is guaranteed that all xi are different; there is at least one plant of each species; the plants are given in order "from left to the right", that is in the ascending order of their xi coordinates (xi < xi + 1, 1 ≤ i < n).

Output

Output a single integer — the minimum number of plants to be replanted.

Sample Input

Input
3 2
2 1
1 2.0
1 3.100
Output
1
Input
3 3
1 5.0
2 5.5
3 6.0
Output
0
Input
6 3
1 14.284235
2 17.921382
1 20.328172
3 20.842331
1 25.790145
1 27.204125
Output
2

Hint

In the first test case, Emuskald can replant the first plant to the right of the last plant, so the answer is 1.

In the second test case, the species are already in the correct order, so no replanting is needed.


/*
dp[i]表示前i株植物不需要移动的最大数目,其中第i株不动 
则dp[i]=max{dp[j]},1<=j<=i,其中s[j]<s[i] 
所求即为n-dp[n]
*/
 
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib> 
#include<algorithm>
using namespace std;
int main()
{
	int n,m;
	int s[5005];
	double x[5005];
	int dp[5005];
	while(cin>>n>>m)
	{
		for(int i=1;i<=n;i++)
		{
			cin>>s[i]>>x[i];
		}
		s[n+1]=m+1;
		memset(dp,0,sizeof(dp));
		for(int i=1;i<=n+1;i++)
		{
			for(int j=1;j<i;j++)
			{
				if(s[j]<=s[i])
				{
					dp[i]=max(dp[i],dp[j]);
				}
			}
			dp[i]++;
		}
		cout<<n-dp[n]<<endl;
	}
	return 0;
}

E - Binomial Coefficients
Time Limit:1000MS     Memory Limit:131072KB     64bit IO Format:%I64d & %I64u

Description

The binomial coefficient C(n, k) has been extensively studied for its importance in combinatorics. Binomial coefficients can be recursively defined as follows:

C(n, 0) = C(n, n) = 1 for all n > 0;
C(n, k) = C(n − 1, k − 1) + C(n − 1, k) for all 0 < k < n.

Given n and k, you are to determine the parity of C(n, k).

Input

The input contains multiple test cases. Each test case consists of a pair of integers n and k (0 ≤ k ≤ n < 231, n > 0) on a separate line.

End of file (EOF) indicates the end of input.

Output

For each test case, output one line containing either a “0” or a “1”, which is the remainder of C(n, k) divided by two.

Sample Input

1 1
1 0
2 1

Sample Output

1
1
0

数学题无解
/*
(n,k)(k<=n)的奇偶性取决于(n-k)与k的二进制表达式是否存在同一位上的两个数码均为1,
若存在,则为偶数,反之为奇数
*/
#include<iostream>
using namespace std;
int main()
{
	int n,k;
    while(cin>>n>>k)
	{
		if(k&(n-k))
		{
			cout<<"0"<<endl;
		}
		else
		{
			cout<<"1"<<endl;
		}
    }
    return 0;
}

F - Good Sequences
Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

Description

Squirrel Liss is interested in sequences. She also has preferences of integers. She thinks n integers a1, a2, ..., an are good.

Now she is interested in good sequences. A sequence x1, x2, ..., xk is called good if it satisfies the following three conditions:

  • The sequence is strictly increasing, i.e. xi < xi + 1 for each i (1 ≤ i ≤ k - 1).
  • No two adjacent elements are coprime, i.e. gcd(xi, xi + 1) > 1 for each i (1 ≤ i ≤ k - 1) (where gcd(p, q) denotes the greatest common divisor of the integers p and q).
  • All elements of the sequence are good integers.

Find the length of the longest good sequence.

Input

The input consists of two lines. The first line contains a single integer n (1 ≤ n ≤ 105) — the number of good integers. The second line contains a single-space separated list of good integers a1, a2, ..., an in strictly increasing order (1 ≤ ai ≤ 105; ai < ai + 1).

Output

Print a single integer — the length of the longest good sequence.

Sample Input

Input
5
2 3 4 6 9
Output
4
Input
9
1 2 3 5 6 7 8 9 10
Output
4

Hint

In the first example, the following sequences are examples of good sequences: [2; 4; 6; 9], [2; 4; 6], [3; 9], [6]. The length of the longest good sequence is 4.


额。。
复杂度小一点的筛法不会做。。下面代码tle
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
using namespace std;
int gcd(int a,int b)
{
	int r=a%b;
	while(r)
	{
		a=b;
		b=r;
		r=a%b;
	}
	return b;
}
int main()
{
	int n;
	int a[100005];
	int dp[100005];
	while(cin>>n)
	{
		a[0]=1;
		for(int i=1;i<=n;i++)
		{
			cin>>a[i];
		}
		memset(dp,0,sizeof(dp));
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<i;j++)
			{
				if(gcd(a[i],a[j])>1)
				{
					dp[i]=max(dp[i],dp[j]);
				}
			}
			dp[i]++;
		}
		cout<<dp[n]<<endl;
	}
	return 0;
}

G - The Frog's Games
Time Limit:1000MS     Memory Limit:65768KB     64bit IO Format:%I64d & %I64u

Description

The annual Games in frogs' kingdom started again. The most famous game is the Ironfrog Triathlon. One test in the Ironfrog Triathlon is jumping. This project requires the frog athletes to jump over the river. The width of the river is L (1<= L <= 1000000000). There are n (0<= n <= 500000) stones lined up in a straight line from one side to the other side of the river. The frogs can only jump through the river, but they can land on the stones. If they fall into the river, they 
are out. The frogs was asked to jump at most m (1<= m <= n+1) times. Now the frogs want to know if they want to jump across the river, at least what ability should they have. (That is the frog's longest jump distance).
 

Input

The input contains several cases. The first line of each case contains three positive integer L, n, and m. 
Then n lines follow. Each stands for the distance from the starting banks to the nth stone, two stone appear in one place is impossible.
 

Output

For each case, output a integer standing for the frog's ability at least they should have.
 

Sample Input

        
6 1 2 2 25 3 3 11 2 18
 

Sample Output

        
4 11
 

/*
二分
*/
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cstdlib>
using namespace std;
int n,m,l;
int dis[500005];
/*
int ok(int ability)
{
	int j=0,i=0,cur=0;
	for(int tt=1;tt<=m;tt++)
	{
		while(dis[j]-dis[i]<=ability)
		{
			j++;
			if(j-1==n+1)
			{
				break;
			}
		}
		cur=dis[j-1];
		i=j-1;
		if(cur>=l)
		{
			break;
		}
	}
	if(cur<l)
	{
		return 0;
	}
	else
	{
		return 1;
	}
}
*/	 
int ok(int ablity)
{
	if(ablity*m<l)
	{
		return 0;
	}
	int i=0,cnt=0,j=0;
	while(i<=n+1)
	{
		if(dis[i]-dis[j]>ablity)
		{
			return 0;
		}
		while(dis[i]-dis[j]<=ablity&&i<=n+1)
		{
			i++;
		}
		j=i-1;
		cnt++;
	}
	if(cnt>m)
	{
		return 0;
	}
	else
	{
		return 1;
	}
}

int main()
{
	while(scanf("%d%d%d",&l,&n,&m)!=EOF)
	{
		for(int i=1;i<=n;i++)
		{
			scanf("%d",&dis[i]);
		}
		dis[0]=0;
		dis[n+1]=l;
		sort(dis,dis+n+2);
		int left=0;
		int right=l;
		int mid;
		while(left<right)
		{
			mid=(left+right)/2;
			if(ok(mid))
			{
				right=mid-1;
			}
			else
			{
				left=mid+1;
			}
		}
		mid=(left+right)/2;
		printf("%d\n",mid);
	}
	return 0;
}

A - Best Cow Line
Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u

Description

FJ is about to take his N (1 ≤ N ≤ 2,000) cows to the annual"Farmer of the Year" competition. In this contest every farmer arranges his cows in a line and herds them past the judges.

The contest organizers adopted a new registration scheme this year: simply register the initial letter of every cow in the order they will appear (i.e., If FJ takes Bessie, Sylvia, and Dora in that order he just registers BSD). After the registration phase ends, every group is judged in increasing lexicographic order according to the string of the initials of the cows' names.

FJ is very busy this year and has to hurry back to his farm, so he wants to be judged as early as possible. He decides to rearrange his cows, who have already lined up, before registering them.

FJ marks a location for a new line of the competing cows. He then proceeds to marshal the cows from the old line to the new one by repeatedly sending either the first or last cow in the (remainder of the) original line to the end of the new line. When he's finished, FJ takes his cows for registration in this new order.

Given the initial order of his cows, determine the least lexicographic string of initials he can make this way.

Input

* Line 1: A single integer: N
* Lines 2..N+1: Line i+1 contains a single initial ('A'..'Z') of the cow in the ith position in the original line

Output

The least lexicographic string he can make. Every line (except perhaps the last one) contains the initials of 80 cows ('A'..'Z') in the new line.

Sample Input

6
A
C
D
B
C
B

Sample Output

ABCBCD

/*
模拟就好
pe了一万遍
*/
#include<iostream>
using namespace std; 
int main()
{
	char cow[2005];
	int n; 
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>cow[i];
	}
	int k=0;
	int cnt=0; 
	for(int i=1;i<=n;i++)
	{
		int left=i;
		int right=n;
		while(cow[left]==cow[right])
		{
			left++;
			right--;
		}
		if(cow[left]<cow[right])
		{
			cout<<cow[i];
		}
		else
		{
			cout<<cow[n];
			n--;
			i--;
		}
		cnt++;
		if(cnt%80==0)
		{
			cout<<endl;
		}
	}
	return 0;
}

B - Saruman's Army
Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u

Description

Saruman the White must lead his army along a straight path from Isengard to Helm’s Deep. To keep track of his forces, Saruman distributes seeing stones, known as palantirs, among the troops. Each palantir has a maximum effective range of R units, and must be carried by some troop in the army (i.e., palantirs are not allowed to “free float” in mid-air). Help Saruman take control of Middle Earth by determining the minimum number of palantirs needed for Saruman to ensure that each of his minions is within R units of some palantir.

Input

The input test file will contain multiple cases. Each test case begins with a single line containing an integer R, the maximum effective range of all palantirs (where 0 ≤ R ≤ 1000), and an integer n, the number of troops in Saruman’s army (where 1 ≤ n ≤ 1000). The next line contains n integers, indicating the positions x1, …, xn of each troop (where 0 ≤ xi ≤ 1000). The end-of-file is marked by a test case with R = n = −1.

Output

For each test case, print a single integer indicating the minimum number of palantirs needed.

Sample Input

0 3
10 20 20
10 7
70 30 1 7 15 20 50
-1 -1

Sample Output

2
4

Hint

In the first test case, Saruman may place a palantir at positions 10 and 20. Here, note that a single palantir with range 0 can cover both of the troops at position 20.

In the second test case, Saruman can place palantirs at position 7 (covering troops at 1, 7, and 15), position 20 (covering positions 20 and 30), position 50, and position 70. Here, note that palantirs must be distributed among troops and are not allowed to “free float.” Thus, Saruman cannot place a palantir at position 60 to cover the troops at positions 50 and 70.


/*
简单贪心,排序后一次寻找中间那个数就好
*/
include<iostream>
#include<algorithm> 
using namespace std;
int n,R;
int a[1005];
int main()
{
	while(cin>>R>>n,R!=-1&&n!=-1)
	{
		for(int i=0;i<n;i++)
		{
			cin>>a[i];
		}
		int ans=0;
		sort(a,a+n);
		for(int i=0;i<n;i++)
		{
			int j;
			for(j=i+1;j<n;j++)
			{
				if(a[i]+R<a[j])
				{
					break;
				}
			}
			int k;
			for(k=j-1;k<n;k++)
			{
				if(a[j-1]+R<a[k])
				{
					break;
				}
			}
			ans++;
			i=k-1;
		}
		cout<<ans<<endl;
	}
	return 0;
}
		

C - Fence Repair
Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u

Description

Farmer John wants to repair a small length of the fence around the pasture. He measures the fence and finds that he needs N (1 ≤ N ≤ 20,000) planks of wood, each having some integer length Li (1 ≤ Li ≤ 50,000) units. He then purchases a single long board just long enough to saw into the N planks (i.e., whose length is the sum of the lengths Li). FJ is ignoring the "kerf", the extra length lost to sawdust when a sawcut is made; you should ignore it, too.

FJ sadly realizes that he doesn't own a saw with which to cut the wood, so he mosies over to Farmer Don's Farm with this long board and politely asks if he may borrow a saw.

Farmer Don, a closet capitalist, doesn't lend FJ a saw but instead offers to charge Farmer John for each of the N-1 cuts in the plank. The charge to cut a piece of wood is exactly equal to its length. Cutting a plank of length 21 costs 21 cents.

Farmer Don then lets Farmer John decide the order and locations to cut the plank. Help Farmer John determine the minimum amount of money he can spend to create the N planks. FJ knows that he can cut the board in various different orders which will result in different charges since the resulting intermediate planks are of different lengths.

Input

Line 1: One integer  N, the number of planks 
Lines 2..  N+1: Each line contains a single integer describing the length of a needed plank

Output

Line 1: One integer: the minimum amount of money he must spend to make  N-1 cuts

Sample Input

3
8
5
8

Sample Output

34

Hint

He wants to cut a board of length 21 into pieces of lengths 8, 5, and 8. 
The original board measures 8+5+8=21. The first cut will cost 21, and should be used to cut the board into pieces measuring 13 and 8. The second cut will cost 13, and should be used to cut the 13 into 8 and 5. This would cost 21+13=34. If the 21 was cut into 16 and 5 instead, the second cut would cost 16 for a total of 37 (which is more than 34).

/*
简单huffman
用优先队列做的
注意要用Long Long 
*/
#include<iostream>
#include<queue>
using namespace std;
struct node
{
	long long len;
	bool operator <(const node &x)const
	{
		return len>x.len;
	}
}pq;
priority_queue<node> que;
int main()
{
	int n;
	long long ans=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>pq.len;
		que.push(pq);
	}
	while(que.size()>1)
	{
		long long a=que.top().len;
		que.pop();
		long long b=que.top().len;
		que.pop();
		pq.len=a+b;
		que.push(pq);
		ans+=pq.len;
	}
	cout<<ans<<endl;
	return 0;
}

D - Cleaning Shifts
Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u

Description

Farmer John is assigning some of his N (1 <= N <= 25,000) cows to do some cleaning chores around the barn. He always wants to have one cow working on cleaning things up and has divided the day into T shifts (1 <= T <= 1,000,000), the first being shift 1 and the last being shift T. 

Each cow is only available at some interval of times during the day for work on cleaning. Any cow that is selected for cleaning duty will work for the entirety of her interval. 

Your job is to help Farmer John assign some cows to shifts so that (i) every shift has at least one cow assigned to it, and (ii) as few cows as possible are involved in cleaning. If it is not possible to assign a cow to each shift, print -1.

Input

* Line 1: Two space-separated integers: N and T 

* Lines 2..N+1: Each line contains the start and end times of the interval during which a cow can work. A cow starts work at the start time and finishes after the end time.

Output

* Line 1: The minimum number of cows Farmer John needs to hire or -1 if it is not possible to assign a cow to each shift.

Sample Input

3 10
1 7
3 6
6 10

Sample Output

2

Hint

This problem has huge input data,use scanf() instead of cin to read data to avoid time limit exceed. 

INPUT DETAILS: 

There are 3 cows and 10 shifts. Cow #1 can work shifts 1..7, cow #2 can work shifts 3..6, and cow #3 can work shifts 6..10. 

OUTPUT DETAILS: 

By selecting cows #1 and #3, all shifts are covered. There is no way to cover all the shifts using fewer than 2 cows.

/*
贪心
排序后
每次选择包括范围最大的
*/
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cstdlib>
using namespace std;
struct node
{
	int start;
	int end;
}cow[25005];
bool cmp(const node &a,const node &b)
{
	if(a.start==b.start)
	{
		return a.end>b.end;
	}
	else
	{
		return a.start<b.start;
	}
}
int main()
{
	int n,t;
	scanf("%d%d",&n,&t);
	for(int i=0;i<n;i++)
	{
		scanf("%d%d",&cow[i].start,&cow[i].end);
	}
	sort(cow,cow+n,cmp);
	if(cow[0].start!=1)
	{
		printf("-1\n");;
	}
	else if(cow[0].end==t)
	{
		printf("1\n");
	}
	else
	{
		int maxend=0;
		int k;
		int flag=0;
		int ok=0;
		int cnt=1;
		for(int i=0;i<n; )
		{
			flag=0;
			maxend=cow[i].end;
			for(int j=i+1;j<n;j++)
			{
				if(cow[j].start>=cow[i].start&&cow[j].start<=cow[i].end+1)
				{
					if(cow[j].end>maxend)
					{
						maxend=cow[j].end;
						k=j;
						flag=1;
					}
				}
			}
			if(flag)
			{
				i=k;
				cnt++;
			}
			else
			{
				break;
			}
			if(cow[i].end==t)
			{
				ok=1;
				break;
			}
		}
		if(ok)
		{
			printf("%d\n",cnt);
		}
		else
		{
			printf("-1\n");
		}
	}
	return 0;
}

E - Radar Installation
Time Limit:1000MS     Memory Limit:10000KB     64bit IO Format:%I64d & %I64u

Description

Assume the coasting is an infinite straight line. Land is in one side of coasting, sea in the other. Each small island is a point locating in the sea side. And any radar installation, locating on the coasting, can only cover d distance, so an island in the sea can be covered by a radius installation, if the distance between them is at most d. 

We use Cartesian coordinate system, defining the coasting is the x-axis. The sea side is above x-axis, and the land side below. Given the position of each island in the sea, and given the distance of the coverage of the radar installation, your task is to write a program to find the minimal number of radar installations to cover all the islands. Note that the position of an island is represented by its x-y coordinates. 
 
Figure A Sample Input of Radar Installations


Input

The input consists of several test cases. The first line of each case contains two integers n (1<=n<=1000) and d, where n is the number of islands in the sea and d is the distance of coverage of the radar installation. This is followed by n lines each containing two integers representing the coordinate of the position of each island. Then a blank line follows to separate the cases. 

The input is terminated by a line containing pair of zeros 

Output

For each test case output one line consisting of the test case number followed by the minimal number of radar installations needed. "-1" installation means no solution for that case.

Sample Input

3 2
1 2
-3 1
2 1

1 2
0 2

0 0

Sample Output

Case 1: 2
Case 2: 1

/*
先求出每个island可能圆心的左右边界
问题转换成一般的贪心选择问题
然后从小到大排序后
从左往右贪心寻找(右边界优先) 
*/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
using namespace std;
int n,d;
struct node
{
	double left;
	double right;
}island[1005];
bool cmp(const node &a,const node &b)
{
	return a.left<b.left;
}
int main()
{
	int tt=1;
	while(cin>>n>>d,n!=0&&d!=0)
	{
		memset(island,0,sizeof(island));
		int ans=1;
		int flag=1;		
		for(int i=0;i<n;i++)
		{
			int x,y;
			cin>>x>>y;
			if(y>d)
			{
				flag=0;
			}
			else if(flag)
			{
				double lenx=sqrt(double(d*d-y*y));
				island[i].left=x-lenx;
				island[i].right=x+lenx;
			}
		}
		if(!flag)
		{
			cout<<"Case "<<tt++<<": -1"<<endl;
		}
		else
		{
			sort(island,island+n,cmp);
			double temp=island[0].right;
			for(int i=1;i<n;i++)
			{
				if(island[i].left>temp)
				{
					ans++;
					temp=island[i].right;
				}
				else if(island[i].right<temp)
				{
					temp=island[i].right;
				}
			}
			cout<<"Case "<<tt++<<": "<<ans<<endl;
		}
	}
	return 0;
}

F - Stall Reservations
Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u

Description

Oh those picky N (1 <= N <= 50,000) cows! They are so picky that each one will only be milked over some precise time interval A..B (1 <= A <= B <= 1,000,000), which includes both times A and B. Obviously, FJ must create a reservation system to determine which stall each cow can be assigned for her milking time. Of course, no cow will share such a private moment with other cows. 

Help FJ by determining:
  • The minimum number of stalls required in the barn so that each cow can have her private milking period
  • An assignment of cows to these stalls over time
Many answers are correct for each test dataset; a program will grade your answer.

Input

Line 1: A single integer, N 

Lines 2..N+1: Line i+1 describes cow i's milking interval with two space-separated integers.

Output

Line 1: The minimum number of stalls the barn must have. 

Lines 2..N+1: Line i+1 describes the stall to which cow i will be assigned for her milking period.

Sample Input

5
1 10
2 4
3 6
5 8
4 7

Sample Output

4
1
2
3
2
4

Hint

Explanation of the sample: 

Here's a graphical schedule for this output: 

Time     1  2  3  4  5  6  7  8  9 10

Stall 1 c1>>>>>>>>>>>>>>>>>>>>>>>>>>>

Stall 2 .. c2>>>>>> c4>>>>>>>>> .. ..

Stall 3 .. .. c3>>>>>>>>> .. .. .. ..

Stall 4 .. .. .. c5>>>>>>>>> .. .. ..
Other outputs using the same number of stalls are possible.
还是Tle。。。
线段树神马的不会。。
/*
tle了
*/
#include<iostream>
#include<algorithm>
using namespace std;
struct node
{
	int start;
	int end;
	int index;
}cow[50005];
bool cmp(const node &a,const node &b)
{
	if(a.start==b.start)
	{
		return a.end>b.end;
	}
	else
	{
		return a.start<b.start;
	}
}
int num[500005];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>cow[i].start>>cow[i].end;
		cow[i].index=i;
	}
	sort(cow,cow+n,cmp);
	int k=1;
	int ok=0;
	for(int i=0;i<n;i++)
	{
		if(!num[cow[i].index])
		{
			num[cow[i].index]=k;
		}
		int temp=cow[i].end;
		for(int j=i+1;j<n;j++)
		{ 
			if(cow[j].start>temp)
			{
				num[cow[j].index]=k;
				temp=cow[j].end;
			}
		}
		k++;	
	}
	int ans=0;
	for(int i=0;i<n;i++)
	{
		ans=max(ans,num[i]);
	}
	cout<<ans<<endl;
	for(int i=0;i<n;i++)
	{
		cout<<num[i]<<endl;
	}
	return 0;
}
				
		

明天计组实验的任务小一点
看看书
干做题不是办法
波束形成算法:LCMV实现(MATLAB) 阵列信号处理,波束成形, 阅读详情

相关推荐

告别里程焦虑:手把手教你用MATLAB/Simulink仿真电动车AMT换挡规律(附代码)

本文详细介绍了如何使用MATLAB/Simulink仿真电动车AMT换挡规律,帮助解决里程焦虑问题。通过搭建完整的仿真系统,包括电机MAP图处理、Stateflow逻辑实现和动力性与经济性换挡曲线生成,优化电动车换挡策略以提升续航与性能。附带的代码示例和实用技巧使开发者能够快速上手并验证仿真结果。

weixin_26757925的博客 311

【CodeForces - 545 ABCDE套题训练题解】贪心, 构造,模拟,dp,最短路树(Dijkstra+变形)

A: 题干: Input The first line contains integer n (1 ≤ n ≤ 100) — the number of cars. Each of the next n lines contains n space-separated integers that determine matrix A. It is guaranteed that on t...

xuanweiace的博客 2011

XCP_Basic 移植步骤

XCP_Basic 移植步骤

ggzzc的博客 2336

生成树 最小生成树_最小生成树

生成树 最小生成树Problem statement: 问题陈述: Given a weighted undirected graph. Find the sum of weights of edges of a Minimum Spanning Tree. 给定加权无向图。 查找最小生成树边缘的权重总和。 Input: 输入: Given 2 integers N and M. N ...

cumtv80668的专栏 300

手把手教你用键盘在Ubuntu上给Lerobot机械臂采集HIL-SERL训练数据(附完整配置文件)

本文详细介绍了在Ubuntu系统中使用键盘控制Lerobot机械臂进行HIL-SERL训练数据采集的完整流程。从环境准备、机械臂校准到键盘遥操系统配置和数据采集优化,提供了实战指南和常见问题解决方案,帮助读者高效获取高质量训练数据,推动具身智能和强化学习应用的发展。

weixin_30733003的博客 491

服务器冗余电源维修图纸,冗余热备份电源的电路图设计

在设计某高可靠性计算机系统时,要求其配套电源采取冗余设计。一般来说,可以采取的方案有容量冗余、冗余冷备份方式、并联均流的N+1备份方式、冗余热备份方式。容量冗余是指电源的最大负载能力大于实际负载,也就是“大马拉小车”,其缺点是不利于提高电源的效率,而且对提高电源的可靠性意义不大。冗余冷备份方式是指电源由两个或多个功能相同的单元模块组成,电源启动后由其中一个单元模块向设备供电,当工作单元发生故障时,...

weixin_39671509的博客 1996

POJ3522:Slim Span

Slim Span Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 4023   Accepted: 2116 Description Given an undirected weighted graph G, you should

第七殿堂 524

手把手教你用Pytorch代码实现Transformer模型(超详细的代码解读)

本文整理了非常清楚的Transformer模型结构图,建议大家在看代码的时候能结合这个结构图来理解,这样理解起来会比较容易! 用Pytorch实现Transformer的完整代码

捡起一束光的博客 7万+

Guava中Graph的操作说明(Guava 23)

来源: https://github.com/google/guava/wiki/GraphsExplained Graphs, Explained Guava's common.graph is a library for modeling graph-structured data, that is, entities and the relationships between the...

kanpiaoxue的专栏 4184

31、多项式的根:求解方法与技术详解

本博客详细探讨了多项式方程根的求解方法与技术,涵盖了从基础理论到高级数值逼近方法的内容。文章介绍了多项式根的存在性条件、解析解法以及常用的数值方法如牛顿法和二分法,并深入分析了割线法、布伦特法等高效数值逼近技术。此外,还讨论了优化策略、根的隔离与验证技术以及实际应用案例,为读者提供了全面的理论知识和实践指导。

w1x2y3的博客 413

构建栅格地图matlab代码

1 使用MATLAB实现地图栅格化 效果图如下所示 图1 ...

qq_59747472的博客 4534

单源最短路径 Dijkstra 算法

Dijkstra Dijkstra算法流程 1.初始化 dist[1]=0,其余节点的 distdistdist 值为正无穷大。 2.找出未标记的、dist[x]dist[ x ]dist[x]最小的节点 xxx ,然后标记节点 xxx。 3.扫描节点 xxx的所有出边 (x,y,z)(x,y,z)(x,y,z),若 dist[y]dist[ y ]dist[y] > dist[x]dist[ x ]dist[x] + zzz,则dist[y]dist[ y ]dist[y] = dist[x]dis

315

Flow Matching05:概率路径与插值【概率路径:线性插值路径(最简单)、高斯插值路径】【先尝试线性插值,看效果如何;若不够好,尝试高斯插值】

好的,我将从数学角度详细解释Flow Matching,从高中生能理解的基础知识开始,逐步深入到高级概念。

u013250861的博客 182

BUAA-SCSE Training day9 Reviewing and Learning

九点开始做,11点半图书馆赶人,还有两题顺便去吃饭,下午OJ崩坏了,好了之后,终于Ak了。。。 水题。。。而且和大一一起训。。压力山大。 A - Hungry Sequence Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status

VeryBigMan 1404

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

CodeForces 20C Dijkstra?

题目 ou are given a weighted undirected graph. The vertices are enumerated from 1 to n. Your task is to find the shortest path between the vertex 1 and the vertex n. Input The first line co

ff137774288的博客 1498

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

poj 1946 Cow Cycl…

这个题目关键是状态的设计 别的就很好想了 dp[i][j][k]表示过了i分钟,第j头牛领头,剩余k能量时能跑的最远距离 然后这个题目还是有些关键点的,就是领头的牛领头跑完之后就可以掉队(这样的策略保证能得到最优解)。 有了这一点才有上面的状态设计。 #include #include #include using namespace std; int n,e,d; int dp[101

yrleep的专栏 608

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

poj 2421 Constructing Roads 并查集+最小生成树

Description There are N villages, which are numbered from 1 to N, and you should build some roads such that every two villages can connect to each other. We say two village A and B are connected, if

渭城朝雨浥轻尘 1061

hdu 1101 Constructing Roads 基础最小生成树★

Constructing Roads Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 24088    Accepted Submission(s): 9249 Problem Description There

爱梦者的心之旅 351

Dijkstra?+spfa+路径的记录

C. Dijkstra? time limit per test 2 seconds memory limit per test 64 megabytes input standard input output standard output You are given a weighted undirected graph. The

u012870383的专栏 658

【Codeforces自我陶醉水题篇~】(差17C code....)

Codeforces17A 题意: 有一种素数会等于两个相邻的素数相加 如果在2~n的范围内有至少k个这样的素数,就YES,否则就NO; 思路: 采用直接打表,后面判断一下就好了。那个预处理素数表还是满赞的~~ 不多说,上code……………. #include<bits/stdc++.h> #include<string.h> usin...

weixin_30896825的博客 3722

poj2412——Constructing Roads(最小生成树变形)

DescriptionThere are N villages, which are numbered from 1 to N, and you should build some roads such that every two villages can connect to each other. We say two village A and B are connected, if and

Beyond the Sora 1414

CodeForces 20C Dijkstra? (最短路)

题目类型  简单题 题目意思 给你一个一元二次方程 A*x*x + B*x + c = 0, 求解的数量 解题方法 1.无穷个解的情况 -> A == 0 && B == 0 && C == 0 2.一个解的情况   -> (A == 0 && B != 0) 或 (A != 0 && B*B - 4 * A * C == 0) 3.两个解的情况  

yunyouxi0's blog 1403

POJ2485 Highways【Kruskal算法+并查集】

HighwaysTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 35689 Accepted: 15997DescriptionThe island nation of Flatopia is perfectly flat. Unfortunately, Flatopia has no public highways. So th...

海岛Blog 805

解题报告2

A - find the mincost route     这个题用Floyd来写需要设置两个二维数组,一个用来存原始的边,另一个用来存Floyd不断更新后的两点之间的当前最短距离,其实求最小环就是在更新过程中,加入一个二重循环判断是否存在一个之前没用过的点k能使i,j联通,并不断寻找满足条件的最小值。 #include            //Floyd求最小环 #include #

Limhhhhh的博客 563

PKU2421 -一道不错的题(用到了并查集,优先队列)

DescriptionThere are N villages, which are numbered from 1 to N, and you should build some roads such that every two villages can connect to each other. We say two village A and B are connected, i

train的专栏 1778

Highways

Highways Problem Description The island nation of Flatopia is perfectly flat. Unfortunately, Flatopia has no public highways. So the traffic is difficult in Flatopia. The Flatopian government is aware of this problem. They're planning to build some highway

konghhhhh的博客 533
上一篇: BUAA-SCSE Training day2
下一篇: BUAA-SCSE Training day9 Reviewing and Learning
屎宝宝
博客等级 码龄15年 15粉丝 57原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址