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

题解: 差分+贪心

Posted by HNYLMS_Tea at 2018-11-26 21:07:58
#include<iostream>
#include<set>
using namespace std;
#define N 10004
#define pii pair<int, int>
int n, m, p, h;
int cha[N];
set<pii> U;
int main() {
	ios::sync_with_stdio(0);
	cin >> n >> p >> h >> m;
	for(int i = 1; i <= m; ++ i) {
		pii IN;
		cin >> IN.first >> IN.second;
		if(IN.first > IN.second) swap(IN.first, IN.second);
		if(U.count(IN)) continue;
		U.insert(IN);
		cha[IN.first + 1] -= 1;
		cha[IN.second] += 1;
	}
	for(int i = 1; i <= n; ++ i) {
		cha[i] += cha[i - 1];
		cout << h + cha[i] << endl;
	}
	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