首页 > 代码库 > ZOJ 3961: Let's Chat
ZOJ 3961: Let's Chat
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 &e : AB)cin >> e; vector<int>BA(2 * BtoA); for (auto &e : 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[j + 1] || AB[i + 1] < BA[j])continue; int cons = min(AB[i + 1], BA[j + 1]) - max(AB[i], BA[j]) + 1; if (cons >= m)fs += cons - m + 1; } cout << fs << endl; } return 0; }
ZOJ 3961: Let's Chat
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。