Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

必须ac(openjudge题解常客)

Posted by 080528lj at 2021-08-25 19:36:37 on Problem 3263
#include<map>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

const int N=10010;
int c[N];
int d[N];
int n,p,h,m;
map<pair<int,int>,bool> existed;
int main()
{
	memset(c,0,sizeof c);
	scanf("%d%d%d%d",&n,&p,&h,&m);
	for(int i=1;i<=m;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		if(a>b) swap(a,b);
		if(existed[make_pair(a,b)])
		{
			continue;
		}
		d[a+1]--;
		d[b]++;
		existed[make_pair(a,b)]=true;
	}
	for(int i=1;i<=n;i++)
	{
		c[i]=c[i-1]+d[i];
	}
	for(int i=1;i<=n;i++)
	{
		printf("%d\n",h+c[i]);
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator