题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5979

Thanks, TuSimple!

Time Limit: 1 Second Memory Limit: 65536 KB

In the very first sentence of the very first problem, we would like to give our sincere thanks to TuSimple, the sponsor of this contest.

Founded in 2015, TuSimple is a global autonomous trucking solution company headquartered in San Diego, operating self-driving trucks out of Tucson, Arizona. TuSimple is now developing a commercial-ready Level 4 (SAE) fully-autonomous driving solution for the logistics industry. TuSimple’s trucks are the first and only capable of self-driving from depot-to-depot and do so every day for its customers. The company is driven by a mission to increase safety, decrease transportation costs, and reduce carbon emissions.

Nowadays, the trucking industry is currently facing a shortage of 50000 drivers (which is expected to increase to 175000 by the end of 2024) and is approaching a 100 percent turnover rate per year with an average driver age of 49 years old. According to a PwC study, autonomous trucking technologies will reduce annual operating costs for a traditional average long-haul truck by 28 percent in 2025. TuSimple is aiming to transform the 740-billion U.S. trucking industry by cutting costs, reducing carbon emissions and eradicating some of the challenges currently faced by operators.

Building the industry’s first 1000-meter perception system, TuSimple soon becomes the pioneer in the industry. As is known to us, 1000 meters can provide 35 seconds of reaction time on average at highway speeds, enabling the system to make the safest and most efficient driving decisions. Even in the adverse weather conditions, the perception system is still designed to identify objects and obstacles, ensuring the safety of both cargoes, trucks, and passers-by. On the other hand, TuSimple’s latest proprietary AI is now capable of long-distance highway driving and complex surface street driving, which allows fully autonomous deliveries from one depot to another.

Despite their advanced technology and an enormous sense of mission in the industry, TuSimple shares the corporate culture of honesty, realistic, exploration and innovation among their employees from bottom to top, which allows them to attract more and more elites from all expertise to join and get involved. “Here’s why a little-known autonomous trucking company is beating Tesla and Waymo in the race for driverless big rigs”, commented by Business Insider.
The future of trucking is now!

As a manager of TuSimple, you are going to hold a dancing party for both the Development Department and the Marketing Department. There will be gentlemen and ladies in total and they are going to dance in pairs. After a careful investigation, we have already known that for each person, they like to dance with either a taller person or a person with smaller height. To simplify the problem, there are no two persons of the same height and people are only allowed to dance with a person of the opposite gender. In order to reserve a proper dancing field, you must calculate the maximum possible number of pairs of people dancing at the same time.

Input

There are multiple test cases. The first line of the input contains an integer , indicating the number of test cases. For each test case:

The first line contains two integers (1<n,m<100000), indicating the number of gentlemen and ladies.

The second line contains integers a1,a2,a3…an (0 ≤\leq≤ ai < 231-1, ai != ajfor all i != j ), indicating the height of each gentleman.

The third line contains integers b1,b2,b3…bm(0 ≤\leq≤ bi < 231-1, bi != bjfor all i != j ), indicating the height of each lady.

The fourth line contains integers p1,p2,p3…pn(0 ≤\leq≤ pi ≤\leq≤ 1), indicating the preference of each gentleman. If , it means gentleman prefers to dance with a lady of smaller height. Otherwise it indicates he prefers to have a taller dancing partner.

The fifth line contains integers q1,q2,q3…qm(0 ≤\leq≤ qi ≤\leq≤ 1), indicating the preference of each lady. If , it means lady prefers to dance with a gentleman of smaller height. Otherwise it indicates she prefers to have a taller dancing partner.

It’s guaranteed that the sum of and of all test cases will not exceed 106 and ai != bj for all 1≤\leq≤ i ≤\leq≤ n, 1≤\leq≤ j ≤\leq≤ m.

Output

For each test case output one line containing one integer, indicating the answer.

Sample Input

1
3 3
1 2 5
3 4 6
1 1 0
0 0 1
Sample Output

2
Hint

In the sample test case, the 1st gentleman can dance with the 2nd lady, and the 2nd gentleman can dance with the 1st lady.

题目大意:
先输入一个整数t代表输入的测试组数,对于每组测试用例,先输入两个整数n,m,分别代表男士和女士的人数,下面四行,第一行输入的是n名男士的身高,第二行为m名女士的身高,第三行为男士期望他的舞伴(女)身高的标准,0代表他期望他的舞伴比他矮,1代表他期望他的舞伴比他高,第四行代表女士期望她的舞伴(男)身高的标准,同样,0代表希望舞伴比她矮,1代表希望舞伴比她高,问最多能有多少对舞者。

解题思路:
通过题意,我们能知道只有当男士要求为0,女士要求为1时,他们才能做舞伴,同理,男士要求为1,女士要求为0也一样,所以我们可以将男士要求为0的身高存在vector数组a0中,要求为1的存在vector数组a1中,女士同理存在b0,b1中,通过查找a0,b1中与a1,b0中符合题意的对数即可得到结果.

