码迷,mamicode.com
首页 > 其他好文 > 详细

ZOJ 3961: Let's Chat

时间:2017-08-07 00:08:02      阅读:232      评论:0      收藏:0      [点我收藏+]

标签:mil   inline   pair   ring   center   back   ble   with   emc   

 

Let‘s Chat

 

///@author Sycamore, ZJNU
///@date 4/22/2017
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <cctype>
#include<fstream>
//#define cin fin
//#define cout fout
//ifstream fin("in.txt");
//ofstream fout("out.txt");
using namespace std;
typedef vector<int> VI;
typedef pair<int, int> PII;
int main()
{
	ios::sync_with_stdio(false);
	int T;
	cin >> T;
	while (T--)
	{
		int n, m, AtoB, BtoA;
		cin >> n >> m >> AtoB >> BtoA;
		vector<int>AB(2 * AtoB);
		for (auto &: AB)cin >> e;
		vector<int>BA(2 * BtoA);
		for (auto &: BA)cin >> e;
		long long fs = 0;
		for (int i = 0; i<2 * AtoB; i += 2)
			for (int j = 0; j <2 * BtoA; j += 2)
			{
				if (AB[i] > BA[+ 1] || AB[+ 1] < BA[j])continue;
				int cons = min(AB[+ 1], BA[+ 1]) - max(AB[i], BA[j]) + 1;
				if (cons >= m)fs += cons - m + 1;
			}
		cout << fs << endl;
	}
	return 0;
}

ZOJ 3961: Let's Chat

标签:mil   inline   pair   ring   center   back   ble   with   emc   

原文地址:http://www.cnblogs.com/zjnu/p/7296325.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!