当前位置:网站首页>9 UAV array
9 UAV array
2022-07-27 11:09:00 【DHU yanghualin (UV allergy)】
9 Drone array
author : Turbo The time limit : 1S chapter : curriculum design
Problem description :
stay 「 challenge round 」 The finale of the opening ceremony 「 Drone array 」 in , Each drone shows a light color . The square array of unmanned aerial vehicles carries out color pattern transformation through two operations :
(1) Adjust the position and layout of the UAV
(2) Switch the light color of the UAV display
Given that both sizes are N*M Two dimensional array of source and target Two color patterns representing the performance of UAV array , Due to the energy consumption of UAV switching light color , Please return to from source To target At least how many UAVs are needed to switch the light color .
Be careful : When adjusting the position layout of UAV, the position of UAV can be changed at will .
Example 1:
Input :
2 2
1 3
5 4
3 1
6 5
Output :1
explain :
First line input 2 2 Indicates that the square matrix is 2 That's ok 2 Column , Followed by two behaviors source, Two more behaviors target.
The best solution is
take [0,1] The drone at moves to [0,0] It's about ;
take [0,0] The drone at moves to [0,1] It's about ;
take [1,0] The drone at moves to [1,1] It's about ;
take [1,1] The drone at moves to [1,0] It's about , Its light color is switched to color number 6 's light ;
So from source To target The minimum number of light switches required is 1.
Example 2:
Input :
2 3
1 2 3
3 4 5
1 3 5
2 3 4
Output :0
explain :
Just adjust the position and layout of the UAV , You can complete the pattern switching . Therefore, there is no need for UAVs to switch colors
Enter description :
Enter several lines :
The first line is two integers n and m,n Represents the number of rows of a two-dimensional array ,m Represents the number of columns of a two-dimensional array .
Then n That's ok , Enter... On each line m It's an integer , representative source Elements of array .
Again n That's ok , Enter... On each line m It's an integer , representative target Elements of array .
Tips :
1 <= n, m <=100
1 <= source[i][j], target[i][j] <=10^4
The output shows that :
Output an integer to represent the result .
Input example :
3 3
4 5 2
2 3 4
7 8 3
3 5 8
3 7 3
7 1 9
Output example :
4
#include<iostream>
using namespace std;
int check(int a[][100], int b[][100],int m,int n)
{
int arr[10000] = {0};
for(int i=0;i<m;i++)
for (int j = 0; j < n; j++)
{
arr[a[i][j]]++;
}
for(int i=0;i<m;i++)
for (int j = 0; j < n; j++)
{
arr[b[i][j]]--;
}
int result = 0;
for (int u = 0; u < 10000; u++)
{
if(arr[u]>0)
result += arr[u];
}
return result;
}
int main()
{
int source[100][100] = { 0 };
int target[100][100] = { 0 };
int m = 0;
int n = 0;
cin >> m;
cin >> n;
for(int i=0;i<m;i++)
for (int u = 0; u < n; u++)
{
cin >> source[i][u];
}
for(int i=0;i<m;i++)
for (int u = 0; u < n; u++)
{
cin >> target[i][u];
}
cout<<check(source, target, m, n);
return 0;
}边栏推荐
- antd中table hover上去的背景色样式修改
- Advanced operation of MySQL data table
- Ansible
- Want to speed up the vit model with one click? Try this open source tool!
- Play with the cluster configuration center and learn about the Taier console
- Internal and external troubles of digital collection NFT "boring ape" bayc
- ASP.NET Core依赖注入之旅:1.理论概念
- 涌现与形态的局部差异和整体差异
- Take you hand-in-hand to develop a complete classic game [Tetris] from scratch, with less than 200 lines of logic.
- Yum source installation
猜你喜欢

一次跨域问题的记录

Advanced operation of MySQL data table

Solved syntaxerror: (Unicode error) 'Unicode scape' codec can't decode bytes in position 2-3: truncated

Yonbuilder enables innovation, and the "golden keyboard Award" of the fourth UFIDA developer competition is open!

The largest square of leetcode (violence solving and dynamic programming solving)

Recruit top talents! The "megeagle creator program" of Kuangshi technology was officially launched

Wilderness search --- search iterations

DNS principle and resolution process

如何组装一个注册中心

An article reveals the NFT strategy of traditional game manufacturers such as Ubisoft
随机推荐
Use of beautifulsoup
How to build a real-time development platform to deeply release the value of enterprise real-time data?
C语言 2:求三数字最大值,求三数字中间值,编写程序步骤
Non progressive phenomena of entropy and morphology
How to create a.Net image with diagnostic tools
Real time development platform construction practice, in-depth release of real-time data value - 04 live broadcast review
Redis+caffeine two-level cache enables smooth access speed
【FPGA教程案例40】通信案例10——基于FPGA的简易OFDM系统verilog实现
MySQL installation (RPM package)
Application scenarios, key technologies and network architecture of communication perception integration
华硕无双,这可能是屏幕最好的平价高刷轻薄笔记本
Delete in MySQL: the difference between delete, drop and truncate
Pyqt5 rapid development and practice 4.2 QWidget
A verification test of the relationship between iteration number and entropy
Recruit top talents! The "megeagle creator program" of Kuangshi technology was officially launched
一次跨域问题的记录
Open source project - taier1.2 release, new workflow, tenant binding simplification and other functions
Solved syntaxerror: (Unicode error) 'Unicode scape' codec can't decode bytes in position 2-3: truncated
开源项目丨Taier1.2版本发布,新增工作流、租户绑定简化等多项功能
Using skills of word