代码:

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <bitset>
#include <set>
#include <utility>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define inf 0x3f3f3f3f
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define lep(i,l,r) for(int i=l;i>=r;i--)
#define ms(arr) memset(arr,0,sizeof(arr))
//priority_queue<int,vector<int> ,greater<int> >q;
const int maxn = (int)1e5 + 5;
const ll mod = 1e9+7;
vector<int> a0,a1,b0,b1;
int a[100100],b[100100];
int main()
{#ifndef ONLINE_JUDGEfreopen("in.txt", "r", stdin);#endif//freopen("out.txt", "w", stdout);ios::sync_with_stdio(0),cin.tie(0);int t;scanf("%d",&t);while(t--) {a0.clear();a1.clear();b0.clear();b1.clear();int n,m;scanf("%d %d",&n,&m);rep(i,1,n) scanf("%d",&a[i]);rep(i,1,m) scanf("%d",&b[i]);int nape;int len1=0,len2=0,len3=0,len4=0;rep(i,1,n) {scanf("%d",&nape);if(nape==0) a0.push_back(a[i]),len1++;if(nape==1) a1.push_back(a[i]),len2++;}rep(i,1,m) {scanf("%d",&nape);if(nape==0) b0.push_back(b[i]),len3++;if(nape==1) b1.push_back(b[i]),len4++;}sort(a0.begin(),a0.end());sort(a1.begin(),a1.end());sort(b0.begin(),b0.end());sort(b1.begin(),b1.end());int ans=0;for(int i=0,j=0;i<len1&&j<len4;) {if(a0[i]>b1[j]) {ans++;i++;j++;}else i++;}for(int i=0,j=0;i<len2&&j<len3;) {if(b0[j]>a1[i]) {ans++;i++;j++;}else j++;}printf("%d\n",ans);}return 0;
}

【模拟】Thanks, TuSimple!相关推荐

  1. springboot实现SSE服务端主动向客户端推送数据,java服务端向客户端推送数据,kotlin模拟客户端向服务端推送数据

    SSE服务端推送 服务器向浏览器推送信息,除了 WebSocket,还有一种方法:Server-Sent Events(以下简称 SSE).本文介绍它的用法. 在很多业务场景中,会涉及到服务端向客户端 ...

  2. curl模拟post请求

    另外可尝试 postman工具 或者用request 直接请求 CURL 发送POST请求curl -header "Content-Type: application/json" ...

  3. flask_模拟请求post,get

    #coding:utf-8 import requestsres = requests.post(url="http://192.168.135.105:8888/",data={ ...

  4. 模拟内存计算如何解决边缘人工智能推理的功耗挑战

    模拟内存计算如何解决边缘人工智能推理的功耗挑战 How analog in-memory computing can solve power challenges of edge AI inferen ...

  5. 为放大器模拟输入模块提供可靠的输入过电压保护

    为放大器模拟输入模块提供可靠的输入过电压保护 Signal Chain Basics #159: Provide robust input overvoltage protection for amp ...

  6. 模拟Servlet本质

    JavaWeb系列教程,持续更新 JavaWeb-Servlet 模拟Servlet本质 使用IDEA开发Servlet程序 Servlet对象的生命周期 适配器(GenericServlet)改造S ...

  7. 2021年大数据Flink(四十):​​​​​​​Flink模拟双十一实时大屏统计

    目录 Flink模拟双十一实时大屏统计 需求 数据 编码步骤: 1.env 2.source 3.transformation 4.使用上面聚合的结果,实现业务需求: 5.execute 参考代码 实 ...

  8. Python:模拟登录、点击和执行 JavaScript 语句案例

    案例一:网站模拟登录 # douban.pyfrom selenium import webdriver from selenium.webdriver.common.keys import Keys ...

  9. 杨老师课堂_Java核心技术下之控制台模拟文件管理器案例

    背景需求介绍: 编写一个模拟文件管理器的程序,实现控制台对文件和文件夹的管理操作. 要求在此程序中: 当用户输入指令 1 时,代表"指定关键字检索文件",此时需要用户输入检索的目录 ...

最新文章

  1. 公司电脑安装操作系统遇到的一个坑
  2. 2021年人工神经网络第一次作业要求
  3. vue-自定义组件传值
  4. WebSocket连接里客户端和服务器端的Socket ID
  5. Redis整合springboot实现集群模式
  6. C# lambda与表达式树
  7. PyTorch 模型训练教程(一)-数据
  8. B/S WEB端条码打印系统 斑马条码打印解决方案
  9. wincc7.5下载安装教程(Win10系统)
  10. WlMAP:突破内网端口转发映射工具
  11. OpenAI公开Dota 2论文:胜率99.4%,「手术」工具连续迁移训练
  12. 加一(python)
  13. 修改C盘下用户的文件名的一些坑!!!
  14. C#测试调用PaddleOCRSharp模块识别图片文字
  15. Jeesite学习(一)
  16. Software Engineering at Google翻译-III-8-Style Guides and Rules(风格指南和规则 )
  17. 人力资源管理平台数据库
  18. BZOJ P2150 部落战争
  19. 自动分割mp3等音频视频文件的脚本
  20. html5画板的使用方法和功能,canvas实现的画板功能

热门文章

  1. (一)Git和Github介绍
  2. 产品精修教程 化妆品精修 数码产品精修 衣服鞋子精修 包包精修
  3. 充满设计感的字体海报设计欣赏
  4. 《失业的程序员》(十八):意外的项目之旅
  5. Excel 2016双击文件打开后是空白,再次双击才能打开(或者通过文件,打开才能打开)...
  6. 求出data为首地址的100D字数组中的最小偶数,并把它存放在AX中,目前只能做出无符号数,有待修改
  7. 【Coursera 计算导论与C语言基础】苹果和虫子+最高分数+最大奇数与最小偶数差+分离整数的各个数位
  8. animate.css+wow.js实现网页动画
  9. Springboot项目使用jdk17启动报错:module java.base does not “opens java.lang.invoke“
  10. 破解微软KB905474正版验证补丁的方法